SPV: Handle type punning in createCompositeCompare().
This commit is contained in:
parent
f8842e55c0
commit
e23c9849c2
@ -1423,7 +1423,6 @@ Id Builder::createCompositeCompare(Decoration precision, Id value1, Id value2, b
|
||||
{
|
||||
Id boolType = makeBoolType();
|
||||
Id valueType = getTypeId(value1);
|
||||
assert(valueType == getTypeId(value2));
|
||||
|
||||
Id resultId;
|
||||
|
||||
@ -1432,6 +1431,7 @@ Id Builder::createCompositeCompare(Decoration precision, Id value1, Id value2, b
|
||||
// Scalars and Vectors
|
||||
|
||||
if (isScalarType(valueType) || isVectorType(valueType)) {
|
||||
assert(valueType == getTypeId(value2));
|
||||
// These just need a single comparison, just have
|
||||
// to figure out what it is.
|
||||
Op op;
|
||||
@ -1470,9 +1470,10 @@ Id Builder::createCompositeCompare(Decoration precision, Id value1, Id value2, b
|
||||
// Compare each pair of constituents
|
||||
for (int constituent = 0; constituent < numConstituents; ++constituent) {
|
||||
std::vector<unsigned> indexes(1, constituent);
|
||||
Id constituentType = getContainedTypeId(valueType, constituent);
|
||||
Id constituent1 = createCompositeExtract(value1, constituentType, indexes);
|
||||
Id constituent2 = createCompositeExtract(value2, constituentType, indexes);
|
||||
Id constituentType1 = getContainedTypeId(getTypeId(value1), constituent);
|
||||
Id constituentType2 = getContainedTypeId(getTypeId(value2), constituent);
|
||||
Id constituent1 = createCompositeExtract(value1, constituentType1, indexes);
|
||||
Id constituent2 = createCompositeExtract(value2, constituentType2, indexes);
|
||||
|
||||
Id subResultId = createCompositeCompare(precision, constituent1, constituent2, equal);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
spv.aggOps.frag
|
||||
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
|
||||
WARNING: 0:6: varying deprecated in version 130; may be removed in future release
|
||||
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
@ -8,14 +7,14 @@ Linked fragment stage:
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 346
|
||||
// Id's are bound by 380
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 16 41 90 342
|
||||
EntryPoint Fragment 4 "main" 16 41 90 376
|
||||
ExecutionMode 4 OriginLowerLeft
|
||||
Source GLSL 130
|
||||
Source GLSL 450
|
||||
Name 4 "main"
|
||||
Name 8 "s1"
|
||||
MemberName 8(s1) 0 "i"
|
||||
@ -33,8 +32,32 @@ Linked fragment stage:
|
||||
Name 82 "v"
|
||||
Name 86 "samp2D"
|
||||
Name 90 "coord"
|
||||
Name 342 "gl_FragColor"
|
||||
Name 345 "foo1"
|
||||
Name 341 "s1"
|
||||
MemberName 341(s1) 0 "i"
|
||||
MemberName 341(s1) 1 "f"
|
||||
Name 342 "s2"
|
||||
MemberName 342(s2) 0 "i"
|
||||
MemberName 342(s2) 1 "f"
|
||||
MemberName 342(s2) 2 "s1_1"
|
||||
Name 343 "bn"
|
||||
MemberName 343(bn) 0 "foo2a"
|
||||
Name 345 "bi"
|
||||
Name 347 "s1"
|
||||
MemberName 347(s1) 0 "i"
|
||||
MemberName 347(s1) 1 "f"
|
||||
Name 348 "s2"
|
||||
MemberName 348(s2) 0 "i"
|
||||
MemberName 348(s2) 1 "f"
|
||||
MemberName 348(s2) 2 "s1_1"
|
||||
Name 376 "color"
|
||||
Name 379 "foo1"
|
||||
MemberDecorate 341(s1) 0 Offset 0
|
||||
MemberDecorate 341(s1) 1 Offset 4
|
||||
MemberDecorate 342(s2) 0 Offset 0
|
||||
MemberDecorate 342(s2) 1 Offset 4
|
||||
MemberDecorate 342(s2) 2 Offset 16
|
||||
MemberDecorate 343(bn) 0 Offset 0
|
||||
Decorate 343(bn) Block
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 32 1
|
||||
@ -79,10 +102,20 @@ Linked fragment stage:
|
||||
126: 7(float) Constant 1084227584
|
||||
232: 7(float) Constant 1086324736
|
||||
338: 7(float) Constant 1088421888
|
||||
341: TypePointer Output 14(fvec4)
|
||||
342(gl_FragColor): 341(ptr) Variable Output
|
||||
344: TypePointer UniformConstant 8(s1)
|
||||
345(foo1): 344(ptr) Variable UniformConstant
|
||||
341(s1): TypeStruct 6(int) 7(float)
|
||||
342(s2): TypeStruct 6(int) 7(float) 341(s1)
|
||||
343(bn): TypeStruct 342(s2)
|
||||
344: TypePointer Uniform 343(bn)
|
||||
345(bi): 344(ptr) Variable Uniform
|
||||
346: 6(int) Constant 0
|
||||
347(s1): TypeStruct 6(int) 7(float)
|
||||
348(s2): TypeStruct 6(int) 7(float) 347(s1)
|
||||
349: TypePointer Uniform 342(s2)
|
||||
372: 7(float) Constant 1090519040
|
||||
375: TypePointer Output 14(fvec4)
|
||||
376(color): 375(ptr) Variable Output
|
||||
378: TypePointer UniformConstant 8(s1)
|
||||
379(foo1): 378(ptr) Variable UniformConstant
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
13(a): 12(ptr) Variable Function
|
||||
@ -406,7 +439,35 @@ Linked fragment stage:
|
||||
Store 82(v) 340
|
||||
Branch 337
|
||||
337: Label
|
||||
343: 14(fvec4) Load 82(v)
|
||||
Store 342(gl_FragColor) 343
|
||||
350: 349(ptr) AccessChain 345(bi) 346
|
||||
351: 342(s2) Load 350
|
||||
352: 55(s2) Load 57(foo2a)
|
||||
353: 6(int) CompositeExtract 351 0
|
||||
354: 6(int) CompositeExtract 352 0
|
||||
355: 61(bool) INotEqual 353 354
|
||||
356: 7(float) CompositeExtract 351 1
|
||||
357: 7(float) CompositeExtract 352 1
|
||||
358: 61(bool) FOrdNotEqual 356 357
|
||||
359: 61(bool) LogicalOr 355 358
|
||||
360: 341(s1) CompositeExtract 351 2
|
||||
361: 8(s1) CompositeExtract 352 2
|
||||
362: 6(int) CompositeExtract 360 0
|
||||
363: 6(int) CompositeExtract 361 0
|
||||
364: 61(bool) INotEqual 362 363
|
||||
365: 7(float) CompositeExtract 360 1
|
||||
366: 7(float) CompositeExtract 361 1
|
||||
367: 61(bool) FOrdNotEqual 365 366
|
||||
368: 61(bool) LogicalOr 364 367
|
||||
369: 61(bool) LogicalOr 359 368
|
||||
SelectionMerge 371 None
|
||||
BranchConditional 369 370 371
|
||||
370: Label
|
||||
373: 14(fvec4) Load 82(v)
|
||||
374: 14(fvec4) VectorTimesScalar 373 372
|
||||
Store 82(v) 374
|
||||
Branch 371
|
||||
371: Label
|
||||
377: 14(fvec4) Load 82(v)
|
||||
Store 376(color) 377
|
||||
Return
|
||||
FunctionEnd
|
||||
|
@ -1,9 +1,10 @@
|
||||
#version 130
|
||||
#version 450
|
||||
|
||||
uniform sampler2D samp2D;
|
||||
varying mediump vec2 coord;
|
||||
in mediump vec2 coord;
|
||||
|
||||
varying vec4 u, w;
|
||||
in vec4 u, w;
|
||||
out vec4 color;
|
||||
|
||||
struct s1 {
|
||||
int i;
|
||||
@ -20,6 +21,10 @@ uniform s1 foo1;
|
||||
uniform s2 foo2a;
|
||||
uniform s2 foo2b;
|
||||
|
||||
layout(std140) uniform bn {
|
||||
s2 foo2a;
|
||||
} bi;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 v;
|
||||
@ -47,5 +52,8 @@ void main()
|
||||
if (a != b)
|
||||
v *= 7.0;
|
||||
|
||||
gl_FragColor = v;
|
||||
if (bi.foo2a != foo2a)
|
||||
v *= 8.0;
|
||||
|
||||
color = v;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user