HLSL: force textures to shadow modes from combined samplers

Texture shadow mode must match the state of the sampler they are
combined with.  This change does that, both for the AST and the
symbol table.  Note that the texture cannot easily be *created*
the right way, because this may not be known at that time.  Instead,
the texture is subsequently patched.

This cannot work if a single texture is used with both a shadow and
non-shadow sampler, so that case is detected and generates an error.
This is permitted by the HLSL language, however.  See #1073 discussion.

Fixed one test source that was using a texture with both shadow and
non-shadow samplers.
This commit is contained in:
LoopDawg
2017-09-27 09:12:51 -06:00
parent f21c173a05
commit 195f584e09
13 changed files with 2358 additions and 2366 deletions

View File

@@ -1,47 +1,48 @@
hlsl.samplecmp.negative.frag
ERROR: 0:9: '' : expected: SamplerComparisonState
ERROR: 0:10: '' : expected: SamplerComparisonState
ERROR: 1 compilation errors. No code generated.
Shader version: 500
gl_FragCoord origin is upper left
ERROR: node is still EOpNull!
0:7 Function Definition: @main( ( temp 4-component vector of float)
0:7 Function Parameters:
0:8 Function Definition: @main( ( temp 4-component vector of float)
0:8 Function Parameters:
0:? Sequence
0:8 texture ( temp float)
0:8 Construct combined texture-sampler ( temp sampler2DShadow)
0:8 'g_shadowTex' ( uniform texture2D)
0:8 'g_shadowSamplerComp' ( uniform sampler)
0:8 Construct vec3 ( temp 3-component vector of float)
0:9 texture ( temp float)
0:9 Construct combined texture-sampler ( temp sampler2DShadow)
0:9 'g_shadowTex' ( uniform texture2DShadow)
0:9 'g_shadowSamplerComp' ( uniform sampler)
0:9 Construct vec3 ( temp 3-component vector of float)
0:? Constant:
0:? 0.000000
0:? 0.000000
0:8 Constant:
0:8 0.000000
0:9 ERROR: Bad aggregation op
0:9 Constant:
0:9 0.000000
0:10 ERROR: Bad aggregation op
( temp float)
0:9 'g_shadowTex' ( uniform texture2D)
0:9 'g_shadowSampler' ( uniform sampler)
0:10 'g_nonShadowTex' ( uniform texture2D)
0:10 'g_shadowSampler' ( uniform sampler)
0:? Constant:
0:? 0.000000
0:? 0.000000
0:9 Constant:
0:9 0.000000
0:11 Branch: Return with expression
0:11 Constant:
0:11 0.000000
0:11 0.000000
0:11 0.000000
0:11 0.000000
0:7 Function Definition: main( ( temp void)
0:7 Function Parameters:
0:10 Constant:
0:10 0.000000
0:12 Branch: Return with expression
0:12 Constant:
0:12 0.000000
0:12 0.000000
0:12 0.000000
0:12 0.000000
0:8 Function Definition: main( ( temp void)
0:8 Function Parameters:
0:? Sequence
0:7 move second child to first child ( temp 4-component vector of float)
0:8 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:7 Function Call: @main( ( temp 4-component vector of float)
0:8 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects
0:? 'g_shadowTex' ( uniform texture2D)
0:? 'g_nonShadowTex' ( uniform texture2D)
0:? 'g_shadowTex' ( uniform texture2DShadow)
0:? 'g_shadowSampler' ( uniform sampler)
0:? 'g_shadowSamplerComp' ( uniform sampler)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
@@ -53,42 +54,43 @@ Linked fragment stage:
Shader version: 500
gl_FragCoord origin is upper left
ERROR: node is still EOpNull!
0:7 Function Definition: @main( ( temp 4-component vector of float)
0:7 Function Parameters:
0:8 Function Definition: @main( ( temp 4-component vector of float)
0:8 Function Parameters:
0:? Sequence
0:8 texture ( temp float)
0:8 Construct combined texture-sampler ( temp sampler2DShadow)
0:8 'g_shadowTex' ( uniform texture2D)
0:8 'g_shadowSamplerComp' ( uniform sampler)
0:8 Construct vec3 ( temp 3-component vector of float)
0:9 texture ( temp float)
0:9 Construct combined texture-sampler ( temp sampler2DShadow)
0:9 'g_shadowTex' ( uniform texture2DShadow)
0:9 'g_shadowSamplerComp' ( uniform sampler)
0:9 Construct vec3 ( temp 3-component vector of float)
0:? Constant:
0:? 0.000000
0:? 0.000000
0:8 Constant:
0:8 0.000000
0:9 ERROR: Bad aggregation op
0:9 Constant:
0:9 0.000000
0:10 ERROR: Bad aggregation op
( temp float)
0:9 'g_shadowTex' ( uniform texture2D)
0:9 'g_shadowSampler' ( uniform sampler)
0:10 'g_nonShadowTex' ( uniform texture2D)
0:10 'g_shadowSampler' ( uniform sampler)
0:? Constant:
0:? 0.000000
0:? 0.000000
0:9 Constant:
0:9 0.000000
0:11 Branch: Return with expression
0:11 Constant:
0:11 0.000000
0:11 0.000000
0:11 0.000000
0:11 0.000000
0:7 Function Definition: main( ( temp void)
0:7 Function Parameters:
0:10 Constant:
0:10 0.000000
0:12 Branch: Return with expression
0:12 Constant:
0:12 0.000000
0:12 0.000000
0:12 0.000000
0:12 0.000000
0:8 Function Definition: main( ( temp void)
0:8 Function Parameters:
0:? Sequence
0:7 move second child to first child ( temp 4-component vector of float)
0:8 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:7 Function Call: @main( ( temp 4-component vector of float)
0:8 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects
0:? 'g_shadowTex' ( uniform texture2D)
0:? 'g_nonShadowTex' ( uniform texture2D)
0:? 'g_shadowTex' ( uniform texture2DShadow)
0:? 'g_shadowSampler' ( uniform sampler)
0:? 'g_shadowSamplerComp' ( uniform sampler)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)