Keep vec1.x l-value in HLSL

Changes in hlsl.shapeConv.frag are just renumbering,
duplicated load (80) has disappeared for whatever reason.
This commit is contained in:
Pavel Asyutchenko 2024-04-19 22:54:52 +02:00 committed by arcady-lunarg
parent d4d821272b
commit e46c1b725c
5 changed files with 149 additions and 68 deletions

View file

@ -102,8 +102,10 @@ gl_FragCoord origin is upper left
0:27 'v' ( temp 4-component vector of float) 0:27 'v' ( temp 4-component vector of float)
0:27 Construct vec4 ( temp 4-component vector of float) 0:27 Construct vec4 ( temp 4-component vector of float)
0:27 'f1' ( temp 1-component vector of float) 0:27 'f1' ( temp 1-component vector of float)
0:28 Construct float ( temp float) 0:28 direct index ( temp float)
0:28 'f1' ( temp 1-component vector of float) 0:28 'f1' ( temp 1-component vector of float)
0:28 Constant:
0:28 0 (const int)
0:29 Construct vec3 ( temp 3-component vector of float) 0:29 Construct vec3 ( temp 3-component vector of float)
0:29 Construct float ( temp float) 0:29 Construct float ( temp float)
0:29 'f1' ( temp 1-component vector of float) 0:29 'f1' ( temp 1-component vector of float)
@ -264,8 +266,10 @@ gl_FragCoord origin is upper left
0:27 'v' ( temp 4-component vector of float) 0:27 'v' ( temp 4-component vector of float)
0:27 Construct vec4 ( temp 4-component vector of float) 0:27 Construct vec4 ( temp 4-component vector of float)
0:27 'f1' ( temp 1-component vector of float) 0:27 'f1' ( temp 1-component vector of float)
0:28 Construct float ( temp float) 0:28 direct index ( temp float)
0:28 'f1' ( temp 1-component vector of float) 0:28 'f1' ( temp 1-component vector of float)
0:28 Constant:
0:28 0 (const int)
0:29 Construct vec3 ( temp 3-component vector of float) 0:29 Construct vec3 ( temp 3-component vector of float)
0:29 Construct float ( temp float) 0:29 Construct float ( temp float)
0:29 'f1' ( temp 1-component vector of float) 0:29 'f1' ( temp 1-component vector of float)
@ -320,7 +324,7 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 8000b // Generated by (magic number): 8000b
// Id's are bound by 127 // Id's are bound by 126
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
@ -339,11 +343,11 @@ gl_FragCoord origin is upper left
Name 34 "MyVal" Name 34 "MyVal"
Name 37 "foo" Name 37 "foo"
Name 70 "f1" Name 70 "f1"
Name 83 "ui" Name 82 "ui"
Name 88 "ui3" Name 87 "ui3"
Name 103 "mixed" Name 102 "mixed"
Name 115 "sf" Name 114 "sf"
Name 118 "sf1" Name 117 "sf1"
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
@ -375,11 +379,11 @@ gl_FragCoord origin is upper left
56: TypeInt 32 0 56: TypeInt 32 0
57: 56(int) Constant 0 57: 56(int) Constant 0
62: TypeVector 41(bool) 4 62: TypeVector 41(bool) 4
82: TypePointer Function 56(int) 81: TypePointer Function 56(int)
85: TypeVector 56(int) 3 84: TypeVector 56(int) 3
87: TypePointer Function 85(ivec3) 86: TypePointer Function 84(ivec3)
122: 6(float) Constant 1077936128 121: 6(float) Constant 1077936128
123: 7(fvec4) ConstantComposite 122 122 122 122 122: 7(fvec4) ConstantComposite 121 121 121 121
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
Return Return
@ -395,11 +399,11 @@ gl_FragCoord origin is upper left
34(MyVal): 23(ptr) Variable Function 34(MyVal): 23(ptr) Variable Function
37(foo): 23(ptr) Variable Function 37(foo): 23(ptr) Variable Function
70(f1): 9(ptr) Variable Function 70(f1): 9(ptr) Variable Function
83(ui): 82(ptr) Variable Function 82(ui): 81(ptr) Variable Function
88(ui3): 87(ptr) Variable Function 87(ui3): 86(ptr) Variable Function
103(mixed): 23(ptr) Variable Function 102(mixed): 23(ptr) Variable Function
115(sf): 9(ptr) Variable Function 114(sf): 9(ptr) Variable Function
118(sf1): 9(ptr) Variable Function 117(sf1): 9(ptr) Variable Function
Store 15(v) 17 Store 15(v) 17
Store 15(v) 19 Store 15(v) 19
20: 6(float) Load 12(f) 20: 6(float) Load 12(f)
@ -443,47 +447,46 @@ gl_FragCoord origin is upper left
77: 7(fvec4) CompositeConstruct 76 76 76 76 77: 7(fvec4) CompositeConstruct 76 76 76 76
78: 62(bvec4) FOrdLessThan 75 77 78: 62(bvec4) FOrdLessThan 75 77
79: 6(float) Load 70(f1) 79: 6(float) Load 70(f1)
80: 6(float) Load 70(f1) 80: 22(fvec3) CompositeConstruct 79 79 79
81: 22(fvec3) CompositeConstruct 80 80 80 83: 56(int) Load 82(ui)
84: 56(int) Load 83(ui) 85: 84(ivec3) CompositeConstruct 83 83 83
86: 85(ivec3) CompositeConstruct 84 84 84 88: 84(ivec3) Load 87(ui3)
89: 85(ivec3) Load 88(ui3) 89: 84(ivec3) ShiftRightLogical 85 88
90: 85(ivec3) ShiftRightLogical 86 89 90: 84(ivec3) Load 87(ui3)
91: 85(ivec3) Load 88(ui3) 91: 56(int) Load 82(ui)
92: 56(int) Load 83(ui) 92: 84(ivec3) CompositeConstruct 91 91 91
93: 85(ivec3) CompositeConstruct 92 92 92 93: 84(ivec3) ShiftRightLogical 90 92
94: 85(ivec3) ShiftRightLogical 91 93 94: 6(float) Load 70(f1)
95: 6(float) Load 70(f1) 95: 7(fvec4) Load 15(v)
96: 7(fvec4) Load 15(v) 96: 7(fvec4) CompositeConstruct 94 94 94 94
97: 7(fvec4) CompositeConstruct 95 95 95 95 97: 7(fvec4) FMul 95 96
98: 7(fvec4) FMul 96 97 Store 15(v) 97
Store 15(v) 98 98: 7(fvec4) Load 15(v)
99: 7(fvec4) Load 15(v) 99: 6(float) CompositeExtract 98 0
100: 6(float) CompositeExtract 99 0 100: 6(float) Load 70(f1)
101: 6(float) Load 70(f1) 101: 6(float) FMul 100 99
102: 6(float) FMul 101 100 Store 70(f1) 101
Store 70(f1) 102 103: 22(fvec3) Load 24(u)
104: 22(fvec3) Load 24(u) 104: 7(fvec4) Load 15(v)
105: 7(fvec4) Load 15(v) 105: 6(float) CompositeExtract 104 0
106: 6(float) CompositeExtract 105 0 106: 6(float) CompositeExtract 104 1
107: 6(float) CompositeExtract 105 1 107: 6(float) CompositeExtract 104 2
108: 6(float) CompositeExtract 105 2 108: 22(fvec3) CompositeConstruct 105 106 107
109: 22(fvec3) CompositeConstruct 106 107 108 109: 22(fvec3) FMul 103 108
110: 22(fvec3) FMul 104 109 Store 102(mixed) 109
Store 103(mixed) 110 110: 22(fvec3) Load 24(u)
111: 22(fvec3) Load 24(u) 111: 6(float) CompositeExtract 110 0
112: 6(float) CompositeExtract 111 0 Store 12(f) 111
Store 12(f) 112 112: 22(fvec3) Load 24(u)
113: 22(fvec3) Load 24(u) 113: 6(float) CompositeExtract 112 0
114: 6(float) CompositeExtract 113 0 Store 70(f1) 113
Store 70(f1) 114 115: 7(fvec4) Load 15(v)
116: 7(fvec4) Load 15(v) 116: 6(float) CompositeExtract 115 0
117: 6(float) CompositeExtract 116 0 Store 114(sf) 116
Store 115(sf) 117 118: 7(fvec4) Load 15(v)
119: 7(fvec4) Load 15(v) 119: 6(float) CompositeExtract 118 0
120: 6(float) CompositeExtract 119 0 Store 117(sf1) 119
Store 118(sf1) 120 120: 7(fvec4) Load 11(input)
121: 7(fvec4) Load 11(input) 123: 7(fvec4) FMul 120 122
124: 7(fvec4) FMul 121 123 ReturnValue 123
ReturnValue 124
FunctionEnd FunctionEnd

