Vulkan: Call GraphResource instead of GraphNode.
We don't need to use the CommandGraphNode class directly. This CL
consolidates our code so we never call the GraphNodes class directly.
Instead we call operations on GraphResource. This should simplify the
interaction with APIs from the various graph and dependency management
classes in the Vulkan back-end.
A new concept of 'starting' vs 'appending' commands is introduced.
Appending tries to avoid starting new command buffers when possible.
Should not change how the graphs are constructed, and mostly be a
refactoring change. There may be minor behaviour changes to some
commands.
Bug: angleproject:2539
Change-Id: Ia971e5cacb1164b9b3b22fa4a0a55b954d81f10e
Reviewed-on: https://chromium-review.googlesource.com/1052068
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/RenderTargetVk.cpp b/src/libANGLE/renderer/vulkan/RenderTargetVk.cpp
index 807dccf..282834b 100644
--- a/src/libANGLE/renderer/vulkan/RenderTargetVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RenderTargetVk.cpp
@@ -26,30 +26,31 @@
{
}
-void RenderTargetVk::onColorDraw(Serial currentSerial,
- vk::CommandGraphNode *writingNode,
+void RenderTargetVk::onColorDraw(vk::CommandGraphResource *framebufferVk,
+ vk::CommandBuffer *commandBuffer,
vk::RenderPassDesc *renderPassDesc)
{
- ASSERT(writingNode->getOutsideRenderPassCommands()->valid());
+ ASSERT(commandBuffer->valid());
+ ASSERT(!mImage->getFormat().textureFormat().hasDepthOrStencilBits());
// Store the attachment info in the renderPassDesc.
renderPassDesc->packColorAttachment(*mImage);
// TODO(jmadill): Use automatic layout transition. http://anglebug.com/2361
- mImage->changeLayoutWithStages(
- VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
- VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
- writingNode->getOutsideRenderPassCommands());
+ mImage->changeLayoutWithStages(VK_IMAGE_ASPECT_COLOR_BIT,
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
+ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, commandBuffer);
- // Set up dependencies between the new graph node and other current nodes in the resource.
- mResource->onWriteResource(writingNode, currentSerial);
+ // Set up dependencies between the RT resource and the Framebuffer.
+ mResource->addWriteDependency(framebufferVk);
}
-void RenderTargetVk::onDepthStencilDraw(Serial currentSerial,
- vk::CommandGraphNode *writingNode,
+void RenderTargetVk::onDepthStencilDraw(vk::CommandGraphResource *framebufferVk,
+ vk::CommandBuffer *commandBuffer,
vk::RenderPassDesc *renderPassDesc)
{
- ASSERT(writingNode->getOutsideRenderPassCommands()->valid());
+ ASSERT(commandBuffer->valid());
ASSERT(mImage->getFormat().textureFormat().hasDepthOrStencilBits());
// Store the attachment info in the renderPassDesc.
@@ -62,11 +63,10 @@
mImage->changeLayoutWithStages(aspectFlags, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
- VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
- writingNode->getOutsideRenderPassCommands());
+ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, commandBuffer);
- // Set up dependencies between the new graph node and other current nodes in the resource.
- mResource->onWriteResource(writingNode, currentSerial);
+ // Set up dependencies between the RT resource and the Framebuffer.
+ mResource->addWriteDependency(framebufferVk);
}
const vk::ImageHelper &RenderTargetVk::getImage() const
@@ -106,10 +106,10 @@
}
vk::ImageHelper *RenderTargetVk::getImageForWrite(Serial currentSerial,
- vk::CommandGraphNode *writingNode) const
+ vk::CommandGraphResource *writingResource) const
{
ASSERT(mImage && mImage->valid());
- mResource->onWriteResource(writingNode, currentSerial);
+ mResource->addWriteDependency(writingResource);
return mImage;
}