Externals: Update glslang.

This updates glslang to commit 4fc7a33910fb8e40b970d160e1b38ab3f67fe0f3
which is the current version listed in the known_good.json file for the
version 1.2.131.2 of the Vulkan-ValidationLayers repo.
This commit is contained in:
orbea
2020-03-02 07:42:00 -08:00
parent b3c705fa96
commit 690dee3533
126 changed files with 29560 additions and 13594 deletions

57
Externals/glslang/gtests/AST.FromFile.cpp vendored Executable file → Normal file
View File

@ -41,26 +41,22 @@ namespace {
using CompileToAstTest = GlslangTest<::testing::TestWithParam<std::string>>;
#ifdef NV_EXTENSIONS
using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
#endif
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);
}
#ifdef NV_EXTENSIONS
// Compiling GLSL to SPIR-V under OpenGL semantics (NV extensions enabled).
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
// clang-format off
INSTANTIATE_TEST_CASE_P(
@ -93,9 +89,13 @@ INSTANTIATE_TEST_CASE_P(
"cppSimple.vert",
"cppIndent.vert",
"cppIntMinOverNegativeOne.frag",
"cppMerge.frag",
"cppNest.vert",
"cppBad.vert",
"cppBad2.vert",
"cppBad3.vert",
"cppBad4.vert",
"cppBad5.vert",
"cppComplexExpr.vert",
"cppDeepNest.frag",
"cppPassMacroName.frag",
@ -113,6 +113,7 @@ INSTANTIATE_TEST_CASE_P(
"300operations.frag",
"300block.frag",
"300samplerExternal.frag",
"300samplerExternalYUV.frag",
"310.comp",
"310.vert",
"310.geom",
@ -120,6 +121,7 @@ INSTANTIATE_TEST_CASE_P(
"310.tesc",
"310.tese",
"310implicitSizeArrayError.vert",
"310.inheritMemory.frag",
"310AofA.vert",
"310runtimeArray.vert",
"320.comp",
@ -231,11 +233,51 @@ INSTANTIATE_TEST_CASE_P(
"precise_struct_block.vert",
"maxClipDistances.vert",
"findFunction.frag",
"constantUnaryConversion.comp",
"glsl.450.subgroup.frag",
"glsl.450.subgroup.geom",
"glsl.450.subgroup.tesc",
"glsl.450.subgroup.tese",
"glsl.450.subgroup.vert",
"glsl.450.subgroupArithmetic.comp",
"glsl.450.subgroupBasic.comp",
"glsl.450.subgroupBallot.comp",
"glsl.450.subgroupBallotNeg.comp",
"glsl.450.subgroupClustered.comp",
"glsl.450.subgroupClusteredNeg.comp",
"glsl.450.subgroupPartitioned.comp",
"glsl.450.subgroupShuffle.comp",
"glsl.450.subgroupShuffleRelative.comp",
"glsl.450.subgroupQuad.comp",
"glsl.450.subgroupVote.comp",
"glsl.460.subgroup.mesh",
"glsl.460.subgroup.task",
"glsl.460.subgroup.rahit",
"glsl.460.subgroup.rcall",
"glsl.460.subgroup.rchit",
"glsl.460.subgroup.rgen",
"glsl.460.subgroup.rint",
"glsl.460.subgroup.rmiss",
"glsl.es320.subgroup.frag",
"glsl.es320.subgroup.geom",
"glsl.es320.subgroup.tesc",
"glsl.es320.subgroup.tese",
"glsl.es320.subgroup.vert",
"glsl.es320.subgroupArithmetic.comp",
"glsl.es320.subgroupBasic.comp",
"glsl.es320.subgroupBallot.comp",
"glsl.es320.subgroupBallotNeg.comp",
"glsl.es320.subgroupClustered.comp",
"glsl.es320.subgroupClusteredNeg.comp",
"glsl.es320.subgroupPartitioned.comp",
"glsl.es320.subgroupShuffle.comp",
"glsl.es320.subgroupShuffleRelative.comp",
"glsl.es320.subgroupQuad.comp",
"glsl.es320.subgroupVote.comp",
})),
FileNameAsCustomTestSuffix
);
#ifdef NV_EXTENSIONS
INSTANTIATE_TEST_CASE_P(
Glsl, CompileToAstTestNV,
::testing::ValuesIn(std::vector<std::string>({
@ -243,7 +285,6 @@ INSTANTIATE_TEST_CASE_P(
})),
FileNameAsCustomTestSuffix
);
#endif
// clang-format on
} // anonymous namespace

View File

@ -20,17 +20,22 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.Vk.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp)
# -- Remapper tests
${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp)
if(ENABLE_SPVREMAPPER)
set(TEST_SOURCES ${TEST_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp)
endif()
glslang_pch(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp)
add_executable(glslangtests ${TEST_SOURCES})
set_property(TARGET glslangtests PROPERTY FOLDER tests)
glslang_set_link_args(glslangtests)
if(ENABLE_GLSLANG_INSTALL)
install(TARGETS glslangtests
install(TARGETS glslangtests EXPORT glslangtestsTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(EXPORT glslangtestsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
endif(ENABLE_GLSLANG_INSTALL)
set(GLSLANG_TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
@ -46,8 +51,13 @@ if(BUILD_TESTING)
${gtest_SOURCE_DIR}/include)
set(LIBRARIES
SPVRemapper glslang OSDependent OGLCompiler glslang
glslang OSDependent OGLCompiler glslang
SPIRV glslang-default-resource-limits)
if(ENABLE_SPVREMAPPER)
set(LIBRARIES ${LIBRARIES} SPVRemapper)
endif()
if(ENABLE_HLSL)
set(LIBRARIES ${LIBRARIES} HLSL)
endif(ENABLE_HLSL)

View File

@ -51,6 +51,7 @@ TEST_P(ConfigTest, FromFile)
{
TestCaseSpec testCase = GetParam();
GlslangResult result;
result.validationResult = true;
// Get the contents for input shader and limit configurations.
std::string shaderContents, configContents;
@ -99,7 +100,7 @@ INSTANTIATE_TEST_CASE_P(
::testing::ValuesIn(std::vector<TestCaseSpec>({
{"specExamples.vert", "baseResults/test.conf", "specExamplesConf.vert.out", (EShMessages)(EShMsgAST | EShMsgCascadingErrors)},
{"100Limits.vert", "100.conf", "100LimitsConf.vert.out", EShMsgCascadingErrors},
})),
}))
);
// clang-format on

View File

@ -127,7 +127,7 @@ INSTANTIATE_TEST_CASE_P(
{float(ldexp(1.0, -127) / 2.0 + (ldexp(1.0, -127) / 4.0f)),
"0x1.8p-128"},
})),);
})));
INSTANTIATE_TEST_CASE_P(
Float32NanTests, HexFloatTest,
@ -145,7 +145,7 @@ INSTANTIATE_TEST_CASE_P(
{uint32_t(0x7f800c00), "0x1.0018p+128"}, // +nan
{uint32_t(0x7F80F000), "0x1.01ep+128"}, // +nan
{uint32_t(0x7FFFFFFF), "0x1.fffffep+128"}, // +nan
})),);
})));
INSTANTIATE_TEST_CASE_P(
Float64Tests, HexDoubleTest,
@ -218,7 +218,7 @@ INSTANTIATE_TEST_CASE_P(
{ldexp(1.0, -1023) / 2.0 + (ldexp(1.0, -1023) / 4.0),
"0x1.8p-1024"},
})),);
})));
INSTANTIATE_TEST_CASE_P(
Float64NanTests, HexDoubleTest,
@ -237,7 +237,7 @@ INSTANTIATE_TEST_CASE_P(
{uint64_t(0x7FF0000000000001LL), "0x1.0000000000001p+1024"}, // -nan
{uint64_t(0x7FF0000300000000LL), "0x1.00003p+1024"}, // -nan
{uint64_t(0x7FFFFFFFFFFFFFFFLL), "0x1.fffffffffffffp+1024"}, // -nan
})),);
})));
TEST(HexFloatStreamTest, OperatorLeftShiftPreservesFloatAndFill) {
std::stringstream s;
@ -282,7 +282,7 @@ INSTANTIATE_TEST_CASE_P(
{"0xFFp+0", 255.f},
{"0x0.8p+0", 0.5f},
{"0x0.4p+0", 0.25f},
})),);
})));
INSTANTIATE_TEST_CASE_P(
Float32DecodeInfTests, DecodeHexFloatTest,
@ -292,7 +292,7 @@ INSTANTIATE_TEST_CASE_P(
{"0x32p+127", uint32_t(0x7F800000)}, // inf
{"0x32p+500", uint32_t(0x7F800000)}, // inf
{"-0x32p+127", uint32_t(0xFF800000)}, // -inf
})),);
})));
INSTANTIATE_TEST_CASE_P(
Float64DecodeTests, DecodeHexDoubleTest,
@ -315,7 +315,7 @@ INSTANTIATE_TEST_CASE_P(
{"0xFFp+0", 255.},
{"0x0.8p+0", 0.5},
{"0x0.4p+0", 0.25},
})),);
})));
INSTANTIATE_TEST_CASE_P(
Float64DecodeInfTests, DecodeHexDoubleTest,
@ -326,7 +326,7 @@ INSTANTIATE_TEST_CASE_P(
{"0x32p+1023", uint64_t(0x7FF0000000000000)}, // inf
{"0x32p+5000", uint64_t(0x7FF0000000000000)}, // inf
{"-0x32p+1023", uint64_t(0xFFF0000000000000)}, // -inf
})),);
})));
TEST(FloatProxy, ValidConversion) {
EXPECT_THAT(FloatProxy<float>(1.f).getAsFloat(), Eq(1.0f));
@ -495,7 +495,7 @@ INSTANTIATE_TEST_CASE_P(
{std::numeric_limits<float>::infinity(), "0x1p+128"},
{-std::numeric_limits<float>::infinity(), "-0x1p+128"},
})),);
})));
INSTANTIATE_TEST_CASE_P(
Float64Tests, FloatProxyDoubleTest,
@ -532,7 +532,7 @@ INSTANTIATE_TEST_CASE_P(
{std::numeric_limits<double>::infinity(), "0x1p+1024"},
{-std::numeric_limits<double>::infinity(), "-0x1p+1024"},
})),);
})));
// double is used so that unbiased_exponent can be used with the output
// of ldexp directly.
@ -793,7 +793,7 @@ INSTANTIATE_TEST_CASE_P(F32ToF16, HexFloatRoundTest,
{static_cast<float>(ldexp(float_fractions({0, 1, 11, 13}), -129)), std::make_pair(half_bits_set({0, 9}), false), spvutils::kRoundToPositiveInfinity},
{static_cast<float>(ldexp(float_fractions({0, 1, 11, 13}), -131)), std::make_pair(half_bits_set({0}), false), spvutils::kRoundToNegativeInfinity},
{static_cast<float>(ldexp(float_fractions({0, 1, 11, 13}), -130)), std::make_pair(half_bits_set({0, 9}), false), spvutils::kRoundToNearestEven},
})),);
})));
// clang-format on
struct UpCastSignificandCase {
@ -837,7 +837,7 @@ INSTANTIATE_TEST_CASE_P(F16toF32, HexFloatRoundUpSignificandTest,
{0x0F00, 0x600000},
{0x0F01, 0x602000},
{0x0FFF, 0x7FE000},
})),);
})));
struct DownCastTest {
float source_float;
@ -914,7 +914,7 @@ INSTANTIATE_TEST_CASE_P(F32ToF16, HexFloatFP32To16Tests,
{-std::numeric_limits<float>::infinity(), negative_infinity, {spvutils::kRoundToZero, spvutils::kRoundToPositiveInfinity, spvutils::kRoundToNegativeInfinity, spvutils::kRoundToNearestEven}},
// Nans are below because we cannot test for equality.
})),);
})));
struct UpCastCase{
uint16_t source_half;
@ -965,7 +965,7 @@ INSTANTIATE_TEST_CASE_P(F16ToF32, HexFloatFP16To32Tests,
// inf
{0x7C00, std::numeric_limits<float>::infinity()},
{0xFC00, -std::numeric_limits<float>::infinity()},
})),);
})));
TEST(HexFloatOperationTests, NanTests) {
using HF = spvutils::HexFloat<spvutils::FloatProxy<float>>;
@ -1071,7 +1071,7 @@ INSTANTIATE_TEST_CASE_P(
// We can't have -1e40 and negate_value == true since
// that represents an original case of "--1e40" which
// is invalid.
}),);
}));
using ParseNormalFloat16Test =
::testing::TestWithParam<FloatParseCase<Float16>>;
@ -1114,7 +1114,7 @@ INSTANTIATE_TEST_CASE_P(
BadFloatParseCase<Float16>("-2.0", true, uint16_t{0}),
BadFloatParseCase<Float16>("+0.0", true, uint16_t{0}),
BadFloatParseCase<Float16>("+2.0", true, uint16_t{0}),
}),);
}));
// A test case for detecting infinities.
template <typename T>
@ -1149,7 +1149,7 @@ INSTANTIATE_TEST_CASE_P(
{"-1e40", false, -FLT_MAX},
{"1e400", false, FLT_MAX},
{"-1e400", false, -FLT_MAX},
})),);
})));
using FloatProxyParseOverflowDoubleTest =
::testing::TestWithParam<OverflowParseCase<double>>;
@ -1176,7 +1176,7 @@ INSTANTIATE_TEST_CASE_P(
{"-1e40", true, -1e40},
{"1e400", false, DBL_MAX},
{"-1e400", false, -DBL_MAX},
})),);
})));
using FloatProxyParseOverflowFloat16Test =
::testing::TestWithParam<OverflowParseCase<uint16_t>>;
@ -1207,7 +1207,7 @@ INSTANTIATE_TEST_CASE_P(
{"-1e38", false, uint16_t{0xfbff}},
{"-1e40", false, uint16_t{0xfbff}},
{"-1e400", false, uint16_t{0xfbff}},
})),);
})));
TEST(FloatProxy, Max) {
EXPECT_THAT(FloatProxy<Float16>::max().getAsFloat().get_value(),

77
Externals/glslang/gtests/Hlsl.FromFile.cpp vendored Normal file → Executable file
View File

@ -61,20 +61,23 @@ using HlslCompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointP
using HlslVulkan1_1CompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslCompileAndFlattenTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslLegalizeTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslDebugTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslDX9CompatibleTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslLegalDebugTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
// Compiling HLSL to pre-legalized SPIR-V under Vulkan semantics. Expected
// to successfully generate both AST and SPIR-V.
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);
}
@ -90,11 +93,41 @@ 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);
}
// Compiling HLSL to pre-legalized SPIR-V. Expected to successfully generate
// SPIR-V with debug instructions, particularly line info.
TEST_P(HlslDebugTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, true, GetParam().entryPoint,
"/baseResults/", false, true);
}
TEST_P(HlslDX9CompatibleTest, FromFile)
{
loadFileCompileAndCheckWithOptions(GlobalTestSettings.testRoot, GetParam().fileName, Source::HLSL,
Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::BothASTAndSpv, true,
GetParam().entryPoint, "/baseResults/",
EShMessages::EShMsgHlslDX9Compatible);
}
// Compiling HLSL to legalized SPIR-V with debug instructions. Expected to
// successfully generate SPIR-V with debug instructions preserved through
// legalization, particularly line info.
TEST_P(HlslLegalDebugTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, true, GetParam().entryPoint,
"/baseResults/", true, true);
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
ToSpirv, HlslCompileTest,
@ -153,6 +186,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.depthLess.frag", "PixelShaderFunction"},
{"hlsl.discard.frag", "PixelShaderFunction"},
{"hlsl.doLoop.frag", "PixelShaderFunction"},
{"hlsl.earlydepthstencil.frag", "main"},
{"hlsl.emptystructreturn.frag", "main"},
{"hlsl.emptystructreturn.vert", "main"},
{"hlsl.emptystruct.init.vert", "main"},
@ -196,6 +230,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.hull.void.tesc", "main"},
{"hlsl.hull.ctrlpt-1.tesc", "main"},
{"hlsl.hull.ctrlpt-2.tesc", "main"},
{"hlsl.format.rwtexture.frag", "main"},
{"hlsl.groupid.comp", "main"},
{"hlsl.identifier.sample.frag", "main"},
{"hlsl.if.frag", "PixelShaderFunction"},
@ -317,7 +352,9 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.shapeConvRet.frag", "main"},
{"hlsl.self_cast.frag", "main"},
{"hlsl.snorm.uav.comp", "main"},
{"hlsl.specConstant.frag", "main"},
{"hlsl.staticMemberFunction.frag", "main"},
{"hlsl.staticFuncInit.frag", "main"},
{"hlsl.store.rwbyteaddressbuffer.type.comp", "main"},
{"hlsl.stringtoken.frag", "main"},
{"hlsl.string.frag", "main"},
@ -381,7 +418,8 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.typeGraphCopy.vert", "main"},
{"hlsl.typedef.frag", "PixelShaderFunction"},
{"hlsl.whileLoop.frag", "PixelShaderFunction"},
{"hlsl.void.frag", "PixelShaderFunction"}
{"hlsl.void.frag", "PixelShaderFunction"},
{"hlsl.type.type.conversion.all.frag", "main"}
}),
FileNameAsCustomTestSuffix
);
@ -398,6 +436,8 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.wavequery.frag", "PixelShaderFunction"},
{"hlsl.wavereduction.comp", "CSMain"},
{"hlsl.wavevote.comp", "CSMain"},
{ "hlsl.type.type.conversion.valid.frag", "main" },
{"hlsl.int.dot.frag", "main"}
}),
FileNameAsCustomTestSuffix
);
@ -433,5 +473,34 @@ INSTANTIATE_TEST_CASE_P(
// clang-format on
#endif
// clang-format off
INSTANTIATE_TEST_CASE_P(
ToSpirv, HlslDebugTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.pp.line2.frag", "MainPs"}
}),
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
ToSpirv, HlslDX9CompatibleTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.sample.dx9.frag", "main"},
{"hlsl.sample.dx9.vert", "main"},
}),
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
ToSpirv, HlslLegalDebugTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.pp.line4.frag", "MainPs"}
}),
FileNameAsCustomTestSuffix
);
// clang-format on
} // anonymous namespace
} // namespace glslangtest

View File

@ -77,16 +77,16 @@ TEST_P(LinkTestVulkan, FromFile)
if (success && (controls & EShMsgSpvRules)) {
spv::SpvBuildLogger logger;
std::vector<uint32_t> spirv_binary;
glslang::SpvOptions options;
options.disableOptimizer = true;
options().disableOptimizer = true;
glslang::GlslangToSpv(*program.getIntermediate(shaders.front()->getStage()),
spirv_binary, &logger, &options);
spirv_binary, &logger, &options());
std::ostringstream disassembly_stream;
spv::Parameterize();
spv::Disassemble(disassembly_stream, spirv_binary);
result.spirvWarningsErrors = logger.getAllMessages();
result.spirv = disassembly_stream.str();
result.validationResult = !options().validate || logger.getAllMessages().empty();
}
std::ostringstream stream;
@ -98,7 +98,8 @@ TEST_P(LinkTestVulkan, FromFile)
std::string expectedOutput;
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname,
result.spirvWarningsErrors);
}
// clang-format off
@ -106,7 +107,8 @@ INSTANTIATE_TEST_CASE_P(
Glsl, LinkTestVulkan,
::testing::ValuesIn(std::vector<std::vector<std::string>>({
{"link1.vk.frag", "link2.vk.frag"},
})),
{"spv.unit1.frag", "spv.unit2.frag", "spv.unit3.frag"},
}))
);
// clang-format on

View File

@ -50,6 +50,7 @@ TEST_P(LinkTest, FromFile)
const size_t fileCount = fileNames.size();
const EShMessages controls = DeriveOptions(Source::GLSL, Semantics::OpenGL, Target::AST);
GlslangResult result;
result.validationResult = true;
// Compile each input shader file.
std::vector<std::unique_ptr<glslang::TShader>> shaders;
@ -100,7 +101,7 @@ INSTANTIATE_TEST_CASE_P(
{"max_vertices_0.geom"},
{"es-link1.frag", "es-link2.frag"},
{"missingBodies.vert"}
})),
}))
);
// clang-format on

View File

@ -50,6 +50,7 @@ TEST_P(PreprocessingTest, FromFile)
INSTANTIATE_TEST_CASE_P(
Glsl, PreprocessingTest,
::testing::ValuesIn(std::vector<std::string>({
"preprocessor.bad_arg.vert",
"preprocessor.cpp_style_line_directive.vert",
"preprocessor.cpp_style___FILE__.vert",
"preprocessor.edge_cases.vert",

222
Externals/glslang/gtests/Spv.FromFile.cpp vendored Executable file → Normal file
View File

@ -1,5 +1,6 @@
//
// Copyright (C) 2016 Google, Inc.
// Copyright (C) 2019 ARM Limited.
//
// All rights reserved.
//
@ -63,19 +64,18 @@ std::string FileNameAsCustomTestSuffixIoMap(
}
using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkanToSpirvDeadCodeElimTest = 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>>;
using VulkanAstSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
using HlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
using GlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
#ifdef AMD_EXTENSIONS
using CompileVulkanToSpirvTestAMD = GlslangTest<::testing::TestWithParam<std::string>>;
#endif
#ifdef NV_EXTENSIONS
using CompileVulkanToSpirvTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
#endif
using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::testing::TestWithParam<std::string>>;
// Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully
@ -83,14 +83,39 @@ 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);
}
TEST_P(CompileVulkanToSpirvDeadCodeElimTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv);
}
// Compiling GLSL to SPIR-V with debug info under Vulkan semantics. Expected
// to successfully generate SPIR-V.
TEST_P(CompileVulkanToDebugSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan,
glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
Target::Spv, true, "",
"/baseResults/", false, true);
}
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);
}
@ -99,7 +124,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);
}
@ -108,7 +133,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);
}
@ -117,7 +142,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);
}
@ -125,7 +150,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);
}
@ -159,27 +184,23 @@ TEST_P(GlslIoMap, FromFile)
GetParam().flattenUniforms);
}
#ifdef AMD_EXTENSIONS
// Compiling GLSL to SPIR-V under Vulkan semantics (AMD extensions enabled).
// Expected to successfully generate SPIR-V.
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
#ifdef NV_EXTENSIONS
// Compiling GLSL to SPIR-V under Vulkan semantics (NV extensions enabled).
// Expected to successfully generate SPIR-V.
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
TEST_P(CompileUpgradeTextureToSampledTextureAndDropSamplersTest, FromFile)
{
@ -215,6 +236,12 @@ INSTANTIATE_TEST_CASE_P(
"spv.140.frag",
"spv.150.geom",
"spv.150.vert",
"spv.16bitstorage.frag",
"spv.16bitstorage_Error.frag",
"spv.16bitstorage-int.frag",
"spv.16bitstorage_Error-int.frag",
"spv.16bitstorage-uint.frag",
"spv.16bitstorage_Error-uint.frag",
"spv.300BuiltIns.vert",
"spv.300layout.frag",
"spv.300layout.vert",
@ -231,6 +258,13 @@ INSTANTIATE_TEST_CASE_P(
"spv.450.tesc",
"spv.450.geom",
"spv.450.noRedecl.tesc",
"spv.8bitstorage-int.frag",
"spv.8bitstorage_Error-int.frag",
"spv.8bitstorage-uint.frag",
"spv.8bitstorage_Error-uint.frag",
"spv.8bitstorage-ubo.vert",
"spv.8bitstorage-ssbo.vert",
"spv.8bit-16bit-construction.frag",
"spv.accessChain.frag",
"spv.aggOps.frag",
"spv.always-discard.frag",
@ -241,14 +275,41 @@ INSTANTIATE_TEST_CASE_P(
"spv.bool.vert",
"spv.boolInBlock.frag",
"spv.branch-return.vert",
"spv.bufferhandle1.frag",
"spv.bufferhandle10.frag",
"spv.bufferhandle11.frag",
"spv.bufferhandle12.frag",
"spv.bufferhandle13.frag",
"spv.bufferhandle14.frag",
"spv.bufferhandle15.frag",
"spv.bufferhandle16.frag",
"spv.bufferhandle17_Errors.frag",
"spv.bufferhandle18.frag",
"spv.bufferhandle19_Errors.frag",
"spv.bufferhandle2.frag",
"spv.bufferhandle3.frag",
"spv.bufferhandle4.frag",
"spv.bufferhandle5.frag",
"spv.bufferhandle6.frag",
"spv.bufferhandle7.frag",
"spv.bufferhandle8.frag",
"spv.bufferhandle9.frag",
"spv.bufferhandleUvec2.frag",
"spv.bufferhandle_Error.frag",
"spv.builtInXFB.vert",
"spv.conditionalDemote.frag",
"spv.conditionalDiscard.frag",
"spv.constructComposite.comp",
"spv.constStruct.vert",
"spv.constConstruct.vert",
"spv.controlFlowAttributes.frag",
"spv.conversion.frag",
"spv.coopmat.comp",
"spv.coopmat_Error.comp",
"spv.dataOut.frag",
"spv.dataOutIndirect.frag",
"spv.dataOutIndirect.vert",
"spv.demoteDisabled.frag",
"spv.deepRvalue.frag",
"spv.depthOut.frag",
"spv.discard-dce.frag",
@ -256,16 +317,26 @@ INSTANTIATE_TEST_CASE_P(
"spv.earlyReturnDiscard.frag",
"spv.extPostDepthCoverage.frag",
"spv.extPostDepthCoverage_Error.frag",
"spv.float16convertonlyarith.comp",
"spv.float16convertonlystorage.comp",
"spv.flowControl.frag",
"spv.forLoop.frag",
"spv.forwardFun.frag",
"spv.fragmentDensity.frag",
"spv.fragmentDensity.vert",
"spv.fragmentDensity-es.frag",
"spv.fragmentDensity-neg.frag",
"spv.fsi.frag",
"spv.fsi_Error.frag",
"spv.fullyCovered.frag",
"spv.functionCall.frag",
"spv.functionNestedOpaque.vert",
"spv.functionSemantics.frag",
"spv.functionParameterTypes.frag",
"spv.GeometryShaderPassthrough.geom",
"spv.interpOps.frag",
"spv.int64.frag",
"spv.intcoopmat.comp",
"spv.intOps.vert",
"spv.layoutNested.vert",
"spv.length.frag",
@ -283,6 +354,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.noDeadDecorations.vert",
"spv.nonSquare.vert",
"spv.nonuniform.frag",
"spv.nonuniform2.frag",
"spv.noWorkgroup.comp",
"spv.offsets.frag",
"spv.Operations.frag",
@ -290,11 +362,14 @@ INSTANTIATE_TEST_CASE_P(
"spv.precision.frag",
"spv.precisionNonESSamp.frag",
"spv.prepost.frag",
"spv.privateVariableTypes.frag",
"spv.qualifiers.vert",
"spv.sample.frag",
"spv.sampleId.frag",
"spv.samplePosition.frag",
"spv.sampleMaskOverrideCoverage.frag",
"spv.scalarlayout.frag",
"spv.scalarlayoutfloat16.frag",
"spv.shaderBallot.comp",
"spv.shaderDrawParams.vert",
"spv.shaderGroupVote.comp",
@ -339,11 +414,41 @@ INSTANTIATE_TEST_CASE_P(
"spv.storageBuffer.vert",
"spv.precise.tese",
"spv.precise.tesc",
"spv.volatileAtomic.comp",
"spv.vulkan100.subgroupArithmetic.comp",
"spv.vulkan100.subgroupPartitioned.comp",
"spv.xfb.vert",
"spv.xfb2.vert",
"spv.xfb3.vert",
"spv.samplerlessTextureFunctions.frag",
"spv.smBuiltins.vert",
"spv.smBuiltins.frag",
})),
FileNameAsCustomTestSuffix
);
// Cases with deliberately unreachable code.
// By default the compiler will aggressively eliminate
// unreachable merges and continues.
INSTANTIATE_TEST_CASE_P(
GlslWithDeadCode, CompileVulkanToSpirvDeadCodeElimTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.dead-after-continue.vert",
"spv.dead-after-discard.frag",
"spv.dead-after-return.vert",
"spv.dead-after-loop-break.vert",
"spv.dead-after-switch-break.vert",
"spv.dead-complex-continue-after-return.vert",
"spv.dead-complex-merge-after-return.vert",
})),
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkanToDebugSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.pp.line.frag",
})),
FileNameAsCustomTestSuffix
);
@ -352,6 +457,9 @@ INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkan1_1ToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.1.3.8bitstorage-ubo.vert",
"spv.1.3.8bitstorage-ssbo.vert",
"spv.1.3.coopmat.comp",
"spv.deviceGroup.frag",
"spv.drawParams.vert",
"spv.int8.frag",
@ -360,7 +468,10 @@ INSTANTIATE_TEST_CASE_P(
"spv.explicittypes.frag",
"spv.float32.frag",
"spv.float64.frag",
"spv.memoryScopeSemantics.comp",
"spv.memoryScopeSemantics_Error.comp",
"spv.multiView.frag",
"spv.RayGenShader11.rgen",
"spv.subgroup.frag",
"spv.subgroup.geom",
"spv.subgroup.tesc",
@ -369,6 +480,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.subgroupArithmetic.comp",
"spv.subgroupBasic.comp",
"spv.subgroupBallot.comp",
"spv.subgroupBallotNeg.comp",
"spv.subgroupClustered.comp",
"spv.subgroupClusteredNeg.comp",
"spv.subgroupPartitioned.comp",
@ -376,11 +488,46 @@ INSTANTIATE_TEST_CASE_P(
"spv.subgroupShuffleRelative.comp",
"spv.subgroupQuad.comp",
"spv.subgroupVote.comp",
"spv.subgroupExtendedTypesArithmetic.comp",
"spv.subgroupExtendedTypesArithmeticNeg.comp",
"spv.subgroupExtendedTypesBallot.comp",
"spv.subgroupExtendedTypesBallotNeg.comp",
"spv.subgroupExtendedTypesClustered.comp",
"spv.subgroupExtendedTypesClusteredNeg.comp",
"spv.subgroupExtendedTypesPartitioned.comp",
"spv.subgroupExtendedTypesPartitionedNeg.comp",
"spv.subgroupExtendedTypesShuffle.comp",
"spv.subgroupExtendedTypesShuffleNeg.comp",
"spv.subgroupExtendedTypesShuffleRelative.comp",
"spv.subgroupExtendedTypesShuffleRelativeNeg.comp",
"spv.subgroupExtendedTypesQuad.comp",
"spv.subgroupExtendedTypesQuadNeg.comp",
"spv.subgroupExtendedTypesVote.comp",
"spv.subgroupExtendedTypesVoteNeg.comp",
"spv.vulkan110.storageBuffer.vert",
})),
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileToSpirv14Test,
::testing::ValuesIn(std::vector<std::string>({
"spv.1.4.LoopControl.frag",
"spv.1.4.NonWritable.frag",
"spv.1.4.OpEntryPoint.frag",
"spv.1.4.OpSelect.frag",
"spv.1.4.OpCopyLogical.comp",
"spv.1.4.OpCopyLogicalBool.comp",
"spv.1.4.OpCopyLogical.funcall.frag",
"spv.1.4.image.frag",
"spv.1.4.sparseTexture.frag",
"spv.1.4.texture.frag",
"spv.1.4.constructComposite.comp",
})),
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
Hlsl, HlslIoMap,
@ -423,6 +570,10 @@ INSTANTIATE_TEST_CASE_P(
"spv.rankShift.comp",
"spv.specConst.vert",
"spv.OVR_multiview.vert",
"spv.xfbOffsetOnBlockMembersAssignment.vert",
"spv.xfbOffsetOnStructMembersAssignment.vert",
"spv.xfbOverlapOffsetCheckWithBlockAndMember.vert",
"spv.xfbStrideJustOnce.vert",
})),
FileNameAsCustomTestSuffix
);
@ -433,6 +584,8 @@ INSTANTIATE_TEST_CASE_P(
"vulkan.frag",
"vulkan.vert",
"vulkan.comp",
"samplerlessTextureFunctions.frag",
"spv.specConstArrayCheck.vert",
})),
FileNameAsCustomTestSuffix
);
@ -457,10 +610,10 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
#ifdef AMD_EXTENSIONS
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkanToSpirvTestAMD,
::testing::ValuesIn(std::vector<std::string>({
"spv.16bitxfb.vert",
"spv.float16.frag",
"spv.float16Fetch.frag",
"spv.imageLoadStoreLod.frag",
@ -472,9 +625,7 @@ INSTANTIATE_TEST_CASE_P(
})),
FileNameAsCustomTestSuffix
);
#endif
#ifdef NV_EXTENSIONS
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkanToSpirvTestNV,
::testing::ValuesIn(std::vector<std::string>({
@ -487,10 +638,41 @@ INSTANTIATE_TEST_CASE_P(
"spv.multiviewPerViewAttributes.vert",
"spv.multiviewPerViewAttributes.tesc",
"spv.atomicInt64.comp",
"spv.shadingRate.frag",
"spv.RayGenShader.rgen",
"spv.RayGenShaderArray.rgen",
"spv.RayGenShader_Errors.rgen",
"spv.RayConstants.rgen",
"spv.IntersectShader.rint",
"spv.IntersectShader_Errors.rint",
"spv.AnyHitShader.rahit",
"spv.AnyHitShader_Errors.rahit",
"spv.ClosestHitShader.rchit",
"spv.ClosestHitShader_Errors.rchit",
"spv.MissShader.rmiss",
"spv.MissShader_Errors.rmiss",
"spv.RayCallable.rcall",
"spv.RayCallable_Errors.rcall",
"spv.fragmentShaderBarycentric.frag",
"spv.fragmentShaderBarycentric2.frag",
"spv.computeShaderDerivatives.comp",
"spv.computeShaderDerivatives2.comp",
"spv.shaderImageFootprint.frag",
"spv.meshShaderBuiltins.mesh",
"spv.meshShaderUserDefined.mesh",
"spv.meshShaderPerViewBuiltins.mesh",
"spv.meshShaderPerViewUserDefined.mesh",
"spv.meshShaderPerView_Errors.mesh",
"spv.meshShaderSharedMem.mesh",
"spv.meshShaderTaskMem.mesh",
"spv.320.meshShaderUserDefined.mesh",
"spv.meshShaderRedeclBuiltins.mesh",
"spv.meshShaderRedeclPerViewBuiltins.mesh",
"spv.meshTaskShader.task",
"spv.perprimitiveNV.frag",
})),
FileNameAsCustomTestSuffix
);
#endif
INSTANTIATE_TEST_CASE_P(
Glsl, CompileUpgradeTextureToSampledTextureAndDropSamplersTest,

View File

@ -60,6 +60,22 @@ EShLanguage GetShaderStage(const std::string& stage)
return EShLangFragment;
} else if (stage == "comp") {
return EShLangCompute;
} else if (stage == "rgen") {
return EShLangRayGenNV;
} else if (stage == "rint") {
return EShLangIntersectNV;
} else if (stage == "rahit") {
return EShLangAnyHitNV;
} else if (stage == "rchit") {
return EShLangClosestHitNV;
} else if (stage == "rmiss") {
return EShLangMissNV;
} else if (stage == "rcall") {
return EShLangCallableNV;
} else if (stage == "task") {
return EShLangTaskNV;
} else if (stage == "mesh") {
return EShLangMeshNV;
} else {
assert(0 && "Unknown shader stage");
return EShLangCount;

134
Externals/glslang/gtests/TestFixture.h vendored Normal file → Executable file
View File

@ -111,7 +111,10 @@ public:
: defaultVersion(100),
defaultProfile(ENoProfile),
forceVersionProfile(false),
isForwardCompatible(false) {}
isForwardCompatible(false) {
// Perform validation by default.
spirvOptions.validate = true;
}
// Tries to load the contents from the file at the given |path|. On success,
// writes the contents into |contents|. On failure, errors out.
@ -137,15 +140,18 @@ public:
// write |real| to the given file named as |fname| if update mode is on.
void checkEqAndUpdateIfRequested(const std::string& expected,
const std::string& real,
const std::string& fname)
const std::string& fname,
const std::string& errorsAndWarnings = "")
{
// In order to output the message we want under proper circumstances,
// we need the following operator<< stuff.
EXPECT_EQ(expected, real)
<< (GlobalTestSettings.updateMode
? ("Mismatch found and update mode turned on - "
"flushing expected result output.")
: "");
"flushing expected result output.\n")
: "")
<< "The following warnings/errors occurred:\n"
<< errorsAndWarnings;
// Update the expected output file if requested.
// It looks weird to duplicate the comparison between expected_output
@ -168,6 +174,7 @@ public:
std::vector<ShaderResult> shaderResults;
std::string linkingOutput;
std::string linkingError;
bool validationResult;
std::string spirvWarningsErrors;
std::string spirv; // Optional SPIR-V disassembly text.
};
@ -177,12 +184,19 @@ public:
// and modifies |shader| on success.
bool compile(glslang::TShader* shader, const std::string& code,
const std::string& entryPointName, EShMessages controls,
const TBuiltInResource* resources=nullptr)
const TBuiltInResource* resources=nullptr,
const std::string* shaderName=nullptr)
{
const char* shaderStrings = code.data();
const int shaderLengths = static_cast<int>(code.size());
const char* shaderNames = nullptr;
shader->setStringsWithLengths(&shaderStrings, &shaderLengths, 1);
if ((controls & EShMsgDebugInfo) && shaderName != nullptr) {
shaderNames = shaderName->data();
shader->setStringsWithLengthsAndNames(
&shaderStrings, &shaderLengths, &shaderNames, 1);
} else
shader->setStringsWithLengths(&shaderStrings, &shaderLengths, 1);
if (!entryPointName.empty()) shader->setEntryPoint(entryPointName.c_str());
return shader->parse(
(resources ? resources : &glslang::DefaultTBuiltInResource),
@ -195,12 +209,14 @@ public:
// during the process. If the target includes SPIR-V, also disassembles
// the result and returns disassembly text.
GlslangResult compileAndLink(
const std::string shaderName, const std::string& code,
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,
bool enableDebug = false,
bool automap = true)
{
const EShLanguage stage = GetShaderStage(GetSuffix(shaderName));
@ -211,7 +227,9 @@ public:
shader.setAutoMapBindings(true);
}
shader.setTextureSamplerTransformMode(texSampTransMode);
#ifdef ENABLE_HLSL
shader.setFlattenUniformArrays(flattenUniformArrays);
#endif
if (controls & EShMsgSpvRules) {
if (controls & EShMsgVulkanRules) {
@ -219,9 +237,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,
@ -231,7 +247,8 @@ public:
}
}
bool success = compile(&shader, code, entryPointName, controls);
bool success = compile(
&shader, code, entryPointName, controls, nullptr, &shaderName);
glslang::TProgram program;
program.addShader(&shader);
@ -241,20 +258,21 @@ public:
if (success && (controls & EShMsgSpvRules)) {
std::vector<uint32_t> spirv_binary;
glslang::SpvOptions options;
options.disableOptimizer = !enableOptimizer;
options().disableOptimizer = !enableOptimizer;
options().generateDebugInfo = enableDebug;
glslang::GlslangToSpv(*program.getIntermediate(stage),
spirv_binary, &logger, &options);
spirv_binary, &logger, &options());
std::ostringstream disassembly_stream;
spv::Parameterize();
spv::Disassemble(disassembly_stream, spirv_binary);
bool validation_result = !options().validate || logger.getAllMessages().empty();
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
program.getInfoLog(), program.getInfoDebugLog(),
logger.getAllMessages(), disassembly_stream.str()};
validation_result, logger.getAllMessages(), disassembly_stream.str()};
} else {
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
program.getInfoLog(), program.getInfoDebugLog(), "", ""};
program.getInfoLog(), program.getInfoDebugLog(), true, "", ""};
}
}
@ -284,7 +302,9 @@ public:
shader.setShiftSsboBinding(baseSsboBinding);
shader.setAutoMapBindings(autoMapBindings);
shader.setAutoMapLocations(true);
#ifdef ENABLE_HLSL
shader.setFlattenUniformArrays(flattenUniformArrays);
#endif
bool success = compile(&shader, code, entryPointName, controls);
@ -292,24 +312,27 @@ public:
program.addShader(&shader);
success &= program.link(controls);
#ifndef GLSLANG_WEB
success &= program.mapIO();
#endif
spv::SpvBuildLogger logger;
if (success && (controls & EShMsgSpvRules)) {
std::vector<uint32_t> spirv_binary;
glslang::GlslangToSpv(*program.getIntermediate(stage),
spirv_binary, &logger);
spirv_binary, &logger, &options());
std::ostringstream disassembly_stream;
spv::Parameterize();
spv::Disassemble(disassembly_stream, spirv_binary);
bool validation_result = !options().validate || logger.getAllMessages().empty();
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
program.getInfoLog(), program.getInfoDebugLog(),
logger.getAllMessages(), disassembly_stream.str()};
validation_result, logger.getAllMessages(), disassembly_stream.str()};
} else {
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
program.getInfoLog(), program.getInfoDebugLog(), "", ""};
program.getInfoLog(), program.getInfoDebugLog(), true, "", ""};
}
}
@ -339,19 +362,20 @@ public:
if (success && (controls & EShMsgSpvRules)) {
std::vector<uint32_t> spirv_binary;
glslang::GlslangToSpv(*program.getIntermediate(stage),
spirv_binary, &logger);
spirv_binary, &logger, &options());
spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions);
std::ostringstream disassembly_stream;
spv::Parameterize();
spv::Disassemble(disassembly_stream, spirv_binary);
bool validation_result = !options().validate || logger.getAllMessages().empty();
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
program.getInfoLog(), program.getInfoDebugLog(),
logger.getAllMessages(), disassembly_stream.str()};
validation_result, logger.getAllMessages(), disassembly_stream.str()};
} else {
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
program.getInfoLog(), program.getInfoDebugLog(), "", ""};
program.getInfoLog(), program.getInfoDebugLog(), true, "", ""};
}
}
@ -372,9 +396,9 @@ public:
return {{{shaderName, "", ""},},
"", "",
"", disassembly_stream.str()};
true, "", disassembly_stream.str()};
} else {
return {{{shaderName, "", ""},}, "", "", "", ""};
return {{{shaderName, "", ""},}, "", "", true, "", ""};
}
}
@ -393,7 +417,9 @@ public:
}
outputIfNotEmpty(result.linkingOutput);
outputIfNotEmpty(result.linkingError);
*stream << result.spirvWarningsErrors;
if (!result.validationResult) {
*stream << "Validation failed\n";
}
if (controls & EShMsgSpvRules) {
*stream
@ -408,11 +434,13 @@ public:
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 bool enableOptimizer = false)
const bool enableOptimizer = false,
const bool enableDebug = false)
{
const std::string inputFname = testDir + "/" + testName;
const std::string expectedOutputFname =
@ -425,15 +453,46 @@ public:
EShMessages controls = DeriveOptions(source, semantics, target);
if (enableOptimizer)
controls = static_cast<EShMessages>(controls & ~EShMsgHlslLegalization);
GlslangResult result = compileAndLink(testName, input, entryPointName, controls, clientTargetVersion, false,
EShTexSampTransKeep, enableOptimizer, automap);
if (enableDebug)
controls = static_cast<EShMessages>(controls | EShMsgDebugInfo);
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;
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
expectedOutputFname);
expectedOutputFname, result.spirvWarningsErrors);
}
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)
{
const std::string inputFname = testDir + "/" + testName;
const std::string expectedOutputFname = testDir + baseDir + testName + ".out";
std::string input, expectedOutput;
tryLoadFile(inputFname, "input", &input);
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
EShMessages controls = DeriveOptions(source, semantics, target);
controls = static_cast<EShMessages>(controls | additionalOptions);
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,
@ -453,14 +512,14 @@ 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;
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
expectedOutputFname);
expectedOutputFname, result.spirvWarningsErrors);
}
void loadFileCompileIoMapAndCheck(const std::string& testDir,
@ -497,7 +556,7 @@ public:
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
expectedOutputFname);
expectedOutputFname, result.spirvWarningsErrors);
}
void loadFileCompileRemapAndCheck(const std::string& testDir,
@ -524,7 +583,7 @@ public:
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
expectedOutputFname);
expectedOutputFname, result.spirvWarningsErrors);
}
void loadFileRemapAndCheck(const std::string& testDir,
@ -551,7 +610,7 @@ public:
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
expectedOutputFname);
expectedOutputFname, result.spirvWarningsErrors);
}
// Preprocesses the given |source| code. On success, returns true, the
@ -623,7 +682,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.
@ -631,14 +690,17 @@ public:
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
expectedOutputFname);
expectedOutputFname, result.spirvWarningsErrors);
}
glslang::SpvOptions& options() { return spirvOptions; }
private:
const int defaultVersion;
const EProfile defaultProfile;
const bool forceVersionProfile;
const bool isForwardCompatible;
glslang::SpvOptions spirvOptions;
};
} // namespace glslangtest

35
Externals/glslang/gtests/pch.cpp vendored Normal file
View File

@ -0,0 +1,35 @@
//
// Copyright (C) 2018 The Khronos Group Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#include "pch.h"

39
Externals/glslang/gtests/pch.h vendored Normal file
View File

@ -0,0 +1,39 @@
#ifndef _PCH_H
#define _PCH_H
//
// Copyright (C) 2018 The Khronos Group Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#include "TestFixture.h"
#endif /* _PCH_H */