From dccfeedfc318bd870fec51c2e73432c122b9656c Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 2 Jul 2018 18:52:14 -0600 Subject: [PATCH] HLSL: Fix #1423: implement CalculateLevelOfDetailUnclamped(). (If there is a bias issue, we need to discover what it is.) --- .../hlsl.calculatelodunclamped.dx10.frag.out | 274 ++++++++++++++++++--- hlsl/hlslParseHelper.cpp | 9 +- 2 files changed, 244 insertions(+), 39 deletions(-) diff --git a/Test/baseResults/hlsl.calculatelodunclamped.dx10.frag.out b/Test/baseResults/hlsl.calculatelodunclamped.dx10.frag.out index 160c095..ef5aabe 100644 --- a/Test/baseResults/hlsl.calculatelodunclamped.dx10.frag.out +++ b/Test/baseResults/hlsl.calculatelodunclamped.dx10.frag.out @@ -1,20 +1,8 @@ hlsl.calculatelodunclamped.dx10.frag -ERROR: 0:28: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 0:29: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 0:30: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 0:32: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 0:33: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 0:34: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 0:36: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 0:37: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 0:38: '' : unimplemented: CalculateLevelOfDetailUnclamped -ERROR: 9 compilation errors. No code generated. - - Shader version: 500 gl_FragCoord origin is upper left using depth_any -ERROR: node is still EOpNull! +0:? Sequence 0:24 Function Definition: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) 0:24 Function Parameters: 0:? Sequence @@ -29,7 +17,7 @@ ERROR: node is still EOpNull! 0:28 Constant: 0:28 0.100000 0:28 Constant: -0:28 0 (const int) +0:28 1 (const int) 0:29 Sequence 0:29 move second child to first child ( temp float) 0:29 'txval11' ( temp float) @@ -41,7 +29,7 @@ ERROR: node is still EOpNull! 0:29 Constant: 0:29 0.200000 0:29 Constant: -0:29 0 (const int) +0:29 1 (const int) 0:30 Sequence 0:30 move second child to first child ( temp float) 0:30 'txval12' ( temp float) @@ -53,7 +41,7 @@ ERROR: node is still EOpNull! 0:30 Constant: 0:30 0.300000 0:30 Constant: -0:30 0 (const int) +0:30 1 (const int) 0:32 Sequence 0:32 move second child to first child ( temp float) 0:32 'txval20' ( temp float) @@ -66,7 +54,7 @@ ERROR: node is still EOpNull! 0:? 0.100000 0:? 0.200000 0:32 Constant: -0:32 0 (const int) +0:32 1 (const int) 0:33 Sequence 0:33 move second child to first child ( temp float) 0:33 'txval21' ( temp float) @@ -79,7 +67,7 @@ ERROR: node is still EOpNull! 0:? 0.300000 0:? 0.400000 0:33 Constant: -0:33 0 (const int) +0:33 1 (const int) 0:34 Sequence 0:34 move second child to first child ( temp float) 0:34 'txval22' ( temp float) @@ -92,7 +80,7 @@ ERROR: node is still EOpNull! 0:? 0.500000 0:? 0.600000 0:34 Constant: -0:34 0 (const int) +0:34 1 (const int) 0:36 Sequence 0:36 move second child to first child ( temp float) 0:36 'txval40' ( temp float) @@ -106,7 +94,7 @@ ERROR: node is still EOpNull! 0:? 0.200000 0:? 0.300000 0:36 Constant: -0:36 0 (const int) +0:36 1 (const int) 0:37 Sequence 0:37 move second child to first child ( temp float) 0:37 'txval41' ( temp float) @@ -120,7 +108,7 @@ ERROR: node is still EOpNull! 0:? 0.500000 0:? 0.600000 0:37 Constant: -0:37 0 (const int) +0:37 1 (const int) 0:38 Sequence 0:38 move second child to first child ( temp float) 0:38 'txval42' ( temp float) @@ -134,7 +122,7 @@ ERROR: node is still EOpNull! 0:? 0.800000 0:? 0.900000 0:38 Constant: -0:38 0 (const int) +0:38 1 (const int) 0:40 move second child to first child ( temp 4-component vector of float) 0:40 Color: direct index for structure ( temp 4-component vector of float) 0:40 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) @@ -195,7 +183,7 @@ Linked fragment stage: Shader version: 500 gl_FragCoord origin is upper left using depth_any -ERROR: node is still EOpNull! +0:? Sequence 0:24 Function Definition: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) 0:24 Function Parameters: 0:? Sequence @@ -210,7 +198,7 @@ ERROR: node is still EOpNull! 0:28 Constant: 0:28 0.100000 0:28 Constant: -0:28 0 (const int) +0:28 1 (const int) 0:29 Sequence 0:29 move second child to first child ( temp float) 0:29 'txval11' ( temp float) @@ -222,7 +210,7 @@ ERROR: node is still EOpNull! 0:29 Constant: 0:29 0.200000 0:29 Constant: -0:29 0 (const int) +0:29 1 (const int) 0:30 Sequence 0:30 move second child to first child ( temp float) 0:30 'txval12' ( temp float) @@ -234,7 +222,7 @@ ERROR: node is still EOpNull! 0:30 Constant: 0:30 0.300000 0:30 Constant: -0:30 0 (const int) +0:30 1 (const int) 0:32 Sequence 0:32 move second child to first child ( temp float) 0:32 'txval20' ( temp float) @@ -247,7 +235,7 @@ ERROR: node is still EOpNull! 0:? 0.100000 0:? 0.200000 0:32 Constant: -0:32 0 (const int) +0:32 1 (const int) 0:33 Sequence 0:33 move second child to first child ( temp float) 0:33 'txval21' ( temp float) @@ -260,7 +248,7 @@ ERROR: node is still EOpNull! 0:? 0.300000 0:? 0.400000 0:33 Constant: -0:33 0 (const int) +0:33 1 (const int) 0:34 Sequence 0:34 move second child to first child ( temp float) 0:34 'txval22' ( temp float) @@ -273,7 +261,7 @@ ERROR: node is still EOpNull! 0:? 0.500000 0:? 0.600000 0:34 Constant: -0:34 0 (const int) +0:34 1 (const int) 0:36 Sequence 0:36 move second child to first child ( temp float) 0:36 'txval40' ( temp float) @@ -287,7 +275,7 @@ ERROR: node is still EOpNull! 0:? 0.200000 0:? 0.300000 0:36 Constant: -0:36 0 (const int) +0:36 1 (const int) 0:37 Sequence 0:37 move second child to first child ( temp float) 0:37 'txval41' ( temp float) @@ -301,7 +289,7 @@ ERROR: node is still EOpNull! 0:? 0.500000 0:? 0.600000 0:37 Constant: -0:37 0 (const int) +0:37 1 (const int) 0:38 Sequence 0:38 move second child to first child ( temp float) 0:38 'txval42' ( temp float) @@ -315,7 +303,7 @@ ERROR: node is still EOpNull! 0:? 0.800000 0:? 0.900000 0:38 Constant: -0:38 0 (const int) +0:38 1 (const int) 0:40 move second child to first child ( temp 4-component vector of float) 0:40 Color: direct index for structure ( temp 4-component vector of float) 0:40 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) @@ -369,4 +357,224 @@ ERROR: node is still EOpNull! 0:? '@entryPointOutput.Depth' ( out float FragDepth) 0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) -SPIR-V is not generated for failed compile or link +// Module Version 10000 +// Generated by (magic number): 80007 +// Id's are bound by 148 + + Capability Shader + Capability Sampled1D + Capability SampledCubeArray + Capability ImageQuery + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 140 144 + ExecutionMode 4 OriginUpperLeft + ExecutionMode 4 DepthReplacing + Source HLSL 500 + Name 4 "main" + Name 8 "PS_OUTPUT" + MemberName 8(PS_OUTPUT) 0 "Color" + MemberName 8(PS_OUTPUT) 1 "Depth" + Name 10 "@main(" + Name 13 "txval10" + Name 16 "g_tTex1df4a" + Name 20 "g_sSamp" + Name 30 "txval11" + Name 33 "g_tTex1di4a" + Name 41 "txval12" + Name 45 "g_tTex1du4a" + Name 53 "txval20" + Name 56 "g_tTex2df4a" + Name 64 "txval21" + Name 67 "g_tTex2di4a" + Name 76 "txval22" + Name 79 "g_tTex2du4a" + Name 89 "txval40" + Name 92 "g_tTexcdf4a" + Name 101 "txval41" + Name 104 "g_tTexcdi4a" + Name 112 "txval42" + Name 115 "g_tTexcdu4a" + Name 127 "psout" + Name 137 "flattenTemp" + Name 140 "@entryPointOutput.Color" + Name 144 "@entryPointOutput.Depth" + Name 147 "g_tTex1df4" + Decorate 16(g_tTex1df4a) DescriptorSet 0 + Decorate 16(g_tTex1df4a) Binding 1 + Decorate 20(g_sSamp) DescriptorSet 0 + Decorate 20(g_sSamp) Binding 0 + Decorate 33(g_tTex1di4a) DescriptorSet 0 + Decorate 45(g_tTex1du4a) DescriptorSet 0 + Decorate 56(g_tTex2df4a) DescriptorSet 0 + Decorate 67(g_tTex2di4a) DescriptorSet 0 + Decorate 79(g_tTex2du4a) DescriptorSet 0 + Decorate 92(g_tTexcdf4a) DescriptorSet 0 + Decorate 104(g_tTexcdi4a) DescriptorSet 0 + Decorate 115(g_tTexcdu4a) DescriptorSet 0 + Decorate 140(@entryPointOutput.Color) Location 0 + Decorate 144(@entryPointOutput.Depth) BuiltIn FragDepth + Decorate 147(g_tTex1df4) DescriptorSet 0 + Decorate 147(g_tTex1df4) Binding 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8(PS_OUTPUT): TypeStruct 7(fvec4) 6(float) + 9: TypeFunction 8(PS_OUTPUT) + 12: TypePointer Function 6(float) + 14: TypeImage 6(float) 1D array sampled format:Unknown + 15: TypePointer UniformConstant 14 + 16(g_tTex1df4a): 15(ptr) Variable UniformConstant + 18: TypeSampler + 19: TypePointer UniformConstant 18 + 20(g_sSamp): 19(ptr) Variable UniformConstant + 22: TypeSampledImage 14 + 24: 6(float) Constant 1036831949 + 25: TypeVector 6(float) 2 + 27: TypeInt 32 1 + 28: 27(int) Constant 1 + 31: TypeImage 27(int) 1D array sampled format:Unknown + 32: TypePointer UniformConstant 31 + 33(g_tTex1di4a): 32(ptr) Variable UniformConstant + 36: TypeSampledImage 31 + 38: 6(float) Constant 1045220557 + 42: TypeInt 32 0 + 43: TypeImage 42(int) 1D array sampled format:Unknown + 44: TypePointer UniformConstant 43 + 45(g_tTex1du4a): 44(ptr) Variable UniformConstant + 48: TypeSampledImage 43 + 50: 6(float) Constant 1050253722 + 54: TypeImage 6(float) 2D array sampled format:Unknown + 55: TypePointer UniformConstant 54 + 56(g_tTex2df4a): 55(ptr) Variable UniformConstant + 59: TypeSampledImage 54 + 61: 25(fvec2) ConstantComposite 24 38 + 65: TypeImage 27(int) 2D array sampled format:Unknown + 66: TypePointer UniformConstant 65 + 67(g_tTex2di4a): 66(ptr) Variable UniformConstant + 70: TypeSampledImage 65 + 72: 6(float) Constant 1053609165 + 73: 25(fvec2) ConstantComposite 50 72 + 77: TypeImage 42(int) 2D array sampled format:Unknown + 78: TypePointer UniformConstant 77 + 79(g_tTex2du4a): 78(ptr) Variable UniformConstant + 82: TypeSampledImage 77 + 84: 6(float) Constant 1056964608 + 85: 6(float) Constant 1058642330 + 86: 25(fvec2) ConstantComposite 84 85 + 90: TypeImage 6(float) Cube array sampled format:Unknown + 91: TypePointer UniformConstant 90 + 92(g_tTexcdf4a): 91(ptr) Variable UniformConstant + 95: TypeSampledImage 90 + 97: TypeVector 6(float) 3 + 98: 97(fvec3) ConstantComposite 24 38 50 + 102: TypeImage 27(int) Cube array sampled format:Unknown + 103: TypePointer UniformConstant 102 +104(g_tTexcdi4a): 103(ptr) Variable UniformConstant + 107: TypeSampledImage 102 + 109: 97(fvec3) ConstantComposite 72 84 85 + 113: TypeImage 42(int) Cube array sampled format:Unknown + 114: TypePointer UniformConstant 113 +115(g_tTexcdu4a): 114(ptr) Variable UniformConstant + 118: TypeSampledImage 113 + 120: 6(float) Constant 1060320051 + 121: 6(float) Constant 1061997773 + 122: 6(float) Constant 1063675494 + 123: 97(fvec3) ConstantComposite 120 121 122 + 126: TypePointer Function 8(PS_OUTPUT) + 128: 27(int) Constant 0 + 129: 6(float) Constant 1065353216 + 130: 7(fvec4) ConstantComposite 129 129 129 129 + 131: TypePointer Function 7(fvec4) + 139: TypePointer Output 7(fvec4) +140(@entryPointOutput.Color): 139(ptr) Variable Output + 143: TypePointer Output 6(float) +144(@entryPointOutput.Depth): 143(ptr) Variable Output + 147(g_tTex1df4): 15(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label +137(flattenTemp): 126(ptr) Variable Function + 138:8(PS_OUTPUT) FunctionCall 10(@main() + Store 137(flattenTemp) 138 + 141: 131(ptr) AccessChain 137(flattenTemp) 128 + 142: 7(fvec4) Load 141 + Store 140(@entryPointOutput.Color) 142 + 145: 12(ptr) AccessChain 137(flattenTemp) 28 + 146: 6(float) Load 145 + Store 144(@entryPointOutput.Depth) 146 + Return + FunctionEnd + 10(@main():8(PS_OUTPUT) Function None 9 + 11: Label + 13(txval10): 12(ptr) Variable Function + 30(txval11): 12(ptr) Variable Function + 41(txval12): 12(ptr) Variable Function + 53(txval20): 12(ptr) Variable Function + 64(txval21): 12(ptr) Variable Function + 76(txval22): 12(ptr) Variable Function + 89(txval40): 12(ptr) Variable Function + 101(txval41): 12(ptr) Variable Function + 112(txval42): 12(ptr) Variable Function + 127(psout): 126(ptr) Variable Function + 17: 14 Load 16(g_tTex1df4a) + 21: 18 Load 20(g_sSamp) + 23: 22 SampledImage 17 21 + 26: 25(fvec2) ImageQueryLod 23 24 + 29: 6(float) CompositeExtract 26 1 + Store 13(txval10) 29 + 34: 31 Load 33(g_tTex1di4a) + 35: 18 Load 20(g_sSamp) + 37: 36 SampledImage 34 35 + 39: 25(fvec2) ImageQueryLod 37 38 + 40: 6(float) CompositeExtract 39 1 + Store 30(txval11) 40 + 46: 43 Load 45(g_tTex1du4a) + 47: 18 Load 20(g_sSamp) + 49: 48 SampledImage 46 47 + 51: 25(fvec2) ImageQueryLod 49 50 + 52: 6(float) CompositeExtract 51 1 + Store 41(txval12) 52 + 57: 54 Load 56(g_tTex2df4a) + 58: 18 Load 20(g_sSamp) + 60: 59 SampledImage 57 58 + 62: 25(fvec2) ImageQueryLod 60 61 + 63: 6(float) CompositeExtract 62 1 + Store 53(txval20) 63 + 68: 65 Load 67(g_tTex2di4a) + 69: 18 Load 20(g_sSamp) + 71: 70 SampledImage 68 69 + 74: 25(fvec2) ImageQueryLod 71 73 + 75: 6(float) CompositeExtract 74 1 + Store 64(txval21) 75 + 80: 77 Load 79(g_tTex2du4a) + 81: 18 Load 20(g_sSamp) + 83: 82 SampledImage 80 81 + 87: 25(fvec2) ImageQueryLod 83 86 + 88: 6(float) CompositeExtract 87 1 + Store 76(txval22) 88 + 93: 90 Load 92(g_tTexcdf4a) + 94: 18 Load 20(g_sSamp) + 96: 95 SampledImage 93 94 + 99: 25(fvec2) ImageQueryLod 96 98 + 100: 6(float) CompositeExtract 99 1 + Store 89(txval40) 100 + 105: 102 Load 104(g_tTexcdi4a) + 106: 18 Load 20(g_sSamp) + 108: 107 SampledImage 105 106 + 110: 25(fvec2) ImageQueryLod 108 109 + 111: 6(float) CompositeExtract 110 1 + Store 101(txval41) 111 + 116: 113 Load 115(g_tTexcdu4a) + 117: 18 Load 20(g_sSamp) + 119: 118 SampledImage 116 117 + 124: 25(fvec2) ImageQueryLod 119 123 + 125: 6(float) CompositeExtract 124 1 + Store 112(txval42) 125 + 132: 131(ptr) AccessChain 127(psout) 128 + Store 132 130 + 133: 12(ptr) AccessChain 127(psout) 28 + Store 133 129 + 134:8(PS_OUTPUT) Load 127(psout) + ReturnValue 134 + FunctionEnd diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index d80f356..76fdfab 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -4377,16 +4377,13 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType txquerylod->getSequence().push_back(txcombine); txquerylod->getSequence().push_back(argCoord); - TIntermTyped* lodComponent = intermediate.addConstantUnion(0, loc, true); + TIntermTyped* lodComponent = intermediate.addConstantUnion( + op == EOpMethodCalculateLevelOfDetail ? 0 : 1, + loc, true); TIntermTyped* lodComponentIdx = intermediate.addIndex(EOpIndexDirect, txquerylod, lodComponent, loc); lodComponentIdx->setType(TType(EbtFloat, EvqTemporary, 1)); - node = lodComponentIdx; - // We cannot currently obtain the unclamped LOD - if (op == EOpMethodCalculateLevelOfDetailUnclamped) - error(loc, "unimplemented: CalculateLevelOfDetailUnclamped", "", ""); - break; } -- 2.7.4