diff --git a/Test/baseResults/hlsl.fraggeom.frag.out b/Test/baseResults/hlsl.fraggeom.frag.out new file mode 100644 index 000000000..7cb85cd5a --- /dev/null +++ b/Test/baseResults/hlsl.fraggeom.frag.out @@ -0,0 +1,112 @@ +hlsl.fraggeom.frag +Shader version: 500 +gl_FragCoord origin is upper left +0:? Sequence +0:9 Function Definition: GS_Draw(struct-myVertex-vf41;struct-myVertex-vf41; ( temp void) +0:9 Function Parameters: +0:9 'IN' ( in structure{ temp 4-component vector of float pos}) +0:9 'OutputStream' ( out structure{ temp 4-component vector of float pos}) +0:? Sequence +0:10 Constant: +0:10 0.000000 +0:11 Constant: +0:11 0.000000 +0:15 Function Definition: @main( ( temp 4-component vector of float) +0:15 Function Parameters: +0:? Sequence +0:16 Branch: Return with expression +0:16 Constant: +0:16 0.000000 +0:16 0.000000 +0:16 0.000000 +0:16 0.000000 +0:15 Function Definition: main( ( temp void) +0:15 Function Parameters: +0:? Sequence +0:15 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:15 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + + +Linked fragment stage: + + +Shader version: 500 +gl_FragCoord origin is upper left +0:? Sequence +0:9 Function Definition: GS_Draw(struct-myVertex-vf41;struct-myVertex-vf41; ( temp void) +0:9 Function Parameters: +0:9 'IN' ( in structure{ temp 4-component vector of float pos}) +0:9 'OutputStream' ( out structure{ temp 4-component vector of float pos}) +0:? Sequence +0:10 Constant: +0:10 0.000000 +0:11 Constant: +0:11 0.000000 +0:15 Function Definition: @main( ( temp 4-component vector of float) +0:15 Function Parameters: +0:? Sequence +0:16 Branch: Return with expression +0:16 Constant: +0:16 0.000000 +0:16 0.000000 +0:16 0.000000 +0:16 0.000000 +0:15 Function Definition: main( ( temp void) +0:15 Function Parameters: +0:? Sequence +0:15 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:15 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 25 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 23 + ExecutionMode 4 OriginUpperLeft + Source HLSL 500 + Name 4 "main" + Name 8 "myVertex" + MemberName 8(myVertex) 0 "pos" + Name 13 "GS_Draw(struct-myVertex-vf41;struct-myVertex-vf41;" + Name 11 "IN" + Name 12 "OutputStream" + Name 16 "@main(" + Name 23 "@entryPointOutput" + Decorate 23(@entryPointOutput) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8(myVertex): TypeStruct 7(fvec4) + 9: TypePointer Function 8(myVertex) + 10: TypeFunction 2 9(ptr) 9(ptr) + 15: TypeFunction 7(fvec4) + 18: 6(float) Constant 0 + 19: 7(fvec4) ConstantComposite 18 18 18 18 + 22: TypePointer Output 7(fvec4) +23(@entryPointOutput): 22(ptr) Variable Output + 4(main): 2 Function None 3 + 5: Label + 24: 7(fvec4) FunctionCall 16(@main() + Store 23(@entryPointOutput) 24 + Return + FunctionEnd +13(GS_Draw(struct-myVertex-vf41;struct-myVertex-vf41;): 2 Function None 10 + 11(IN): 9(ptr) FunctionParameter +12(OutputStream): 9(ptr) FunctionParameter + 14: Label + Return + FunctionEnd + 16(@main(): 7(fvec4) Function None 15 + 17: Label + ReturnValue 19 + FunctionEnd diff --git a/Test/hlsl.fraggeom.frag b/Test/hlsl.fraggeom.frag new file mode 100644 index 000000000..5592e857a --- /dev/null +++ b/Test/hlsl.fraggeom.frag @@ -0,0 +1,17 @@ +// test geometry shader in fragment shader. GS attributes should be successfully ignored. + +struct myVertex { + float4 pos : SV_Position; +}; + +[maxvertexcount(1)] +void GS_Draw(point myVertex IN, inout PointStream OutputStream) +{ + OutputStream.Append(IN); + OutputStream.RestartStrip(); +} + +float4 main() : SV_TARGET +{ + return 0; +} diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index c53e1e55c..7dbed5e0b 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -109,6 +109,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.emptystruct.init.vert", "main"}, {"hlsl.entry-in.frag", "PixelShaderFunction"}, {"hlsl.entry-out.frag", "PixelShaderFunction"}, + {"hlsl.fraggeom.frag", "main"}, {"hlsl.float1.frag", "PixelShaderFunction"}, {"hlsl.float4.frag", "PixelShaderFunction"}, {"hlsl.flatten.return.frag", "main"}, diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 7b4346d70..54be46766 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -3660,6 +3660,12 @@ void HlslParseContext::decomposeGeometryMethods(const TSourceLoc& loc, TIntermTy switch (op) { case EOpMethodAppend: if (argAggregate) { + // Don't emit these for non-GS stage, since we won't have the gsStreamOutput symbol. + if (language != EShLangGeometry) { + node = nullptr; + return; + } + TIntermAggregate* sequence = nullptr; TIntermAggregate* emit = new TIntermAggregate(EOpEmitVertex); @@ -3689,6 +3695,12 @@ void HlslParseContext::decomposeGeometryMethods(const TSourceLoc& loc, TIntermTy case EOpMethodRestartStrip: { + // Don't emit these for non-GS stage, since we won't have the gsStreamOutput symbol. + if (language != EShLangGeometry) { + node = nullptr; + return; + } + TIntermAggregate* cut = new TIntermAggregate(EOpEndPrimitive); cut->setLoc(loc); cut->setType(TType(EbtVoid));