Add includer to gtest for include file tests.
Turn on debug info flag for non-semantic debug test.
This commit is contained in:
parent
a92c61f845
commit
d8f5681ec0
9 changed files with 338 additions and 552 deletions
|
|
@ -67,7 +67,6 @@ std::string FileNameAsCustomTestSuffixIoMap(
|
|||
using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
using CompileVulkanToSpirvTestNoLink = 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 CompileToSpirv16Test = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
|
|
@ -82,7 +81,8 @@ using CompileVulkanToSpirvTestAMD = GlslangTest<::testing::TestWithParam<std::st
|
|||
using CompileVulkanToSpirvTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
using CompileVulkanToSpirv14TestNV = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
using CompileVulkanToNonSemanticShaderDebugInfoTest = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
using GlslSpirvDebugInfoTest = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
using GlslNonSemanticShaderDebugInfoTest = GlslangTest<::testing::TestWithParam<std::string>>;
|
||||
|
||||
// Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully
|
||||
// generate SPIR-V.
|
||||
|
|
@ -110,17 +110,6 @@ TEST_P(CompileVulkanToSpirvDeadCodeElimTest, FromFile)
|
|||
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)
|
||||
{
|
||||
|
|
@ -251,11 +240,18 @@ TEST_P(CompileUpgradeTextureToSampledTextureAndDropSamplersTest, FromFile)
|
|||
Target::Spv);
|
||||
}
|
||||
|
||||
TEST_P(CompileVulkanToNonSemanticShaderDebugInfoTest, FromFile)
|
||||
TEST_P(GlslSpirvDebugInfoTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
|
||||
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
|
||||
Target::Spv, true, "", "/baseResults/", false, true, true);
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), Source::GLSL, Semantics::Vulkan,
|
||||
glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, Target::Spv, true, "",
|
||||
"/baseResults/", false, true, false);
|
||||
}
|
||||
|
||||
TEST_P(GlslNonSemanticShaderDebugInfoTest, FromFile)
|
||||
{
|
||||
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), Source::GLSL, Semantics::Vulkan,
|
||||
glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, Target::Spv, true, "",
|
||||
"/baseResults/", false, true, true);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
|
@ -584,15 +580,6 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Glsl, CompileVulkanToDebugSpirvTest,
|
||||
::testing::ValuesIn(std::vector<std::string>({
|
||||
"spv.pp.line.frag",
|
||||
})),
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Glsl, CompileVulkan1_1ToSpirvTest,
|
||||
|
|
@ -945,7 +932,16 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Glsl, CompileVulkanToNonSemanticShaderDebugInfoTest,
|
||||
Glsl, GlslSpirvDebugInfoTest,
|
||||
::testing::ValuesIn(std::vector<std::string>({
|
||||
"spv.pp.line.frag",
|
||||
"spv.debugInfo.frag",
|
||||
})),
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Glsl, GlslNonSemanticShaderDebugInfoTest,
|
||||
::testing::ValuesIn(std::vector<std::string>({
|
||||
"spv.debuginfo.glsl.vert",
|
||||
"spv.debuginfo.glsl.frag",
|
||||
|
|
@ -957,6 +953,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"spv.debuginfo.const_params.glsl.comp",
|
||||
"spv.debuginfo.scalar_types.glsl.frag",
|
||||
"spv.debuginfo.rt_types.glsl.rgen",
|
||||
"spv.debuginfo.include.glsl.frag",
|
||||
})),
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#ifndef GLSLANG_GTESTS_TEST_FIXTURE_H
|
||||
#define GLSLANG_GTESTS_TEST_FIXTURE_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
|
@ -199,9 +200,42 @@ public:
|
|||
} else
|
||||
shader->setStringsWithLengths(&shaderStrings, &shaderLengths, 1);
|
||||
if (!entryPointName.empty()) shader->setEntryPoint(entryPointName.c_str());
|
||||
return shader->parse(
|
||||
(resources ? resources : GetDefaultResources()),
|
||||
defaultVersion, isForwardCompatible, controls);
|
||||
|
||||
// A includer that always assumes header name is a relative path to the test folder.
|
||||
class GlslangTestIncluder : public glslang::TShader::Includer {
|
||||
public:
|
||||
virtual IncludeResult* includeLocal(const char* headerName, const char* /*includerName*/,
|
||||
size_t /*inclusionDepth*/) override
|
||||
{
|
||||
std::string path = GLSLANG_TEST_DIRECTORY;
|
||||
path += '/';
|
||||
path += headerName;
|
||||
std::replace(path.begin(), path.end(), '\\', '/');
|
||||
|
||||
auto [success, fileContent] = ReadFile(path);
|
||||
if (success) {
|
||||
auto buffer = new char[fileContent.size() + 1];
|
||||
std::copy(fileContent.begin(), fileContent.end(), buffer);
|
||||
buffer[fileContent.size()] = '\0';
|
||||
|
||||
return new IncludeResult(headerName, buffer, fileContent.size(), buffer);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void releaseInclude(IncludeResult* result) override
|
||||
{
|
||||
if (result != nullptr) {
|
||||
delete[] static_cast<char*>(result->userData);
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GlslangTestIncluder includer;
|
||||
return shader->parse((resources ? resources : GetDefaultResources()), defaultVersion, isForwardCompatible,
|
||||
controls, includer);
|
||||
}
|
||||
|
||||
// Compiles and links the given source |code| of the given shader
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue