SPV 1.4: Add testing infrastructure for SPV 1.4 tests.

This includes the test for the first feature of OpEntryPoint.
This commit is contained in:
John Kessenich
2019-01-04 17:10:53 +07:00
parent 7c7731ecbb
commit cfea59d357
6 changed files with 185 additions and 32 deletions

View File

@@ -48,7 +48,7 @@ using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
TEST_P(CompileToAstTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::AST);
}
@@ -57,7 +57,7 @@ TEST_P(CompileToAstTest, FromFile)
TEST_P(CompileToAstTestNV, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::AST);
}
#endif

View File

@@ -70,14 +70,14 @@ using HlslLegalDebugTest = GlslangTest<::testing::TestWithParam<FileNameEntryPoi
TEST_P(HlslCompileTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_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,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_3,
Target::BothASTAndSpv, true, GetParam().entryPoint);
}
@@ -93,7 +93,7 @@ TEST_P(HlslCompileAndFlattenTest, FromFile)
TEST_P(HlslLegalizeTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, true, GetParam().entryPoint,
"/baseLegalResults/", true);
}
@@ -103,7 +103,7 @@ TEST_P(HlslLegalizeTest, FromFile)
TEST_P(HlslDebugTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, true, GetParam().entryPoint,
"/baseResults/", false, true);
}
@@ -111,7 +111,8 @@ TEST_P(HlslDebugTest, FromFile)
TEST_P(HlslDX9CompatibleTest, FromFile)
{
loadFileCompileAndCheckWithOptions(GlobalTestSettings.testRoot, GetParam().fileName, Source::HLSL,
Semantics::Vulkan, glslang::EShTargetVulkan_1_0, Target::BothASTAndSpv, true,
Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::BothASTAndSpv, true,
GetParam().entryPoint, "/baseResults/",
EShMessages::EShMsgHlslDX9Compatible);
}
@@ -122,7 +123,7 @@ TEST_P(HlslDX9CompatibleTest, FromFile)
TEST_P(HlslLegalDebugTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, true, GetParam().entryPoint,
"/baseResults/", true, true);
}

View File

@@ -65,6 +65,7 @@ std::string FileNameAsCustomTestSuffixIoMap(
using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkanToDebugSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkan1_1ToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileToSpirv14Test = 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>>;
@@ -84,7 +85,7 @@ using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::t
TEST_P(CompileVulkanToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv);
}
@@ -94,7 +95,7 @@ TEST_P(CompileVulkanToDebugSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan,
glslang::EShTargetVulkan_1_0,
glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, true, "",
"/baseResults/", false, true);
}
@@ -102,7 +103,14 @@ TEST_P(CompileVulkanToDebugSpirvTest, FromFile)
TEST_P(CompileVulkan1_1ToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1,
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_3,
Target::Spv);
}
TEST_P(CompileToSpirv14Test, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_4,
Target::Spv);
}
@@ -111,7 +119,7 @@ TEST_P(CompileVulkan1_1ToSpirvTest, FromFile)
TEST_P(CompileOpenGLToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv);
}
@@ -120,7 +128,7 @@ TEST_P(CompileOpenGLToSpirvTest, FromFile)
TEST_P(VulkanSemantics, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, false);
}
@@ -129,7 +137,7 @@ TEST_P(VulkanSemantics, FromFile)
TEST_P(OpenGLSemantics, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, false);
}
@@ -137,7 +145,7 @@ TEST_P(OpenGLSemantics, FromFile)
TEST_P(VulkanAstSemantics, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::AST);
}
@@ -177,7 +185,7 @@ TEST_P(GlslIoMap, FromFile)
TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv);
}
#endif
@@ -188,7 +196,7 @@ TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
TEST_P(CompileVulkanToSpirvTestNV, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0,
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv);
}
#endif
@@ -453,6 +461,15 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileToSpirv14Test,
::testing::ValuesIn(std::vector<std::string>({
"spv.1.4.OpEntryPoint.frag",
})),
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
Hlsl, HlslIoMap,

31
gtests/TestFixture.h Normal file → Executable file
View File

@@ -212,6 +212,7 @@ public:
const std::string& shaderName, const std::string& code,
const std::string& entryPointName, EShMessages controls,
glslang::EShTargetClientVersion clientTargetVersion,
glslang::EShTargetLanguageVersion targetLanguageVersion,
bool flattenUniformArrays = false,
EShTextureSamplerTransformMode texSampTransMode = EShTexSampTransKeep,
bool enableOptimizer = false,
@@ -234,9 +235,7 @@ public:
: 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);
shader.setEnvTarget(glslang::EShTargetSpv, targetLanguageVersion);
} else {
shader.setEnvInput((controls & EShMsgReadHlsl) ? glslang::EShSourceHlsl
: glslang::EShSourceGlsl,
@@ -429,6 +428,7 @@ public:
Source source,
Semantics semantics,
glslang::EShTargetClientVersion clientTargetVersion,
glslang::EShTargetLanguageVersion targetLanguageVersion,
Target target,
bool automap = true,
const std::string& entryPointName="",
@@ -449,8 +449,8 @@ public:
controls = static_cast<EShMessages>(controls & ~EShMsgHlslLegalization);
if (enableDebug)
controls = static_cast<EShMessages>(controls | EShMsgDebugInfo);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, clientTargetVersion, false,
EShTexSampTransKeep, enableOptimizer, enableDebug, automap);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, clientTargetVersion,
targetLanguageVersion, false, EShTexSampTransKeep, enableOptimizer, enableDebug, automap);
// Generate the hybrid output in the way of glslangValidator.
std::ostringstream stream;
@@ -460,11 +460,12 @@ public:
expectedOutputFname, result.spirvWarningsErrors);
}
void loadFileCompileAndCheckWithOptions(const std::string &testDir,
const std::string &testName,
Source source,
Semantics semantics,
glslang::EShTargetClientVersion clientTargetVersion,
void loadFileCompileAndCheckWithOptions(const std::string &testDir,
const std::string &testName,
Source source,
Semantics semantics,
glslang::EShTargetClientVersion clientTargetVersion,
glslang::EShTargetLanguageVersion targetLanguageVersion,
Target target, bool automap = true, const std::string &entryPointName = "",
const std::string &baseDir = "/baseResults/",
const EShMessages additionalOptions = EShMessages::EShMsgDefault)
@@ -478,15 +479,15 @@ public:
EShMessages controls = DeriveOptions(source, semantics, target);
controls = static_cast<EShMessages>(controls | additionalOptions);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, clientTargetVersion, false,
EShTexSampTransKeep, false, automap);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, clientTargetVersion,
targetLanguageVersion, false, EShTexSampTransKeep, false, automap);
// Generate the hybrid output in the way of glslangValidator.
std::ostringstream stream;
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname);
}
}
void loadFileCompileFlattenUniformsAndCheck(const std::string& testDir,
const std::string& testName,
@@ -505,7 +506,7 @@ public:
const EShMessages controls = DeriveOptions(source, semantics, target);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls,
glslang::EShTargetVulkan_1_0, true);
glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, true);
// Generate the hybrid output in the way of glslangValidator.
std::ostringstream stream;
@@ -675,7 +676,7 @@ public:
const EShMessages controls = DeriveOptions(source, semantics, target);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls,
glslang::EShTargetVulkan_1_0, false,
glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, false,
EShTexSampTransUpgradeTextureRemoveSampler);
// Generate the hybrid output in the way of glslangValidator.