Commit ae3be767 by John Kessenich

Testing: Add infrastructure for testing targets of Vulkan 1.0 versus 1.1.

Note the tests do not yet generate the correct code regarding what extensions they declare.
parent 66bdc47f
......@@ -2297,7 +2297,7 @@ local_size = (32, 16, 1)
0:? 'data' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of uint u, temp 4-component vector of int i, temp 4-component vector of float f, temp 4-component vector of double d} @data})
0:? 'dti' ( in 3-component vector of uint GlobalInvocationID)
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 359
......
......@@ -2321,7 +2321,7 @@ local_size = (32, 16, 1)
0:? 'data' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of uint u, temp 4-component vector of int i, temp 4-component vector of float f, temp 4-component vector of double d} @data})
0:? 'dti' ( in 3-component vector of uint GlobalInvocationID)
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 369
......
......@@ -8025,7 +8025,7 @@ local_size = (32, 16, 1)
0:? 'data' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of uint u, temp 4-component vector of int i, temp 4-component vector of float f, temp 4-component vector of double d} @data})
0:? 'dti' ( in 3-component vector of uint GlobalInvocationID)
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 1120
......
......@@ -59,7 +59,7 @@ local_size = (32, 16, 1)
0:? Linker Objects
0:? 'data' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of uint @data})
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 28
......
......@@ -71,7 +71,7 @@ gl_FragCoord origin is upper left
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 30
......
......@@ -6185,7 +6185,7 @@ local_size = (32, 16, 1)
0:? 'data' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of uint u, temp 4-component vector of int i, temp 4-component vector of float f, temp 4-component vector of double d} @data})
0:? 'dti' ( in 3-component vector of uint GlobalInvocationID)
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 901
......
......@@ -203,7 +203,7 @@ local_size = (32, 16, 1)
0:? 'data' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of uint64_t @data})
0:? 'dti' ( in 3-component vector of uint GlobalInvocationID)
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 75
......
spv.deviceGroup.frag
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 17
......
spv.drawParams.vert
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 29
......
spv.float32.frag
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 530
......@@ -11,8 +11,6 @@ spv.float32.frag
Capability Int8
Capability DerivativeControl
Capability InterpolationFunction
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_AMD_gpu_shader_int16"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 468
......
spv.float64.frag
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 521
......@@ -11,8 +11,6 @@ spv.float64.frag
Capability Int8
Capability DerivativeControl
Capability InterpolationFunction
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_AMD_gpu_shader_int16"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 458
......
spv.int32.frag
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 495
......@@ -9,8 +9,6 @@ spv.int32.frag
Capability Int64
Capability Int16
Capability Int8
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_AMD_gpu_shader_int16"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main"
......
spv.int8.frag
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 531
......@@ -9,8 +9,6 @@ spv.int8.frag
Capability Int64
Capability Int16
Capability Int8
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_AMD_gpu_shader_int16"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main"
......
spv.multiView.frag
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 17
......
spv.subgroup.frag
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 17
......
spv.subgroup.geom
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 26
......
spv.subgroup.tesc
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 26
......
spv.subgroup.tese
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 26
......
spv.subgroup.vert
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 26
......
spv.subgroupArithmetic.comp
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 2085
......
spv.subgroupBallot.comp
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 417
......
spv.subgroupBasic.comp
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 40
......
spv.subgroupClustered.comp
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 737
......
spv.subgroupQuad.comp
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 616
......
spv.subgroupShuffle.comp
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 379
......
spv.subgroupShuffleRelative.comp
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 379
......
spv.subgroupVote.comp
// Module Version 10000
// Module Version 10300
// Generated by (magic number): 80004
// Id's are bound by 216
......
#version 450
#extension GL_KHX_shader_explicit_arithmetic_types: enable
#extension GL_KHX_shader_explicit_arithmetic_types_int8: require
#extension GL_KHX_shader_explicit_arithmetic_types_int16: require
#extension GL_KHX_shader_explicit_arithmetic_types_int32: require
#extension GL_KHX_shader_explicit_arithmetic_types_int64: require
#extension GL_KHX_shader_explicit_arithmetic_types_float16: require
#extension GL_KHX_shader_explicit_arithmetic_types_float32: require
#extension GL_KHX_shader_explicit_arithmetic_types_float64: require
layout(binding = 0) uniform Uniforms
{
uint index;
};
layout(std140, binding = 1) uniform Block
{
int16_t i16;
i16vec2 i16v2;
i16vec3 i16v3;
i16vec4 i16v4;
uint16_t u16;
u16vec2 u16v2;
u16vec3 u16v3;
u16vec4 u16v4;
} block;
void main()
{
}
void literal()
{
const int16_t i16Const[3] =
{
int16_t(-0x1111), // Hex
int16_t(-1), // Dec
int16_t(040000), // Oct
};
int16_t i16 = i16Const[index];
const uint16_t u16Const[] =
{
uint16_t(0xFFFF), // Hex
uint16_t(65535), // Dec
uint16_t(077777), // Oct
};
uint16_t u16 = u16Const[index];
}
void typeCast16()
{
i8vec2 i8v;
u8vec2 u8v;
i16vec2 i16v;
u16vec2 u16v;
i32vec2 i32v;
u32vec2 u32v;
i64vec2 i64v;
u64vec2 u64v;
f16vec2 f16v;
f32vec2 f32v;
f64vec2 f64v;
bvec2 bv;
i32v = i16v; // int16_t -> int32_t
i32v = u16v; // uint16_t -> int32_t
u16v = i16v; // int16_t -> uint16_t
u32v = i16v; // int16_t -> uint32_t
i64v = i16v; // int16_t -> int64_t
u64v = i16v; // int16_t -> uint64_t
u32v = u16v; // uint16_t -> uint32_t
i64v = u16v; // uint16_t -> int64_t
u64v = u16v; // uint16_t -> uint64_t
f16v = i16v; // int16_t -> float16_t
f32v = i16v; // int16_t -> float32_t
f64v = i16v; // int16_t -> float64_t
f16v = u16v; // uint16_t -> float16_t
f32v = u16v; // uint16_t -> float32_t
f64v = u16v; // uint16_t -> float64_t
i32v = i32vec2(i16v); // int16_t -> int32_t
i32v = i32vec2(u16v); // uint16_t -> int32_t
u16v = u16vec2(i16v); // int16_t -> uint16_t
u32v = u32vec2(i16v); // int16_t -> uint32_t
i64v = i64vec2(i16v); // int16_t -> int64_t
u64v = i64vec2(i16v); // int16_t -> uint64_t
u32v = u32vec2(u16v); // uint16_t -> uint32_t
i64v = i64vec2(u16v); // uint16_t -> int64_t
u64v = i64vec2(u16v); // uint16_t -> uint64_t
f16v = f16vec2(i16v); // int16_t -> float16_t
f32v = f32vec2(i16v); // int16_t -> float32_t
f64v = f64vec2(i16v); // int16_t -> float64_t
f16v = f16vec2(u16v); // uint16_t -> float16_t
f32v = f32vec2(u16v); // uint16_t -> float32_t
f64v = f64vec2(u16v); // uint16_t -> float64_t
i8v = i8vec2(i16v); // int16_t -> int8_t
i8v = i8vec2(u16v); // uint16_t -> int8_t
u8v = u8vec2(i16v); // int16_t -> uint8_t
u8v = u8vec2(u16v); // uint16_t -> uint8_t
i16v = u8vec2(u16v); // uint16_t -> int16_t
i16v = i16vec2(bv); // bool -> int16
u16v = u16vec2(bv); // bool -> uint16
bv = bvec2(i16v); // int16 -> bool
bv = bvec2(u16v); // uint16 -> bool
}
void operators()
{
u16vec3 u16v;
int16_t i16;
uvec3 uv;
int32_t i;
int64_t i64;
bool b;
// Unary
u16v++;
i16--;
++i16;
--u16v;
u16v = ~u16v;
i16 = +i16;
u16v = -u16v;
// Arithmetic
i16 += i16;
u16v -= u16v;
i *= i16;
uv /= u16v;
uv %= i16;
uv = u16v + uv;
i64 = i16 - i64;
uv = u16v * uv;
i64 = i16 * i64;
i = i16 % i;
// Shift
u16v <<= i16;
i16 >>= u16v.y;
i16 = i16 << u16v.z;
uv = u16v << i;
// Relational
b = (u16v.x != i16);
b = (i16 == u16v.x);
b = (u16v.x > uv.y);
b = (i16 < i);
b = (u16v.y >= uv.x);
b = (i16 <= i);
// Bitwise
uv |= i16;
i = i16 | i;
i64 &= i16;
uv = u16v & uv;
uv ^= i16;
u16v = u16v ^ i16;
}
void builtinFuncs()
{
i16vec2 i16v;
i16vec4 i16v4;
u16vec3 u16v;
u16vec2 u16v2;
u16vec4 u16v4;
bvec3 bv;
int16_t i16;
uint16_t u16;
int32_t i32;
uint32_t u32;
int64_t i64;
uint64_t u64;
// abs()
i16v = abs(i16v);
// sign()
i16 = sign(i16);
// min()
i16v = min(i16v, i16);
i16v = min(i16v, i16vec2(-1));
u16v = min(u16v, u16);
u16v = min(u16v, u16vec3(0));
// max()
i16v = max(i16v, i16);
i16v = max(i16v, i16vec2(-1));
u16v = max(u16v, u16);
u16v = max(u16v, u16vec3(0));
// clamp()
i16v = clamp(i16v, -i16, i16);
i16v = clamp(i16v, -i16v, i16v);
u16v = clamp(u16v, -u16, u16);
u16v = clamp(u16v, -u16v, u16v);
// mix()
i16 = mix(i16v.x, i16v.y, true);
i16v = mix(i16vec2(i16), i16vec2(-i16), bvec2(false));
u16 = mix(u16v.x, u16v.y, true);
u16v = mix(u16vec3(u16), u16vec3(-u16), bvec3(false));
//pack
i32 = pack32(i16v);
i64 = pack64(i16v4);
u32 = pack32(u16v2);
u64 = pack64(u16v4);
i16v = unpack16(i32);
i16v4 = unpack16(i64);
u16v2 = unpack16(u32);
u16v4 = unpack16(u64);
// lessThan()
bv = lessThan(u16v, u16vec3(u16));
bv.xy = lessThan(i16v, i16vec2(i16));
// lessThanEqual()
bv = lessThanEqual(u16v, u16vec3(u16));
bv.xy = lessThanEqual(i16v, i16vec2(i16));
// greaterThan()
bv = greaterThan(u16v, u16vec3(u16));
bv.xy = greaterThan(i16v, i16vec2(i16));
// greaterThanEqual()
bv = greaterThanEqual(u16v, u16vec3(u16));
bv.xy = greaterThanEqual(i16v, i16vec2(i16));
// equal()
bv = equal(u16v, u16vec3(u16));
bv.xy = equal(i16v, i16vec2(i16));
// notEqual()
bv = notEqual(u16v, u16vec3(u16));
bv.xy = notEqual(i16v, i16vec2(i16));
}
// Type conversion for specialization constant
layout(constant_id = 100) const int16_t si16 = int16_t(-10);
layout(constant_id = 101) const uint16_t su16 = uint16_t(20);
......@@ -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, 100,
Target::AST);
}
......
......@@ -58,6 +58,7 @@ std::string FileNameAsCustomTestSuffix(
}
using HlslCompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslVulkan110CompileTest = 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, 100,
Target::BothASTAndSpv, true, GetParam().entryPoint);
}
TEST_P(HlslVulkan110CompileTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, 110,
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, 100,
Target::Spv, true, GetParam().entryPoint,
"/baseLegalResults/", false);
}
......@@ -368,6 +376,17 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.type.identifier.frag", "main"},
{"hlsl.typeGraphCopy.vert", "main"},
{"hlsl.typedef.frag", "PixelShaderFunction"},
{"hlsl.whileLoop.frag", "PixelShaderFunction"},
{"hlsl.void.frag", "PixelShaderFunction"}
}),
FileNameAsCustomTestSuffix
);
// clang-format on
// clang-format off
INSTANTIATE_TEST_CASE_P(
ToSpirv, HlslVulkan110CompileTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.wavebroadcast.comp", "CSMain"},
{"hlsl.waveprefix.comp", "CSMain"},
{"hlsl.wavequad.comp", "CSMain"},
......@@ -375,8 +394,6 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.wavequery.frag", "PixelShaderFunction"},
{"hlsl.wavereduction.comp", "CSMain"},
{"hlsl.wavevote.comp", "CSMain"},
{"hlsl.whileLoop.frag", "PixelShaderFunction"},
{"hlsl.void.frag", "PixelShaderFunction"}
}),
FileNameAsCustomTestSuffix
);
......
......@@ -63,6 +63,7 @@ std::string FileNameAsCustomTestSuffixIoMap(
}
using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkan110ToSpirvTest = 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, 100,
Target::Spv);
}
TEST_P(CompileVulkan110ToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, 110,
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, 100,
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, 100,
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, 100,
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, 100,
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, 100,
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, 100,
Target::Spv);
}
#endif
......@@ -242,9 +250,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",
......@@ -272,7 +278,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",
......@@ -331,28 +336,40 @@ INSTANTIATE_TEST_CASE_P(
"spv.storageBuffer.vert",
"spv.precise.tese",
"spv.precise.tesc",
"spv.xfb.vert",
"spv.xfb2.vert",
"spv.xfb3.vert",
})),
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkan110ToSpirvTest,
::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.subgroupVote.comp",
"spv.subgroupBallot.comp",
"spv.subgroupShuffle.comp",
"spv.subgroupShuffleRelative.comp",
"spv.subgroupArithmetic.comp",
"spv.subgroupClustered.comp",
"spv.subgroupClusteredNeg.comp",
"spv.subgroupShuffle.comp",
"spv.subgroupShuffleRelative.comp",
"spv.subgroupQuad.comp",
"spv.int8.frag",
"spv.int16.frag",
"spv.int32.frag",
"spv.float32.frag",
"spv.float64.frag",
"spv.xfb.vert",
"spv.xfb2.vert",
"spv.xfb3.vert",
"spv.subgroupVote.comp",
})),
FileNameAsCustomTestSuffix
);
......
......@@ -70,7 +70,7 @@ enum class Source {
// Enum for shader compilation semantics.
enum class Semantics {
OpenGL,
Vulkan,
Vulkan
};
// Enum for compilation target.
......@@ -196,15 +196,15 @@ public:
// the result and returns disassembly text.
GlslangResult compileAndLink(
const std::string shaderName, const std::string& code,
const std::string& entryPointName, EShMessages controls,
const std::string& entryPointName, EShMessages controls, int 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 +212,22 @@ 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 == 110 ? 0x00010300 : 0x00010000);
} else {
shader.setEnvInput((controls & EShMsgReadHlsl) ? glslang::EShSourceHlsl
: glslang::EShSourceGlsl,
stage, glslang::EShClientOpenGL, 100);
shader.setEnvClient(glslang::EShClientOpenGL, clientTargetVersion);
shader.setEnvTarget(glslang::EshTargetSpv, 0x00010000);
}
}
bool success = compile(&shader, code, entryPointName, controls);
glslang::TProgram program;
......@@ -224,7 +240,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 +271,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 +295,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 +319,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 +335,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 +404,7 @@ public:
const std::string& testName,
Source source,
Semantics semantics,
int clientTargetVersion,
Target target,
bool automap = true,
const std::string& entryPointName="",
......@@ -403,8 +420,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 +447,7 @@ 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, 100, true);
// Generate the hybrid output in the way of glslangValidator.
std::ostringstream stream;
......@@ -599,7 +616,7 @@ 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, 100, 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