SPV Version: Emit the requested SPIR-V version, not the header version.
Fixes #1236.
This commit is contained in:
@@ -107,7 +107,8 @@ private:
|
||||
//
|
||||
class TGlslangToSpvTraverser : public glslang::TIntermTraverser {
|
||||
public:
|
||||
TGlslangToSpvTraverser(const glslang::TIntermediate*, spv::SpvBuildLogger* logger, glslang::SpvOptions& options);
|
||||
TGlslangToSpvTraverser(unsigned int spvVersion, const glslang::TIntermediate*, spv::SpvBuildLogger* logger,
|
||||
glslang::SpvOptions& options);
|
||||
virtual ~TGlslangToSpvTraverser() { }
|
||||
|
||||
bool visitAggregate(glslang::TVisit, glslang::TIntermAggregate*);
|
||||
@@ -880,13 +881,13 @@ bool HasNonLayoutQualifiers(const glslang::TType& type, const glslang::TQualifie
|
||||
// Implement the TGlslangToSpvTraverser class.
|
||||
//
|
||||
|
||||
TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* glslangIntermediate,
|
||||
TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, const glslang::TIntermediate* glslangIntermediate,
|
||||
spv::SpvBuildLogger* buildLogger, glslang::SpvOptions& options)
|
||||
: TIntermTraverser(true, false, true),
|
||||
options(options),
|
||||
shaderEntry(nullptr), currentFunction(nullptr),
|
||||
sequenceDepth(0), logger(buildLogger),
|
||||
builder((glslang::GetKhronosToolId() << 16) | glslang::GetSpirvGeneratorVersion(), logger),
|
||||
builder(spvVersion, (glslang::GetKhronosToolId() << 16) | glslang::GetSpirvGeneratorVersion(), logger),
|
||||
inEntryPoint(false), entryPointTerminated(false), linkageOnly(false),
|
||||
glslangIntermediate(glslangIntermediate)
|
||||
{
|
||||
@@ -6067,7 +6068,7 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
|
||||
|
||||
glslang::GetThreadPoolAllocator().push();
|
||||
|
||||
TGlslangToSpvTraverser it(&intermediate, logger, *options);
|
||||
TGlslangToSpvTraverser it(intermediate.getSpv().spv, &intermediate, logger, *options);
|
||||
root->traverse(&it);
|
||||
it.finishSpv();
|
||||
it.dumpSpv(spirv);
|
||||
|
||||
@@ -56,7 +56,8 @@
|
||||
|
||||
namespace spv {
|
||||
|
||||
Builder::Builder(unsigned int magicNumber, SpvBuildLogger* buildLogger) :
|
||||
Builder::Builder(unsigned int spvVersion, unsigned int magicNumber, SpvBuildLogger* buildLogger) :
|
||||
spvVersion(spvVersion),
|
||||
source(SourceLanguageUnknown),
|
||||
sourceVersion(0),
|
||||
sourceFileStringId(NoResult),
|
||||
@@ -2403,7 +2404,7 @@ void Builder::dump(std::vector<unsigned int>& out) const
|
||||
{
|
||||
// Header, before first instructions:
|
||||
out.push_back(MagicNumber);
|
||||
out.push_back(Version);
|
||||
out.push_back(spvVersion);
|
||||
out.push_back(builderNumber);
|
||||
out.push_back(uniqueId + 1);
|
||||
out.push_back(0);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace spv {
|
||||
|
||||
class Builder {
|
||||
public:
|
||||
Builder(unsigned int userNumber, SpvBuildLogger* logger);
|
||||
Builder(unsigned int spvVersion, unsigned int userNumber, SpvBuildLogger* logger);
|
||||
virtual ~Builder();
|
||||
|
||||
static const int maxMatrixSize = 4;
|
||||
@@ -585,6 +585,7 @@ public:
|
||||
void dumpInstructions(std::vector<unsigned int>&, const std::vector<std::unique_ptr<Instruction> >&) const;
|
||||
void dumpModuleProcesses(std::vector<unsigned int>&) const;
|
||||
|
||||
unsigned int spvVersion; // the version of SPIR-V to emit in the header
|
||||
SourceLanguage source;
|
||||
int sourceVersion;
|
||||
spv::Id sourceFileStringId;
|
||||
|
||||
Reference in New Issue
Block a user