summaryrefslogtreecommitdiffstats
path: root/Graphics/GLSLTools
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-11-16 16:05:25 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-11-16 16:05:25 +0000
commit937087a641ca21f0bc25121c125fa419eee38035 (patch)
treea73cabffe062d1a45670d3e5623a4dfe9bd3817e /Graphics/GLSLTools
parentFixed handling constant buffers in SPIRV bytecode produced by DXC (fixed http... (diff)
downloadDiligentCore-937087a641ca21f0bc25121c125fa419eee38035.tar.gz
DiligentCore-937087a641ca21f0bc25121c125fa419eee38035.zip
Updated comment
Diffstat (limited to 'Graphics/GLSLTools')
-rw-r--r--Graphics/GLSLTools/src/SPIRVShaderResources.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
index 86261e5b..fc881893 100644
--- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
+++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
@@ -112,19 +112,34 @@ static spv::ExecutionModel ShaderTypeToExecutionModel(SHADER_TYPE ShaderType)
const std::string& GetUBName(spirv_cross::Compiler& Compiler, const spirv_cross::Resource& UB, const spirv_cross::ParsedIR::Source& IRSource)
{
// Consider the following HLSL constant buffer:
+ //
// cbuffer Constants
// {
// float4x4 g_WorldViewProj;
// };
//
- // Reflecion information for this constant buffer extracted from the byte code produced
- // by glslang and dxc looks as follows:
+ // glslang emits SPIRV as if the following GLSL was written:
+ //
+ // uniform Constants // UB.name
+ // {
+ // float4x4 g_WorldViewProj;
+ // }; // no instance name
+ //
+ // DXC emits the byte code that corresponds to the following GLSL:
//
- // glslang DXC
- // UB.name "Constants" "type_Constants"
- // Compiler.get_name(UB.id) "" "Constants"
+ // uniform type_Constants // UB.name
+ // {
+ // float4x4 g_WorldViewProj;
+ // }Constants; // get_name(UB.id)
+ //
+ //
+ // | glslang | DXC
+ // -------------------------------------------------------------------
+ // UB.name | "Constants" | "type_Constants"
+ // Compiler.get_name(UB.id) | "" | "Constants"
//
- // For byte code produced from GLSL, we must always use UB.name
+ // Note that for the byte code produced from GLSL, we must always
+ // use UB.name even if the instance name is present
const auto& instance_name = Compiler.get_name(UB.id);
return (IRSource.hlsl && !instance_name.empty()) ? instance_name : UB.name;