SPV: Handle nested opaque types as function parameters.
This commit is contained in:
parent
7491234713
commit
4a57dced66
@ -251,10 +251,10 @@ spv::StorageClass TranslateStorageClass(const glslang::TType& type)
|
|||||||
return spv::StorageClassInput;
|
return spv::StorageClassInput;
|
||||||
else if (type.getQualifier().isPipeOutput())
|
else if (type.getQualifier().isPipeOutput())
|
||||||
return spv::StorageClassOutput;
|
return spv::StorageClassOutput;
|
||||||
else if (type.getBasicType() == glslang::EbtSampler)
|
|
||||||
return spv::StorageClassUniformConstant;
|
|
||||||
else if (type.getBasicType() == glslang::EbtAtomicUint)
|
else if (type.getBasicType() == glslang::EbtAtomicUint)
|
||||||
return spv::StorageClassAtomicCounter;
|
return spv::StorageClassAtomicCounter;
|
||||||
|
else if (type.containsOpaque())
|
||||||
|
return spv::StorageClassUniformConstant;
|
||||||
else if (type.getQualifier().isUniformOrBuffer()) {
|
else if (type.getQualifier().isUniformOrBuffer()) {
|
||||||
if (type.getQualifier().layoutPushConstant)
|
if (type.getQualifier().layoutPushConstant)
|
||||||
return spv::StorageClassPushConstant;
|
return spv::StorageClassPushConstant;
|
||||||
@ -262,7 +262,6 @@ spv::StorageClass TranslateStorageClass(const glslang::TType& type)
|
|||||||
return spv::StorageClassUniform;
|
return spv::StorageClassUniform;
|
||||||
else
|
else
|
||||||
return spv::StorageClassUniformConstant;
|
return spv::StorageClassUniformConstant;
|
||||||
// TODO: how are we distinguishing between default and non-default non-writable uniforms? Do default uniforms even exist?
|
|
||||||
} else {
|
} else {
|
||||||
switch (type.getQualifier().storage) {
|
switch (type.getQualifier().storage) {
|
||||||
case glslang::EvqShared: return spv::StorageClassWorkgroup; break;
|
case glslang::EvqShared: return spv::StorageClassWorkgroup; break;
|
||||||
@ -2731,7 +2730,7 @@ 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);
|
||||||
if (paramType.isOpaque())
|
if (paramType.containsOpaque())
|
||||||
typeId = builder.makePointer(TranslateStorageClass(paramType), typeId);
|
typeId = builder.makePointer(TranslateStorageClass(paramType), typeId);
|
||||||
else if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
|
else if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
|
||||||
typeId = builder.makePointer(spv::StorageClassFunction, typeId);
|
typeId = builder.makePointer(spv::StorageClassFunction, typeId);
|
||||||
@ -3192,7 +3191,7 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
|
|||||||
glslangArgs[a]->traverse(this);
|
glslangArgs[a]->traverse(this);
|
||||||
argTypes.push_back(¶mType);
|
argTypes.push_back(¶mType);
|
||||||
// keep outputs and opaque objects as l-values, evaluate input-only as r-values
|
// keep outputs and opaque objects as l-values, evaluate input-only as r-values
|
||||||
if (qualifiers[a] != glslang::EvqConstReadOnly || paramType.isOpaque()) {
|
if (qualifiers[a] != glslang::EvqConstReadOnly || paramType.containsOpaque()) {
|
||||||
// save l-value
|
// save l-value
|
||||||
lValues.push_back(builder.getAccessChain());
|
lValues.push_back(builder.getAccessChain());
|
||||||
} else {
|
} else {
|
||||||
@ -3211,7 +3210,7 @@ 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.isOpaque()) {
|
if (paramType.containsOpaque()) {
|
||||||
builder.setAccessChain(lValues[lValueCount]);
|
builder.setAccessChain(lValues[lValueCount]);
|
||||||
arg = builder.accessChainGetLValue();
|
arg = builder.accessChainGetLValue();
|
||||||
++lValueCount;
|
++lValueCount;
|
||||||
|
67
Test/baseResults/spv.functionNestedOpaque.vert.out
Normal file
67
Test/baseResults/spv.functionNestedOpaque.vert.out
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
spv.functionNestedOpaque.vert
|
||||||
|
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
|
||||||
|
|
||||||
|
// Module Version 10000
|
||||||
|
// Generated by (magic number): 80001
|
||||||
|
// Id's are bound by 39
|
||||||
|
|
||||||
|
Capability Shader
|
||||||
|
1: ExtInstImport "GLSL.std.450"
|
||||||
|
MemoryModel Logical GLSL450
|
||||||
|
EntryPoint Vertex 4 "main"
|
||||||
|
Source GLSL 450
|
||||||
|
Name 4 "main"
|
||||||
|
Name 12 "foo(s21;"
|
||||||
|
Name 11 "t"
|
||||||
|
Name 14 "S"
|
||||||
|
MemberName 14(S) 0 "s"
|
||||||
|
Name 18 "barc(struct-S-s211;"
|
||||||
|
Name 17 "p"
|
||||||
|
Name 21 "bar(struct-S-s211;"
|
||||||
|
Name 20 "p"
|
||||||
|
Name 36 "si"
|
||||||
|
2: TypeVoid
|
||||||
|
3: TypeFunction 2
|
||||||
|
6: TypeFloat 32
|
||||||
|
7: TypeImage 6(float) 2D sampled format:Unknown
|
||||||
|
8: TypeSampledImage 7
|
||||||
|
9: TypePointer UniformConstant 8
|
||||||
|
10: TypeFunction 2 9(ptr)
|
||||||
|
14(S): TypeStruct 8
|
||||||
|
15: TypePointer UniformConstant 14(S)
|
||||||
|
16: TypeFunction 2 15(ptr)
|
||||||
|
24: TypeVector 6(float) 2
|
||||||
|
25: 6(float) Constant 1056964608
|
||||||
|
26: 24(fvec2) ConstantComposite 25 25
|
||||||
|
27: TypeVector 6(float) 4
|
||||||
|
28: 6(float) Constant 0
|
||||||
|
30: TypeInt 32 1
|
||||||
|
31: 30(int) Constant 0
|
||||||
|
36(si): 15(ptr) Variable UniformConstant
|
||||||
|
4(main): 2 Function None 3
|
||||||
|
5: Label
|
||||||
|
37: 2 FunctionCall 18(barc(struct-S-s211;) 36(si)
|
||||||
|
38: 2 FunctionCall 21(bar(struct-S-s211;) 36(si)
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
||||||
|
12(foo(s21;): 2 Function None 10
|
||||||
|
11(t): 9(ptr) FunctionParameter
|
||||||
|
13: Label
|
||||||
|
23: 8 Load 11(t)
|
||||||
|
29: 27(fvec4) ImageSampleExplicitLod 23 26 Lod 28
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
||||||
|
18(barc(struct-S-s211;): 2 Function None 16
|
||||||
|
17(p): 15(ptr) FunctionParameter
|
||||||
|
19: Label
|
||||||
|
32: 9(ptr) AccessChain 17(p) 31
|
||||||
|
33: 2 FunctionCall 12(foo(s21;) 32
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
||||||
|
21(bar(struct-S-s211;): 2 Function None 16
|
||||||
|
20(p): 15(ptr) FunctionParameter
|
||||||
|
22: Label
|
||||||
|
34: 9(ptr) AccessChain 20(p) 31
|
||||||
|
35: 2 FunctionCall 12(foo(s21;) 34
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
26
Test/spv.functionNestedOpaque.vert
Executable file
26
Test/spv.functionNestedOpaque.vert
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
uniform struct S {
|
||||||
|
sampler2D s;
|
||||||
|
} si;
|
||||||
|
|
||||||
|
void foo(sampler2D t)
|
||||||
|
{
|
||||||
|
texture(t, vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
void barc(const S p)
|
||||||
|
{
|
||||||
|
foo(p.s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bar(S p)
|
||||||
|
{
|
||||||
|
foo(p.s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
barc(si);
|
||||||
|
bar(si);
|
||||||
|
}
|
@ -2,5 +2,5 @@
|
|||||||
// For the version, it uses the latest git tag followed by the number of commits.
|
// For the version, it uses the latest git tag followed by the number of commits.
|
||||||
// For the date, it uses the current date (when then script is run).
|
// For the date, it uses the current date (when then script is run).
|
||||||
|
|
||||||
#define GLSLANG_REVISION "Overload400-PrecQual.1843"
|
#define GLSLANG_REVISION "Overload400-PrecQual.1845"
|
||||||
#define GLSLANG_DATE "18-Feb-2017"
|
#define GLSLANG_DATE "24-Feb-2017"
|
||||||
|
@ -232,6 +232,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
"spv.forLoop.frag",
|
"spv.forLoop.frag",
|
||||||
"spv.forwardFun.frag",
|
"spv.forwardFun.frag",
|
||||||
"spv.functionCall.frag",
|
"spv.functionCall.frag",
|
||||||
|
"spv.functionNestedOpaque.vert",
|
||||||
"spv.functionSemantics.frag",
|
"spv.functionSemantics.frag",
|
||||||
"spv.interpOps.frag",
|
"spv.interpOps.frag",
|
||||||
"spv.int64.frag",
|
"spv.int64.frag",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user