Commit 2076acf6 by John Kessenich

Versioning: Move to symbolic version numbers for SPV 1.0 vs 1.3 and Vulkan 1.0 vs. 1.1.

parent 96e77c11
......@@ -196,7 +196,7 @@ protected:
#endif
void addPre13Extension(const char* ext)
{
if (builder.getSpvVersion() < 0x00010300)
if (builder.getSpvVersion() < glslang::Spv_1_3)
builder.addExtension(ext);
}
......@@ -2463,7 +2463,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
case glslang::EbtFloat16:
builder.addCapability(spv::CapabilityFloat16);
#if AMD_EXTENSIONS
if (builder.getSpvVersion() < 0x00010300)
if (builder.getSpvVersion() < glslang::Spv_1_3)
builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
#endif
spvType = builder.makeFloatType(16);
......@@ -2487,7 +2487,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
case glslang::EbtInt16:
builder.addCapability(spv::CapabilityInt16);
#ifdef AMD_EXTENSIONS
if (builder.getSpvVersion() < 0x00010300)
if (builder.getSpvVersion() < glslang::Spv_1_3)
builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16);
#endif
spvType = builder.makeIntType(16);
......@@ -2495,7 +2495,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
case glslang::EbtUint16:
builder.addCapability(spv::CapabilityInt16);
#ifdef AMD_EXTENSIONS
if (builder.getSpvVersion() < 0x00010300)
if (builder.getSpvVersion() < glslang::Spv_1_3)
builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16);
#endif
spvType = builder.makeUintType(16);
......
......@@ -156,11 +156,11 @@ const char* sourceEntryPointName = nullptr;
const char* shaderStageName = nullptr;
const char* variableName = nullptr;
std::vector<std::string> IncludeDirectoryList;
int ClientInputSemanticsVersion = 100; // maps to, say, #define VULKAN 100
int VulkanClientVersion = 100; // would map to, say, Vulkan 1.0
int OpenGLClientVersion = 450; // doesn't influence anything yet, but maps to OpenGL 4.50
unsigned int TargetVersion = 0x00010000; // maps to, say, SPIR-V 1.0
std::vector<std::string> Processes; // what should be recorded by OpModuleProcessed, or equivalent
int ClientInputSemanticsVersion = 100; // maps to, say, #define VULKAN 100
int VulkanClientVersion = glslang::Vulkan_1_0; // would map to, say, Vulkan 1.0
int OpenGLClientVersion = 450; // doesn't influence anything yet, but maps to OpenGL 4.50
unsigned int TargetVersion = glslang::Spv_1_0; // maps to, say, SPIR-V 1.0
std::vector<std::string> Processes; // what should be recorded by OpModuleProcessed, or equivalent
// Per descriptor-set binding base data
typedef std::map<unsigned int, unsigned int> TPerSetBaseBinding;
......@@ -504,11 +504,11 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
if (argc > 1) {
if (strcmp(argv[1], "vulkan1.0") == 0) {
setVulkanSpv();
VulkanClientVersion = 100;
VulkanClientVersion = glslang::Vulkan_1_0;
} else if (strcmp(argv[1], "vulkan1.1") == 0) {
setVulkanSpv();
TargetVersion = 0x00010300;
VulkanClientVersion = 110;
TargetVersion = glslang::Spv_1_3;
VulkanClientVersion = glslang::Vulkan_1_1;
} else if (strcmp(argv[1], "opengl") == 0) {
setOpenGlSpv();
OpenGLClientVersion = 450;
......@@ -517,7 +517,7 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
}
bumpArg();
} else if (lowerword == "variable-name" || // synonyms
lowerword == "vn") {
lowerword == "vn") {
Options |= EOptionOutputHexadecimal;
if (argc <= 1)
Error("no <C-variable-name> provided for --variable-name");
......
......@@ -1640,7 +1640,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
if (callNode.getOp() > EOpSubgroupGuardStart && callNode.getOp() < EOpSubgroupGuardStop) {
// these require SPIR-V 1.3
if (spvVersion.spv > 0 && spvVersion.spv < 0x00010300)
if (spvVersion.spv > 0 && spvVersion.spv < Spv_1_3)
error(loc, "requires SPIR-V 1.3", "subgroup op", "");
}
}
......
......@@ -619,9 +619,9 @@ void TranslateEnvironment(const TEnvironment* environment, EShMessages& messages
{
// Set up environmental defaults, first ignoring 'environment'.
if (messages & EShMsgSpvRules)
spvVersion.spv = 0x00010000;
spvVersion.spv = Spv_1_0;
if (messages & EShMsgVulkanRules) {
spvVersion.vulkan = 100;
spvVersion.vulkan = Vulkan_1_0;
spvVersion.vulkanGlsl = 100;
} else if (spvVersion.spv != 0)
spvVersion.openGl = 100;
......
......@@ -135,11 +135,17 @@ struct TClient {
int version; // version of client itself (not the client's input dialect)
};
static const int Vulkan_1_0 = (1 << 22);
static const int Vulkan_1_1 = (1 << 22) | (1 << 12);
struct TTarget {
EShTargetLanguage language;
unsigned int version; // the version to target, if SPIR-V, defined by "word 1" of the SPIR-V binary header
};
static const int Spv_1_0 = (1 << 16);
static const int Spv_1_3 = (1 << 16) | (3 << 8);
// All source/client/target versions and settings.
// Can override previous methods of setting, when items are set here.
// Expected to grow, as more are added, rather than growing parameter lists.
......
......@@ -44,7 +44,7 @@ using CompileToAstTest = GlslangTest<::testing::TestWithParam<std::string>>;
TEST_P(CompileToAstTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::OpenGL, 100,
Source::GLSL, Semantics::OpenGL, glslang::Vulkan_1_0,
Target::AST);
}
......
......@@ -58,7 +58,7 @@ std::string FileNameAsCustomTestSuffix(
}
using HlslCompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslVulkan110CompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslVulkan1_1CompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslCompileAndFlattenTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslLegalizeTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
......@@ -67,14 +67,14 @@ using HlslLegalizeTest = GlslangTest<::testing::TestWithParam<FileNameEntryPoint
TEST_P(HlslCompileTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, 100,
Source::HLSL, Semantics::Vulkan, glslang::Vulkan_1_0,
Target::BothASTAndSpv, true, GetParam().entryPoint);
}
TEST_P(HlslVulkan110CompileTest, FromFile)
TEST_P(HlslVulkan1_1CompileTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, 110,
Source::HLSL, Semantics::Vulkan, glslang::Vulkan_1_1,
Target::BothASTAndSpv, true, GetParam().entryPoint);
}
......@@ -90,7 +90,7 @@ TEST_P(HlslCompileAndFlattenTest, FromFile)
TEST_P(HlslLegalizeTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, 100,
Source::HLSL, Semantics::Vulkan, glslang::Vulkan_1_0,
Target::Spv, true, GetParam().entryPoint,
"/baseLegalResults/", false);
}
......@@ -385,7 +385,7 @@ INSTANTIATE_TEST_CASE_P(
// clang-format off
INSTANTIATE_TEST_CASE_P(
ToSpirv, HlslVulkan110CompileTest,
ToSpirv, HlslVulkan1_1CompileTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.wavebroadcast.comp", "CSMain"},
{"hlsl.waveprefix.comp", "CSMain"},
......
......@@ -63,7 +63,7 @@ std::string FileNameAsCustomTestSuffixIoMap(
}
using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkan110ToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkan1_1ToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileOpenGLToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using VulkanSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
using OpenGLSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
......@@ -83,14 +83,14 @@ using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::t
TEST_P(CompileVulkanToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, 100,
Source::GLSL, Semantics::Vulkan, glslang::Vulkan_1_0,
Target::Spv);
}
TEST_P(CompileVulkan110ToSpirvTest, FromFile)
TEST_P(CompileVulkan1_1ToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, 110,
Source::GLSL, Semantics::Vulkan, glslang::Vulkan_1_1,
Target::Spv);
}
......@@ -108,7 +108,7 @@ TEST_P(CompileOpenGLToSpirvTest, FromFile)
TEST_P(VulkanSemantics, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, 100,
Source::GLSL, Semantics::Vulkan, glslang::Vulkan_1_0,
Target::Spv, false);
}
......@@ -125,7 +125,7 @@ TEST_P(OpenGLSemantics, FromFile)
TEST_P(VulkanAstSemantics, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, 100,
Source::GLSL, Semantics::Vulkan, glslang::Vulkan_1_0,
Target::AST);
}
......@@ -165,7 +165,7 @@ TEST_P(GlslIoMap, FromFile)
TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, 100,
Source::GLSL, Semantics::Vulkan, glslang::Vulkan_1_0,
Target::Spv);
}
#endif
......@@ -176,7 +176,7 @@ TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
TEST_P(CompileVulkanToSpirvTestNV, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, 100,
Source::GLSL, Semantics::Vulkan, glslang::Vulkan_1_0,
Target::Spv);
}
#endif
......@@ -347,7 +347,7 @@ INSTANTIATE_TEST_CASE_P(
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkan110ToSpirvTest,
Glsl, CompileVulkan1_1ToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.deviceGroup.frag",
"spv.drawParams.vert",
......
......@@ -218,13 +218,15 @@ public:
: glslang::EShSourceGlsl,
stage, glslang::EShClientVulkan, 100);
shader.setEnvClient(glslang::EShClientVulkan, clientTargetVersion);
shader.setEnvTarget(glslang::EShTargetSpv, clientTargetVersion == 110 ? 0x00010300 : 0x00010000);
shader.setEnvTarget(glslang::EShTargetSpv,
clientTargetVersion == glslang::Vulkan_1_1 ? glslang::Spv_1_3
: glslang::Spv_1_0);
} else {
shader.setEnvInput((controls & EShMsgReadHlsl) ? glslang::EShSourceHlsl
: glslang::EShSourceGlsl,
stage, glslang::EShClientOpenGL, 100);
shader.setEnvClient(glslang::EShClientOpenGL, clientTargetVersion);
shader.setEnvTarget(glslang::EshTargetSpv, 0x00010000);
shader.setEnvTarget(glslang::EshTargetSpv, glslang::Spv_1_0);
}
}
......@@ -447,7 +449,7 @@ public:
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
const EShMessages controls = DeriveOptions(source, semantics, target);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, 100, true);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, glslang::Vulkan_1_0, true);
// Generate the hybrid output in the way of glslangValidator.
std::ostringstream stream;
......@@ -616,7 +618,7 @@ public:
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
const EShMessages controls = DeriveOptions(source, semantics, target);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, 100, false,
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, glslang::Vulkan_1_0, false,
EShTexSampTransUpgradeTextureRemoveSampler);
// Generate the hybrid output in the way of glslangValidator.
......
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