Fix #1331: Emit SPV_GOOGLE_hlsl_functionality1 for counters.

It was missing when there were no semantics.
This commit is contained in:
John Kessenich 2018-04-05 19:35:38 -06:00
parent 7f0bcfd8d8
commit f52b63812a
4 changed files with 76 additions and 1 deletions

View File

@ -1279,7 +1279,8 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
id = getSymbolId(it->second);
if (id != spv::NoResult) {
spv::Id counterId = getSymbolId(symbol);
if (counterId != spv::NoResult)
if (counterId != spv::NoResult) {
builder.addExtension("SPV_GOOGLE_hlsl_functionality1");
builder.addDecorationId(id, spv::DecorationHlslCounterBufferGOOGLE, counterId);
}
}
@ -1287,6 +1288,7 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
}
}
}
}
}
bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::TIntermBinary* node)

View File

@ -0,0 +1,63 @@
hlsl.noSemantic.functionality1.comp
// Module Version 10000
// Generated by (magic number): 80006
// Id's are bound by 31
Capability Shader
Extension "SPV_GOOGLE_hlsl_functionality1"
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 "Buf"
MemberName 11(Buf) 0 "@data"
Name 13 "Buf"
Name 16 "Buf@count"
MemberName 16(Buf@count) 0 "@count"
Name 18 "Buf@count"
Decorate 10 ArrayStride 16
MemberDecorate 11(Buf) 0 Offset 0
Decorate 11(Buf) BufferBlock
Decorate 13(Buf) DescriptorSet 0
Decorate 13(Buf) Binding 0
MemberDecorate 16(Buf@count) 0 Offset 0
Decorate 16(Buf@count) BufferBlock
Decorate 18(Buf@count) DescriptorSet 0
DecorateId 13(Buf) DecorationHlslCounterBufferGOOGLE 18(Buf@count)
2: TypeVoid
3: TypeFunction 2
8: TypeFloat 32
9: TypeVector 8(float) 4
10: TypeRuntimeArray 9(fvec4)
11(Buf): TypeStruct 10
12: TypePointer Uniform 11(Buf)
13(Buf): 12(ptr) Variable Uniform
14: TypeInt 32 1
15: 14(int) Constant 0
16(Buf@count): TypeStruct 14(int)
17: TypePointer Uniform 16(Buf@count)
18(Buf@count): 17(ptr) Variable Uniform
19: TypePointer Uniform 14(int)
21: 14(int) Constant 1
22: TypeInt 32 0
23: 22(int) Constant 1
24: 22(int) Constant 0
26: 8(float) Constant 1065353216
27: 9(fvec4) ConstantComposite 26 26 26 26
28: TypePointer Uniform 9(fvec4)
4(main): 2 Function None 3
5: Label
30: 2 FunctionCall 6(@main()
Return
FunctionEnd
6(@main(): 2 Function None 3
7: Label
20: 19(ptr) AccessChain 18(Buf@count) 15
25: 22(int) AtomicIAdd 20 23 24 21
29: 28(ptr) AccessChain 13(Buf) 15 25
Store 29 27
Return
FunctionEnd

View File

@ -0,0 +1,7 @@
AppendStructuredBuffer<float4> Buf : register(u0);
[numthreads(1, 1, 1)]
void main()
{
Buf.Append(1.0f.xxxx);
}

View File

@ -207,6 +207,9 @@ diff -b $BASEDIR/hlsl.y-negate-3.vert.out $TARGETDIR/hlsl.y-negate-3.vert.out ||
$EXE -H -e main -D -Od -fhlsl_functionality1 hlsl.structbuffer.incdec.frag > \
$TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out
diff -b $BASEDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out $TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out || HASERROR=1
$EXE -H -e main -D -Od -fhlsl_functionality1 hlsl.noSemantic.functionality1.comp > \
$TARGETDIR/hlsl.noSemantic.functionality1.comp.out
diff -b $BASEDIR/hlsl.noSemantic.functionality1.comp.out $TARGETDIR/hlsl.noSemantic.functionality1.comp.out || HASERROR=1
#
# Final checking