diff options
| author | Yong He <yonghe@outlook.com> | 2024-10-09 12:18:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-09 12:18:19 -0700 |
| commit | b8aab84e2c4c3e6d91d75ffcebfcc2f6e84da01c (patch) | |
| tree | 79207c563a1142bad97547c873d73d084f8748b6 | |
| parent | 1bbc421a663bd494cc1a4dd097852553049cc1d5 (diff) | |
Use user defined type name in glsl buffer declarations. (#5242)
| -rw-r--r-- | source/slang/slang-emit-glsl.cpp | 7 | ||||
| -rw-r--r-- | tests/bindings/hlsl-to-vulkan-global-binding.hlsl | 2 | ||||
| -rw-r--r-- | tests/cross-compile/texture-load.slang | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index c0a0bf3db..ca5569602 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -453,10 +453,9 @@ void GLSLSourceEmitter::_emitGLSLParameterGroup(IRGlobalParam* varDecl, IRUnifor m_writer->emit(") uniform "); } - // Generate a dummy name for the block - m_writer->emit("_S"); - m_writer->emit(m_uniqueIDCounter++); - + // Generate a name for the block. + m_writer->emit(_generateUniqueName( + (StringBuilder() << "block_" << getUnmangledName(type->getElementType()).getUnownedSlice()).getUnownedSlice())); auto elementType = type->getElementType(); auto structType = as<IRStructType>(elementType); diff --git a/tests/bindings/hlsl-to-vulkan-global-binding.hlsl b/tests/bindings/hlsl-to-vulkan-global-binding.hlsl index ebccaab18..ef9995e8f 100644 --- a/tests/bindings/hlsl-to-vulkan-global-binding.hlsl +++ b/tests/bindings/hlsl-to-vulkan-global-binding.hlsl @@ -5,7 +5,7 @@ // CHECK: layout(binding = 1) // CHECK: uniform sampler sampler_0; // CHECK: layout(binding = 5, set = 9) -// CHECK: layout(std140) uniform _S1 +// CHECK: layout(std140) uniform block_ uniform int a; uniform float b; diff --git a/tests/cross-compile/texture-load.slang b/tests/cross-compile/texture-load.slang index 71f22b13a..167db7831 100644 --- a/tests/cross-compile/texture-load.slang +++ b/tests/cross-compile/texture-load.slang @@ -3,7 +3,7 @@ // Confirm that texture `Load` operations yield the // expected type when compiled to SPIR-V. -//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage compute +//TEST:SIMPLE(filecheck=CHECK):-target spirv-assembly -entry main -stage compute -emit-spirv-via-glsl Texture2D<float2> inputTexture; RWTexture2D<float2> outputTexture; @@ -13,6 +13,8 @@ cbuffer C int2 pos; } +// CHECK: OpImageWrite + [numthreads(16, 16, 1)] void main(uint2 pixelIndex : SV_DispatchThreadID) { |
