Commit 5dca651f by Jamie Madill Committed by Commit Bot

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/1066554Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent dc0daf8b
......@@ -192,8 +192,6 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk,
// 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));
......
......@@ -179,6 +179,8 @@ Error CommandGraphResource::beginWriteResource(RendererVk *renderer,
Error CommandGraphResource::appendWriteResource(RendererVk *renderer,
CommandBuffer **commandBufferOut)
{
updateQueueSerial(renderer->getCurrentQueueSerial());
if (!hasChildlessWritingNode())
{
return beginWriteResource(renderer, commandBufferOut);
......@@ -198,10 +200,19 @@ Error CommandGraphResource::appendWriteResource(RendererVk *renderer,
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
......
......@@ -31,7 +31,6 @@ class CommandGraphResource
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 @@ class CommandGraphResource
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 @@ class CommandGraphResource
// 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;
......
......@@ -659,14 +659,10 @@ gl::Error FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk,
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();
}
......
......@@ -553,7 +553,6 @@ gl::Error TextureVk::copySubImageImpl(const gl::Context *context,
vk::Error TextureVk::getCommandBufferForWrite(RendererVk *renderer,
vk::CommandBuffer **commandBufferOut)
{
updateQueueSerial(renderer->getCurrentQueueSerial());
ANGLE_TRY(appendWriteResource(renderer, commandBufferOut));
return vk::NoError();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment