SPV: Implement Vulkan 1.1 features and extensions.
This commit is contained in:
@@ -44,7 +44,7 @@ using CompileToAstTest = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
TEST_P(CompileToAstTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::OpenGL,
|
||||
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
|
||||
Target::AST);
|
||||
}
|
||||
|
||||
@@ -210,6 +210,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"precise.tesc",
|
||||
"precise_struct_block.vert",
|
||||
"maxClipDistances.vert",
|
||||
"findFunction.frag",
|
||||
})),
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
||||
@@ -58,6 +58,7 @@ std::string FileNameAsCustomTestSuffix(
|
||||
}
|
||||
|
||||
using HlslCompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
|
||||
using HlslVulkan1_1CompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
|
||||
using HlslCompileAndFlattenTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
|
||||
using HlslLegalizeTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
|
||||
|
||||
@@ -66,7 +67,14 @@ using HlslLegalizeTest = GlslangTest<::testing::TestWithParam<FileNameEntryPoint
|
||||
TEST_P(HlslCompileTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
|
||||
Source::HLSL, Semantics::Vulkan,
|
||||
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
|
||||
Target::BothASTAndSpv, true, GetParam().entryPoint);
|
||||
}
|
||||
|
||||
TEST_P(HlslVulkan1_1CompileTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
|
||||
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1,
|
||||
Target::BothASTAndSpv, true, GetParam().entryPoint);
|
||||
}
|
||||
|
||||
@@ -82,7 +90,7 @@ TEST_P(HlslCompileAndFlattenTest, FromFile)
|
||||
TEST_P(HlslLegalizeTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
|
||||
Source::HLSL, Semantics::Vulkan,
|
||||
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
|
||||
Target::Spv, true, GetParam().entryPoint,
|
||||
"/baseLegalResults/", false);
|
||||
}
|
||||
@@ -375,6 +383,22 @@ INSTANTIATE_TEST_CASE_P(
|
||||
);
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
ToSpirv, HlslVulkan1_1CompileTest,
|
||||
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
|
||||
{"hlsl.wavebroadcast.comp", "CSMain"},
|
||||
{"hlsl.waveprefix.comp", "CSMain"},
|
||||
{"hlsl.wavequad.comp", "CSMain"},
|
||||
{"hlsl.wavequery.comp", "CSMain"},
|
||||
{"hlsl.wavequery.frag", "PixelShaderFunction"},
|
||||
{"hlsl.wavereduction.comp", "CSMain"},
|
||||
{"hlsl.wavevote.comp", "CSMain"},
|
||||
}),
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
ToSpirv, HlslCompileAndFlattenTest,
|
||||
|
||||
@@ -63,6 +63,7 @@ std::string FileNameAsCustomTestSuffixIoMap(
|
||||
}
|
||||
|
||||
using CompileVulkanToSpirvTest = 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>>;
|
||||
@@ -82,7 +83,14 @@ using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::t
|
||||
TEST_P(CompileVulkanToSpirvTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::Vulkan,
|
||||
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
|
||||
Target::Spv);
|
||||
}
|
||||
|
||||
TEST_P(CompileVulkan1_1ToSpirvTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1,
|
||||
Target::Spv);
|
||||
}
|
||||
|
||||
@@ -91,7 +99,7 @@ TEST_P(CompileVulkanToSpirvTest, FromFile)
|
||||
TEST_P(CompileOpenGLToSpirvTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::OpenGL,
|
||||
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
|
||||
Target::Spv);
|
||||
}
|
||||
|
||||
@@ -100,7 +108,7 @@ TEST_P(CompileOpenGLToSpirvTest, FromFile)
|
||||
TEST_P(VulkanSemantics, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::Vulkan,
|
||||
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
|
||||
Target::Spv, false);
|
||||
}
|
||||
|
||||
@@ -109,7 +117,7 @@ TEST_P(VulkanSemantics, FromFile)
|
||||
TEST_P(OpenGLSemantics, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::OpenGL,
|
||||
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
|
||||
Target::Spv, false);
|
||||
}
|
||||
|
||||
@@ -117,7 +125,7 @@ TEST_P(OpenGLSemantics, FromFile)
|
||||
TEST_P(VulkanAstSemantics, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::Vulkan,
|
||||
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
|
||||
Target::AST);
|
||||
}
|
||||
|
||||
@@ -157,7 +165,7 @@ TEST_P(GlslIoMap, FromFile)
|
||||
TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::Vulkan,
|
||||
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
|
||||
Target::Spv);
|
||||
}
|
||||
#endif
|
||||
@@ -168,7 +176,7 @@ TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
|
||||
TEST_P(CompileVulkanToSpirvTestNV, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::Vulkan,
|
||||
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
|
||||
Target::Spv);
|
||||
}
|
||||
#endif
|
||||
@@ -243,9 +251,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"spv.dataOutIndirect.vert",
|
||||
"spv.deepRvalue.frag",
|
||||
"spv.depthOut.frag",
|
||||
"spv.deviceGroup.frag",
|
||||
"spv.discard-dce.frag",
|
||||
"spv.drawParams.vert",
|
||||
"spv.doWhileLoop.frag",
|
||||
"spv.earlyReturnDiscard.frag",
|
||||
"spv.extPostDepthCoverage.frag",
|
||||
@@ -273,7 +279,6 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"spv.merge-unreachable.frag",
|
||||
"spv.multiStruct.comp",
|
||||
"spv.multiStructFuncall.frag",
|
||||
"spv.multiView.frag",
|
||||
"spv.newTexture.frag",
|
||||
"spv.noDeadDecorations.vert",
|
||||
"spv.nonSquare.vert",
|
||||
@@ -332,6 +337,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"spv.storageBuffer.vert",
|
||||
"spv.precise.tese",
|
||||
"spv.precise.tesc",
|
||||
"spv.vulkan100.subgroupArithmetic.comp",
|
||||
"spv.xfb.vert",
|
||||
"spv.xfb2.vert",
|
||||
"spv.xfb3.vert",
|
||||
@@ -339,6 +345,38 @@ INSTANTIATE_TEST_CASE_P(
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Glsl, CompileVulkan1_1ToSpirvTest,
|
||||
::testing::ValuesIn(std::vector<std::string>({
|
||||
"spv.deviceGroup.frag",
|
||||
"spv.drawParams.vert",
|
||||
"spv.int8.frag",
|
||||
"spv.vulkan110.int16.frag",
|
||||
"spv.int32.frag",
|
||||
"spv.explicittypes.frag",
|
||||
"spv.float32.frag",
|
||||
"spv.float64.frag",
|
||||
"spv.multiView.frag",
|
||||
"spv.subgroup.frag",
|
||||
"spv.subgroup.geom",
|
||||
"spv.subgroup.tesc",
|
||||
"spv.subgroup.tese",
|
||||
"spv.subgroup.vert",
|
||||
"spv.subgroupArithmetic.comp",
|
||||
"spv.subgroupBasic.comp",
|
||||
"spv.subgroupBallot.comp",
|
||||
"spv.subgroupClustered.comp",
|
||||
"spv.subgroupClusteredNeg.comp",
|
||||
"spv.subgroupShuffle.comp",
|
||||
"spv.subgroupShuffleRelative.comp",
|
||||
"spv.subgroupQuad.comp",
|
||||
"spv.subgroupVote.comp",
|
||||
"spv.vulkan110.storageBuffer.vert",
|
||||
})),
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Hlsl, HlslIoMap,
|
||||
@@ -422,6 +460,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"spv.float16Fetch.frag",
|
||||
"spv.imageLoadStoreLod.frag",
|
||||
"spv.int16.frag",
|
||||
"spv.int16.amd.frag",
|
||||
"spv.shaderBallotAMD.comp",
|
||||
"spv.shaderFragMaskAMD.frag",
|
||||
"spv.textureGatherBiasLod.frag",
|
||||
|
||||
@@ -70,7 +70,7 @@ enum class Source {
|
||||
// Enum for shader compilation semantics.
|
||||
enum class Semantics {
|
||||
OpenGL,
|
||||
Vulkan,
|
||||
Vulkan
|
||||
};
|
||||
|
||||
// Enum for compilation target.
|
||||
@@ -197,14 +197,15 @@ public:
|
||||
GlslangResult compileAndLink(
|
||||
const std::string shaderName, const std::string& code,
|
||||
const std::string& entryPointName, EShMessages controls,
|
||||
glslang::EshTargetClientVersion clientTargetVersion,
|
||||
bool flattenUniformArrays = false,
|
||||
EShTextureSamplerTransformMode texSampTransMode = EShTexSampTransKeep,
|
||||
bool disableOptimizer = true,
|
||||
bool automap = true)
|
||||
{
|
||||
const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
|
||||
const EShLanguage stage = GetShaderStage(GetSuffix(shaderName));
|
||||
|
||||
glslang::TShader shader(kind);
|
||||
glslang::TShader shader(stage);
|
||||
if (automap) {
|
||||
shader.setAutoMapLocations(true);
|
||||
shader.setAutoMapBindings(true);
|
||||
@@ -212,6 +213,24 @@ public:
|
||||
shader.setTextureSamplerTransformMode(texSampTransMode);
|
||||
shader.setFlattenUniformArrays(flattenUniformArrays);
|
||||
|
||||
if (controls & EShMsgSpvRules) {
|
||||
if (controls & EShMsgVulkanRules) {
|
||||
shader.setEnvInput((controls & EShMsgReadHlsl) ? glslang::EShSourceHlsl
|
||||
: glslang::EShSourceGlsl,
|
||||
stage, glslang::EShClientVulkan, 100);
|
||||
shader.setEnvClient(glslang::EShClientVulkan, clientTargetVersion);
|
||||
shader.setEnvTarget(glslang::EShTargetSpv,
|
||||
clientTargetVersion == glslang::EShTargetVulkan_1_1 ? glslang::EShTargetSpv_1_3
|
||||
: glslang::EShTargetSpv_1_0);
|
||||
} else {
|
||||
shader.setEnvInput((controls & EShMsgReadHlsl) ? glslang::EShSourceHlsl
|
||||
: glslang::EShSourceGlsl,
|
||||
stage, glslang::EShClientOpenGL, 100);
|
||||
shader.setEnvClient(glslang::EShClientOpenGL, clientTargetVersion);
|
||||
shader.setEnvTarget(glslang::EshTargetSpv, glslang::EShTargetSpv_1_0);
|
||||
}
|
||||
}
|
||||
|
||||
bool success = compile(&shader, code, entryPointName, controls);
|
||||
|
||||
glslang::TProgram program;
|
||||
@@ -224,7 +243,7 @@ public:
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
glslang::SpvOptions options;
|
||||
options.disableOptimizer = disableOptimizer;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(kind),
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage),
|
||||
spirv_binary, &logger, &options);
|
||||
|
||||
std::ostringstream disassembly_stream;
|
||||
@@ -255,9 +274,9 @@ public:
|
||||
bool autoMapBindings,
|
||||
bool flattenUniformArrays)
|
||||
{
|
||||
const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
|
||||
const EShLanguage stage = GetShaderStage(GetSuffix(shaderName));
|
||||
|
||||
glslang::TShader shader(kind);
|
||||
glslang::TShader shader(stage);
|
||||
shader.setShiftSamplerBinding(baseSamplerBinding);
|
||||
shader.setShiftTextureBinding(baseTextureBinding);
|
||||
shader.setShiftImageBinding(baseImageBinding);
|
||||
@@ -279,7 +298,7 @@ public:
|
||||
|
||||
if (success && (controls & EShMsgSpvRules)) {
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(kind),
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage),
|
||||
spirv_binary, &logger);
|
||||
|
||||
std::ostringstream disassembly_stream;
|
||||
@@ -303,9 +322,9 @@ public:
|
||||
const std::string& entryPointName, EShMessages controls,
|
||||
const unsigned int remapOptions = spv::spirvbin_t::NONE)
|
||||
{
|
||||
const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
|
||||
const EShLanguage stage = GetShaderStage(GetSuffix(shaderName));
|
||||
|
||||
glslang::TShader shader(kind);
|
||||
glslang::TShader shader(stage);
|
||||
shader.setAutoMapBindings(true);
|
||||
shader.setAutoMapLocations(true);
|
||||
|
||||
@@ -319,7 +338,7 @@ public:
|
||||
|
||||
if (success && (controls & EShMsgSpvRules)) {
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(kind),
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage),
|
||||
spirv_binary, &logger);
|
||||
|
||||
spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions);
|
||||
@@ -388,6 +407,7 @@ public:
|
||||
const std::string& testName,
|
||||
Source source,
|
||||
Semantics semantics,
|
||||
glslang::EshTargetClientVersion clientTargetVersion,
|
||||
Target target,
|
||||
bool automap = true,
|
||||
const std::string& entryPointName="",
|
||||
@@ -403,8 +423,8 @@ public:
|
||||
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
|
||||
|
||||
const EShMessages controls = DeriveOptions(source, semantics, target);
|
||||
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false, EShTexSampTransKeep,
|
||||
disableOptimizer, automap);
|
||||
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, clientTargetVersion, false,
|
||||
EShTexSampTransKeep, disableOptimizer, automap);
|
||||
|
||||
// Generate the hybrid output in the way of glslangValidator.
|
||||
std::ostringstream stream;
|
||||
@@ -430,7 +450,8 @@ public:
|
||||
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
|
||||
|
||||
const EShMessages controls = DeriveOptions(source, semantics, target);
|
||||
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, true);
|
||||
GlslangResult result = compileAndLink(testName, input, entryPointName, controls,
|
||||
glslang::EShTargetVulkan_1_0, true);
|
||||
|
||||
// Generate the hybrid output in the way of glslangValidator.
|
||||
std::ostringstream stream;
|
||||
@@ -599,7 +620,8 @@ public:
|
||||
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
|
||||
|
||||
const EShMessages controls = DeriveOptions(source, semantics, target);
|
||||
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false,
|
||||
GlslangResult result = compileAndLink(testName, input, entryPointName, controls,
|
||||
glslang::EShTargetVulkan_1_0, false,
|
||||
EShTexSampTransUpgradeTextureRemoveSampler);
|
||||
|
||||
// Generate the hybrid output in the way of glslangValidator.
|
||||
|
||||
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
|
||||
glslangtest::GlobalTestSettings.updateMode = true;
|
||||
}
|
||||
if (std::string("--test-root") == argv[i]) {
|
||||
// Allow the user set the tets root directory. This is useful
|
||||
// Allow the user set the test root directory. This is useful
|
||||
// for testing with files from another source tree.
|
||||
if (i + 1 < argc) {
|
||||
glslangtest::GlobalTestSettings.testRoot = argv[i + 1];
|
||||
@@ -64,6 +64,11 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (std::string("--help") == argv[i]) {
|
||||
printf("\nExtra options:\n\n");
|
||||
printf(" --update-mode\n Update the golden results for the tests.\n");
|
||||
printf(" --test-root <arg>\n Specify the test root directory (useful for testing with\n files from another source tree).\n");
|
||||
}
|
||||
}
|
||||
|
||||
const int result = RUN_ALL_TESTS();
|
||||
|
||||
Reference in New Issue
Block a user