Commit 88220d50 by Jeff Bolz

For nonuniformEXT constructor, make a copy of the node to decorate

parent e291f7a0
...@@ -5543,6 +5543,11 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, OpDe ...@@ -5543,6 +5543,11 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, OpDe
case glslang::EOpConstructReference: case glslang::EOpConstructReference:
unaryOp = spv::OpBitcast; unaryOp = spv::OpBitcast;
break; break;
case glslang::EOpCopyObject:
unaryOp = spv::OpCopyObject;
break;
default: default:
return 0; return 0;
} }
......
...@@ -31,11 +31,13 @@ ERROR: node is still EOpNull! ...@@ -31,11 +31,13 @@ ERROR: node is still EOpNull!
0:27 move second child to first child ( temp int) 0:27 move second child to first child ( temp int)
0:27 'nu_li' ( nonuniform temp int) 0:27 'nu_li' ( nonuniform temp int)
0:27 add ( nonuniform temp int) 0:27 add ( nonuniform temp int)
0:27 'a' ( nonuniform temp int) 0:27 copy object ( nonuniform temp int)
0:27 component-wise multiply ( nonuniform temp int)
0:27 'a' ( temp int) 0:27 'a' ( temp int)
0:27 Constant: 0:27 copy object ( nonuniform temp int)
0:27 2 (const int) 0:27 component-wise multiply ( temp int)
0:27 'a' ( temp int)
0:27 Constant:
0:27 2 (const int)
0:28 'nu_li' ( nonuniform temp int) 0:28 'nu_li' ( nonuniform temp int)
0:29 'nu_li' ( nonuniform temp int) 0:29 'nu_li' ( nonuniform temp int)
0:? Linker Objects 0:? Linker Objects
...@@ -72,11 +74,13 @@ ERROR: node is still EOpNull! ...@@ -72,11 +74,13 @@ ERROR: node is still EOpNull!
0:27 move second child to first child ( temp int) 0:27 move second child to first child ( temp int)
0:27 'nu_li' ( nonuniform temp int) 0:27 'nu_li' ( nonuniform temp int)
0:27 add ( nonuniform temp int) 0:27 add ( nonuniform temp int)
0:27 'a' ( nonuniform temp int) 0:27 copy object ( nonuniform temp int)
0:27 component-wise multiply ( nonuniform temp int)
0:27 'a' ( temp int) 0:27 'a' ( temp int)
0:27 Constant: 0:27 copy object ( nonuniform temp int)
0:27 2 (const int) 0:27 component-wise multiply ( temp int)
0:27 'a' ( temp int)
0:27 Constant:
0:27 2 (const int)
0:28 'nu_li' ( nonuniform temp int) 0:28 'nu_li' ( nonuniform temp int)
0:29 'nu_li' ( nonuniform temp int) 0:29 'nu_li' ( nonuniform temp int)
0:? Linker Objects 0:? Linker Objects
......
spv.nonuniform2.frag
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 24
Capability Shader
Capability ImageBuffer
Capability CapabilityShaderNonUniformEXT
Capability CapabilityRuntimeDescriptorArrayEXT
Capability CapabilityStorageTexelBufferArrayNonUniformIndexingEXT
Extension "SPV_EXT_descriptor_indexing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 16
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_EXT_nonuniform_qualifier"
Name 4 "main"
Name 9 "FragColor"
Name 13 "data"
Name 16 "rIndex"
Decorate 9(FragColor) Location 0
Decorate 13(data) DescriptorSet 0
Decorate 13(data) Binding 4
Decorate 16(rIndex) Flat
Decorate 16(rIndex) Location 3
Decorate 18 DecorationNonUniformEXT
Decorate 21 DecorationNonUniformEXT
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(FragColor): 8(ptr) Variable Output
10: TypeImage 6(float) Buffer nonsampled format:Rgba32f
11: TypeRuntimeArray 10
12: TypePointer UniformConstant 11
13(data): 12(ptr) Variable UniformConstant
14: TypeInt 32 1
15: TypePointer Input 14(int)
16(rIndex): 15(ptr) Variable Input
19: TypePointer UniformConstant 10
22: 14(int) Constant 0
4(main): 2 Function None 3
5: Label
17: 14(int) Load 16(rIndex)
18: 14(int) CopyObject 17
20: 19(ptr) AccessChain 13(data) 18
21: 10 Load 20
23: 7(fvec4) ImageRead 21 22
Store 9(FragColor) 23
Return
FunctionEnd
#version 450
#extension GL_EXT_nonuniform_qualifier : require
layout(set=0,binding=4,rgba32f) uniform imageBuffer data[];
layout(location = 0) out vec4 FragColor;
layout(location = 3) in flat int rIndex;
void main()
{
FragColor = imageLoad(data[nonuniformEXT(rIndex)], 0);
}
...@@ -85,6 +85,8 @@ enum TOperator { ...@@ -85,6 +85,8 @@ enum TOperator {
EOpPreIncrement, EOpPreIncrement,
EOpPreDecrement, EOpPreDecrement,
EOpCopyObject,
// (u)int* -> bool // (u)int* -> bool
EOpConvInt8ToBool, EOpConvInt8ToBool,
EOpConvUint8ToBool, EOpConvUint8ToBool,
......
...@@ -6951,9 +6951,10 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -6951,9 +6951,10 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
break; break;
case EOpConstructNonuniform: case EOpConstructNonuniform:
node->getWritableType().getQualifier().nonUniform = true; // Make a nonuniform copy of node
return node; newNode = intermediate.addBuiltInFunctionCall(node->getLoc(), EOpCopyObject, true, node, node->getType());
break; newNode->getWritableType().getQualifier().nonUniform = true;
return newNode;
case EOpConstructReference: case EOpConstructReference:
// construct reference from reference // construct reference from reference
......
...@@ -237,6 +237,7 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node) ...@@ -237,6 +237,7 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
case EOpPostDecrement: out.debug << "Post-Decrement"; break; case EOpPostDecrement: out.debug << "Post-Decrement"; break;
case EOpPreIncrement: out.debug << "Pre-Increment"; break; case EOpPreIncrement: out.debug << "Pre-Increment"; break;
case EOpPreDecrement: out.debug << "Pre-Decrement"; break; case EOpPreDecrement: out.debug << "Pre-Decrement"; break;
case EOpCopyObject: out.debug << "copy object"; break;
// * -> bool // * -> bool
case EOpConvInt8ToBool: out.debug << "Convert int8_t to bool"; break; case EOpConvInt8ToBool: out.debug << "Convert int8_t to bool"; break;
......
...@@ -335,6 +335,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -335,6 +335,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.noDeadDecorations.vert", "spv.noDeadDecorations.vert",
"spv.nonSquare.vert", "spv.nonSquare.vert",
"spv.nonuniform.frag", "spv.nonuniform.frag",
"spv.nonuniform2.frag",
"spv.noWorkgroup.comp", "spv.noWorkgroup.comp",
"spv.offsets.frag", "spv.offsets.frag",
"spv.Operations.frag", "spv.Operations.frag",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment