Support multiple source languages, adding HLSL as an option.
This commit is contained in:
@@ -160,15 +160,22 @@ protected:
|
||||
//
|
||||
|
||||
// Translate glslang profile to SPIR-V source language.
|
||||
spv::SourceLanguage TranslateSourceLanguage(EProfile profile)
|
||||
spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile profile)
|
||||
{
|
||||
switch (profile) {
|
||||
case ENoProfile:
|
||||
case ECoreProfile:
|
||||
case ECompatibilityProfile:
|
||||
return spv::SourceLanguageGLSL;
|
||||
case EEsProfile:
|
||||
return spv::SourceLanguageESSL;
|
||||
switch (source) {
|
||||
case glslang::EShSourceGlsl:
|
||||
switch (profile) {
|
||||
case ENoProfile:
|
||||
case ECoreProfile:
|
||||
case ECompatibilityProfile:
|
||||
return spv::SourceLanguageGLSL;
|
||||
case EEsProfile:
|
||||
return spv::SourceLanguageESSL;
|
||||
default:
|
||||
return spv::SourceLanguageUnknown;
|
||||
}
|
||||
case glslang::EShSourceHlsl:
|
||||
return spv::SourceLanguageHLSL;
|
||||
default:
|
||||
return spv::SourceLanguageUnknown;
|
||||
}
|
||||
@@ -587,7 +594,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
|
||||
spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage());
|
||||
|
||||
builder.clearAccessChain();
|
||||
builder.setSource(TranslateSourceLanguage(glslangIntermediate->getProfile()), glslangIntermediate->getVersion());
|
||||
builder.setSource(TranslateSourceLanguage(glslangIntermediate->getSource(), glslangIntermediate->getProfile()), glslangIntermediate->getVersion());
|
||||
stdBuiltins = builder.import("GLSL.std.450");
|
||||
builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450);
|
||||
shaderEntry = builder.makeEntrypoint(glslangIntermediate->getEntryPoint().c_str());
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace spv {
|
||||
// (for non-sparse mask enums, this is the number of enumurants)
|
||||
//
|
||||
|
||||
const int SourceLanguageCeiling = 5;
|
||||
const int SourceLanguageCeiling = 6; // HLSL todo: need official enumerant
|
||||
|
||||
const char* SourceString(int source)
|
||||
{
|
||||
@@ -74,6 +74,7 @@ const char* SourceString(int source)
|
||||
case 2: return "GLSL";
|
||||
case 3: return "OpenCL_C";
|
||||
case 4: return "OpenCL_CPP";
|
||||
case 5: return "HLSL";
|
||||
|
||||
case SourceLanguageCeiling:
|
||||
default: return "Bad";
|
||||
|
||||
@@ -61,6 +61,7 @@ enum SourceLanguage {
|
||||
SourceLanguageGLSL = 2,
|
||||
SourceLanguageOpenCL_C = 3,
|
||||
SourceLanguageOpenCL_CPP = 4,
|
||||
SourceLanguageHLSL = 5,
|
||||
};
|
||||
|
||||
enum ExecutionModel {
|
||||
|
||||
Reference in New Issue
Block a user