Add manifest support for pass declarations
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m17s
CI / Windows Release Package (push) Successful in 2m28s

This commit is contained in:
2026-05-08 17:19:30 +10:00
parent 87cb55b80b
commit 596d370f43
15 changed files with 362 additions and 128 deletions

View File

@@ -80,6 +80,34 @@ void TestValidManifest()
Expect(package.parameters.size() == 4, "parameters parse");
Expect(package.parameters[1].type == ShaderParameterType::Text && package.parameters[1].defaultTextValue == "LIVE", "text parameter parses");
Expect(package.parameters[3].type == ShaderParameterType::Trigger, "trigger parameter parses");
Expect(package.passes.size() == 1 && package.passes[0].id == "main", "legacy manifests get an implicit main pass");
std::filesystem::remove_all(root);
}
void TestExplicitPassManifest()
{
const std::filesystem::path root = MakeTestRoot();
WriteShaderPackage(root, "multi", R"({
"id": "multi-pass",
"name": "Multi Pass",
"passes": [
{ "id": "blurX", "source": "blur-x.slang", "entryPoint": "blurHorizontal", "inputs": ["layerInput"], "output": "blurredX" },
{ "id": "final", "source": "final.slang", "entryPoint": "finish", "inputs": ["blurredX"], "output": "layerOutput" }
],
"parameters": []
})");
WriteFile(root / "multi" / "blur-x.slang", "float4 blurHorizontal(float2 uv) { return float4(uv, 0.0, 1.0); }\n");
WriteFile(root / "multi" / "final.slang", "float4 finish(float2 uv) { return float4(uv, 1.0, 1.0); }\n");
ShaderPackageRegistry registry(4);
ShaderPackage package;
std::string error;
Expect(registry.ParseManifest(root / "multi" / "shader.json", package, error), "explicit pass manifest parses");
Expect(package.passes.size() == 2, "explicit passes parse");
Expect(package.passes[0].id == "blurX" && package.passes[0].entryPoint == "blurHorizontal", "first pass metadata parses");
Expect(package.passes[0].inputNames.size() == 1 && package.passes[0].inputNames[0] == "layerInput", "pass inputs parse");
Expect(package.passes[1].outputName == "layerOutput", "pass output parses");
std::filesystem::remove_all(root);
}
@@ -231,6 +259,7 @@ void TestInvalidPackageDoesNotFailScan()
int main()
{
TestValidManifest();
TestExplicitPassManifest();
TestMissingFontAsset();
TestInvalidManifest();
TestInvalidTemporalSettings();

View File

@@ -81,15 +81,19 @@ int main()
if (packageIt == packagesById.end())
continue;
std::string fragmentShaderSource;
std::string compileError;
if (!compiler.BuildLayerFragmentShaderSource(packageIt->second, fragmentShaderSource, compileError))
const ShaderPackage& shaderPackage = packageIt->second;
for (const ShaderPassDefinition& pass : shaderPackage.passes)
{
Fail("Shader package '" + packageId + "' failed Slang validation: " + compileError);
continue;
std::string fragmentShaderSource;
std::string compileError;
if (!compiler.BuildPassFragmentShaderSource(shaderPackage, pass, fragmentShaderSource, compileError))
{
Fail("Shader package '" + packageId + "' pass '" + pass.id + "' failed Slang validation: " + compileError);
continue;
}
if (fragmentShaderSource.find("#version 430 core") == std::string::npos)
Fail("Shader package '" + packageId + "' pass '" + pass.id + "' generated GLSL without the expected patched GLSL version header.");
}
if (fragmentShaderSource.find("#version 430 core") == std::string::npos)
Fail("Shader package '" + packageId + "' generated GLSL without the expected patched GLSL version header.");
}
std::error_code removeError;