HLSL: use LOD form of ImageQuerySize when needed.

The non-LOD form of image size query is prohibited in certain cases:
see the OpImageQuerySize and OpImageQuerySizeLod sections of the SPIR-V
spec for details.  Sometimes we were generating the non-LOD form when
we should have been using the LOD form.  Sometimes the LOD form is required
even if the underlying HLSL query did not supply a MIP level itself,
in which case level 0 is now queried.
This commit is contained in:
steve-lunarg 2017-03-07 19:30:25 -07:00
parent 057df2935a
commit 3ce4536ac8
5 changed files with 1004 additions and 892 deletions

View file

@ -9,6 +9,8 @@ Shader version: 450
0:21 'sizeQueryTemp' (temp uint)
0:21 textureSize (temp uint)
0:21 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:21 Constant:
0:21 0 (const int)
0:21 move second child to first child (temp uint)
0:21 'WidthU' (temp uint)
0:21 'sizeQueryTemp' (temp uint)
@ -66,6 +68,8 @@ Shader version: 450
0:21 'sizeQueryTemp' (temp uint)
0:21 textureSize (temp uint)
0:21 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:21 Constant:
0:21 0 (const int)
0:21 move second child to first child (temp uint)
0:21 'WidthU' (temp uint)
0:21 'sizeQueryTemp' (temp uint)
@ -125,10 +129,10 @@ Shader version: 450
Name 10 "@main("
Name 14 "sizeQueryTemp"
Name 17 "g_tTex1df4"
Name 21 "WidthU"
Name 23 "sizeQueryTemp"
Name 28 "NumberOfLevelsU"
Name 32 "vsout"
Name 22 "WidthU"
Name 24 "sizeQueryTemp"
Name 29 "NumberOfLevelsU"
Name 33 "vsout"
Name 42 "@entryPointOutput_Pos"
Name 47 "g_sSamp"
Decorate 17(g_tTex1df4) DescriptorSet 0
@ -148,9 +152,9 @@ Shader version: 450
16: TypePointer UniformConstant 15
17(g_tTex1df4): 16(ptr) Variable UniformConstant
19: TypeInt 32 1
25: 12(int) Constant 6
31: TypePointer Function 8(VS_OUTPUT)
33: 19(int) Constant 0
20: 19(int) Constant 0
26: 12(int) Constant 6
32: TypePointer Function 8(VS_OUTPUT)
34: 6(float) Constant 0
35: 7(fvec4) ConstantComposite 34 34 34 34
36: TypePointer Function 7(fvec4)
@ -169,25 +173,25 @@ Shader version: 450
10(@main():8(VS_OUTPUT) Function None 9
11: Label
14(sizeQueryTemp): 13(ptr) Variable Function
21(WidthU): 13(ptr) Variable Function
23(sizeQueryTemp): 13(ptr) Variable Function
28(NumberOfLevelsU): 13(ptr) Variable Function
32(vsout): 31(ptr) Variable Function
22(WidthU): 13(ptr) Variable Function
24(sizeQueryTemp): 13(ptr) Variable Function
29(NumberOfLevelsU): 13(ptr) Variable Function
33(vsout): 32(ptr) Variable Function
18: 15 Load 17(g_tTex1df4)
20: 19(int) ImageQuerySize 18
Store 14(sizeQueryTemp) 20
22: 12(int) Load 14(sizeQueryTemp)
Store 21(WidthU) 22
24: 15 Load 17(g_tTex1df4)
26: 19(int) ImageQuerySizeLod 24 25
Store 23(sizeQueryTemp) 26
27: 12(int) Load 23(sizeQueryTemp)
Store 21(WidthU) 27
29: 15 Load 17(g_tTex1df4)
30: 19(int) ImageQueryLevels 29
Store 28(NumberOfLevelsU) 30
37: 36(ptr) AccessChain 32(vsout) 33
21: 19(int) ImageQuerySizeLod 18 20
Store 14(sizeQueryTemp) 21
23: 12(int) Load 14(sizeQueryTemp)
Store 22(WidthU) 23
25: 15 Load 17(g_tTex1df4)
27: 19(int) ImageQuerySizeLod 25 26
Store 24(sizeQueryTemp) 27
28: 12(int) Load 24(sizeQueryTemp)
Store 22(WidthU) 28
30: 15 Load 17(g_tTex1df4)
31: 19(int) ImageQueryLevels 30
Store 29(NumberOfLevelsU) 31
37: 36(ptr) AccessChain 33(vsout) 20
Store 37 35
38:8(VS_OUTPUT) Load 32(vsout)
38:8(VS_OUTPUT) Load 33(vsout)
ReturnValue 38
FunctionEnd