Skip to content

Commit

Permalink
Tests: Fix GLSL shaders not being executed
Browse files Browse the repository at this point in the history
for whatever reason
  • Loading branch information
SirLynix committed Jul 28, 2024
1 parent a16ff31 commit 4422c2d
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions tests/src/Tests/ShaderUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,32 +294,28 @@ void ExpectGLSL(nzsl::ShaderStageType stageType, const nzsl::Ast::Module& shader

void ExpectGLSL(const nzsl::Ast::Module& shaderModule, std::string_view expectedOutput, const nzsl::ShaderWriter::States& options, const nzsl::GlslWriter::Environment& env, bool testShaderCompilation)
{

// Retrieve entry-point to get shader type
std::optional<nzsl::ShaderStageType> entryShaderStage;

SECTION("Detecting GLSL entry point")
{
// Retrieve entry-point to get shader type

nzsl::Ast::ReflectVisitor::Callbacks callbacks;
callbacks.onEntryPointDeclaration = [&](nzsl::ShaderStageType stageType, const std::string& functionName)
{
INFO("multiple entry points found! (" << functionName << ")");
REQUIRE((!entryShaderStage.has_value() || stageType == entryShaderStage));
nzsl::Ast::ReflectVisitor::Callbacks callbacks;
callbacks.onEntryPointDeclaration = [&](nzsl::ShaderStageType stageType, const std::string& functionName)
{
INFO("multiple entry points found! (" << functionName << ")");
REQUIRE((!entryShaderStage.has_value() || stageType == entryShaderStage));

entryShaderStage = stageType;
};
entryShaderStage = stageType;
};

nzsl::Ast::ReflectVisitor reflectVisitor;
reflectVisitor.Reflect(*shaderModule.rootNode, callbacks);
nzsl::Ast::ReflectVisitor reflectVisitor;
reflectVisitor.Reflect(*shaderModule.rootNode, callbacks);

{
INFO("no entry point found");
REQUIRE(entryShaderStage.has_value());
}
{
INFO("no entry point found");
REQUIRE(entryShaderStage.has_value());
}

if (entryShaderStage)
ExpectGLSL(entryShaderStage.value(), shaderModule, expectedOutput, options, env, testShaderCompilation);
ExpectGLSL(entryShaderStage.value(), shaderModule, expectedOutput, options, env, testShaderCompilation);
}

void ExpectNZSL(const nzsl::Ast::Module& shaderModule, std::string_view expectedOutput, const nzsl::ShaderWriter::States& options)
Expand Down

0 comments on commit 4422c2d

Please sign in to comment.