From 2b4f77f2dc6cdc8a6804b1caf8891e182fc87ebb Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Fri, 4 Aug 2017 13:51:54 -0600 Subject: [PATCH] HLSL: Correct use of isPerVertexBuiltIn() to be isClipOrCullDistance(). This allows removal of isPerVertexBuiltIn(). It also leads to removal of addInterstageIoToLinkage(), which is no longer needed. Includes related name improvements. --- Test/baseResults/hlsl.clipdistance-4.vert.out | 2 + Test/baseResults/hlsl.clipdistance-5.vert.out | 2 + Test/baseResults/hlsl.clipdistance-6.vert.out | 2 + Test/baseResults/hlsl.clipdistance-7.vert.out | 2 + Test/baseResults/hlsl.clipdistance-8.vert.out | 2 + Test/baseResults/hlsl.clipdistance-9.vert.out | 2 + Test/baseResults/hlsl.domain.2.tese.out | 4 +- Test/baseResults/hlsl.entry-in.frag.out | 4 +- .../hlsl.gather.basic.dx10.vert.out | 2 + .../hlsl.getdimensions.dx10.vert.out | 2 + .../baseResults/hlsl.load.basic.dx10.vert.out | 2 + .../hlsl.samplegrad.basic.dx10.vert.out | 2 + .../hlsl.samplelevel.basic.dx10.vert.out | 2 + Test/baseResults/hlsl.scalarCast.vert.out | 2 + Test/baseResults/hlsl.semantic.geom.out | 8 ++- Test/baseResults/hlsl.struct.frag.out | 4 +- Test/baseResults/hlsl.struct.split-1.vert.out | 2 + .../hlsl.struct.split.array.geom.out | 28 ++++++---- .../hlsl.struct.split.assign.frag.out | 4 +- .../hlsl.struct.split.call.vert.out | 2 + .../hlsl.struct.split.nested.geom.out | 4 ++ .../hlsl.struct.split.trivial.geom.out | 4 ++ .../hlsl.struct.split.trivial.vert.out | 2 + .../hlsl.structarray.flatten.geom.out | 2 + Test/baseResults/hlsl.structin.vert.out | 2 + glslang/Include/Types.h | 29 +---------- hlsl/hlslParseHelper.cpp | 51 +++++-------------- hlsl/hlslParseHelper.h | 15 +++--- 28 files changed, 94 insertions(+), 95 deletions(-) diff --git a/Test/baseResults/hlsl.clipdistance-4.vert.out b/Test/baseResults/hlsl.clipdistance-4.vert.out index 916f8328..f06d2124 100644 --- a/Test/baseResults/hlsl.clipdistance-4.vert.out +++ b/Test/baseResults/hlsl.clipdistance-4.vert.out @@ -128,6 +128,7 @@ Shader version: 500 0:11 Constant: 0:11 3 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? 'Position' (layout( location=0) in 4-component vector of float) 0:? '@entryPointOutput_ClipRect' ( out 4-element array of float ClipDistance) @@ -264,6 +265,7 @@ Shader version: 500 0:11 Constant: 0:11 3 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? 'Position' (layout( location=0) in 4-component vector of float) 0:? '@entryPointOutput_ClipRect' ( out 4-element array of float ClipDistance) diff --git a/Test/baseResults/hlsl.clipdistance-5.vert.out b/Test/baseResults/hlsl.clipdistance-5.vert.out index 3fd39028..d462850d 100644 --- a/Test/baseResults/hlsl.clipdistance-5.vert.out +++ b/Test/baseResults/hlsl.clipdistance-5.vert.out @@ -152,6 +152,7 @@ Shader version: 500 0:11 Constant: 0:11 1 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? 'Position' (layout( location=0) in 4-component vector of float) 0:? '@entryPointOutput_ClipRect' ( out 4-element array of float ClipDistance) @@ -312,6 +313,7 @@ Shader version: 500 0:11 Constant: 0:11 1 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? 'Position' (layout( location=0) in 4-component vector of float) 0:? '@entryPointOutput_ClipRect' ( out 4-element array of float ClipDistance) diff --git a/Test/baseResults/hlsl.clipdistance-6.vert.out b/Test/baseResults/hlsl.clipdistance-6.vert.out index 9d7375e0..09d4b094 100644 --- a/Test/baseResults/hlsl.clipdistance-6.vert.out +++ b/Test/baseResults/hlsl.clipdistance-6.vert.out @@ -208,6 +208,7 @@ Shader version: 500 0:8 Constant: 0:8 3 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? '@entryPointOutput_clip1' ( out 8-element array of float ClipDistance) @@ -423,6 +424,7 @@ Shader version: 500 0:8 Constant: 0:8 3 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? '@entryPointOutput_clip1' ( out 8-element array of float ClipDistance) // Module Version 10000 diff --git a/Test/baseResults/hlsl.clipdistance-7.vert.out b/Test/baseResults/hlsl.clipdistance-7.vert.out index 01de52a7..d358c7a1 100644 --- a/Test/baseResults/hlsl.clipdistance-7.vert.out +++ b/Test/baseResults/hlsl.clipdistance-7.vert.out @@ -186,6 +186,7 @@ Shader version: 500 0:8 Constant: 0:8 3 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? '@entryPointOutput_clip1' ( out 8-element array of float ClipDistance) @@ -379,6 +380,7 @@ Shader version: 500 0:8 Constant: 0:8 3 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? '@entryPointOutput_clip1' ( out 8-element array of float ClipDistance) // Module Version 10000 diff --git a/Test/baseResults/hlsl.clipdistance-8.vert.out b/Test/baseResults/hlsl.clipdistance-8.vert.out index 20abcb4c..901b3a99 100644 --- a/Test/baseResults/hlsl.clipdistance-8.vert.out +++ b/Test/baseResults/hlsl.clipdistance-8.vert.out @@ -114,6 +114,7 @@ Shader version: 500 0:8 Constant: 0:8 2 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? '@entryPointOutput_clip1' ( out 4-element array of float ClipDistance) @@ -235,6 +236,7 @@ Shader version: 500 0:8 Constant: 0:8 2 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? '@entryPointOutput_clip1' ( out 4-element array of float ClipDistance) // Module Version 10000 diff --git a/Test/baseResults/hlsl.clipdistance-9.vert.out b/Test/baseResults/hlsl.clipdistance-9.vert.out index 1ab0d012..49ae59f2 100644 --- a/Test/baseResults/hlsl.clipdistance-9.vert.out +++ b/Test/baseResults/hlsl.clipdistance-9.vert.out @@ -91,6 +91,7 @@ Shader version: 500 0:7 3 (const int) 0:? 'clip1' ( temp float) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? 'clip0' ( out 4-element array of float ClipDistance) @@ -189,6 +190,7 @@ Shader version: 500 0:7 3 (const int) 0:? 'clip1' ( temp float) 0:? Linker Objects +0:? '@entryPointOutput_Position' ( out 4-component vector of float Position) 0:? 'clip0' ( out 4-element array of float ClipDistance) // Module Version 10000 diff --git a/Test/baseResults/hlsl.domain.2.tese.out b/Test/baseResults/hlsl.domain.2.tese.out index 77683ed5..35c8daa0 100644 --- a/Test/baseResults/hlsl.domain.2.tese.out +++ b/Test/baseResults/hlsl.domain.2.tese.out @@ -138,9 +138,9 @@ triangle order = none 0:? 'norm' (layout( location=1) out 3-component vector of float) 0:? 'i' (layout( location=0) in 3-element array of structure{ temp 4-component vector of float pos, temp 3-component vector of float norm}) 0:? 'tesscoord' ( patch in 3-component vector of float TessCoord) -0:? 'pcf_data' (layout( location=2) patch in structure{ temp float foo}) 0:? 'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter) 0:? 'pcf_data_flInsideTessFactor' ( patch in 2-element array of float TessLevelInner) +0:? 'pcf_data' (layout( location=2) patch in structure{ temp float foo}) Linked tessellation evaluation stage: @@ -285,9 +285,9 @@ triangle order = none 0:? 'norm' (layout( location=1) out 3-component vector of float) 0:? 'i' (layout( location=0) in 3-element array of structure{ temp 4-component vector of float pos, temp 3-component vector of float norm}) 0:? 'tesscoord' ( patch in 3-component vector of float TessCoord) -0:? 'pcf_data' (layout( location=2) patch in structure{ temp float foo}) 0:? 'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter) 0:? 'pcf_data_flInsideTessFactor' ( patch in 2-element array of float TessLevelInner) +0:? 'pcf_data' (layout( location=2) patch in structure{ temp float foo}) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.entry-in.frag.out b/Test/baseResults/hlsl.entry-in.frag.out index 1c3b3cd2..b0cac035 100755 --- a/Test/baseResults/hlsl.entry-in.frag.out +++ b/Test/baseResults/hlsl.entry-in.frag.out @@ -82,8 +82,8 @@ gl_FragCoord origin is upper left 0:? 'i' ( temp structure{ temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2}) 0:? Linker Objects 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) -0:? 'i' (layout( location=0) in structure{ temp 2-component vector of float v, flat temp 2-component vector of int i2}) 0:? 'i_fragCoord' ( in 4-component vector of float FragCoord) +0:? 'i' (layout( location=0) in structure{ temp 2-component vector of float v, flat temp 2-component vector of int i2}) Linked fragment stage: @@ -172,8 +172,8 @@ gl_FragCoord origin is upper left 0:? 'i' ( temp structure{ temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2}) 0:? Linker Objects 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) -0:? 'i' (layout( location=0) in structure{ temp 2-component vector of float v, flat temp 2-component vector of int i2}) 0:? 'i_fragCoord' ( in 4-component vector of float FragCoord) +0:? 'i' (layout( location=0) in structure{ temp 2-component vector of float v, flat temp 2-component vector of int i2}) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.gather.basic.dx10.vert.out b/Test/baseResults/hlsl.gather.basic.dx10.vert.out index f894cf93..34d5daf3 100644 --- a/Test/baseResults/hlsl.gather.basic.dx10.vert.out +++ b/Test/baseResults/hlsl.gather.basic.dx10.vert.out @@ -105,6 +105,7 @@ Shader version: 500 0:? 'g_tTexcdf4' ( uniform textureCube) 0:? 'g_tTexcdi4' ( uniform itextureCube) 0:? 'g_tTexcdu4' ( uniform utextureCube) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) Linked vertex stage: @@ -216,6 +217,7 @@ Shader version: 500 0:? 'g_tTexcdf4' ( uniform textureCube) 0:? 'g_tTexcdi4' ( uniform itextureCube) 0:? 'g_tTexcdu4' ( uniform utextureCube) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.getdimensions.dx10.vert.out b/Test/baseResults/hlsl.getdimensions.dx10.vert.out index bd1e169f..7cce4c9d 100644 --- a/Test/baseResults/hlsl.getdimensions.dx10.vert.out +++ b/Test/baseResults/hlsl.getdimensions.dx10.vert.out @@ -53,6 +53,7 @@ Shader version: 500 0:? Linker Objects 0:? 'g_sSamp' (layout( binding=0) uniform sampler) 0:? 'g_tTex1df4' (layout( binding=0) uniform texture1D) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) Linked vertex stage: @@ -112,6 +113,7 @@ Shader version: 500 0:? Linker Objects 0:? 'g_sSamp' (layout( binding=0) uniform sampler) 0:? 'g_tTex1df4' (layout( binding=0) uniform texture1D) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.load.basic.dx10.vert.out b/Test/baseResults/hlsl.load.basic.dx10.vert.out index 99d0652b..7f5529cc 100644 --- a/Test/baseResults/hlsl.load.basic.dx10.vert.out +++ b/Test/baseResults/hlsl.load.basic.dx10.vert.out @@ -221,6 +221,7 @@ Shader version: 500 0:? 'g_tTexcdi4a' ( uniform itextureCubeArray) 0:? 'g_tTexcdu4a' ( uniform utextureCubeArray) 0:? 'anon@0' (layout( row_major std140) uniform block{ uniform int c1, uniform 2-component vector of int c2, uniform 3-component vector of int c3, uniform 4-component vector of int c4, uniform int o1, uniform 2-component vector of int o2, uniform 3-component vector of int o3, uniform 4-component vector of int o4}) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) Linked vertex stage: @@ -448,6 +449,7 @@ Shader version: 500 0:? 'g_tTexcdi4a' ( uniform itextureCubeArray) 0:? 'g_tTexcdu4a' ( uniform utextureCubeArray) 0:? 'anon@0' (layout( row_major std140) uniform block{ uniform int c1, uniform 2-component vector of int c2, uniform 3-component vector of int c3, uniform 4-component vector of int c4, uniform int o1, uniform 2-component vector of int o2, uniform 3-component vector of int o3, uniform 4-component vector of int o4}) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out b/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out index 4d8a3ca7..eaff3247 100644 --- a/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out +++ b/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out @@ -242,6 +242,7 @@ Shader version: 500 0:? 'g_tTexcdf4' ( uniform textureCube) 0:? 'g_tTexcdi4' ( uniform itextureCube) 0:? 'g_tTexcdu4' ( uniform utextureCube) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) Linked vertex stage: @@ -490,6 +491,7 @@ Shader version: 500 0:? 'g_tTexcdf4' ( uniform textureCube) 0:? 'g_tTexcdi4' ( uniform itextureCube) 0:? 'g_tTexcdu4' ( uniform utextureCube) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out b/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out index 0e430c0f..42449e9f 100644 --- a/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out +++ b/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out @@ -188,6 +188,7 @@ Shader version: 500 0:? 'g_tTexcdf4' ( uniform textureCube) 0:? 'g_tTexcdi4' ( uniform itextureCube) 0:? 'g_tTexcdu4' ( uniform utextureCube) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) Linked vertex stage: @@ -382,6 +383,7 @@ Shader version: 500 0:? 'g_tTexcdf4' ( uniform textureCube) 0:? 'g_tTexcdi4' ( uniform itextureCube) 0:? 'g_tTexcdu4' ( uniform utextureCube) +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.scalarCast.vert.out b/Test/baseResults/hlsl.scalarCast.vert.out index c7ac1429..e1683c07 100755 --- a/Test/baseResults/hlsl.scalarCast.vert.out +++ b/Test/baseResults/hlsl.scalarCast.vert.out @@ -158,6 +158,7 @@ Shader version: 500 0:29 Constant: 0:29 1 (const int) 0:? Linker Objects +0:? '@entryPointOutput_position' ( out 4-component vector of float Position) 0:? '@entryPointOutput' (layout( location=0) out structure{ temp 2-component vector of float texCoord}) @@ -323,6 +324,7 @@ Shader version: 500 0:29 Constant: 0:29 1 (const int) 0:? Linker Objects +0:? '@entryPointOutput_position' ( out 4-component vector of float Position) 0:? '@entryPointOutput' (layout( location=0) out structure{ temp 2-component vector of float texCoord}) // Module Version 10000 diff --git a/Test/baseResults/hlsl.semantic.geom.out b/Test/baseResults/hlsl.semantic.geom.out index 7cb4dea5..5da0e611 100755 --- a/Test/baseResults/hlsl.semantic.geom.out +++ b/Test/baseResults/hlsl.semantic.geom.out @@ -71,10 +71,12 @@ output primitive = line_strip 0:? 'OutputStream' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) 0:? Linker Objects 0:? 'VertexID' (layout( location=0) in 3-element array of uint) +0:? 'OutputStream_clip0' ( out float Position) +0:? 'OutputStream_vpai' ( out uint ViewportIndex) +0:? 'OutputStream_rtai' ( out uint Layer) 0:? 'OutputStream' (layout( location=0) out structure{ temp int ii}) 0:? 'OutputStream_clip0' ( out 1-element array of float ClipDistance) 0:? 'OutputStream_cull0' ( out 1-element array of float CullDistance) -0:? 'OutputStream_vpai' ( out uint ViewportIndex) Linked geometry stage: @@ -152,10 +154,12 @@ output primitive = line_strip 0:? 'OutputStream' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) 0:? Linker Objects 0:? 'VertexID' (layout( location=0) in 3-element array of uint) +0:? 'OutputStream_clip0' ( out float Position) +0:? 'OutputStream_vpai' ( out uint ViewportIndex) +0:? 'OutputStream_rtai' ( out uint Layer) 0:? 'OutputStream' (layout( location=0) out structure{ temp int ii}) 0:? 'OutputStream_clip0' ( out 1-element array of float ClipDistance) 0:? 'OutputStream_cull0' ( out 1-element array of float CullDistance) -0:? 'OutputStream_vpai' ( out uint ViewportIndex) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.struct.frag.out b/Test/baseResults/hlsl.struct.frag.out index 4501f80a..b613b2bd 100755 --- a/Test/baseResults/hlsl.struct.frag.out +++ b/Test/baseResults/hlsl.struct.frag.out @@ -117,8 +117,8 @@ gl_FragCoord origin is upper left 0:? 's2' ( global structure{ temp 4-component vector of float i}) 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? 'input' (layout( location=0) in 4-component vector of float) -0:? 's' (layout( location=1) in structure{ smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, flat temp bool ff2, flat temp bool ff3, temp 4-component vector of float ff4}) 0:? 's_ff1' ( flat in bool Face) +0:? 's' (layout( location=1) in structure{ smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, flat temp bool ff2, flat temp bool ff3, temp 4-component vector of float ff4}) Linked fragment stage: @@ -238,8 +238,8 @@ gl_FragCoord origin is upper left 0:? 's2' ( global structure{ temp 4-component vector of float i}) 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? 'input' (layout( location=0) in 4-component vector of float) -0:? 's' (layout( location=1) in structure{ smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, flat temp bool ff2, flat temp bool ff3, temp 4-component vector of float ff4}) 0:? 's_ff1' ( flat in bool Face) +0:? 's' (layout( location=1) in structure{ smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, flat temp bool ff2, flat temp bool ff3, temp 4-component vector of float ff4}) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.struct.split-1.vert.out b/Test/baseResults/hlsl.struct.split-1.vert.out index db406822..71d051b4 100644 --- a/Test/baseResults/hlsl.struct.split-1.vert.out +++ b/Test/baseResults/hlsl.struct.split-1.vert.out @@ -93,6 +93,7 @@ Shader version: 500 0:17 Constant: 0:17 2 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Pos_out' ( out 4-component vector of float Position) 0:? '@entryPointOutput' (layout( location=0) out structure{ temp int x0_out, temp int x1_out}) 0:? 'x0_in' (layout( location=0) in int) 0:? 'Pos_in' (layout( location=1) in 4-component vector of float) @@ -197,6 +198,7 @@ Shader version: 500 0:17 Constant: 0:17 2 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Pos_out' ( out 4-component vector of float Position) 0:? '@entryPointOutput' (layout( location=0) out structure{ temp int x0_out, temp int x1_out}) 0:? 'x0_in' (layout( location=0) in int) 0:? 'Pos_in' (layout( location=1) in 4-component vector of float) diff --git a/Test/baseResults/hlsl.struct.split.array.geom.out b/Test/baseResults/hlsl.struct.split.array.geom.out index 5c36e2b9..01700865 100644 --- a/Test/baseResults/hlsl.struct.split.array.geom.out +++ b/Test/baseResults/hlsl.struct.split.array.geom.out @@ -72,6 +72,7 @@ output primitive = triangle_strip 0:? 'OutputStream' ( temp structure{ temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID}) 0:? Linker Objects 0:? 'v' (layout( location=0) in 1-element array of uint) +0:? 'OutputStream_Pos' ( out 4-component vector of float Position) 0:? 'OutputStream' (layout( location=0) out structure{ temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID}) @@ -151,16 +152,17 @@ output primitive = triangle_strip 0:? 'OutputStream' ( temp structure{ temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID}) 0:? Linker Objects 0:? 'v' (layout( location=0) in 1-element array of uint) +0:? 'OutputStream_Pos' ( out 4-component vector of float Position) 0:? 'OutputStream' (layout( location=0) out structure{ temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID}) // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 77 +// Id's are bound by 79 Capability Geometry 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint Geometry 4 "main" 66 76 + EntryPoint Geometry 4 "main" 66 75 78 ExecutionMode 4 InputPoints ExecutionMode 4 Invocations 1 ExecutionMode 4 OutputTriangleStrip @@ -184,13 +186,15 @@ output primitive = triangle_strip Name 68 "OutputStream" Name 69 "param" Name 71 "param" - Name 74 "PSInput" - MemberName 74(PSInput) 0 "TexCoord" - MemberName 74(PSInput) 1 "TerrainPos" - MemberName 74(PSInput) 2 "VertexID" - Name 76 "OutputStream" + Name 75 "OutputStream_Pos" + Name 76 "PSInput" + MemberName 76(PSInput) 0 "TexCoord" + MemberName 76(PSInput) 1 "TerrainPos" + MemberName 76(PSInput) 2 "VertexID" + Name 78 "OutputStream" Decorate 66(v) Location 0 - Decorate 76(OutputStream) Location 0 + Decorate 75(OutputStream_Pos) BuiltIn Position + Decorate 78(OutputStream) Location 0 2: TypeVoid 3: TypeFunction 2 6: TypeInt 32 0 @@ -223,9 +227,11 @@ output primitive = triangle_strip 60: 28(int) Constant 1 65: TypePointer Input 8 66(v): 65(ptr) Variable Input - 74(PSInput): TypeStruct 12(fvec2) 13(fvec3) 6(int) - 75: TypePointer Output 74(PSInput) -76(OutputStream): 75(ptr) Variable Output + 74: TypePointer Output 11(fvec4) +75(OutputStream_Pos): 74(ptr) Variable Output + 76(PSInput): TypeStruct 12(fvec2) 13(fvec3) 6(int) + 77: TypePointer Output 76(PSInput) +78(OutputStream): 77(ptr) Variable Output 4(main): 2 Function None 3 5: Label 64(v): 9(ptr) Variable Function diff --git a/Test/baseResults/hlsl.struct.split.assign.frag.out b/Test/baseResults/hlsl.struct.split.assign.frag.out index 7bce9c9a..9a50f770 100644 --- a/Test/baseResults/hlsl.struct.split.assign.frag.out +++ b/Test/baseResults/hlsl.struct.split.assign.frag.out @@ -111,8 +111,8 @@ gl_FragCoord origin is upper left 0:? Linker Objects 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? 'i' (layout( location=0) flat in int) -0:? 'input' (layout( location=1) in 3-element array of structure{ temp float f}) 0:? 'input_pos' ( in 3-element array of 4-component vector of float FragCoord) +0:? 'input' (layout( location=1) in 3-element array of structure{ temp float f}) Linked fragment stage: @@ -230,8 +230,8 @@ gl_FragCoord origin is upper left 0:? Linker Objects 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? 'i' (layout( location=0) flat in int) -0:? 'input' (layout( location=1) in 3-element array of structure{ temp float f}) 0:? 'input_pos' ( in 3-element array of 4-component vector of float FragCoord) +0:? 'input' (layout( location=1) in 3-element array of structure{ temp float f}) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.struct.split.call.vert.out b/Test/baseResults/hlsl.struct.split.call.vert.out index 647f9b49..12fa3855 100644 --- a/Test/baseResults/hlsl.struct.split.call.vert.out +++ b/Test/baseResults/hlsl.struct.split.call.vert.out @@ -103,6 +103,7 @@ Shader version: 500 0:22 Constant: 0:22 2 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Pos_out' ( out 4-component vector of float Position) 0:? '@entryPointOutput' (layout( location=0) out structure{ temp int x0_out, temp int x1_out}) 0:? 'x0_in' (layout( location=0) in int) 0:? 'Pos_in' (layout( location=1) in 4-component vector of float) @@ -216,6 +217,7 @@ Shader version: 500 0:22 Constant: 0:22 2 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Pos_out' ( out 4-component vector of float Position) 0:? '@entryPointOutput' (layout( location=0) out structure{ temp int x0_out, temp int x1_out}) 0:? 'x0_in' (layout( location=0) in int) 0:? 'Pos_in' (layout( location=1) in 4-component vector of float) diff --git a/Test/baseResults/hlsl.struct.split.nested.geom.out b/Test/baseResults/hlsl.struct.split.nested.geom.out index 9cb61ca0..7182fc75 100644 --- a/Test/baseResults/hlsl.struct.split.nested.geom.out +++ b/Test/baseResults/hlsl.struct.split.nested.geom.out @@ -195,7 +195,9 @@ output primitive = triangle_strip 0:? 'tin' ( temp 3-element array of structure{ temp 4-component vector of float pos, temp 2-component vector of float tc}) 0:? 'ts' ( temp structure{ temp structure{ temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{ temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io}) 0:? Linker Objects +0:? 'tin_pos' ( in 3-element array of 4-component vector of float Position) 0:? 'tin' (layout( location=0) in 3-element array of structure{ temp 2-component vector of float tc}) +0:? 'ts_psIn_pos' ( out 4-component vector of float Position) 0:? 'ts' (layout( location=0) out structure{ temp structure{ temp 2-component vector of float tc} psIn, temp structure{ temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io}) @@ -398,7 +400,9 @@ output primitive = triangle_strip 0:? 'tin' ( temp 3-element array of structure{ temp 4-component vector of float pos, temp 2-component vector of float tc}) 0:? 'ts' ( temp structure{ temp structure{ temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{ temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io}) 0:? Linker Objects +0:? 'tin_pos' ( in 3-element array of 4-component vector of float Position) 0:? 'tin' (layout( location=0) in 3-element array of structure{ temp 2-component vector of float tc}) +0:? 'ts_psIn_pos' ( out 4-component vector of float Position) 0:? 'ts' (layout( location=0) out structure{ temp structure{ temp 2-component vector of float tc} psIn, temp structure{ temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io}) // Module Version 10000 diff --git a/Test/baseResults/hlsl.struct.split.trivial.geom.out b/Test/baseResults/hlsl.struct.split.trivial.geom.out index a8eb4465..e55eb033 100644 --- a/Test/baseResults/hlsl.struct.split.trivial.geom.out +++ b/Test/baseResults/hlsl.struct.split.trivial.geom.out @@ -90,6 +90,8 @@ output primitive = triangle_strip 0:? 'i' ( temp 3-element array of structure{ temp 4-component vector of float pos}) 0:? 'ts' ( temp structure{ temp 4-component vector of float pos}) 0:? Linker Objects +0:? 'i_pos' ( in 3-element array of 4-component vector of float Position) +0:? 'ts_pos' ( out 4-component vector of float Position) Linked geometry stage: @@ -186,6 +188,8 @@ output primitive = triangle_strip 0:? 'i' ( temp 3-element array of structure{ temp 4-component vector of float pos}) 0:? 'ts' ( temp structure{ temp 4-component vector of float pos}) 0:? Linker Objects +0:? 'i_pos' ( in 3-element array of 4-component vector of float Position) +0:? 'ts_pos' ( out 4-component vector of float Position) // Module Version 10000 // Generated by (magic number): 80001 diff --git a/Test/baseResults/hlsl.struct.split.trivial.vert.out b/Test/baseResults/hlsl.struct.split.trivial.vert.out index fbff6b90..80192cc4 100644 --- a/Test/baseResults/hlsl.struct.split.trivial.vert.out +++ b/Test/baseResults/hlsl.struct.split.trivial.vert.out @@ -42,6 +42,7 @@ Shader version: 500 0:16 Constant: 0:16 0 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) 0:? 'Pos_in' (layout( location=0) in 4-component vector of float) 0:? 'Pos_loose' (layout( location=1) in 4-component vector of float) @@ -92,6 +93,7 @@ Shader version: 500 0:16 Constant: 0:16 0 (const int) 0:? Linker Objects +0:? '@entryPointOutput_Pos' ( out 4-component vector of float Position) 0:? 'Pos_in' (layout( location=0) in 4-component vector of float) 0:? 'Pos_loose' (layout( location=1) in 4-component vector of float) diff --git a/Test/baseResults/hlsl.structarray.flatten.geom.out b/Test/baseResults/hlsl.structarray.flatten.geom.out index 702f06e1..1d4bfa9a 100644 --- a/Test/baseResults/hlsl.structarray.flatten.geom.out +++ b/Test/baseResults/hlsl.structarray.flatten.geom.out @@ -84,6 +84,7 @@ output primitive = triangle_strip 0:? 'outStream' ( temp structure{ temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv}) 0:? Linker Objects 0:? 'vin' (layout( location=0) in 2-element array of structure{ temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv}) +0:? 'outStream_position' ( out 4-component vector of float Position) 0:? 'outStream' (layout( location=0) out structure{ temp 4-component vector of float color, temp 2-component vector of float uv}) @@ -175,6 +176,7 @@ output primitive = triangle_strip 0:? 'outStream' ( temp structure{ temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv}) 0:? Linker Objects 0:? 'vin' (layout( location=0) in 2-element array of structure{ temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv}) +0:? 'outStream_position' ( out 4-component vector of float Position) 0:? 'outStream' (layout( location=0) out structure{ temp 4-component vector of float color, temp 2-component vector of float uv}) // Module Version 10000 diff --git a/Test/baseResults/hlsl.structin.vert.out b/Test/baseResults/hlsl.structin.vert.out index ff6b37ae..1256eec9 100755 --- a/Test/baseResults/hlsl.structin.vert.out +++ b/Test/baseResults/hlsl.structin.vert.out @@ -150,6 +150,7 @@ Shader version: 500 0:8 Constant: 0:8 2 (const int) 0:? Linker Objects +0:? '@entryPointOutput_coord' ( out 4-component vector of float Position) 0:? '@entryPointOutput' (layout( location=0) out structure{ temp 2-element array of 4-component vector of float m, smooth temp 4-component vector of float b}) 0:? 'd' (layout( location=0) in 4-component vector of float) 0:? 'm[0]' (layout( location=1) in 4-component vector of float) @@ -315,6 +316,7 @@ Shader version: 500 0:8 Constant: 0:8 2 (const int) 0:? Linker Objects +0:? '@entryPointOutput_coord' ( out 4-component vector of float Position) 0:? '@entryPointOutput' (layout( location=0) out structure{ temp 2-element array of 4-component vector of float m, smooth temp 4-component vector of float b}) 0:? 'd' (layout( location=0) in 4-component vector of float) 0:? 'm[0]' (layout( location=1) in 4-component vector of float) diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 18448c86..b94f9152 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -1365,39 +1365,12 @@ public: return false; } virtual bool isOpaque() const { return basicType == EbtSampler || basicType == EbtAtomicUint; } + virtual bool isBuiltIn() const { return getQualifier().builtIn != EbvNone; } // "Image" is a superset of "Subpass" virtual bool isImage() const { return basicType == EbtSampler && getSampler().isImage(); } virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); } - virtual bool isBuiltIn() const { return getQualifier().builtIn != EbvNone; } - - // Return true if this is a per-vertex built-in - virtual bool isPerVertexBuiltIn(EShLanguage language) const - { - if (getQualifier().builtIn == EbvNone || language == EShLangFragment) - return false; - - // Any non-fragment stage - switch (getQualifier().builtIn) { - case EbvPosition: - case EbvPointSize: - case EbvClipDistance: - case EbvCullDistance: -#ifdef NV_EXTENSIONS - case EbvLayer: - case EbvViewportMaskNV: - case EbvSecondaryPositionNV: - case EbvSecondaryViewportMaskNV: - case EbvPositionPerViewNV: - case EbvViewportMaskPerViewNV: -#endif - return true; - default: - return false; - } - } - // return true if this type contains any subtype which satisfies the given predicate. template bool contains(P predicate) const diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index a1e783ba..ceda4051 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -1138,7 +1138,9 @@ TType& HlslParseContext::split(TType& type, TString name, const TType* outerStru fixBuiltInIoType(ioVar->getWritableType()); - interstageBuiltInIo[tInterstageIoData(memberType, *outerStructType)] = ioVar; + splitBuiltIns[tInterstageIoData(memberType, *outerStructType)] = ioVar; + if (!isClipOrCullDistance(ioVar->getType())) + trackLinkage(*ioVar); // Merge qualifier from the user structure mergeQualifiers(ioVar->getWritableType().getQualifier(), outerStructType->getQualifier()); @@ -1388,7 +1390,7 @@ void HlslParseContext::trackLinkage(TSymbol& symbol) TBuiltInVariable biType = symbol.getType().getQualifier().builtIn; if (biType != EbvNone) - builtInLinkageSymbols[biType] = symbol.clone(); + builtInTessLinkageSymbols[biType] = symbol.clone(); TParseContextBase::trackLinkage(symbol); } @@ -1530,32 +1532,6 @@ void HlslParseContext::handleFunctionDeclarator(const TSourceLoc& loc, TFunction error(loc, "function name is redeclaration of existing name", function.getName().c_str(), ""); } -// Finalization step: Add interstage IO variables to the linkage in canonical order. -void HlslParseContext::addInterstageIoToLinkage() -{ - TSourceLoc loc; - loc.init(); - - std::vector io; - io.reserve(interstageBuiltInIo.size()); - - for (auto ioVar = interstageBuiltInIo.begin(); ioVar != interstageBuiltInIo.end(); ++ioVar) - io.push_back(ioVar->first); - - // Our canonical order is the TBuiltInVariable numeric order. - std::sort(io.begin(), io.end()); - - // We have to (potentially) track two IO blocks, one in, one out. E.g, a GS may have a - // PerVertex block in both directions, possibly with different members. - for (int idx = 0; idx < int(io.size()); ++idx) { - TVariable* var = interstageBuiltInIo[io[idx]]; - - // Add the loose interstage IO to the linkage - if (! var->getType().isPerVertexBuiltIn(language)) - trackLinkage(*var); - } -} - // For struct buffers with counters, we must pass the counter buffer as hidden parameter. // This adds the hidden parameter to the parameter list in 'paramNodes' if needed. // Otherwise, it's a no-op @@ -1983,7 +1959,7 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct // an array element as indexed by invocation ID, which we might have to make up. // This is required to match SPIR-V semantics. if (language == EShLangTessControl) { - TIntermSymbol* invocationIdSym = findLinkageSymbol(EbvInvocationId); + TIntermSymbol* invocationIdSym = findTessLinkageSymbol(EbvInvocationId); // If there is no user declared invocation ID, we must make one. if (invocationIdSym == nullptr) { @@ -2532,7 +2508,7 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op if (split && derefType.isBuiltIn()) { // copy from interstage IO built-in if needed const TIntermTyped* outer = isLeft ? outerLeft : outerRight; - subTree = intermediate.addSymbol(*interstageBuiltInIo.find( + subTree = intermediate.addSymbol(*splitBuiltIns.find( HlslParseContext::tInterstageIoData(derefType, outer->getType()))->second); // Arrayness of builtIn symbols isn't handled by the normal recursion: @@ -8859,11 +8835,11 @@ void HlslParseContext::clearUniformInputOutput(TQualifier& qualifier) } -// Return a symbol for the linkage variable of the given TBuiltInVariable type -TIntermSymbol* HlslParseContext::findLinkageSymbol(TBuiltInVariable biType) const +// Return a symbol for the tessellation linkage variable of the given TBuiltInVariable type +TIntermSymbol* HlslParseContext::findTessLinkageSymbol(TBuiltInVariable biType) const { - const auto it = builtInLinkageSymbols.find(biType); - if (it == builtInLinkageSymbols.end()) // if it wasn't declared by the user, return nullptr + const auto it = builtInTessLinkageSymbols.find(biType); + if (it == builtInTessLinkageSymbols.end()) // if it wasn't declared by the user, return nullptr return nullptr; return intermediate.addSymbol(*it->second->getAsVariable()); @@ -8973,7 +8949,7 @@ void HlslParseContext::addPatchConstantInvocation() TFunction& patchConstantFunction = const_cast(*candidateList[0]); const int pcfParamCount = patchConstantFunction.getParamCount(); - TIntermSymbol* invocationIdSym = findLinkageSymbol(EbvInvocationId); + TIntermSymbol* invocationIdSym = findTessLinkageSymbol(EbvInvocationId); TIntermSequence& epBodySeq = entryPointFunctionBody->getAsAggregate()->getSequence(); int outPatchParam = -1; // -1 means there isn't one. @@ -9023,7 +8999,7 @@ void HlslParseContext::addPatchConstantInvocation() // Presently, the only non-built-in we support is InputPatch, which is treated as // a pseudo-built-in. if (biType == EbvInputPatch) { - builtInLinkageSymbols[biType] = inputPatch; + builtInTessLinkageSymbols[biType] = inputPatch; } else if (biType == EbvOutputPatch) { // Nothing... } else { @@ -9069,7 +9045,7 @@ void HlslParseContext::addPatchConstantInvocation() // find which built-in it is const TBuiltInVariable biType = patchConstantFunction[p].getDeclaredBuiltIn(); - inputArg = findLinkageSymbol(biType); + inputArg = findTessLinkageSymbol(biType); if (inputArg == nullptr) { error(loc, "unable to find patch constant function built-in variable", "", ""); @@ -9263,7 +9239,6 @@ void HlslParseContext::finish() removeUnusedStructBufferCounters(); addPatchConstantInvocation(); - addInterstageIoToLinkage(); TParseContextBase::finish(); } diff --git a/hlsl/hlslParseHelper.h b/hlsl/hlslParseHelper.h index ef814097..f4abea33 100755 --- a/hlsl/hlslParseHelper.h +++ b/hlsl/hlslParseHelper.h @@ -260,7 +260,6 @@ protected: TVariable* getSplitIoVar(const TIntermTyped* node) const; TVariable* getSplitIoVar(const TVariable* var) const; TVariable* getSplitIoVar(int id) const; - void addInterstageIoToLinkage(); void addPatchConstantInvocation(); TIntermTyped* makeIntegerIndex(TIntermTyped*); @@ -312,14 +311,14 @@ protected: static bool isClipOrCullDistance(const TQualifier& qual) { return isClipOrCullDistance(qual.builtIn); } static bool isClipOrCullDistance(const TType& type) { return isClipOrCullDistance(type.getQualifier()); } - // Pass through to base class after remembering builtin mappings. + // Pass through to base class after remembering built-in mappings. using TParseContextBase::trackLinkage; void trackLinkage(TSymbol& variable) override; void finish() override; // post-processing // Linkage symbol helpers - TIntermSymbol* findLinkageSymbol(TBuiltInVariable biType) const; + TIntermSymbol* findTessLinkageSymbol(TBuiltInVariable biType) const; // Current state of parsing int annotationNestingLevel; // 0 if outside all annotations @@ -383,14 +382,14 @@ protected: TMap ioTypeMap; // Structure splitting data: - TMap splitIoVars; // variables with the builtin interstage IO removed, indexed by unique ID. + TMap splitIoVars; // variables with the built-in interstage IO removed, indexed by unique ID. // Structuredbuffer shared types. Typically there are only a few. TVector structBufferTypes; TMap structBufferCounter; - // The builtin interstage IO map considers e.g, EvqPosition on input and output separately, so that we + // The built-in interstage IO map considers e.g, EvqPosition on input and output separately, so that we // can build the linkage correctly if position appears on both sides. Otherwise, multiple positions // are considered identical. struct tInterstageIoData { @@ -410,7 +409,7 @@ protected: } }; - TMap interstageBuiltInIo; // individual builtin interstage IO vars, indexed by builtin type. + TMap splitBuiltIns; // split built-ins, indexed by built-in type. TVariable* inputPatch; unsigned int nextInLocation; @@ -421,7 +420,7 @@ protected: TIntermNode* entryPointFunctionBody; TString patchConstantFunctionName; // hull shader patch constant function name, from function level attribute. - TMap builtInLinkageSymbols; // used for tessellation, finding declared builtins + TMap builtInTessLinkageSymbols; // used for tessellation, finding declared built-ins TVector currentTypePrefix; // current scoping prefix for nested structures TVector implicitThisStack; // currently active 'this' variables for nested structures @@ -447,7 +446,7 @@ protected: TVector mipsOperatorMipArg; }; -// This is the prefix we use for builtin methods to avoid namespace collisions with +// This is the prefix we use for built-in methods to avoid namespace collisions with // global scope user functions. // TODO: this would be better as a nonparseable character, but that would // require changing the scanner. -- 2.34.1