aboutsummaryrefslogtreecommitdiff
path: root/SPIRV/GlslangToSpv.cpp
diff options
context:
space:
mode:
authorJohn Kessenich <cepheus@frii.com>2016-06-16 14:06:26 -0600
committerJohn Kessenich <cepheus@frii.com>2016-06-16 14:06:26 -0600
commit65336488a8bfd53b09ee9b58cc2238c074efeb94 (patch)
treea21ac64af7cfb393aed35f3aa4da2b2f72448a55 /SPIRV/GlslangToSpv.cpp
parent76d4dfcd51f9b1624b6241a82969c7423aabf82f (diff)
downloadglslang-65336488a8bfd53b09ee9b58cc2238c074efeb94.tar.gz
SPV: projective texturing: move the project coordinate.
SPV doesn't allow gaps in the components of the texturing coordinate. It also removes the shadow reference. So, close up the components so all used components are together.
Diffstat (limited to 'SPIRV/GlslangToSpv.cpp')
-rwxr-xr-xSPIRV/GlslangToSpv.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 39b4ea6e..b41afc59 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -2677,6 +2677,30 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
}
}
+ // projective component (might not to move)
+ // GLSL: "The texture coordinates consumed from P, not including the last component of P,
+ // are divided by the last component of P."
+ // SPIR-V: "... (u [, v] [, w], q)... It may be a vector larger than needed, but all
+ // unused components will appear after all used components."
+ if (cracked.proj) {
+ int projSourceComp = builder.getNumComponents(params.coords) - 1;
+ int projTargetComp;
+ switch (sampler.dim) {
+ case glslang::Esd1D: projTargetComp = 1; break;
+ case glslang::Esd2D: projTargetComp = 2; break;
+ case glslang::EsdRect: projTargetComp = 2; break;
+ default: projTargetComp = projSourceComp; break;
+ }
+ // copy the projective coordinate if we have to
+ if (projTargetComp != projSourceComp) {
+ spv::Id projComp = builder.createCompositeExtract(params.coords,
+ builder.getScalarTypeId(builder.getTypeId(params.coords)),
+ projSourceComp);
+ params.coords = builder.createCompositeInsert(projComp, params.coords,
+ builder.getTypeId(params.coords), projTargetComp);
+ }
+ }
+
return builder.createTextureCall(precision, convertGlslangToSpvType(node->getType()), sparse, cracked.fetch, cracked.proj, cracked.gather, noImplicitLod, params);
}