Commit 387ff13c authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

Add plumbing to set MSL version

parent d860eba9
......@@ -192,7 +192,7 @@ QBakedShader QShaderBaker::bake()
shader.shader = currentSpirvShader->translateToHLSL(req.second.version);
break;
case QBakedShader::MslShader:
shader.shader = currentSpirvShader->translateToMSL();
shader.shader = currentSpirvShader->translateToMSL(req.second.version);
shader.entryPoint = QByteArrayLiteral("main0");
break;
default:
......
......@@ -424,11 +424,16 @@ QByteArray QSpirvShader::translateToHLSL(int version) const
return QByteArray::fromStdString(hlsl);
}
QByteArray QSpirvShader::translateToMSL() const
QByteArray QSpirvShader::translateToMSL(int version) const
{
if (!d->mslGen)
d->mslGen = new spirv_cross::CompilerMSL(reinterpret_cast<const uint32_t *>(d->ir.constData()), d->ir.size() / 4);
spirv_cross::CompilerMSL::Options options;
options.msl_version = spirv_cross::CompilerMSL::Options::make_msl_version(version / 10, version % 10);
// leave platform set to macOS, it won't matter in practice (hopefully)
d->mslGen->set_msl_options(options);
const std::string msl = d->mslGen->compile();
return QByteArray::fromStdString(msl);
......
......@@ -73,7 +73,7 @@ public:
QByteArray translateToGLSL(int version = 120, GlslFlags flags = GlslFlags()) const;
QByteArray translateToHLSL(int version = 50) const;
QByteArray translateToMSL() const;
QByteArray translateToMSL(int version = 12) const;
private:
Q_DISABLE_COPY(QSpirvShader)
......
......@@ -34,8 +34,8 @@ other shader types? (gs?)
shadertools:
version to qsb data stream
hlsl version to qsb
msl version to qsb (?)
hlsl version config to qsb
msl version config to qsb
bytecode (fxc/dxc) for d3d?
bytecode for metal?
......
......@@ -232,9 +232,9 @@ int main(int argc, char **argv)
}
}
if (cmdLineParser.isSet(hlslOption))
genShaders << qMakePair(QBakedShader::HlslShader, QBakedShader::ShaderSourceVersion(50));
genShaders << qMakePair(QBakedShader::HlslShader, QBakedShader::ShaderSourceVersion(50)); // Shader Model 5.0
if (cmdLineParser.isSet(mslOption))
genShaders << qMakePair(QBakedShader::MslShader, QBakedShader::ShaderSourceVersion());
genShaders << qMakePair(QBakedShader::MslShader, QBakedShader::ShaderSourceVersion(12)); // 1.2
baker.setGeneratedShaders(genShaders);
QBakedShader bs = baker.bake();
......
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