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

@ -0,0 +1,107 @@
spv.1.4.OpEntryPoint.frag
Validation failed
// Module Version 10400
// Generated by (magic number): 80007
// Id's are bound by 64
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 11 14 17 25 33 41
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "functionv"
Name 11 "inv"
Name 14 "globalv"
Name 17 "outv"
Name 23 "ubt"
MemberName 23(ubt) 0 "v"
Name 25 "uniformv"
Name 31 "pushB"
MemberName 31(pushB) 0 "a"
Name 33 "pushv"
Name 39 "bbt"
MemberName 39(bbt) 0 "f"
Name 41 "bufferv"
Decorate 11(inv) Location 0
Decorate 17(outv) Location 0
MemberDecorate 23(ubt) 0 Offset 0
Decorate 23(ubt) Block
Decorate 25(uniformv) DescriptorSet 0
Decorate 25(uniformv) Binding 0
MemberDecorate 31(pushB) 0 Offset 0
Decorate 31(pushB) Block
Decorate 33(pushv) Binding 2
MemberDecorate 39(bbt) 0 Offset 0
Decorate 39(bbt) Block
Decorate 41(bufferv) DescriptorSet 0
Decorate 41(bufferv) Binding 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
10: TypePointer Input 7(fvec4)
11(inv): 10(ptr) Variable Input
13: TypePointer Private 7(fvec4)
14(globalv): 13(ptr) Variable Private
16: TypePointer Output 7(fvec4)
17(outv): 16(ptr) Variable Output
23(ubt): TypeStruct 7(fvec4)
24: TypePointer Uniform 23(ubt)
25(uniformv): 24(ptr) Variable Uniform
26: TypeInt 32 1
27: 26(int) Constant 0
28: TypePointer Uniform 7(fvec4)
31(pushB): TypeStruct 26(int)
32: TypePointer PushConstant 31(pushB)
33(pushv): 32(ptr) Variable PushConstant
34: TypePointer PushConstant 26(int)
39(bbt): TypeStruct 6(float)
40: TypePointer StorageBuffer 39(bbt)
41(bufferv): 40(ptr) Variable StorageBuffer
42: TypePointer StorageBuffer 6(float)
4(main): 2 Function None 3
5: Label
9(functionv): 8(ptr) Variable Function
12: 7(fvec4) Load 11(inv)
Store 9(functionv) 12
15: 7(fvec4) Load 11(inv)
Store 14(globalv) 15
18: 7(fvec4) Load 9(functionv)
19: 7(fvec4) Load 11(inv)
20: 7(fvec4) FAdd 18 19
21: 7(fvec4) Load 14(globalv)
22: 7(fvec4) FAdd 20 21
29: 28(ptr) AccessChain 25(uniformv) 27
30: 7(fvec4) Load 29
35: 34(ptr) AccessChain 33(pushv) 27
36: 26(int) Load 35
37: 6(float) ConvertSToF 36
38: 7(fvec4) VectorTimesScalar 30 37
43: 42(ptr) AccessChain 41(bufferv) 27
44: 6(float) Load 43
45: 7(fvec4) VectorTimesScalar 38 44
46: 7(fvec4) FAdd 22 45
Store 17(outv) 46
47: 7(fvec4) Load 9(functionv)
48: 7(fvec4) Load 11(inv)
49: 7(fvec4) FAdd 47 48
50: 7(fvec4) Load 14(globalv)
51: 7(fvec4) FAdd 49 50
52: 28(ptr) AccessChain 25(uniformv) 27
53: 7(fvec4) Load 52
54: 34(ptr) AccessChain 33(pushv) 27
55: 26(int) Load 54
56: 6(float) ConvertSToF 55
57: 7(fvec4) VectorTimesScalar 53 56
58: 42(ptr) AccessChain 41(bufferv) 27
59: 6(float) Load 58
60: 7(fvec4) VectorTimesScalar 57 59
61: 7(fvec4) FAdd 51 60
62: 7(fvec4) Load 17(outv)
63: 7(fvec4) FAdd 62 61
Store 17(outv) 63
Return
FunctionEnd

View File

@ -0,0 +1,27 @@
#version 450
layout(location = 0) in vec4 inv;
layout(location = 0) out vec4 outv;
vec4 globalv;
layout(binding = 0) uniform ubt {
vec4 v;
} uniformv;
layout(binding = 1) buffer bbt {
float f;
} bufferv;
layout(binding = 2, push_constant) uniform pushB {
int a;
} pushv;
void main()
{
vec4 functionv;
functionv = inv;
globalv = inv;
outv = functionv + inv + globalv + uniformv.v * pushv.a * bufferv.f;
outv += functionv + inv + globalv + uniformv.v * pushv.a * bufferv.f;
}

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.