Add render graph texture transition plans

This commit is contained in:
2026-04-14 04:45:39 +08:00
parent c0d62dc749
commit 8bd375cd24
4 changed files with 102 additions and 0 deletions

View File

@@ -429,6 +429,16 @@ TEST(RenderGraph_Test, PreservesImportedTextureStateContractAcrossCompile) {
EXPECT_EQ(resolvedOptions.initialState, ResourceStates::Present);
EXPECT_EQ(resolvedOptions.finalState, ResourceStates::PixelShaderResource);
EXPECT_TRUE(resolvedOptions.graphOwnsTransitions);
RenderGraphTextureTransitionPlan transitionPlan = {};
ASSERT_TRUE(compiledGraph.TryGetTextureTransitionPlan(importedTexture, transitionPlan));
EXPECT_TRUE(transitionPlan.graphOwnsTransitions);
EXPECT_TRUE(transitionPlan.hasFirstAccessState);
EXPECT_TRUE(transitionPlan.hasLastAccessState);
EXPECT_EQ(transitionPlan.initialState, ResourceStates::Present);
EXPECT_EQ(transitionPlan.firstAccessState, ResourceStates::PixelShaderResource);
EXPECT_EQ(transitionPlan.lastAccessState, ResourceStates::PixelShaderResource);
EXPECT_EQ(transitionPlan.finalState, ResourceStates::PixelShaderResource);
}
TEST(RenderGraph_Test, ExecutesGraphOwnedImportedTextureTransitionsAtGraphBoundaries) {
@@ -495,6 +505,34 @@ TEST(RenderGraph_Test, RejectsTransientTextureReadBeforeWrite) {
EXPECT_FALSE(errorMessage.Empty());
}
TEST(RenderGraph_Test, RejectsGraphOwnedImportedTextureWithoutView) {
RenderGraph graph;
RenderGraphBuilder builder(graph);
const RenderGraphTextureDesc desc = BuildTestTextureDesc();
RenderGraphImportedTextureOptions importedOptions = {};
importedOptions.initialState = ResourceStates::Present;
importedOptions.finalState = ResourceStates::Present;
importedOptions.graphOwnsTransitions = true;
const RenderGraphTextureHandle importedTexture = builder.ImportTexture(
"BackBuffer",
desc,
nullptr,
importedOptions);
builder.AddRasterPass(
"FinalBlit",
[&](RenderGraphPassBuilder& pass) {
pass.WriteTexture(importedTexture);
});
CompiledRenderGraph compiledGraph;
XCEngine::Containers::String errorMessage;
EXPECT_FALSE(RenderGraphCompiler::Compile(graph, compiledGraph, &errorMessage));
EXPECT_FALSE(errorMessage.Empty());
}
TEST(RenderGraph_Test, ExecutesCompiledPassCallbacksInCompiledOrder) {
RenderGraph graph;
RenderGraphBuilder builder(graph);