Vulkan: Make Resource's updateSerial private.
This simplifies the API from the calling resource classes. This method
is called internally instead. beginWriteResource and
appendWriteResource both call updateSerial internally.
Additionally this removes hasStartedRenderPass and instead returns a
boolean from appendToStartedRenderPass indicating success.
Bug: angleproject:2539
Change-Id: Idcf72e6a80dde90e83dabc64644051bb536c6b12
Reviewed-on: https://chromium-review.googlesource.com/1066554
Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/BufferVk.cpp b/src/libANGLE/renderer/vulkan/BufferVk.cpp
index 1cd17c8..cdb057e 100644
--- a/src/libANGLE/renderer/vulkan/BufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/BufferVk.cpp
@@ -192,8 +192,6 @@
// Use map when available.
if (renderer->isResourceInUse(*this))
{
- updateQueueSerial(renderer->getCurrentQueueSerial());
-
vk::StagingBuffer stagingBuffer;
ANGLE_TRY(stagingBuffer.init(contextVk, static_cast<VkDeviceSize>(size),
vk::StagingUsage::Write));
diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.cpp b/src/libANGLE/renderer/vulkan/CommandGraph.cpp
index c6420e8..e9c20d4 100644
--- a/src/libANGLE/renderer/vulkan/CommandGraph.cpp
+++ b/src/libANGLE/renderer/vulkan/CommandGraph.cpp
@@ -179,6 +179,8 @@
Error CommandGraphResource::appendWriteResource(RendererVk *renderer,
CommandBuffer **commandBufferOut)
{
+ updateQueueSerial(renderer->getCurrentQueueSerial());
+
if (!hasChildlessWritingNode())
{
return beginWriteResource(renderer, commandBufferOut);
@@ -198,10 +200,19 @@
return NoError();
}
-void CommandGraphResource::appendToRenderPass(class CommandBuffer **commandBufferOut) const
+bool CommandGraphResource::appendToStartedRenderPass(RendererVk *renderer,
+ CommandBuffer **commandBufferOut)
{
- ASSERT(hasStartedRenderPass());
- *commandBufferOut = mCurrentWritingNode->getInsideRenderPassCommands();
+ updateQueueSerial(renderer->getCurrentQueueSerial());
+ if (hasStartedRenderPass())
+ {
+ *commandBufferOut = mCurrentWritingNode->getInsideRenderPassCommands();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
bool CommandGraphResource::hasStartedRenderPass() const
diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.h b/src/libANGLE/renderer/vulkan/CommandGraph.h
index 914dadd..93a54d7 100644
--- a/src/libANGLE/renderer/vulkan/CommandGraph.h
+++ b/src/libANGLE/renderer/vulkan/CommandGraph.h
@@ -31,7 +31,6 @@
CommandGraphResource();
virtual ~CommandGraphResource();
- void updateQueueSerial(Serial queueSerial);
Serial getQueueSerial() const;
// Allocates a write node via getNewWriteNode and returns a started command buffer.
@@ -55,11 +54,9 @@
const std::vector<VkClearValue> &clearValues,
CommandBuffer **commandBufferOut) const;
- // Checks if we're in a RenderPass.
- bool hasStartedRenderPass() const;
-
- // Returns a started command buffer if we've already called beginRenderPass.
- void appendToRenderPass(CommandBuffer **commandBufferOut) const;
+ // Checks if we're in a RenderPass, returning true if so. Updates serial internally.
+ // Returns the started command buffer in commandBufferOut.
+ bool appendToStartedRenderPass(RendererVk *renderer, CommandBuffer **commandBufferOut);
// Accessor for RenderPass RenderArea.
const gl::Rectangle &getRenderPassRenderArea() const;
@@ -82,6 +79,13 @@
// Allocates a new write node and calls onWriteResource internally.
CommandGraphNode *getNewWritingNode(RendererVk *renderer);
+ // Checks if we're in a RenderPass without children.
+ bool hasStartedRenderPass() const;
+
+ // Updates the in-use serial tracked for this resource. Will clear dependencies if the resource
+ // was not used in this set of command nodes.
+ void updateQueueSerial(Serial queueSerial);
+
Serial mStoredQueueSerial;
std::vector<CommandGraphNode *> mCurrentReadingNodes;
CommandGraphNode *mCurrentWritingNode;
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index 9a4de3f..eb9a722 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -659,14 +659,10 @@
vk::RecordingMode *modeOut)
{
RendererVk *renderer = contextVk->getRenderer();
- Serial currentSerial = renderer->getCurrentQueueSerial();
// This will clear the current write operation if it is complete.
- updateQueueSerial(currentSerial);
-
- if (hasStartedRenderPass())
+ if (appendToStartedRenderPass(renderer, commandBufferOut))
{
- appendToRenderPass(commandBufferOut);
*modeOut = vk::RecordingMode::Append;
return gl::NoError();
}
diff --git a/src/libANGLE/renderer/vulkan/TextureVk.cpp b/src/libANGLE/renderer/vulkan/TextureVk.cpp
index 742a399..724c69d 100644
--- a/src/libANGLE/renderer/vulkan/TextureVk.cpp
+++ b/src/libANGLE/renderer/vulkan/TextureVk.cpp
@@ -553,7 +553,6 @@
vk::Error TextureVk::getCommandBufferForWrite(RendererVk *renderer,
vk::CommandBuffer **commandBufferOut)
{
- updateQueueSerial(renderer->getCurrentQueueSerial());
ANGLE_TRY(appendWriteResource(renderer, commandBufferOut));
return vk::NoError();
}