Commit 87a94fc0 by John Kessenich

Merge pull request #302 from amdrexu/bugfix

SPV: Fix an issue of interpolation decoration.
parents 2921e0c5 bbceed7b
...@@ -108,7 +108,7 @@ public: ...@@ -108,7 +108,7 @@ public:
void dumpSpv(std::vector<unsigned int>& out); void dumpSpv(std::vector<unsigned int>& out);
protected: protected:
spv::Decoration TranslateInterpolationDecoration(const glslang::TQualifier& qualifier); spv::Decoration TranslateAuxiliaryStorageDecoration(const glslang::TQualifier& qualifier);
spv::BuiltIn TranslateBuiltInDecoration(glslang::TBuiltInVariable, bool member); spv::BuiltIn TranslateBuiltInDecoration(glslang::TBuiltInVariable, bool member);
spv::ImageFormat TranslateImageFormat(const glslang::TType& type); spv::ImageFormat TranslateImageFormat(const glslang::TType& type);
spv::Id createSpvVariable(const glslang::TIntermSymbol*); spv::Id createSpvVariable(const glslang::TIntermSymbol*);
...@@ -354,18 +354,26 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type, glslang::T ...@@ -354,18 +354,26 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type, glslang::T
// Translate glslang type to SPIR-V interpolation decorations. // Translate glslang type to SPIR-V interpolation decorations.
// Returns spv::Decoration(spv::BadValue) when no decoration // Returns spv::Decoration(spv::BadValue) when no decoration
// should be applied. // should be applied.
spv::Decoration TGlslangToSpvTraverser::TranslateInterpolationDecoration(const glslang::TQualifier& qualifier) spv::Decoration TranslateInterpolationDecoration(const glslang::TQualifier& qualifier)
{ {
if (qualifier.smooth) { if (qualifier.smooth)
// Smooth decoration doesn't exist in SPIR-V 1.0 // Smooth decoration doesn't exist in SPIR-V 1.0
return (spv::Decoration)spv::BadValue; return (spv::Decoration)spv::BadValue;
} else if (qualifier.nopersp)
if (qualifier.nopersp)
return spv::DecorationNoPerspective; return spv::DecorationNoPerspective;
else if (qualifier.patch)
return spv::DecorationPatch;
else if (qualifier.flat) else if (qualifier.flat)
return spv::DecorationFlat; return spv::DecorationFlat;
else
return (spv::Decoration)spv::BadValue;
}
// Translate glslang type to SPIR-V auxiliary storage decorations.
// Returns spv::Decoration(spv::BadValue) when no decoration
// should be applied.
spv::Decoration TGlslangToSpvTraverser::TranslateAuxiliaryStorageDecoration(const glslang::TQualifier& qualifier)
{
if (qualifier.patch)
return spv::DecorationPatch;
else if (qualifier.centroid) else if (qualifier.centroid)
return spv::DecorationCentroid; return spv::DecorationCentroid;
else if (qualifier.sample) { else if (qualifier.sample) {
...@@ -1890,9 +1898,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1890,9 +1898,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
builder.addMemberName(spvType, member, glslangType.getFieldName().c_str()); builder.addMemberName(spvType, member, glslangType.getFieldName().c_str());
addMemberDecoration(spvType, member, TranslateLayoutDecoration(glslangType, subQualifier.layoutMatrix)); addMemberDecoration(spvType, member, TranslateLayoutDecoration(glslangType, subQualifier.layoutMatrix));
addMemberDecoration(spvType, member, TranslatePrecisionDecoration(glslangType)); addMemberDecoration(spvType, member, TranslatePrecisionDecoration(glslangType));
// Add interpolation 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)); addMemberDecoration(spvType, member, TranslateInterpolationDecoration(subQualifier));
addMemberDecoration(spvType, member, TranslateAuxiliaryStorageDecoration(subQualifier));
} }
addMemberDecoration(spvType, member, TranslateInvariantDecoration(subQualifier)); addMemberDecoration(spvType, member, TranslateInvariantDecoration(subQualifier));
...@@ -3917,6 +3926,7 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol ...@@ -3917,6 +3926,7 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
if (! symbol->getType().isStruct()) { if (! symbol->getType().isStruct()) {
addDecoration(id, TranslatePrecisionDecoration(symbol->getType())); addDecoration(id, TranslatePrecisionDecoration(symbol->getType()));
addDecoration(id, TranslateInterpolationDecoration(symbol->getType().getQualifier())); addDecoration(id, TranslateInterpolationDecoration(symbol->getType().getQualifier()));
addDecoration(id, TranslateAuxiliaryStorageDecoration(symbol->getType().getQualifier()));
if (symbol->getType().getQualifier().hasSpecConstantId()) if (symbol->getType().getQualifier().hasSpecConstantId())
addDecoration(id, spv::DecorationSpecId, symbol->getType().getQualifier().layoutSpecConstantId); addDecoration(id, spv::DecorationSpecId, symbol->getType().getQualifier().layoutSpecConstantId);
if (symbol->getQualifier().hasIndex()) if (symbol->getQualifier().hasIndex())
......
...@@ -21,9 +21,11 @@ Linked vertex stage: ...@@ -21,9 +21,11 @@ Linked vertex stage:
Name 15 "outVf" Name 15 "outVf"
Name 17 "outVn" Name 17 "outVn"
Name 19 "outVcn" Name 19 "outVcn"
Decorate 9(outVc) Centroid
Decorate 15(outVf) Flat Decorate 15(outVf) Flat
Decorate 17(outVn) NoPerspective Decorate 17(outVn) NoPerspective
Decorate 19(outVcn) NoPerspective Decorate 19(outVcn) NoPerspective
Decorate 19(outVcn) Centroid
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
......
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