Commit 76d4dfcd by John Kessenich

SPV non-functional: minor readability improvements for texturing.

parent ac666e73
...@@ -643,9 +643,9 @@ bool HasNonLayoutQualifiers(const glslang::TQualifier& qualifier) ...@@ -643,9 +643,9 @@ bool HasNonLayoutQualifiers(const glslang::TQualifier& qualifier)
{ {
// This should list qualifiers that simultaneous satisfy: // This should list qualifiers that simultaneous satisfy:
// - struct members can inherit from a struct declaration // - struct members can inherit from a struct declaration
// - effect decorations on the struct members (note smooth does not, and expecting something like volatile to effect the whole object) // - affect decorations on the struct members (note smooth does not, and expecting something like volatile to effect the whole object)
// - are not part of the offset/st430/etc or row/column-major layout // - are not part of the offset/st430/etc or row/column-major layout
return qualifier.invariant || qualifier.nopersp || qualifier.flat || qualifier.centroid || qualifier.patch || qualifier.sample || qualifier.hasLocation(); return qualifier.invariant || qualifier.hasLocation();
} }
// //
...@@ -1913,8 +1913,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1913,8 +1913,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
addMemberDecoration(spvType, member, TranslatePrecisionDecoration(glslangType)); addMemberDecoration(spvType, member, TranslatePrecisionDecoration(glslangType));
// Add interpolation and auxiliary storage decorations only to top-level members of Input and Output storage classes // Add interpolation and auxiliary storage decorations only to top-level members of Input and Output storage classes
if (type.getQualifier().storage == glslang::EvqVaryingIn || type.getQualifier().storage == glslang::EvqVaryingOut) { if (type.getQualifier().storage == glslang::EvqVaryingIn || type.getQualifier().storage == glslang::EvqVaryingOut) {
addMemberDecoration(spvType, member, TranslateInterpolationDecoration(subQualifier)); if (type.getBasicType() == glslang::EbtBlock) {
addMemberDecoration(spvType, member, TranslateAuxiliaryStorageDecoration(subQualifier)); addMemberDecoration(spvType, member, TranslateInterpolationDecoration(subQualifier));
addMemberDecoration(spvType, member, TranslateAuxiliaryStorageDecoration(subQualifier));
}
} }
addMemberDecoration(spvType, member, TranslateInvariantDecoration(subQualifier)); addMemberDecoration(spvType, member, TranslateInvariantDecoration(subQualifier));
...@@ -2606,14 +2608,16 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2606,14 +2608,16 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
++extraArgs; ++extraArgs;
} else if (sampler.shadow) { } else if (sampler.shadow) {
std::vector<spv::Id> indexes; std::vector<spv::Id> indexes;
int comp; int dRefComp;
if (cracked.proj) if (cracked.proj)
comp = 2; // "The resulting 3rd component of P in the shadow forms is used as Dref" dRefComp = 2; // "The resulting 3rd component of P in the shadow forms is used as Dref"
else else
comp = builder.getNumComponents(params.coords) - 1; dRefComp = builder.getNumComponents(params.coords) - 1;
indexes.push_back(comp); indexes.push_back(dRefComp);
params.Dref = builder.createCompositeExtract(params.coords, builder.getScalarTypeId(builder.getTypeId(params.coords)), indexes); params.Dref = builder.createCompositeExtract(params.coords, builder.getScalarTypeId(builder.getTypeId(params.coords)), indexes);
} }
// lod
if (cracked.lod) { if (cracked.lod) {
params.lod = arguments[2]; params.lod = arguments[2];
++extraArgs; ++extraArgs;
...@@ -2621,15 +2625,21 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2621,15 +2625,21 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
// we need to invent the default lod for an explicit lod instruction for a non-fragment stage // we need to invent the default lod for an explicit lod instruction for a non-fragment stage
noImplicitLod = true; noImplicitLod = true;
} }
// multisample
if (sampler.ms) { if (sampler.ms) {
params.sample = arguments[2]; // For MS, "sample" should be specified params.sample = arguments[2]; // For MS, "sample" should be specified
++extraArgs; ++extraArgs;
} }
// gradient
if (cracked.grad) { if (cracked.grad) {
params.gradX = arguments[2 + extraArgs]; params.gradX = arguments[2 + extraArgs];
params.gradY = arguments[3 + extraArgs]; params.gradY = arguments[3 + extraArgs];
extraArgs += 2; extraArgs += 2;
} }
// offset and offsets
if (cracked.offset) { if (cracked.offset) {
params.offset = arguments[2 + extraArgs]; params.offset = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
...@@ -2637,25 +2647,33 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2637,25 +2647,33 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
params.offsets = arguments[2 + extraArgs]; params.offsets = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
} }
// lod clamp
if (cracked.lodClamp) { if (cracked.lodClamp) {
params.lodClamp = arguments[2 + extraArgs]; params.lodClamp = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
} }
// sparse
if (sparse) { if (sparse) {
params.texelOut = arguments[2 + extraArgs]; params.texelOut = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
} }
// bias
if (bias) { if (bias) {
params.bias = arguments[2 + extraArgs]; params.bias = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
} }
// gather component
if (cracked.gather && ! sampler.shadow) { if (cracked.gather && ! sampler.shadow) {
// default component is 0, if missing, otherwise an argument // default component is 0, if missing, otherwise an argument
if (2 + extraArgs < (int)arguments.size()) { if (2 + extraArgs < (int)arguments.size()) {
params.comp = arguments[2 + extraArgs]; params.component = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
} else { } else {
params.comp = builder.makeIntConstant(0); params.component = builder.makeIntConstant(0);
} }
} }
......
...@@ -1430,10 +1430,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse, ...@@ -1430,10 +1430,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
bool explicitLod = false; bool explicitLod = false;
texArgs[numArgs++] = parameters.sampler; texArgs[numArgs++] = parameters.sampler;
texArgs[numArgs++] = parameters.coords; texArgs[numArgs++] = parameters.coords;
if (parameters.Dref) if (parameters.Dref != NoResult)
texArgs[numArgs++] = parameters.Dref; texArgs[numArgs++] = parameters.Dref;
if (parameters.comp) if (parameters.component != NoResult)
texArgs[numArgs++] = parameters.comp; texArgs[numArgs++] = parameters.component;
// //
// Set up the optional arguments // Set up the optional arguments
......
...@@ -321,7 +321,7 @@ public: ...@@ -321,7 +321,7 @@ public:
Id gradX; Id gradX;
Id gradY; Id gradY;
Id sample; Id sample;
Id comp; Id component;
Id texelOut; Id texelOut;
Id lodClamp; Id lodClamp;
}; };
......
...@@ -63,9 +63,6 @@ Linked vertex stage: ...@@ -63,9 +63,6 @@ Linked vertex stage:
Decorate 55(sampb2) Binding 5 Decorate 55(sampb2) Binding 5
Decorate 56(sampb4) DescriptorSet 0 Decorate 56(sampb4) DescriptorSet 0
Decorate 56(sampb4) Binding 31 Decorate 56(sampb4) Binding 31
MemberDecorate 60(SS) 0 Flat
MemberDecorate 60(SS) 1 Flat
MemberDecorate 60(SS) 2 Flat
Decorate 62(var) Location 0 Decorate 62(var) Location 0
MemberDecorate 63(MS) 0 Location 17 MemberDecorate 63(MS) 0 Location 17
Decorate 63(MS) Block Decorate 63(MS) Block
......
...@@ -7,12 +7,12 @@ Linked vertex stage: ...@@ -7,12 +7,12 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 67 // Id's are bound by 66
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 63 66 EntryPoint Vertex 4 "main" 62 65
Source GLSL 450 Source GLSL 450
Name 4 "main" Name 4 "main"
Name 14 "S" Name 14 "S"
...@@ -82,16 +82,12 @@ Linked vertex stage: ...@@ -82,16 +82,12 @@ Linked vertex stage:
MemberName 58(bBt3) 0 "ntcol" MemberName 58(bBt3) 0 "ntcol"
MemberName 58(bBt3) 1 "ntrow" MemberName 58(bBt3) 1 "ntrow"
Name 60 "bBtn3" Name 60 "bBtn3"
Name 61 "S" Name 62 "sout"
MemberName 61(S) 0 "a" Name 63 "S"
MemberName 61(S) 1 "b" MemberName 63(S) 0 "a"
MemberName 61(S) 2 "c" MemberName 63(S) 1 "b"
Name 63 "sout" MemberName 63(S) 2 "c"
Name 64 "S" Name 65 "soutinv"
MemberName 64(S) 0 "a"
MemberName 64(S) 1 "b"
MemberName 64(S) 2 "c"
Name 66 "soutinv"
Decorate 13 ArrayStride 32 Decorate 13 ArrayStride 32
MemberDecorate 14(S) 0 Offset 0 MemberDecorate 14(S) 0 Offset 0
MemberDecorate 14(S) 1 ColMajor MemberDecorate 14(S) 1 ColMajor
...@@ -166,13 +162,10 @@ Linked vertex stage: ...@@ -166,13 +162,10 @@ Linked vertex stage:
Decorate 58(bBt3) BufferBlock Decorate 58(bBt3) BufferBlock
Decorate 60(bBtn3) DescriptorSet 1 Decorate 60(bBtn3) DescriptorSet 1
Decorate 60(bBtn3) Binding 0 Decorate 60(bBtn3) Binding 0
MemberDecorate 61(S) 0 Flat MemberDecorate 63(S) 0 Invariant
MemberDecorate 61(S) 1 Flat MemberDecorate 63(S) 1 Invariant
MemberDecorate 61(S) 2 Flat MemberDecorate 63(S) 2 Invariant
MemberDecorate 64(S) 0 Invariant Decorate 65(soutinv) Invariant
MemberDecorate 64(S) 1 Invariant
MemberDecorate 64(S) 2 Invariant
Decorate 66(soutinv) Invariant
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
...@@ -230,12 +223,11 @@ Linked vertex stage: ...@@ -230,12 +223,11 @@ Linked vertex stage:
58(bBt3): TypeStruct 49(Nestor) 54(Nestor) 58(bBt3): TypeStruct 49(Nestor) 54(Nestor)
59: TypePointer Uniform 58(bBt3) 59: TypePointer Uniform 58(bBt3)
60(bBtn3): 59(ptr) Variable Uniform 60(bBtn3): 59(ptr) Variable Uniform
61(S): TypeStruct 8(ivec3) 13 7(int) 61: TypePointer Output 29(S)
62: TypePointer Output 61(S) 62(sout): 61(ptr) Variable Output
63(sout): 62(ptr) Variable Output 63(S): TypeStruct 8(ivec3) 13 7(int)
64(S): TypeStruct 8(ivec3) 13 7(int) 64: TypePointer Output 63(S)
65: TypePointer Output 64(S) 65(soutinv): 64(ptr) Variable Output
66(soutinv): 65(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
Return Return
......
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