Formalize builtin shader resource contracts

This commit is contained in:
2026-04-08 04:44:36 +08:00
parent 6113ed92b0
commit 2c1c815072
26 changed files with 358 additions and 368 deletions

View File

@@ -74,6 +74,19 @@ std::string EscapeRegexLiteralForTest(const std::string& value) {
<< source;
}
void AppendDefaultBuiltinPassResources(ShaderPass& pass) {
Array<ShaderResourceBindingDesc> bindings;
const bool resolved = TryBuildBuiltinPassDefaultResourceBindings(pass, bindings);
EXPECT_TRUE(resolved);
if (!resolved) {
return;
}
for (const ShaderResourceBindingDesc& binding : bindings) {
pass.resources.PushBack(binding);
}
}
} // namespace
TEST(BuiltinForwardPipeline_Test, UsesFloat3PositionInputLayoutForStaticMeshVertices) {
@@ -127,7 +140,7 @@ TEST(BuiltinForwardPipeline_Test, BuiltinForwardShaderUsesAuthoringSurfaceContra
const ShaderPass* pass = shader->FindPass("ForwardLit");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 8u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -156,7 +169,7 @@ TEST(BuiltinForwardPipeline_Test, BuiltinUnlitShaderUsesAuthoringSurfaceContract
const ShaderPass* pass = shader->FindPass("Unlit");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 4u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -602,7 +615,7 @@ TEST(BuiltinForwardPipeline_Test, BuiltinSkyboxShaderUsesAuthoringContract) {
const ShaderPass* pass = shader->FindPass("Skybox");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 5u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::None);
EXPECT_FALSE(pass->fixedFunctionState.depthWriteEnable);
@@ -636,7 +649,7 @@ TEST(BuiltinForwardPipeline_Test, BuiltinSkyboxShaderUsesAuthoringContract) {
delete shader;
}
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromImplicitSkyboxShaderContract) {
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromLoadedSkyboxShaderContract) {
ShaderLoader loader;
LoadResult result = loader.Load(GetBuiltinSkyboxShaderPath());
ASSERT_TRUE(result);
@@ -674,7 +687,7 @@ TEST(BuiltinForwardPipeline_Test, BuiltinFinalColorShaderUsesAuthoringContract)
const ShaderPass* pass = shader->FindPass("FinalColor");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 3u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::None);
EXPECT_FALSE(pass->fixedFunctionState.depthWriteEnable);
@@ -699,7 +712,7 @@ TEST(BuiltinForwardPipeline_Test, BuiltinFinalColorShaderUsesAuthoringContract)
delete shader;
}
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromImplicitFinalColorShaderContract) {
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromLoadedFinalColorShaderContract) {
ShaderLoader loader;
LoadResult result = loader.Load(GetBuiltinFinalColorShaderPath());
ASSERT_TRUE(result);
@@ -735,7 +748,7 @@ TEST(BuiltinForwardPipeline_Test, BuiltinColorScalePostProcessShaderUsesAuthorin
const ShaderPass* pass = shader->FindPass("ColorScale");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 3u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::None);
EXPECT_FALSE(pass->fixedFunctionState.depthWriteEnable);
@@ -748,7 +761,7 @@ TEST(BuiltinForwardPipeline_Test, BuiltinColorScalePostProcessShaderUsesAuthorin
delete shader;
}
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromImplicitColorScalePostProcessShaderContract) {
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromLoadedColorScalePostProcessShaderContract) {
ShaderLoader loader;
LoadResult result = loader.Load(GetBuiltinColorScalePostProcessShaderPath());
ASSERT_TRUE(result);
@@ -806,11 +819,11 @@ TEST(BuiltinForwardPipeline_Test, VulkanRuntimeCompileDescRewritesAuthoringFinal
"register(b0)"));
EXPECT_TRUE(SourceContainsRegisterBinding(
d3d12Source,
"Texture2D gSourceColorTexture",
"Texture2D SourceColorTexture",
"register(t0)"));
EXPECT_TRUE(SourceContainsRegisterBinding(
d3d12Source,
"SamplerState gLinearClampSampler",
"SamplerState LinearClampSampler",
"register(s0)"));
EXPECT_EQ(d3d12Source.find("space0"), std::string::npos);
EXPECT_EQ(d3d12Source.find("space1"), std::string::npos);
@@ -832,11 +845,11 @@ TEST(BuiltinForwardPipeline_Test, VulkanRuntimeCompileDescRewritesAuthoringFinal
"register(b0, space0)"));
EXPECT_TRUE(SourceContainsRegisterBinding(
runtimeSource,
"Texture2D gSourceColorTexture",
"Texture2D SourceColorTexture",
"register(t0, space1)"));
EXPECT_TRUE(SourceContainsRegisterBinding(
runtimeSource,
"SamplerState gLinearClampSampler",
"SamplerState LinearClampSampler",
"register(s0, space2)"));
ShaderCompileDesc vulkanCompileDesc = {};
@@ -932,11 +945,11 @@ TEST(BuiltinForwardPipeline_Test, VulkanRuntimeCompileDescRewritesAuthoringColor
"register(b0)"));
EXPECT_TRUE(SourceContainsRegisterBinding(
d3d12Source,
"Texture2D gSourceColorTexture",
"Texture2D SourceColorTexture",
"register(t0)"));
EXPECT_TRUE(SourceContainsRegisterBinding(
d3d12Source,
"SamplerState gLinearClampSampler",
"SamplerState LinearClampSampler",
"register(s0)"));
EXPECT_EQ(d3d12Source.find("space0"), std::string::npos);
EXPECT_EQ(d3d12Source.find("space1"), std::string::npos);
@@ -958,11 +971,11 @@ TEST(BuiltinForwardPipeline_Test, VulkanRuntimeCompileDescRewritesAuthoringColor
"register(b0, space0)"));
EXPECT_TRUE(SourceContainsRegisterBinding(
runtimeSource,
"Texture2D gSourceColorTexture",
"Texture2D SourceColorTexture",
"register(t0, space1)"));
EXPECT_TRUE(SourceContainsRegisterBinding(
runtimeSource,
"SamplerState gLinearClampSampler",
"SamplerState LinearClampSampler",
"register(s0, space2)"));
ShaderCompileDesc vulkanCompileDesc = {};
@@ -974,7 +987,7 @@ TEST(BuiltinForwardPipeline_Test, VulkanRuntimeCompileDescRewritesAuthoringColor
const std::string vulkanSource(
reinterpret_cast<const char*>(vulkanCompileDesc.source.data()),
vulkanCompileDesc.source.size());
EXPECT_NE(vulkanSource.find("gSourceColorTexture.Sample"), std::string::npos);
EXPECT_NE(vulkanSource.find("SourceColorTexture.Sample"), std::string::npos);
EXPECT_NE(vulkanSource.find("gColorScale"), std::string::npos);
delete shader;
@@ -1025,7 +1038,7 @@ TEST(BuiltinForwardPipeline_Test, OpenGLRuntimeTranspilesColorScaleVariantToComb
delete shader;
}
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromLoadedImplicitForwardShader) {
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromLoadedForwardShaderContract) {
ShaderLoader loader;
LoadResult result = loader.Load(GetBuiltinForwardLitShaderPath());
ASSERT_TRUE(result);
@@ -1065,6 +1078,7 @@ TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromBuilti
tag.name = "LightMode";
tag.value = "ForwardBase";
pass.tags.PushBack(tag);
AppendDefaultBuiltinPassResources(pass);
BuiltinPassResourceBindingPlan plan = {};
String error;
@@ -1081,7 +1095,7 @@ TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromBuilti
EXPECT_EQ(plan.descriptorSetCount, 8u);
}
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromImplicitUnlitContract) {
TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromLoadedUnlitShaderContract) {
ShaderLoader loader;
LoadResult result = loader.Load(GetBuiltinUnlitShaderPath());
ASSERT_TRUE(result);
@@ -1109,7 +1123,7 @@ TEST(BuiltinForwardPipeline_Test, BuildsBuiltinPassResourceBindingPlanFromImplic
delete shader;
}
TEST(BuiltinForwardPipeline_Test, UsesNormalizedImplicitSetIndicesForForwardSurfaceResources) {
TEST(BuiltinForwardPipeline_Test, UsesLoadedForwardShaderResourceSetIndices) {
ShaderLoader loader;
LoadResult result = loader.Load(GetBuiltinForwardLitShaderPath());
ASSERT_TRUE(result);
@@ -1120,7 +1134,7 @@ TEST(BuiltinForwardPipeline_Test, UsesNormalizedImplicitSetIndicesForForwardSurf
const ShaderPass* pass = shader->FindPass("ForwardLit");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 8u);
BuiltinPassResourceBindingPlan plan = {};
String error;
@@ -1138,7 +1152,7 @@ TEST(BuiltinForwardPipeline_Test, UsesNormalizedImplicitSetIndicesForForwardSurf
delete shader;
}
TEST(BuiltinPassLayout_Test, BuildsSharedSetLayoutsFromImplicitForwardResources) {
TEST(BuiltinPassLayout_Test, BuildsSharedSetLayoutsFromLoadedForwardShaderResources) {
ShaderLoader loader;
LoadResult result = loader.Load(GetBuiltinForwardLitShaderPath());
ASSERT_TRUE(result);
@@ -1149,7 +1163,7 @@ TEST(BuiltinPassLayout_Test, BuildsSharedSetLayoutsFromImplicitForwardResources)
const ShaderPass* pass = shader->FindPass("ForwardLit");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 8u);
BuiltinPassResourceBindingPlan plan = {};
String error;
@@ -1209,7 +1223,7 @@ TEST(BuiltinDepthStylePass_Test, BuiltinDepthOnlyShaderUsesAuthoringContract) {
const ShaderPass* pass = shader->FindPass("DepthOnly");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 4u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -1229,7 +1243,7 @@ TEST(BuiltinDepthStylePass_Test, BuiltinShadowCasterShaderUsesAuthoringContract)
const ShaderPass* pass = shader->FindPass("ShadowCaster");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 4u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -1249,7 +1263,7 @@ TEST(BuiltinObjectIdPass_Test, BuiltinObjectIdShaderUsesAuthoringContract) {
const ShaderPass* pass = shader->FindPass("ObjectId");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 1u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -1287,7 +1301,7 @@ TEST(BuiltinObjectIdPass_Test, BuildsBuiltinPassResourceBindingPlanFromBuiltinOb
delete shader;
}
TEST(BuiltinObjectIdPass_Test, BuildsBuiltinPassResourceBindingPlanFromImplicitObjectIdContract) {
TEST(BuiltinObjectIdPass_Test, BuildsBuiltinPassResourceBindingPlanFromExplicitObjectIdContract) {
ShaderPass pass = {};
pass.name = "ObjectId";
@@ -1295,6 +1309,7 @@ TEST(BuiltinObjectIdPass_Test, BuildsBuiltinPassResourceBindingPlanFromImplicitO
tag.name = "LightMode";
tag.value = "ObjectId";
pass.tags.PushBack(tag);
AppendDefaultBuiltinPassResources(pass);
BuiltinPassResourceBindingPlan plan = {};
String error;
@@ -1306,7 +1321,7 @@ TEST(BuiltinObjectIdPass_Test, BuildsBuiltinPassResourceBindingPlanFromImplicitO
EXPECT_EQ(plan.descriptorSetCount, 1u);
}
TEST(BuiltinDepthStylePass_Test, BuildsBuiltinPassResourceBindingPlanFromImplicitDepthOnlyContract) {
TEST(BuiltinDepthStylePass_Test, BuildsBuiltinPassResourceBindingPlanFromExplicitDepthOnlyContract) {
ShaderPass pass = {};
pass.name = "DepthOnly";
@@ -1314,6 +1329,7 @@ TEST(BuiltinDepthStylePass_Test, BuildsBuiltinPassResourceBindingPlanFromImplici
tag.name = "LightMode";
tag.value = "DepthOnly";
pass.tags.PushBack(tag);
AppendDefaultBuiltinPassResources(pass);
BuiltinPassResourceBindingPlan plan = {};
String error;

View File

@@ -186,7 +186,7 @@ TEST(ShaderLoader, LoadShaderAuthoringBuildsMultiPassGenericVariants) {
const ShaderPass* forwardLitPass = shader->FindPass("ForwardLit");
ASSERT_NE(forwardLitPass, nullptr);
ASSERT_EQ(forwardLitPass->tags.Size(), 2u);
EXPECT_TRUE(forwardLitPass->resources.Empty());
EXPECT_EQ(forwardLitPass->resources.Size(), 8u);
ASSERT_NE(FindPassTag(forwardLitPass, "LightMode"), nullptr);
ASSERT_NE(FindPassTag(forwardLitPass, "Queue"), nullptr);
EXPECT_EQ(FindPassTag(forwardLitPass, "LightMode")->value, "ForwardBase");
@@ -395,7 +395,7 @@ TEST(ShaderLoader, LoadShaderAuthoringBuildsGenericHlslVariants) {
EXPECT_EQ(pass->tags[1].value, "200");
EXPECT_EQ(pass->tags[2].name, "LightMode");
EXPECT_EQ(pass->tags[2].value, "ForwardLit");
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 8u);
ASSERT_EQ(pass->keywordDeclarations.Size(), 2u);
EXPECT_EQ(pass->keywordDeclarations[0].type, ShaderKeywordDeclarationType::MultiCompile);
ASSERT_EQ(pass->keywordDeclarations[0].options.Size(), 2u);
@@ -1636,7 +1636,7 @@ TEST(ShaderLoader, AssetDatabaseCreatesShaderArtifactFromAuthoringAndLoaderReads
const ShaderPass* pass = shader->FindPass("ForwardLit");
ASSERT_NE(pass, nullptr);
ASSERT_EQ(pass->variants.Size(), 4u);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 8u);
const ShaderStageVariant* fragmentVariant =
shader->FindVariant("ForwardLit", ShaderType::Fragment, ShaderBackend::OpenGL);
@@ -1912,7 +1912,7 @@ TEST(ShaderLoader, LoadBuiltinForwardLitShaderBuildsAuthoringVariants) {
ASSERT_EQ(shader->GetProperties().Size(), 3u);
ASSERT_EQ(pass->variants.Size(), 8u);
ASSERT_EQ(pass->tags.Size(), 1u);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 8u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -1935,11 +1935,11 @@ TEST(ShaderLoader, LoadBuiltinForwardLitShaderBuildsAuthoringVariants) {
EXPECT_EQ(cutoffProperty->type, ShaderPropertyType::Range);
EXPECT_EQ(cutoffProperty->semantic, "AlphaCutoff");
EXPECT_EQ(shader->FindPassResourceBinding("ForwardLit", "PerObjectConstants"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("ForwardLit", "LightingConstants"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("ForwardLit", "ShadowReceiverConstants"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("ForwardLit", "BaseColorTexture"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("ForwardLit", "ShadowMapTexture"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ForwardLit", "PerObjectConstants"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ForwardLit", "LightingConstants"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ForwardLit", "ShadowReceiverConstants"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ForwardLit", "BaseColorTexture"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ForwardLit", "ShadowMapTexture"), nullptr);
ASSERT_EQ(pass->keywordDeclarations.Size(), 2u);
EXPECT_EQ(pass->keywordDeclarations[0].type, ShaderKeywordDeclarationType::MultiCompile);
ASSERT_EQ(pass->keywordDeclarations[0].options.Size(), 2u);
@@ -2087,7 +2087,7 @@ TEST(ShaderLoader, LoadBuiltinUnlitShaderBuildsAuthoringVariants) {
ASSERT_EQ(shader->GetProperties().Size(), 2u);
ASSERT_EQ(pass->variants.Size(), 2u);
ASSERT_EQ(pass->tags.Size(), 1u);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 4u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -2105,7 +2105,7 @@ TEST(ShaderLoader, LoadBuiltinUnlitShaderBuildsAuthoringVariants) {
EXPECT_EQ(baseMapProperty->type, ShaderPropertyType::Texture2D);
EXPECT_EQ(baseMapProperty->semantic, "BaseColorTexture");
EXPECT_EQ(shader->FindPassResourceBinding("Unlit", "PerObjectConstants"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("Unlit", "PerObjectConstants"), nullptr);
EXPECT_NE(shader->FindVariant("Unlit", ShaderType::Vertex, ShaderBackend::D3D12), nullptr);
EXPECT_NE(shader->FindVariant("Unlit", ShaderType::Fragment, ShaderBackend::D3D12), nullptr);
@@ -2162,7 +2162,7 @@ TEST(ShaderLoader, LoadBuiltinObjectIdShaderBuildsAuthoringVariants) {
const ShaderPass* pass = shader->FindPass("ObjectId");
ASSERT_NE(pass, nullptr);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 1u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -2228,7 +2228,7 @@ TEST(ShaderLoader, LoadBuiltinDepthOnlyShaderBuildsAuthoringVariants) {
const ShaderPass* pass = shader->FindPass("DepthOnly");
ASSERT_NE(pass, nullptr);
ASSERT_EQ(shader->GetProperties().Size(), 3u);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 4u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -2259,10 +2259,10 @@ TEST(ShaderLoader, LoadBuiltinDepthOnlyShaderBuildsAuthoringVariants) {
EXPECT_EQ(baseMapProperty->type, ShaderPropertyType::Texture2D);
EXPECT_EQ(baseMapProperty->semantic, "BaseColorTexture");
EXPECT_EQ(shader->FindPassResourceBinding("DepthOnly", "PerObjectConstants"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("DepthOnly", "MaterialConstants"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("DepthOnly", "BaseColorTexture"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("DepthOnly", "LinearClampSampler"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("DepthOnly", "PerObjectConstants"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("DepthOnly", "MaterialConstants"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("DepthOnly", "BaseColorTexture"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("DepthOnly", "LinearClampSampler"), nullptr);
EXPECT_NE(shader->FindVariant("DepthOnly", ShaderType::Vertex, ShaderBackend::D3D12), nullptr);
EXPECT_NE(shader->FindVariant("DepthOnly", ShaderType::Fragment, ShaderBackend::D3D12), nullptr);
@@ -2354,7 +2354,7 @@ TEST(ShaderLoader, LoadBuiltinShadowCasterShaderBuildsAuthoringVariants) {
const ShaderPass* pass = shader->FindPass("ShadowCaster");
ASSERT_NE(pass, nullptr);
ASSERT_EQ(shader->GetProperties().Size(), 3u);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 4u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::Back);
EXPECT_TRUE(pass->fixedFunctionState.depthWriteEnable);
@@ -2385,10 +2385,10 @@ TEST(ShaderLoader, LoadBuiltinShadowCasterShaderBuildsAuthoringVariants) {
EXPECT_EQ(baseMapProperty->type, ShaderPropertyType::Texture2D);
EXPECT_EQ(baseMapProperty->semantic, "BaseColorTexture");
EXPECT_EQ(shader->FindPassResourceBinding("ShadowCaster", "PerObjectConstants"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("ShadowCaster", "MaterialConstants"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("ShadowCaster", "BaseColorTexture"), nullptr);
EXPECT_EQ(shader->FindPassResourceBinding("ShadowCaster", "LinearClampSampler"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ShadowCaster", "PerObjectConstants"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ShadowCaster", "MaterialConstants"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ShadowCaster", "BaseColorTexture"), nullptr);
EXPECT_NE(shader->FindPassResourceBinding("ShadowCaster", "LinearClampSampler"), nullptr);
EXPECT_NE(shader->FindVariant("ShadowCaster", ShaderType::Vertex, ShaderBackend::D3D12), nullptr);
EXPECT_NE(shader->FindVariant("ShadowCaster", ShaderType::Fragment, ShaderBackend::D3D12), nullptr);
@@ -2482,7 +2482,7 @@ TEST(ShaderLoader, LoadBuiltinFinalColorShaderBuildsAuthoringVariants) {
ASSERT_EQ(shader->GetProperties().Size(), 4u);
ASSERT_EQ(pass->variants.Size(), 2u);
ASSERT_EQ(pass->tags.Size(), 1u);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 3u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::None);
EXPECT_FALSE(pass->fixedFunctionState.depthWriteEnable);
@@ -2533,7 +2533,7 @@ TEST(ShaderLoader, LoadBuiltinFinalColorShaderBuildsAuthoringVariants) {
EXPECT_EQ(openglFragment->language, ShaderLanguage::HLSL);
EXPECT_EQ(openglFragment->entryPoint, "MainPS");
EXPECT_EQ(openglFragment->profile, "ps_5_0");
EXPECT_NE(std::string(openglFragment->sourceCode.CStr()).find("gSourceColorTexture.Sample"), std::string::npos);
EXPECT_NE(std::string(openglFragment->sourceCode.CStr()).find("SourceColorTexture.Sample"), std::string::npos);
const ShaderStageVariant* vulkanFragment = shader->FindVariant(
"FinalColor",
@@ -2565,7 +2565,7 @@ TEST(ShaderLoader, LoadBuiltinColorScalePostProcessShaderBuildsAuthoringVariants
ASSERT_EQ(shader->GetProperties().Size(), 1u);
ASSERT_EQ(pass->variants.Size(), 2u);
ASSERT_EQ(pass->tags.Size(), 1u);
EXPECT_TRUE(pass->resources.Empty());
EXPECT_EQ(pass->resources.Size(), 3u);
EXPECT_TRUE(pass->hasFixedFunctionState);
EXPECT_EQ(pass->fixedFunctionState.cullMode, MaterialCullMode::None);
EXPECT_FALSE(pass->fixedFunctionState.depthWriteEnable);
@@ -2604,7 +2604,7 @@ TEST(ShaderLoader, LoadBuiltinColorScalePostProcessShaderBuildsAuthoringVariants
EXPECT_EQ(openglFragment->language, ShaderLanguage::HLSL);
EXPECT_EQ(openglFragment->entryPoint, "MainPS");
EXPECT_EQ(openglFragment->profile, "ps_5_0");
EXPECT_NE(std::string(openglFragment->sourceCode.CStr()).find("gSourceColorTexture.Sample"), std::string::npos);
EXPECT_NE(std::string(openglFragment->sourceCode.CStr()).find("SourceColorTexture.Sample"), std::string::npos);
const ShaderStageVariant* vulkanFragment = shader->FindVariant(
"ColorScale",
@@ -2616,7 +2616,7 @@ TEST(ShaderLoader, LoadBuiltinColorScalePostProcessShaderBuildsAuthoringVariants
EXPECT_EQ(vulkanFragment->entryPoint, "MainPS");
EXPECT_EQ(vulkanFragment->profile, "ps_5_0");
EXPECT_NE(std::string(vulkanFragment->sourceCode.CStr()).find("gColorScale"), std::string::npos);
EXPECT_NE(std::string(vulkanFragment->sourceCode.CStr()).find("gSourceColorTexture.Sample"), std::string::npos);
EXPECT_NE(std::string(vulkanFragment->sourceCode.CStr()).find("SourceColorTexture.Sample"), std::string::npos);
delete shader;
}