Merge pull request #959 from TiemoJung/texture_upgrade

Fix for not transforming all image symbols into sampled images symbols
This commit is contained in:
John Kessenich 2017-07-03 21:47:39 -06:00 committed by GitHub
commit aad93a80b2
2 changed files with 24 additions and 24 deletions

View File

@ -1,19 +1,19 @@
spv.texture.sampler.transform.frag
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 19
// Id's are bound by 20
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 16
EntryPoint Fragment 4 "main" 9 17
ExecutionMode 4 OriginUpperLeft
Source GLSL 440
Name 4 "main"
Name 9 "color"
Name 12 "tex"
Name 16 "coord"
Decorate 12(tex) DescriptorSet 0
Name 13 "tex"
Name 17 "coord"
Decorate 13(tex) DescriptorSet 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -21,16 +21,17 @@ spv.texture.sampler.transform.frag
8: TypePointer Output 7(fvec4)
9(color): 8(ptr) Variable Output
10: TypeImage 6(float) 2D sampled format:Unknown
11: TypePointer UniformConstant 10
12(tex): 11(ptr) Variable UniformConstant
14: TypeVector 6(float) 2
15: TypePointer Input 14(fvec2)
16(coord): 15(ptr) Variable Input
11: TypeSampledImage 10
12: TypePointer UniformConstant 11
13(tex): 12(ptr) Variable UniformConstant
15: TypeVector 6(float) 2
16: TypePointer Input 15(fvec2)
17(coord): 16(ptr) Variable Input
4(main): 2 Function None 3
5: Label
13: 10 Load 12(tex)
17: 14(fvec2) Load 16(coord)
18: 7(fvec4) ImageSampleImplicitLod 13 17
Store 9(color) 18
14: 11 Load 13(tex)
18: 15(fvec2) Load 17(coord)
19: 7(fvec4) ImageSampleImplicitLod 14 18
Store 9(color) 19
Return
FunctionEnd

View File

@ -3186,6 +3186,11 @@ bool TIntermediate::specConstantPropagates(const TIntermTyped& node1, const TInt
}
struct TextureUpgradeAndSamplerRemovalTransform : public TIntermTraverser {
void visitSymbol(TIntermSymbol* symbol) override {
if (symbol->getBasicType() == EbtSampler && symbol->getType().getSampler().isTexture()) {
symbol->getWritableType().getSampler().combined = true;
}
}
bool visitAggregate(TVisit, TIntermAggregate* ag) override {
using namespace std;
TIntermSequence& seq = ag->getSequence();
@ -3199,17 +3204,11 @@ struct TextureUpgradeAndSamplerRemovalTransform : public TIntermTraverser {
});
seq.erase(newEnd, seq.end());
// replace constructors with sampler/textures
// update textures into sampled textures
for_each(seq.begin(), seq.end(), [](TIntermNode*& node) {
TIntermSymbol* symbol = node->getAsSymbolNode();
if (!symbol) {
TIntermAggregate *constructor = node->getAsAggregate();
if (constructor && constructor->getOp() == EOpConstructTextureSampler) {
if (!constructor->getSequence().empty())
node = constructor->getSequence()[0];
}
} else if (symbol->getBasicType() == EbtSampler && symbol->getType().getSampler().isTexture()) {
symbol->getWritableType().getSampler().combined = true;
TIntermAggregate *constructor = node->getAsAggregate();
if (constructor && constructor->getOp() == EOpConstructTextureSampler) {
if (!constructor->getSequence().empty())
node = constructor->getSequence()[0];
}
});
return true;