Support graph-owned imported texture transitions
This commit is contained in:
@@ -108,6 +108,16 @@ private:
|
||||
Format m_format = Format::Unknown;
|
||||
};
|
||||
|
||||
class MockImportedView final : public RHIResourceView {
|
||||
public:
|
||||
void Shutdown() override {}
|
||||
void* GetNativeHandle() override { return nullptr; }
|
||||
bool IsValid() const override { return true; }
|
||||
ResourceViewType GetViewType() const override { return ResourceViewType::RenderTarget; }
|
||||
ResourceViewDimension GetDimension() const override { return ResourceViewDimension::Texture2D; }
|
||||
Format GetFormat() const override { return Format::R8G8B8A8_UNorm; }
|
||||
};
|
||||
|
||||
class MockTransientDevice final : public RHIDevice {
|
||||
public:
|
||||
explicit MockTransientDevice(std::shared_ptr<MockTransientAllocationState> state)
|
||||
@@ -421,6 +431,51 @@ TEST(RenderGraph_Test, PreservesImportedTextureStateContractAcrossCompile) {
|
||||
EXPECT_TRUE(resolvedOptions.graphOwnsTransitions);
|
||||
}
|
||||
|
||||
TEST(RenderGraph_Test, ExecutesGraphOwnedImportedTextureTransitionsAtGraphBoundaries) {
|
||||
RenderGraph graph;
|
||||
RenderGraphBuilder builder(graph);
|
||||
|
||||
const RenderGraphTextureDesc desc = BuildTestTextureDesc();
|
||||
RenderGraphImportedTextureOptions importedOptions = {};
|
||||
importedOptions.initialState = ResourceStates::Present;
|
||||
importedOptions.finalState = ResourceStates::Present;
|
||||
importedOptions.graphOwnsTransitions = true;
|
||||
|
||||
MockImportedView importedView;
|
||||
const RenderGraphTextureHandle backBuffer = builder.ImportTexture(
|
||||
"BackBuffer",
|
||||
desc,
|
||||
&importedView,
|
||||
importedOptions);
|
||||
|
||||
builder.AddRasterPass(
|
||||
"FinalBlit",
|
||||
[&](RenderGraphPassBuilder& pass) {
|
||||
pass.WriteTexture(backBuffer);
|
||||
});
|
||||
|
||||
CompiledRenderGraph compiledGraph;
|
||||
XCEngine::Containers::String errorMessage;
|
||||
ASSERT_TRUE(RenderGraphCompiler::Compile(graph, compiledGraph, &errorMessage))
|
||||
<< errorMessage.CStr();
|
||||
|
||||
MockTransientCommandList commandList;
|
||||
RenderContext renderContext = {};
|
||||
renderContext.device = reinterpret_cast<RHIDevice*>(1);
|
||||
renderContext.commandList = &commandList;
|
||||
renderContext.commandQueue = reinterpret_cast<RHICommandQueue*>(1);
|
||||
ASSERT_TRUE(RenderGraphExecutor::Execute(compiledGraph, renderContext, &errorMessage))
|
||||
<< errorMessage.CStr();
|
||||
|
||||
ASSERT_EQ(commandList.transitionCalls.size(), 2u);
|
||||
EXPECT_EQ(commandList.transitionCalls[0].resource, &importedView);
|
||||
EXPECT_EQ(commandList.transitionCalls[0].before, ResourceStates::Present);
|
||||
EXPECT_EQ(commandList.transitionCalls[0].after, ResourceStates::RenderTarget);
|
||||
EXPECT_EQ(commandList.transitionCalls[1].resource, &importedView);
|
||||
EXPECT_EQ(commandList.transitionCalls[1].before, ResourceStates::RenderTarget);
|
||||
EXPECT_EQ(commandList.transitionCalls[1].after, ResourceStates::Present);
|
||||
}
|
||||
|
||||
TEST(RenderGraph_Test, RejectsTransientTextureReadBeforeWrite) {
|
||||
RenderGraph graph;
|
||||
RenderGraphBuilder builder(graph);
|
||||
|
||||
Reference in New Issue
Block a user