Commit 5a57ca68 by John Kessenich Committed by GitHub

Merge pull request #1078 from greg-lunarg/addopt14

Remove opaque workarounds
parents dabd1bf2 354a54c6
...@@ -158,6 +158,8 @@ protected: ...@@ -158,6 +158,8 @@ protected:
void declareUseOfStructMember(const glslang::TTypeList& members, int glslangMember); void declareUseOfStructMember(const glslang::TTypeList& members, int glslangMember);
bool isShaderEntryPoint(const glslang::TIntermAggregate* node); bool isShaderEntryPoint(const glslang::TIntermAggregate* node);
bool writableParam(glslang::TStorageQualifier);
bool originalParam(glslang::TStorageQualifier, const glslang::TType&, bool implicitThisParam);
void makeFunctions(const glslang::TIntermSequence&); void makeFunctions(const glslang::TIntermSequence&);
void makeGlobalInitializers(const glslang::TIntermSequence&); void makeGlobalInitializers(const glslang::TIntermSequence&);
void visitFunctions(const glslang::TIntermSequence&); void visitFunctions(const glslang::TIntermSequence&);
...@@ -771,33 +773,41 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T ...@@ -771,33 +773,41 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
{ {
if (type.getQualifier().isPipeInput()) if (type.getQualifier().isPipeInput())
return spv::StorageClassInput; return spv::StorageClassInput;
else if (type.getQualifier().isPipeOutput()) if (type.getQualifier().isPipeOutput())
return spv::StorageClassOutput; return spv::StorageClassOutput;
else if (type.getBasicType() == glslang::EbtAtomicUint)
return spv::StorageClassAtomicCounter; if (glslangIntermediate->getSource() != glslang::EShSourceHlsl ||
else if (type.containsOpaque()) type.getQualifier().storage == glslang::EvqUniform) {
return spv::StorageClassUniformConstant; if (type.getBasicType() == glslang::EbtAtomicUint)
else if (glslangIntermediate->usingStorageBuffer() && type.getQualifier().storage == glslang::EvqBuffer) { return spv::StorageClassAtomicCounter;
if (type.containsOpaque())
return spv::StorageClassUniformConstant;
}
if (glslangIntermediate->usingStorageBuffer() && type.getQualifier().storage == glslang::EvqBuffer) {
builder.addExtension(spv::E_SPV_KHR_storage_buffer_storage_class); builder.addExtension(spv::E_SPV_KHR_storage_buffer_storage_class);
return spv::StorageClassStorageBuffer; return spv::StorageClassStorageBuffer;
} else if (type.getQualifier().isUniformOrBuffer()) { }
if (type.getQualifier().isUniformOrBuffer()) {
if (type.getQualifier().layoutPushConstant) if (type.getQualifier().layoutPushConstant)
return spv::StorageClassPushConstant; return spv::StorageClassPushConstant;
if (type.getBasicType() == glslang::EbtBlock) if (type.getBasicType() == glslang::EbtBlock)
return spv::StorageClassUniform; return spv::StorageClassUniform;
else return spv::StorageClassUniformConstant;
return spv::StorageClassUniformConstant; }
} else {
switch (type.getQualifier().storage) { switch (type.getQualifier().storage) {
case glslang::EvqShared: return spv::StorageClassWorkgroup; break; case glslang::EvqShared: return spv::StorageClassWorkgroup;
case glslang::EvqGlobal: return spv::StorageClassPrivate; case glslang::EvqGlobal: return spv::StorageClassPrivate;
case glslang::EvqConstReadOnly: return spv::StorageClassFunction; case glslang::EvqConstReadOnly: return spv::StorageClassFunction;
case glslang::EvqTemporary: return spv::StorageClassFunction; case glslang::EvqTemporary: return spv::StorageClassFunction;
default: default:
assert(0); assert(0);
return spv::StorageClassFunction; break;
}
} }
return spv::StorageClassFunction;
} }
// Return whether or not the given type is something that should be tied to a // Return whether or not the given type is something that should be tied to a
...@@ -2961,6 +2971,24 @@ bool TGlslangToSpvTraverser::isShaderEntryPoint(const glslang::TIntermAggregate* ...@@ -2961,6 +2971,24 @@ bool TGlslangToSpvTraverser::isShaderEntryPoint(const glslang::TIntermAggregate*
return node->getName().compare(glslangIntermediate->getEntryPointMangledName().c_str()) == 0; return node->getName().compare(glslangIntermediate->getEntryPointMangledName().c_str()) == 0;
} }
// Does parameter need a place to keep writes, separate from the original?
bool TGlslangToSpvTraverser::writableParam(glslang::TStorageQualifier qualifier)
{
return qualifier != glslang::EvqConstReadOnly;
}
// Is parameter pass-by-original?
bool TGlslangToSpvTraverser::originalParam(glslang::TStorageQualifier qualifier, const glslang::TType& paramType,
bool implicitThisParam)
{
if (implicitThisParam) // implicit this
return true;
if (glslangIntermediate->getSource() == glslang::EShSourceHlsl)
return false;
return paramType.containsOpaque() || // sampler, etc.
(paramType.getBasicType() == glslang::EbtBlock && qualifier == glslang::EvqBuffer); // SSBO
}
// Make all the functions, skeletally, without actually visiting their bodies. // Make all the functions, skeletally, without actually visiting their bodies.
void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslFunctions) void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslFunctions)
{ {
...@@ -3001,13 +3029,9 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF ...@@ -3001,13 +3029,9 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
for (int p = 0; p < (int)parameters.size(); ++p) { for (int p = 0; p < (int)parameters.size(); ++p) {
const glslang::TType& paramType = parameters[p]->getAsTyped()->getType(); const glslang::TType& paramType = parameters[p]->getAsTyped()->getType();
spv::Id typeId = convertGlslangToSpvType(paramType); spv::Id typeId = convertGlslangToSpvType(paramType);
// can we pass by reference? if (originalParam(paramType.getQualifier().storage, paramType, implicitThis && p == 0))
if (paramType.containsOpaque() || // sampler, etc.
(paramType.getBasicType() == glslang::EbtBlock &&
paramType.getQualifier().storage == glslang::EvqBuffer) || // SSBO
(p == 0 && implicitThis)) // implicit 'this'
typeId = builder.makePointer(TranslateStorageClass(paramType), typeId); typeId = builder.makePointer(TranslateStorageClass(paramType), typeId);
else if (paramType.getQualifier().storage != glslang::EvqConstReadOnly) else if (writableParam(paramType.getQualifier().storage))
typeId = builder.makePointer(spv::StorageClassFunction, typeId); typeId = builder.makePointer(spv::StorageClassFunction, typeId);
else else
rValueParameters.insert(parameters[p]->getAsSymbolNode()->getId()); rValueParameters.insert(parameters[p]->getAsSymbolNode()->getId());
...@@ -3567,11 +3591,6 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg ...@@ -3567,11 +3591,6 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
const glslang::TIntermSequence& glslangArgs = node->getSequence(); const glslang::TIntermSequence& glslangArgs = node->getSequence();
const glslang::TQualifierList& qualifiers = node->getQualifierList(); const glslang::TQualifierList& qualifiers = node->getQualifierList();
// Encapsulate lvalue logic, used in several places below, for safety.
const auto isLValue = [](int qualifier, const glslang::TType& paramType) -> bool {
return qualifier != glslang::EvqConstReadOnly || paramType.containsOpaque();
};
// See comments in makeFunctions() for details about the semantics for parameter passing. // See comments in makeFunctions() for details about the semantics for parameter passing.
// //
// These imply we need a four step process: // These imply we need a four step process:
...@@ -3590,8 +3609,9 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg ...@@ -3590,8 +3609,9 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
builder.clearAccessChain(); builder.clearAccessChain();
glslangArgs[a]->traverse(this); glslangArgs[a]->traverse(this);
argTypes.push_back(&paramType); argTypes.push_back(&paramType);
// keep outputs and opaque objects as l-values, evaluate input-only as r-values // keep outputs and pass-by-originals as l-values, evaluate others as r-values
if (isLValue(qualifiers[a], paramType)) { if (writableParam(qualifiers[a]) ||
originalParam(qualifiers[a], paramType, function->hasImplicitThis() && a == 0)) {
// save l-value // save l-value
lValues.push_back(builder.getAccessChain()); lValues.push_back(builder.getAccessChain());
} else { } else {
...@@ -3610,13 +3630,11 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg ...@@ -3610,13 +3630,11 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
for (int a = 0; a < (int)glslangArgs.size(); ++a) { for (int a = 0; a < (int)glslangArgs.size(); ++a) {
const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType(); const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType();
spv::Id arg; spv::Id arg;
if (paramType.containsOpaque() || if (originalParam(qualifiers[a], paramType, function->hasImplicitThis() && a == 0)) {
(paramType.getBasicType() == glslang::EbtBlock && qualifiers[a] == glslang::EvqBuffer) ||
(a == 0 && function->hasImplicitThis())) {
builder.setAccessChain(lValues[lValueCount]); builder.setAccessChain(lValues[lValueCount]);
arg = builder.accessChainGetLValue(); arg = builder.accessChainGetLValue();
++lValueCount; ++lValueCount;
} else if (isLValue(qualifiers[a], paramType)) { } else if (writableParam(qualifiers[a])) {
// need space to hold the copy // need space to hold the copy
arg = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(paramType), "param"); arg = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(paramType), "param");
if (qualifiers[a] == glslang::EvqIn || qualifiers[a] == glslang::EvqInOut) { if (qualifiers[a] == glslang::EvqIn || qualifiers[a] == glslang::EvqInOut) {
...@@ -3643,7 +3661,9 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg ...@@ -3643,7 +3661,9 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
lValueCount = 0; lValueCount = 0;
for (int a = 0; a < (int)glslangArgs.size(); ++a) { for (int a = 0; a < (int)glslangArgs.size(); ++a) {
const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType(); const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType();
if (isLValue(qualifiers[a], paramType)) { if (originalParam(qualifiers[a], paramType, function->hasImplicitThis() && a == 0))
++lValueCount;
else if (writableParam(qualifiers[a])) {
if (qualifiers[a] == glslang::EvqOut || qualifiers[a] == glslang::EvqInOut) { if (qualifiers[a] == glslang::EvqOut || qualifiers[a] == glslang::EvqInOut) {
spv::Id copy = builder.createLoad(spvArgs[a]); spv::Id copy = builder.createLoad(spvArgs[a]);
builder.setAccessChain(lValues[lValueCount]); builder.setAccessChain(lValues[lValueCount]);
......
hlsl.aliasOpaque.frag hlsl.aliasOpaque.frag
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 61 // Id's are bound by 81
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 46 EntryPoint Fragment 4 "main" 57
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
Name 36 "gss" Name 37 "gss2"
Name 37 "gtex" Name 39 "gss"
Name 46 "@entryPointOutput" Name 43 "gtex"
Decorate 36(gss) DescriptorSet 0 Name 57 "@entryPointOutput"
Decorate 37(gtex) DescriptorSet 0 Decorate 37(gss2) DescriptorSet 0
Decorate 46(@entryPointOutput) Location 0 Decorate 39(gss) DescriptorSet 0
Decorate 43(gtex) DescriptorSet 0
Decorate 57(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeSampler 6: TypeSampler
7: TypePointer UniformConstant 6
8: TypeFloat 32 8: TypeFloat 32
10: TypeImage 8(float) 2D sampled format:Unknown 10: TypeImage 8(float) 2D sampled format:Unknown
11: TypePointer UniformConstant 10
12: TypeVector 8(float) 4 12: TypeVector 8(float) 4
25: TypeSampledImage 10 25: TypeSampledImage 10
27: TypeVector 8(float) 2 27: TypeVector 8(float) 2
28: 8(float) Constant 1045220557 28: 8(float) Constant 1045220557
29: 8(float) Constant 1050253722 29: 8(float) Constant 1050253722
30: 27(fvec2) ConstantComposite 28 29 30: 27(fvec2) ConstantComposite 28 29
36(gss): 7(ptr) Variable UniformConstant 36: TypePointer UniformConstant 6
37(gtex): 11(ptr) Variable UniformConstant 37(gss2): 36(ptr) Variable UniformConstant
39: 8(float) Constant 1077936128 39(gss): 36(ptr) Variable UniformConstant
45: TypePointer Output 12(fvec4) 42: TypePointer UniformConstant 10
46(@entryPointOutput): 45(ptr) Variable Output 43(gtex): 42(ptr) Variable UniformConstant
46: 8(float) Constant 1077936128
56: TypePointer Output 12(fvec4)
57(@entryPointOutput): 56(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
56: 10 Load 37(gtex) 68: 6 Load 39(gss)
57: 6 Load 36(gss) 69: 10 Load 43(gtex)
58: 25 SampledImage 56 57 78: 25 SampledImage 69 68
59: 12(fvec4) ImageSampleImplicitLod 58 30 79: 12(fvec4) ImageSampleImplicitLod 78 30
60: 12(fvec4) VectorTimesScalar 59 39 80: 12(fvec4) VectorTimesScalar 79 46
Store 46(@entryPointOutput) 60 Store 57(@entryPointOutput) 80
Return Return
FunctionEnd FunctionEnd
hlsl.flattenOpaque.frag hlsl.flattenOpaque.frag
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 118 // Id's are bound by 144
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 83 EntryPoint Fragment 4 "main" 97
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
Name 37 "tex" Name 38 "tex"
Name 68 "s.s2D" Name 70 "s.s2D"
Name 73 "s2.s2D" Name 79 "s2.s2D"
Name 74 "s2.tex" Name 80 "s2.tex"
Name 83 "@entryPointOutput" Name 97 "@entryPointOutput"
Decorate 37(tex) DescriptorSet 0 Decorate 38(tex) DescriptorSet 0
Decorate 68(s.s2D) DescriptorSet 0 Decorate 70(s.s2D) DescriptorSet 0
Decorate 73(s2.s2D) DescriptorSet 0 Decorate 79(s2.s2D) DescriptorSet 0
Decorate 74(s2.tex) DescriptorSet 0 Decorate 80(s2.tex) DescriptorSet 0
Decorate 83(@entryPointOutput) Location 0 Decorate 97(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeSampler 6: TypeSampler
7: TypePointer UniformConstant 6
8: TypeFloat 32 8: TypeFloat 32
9: TypeVector 8(float) 4 9: TypeVector 8(float) 4
14: TypeVector 8(float) 2 14: TypeVector 8(float) 2
21: TypeImage 8(float) 2D sampled format:Unknown 21: TypeImage 8(float) 2D sampled format:Unknown
22: TypePointer UniformConstant 21 37: TypePointer UniformConstant 21
37(tex): 22(ptr) Variable UniformConstant 38(tex): 37(ptr) Variable UniformConstant
40: TypeSampledImage 21 41: TypeSampledImage 21
42: 8(float) Constant 1045220557 43: 8(float) Constant 1045220557
43: 8(float) Constant 1050253722 44: 8(float) Constant 1050253722
44: 14(fvec2) ConstantComposite 42 43 45: 14(fvec2) ConstantComposite 43 44
68(s.s2D): 7(ptr) Variable UniformConstant 69: TypePointer UniformConstant 6
73(s2.s2D): 7(ptr) Variable UniformConstant 70(s.s2D): 69(ptr) Variable UniformConstant
74(s2.tex): 22(ptr) Variable UniformConstant 79(s2.s2D): 69(ptr) Variable UniformConstant
82: TypePointer Output 9(fvec4) 80(s2.tex): 37(ptr) Variable UniformConstant
83(@entryPointOutput): 82(ptr) Variable Output 96: TypePointer Output 9(fvec4)
97(@entryPointOutput): 96(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
97: 21 Load 37(tex) 109: 6 Load 70(s.s2D)
98: 6 Load 68(s.s2D) 123: 21 Load 38(tex)
99: 40 SampledImage 97 98 125: 41 SampledImage 123 109
100: 9(fvec4) ImageSampleImplicitLod 99 44 126: 9(fvec4) ImageSampleImplicitLod 125 45
102: 21 Load 37(tex) 111: 6 Load 70(s.s2D)
103: 6 Load 68(s.s2D) 128: 21 Load 38(tex)
104: 40 SampledImage 102 103 130: 41 SampledImage 128 111
106: 9(fvec4) ImageSampleImplicitLod 104 44 132: 9(fvec4) ImageSampleImplicitLod 130 45
91: 9(fvec4) FAdd 100 106 113: 9(fvec4) FAdd 126 132
108: 21 Load 74(s2.tex) 114: 6 Load 79(s2.s2D)
109: 6 Load 73(s2.s2D) 115: 21 Load 80(s2.tex)
110: 40 SampledImage 108 109 136: 41 SampledImage 115 114
111: 9(fvec4) ImageSampleImplicitLod 110 44 137: 9(fvec4) ImageSampleImplicitLod 136 45
93: 9(fvec4) FAdd 91 111 117: 9(fvec4) FAdd 113 137
113: 21 Load 74(s2.tex) 118: 6 Load 79(s2.s2D)
114: 6 Load 73(s2.s2D) 119: 21 Load 80(s2.tex)
115: 40 SampledImage 113 114 141: 41 SampledImage 119 118
117: 9(fvec4) ImageSampleImplicitLod 115 44 143: 9(fvec4) ImageSampleImplicitLod 141 45
95: 9(fvec4) FAdd 93 117 121: 9(fvec4) FAdd 117 143
Store 83(@entryPointOutput) 95 Store 97(@entryPointOutput) 121
Return Return
FunctionEnd FunctionEnd
hlsl.flattenOpaqueInit.vert hlsl.flattenOpaqueInit.vert
WARNING: 0:20: '=' : cannot do member-wise aliasing for opaque members with this initializer WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 76 // Id's are bound by 117
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 58 EntryPoint Vertex 4 "main" 78
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
Name 17 "FxaaTex" Name 17 "FxaaTex"
MemberName 17(FxaaTex) 0 "smpl" MemberName 17(FxaaTex) 0 "smpl"
MemberName 17(FxaaTex) 1 "tex" MemberName 17(FxaaTex) 1 "tex"
Name 36 "g_tInputTexture_sampler" Name 38 "g_tInputTexture_sampler"
Name 37 "g_tInputTexture" Name 42 "g_tInputTexture"
Name 39 "t" Name 78 "@entryPointOutput"
Name 43 "flattenTemp" Decorate 38(g_tInputTexture_sampler) DescriptorSet 0
Name 45 "tex2.smpl" Decorate 42(g_tInputTexture) DescriptorSet 0
Name 50 "tex2.tex" Decorate 78(@entryPointOutput) Location 0
Name 58 "@entryPointOutput"
Decorate 36(g_tInputTexture_sampler) DescriptorSet 0
Decorate 37(g_tInputTexture) DescriptorSet 0
Decorate 58(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeSampler 6: TypeSampler
7: TypePointer UniformConstant 6
8: TypeFloat 32 8: TypeFloat 32
9: TypeImage 8(float) 2D sampled format:Unknown 9: TypeImage 8(float) 2D sampled format:Unknown
10: TypePointer UniformConstant 9
11: TypeVector 8(float) 4 11: TypeVector 8(float) 4
17(FxaaTex): TypeStruct 6 9 17(FxaaTex): TypeStruct 6 9
26: TypeSampledImage 9 26: TypeSampledImage 9
...@@ -39,32 +32,18 @@ WARNING: 0:20: '=' : cannot do member-wise aliasing for opaque members with this ...@@ -39,32 +32,18 @@ WARNING: 0:20: '=' : cannot do member-wise aliasing for opaque members with this
30: 8(float) Constant 1053609165 30: 8(float) Constant 1053609165
31: 28(fvec2) ConstantComposite 29 30 31: 28(fvec2) ConstantComposite 29 30
32: 8(float) Constant 0 32: 8(float) Constant 0
36(g_tInputTexture_sampler): 7(ptr) Variable UniformConstant 37: TypePointer UniformConstant 6
37(g_tInputTexture): 10(ptr) Variable UniformConstant 38(g_tInputTexture_sampler): 37(ptr) Variable UniformConstant
38: TypePointer UniformConstant 17(FxaaTex) 41: TypePointer UniformConstant 9
39(t): 38(ptr) Variable UniformConstant 42(g_tInputTexture): 41(ptr) Variable UniformConstant
43(flattenTemp): 38(ptr) Variable UniformConstant 77: TypePointer Output 11(fvec4)
45(tex2.smpl): 7(ptr) Variable UniformConstant 78(@entryPointOutput): 77(ptr) Variable Output
46: TypeInt 32 1
47: 46(int) Constant 0
50(tex2.tex): 10(ptr) Variable UniformConstant
51: 46(int) Constant 1
57: TypePointer Output 11(fvec4)
58(@entryPointOutput): 57(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
70: 17(FxaaTex) Load 39(t) 90: 6 Load 38(g_tInputTexture_sampler)
Store 43(flattenTemp) 70 91: 9 Load 42(g_tInputTexture)
63: 7(ptr) AccessChain 43(flattenTemp) 47 115: 26 SampledImage 91 90
64: 6 Load 63 116: 11(fvec4) ImageSampleExplicitLod 115 31 Lod 32
Store 45(tex2.smpl) 64 Store 78(@entryPointOutput) 116
65: 10(ptr) AccessChain 43(flattenTemp) 51
66: 9 Load 65
Store 50(tex2.tex) 66
72: 9 Load 37(g_tInputTexture)
73: 6 Load 36(g_tInputTexture_sampler)
74: 26 SampledImage 72 73
75: 11(fvec4) ImageSampleExplicitLod 74 31 Lod 32
Store 58(@entryPointOutput) 75
Return Return
FunctionEnd FunctionEnd
hlsl.flattenOpaqueInitMix.vert hlsl.flattenOpaqueInitMix.vert
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 60 // Id's are bound by 100
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 44 EntryPoint Vertex 4 "main" 68
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
Name 36 "g_tInputTexture_sampler" Name 34 "FxaaTex"
Name 37 "g_tInputTexture" MemberName 34(FxaaTex) 0 "smpl"
Name 44 "@entryPointOutput" MemberName 34(FxaaTex) 1 "tex"
Decorate 36(g_tInputTexture_sampler) DescriptorSet 0 MemberName 34(FxaaTex) 2 "f"
Decorate 37(g_tInputTexture) DescriptorSet 0 Name 38 "g_tInputTexture_sampler"
Decorate 44(@entryPointOutput) Location 0 Name 41 "g_tInputTexture"
Name 68 "@entryPointOutput"
Decorate 38(g_tInputTexture_sampler) DescriptorSet 0
Decorate 41(g_tInputTexture) DescriptorSet 0
Decorate 68(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeSampler 6: TypeSampler
7: TypePointer UniformConstant 6
8: TypeFloat 32 8: TypeFloat 32
9: TypeImage 8(float) 2D sampled format:Unknown 9: TypeImage 8(float) 2D sampled format:Unknown
10: TypePointer UniformConstant 9
12: TypeVector 8(float) 4 12: TypeVector 8(float) 4
24: TypeSampledImage 9 24: TypeSampledImage 9
28: TypeVector 8(float) 2 28: TypeVector 8(float) 2
30: 8(float) Constant 0 30: 8(float) Constant 0
35: 8(float) Constant 1056964608 34(FxaaTex): TypeStruct 6 9 8(float)
36(g_tInputTexture_sampler): 7(ptr) Variable UniformConstant 37: TypePointer UniformConstant 6
37(g_tInputTexture): 10(ptr) Variable UniformConstant 38(g_tInputTexture_sampler): 37(ptr) Variable UniformConstant
43: TypePointer Output 12(fvec4) 40: TypePointer UniformConstant 9
44(@entryPointOutput): 43(ptr) Variable Output 41(g_tInputTexture): 40(ptr) Variable UniformConstant
43: 8(float) Constant 1056964608
67: TypePointer Output 12(fvec4)
68(@entryPointOutput): 67(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
53: 9 Load 37(g_tInputTexture) 79: 6 Load 38(g_tInputTexture_sampler)
54: 6 Load 36(g_tInputTexture_sampler) 80: 9 Load 41(g_tInputTexture)
55: 24 SampledImage 53 54 95: 24 SampledImage 80 79
58: 28(fvec2) CompositeConstruct 35 35 98: 28(fvec2) CompositeConstruct 43 43
59: 12(fvec4) ImageSampleExplicitLod 55 58 Lod 30 99: 12(fvec4) ImageSampleExplicitLod 95 98 Lod 30
Store 44(@entryPointOutput) 59 Store 68(@entryPointOutput) 99
Return Return
FunctionEnd FunctionEnd
hlsl.aliasOpaque.frag hlsl.aliasOpaque.frag
WARNING: AST will form illegal SPIR-V; need to transform to legalize
Shader version: 500 Shader version: 500
gl_FragCoord origin is upper left gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
...@@ -21,18 +22,24 @@ gl_FragCoord origin is upper left ...@@ -21,18 +22,24 @@ gl_FragCoord origin is upper left
0:17 Function Definition: @main( ( temp 4-component vector of float) 0:17 Function Definition: @main( ( temp 4-component vector of float)
0:17 Function Parameters: 0:17 Function Parameters:
0:? Sequence 0:? Sequence
0:19 'gss2' ( uniform sampler) 0:19 move second child to first child ( temp sampler)
0:20 'gss' ( uniform sampler) 0:? 'os.ss' ( temp sampler)
0:21 'gtex' ( uniform texture2D) 0:19 'gss2' ( uniform sampler)
0:20 move second child to first child ( temp sampler)
0:? 'os.ss' ( temp sampler)
0:20 'gss' ( uniform sampler)
0:21 move second child to first child ( temp texture2D)
0:? 'os.tex' ( temp texture2D)
0:21 'gtex' ( uniform texture2D)
0:22 move second child to first child ( temp float) 0:22 move second child to first child ( temp float)
0:? 'os.a' ( temp float) 0:? 'os.a' ( temp float)
0:22 Constant: 0:22 Constant:
0:22 3.000000 0:22 3.000000
0:28 Branch: Return with expression 0:28 Branch: Return with expression
0:28 Function Call: osCall(struct-OS-p1-f1-t211; ( temp 4-component vector of float) 0:28 Function Call: osCall(struct-OS-p1-f1-t211; ( temp 4-component vector of float)
0:? 'gss' ( uniform sampler) 0:? 'os.ss' ( temp sampler)
0:? 'os.a' ( temp float) 0:? 'os.a' ( temp float)
0:? 'gtex' ( uniform texture2D) 0:? 'os.tex' ( temp texture2D)
0:17 Function Definition: main( ( temp void) 0:17 Function Definition: main( ( temp void)
0:17 Function Parameters: 0:17 Function Parameters:
0:? Sequence 0:? Sequence
...@@ -71,18 +78,24 @@ gl_FragCoord origin is upper left ...@@ -71,18 +78,24 @@ gl_FragCoord origin is upper left
0:17 Function Definition: @main( ( temp 4-component vector of float) 0:17 Function Definition: @main( ( temp 4-component vector of float)
0:17 Function Parameters: 0:17 Function Parameters:
0:? Sequence 0:? Sequence
0:19 'gss2' ( uniform sampler) 0:19 move second child to first child ( temp sampler)
0:20 'gss' ( uniform sampler) 0:? 'os.ss' ( temp sampler)
0:21 'gtex' ( uniform texture2D) 0:19 'gss2' ( uniform sampler)
0:20 move second child to first child ( temp sampler)
0:? 'os.ss' ( temp sampler)
0:20 'gss' ( uniform sampler)
0:21 move second child to first child ( temp texture2D)
0:? 'os.tex' ( temp texture2D)
0:21 'gtex' ( uniform texture2D)
0:22 move second child to first child ( temp float) 0:22 move second child to first child ( temp float)
0:? 'os.a' ( temp float) 0:? 'os.a' ( temp float)
0:22 Constant: 0:22 Constant:
0:22 3.000000 0:22 3.000000
0:28 Branch: Return with expression 0:28 Branch: Return with expression
0:28 Function Call: osCall(struct-OS-p1-f1-t211; ( temp 4-component vector of float) 0:28 Function Call: osCall(struct-OS-p1-f1-t211; ( temp 4-component vector of float)
0:? 'gss' ( uniform sampler) 0:? 'os.ss' ( temp sampler)
0:? 'os.a' ( temp float) 0:? 'os.a' ( temp float)
0:? 'gtex' ( uniform texture2D) 0:? 'os.tex' ( temp texture2D)
0:17 Function Definition: main( ( temp void) 0:17 Function Definition: main( ( temp void)
0:17 Function Parameters: 0:17 Function Parameters:
0:? Sequence 0:? Sequence
...@@ -97,12 +110,12 @@ gl_FragCoord origin is upper left ...@@ -97,12 +110,12 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 48 // Id's are bound by 59
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 46 EntryPoint Fragment 4 "main" 57
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
...@@ -111,24 +124,28 @@ gl_FragCoord origin is upper left ...@@ -111,24 +124,28 @@ gl_FragCoord origin is upper left
Name 15 "s.a" Name 15 "s.a"
Name 16 "s.tex" Name 16 "s.tex"
Name 20 "@main(" Name 20 "@main("
Name 35 "gss2" Name 35 "os.ss"
Name 36 "gss" Name 37 "gss2"
Name 37 "gtex" Name 39 "gss"
Name 38 "os.a" Name 41 "os.tex"
Name 40 "param" Name 43 "gtex"
Name 46 "@entryPointOutput" Name 45 "os.a"
Decorate 35(gss2) DescriptorSet 0 Name 47 "param"
Decorate 36(gss) DescriptorSet 0 Name 49 "param"
Decorate 37(gtex) DescriptorSet 0 Name 51 "param"
Decorate 46(@entryPointOutput) Location 0 Name 57 "@entryPointOutput"
Decorate 37(gss2) DescriptorSet 0
Decorate 39(gss) DescriptorSet 0
Decorate 43(gtex) DescriptorSet 0
Decorate 57(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeSampler 6: TypeSampler
7: TypePointer UniformConstant 6 7: TypePointer Function 6
8: TypeFloat 32 8: TypeFloat 32
9: TypePointer Function 8(float) 9: TypePointer Function 8(float)
10: TypeImage 8(float) 2D sampled format:Unknown 10: TypeImage 8(float) 2D sampled format:Unknown
11: TypePointer UniformConstant 10 11: TypePointer Function 10
12: TypeVector 8(float) 4 12: TypeVector 8(float) 4
13: TypeFunction 12(fvec4) 7(ptr) 9(ptr) 11(ptr) 13: TypeFunction 12(fvec4) 7(ptr) 9(ptr) 11(ptr)
19: TypeFunction 12(fvec4) 19: TypeFunction 12(fvec4)
...@@ -137,16 +154,18 @@ gl_FragCoord origin is upper left ...@@ -137,16 +154,18 @@ gl_FragCoord origin is upper left
28: 8(float) Constant 1045220557 28: 8(float) Constant 1045220557
29: 8(float) Constant 1050253722 29: 8(float) Constant 1050253722
30: 27(fvec2) ConstantComposite 28 29 30: 27(fvec2) ConstantComposite 28 29
35(gss2): 7(ptr) Variable UniformConstant 36: TypePointer UniformConstant 6
36(gss): 7(ptr) Variable UniformConstant 37(gss2): 36(ptr) Variable UniformConstant
37(gtex): 11(ptr) Variable UniformConstant 39(gss): 36(ptr) Variable UniformConstant
39: 8(float) Constant 1077936128 42: TypePointer UniformConstant 10
45: TypePointer Output 12(fvec4) 43(gtex): 42(ptr) Variable UniformConstant
46(@entryPointOutput): 45(ptr) Variable Output 46: 8(float) Constant 1077936128
56: TypePointer Output 12(fvec4)
57(@entryPointOutput): 56(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
47: 12(fvec4) FunctionCall 20(@main() 58: 12(fvec4) FunctionCall 20(@main()
Store 46(@entryPointOutput) 47 Store 57(@entryPointOutput) 58
Return Return
FunctionEnd FunctionEnd
17(osCall(struct-OS-p1-f1-t211;): 12(fvec4) Function None 13 17(osCall(struct-OS-p1-f1-t211;): 12(fvec4) Function None 13
...@@ -164,11 +183,25 @@ gl_FragCoord origin is upper left ...@@ -164,11 +183,25 @@ gl_FragCoord origin is upper left
FunctionEnd FunctionEnd
20(@main(): 12(fvec4) Function None 19 20(@main(): 12(fvec4) Function None 19
21: Label 21: Label
38(os.a): 9(ptr) Variable Function 35(os.ss): 7(ptr) Variable Function
40(param): 9(ptr) Variable Function 41(os.tex): 11(ptr) Variable Function
Store 38(os.a) 39 45(os.a): 9(ptr) Variable Function
41: 8(float) Load 38(os.a) 47(param): 7(ptr) Variable Function
Store 40(param) 41 49(param): 9(ptr) Variable Function
42: 12(fvec4) FunctionCall 17(osCall(struct-OS-p1-f1-t211;) 36(gss) 40(param) 37(gtex) 51(param): 11(ptr) Variable Function
ReturnValue 42 38: 6 Load 37(gss2)
Store 35(os.ss) 38
40: 6 Load 39(gss)
Store 35(os.ss) 40
44: 10 Load 43(gtex)
Store 41(os.tex) 44
Store 45(os.a) 46
48: 6 Load 35(os.ss)
Store 47(param) 48
50: 8(float) Load 45(os.a)
Store 49(param) 50
52: 10 Load 41(os.tex)
Store 51(param) 52
53: 12(fvec4) FunctionCall 17(osCall(struct-OS-p1-f1-t211;) 47(param) 49(param) 51(param)
ReturnValue 53
FunctionEnd FunctionEnd
...@@ -59,7 +59,7 @@ gl_FragCoord origin is upper left ...@@ -59,7 +59,7 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 26 // Id's are bound by 27
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
...@@ -68,44 +68,45 @@ gl_FragCoord origin is upper left ...@@ -68,44 +68,45 @@ gl_FragCoord origin is upper left
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
Name 14 "TexFunc(t21;vf3;" Name 13 "TexFunc(t21;vf3;"
Name 12 "t2D" Name 11 "t2D"
Name 13 "RGB" Name 12 "RGB"
Name 16 "@main(" Name 15 "@main("
Name 20 "MyTexture" Name 20 "MyTexture"
Name 21 "final_RGB" Name 22 "final_RGB"
Name 22 "param" Name 23 "param"
Decorate 20(MyTexture) DescriptorSet 0 Decorate 20(MyTexture) DescriptorSet 0
Decorate 20(MyTexture) Binding 0 Decorate 20(MyTexture) Binding 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
7: TypeImage 6(float) 2D sampled format:Unknown 7: TypeImage 6(float) 2D sampled format:Unknown
8: TypePointer UniformConstant 7 8: TypeVector 6(float) 3
9: TypeVector 6(float) 3 9: TypePointer Function 8(fvec3)
10: TypePointer Function 9(fvec3) 10: TypeFunction 2 7 9(ptr)
11: TypeFunction 2 8(ptr) 10(ptr) 17: 6(float) Constant 0
18: 6(float) Constant 0 18: 8(fvec3) ConstantComposite 17 17 17
19: 9(fvec3) ConstantComposite 18 18 18 19: TypePointer UniformConstant 7
20(MyTexture): 8(ptr) Variable UniformConstant 20(MyTexture): 19(ptr) Variable UniformConstant
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
25: 2 FunctionCall 16(@main() 26: 2 FunctionCall 15(@main()
Return Return
FunctionEnd FunctionEnd
14(TexFunc(t21;vf3;): 2 Function None 11 13(TexFunc(t21;vf3;): 2 Function None 10
12(t2D): 8(ptr) FunctionParameter 11(t2D): 7 FunctionParameter
13(RGB): 10(ptr) FunctionParameter 12(RGB): 9(ptr) FunctionParameter
15: Label 14: Label
Store 13(RGB) 19 Store 12(RGB) 18
Return Return
FunctionEnd FunctionEnd
16(@main(): 2 Function None 3 15(@main(): 2 Function None 3
17: Label 16: Label
21(final_RGB): 10(ptr) Variable Function 22(final_RGB): 9(ptr) Variable Function
22(param): 10(ptr) Variable Function 23(param): 9(ptr) Variable Function
23: 2 FunctionCall 14(TexFunc(t21;vf3;) 20(MyTexture) 22(param) 21: 7 Load 20(MyTexture)
24: 9(fvec3) Load 22(param) 24: 2 FunctionCall 13(TexFunc(t21;vf3;) 21 23(param)
Store 21(final_RGB) 24 25: 8(fvec3) Load 23(param)
Store 22(final_RGB) 25
Return Return
FunctionEnd FunctionEnd
...@@ -151,12 +151,12 @@ gl_FragCoord origin is upper left ...@@ -151,12 +151,12 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 70 // Id's are bound by 76
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 58 61 EntryPoint Fragment 4 "main" 64 67
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
...@@ -171,51 +171,55 @@ gl_FragCoord origin is upper left ...@@ -171,51 +171,55 @@ gl_FragCoord origin is upper left
Name 18 "arg_c@count" Name 18 "arg_c@count"
Name 25 "@main(u1;" Name 25 "@main(u1;"
Name 24 "pos" Name 24 "pos"
Name 49 "sbuf_a" Name 50 "sbuf_a"
Name 50 "sbuf_a@count" Name 52 "sbuf_a@count"
Name 51 "sbuf_c" Name 53 "sbuf_c"
Name 52 "sbuf_c@count" Name 54 "sbuf_c@count"
Name 56 "pos" Name 55 "param"
Name 58 "pos" Name 56 "param"
Name 61 "@entryPointOutput" Name 57 "param"
Name 62 "param" Name 58 "param"
Name 65 "sbuf_a@count" Name 62 "pos"
MemberName 65(sbuf_a@count) 0 "@count" Name 64 "pos"
Name 67 "sbuf_a@count" Name 67 "@entryPointOutput"
Name 68 "sbuf_c@count" Name 68 "param"
Name 69 "sbuf_unused" Name 71 "sbuf_a@count"
MemberName 71(sbuf_a@count) 0 "@count"
Name 73 "sbuf_a@count"
Name 74 "sbuf_c@count"
Name 75 "sbuf_unused"
Decorate 8 ArrayStride 16 Decorate 8 ArrayStride 16
MemberDecorate 9 0 Offset 0 MemberDecorate 9 0 Offset 0
Decorate 9 BufferBlock Decorate 9 BufferBlock
Decorate 12 BufferBlock Decorate 12 BufferBlock
Decorate 49(sbuf_a) DescriptorSet 0 Decorate 50(sbuf_a) DescriptorSet 0
Decorate 50(sbuf_a@count) DescriptorSet 0 Decorate 52(sbuf_a@count) DescriptorSet 0
Decorate 51(sbuf_c) DescriptorSet 0 Decorate 53(sbuf_c) DescriptorSet 0
Decorate 52(sbuf_c@count) DescriptorSet 0 Decorate 54(sbuf_c@count) DescriptorSet 0
Decorate 58(pos) Flat Decorate 64(pos) Flat
Decorate 58(pos) Location 0 Decorate 64(pos) Location 0
Decorate 61(@entryPointOutput) Location 0 Decorate 67(@entryPointOutput) Location 0
MemberDecorate 65(sbuf_a@count) 0 Offset 0 MemberDecorate 71(sbuf_a@count) 0 Offset 0
Decorate 65(sbuf_a@count) BufferBlock Decorate 71(sbuf_a@count) BufferBlock
Decorate 67(sbuf_a@count) DescriptorSet 0 Decorate 73(sbuf_a@count) DescriptorSet 0
Decorate 68(sbuf_c@count) DescriptorSet 0 Decorate 74(sbuf_c@count) DescriptorSet 0
Decorate 69(sbuf_unused) DescriptorSet 0 Decorate 75(sbuf_unused) DescriptorSet 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
7: TypeVector 6(float) 4 7: TypeVector 6(float) 4
8: TypeRuntimeArray 7(fvec4) 8: TypeRuntimeArray 7(fvec4)
9: TypeStruct 8 9: TypeStruct 8
10: TypePointer Uniform 9(struct) 10: TypePointer Function 9(struct)
11: TypeInt 32 1 11: TypeInt 32 1
12: TypeStruct 11(int) 12: TypeStruct 11(int)
13: TypePointer Uniform 12(struct) 13: TypePointer Function 12(struct)
14: TypeFunction 7(fvec4) 10(ptr) 13(ptr) 10(ptr) 13(ptr) 14: TypeFunction 7(fvec4) 10(ptr) 13(ptr) 10(ptr) 13(ptr)
21: TypeInt 32 0 21: TypeInt 32 0
22: TypePointer Function 21(int) 22: TypePointer Function 21(int)
23: TypeFunction 7(fvec4) 22(ptr) 23: TypeFunction 7(fvec4) 22(ptr)
27: 11(int) Constant 0 27: 11(int) Constant 0
28: TypePointer Uniform 11(int) 28: TypePointer Function 11(int)
30: 11(int) Constant 1 30: 11(int) Constant 1
31: 21(int) Constant 1 31: 21(int) Constant 1
32: 21(int) Constant 0 32: 21(int) Constant 0
...@@ -224,31 +228,33 @@ gl_FragCoord origin is upper left ...@@ -224,31 +228,33 @@ gl_FragCoord origin is upper left
36: 6(float) Constant 1077936128 36: 6(float) Constant 1077936128
37: 6(float) Constant 1082130432 37: 6(float) Constant 1082130432
38: 7(fvec4) ConstantComposite 34 35 36 37 38: 7(fvec4) ConstantComposite 34 35 36 37
39: TypePointer Uniform 7(fvec4) 39: TypePointer Function 7(fvec4)
42: 11(int) Constant 4294967295 42: 11(int) Constant 4294967295
49(sbuf_a): 10(ptr) Variable Uniform 49: TypePointer Uniform 9(struct)
50(sbuf_a@count): 13(ptr) Variable Uniform 50(sbuf_a): 49(ptr) Variable Uniform
51(sbuf_c): 10(ptr) Variable Uniform 51: TypePointer Uniform 12(struct)
52(sbuf_c@count): 13(ptr) Variable Uniform 52(sbuf_a@count): 51(ptr) Variable Uniform
57: TypePointer Input 21(int) 53(sbuf_c): 49(ptr) Variable Uniform
58(pos): 57(ptr) Variable Input 54(sbuf_c@count): 51(ptr) Variable Uniform
60: TypePointer Output 7(fvec4) 63: TypePointer Input 21(int)
61(@entryPointOutput): 60(ptr) Variable Output 64(pos): 63(ptr) Variable Input
65(sbuf_a@count): TypeStruct 11(int) 66: TypePointer Output 7(fvec4)
66: TypePointer Uniform 65(sbuf_a@count) 67(@entryPointOutput): 66(ptr) Variable Output
67(sbuf_a@count): 66(ptr) Variable Uniform 71(sbuf_a@count): TypeStruct 11(int)
68(sbuf_c@count): 66(ptr) Variable Uniform 72: TypePointer Uniform 71(sbuf_a@count)
69(sbuf_unused): 10(ptr) Variable Uniform 73(sbuf_a@count): 72(ptr) Variable Uniform
74(sbuf_c@count): 72(ptr) Variable Uniform
75(sbuf_unused): 49(ptr) Variable Uniform
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
56(pos): 22(ptr) Variable Function 62(pos): 22(ptr) Variable Function
62(param): 22(ptr) Variable Function 68(param): 22(ptr) Variable Function
59: 21(int) Load 58(pos) 65: 21(int) Load 64(pos)
Store 56(pos) 59 Store 62(pos) 65
63: 21(int) Load 56(pos) 69: 21(int) Load 62(pos)
Store 62(param) 63 Store 68(param) 69
64: 7(fvec4) FunctionCall 25(@main(u1;) 62(param) 70: 7(fvec4) FunctionCall 25(@main(u1;) 68(param)
Store 61(@entryPointOutput) 64 Store 67(@entryPointOutput) 70
Return Return
FunctionEnd FunctionEnd
19(Fn2(block--vf4[0]1;block--vf4[0]1;): 7(fvec4) Function None 14 19(Fn2(block--vf4[0]1;block--vf4[0]1;): 7(fvec4) Function None 14
...@@ -271,6 +277,10 @@ gl_FragCoord origin is upper left ...@@ -271,6 +277,10 @@ gl_FragCoord origin is upper left
25(@main(u1;): 7(fvec4) Function None 23 25(@main(u1;): 7(fvec4) Function None 23
24(pos): 22(ptr) FunctionParameter 24(pos): 22(ptr) FunctionParameter
26: Label 26: Label
53: 7(fvec4) FunctionCall 19(Fn2(block--vf4[0]1;block--vf4[0]1;) 49(sbuf_a) 50(sbuf_a@count) 51(sbuf_c) 52(sbuf_c@count) 55(param): 10(ptr) Variable Function
ReturnValue 53 56(param): 13(ptr) Variable Function
57(param): 10(ptr) Variable Function
58(param): 13(ptr) Variable Function
59: 7(fvec4) FunctionCall 19(Fn2(block--vf4[0]1;block--vf4[0]1;) 55(param) 56(param) 57(param) 58(param)
ReturnValue 59
FunctionEnd FunctionEnd
...@@ -135,14 +135,14 @@ local_size = (256, 1, 1) ...@@ -135,14 +135,14 @@ local_size = (256, 1, 1)
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 61 // Id's are bound by 62
Capability Shader Capability Shader
Capability ImageBuffer Capability ImageBuffer
Capability StorageImageExtendedFormats Capability StorageImageExtendedFormats
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main" 56 EntryPoint GLCompute 4 "main" 57
ExecutionMode 4 LocalSize 256 1 1 ExecutionMode 4 LocalSize 256 1 1
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
...@@ -155,13 +155,14 @@ local_size = (256, 1, 1) ...@@ -155,13 +155,14 @@ local_size = (256, 1, 1)
Name 18 "dispatchId" Name 18 "dispatchId"
Name 22 "result" Name 22 "result"
Name 25 "byteAddrTemp" Name 25 "byteAddrTemp"
Name 43 "result" Name 42 "result"
Name 44 "g_input" Name 44 "g_input"
Name 45 "param" Name 45 "param"
Name 50 "g_output" Name 47 "param"
Name 54 "dispatchId" Name 51 "g_output"
Name 56 "dispatchId" Name 55 "dispatchId"
Name 58 "param" Name 57 "dispatchId"
Name 59 "param"
Decorate 8 ArrayStride 4 Decorate 8 ArrayStride 4
MemberDecorate 9 0 NonWritable MemberDecorate 9 0 NonWritable
MemberDecorate 9 0 Offset 0 MemberDecorate 9 0 Offset 0
...@@ -169,16 +170,16 @@ local_size = (256, 1, 1) ...@@ -169,16 +170,16 @@ local_size = (256, 1, 1)
Decorate 14(buffer) NonWritable Decorate 14(buffer) NonWritable
Decorate 44(g_input) DescriptorSet 0 Decorate 44(g_input) DescriptorSet 0
Decorate 44(g_input) Binding 0 Decorate 44(g_input) Binding 0
Decorate 50(g_output) DescriptorSet 0 Decorate 51(g_output) DescriptorSet 0
Decorate 50(g_output) Binding 1 Decorate 51(g_output) Binding 1
Decorate 56(dispatchId) BuiltIn GlobalInvocationId Decorate 57(dispatchId) BuiltIn GlobalInvocationId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 0 6: TypeInt 32 0
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
8: TypeRuntimeArray 6(int) 8: TypeRuntimeArray 6(int)
9: TypeStruct 8 9: TypeStruct 8
10: TypePointer Uniform 9(struct) 10: TypePointer Function 9(struct)
11: TypeVector 6(int) 2 11: TypeVector 6(int) 2
12: TypeFunction 11(ivec2) 7(ptr) 10(ptr) 12: TypeFunction 11(ivec2) 7(ptr) 10(ptr)
17: TypeFunction 2 7(ptr) 17: TypeFunction 2 7(ptr)
...@@ -187,23 +188,23 @@ local_size = (256, 1, 1) ...@@ -187,23 +188,23 @@ local_size = (256, 1, 1)
24: TypePointer Function 23(int) 24: TypePointer Function 23(int)
27: 23(int) Constant 2 27: 23(int) Constant 2
29: 23(int) Constant 0 29: 23(int) Constant 0
31: TypePointer Uniform 6(int) 34: 23(int) Constant 1
35: 23(int) Constant 1 43: TypePointer Uniform 9(struct)
44(g_input): 10(ptr) Variable Uniform 44(g_input): 43(ptr) Variable Uniform
48: TypeImage 6(int) Buffer nonsampled format:Rg32ui 49: TypeImage 6(int) Buffer nonsampled format:Rg32ui
49: TypePointer UniformConstant 48 50: TypePointer UniformConstant 49
50(g_output): 49(ptr) Variable UniformConstant 51(g_output): 50(ptr) Variable UniformConstant
55: TypePointer Input 6(int) 56: TypePointer Input 6(int)
56(dispatchId): 55(ptr) Variable Input 57(dispatchId): 56(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
54(dispatchId): 7(ptr) Variable Function 55(dispatchId): 7(ptr) Variable Function
58(param): 7(ptr) Variable Function 59(param): 7(ptr) Variable Function
57: 6(int) Load 56(dispatchId) 58: 6(int) Load 57(dispatchId)
Store 54(dispatchId) 57 Store 55(dispatchId) 58
59: 6(int) Load 54(dispatchId) 60: 6(int) Load 55(dispatchId)
Store 58(param) 59 Store 59(param) 60
60: 2 FunctionCall 19(@main(u1;) 58(param) 61: 2 FunctionCall 19(@main(u1;) 59(param)
Return Return
FunctionEnd FunctionEnd
15(testLoad(u1;block--u1[0]1;): 11(ivec2) Function None 12 15(testLoad(u1;block--u1[0]1;): 11(ivec2) Function None 12
...@@ -216,29 +217,30 @@ local_size = (256, 1, 1) ...@@ -216,29 +217,30 @@ local_size = (256, 1, 1)
28: 23(int) ShiftRightLogical 26 27 28: 23(int) ShiftRightLogical 26 27
Store 25(byteAddrTemp) 28 Store 25(byteAddrTemp) 28
30: 23(int) Load 25(byteAddrTemp) 30: 23(int) Load 25(byteAddrTemp)
32: 31(ptr) AccessChain 14(buffer) 29 30 31: 7(ptr) AccessChain 14(buffer) 29 30
33: 6(int) Load 32 32: 6(int) Load 31
34: 23(int) Load 25(byteAddrTemp) 33: 23(int) Load 25(byteAddrTemp)
36: 23(int) IAdd 34 35 35: 23(int) IAdd 33 34
37: 31(ptr) AccessChain 14(buffer) 29 36 36: 7(ptr) AccessChain 14(buffer) 29 35
38: 6(int) Load 37 37: 6(int) Load 36
39: 11(ivec2) CompositeConstruct 33 38 38: 11(ivec2) CompositeConstruct 32 37
Store 22(result) 39 Store 22(result) 38
40: 11(ivec2) Load 22(result) 39: 11(ivec2) Load 22(result)
ReturnValue 40 ReturnValue 39
FunctionEnd FunctionEnd
19(@main(u1;): 2 Function None 17 19(@main(u1;): 2 Function None 17
18(dispatchId): 7(ptr) FunctionParameter 18(dispatchId): 7(ptr) FunctionParameter
20: Label 20: Label
43(result): 21(ptr) Variable Function 42(result): 21(ptr) Variable Function
45(param): 7(ptr) Variable Function 45(param): 7(ptr) Variable Function
47(param): 10(ptr) Variable Function
46: 6(int) Load 18(dispatchId) 46: 6(int) Load 18(dispatchId)
Store 45(param) 46 Store 45(param) 46
47: 11(ivec2) FunctionCall 15(testLoad(u1;block--u1[0]1;) 45(param) 44(g_input) 48: 11(ivec2) FunctionCall 15(testLoad(u1;block--u1[0]1;) 45(param) 47(param)
Store 43(result) 47 Store 42(result) 48
51: 48 Load 50(g_output) 52: 49 Load 51(g_output)
52: 6(int) Load 18(dispatchId) 53: 6(int) Load 18(dispatchId)
53: 11(ivec2) Load 43(result) 54: 11(ivec2) Load 42(result)
ImageWrite 51 52 53 ImageWrite 52 53 54
Return Return
FunctionEnd FunctionEnd
...@@ -135,12 +135,12 @@ gl_FragCoord origin is upper left ...@@ -135,12 +135,12 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 62 // Id's are bound by 73
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 60 EntryPoint Fragment 4 "main" 71
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
...@@ -153,44 +153,51 @@ gl_FragCoord origin is upper left ...@@ -153,44 +153,51 @@ gl_FragCoord origin is upper left
Name 28 "Func(I21;" Name 28 "Func(I21;"
Name 27 "DummyTex" Name 27 "DummyTex"
Name 31 "@main(" Name 31 "@main("
Name 44 "tf1" Name 45 "tf1"
Name 46 "tf4" Name 46 "param"
Name 50 "twf1" Name 49 "tf4"
Name 54 "twf4" Name 50 "param"
Name 60 "@entryPointOutput" Name 56 "twf1"
Decorate 44(tf1) DescriptorSet 0 Name 57 "param"
Decorate 46(tf4) DescriptorSet 0 Name 63 "twf4"
Decorate 50(twf1) DescriptorSet 0 Name 64 "param"
Decorate 54(twf4) DescriptorSet 0 Name 71 "@entryPointOutput"
Decorate 60(@entryPointOutput) Location 0 Decorate 45(tf1) DescriptorSet 0
Decorate 49(tf4) DescriptorSet 0
Decorate 56(twf1) DescriptorSet 0
Decorate 63(twf4) DescriptorSet 0
Decorate 71(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
7: TypeImage 6(float) 2D sampled format:Unknown 7: TypeImage 6(float) 2D sampled format:Unknown
8: TypePointer UniformConstant 7 8: TypePointer Function 7
9: TypeFunction 6(float) 8(ptr) 9: TypeFunction 6(float) 8(ptr)
13: TypeVector 6(float) 4 13: TypeVector 6(float) 4
14: TypeFunction 13(fvec4) 8(ptr) 14: TypeFunction 13(fvec4) 8(ptr)
18: TypeImage 6(float) 2D nonsampled format:R32f 18: TypeImage 6(float) 2D nonsampled format:R32f
19: TypePointer UniformConstant 18 19: TypePointer Function 18
20: TypeFunction 6(float) 19(ptr) 20: TypeFunction 6(float) 19(ptr)
24: TypeImage 6(float) 2D nonsampled format:Rgba32f 24: TypeImage 6(float) 2D nonsampled format:Rgba32f
25: TypePointer UniformConstant 24 25: TypePointer Function 24
26: TypeFunction 13(fvec4) 25(ptr) 26: TypeFunction 13(fvec4) 25(ptr)
30: TypeFunction 13(fvec4) 30: TypeFunction 13(fvec4)
33: 6(float) Constant 1065353216 33: 6(float) Constant 1065353216
36: 6(float) Constant 0 36: 6(float) Constant 0
37: 13(fvec4) ConstantComposite 36 36 36 36 37: 13(fvec4) ConstantComposite 36 36 36 36
44(tf1): 8(ptr) Variable UniformConstant 44: TypePointer UniformConstant 7
46(tf4): 8(ptr) Variable UniformConstant 45(tf1): 44(ptr) Variable UniformConstant
50(twf1): 19(ptr) Variable UniformConstant 49(tf4): 44(ptr) Variable UniformConstant
54(twf4): 25(ptr) Variable UniformConstant 55: TypePointer UniformConstant 18
59: TypePointer Output 13(fvec4) 56(twf1): 55(ptr) Variable UniformConstant
60(@entryPointOutput): 59(ptr) Variable Output 62: TypePointer UniformConstant 24
63(twf4): 62(ptr) Variable UniformConstant
70: TypePointer Output 13(fvec4)
71(@entryPointOutput): 70(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
61: 13(fvec4) FunctionCall 31(@main() 72: 13(fvec4) FunctionCall 31(@main()
Store 60(@entryPointOutput) 61 Store 71(@entryPointOutput) 72
Return Return
FunctionEnd FunctionEnd
11(Func(t211;): 6(float) Function None 9 11(Func(t211;): 6(float) Function None 9
...@@ -215,14 +222,26 @@ gl_FragCoord origin is upper left ...@@ -215,14 +222,26 @@ gl_FragCoord origin is upper left
FunctionEnd FunctionEnd
31(@main(): 13(fvec4) Function None 30 31(@main(): 13(fvec4) Function None 30
32: Label 32: Label
45: 6(float) FunctionCall 11(Func(t211;) 44(tf1) 46(param): 8(ptr) Variable Function
47: 13(fvec4) FunctionCall 16(Func(t21;) 46(tf4) 50(param): 8(ptr) Variable Function
48: 13(fvec4) CompositeConstruct 45 45 45 45 57(param): 19(ptr) Variable Function
49: 13(fvec4) FAdd 48 47 64(param): 25(ptr) Variable Function
51: 6(float) FunctionCall 22(Func(I211;) 50(twf1) 47: 7 Load 45(tf1)
52: 13(fvec4) CompositeConstruct 51 51 51 51 Store 46(param) 47
53: 13(fvec4) FAdd 49 52 48: 6(float) FunctionCall 11(Func(t211;) 46(param)
55: 13(fvec4) FunctionCall 28(Func(I21;) 54(twf4) 51: 7 Load 49(tf4)
56: 13(fvec4) FAdd 53 55 Store 50(param) 51
ReturnValue 56 52: 13(fvec4) FunctionCall 16(Func(t21;) 50(param)
53: 13(fvec4) CompositeConstruct 48 48 48 48
54: 13(fvec4) FAdd 53 52
58: 18 Load 56(twf1)
Store 57(param) 58
59: 6(float) FunctionCall 22(Func(I211;) 57(param)
60: 13(fvec4) CompositeConstruct 59 59 59 59
61: 13(fvec4) FAdd 54 60
65: 24 Load 63(twf4)
Store 64(param) 65
66: 13(fvec4) FunctionCall 28(Func(I21;) 64(param)
67: 13(fvec4) FAdd 61 66
ReturnValue 67
FunctionEnd FunctionEnd
...@@ -1286,7 +1286,7 @@ protected: ...@@ -1286,7 +1286,7 @@ protected:
}; };
typedef TVector<TIntermNode*> TIntermSequence; typedef TVector<TIntermNode*> TIntermSequence;
typedef TVector<int> TQualifierList; typedef TVector<TStorageQualifier> TQualifierList;
// //
// Nodes that operate on an arbitrary sized set of children. // Nodes that operate on an arbitrary sized set of children.
// //
......
...@@ -234,7 +234,8 @@ public: ...@@ -234,7 +234,8 @@ public:
hlslOffsets(false), hlslOffsets(false),
useStorageBuffer(false), useStorageBuffer(false),
hlslIoMapping(false), hlslIoMapping(false),
textureSamplerTransformMode(EShTexSampTransKeep) textureSamplerTransformMode(EShTexSampTransKeep),
needToLegalize(false)
{ {
localSize[0] = 1; localSize[0] = 1;
localSize[1] = 1; localSize[1] = 1;
...@@ -610,6 +611,9 @@ public: ...@@ -610,6 +611,9 @@ public:
void addProcessArgument(const std::string& arg) { processes.addArgument(arg); } void addProcessArgument(const std::string& arg) { processes.addArgument(arg); }
const std::vector<std::string>& getProcesses() const { return processes.getProcesses(); } const std::vector<std::string>& getProcesses() const { return processes.getProcesses(); }
void setNeedsLegalization() { needToLegalize = true; }
bool needsLegalization() const { return needToLegalize; }
const char* const implicitThisName; const char* const implicitThisName;
protected: protected:
...@@ -708,6 +712,8 @@ protected: ...@@ -708,6 +712,8 @@ protected:
// for OpModuleProcessed, or equivalent // for OpModuleProcessed, or equivalent
TProcesses processes; TProcesses processes;
bool needToLegalize;
private: private:
void operator=(TIntermediate&); // prevent assignments void operator=(TIntermediate&); // prevent assignments
}; };
......
...@@ -166,11 +166,6 @@ bool HlslParseContext::shouldConvertLValue(const TIntermNode* node) const ...@@ -166,11 +166,6 @@ bool HlslParseContext::shouldConvertLValue(const TIntermNode* node) const
if (lhsAsAggregate != nullptr && lhsAsAggregate->getOp() == EOpImageLoad) if (lhsAsAggregate != nullptr && lhsAsAggregate->getOp() == EOpImageLoad)
return true; return true;
// If it's a syntactic write to a sampler, we will use that to establish
// a compile-time alias.
if (node->getAsTyped()->getBasicType() == EbtSampler)
return true;
return false; return false;
} }
...@@ -239,6 +234,13 @@ bool HlslParseContext::lValueErrorCheck(const TSourceLoc& loc, const char* op, T ...@@ -239,6 +234,13 @@ bool HlslParseContext::lValueErrorCheck(const TSourceLoc& loc, const char* op, T
} }
} }
// We tolerate samplers as l-values, even though they are nominally
// illegal, because we expect a later optimization to eliminate them.
if (node->getType().getBasicType() == EbtSampler) {
intermediate.setNeedsLegalization();
return false;
}
// Let the base class check errors // Let the base class check errors
return TParseContextBase::lValueErrorCheck(loc, op, node); return TParseContextBase::lValueErrorCheck(loc, op, node);
} }
...@@ -274,10 +276,6 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char* ...@@ -274,10 +276,6 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
// *** If we get here, we're going to apply some conversion to an l-value. // *** If we get here, we're going to apply some conversion to an l-value.
// Spin off sampler aliasing
if (node->getAsTyped()->getBasicType() == EbtSampler)
return handleSamplerLvalue(loc, op, node);
// Helper to create a load. // Helper to create a load.
const auto makeLoad = [&](TIntermSymbol* rhsTmp, TIntermTyped* object, TIntermTyped* coord, const TType& derefType) { const auto makeLoad = [&](TIntermSymbol* rhsTmp, TIntermTyped* object, TIntermTyped* coord, const TType& derefType) {
TIntermAggregate* loadOp = new TIntermAggregate(EOpImageLoad); TIntermAggregate* loadOp = new TIntermAggregate(EOpImageLoad);
...@@ -524,58 +522,6 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char* ...@@ -524,58 +522,6 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
return node; return node;
} }
// Deal with sampler aliasing: turning assignments into aliases
// Return a placeholder node for higher-level code that think assignments must
// generate code.
TIntermTyped* HlslParseContext::handleSamplerLvalue(const TSourceLoc& loc, const char* op, TIntermTyped*& node)
{
// Can only alias an assignment: "s1 = s2"
TIntermBinary* binary = node->getAsBinaryNode();
if (binary == nullptr || node->getAsOperator()->getOp() != EOpAssign ||
binary->getLeft()->getAsSymbolNode() == nullptr ||
binary->getRight()->getAsSymbolNode() == nullptr) {
error(loc, "can't modify sampler", op, "");
return node;
}
if (controlFlowNestingLevel > 0)
warn(loc, "sampler or image aliased under control flow; consumption must be in same path", op, "");
TIntermTyped* set = setOpaqueLvalue(binary->getLeft(), binary->getRight());
if (set == nullptr)
warn(loc, "could not create alias for sampler", op, "");
else
node = set;
return node;
}
// Do an opaque assignment that needs to turn into an alias.
// Return nullptr if it can't be done, otherwise return a placeholder
// node for higher-level code that think assignments must generate code.
TIntermTyped* HlslParseContext::setOpaqueLvalue(TIntermTyped* leftTyped, TIntermTyped* rightTyped)
{
// Best is if we are aliasing a flattened struct member "S.s1 = s2",
// in which case we want to update the flattening information with the alias,
// making everything else work seamlessly.
TIntermSymbol* left = leftTyped->getAsSymbolNode();
TIntermSymbol* right = rightTyped->getAsSymbolNode();
for (auto fit = flattenMap.begin(); fit != flattenMap.end(); ++fit) {
for (auto mit = fit->second.members.begin(); mit != fit->second.members.end(); ++mit) {
if ((*mit)->getUniqueId() == left->getId()) {
// found it: update with alias to the existing variable, and don't emit any code
(*mit) = new TVariable(&right->getName(), right->getType());
(*mit)->setUniqueId(right->getId());
// replace node (rest of compiler expects either an error or code to generate)
// with pointless access
return right;
}
}
}
return nullptr;
}
void HlslParseContext::handlePragma(const TSourceLoc& loc, const TVector<TString>& tokens) void HlslParseContext::handlePragma(const TSourceLoc& loc, const TVector<TString>& tokens)
{ {
if (pragmaCallback) if (pragmaCallback)
...@@ -2513,41 +2459,6 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc ...@@ -2513,41 +2459,6 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc
return assignList; return assignList;
} }
// For a declaration with an initializer, where the initialized symbol is flattened,
// and possibly contains opaque values, such that the initializer should never exist
// as emitted code, because even creating the initializer would write opaques.
//
// If possible, decompose this into individual member-wise assignments, which themselves
// are expected to then not exist for opaque types, because they will turn into aliases.
//
// Return a node that contains the non-aliased assignments that must continue to exist.
TIntermTyped* HlslParseContext::executeFlattenedInitializer(const TSourceLoc& loc, TIntermSymbol* symbol,
TIntermAggregate& initializer)
{
// We need individual RHS initializers per member to do this
const TTypeList* typeList = symbol->getType().getStruct();
if (typeList == nullptr || initializer.getSequence().size() != typeList->size()) {
warn(loc, "cannot do member-wise aliasing for opaque members with this initializer", "=", "");
return handleAssign(loc, EOpAssign, symbol, &initializer);
}
TIntermAggregate* initList = nullptr;
// synthesize an access to each member, and then an assignment to it
for (int member = 0; member < (int)typeList->size(); ++member) {
TIntermTyped* memberInitializer = initializer.getSequence()[member]->getAsTyped();
TIntermTyped* flattenedMember = flattenAccess(symbol, member);
if (flattenedMember->getType().containsOpaque())
setOpaqueLvalue(flattenedMember, memberInitializer);
else
initList = intermediate.growAggregate(initList, handleAssign(loc, EOpAssign, flattenedMember,
memberInitializer));
}
if (initList)
initList->setOperator(EOpSequence);
return initList;
}
// Some simple source assignments need to be flattened to a sequence // Some simple source assignments need to be flattened to a sequence
// of AST assignments. Catch these and flatten, otherwise, pass through // of AST assignments. Catch these and flatten, otherwise, pass through
// to intermediate.addAssign(). // to intermediate.addAssign().
...@@ -2560,6 +2471,10 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op ...@@ -2560,6 +2471,10 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
if (left == nullptr || right == nullptr) if (left == nullptr || right == nullptr)
return nullptr; return nullptr;
// writing to opaques will require fixing transforms
if (left->getType().containsOpaque())
intermediate.setNeedsLegalization();
if (left->getAsOperator() && left->getAsOperator()->getOp() == EOpMatrixSwizzle) if (left->getAsOperator() && left->getAsOperator()->getOp() == EOpMatrixSwizzle)
return handleAssignToMatrixSwizzle(loc, op, left, right); return handleAssignToMatrixSwizzle(loc, op, left, right);
...@@ -2720,7 +2635,8 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op ...@@ -2720,7 +2635,8 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
const int elementsL = left->getType().isArray() ? left->getType().getOuterArraySize() : 1; const int elementsL = left->getType().isArray() ? left->getType().getOuterArraySize() : 1;
const int elementsR = right->getType().isArray() ? right->getType().getOuterArraySize() : 1; const int elementsR = right->getType().isArray() ? right->getType().getOuterArraySize() : 1;
// The arrays may not be the same size, e.g, if the size has been forced for EbvTessLevelInner or Outer. // The arrays might not be the same size,
// e.g., if the size has been forced for EbvTessLevelInner/Outer.
const int elementsToCopy = std::min(elementsL, elementsR); const int elementsToCopy = std::min(elementsL, elementsR);
// array case // array case
...@@ -7616,20 +7532,10 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm ...@@ -7616,20 +7532,10 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm
// normal assigning of a value to a variable... // normal assigning of a value to a variable...
specializationCheck(loc, initializer->getType(), "initializer"); specializationCheck(loc, initializer->getType(), "initializer");
TIntermSymbol* intermSymbol = intermediate.addSymbol(*variable, loc); TIntermSymbol* intermSymbol = intermediate.addSymbol(*variable, loc);
TIntermNode* initNode = handleAssign(loc, EOpAssign, intermSymbol, initializer);
// If we are flattening, it could be due to setting opaques, which must be handled if (initNode == nullptr)
// as aliases, and the 'initializer' node cannot actually be emitted, because it assignError(loc, "=", intermSymbol->getCompleteString(), initializer->getCompleteString());
// itself stores the result of the constructor, and we can't store to opaques. return initNode;
// handleAssign() will emit the initializer.
TIntermNode* initNode = nullptr;
if (flattened && intermSymbol->getType().containsOpaque())
return executeFlattenedInitializer(loc, intermSymbol, *initializer->getAsAggregate());
else {
initNode = handleAssign(loc, EOpAssign, intermSymbol, initializer);
if (initNode == nullptr)
assignError(loc, "=", intermSymbol->getCompleteString(), initializer->getCompleteString());
return initNode;
}
} }
return nullptr; return nullptr;
...@@ -9517,6 +9423,11 @@ void HlslParseContext::finish() ...@@ -9517,6 +9423,11 @@ void HlslParseContext::finish()
error(mipsOperatorMipArg.back().loc, "unterminated mips operator:", "", ""); error(mipsOperatorMipArg.back().loc, "unterminated mips operator:", "", "");
} }
// Communicate out (esp. for command line) that we formed AST that will make
// illegal AST SPIR-V and it needs transforms to legalize it.
if (intermediate.needsLegalization())
infoSink.info << "WARNING: AST will form illegal SPIR-V; need to transform to legalize";
removeUnusedStructBufferCounters(); removeUnusedStructBufferCounters();
addPatchConstantInvocation(); addPatchConstantInvocation();
fixTextureShadowModes(); fixTextureShadowModes();
......
...@@ -88,7 +88,6 @@ public: ...@@ -88,7 +88,6 @@ public:
void remapNonEntryPointIO(TFunction& function); void remapNonEntryPointIO(TFunction& function);
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*); TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg); void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
TIntermTyped* executeFlattenedInitializer(const TSourceLoc&, TIntermSymbol*, TIntermAggregate&);
TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right); TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleAssignToMatrixSwizzle(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right); TIntermTyped* handleAssignToMatrixSwizzle(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermTyped*); TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermTyped*);
...@@ -191,8 +190,6 @@ public: ...@@ -191,8 +190,6 @@ public:
// Apply L-value conversions. E.g, turning a write to a RWTexture into an ImageStore. // Apply L-value conversions. E.g, turning a write to a RWTexture into an ImageStore.
TIntermTyped* handleLvalue(const TSourceLoc&, const char* op, TIntermTyped*& node); TIntermTyped* handleLvalue(const TSourceLoc&, const char* op, TIntermTyped*& node);
TIntermTyped* handleSamplerLvalue(const TSourceLoc&, const char* op, TIntermTyped*& node);
TIntermTyped* setOpaqueLvalue(TIntermTyped* left, TIntermTyped* right);
bool lValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*) override; bool lValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*) override;
TLayoutFormat getLayoutFromTxType(const TSourceLoc&, const TType&); TLayoutFormat getLayoutFromTxType(const TSourceLoc&, const TType&);
......
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