From 0a82611174e0e1b290702ad57301f873e883f519 Mon Sep 17 00:00:00 2001 From: Sebastian Tafuri Date: Fri, 6 Oct 2017 22:45:00 +0200 Subject: [PATCH 1/3] Only track variables in the global scope --- hlsl/hlslParseHelper.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 615776c1..58eb64c9 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -8289,8 +8289,11 @@ void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TS return; } - // Save it in the AST for linker use. - trackLinkage(variable); + if(symbolTable.atGlobalLevel()) + { + // Save it in the AST for linker use. + trackLinkage(variable); + } } // From 5133b108da38757cb89e0845869e9b614c7c46f8 Mon Sep 17 00:00:00 2001 From: Sebastian Tafuri Date: Sat, 7 Oct 2017 00:12:50 +0200 Subject: [PATCH 2/3] Fixed formatting --- hlsl/hlslParseHelper.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 58eb64c9..8d2d265d 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -8289,11 +8289,9 @@ void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TS return; } - if(symbolTable.atGlobalLevel()) - { - // Save it in the AST for linker use. - trackLinkage(variable); - } + // Save it in the AST for linker use. + if (symbolTable.atGlobalLevel()) + trackLinkage(variable); } // From 4f6865f406d38eebb42ebdba6a3c812331439623 Mon Sep 17 00:00:00 2001 From: Sebastian Tafuri Date: Sat, 7 Oct 2017 00:47:54 +0200 Subject: [PATCH 3/3] Added test for local structured buffer variable --- .../hlsl.localStructuredBuffer.comp.out | 64 +++++++++++++++++++ Test/hlsl.localStructuredBuffer.comp | 4 ++ gtests/Hlsl.FromFile.cpp | 1 + 3 files changed, 69 insertions(+) create mode 100644 Test/baseResults/hlsl.localStructuredBuffer.comp.out create mode 100644 Test/hlsl.localStructuredBuffer.comp diff --git a/Test/baseResults/hlsl.localStructuredBuffer.comp.out b/Test/baseResults/hlsl.localStructuredBuffer.comp.out new file mode 100644 index 00000000..e5e028f4 --- /dev/null +++ b/Test/baseResults/hlsl.localStructuredBuffer.comp.out @@ -0,0 +1,64 @@ +hlsl.localStructuredBuffer.comp +Shader version: 500 +local_size = (1, 1, 1) +0:? Sequence +0:2 Function Definition: @main( ( temp void) +0:2 Function Parameters: +0:2 Function Definition: main( ( temp void) +0:2 Function Parameters: +0:? Sequence +0:2 Function Call: @main( ( temp void) +0:? Linker Objects +0:? 'srt0' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of uint @data}) + + +Linked compute stage: + + +Shader version: 500 +local_size = (1, 1, 1) +0:? Sequence +0:2 Function Definition: @main( ( temp void) +0:2 Function Parameters: +0:2 Function Definition: main( ( temp void) +0:2 Function Parameters: +0:? Sequence +0:2 Function Call: @main( ( temp void) +0:? Linker Objects +0:? 'srt0' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of uint @data}) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 14 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint GLCompute 4 "main" + ExecutionMode 4 LocalSize 1 1 1 + Source HLSL 500 + Name 4 "main" + Name 6 "@main(" + Name 11 "srt0" + MemberName 11(srt0) 0 "@data" + Name 13 "srt0" + Decorate 10 ArrayStride 4 + MemberDecorate 11(srt0) 0 Offset 0 + Decorate 11(srt0) BufferBlock + Decorate 13(srt0) DescriptorSet 0 + 2: TypeVoid + 3: TypeFunction 2 + 9: TypeInt 32 0 + 10: TypeRuntimeArray 9(int) + 11(srt0): TypeStruct 10 + 12: TypePointer Uniform 11(srt0) + 13(srt0): 12(ptr) Variable Uniform + 4(main): 2 Function None 3 + 5: Label + 8: 2 FunctionCall 6(@main() + Return + FunctionEnd + 6(@main(): 2 Function None 3 + 7: Label + Return + FunctionEnd diff --git a/Test/hlsl.localStructuredBuffer.comp b/Test/hlsl.localStructuredBuffer.comp new file mode 100644 index 00000000..34e06e00 --- /dev/null +++ b/Test/hlsl.localStructuredBuffer.comp @@ -0,0 +1,4 @@ +RWStructuredBuffer srt0; +void main() { + RWStructuredBuffer srt0Local = srt0; +} \ No newline at end of file diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index 97101af8..f9511679 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -219,6 +219,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.load.rwtexture.array.dx10.frag", "main"}, {"hlsl.load.offset.dx10.frag", "main"}, {"hlsl.load.offsetarray.dx10.frag", "main"}, + {"hlsl.localStructuredBuffer.comp", "main"}, {"hlsl.logical.binary.frag", "main"}, {"hlsl.logical.binary.vec.frag", "main"}, {"hlsl.logicalConvert.frag", "main"},