View file

@ -0,0 +1,72 @@
hlsl.swizzle.vec1.comp
Shader version: 500
local_size = (1, 1, 1)
0:? Sequence
0:2 Function Definition: @main( ( temp void)
0:2 Function Parameters:
0:? Sequence
0:4 move second child to first child ( temp float)
0:4 direct index ( temp float)
0:4 'f1' ( temp 1-component vector of float)
0:4 Constant:
0:4 0 (const int)
0:4 Constant:
0:4 0.500000
0:2 Function Definition: main( ( temp void)
0:2 Function Parameters:
0:? Sequence
0:2 Function Call: @main( ( temp void)
0:? Linker Objects
Linked compute stage:
Shader version: 500
local_size = (1, 1, 1)
0:? Sequence
0:2 Function Definition: @main( ( temp void)
0:2 Function Parameters:
0:? Sequence
0:4 move second child to first child ( temp float)
0:4 direct index ( temp float)
0:4 'f1' ( temp 1-component vector of float)
0:4 Constant:
0:4 0 (const int)
0:4 Constant:
0:4 0.500000
0:2 Function Definition: main( ( temp void)
0:2 Function Parameters:
0:? Sequence
0:2 Function Call: @main( ( temp void)
0:? Linker Objects
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 13
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 1 1 1
Source HLSL 500
Name 4 "main"
Name 6 "@main("
Name 10 "f1"
2: TypeVoid
3: TypeFunction 2
8: TypeFloat 32
9: TypePointer Function 8(float)
11: 8(float) Constant 1056964608
4(main): 2 Function None 3
5: Label
12: 2 FunctionCall 6(@main()
Return
FunctionEnd
6(@main(): 2 Function None 3
7: Label
10(f1): 9(ptr) Variable Function
Store 10(f1) 11
Return
FunctionEnd

View file

@ -0,0 +1,8 @@
void main()
{
float1 f1;
f1.x = 0.5;
// This is not implemented
// f1.xx = float2(0.6, 0.7);
}

View file

@ -962,14 +962,11 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
return addConstructor(loc, base, type); return addConstructor(loc, base, type);
} }
} }
if (base->getVectorSize() == 1) { // Use EOpIndexDirect (below) with vec1.x so that it remains l-value (Test/hlsl.swizzle.vec1.comp)
if (base->getVectorSize() == 1 && selectors.size() > 1) {
TType scalarType(base->getBasicType(), EvqTemporary, 1); TType scalarType(base->getBasicType(), EvqTemporary, 1);
if (selectors.size() == 1) TType vectorType(base->getBasicType(), EvqTemporary, selectors.size());
return addConstructor(loc, base, scalarType); return addConstructor(loc, addConstructor(loc, base, scalarType), vectorType);
else {
TType vectorType(base->getBasicType(), EvqTemporary, selectors.size());
return addConstructor(loc, addConstructor(loc, base, scalarType), vectorType);
}
} }
if (base->getType().getQualifier().isFrontEndConstant()) if (base->getType().getQualifier().isFrontEndConstant())

View file

@ -420,6 +420,7 @@ INSTANTIATE_TEST_SUITE_P(
{"hlsl.structIoFourWay.frag", "main"}, {"hlsl.structIoFourWay.frag", "main"},
{"hlsl.structStructName.frag", "main"}, {"hlsl.structStructName.frag", "main"},
{"hlsl.subpass.frag", "main"}, {"hlsl.subpass.frag", "main"},
{"hlsl.swizzle.vec1.comp", "main"},
{"hlsl.synthesizeInput.frag", "main"}, {"hlsl.synthesizeInput.frag", "main"},
{"hlsl.texturebuffer.frag", "main"}, {"hlsl.texturebuffer.frag", "main"},
{"hlsl.texture.struct.frag", "main"}, {"hlsl.texture.struct.frag", "main"},