Commit c8a7c033 by Jamie Madill Committed by Commit Bot

Vulkan: Move primary command buffer to CommandQueue.

This brings CommandQueue one step closer to the worker thread. Bug: b/172704839 Change-Id: I35225c5f302e34e3feb38a35c22b6d8e6f4ad10c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2524543Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 580b775f
...@@ -46,23 +46,19 @@ class CommandQueue final : angle::NonCopyable ...@@ -46,23 +46,19 @@ class CommandQueue final : angle::NonCopyable
bool hasInFlightCommands() const; bool hasInFlightCommands() const;
angle::Result allocatePrimaryCommandBuffer(vk::Context *context,
vk::PrimaryCommandBuffer *commandBufferOut);
angle::Result releasePrimaryCommandBuffer(vk::Context *context,
vk::PrimaryCommandBuffer &&commandBuffer);
void clearAllGarbage(RendererVk *renderer); void clearAllGarbage(RendererVk *renderer);
angle::Result finishToSerial(vk::Context *context, Serial finishSerial, uint64_t timeout); angle::Result finishToSerial(vk::Context *context, Serial finishSerial, uint64_t timeout);
angle::Result submitFrame(vk::Context *context, angle::Result submitFrame(vk::Context *context,
egl::ContextPriority priority, egl::ContextPriority priority,
const VkSubmitInfo &submitInfo, const std::vector<VkSemaphore> &waitSemaphores,
const std::vector<VkPipelineStageFlags> &waitSemaphoreStageMasks,
const vk::Semaphore *signalSemaphore,
const vk::Shared<vk::Fence> &sharedFence, const vk::Shared<vk::Fence> &sharedFence,
vk::ResourceUseList *resourceList, vk::ResourceUseList *resourceList,
vk::GarbageList *currentGarbage, vk::GarbageList *currentGarbage,
vk::CommandPool *commandPool, vk::CommandPool *commandPool);
vk::PrimaryCommandBuffer &&commandBuffer);
vk::Shared<vk::Fence> getLastSubmittedFence(const vk::Context *context) const; vk::Shared<vk::Fence> getLastSubmittedFence(const vk::Context *context) const;
...@@ -71,17 +67,33 @@ class CommandQueue final : angle::NonCopyable ...@@ -71,17 +67,33 @@ class CommandQueue final : angle::NonCopyable
// result). It would be nice if we didn't have to expose this for QueryVk::getResult. // result). It would be nice if we didn't have to expose this for QueryVk::getResult.
angle::Result checkCompletedCommands(vk::Context *context); angle::Result checkCompletedCommands(vk::Context *context);
angle::Result flushOutsideRPCommands(vk::Context *context,
vk::CommandBufferHelper *outsideRPCommands);
angle::Result flushRenderPassCommands(vk::Context *context,
const vk::RenderPass &renderPass,
vk::CommandBufferHelper *renderPassCommands);
// TODO(jmadill): Remove this. b/172704839
bool hasPrimaryCommands() const { return mPrimaryCommands.valid(); }
private: private:
angle::Result releaseToCommandBatch(vk::Context *context, angle::Result releaseToCommandBatch(vk::Context *context,
vk::PrimaryCommandBuffer &&commandBuffer, vk::PrimaryCommandBuffer &&commandBuffer,
vk::CommandPool *commandPool, vk::CommandPool *commandPool,
vk::CommandBatch *batch); vk::CommandBatch *batch);
angle::Result retireFinishedCommands(vk::Context *context, size_t finishedCount); angle::Result retireFinishedCommands(vk::Context *context, size_t finishedCount);
angle::Result startPrimaryCommandBuffer(vk::Context *context);
angle::Result allocatePrimaryCommandBuffer(vk::Context *context,
vk::PrimaryCommandBuffer *commandBufferOut);
angle::Result releasePrimaryCommandBuffer(vk::Context *context,
vk::PrimaryCommandBuffer &&commandBuffer);
vk::GarbageQueue mGarbageQueue; vk::GarbageQueue mGarbageQueue;
std::vector<vk::CommandBatch> mInFlightCommands; std::vector<vk::CommandBatch> mInFlightCommands;
// Keeps a free list of reusable primary command buffers. // Keeps a free list of reusable primary command buffers.
vk::PrimaryCommandBuffer mPrimaryCommands;
vk::PersistentCommandPool mPrimaryCommandPool; vk::PersistentCommandPool mPrimaryCommandPool;
}; };
...@@ -922,9 +934,8 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -922,9 +934,8 @@ class ContextVk : public ContextImpl, public vk::Context
void writeAtomicCounterBufferDriverUniformOffsets(uint32_t *offsetsOut, size_t offsetsSize); void writeAtomicCounterBufferDriverUniformOffsets(uint32_t *offsetsOut, size_t offsetsSize);
angle::Result submitFrame(const VkSubmitInfo &submitInfo, angle::Result submitFrame(const vk::Semaphore *signalSemaphore,
vk::ResourceUseList *resourceList, vk::ResourceUseList *resourceList);
vk::PrimaryCommandBuffer &&commandBuffer);
angle::Result memoryBarrierImpl(GLbitfield barriers, VkPipelineStageFlags stageMask); angle::Result memoryBarrierImpl(GLbitfield barriers, VkPipelineStageFlags stageMask);
angle::Result synchronizeCpuGpuTime(); angle::Result synchronizeCpuGpuTime();
...@@ -939,7 +950,6 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -939,7 +950,6 @@ class ContextVk : public ContextImpl, public vk::Context
bool shouldUseOldRewriteStructSamplers() const; bool shouldUseOldRewriteStructSamplers() const;
void clearAllGarbage(); void clearAllGarbage();
angle::Result ensureSubmitFenceInitialized(); angle::Result ensureSubmitFenceInitialized();
angle::Result startPrimaryCommandBuffer();
bool hasRecordedCommands(); bool hasRecordedCommands();
void dumpCommandStreamDiagnostics(); void dumpCommandStreamDiagnostics();
angle::Result flushOutsideRenderPassCommands(); angle::Result flushOutsideRenderPassCommands();
...@@ -1117,9 +1127,6 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -1117,9 +1127,6 @@ class ContextVk : public ContextImpl, public vk::Context
vk::CommandBufferHelper *mOutsideRenderPassCommands; vk::CommandBufferHelper *mOutsideRenderPassCommands;
vk::CommandBufferHelper *mRenderPassCommands; vk::CommandBufferHelper *mRenderPassCommands;
vk::PrimaryCommandBuffer mPrimaryCommands;
// Function recycleCommandBuffer() is public above
bool mHasPrimaryCommands;
// Transform feedback buffers. // Transform feedback buffers.
angle::FastUnorderedSet<const vk::BufferHelper *, angle::FastUnorderedSet<const vk::BufferHelper *,
......
...@@ -1250,20 +1250,9 @@ void CommandBufferHelper::invalidateRenderPassStencilAttachment( ...@@ -1250,20 +1250,9 @@ void CommandBufferHelper::invalidateRenderPassStencilAttachment(
ExtendRenderPassInvalidateArea(invalidateArea, &mStencilInvalidateArea); ExtendRenderPassInvalidateArea(invalidateArea, &mStencilInvalidateArea);
} }
angle::Result CommandBufferHelper::getRenderPassWithOps(ContextVk *contextVk,
RenderPass **renderPass)
{
*renderPass = nullptr;
if (mIsRenderPassCommandBuffer)
{
ANGLE_TRY(contextVk->getRenderPassWithOps(mRenderPassDesc, mAttachmentOps, renderPass));
}
return angle::Result::Continue;
}
angle::Result CommandBufferHelper::flushToPrimary(const angle::FeaturesVk &features, angle::Result CommandBufferHelper::flushToPrimary(const angle::FeaturesVk &features,
PrimaryCommandBuffer *primary, PrimaryCommandBuffer *primary,
RenderPass *renderPass) const RenderPass *renderPass)
{ {
ANGLE_TRACE_EVENT0("gpu.angle", "CommandBufferHelper::flushToPrimary"); ANGLE_TRACE_EVENT0("gpu.angle", "CommandBufferHelper::flushToPrimary");
ASSERT(!empty()); ASSERT(!empty());
......
...@@ -954,10 +954,9 @@ class CommandBufferHelper : angle::NonCopyable ...@@ -954,10 +954,9 @@ class CommandBufferHelper : angle::NonCopyable
CommandBuffer &getCommandBuffer() { return mCommandBuffer; } CommandBuffer &getCommandBuffer() { return mCommandBuffer; }
angle::Result getRenderPassWithOps(ContextVk *contextVk, RenderPass **renderPass);
angle::Result flushToPrimary(const angle::FeaturesVk &features, angle::Result flushToPrimary(const angle::FeaturesVk &features,
PrimaryCommandBuffer *primary, PrimaryCommandBuffer *primary,
RenderPass *renderPass); const RenderPass *renderPass);
void executeBarriers(const angle::FeaturesVk &features, PrimaryCommandBuffer *primary); void executeBarriers(const angle::FeaturesVk &features, PrimaryCommandBuffer *primary);
...@@ -1103,6 +1102,9 @@ class CommandBufferHelper : angle::NonCopyable ...@@ -1103,6 +1102,9 @@ class CommandBufferHelper : angle::NonCopyable
void addCommandDiagnostics(ContextVk *contextVk); void addCommandDiagnostics(ContextVk *contextVk);
const RenderPassDesc &getRenderPassDesc() const { return mRenderPassDesc; }
const AttachmentOpsArray &getAttachmentOps() const { return mAttachmentOps; }
private: private:
bool onDepthStencilAccess(ResourceAccess access, bool onDepthStencilAccess(ResourceAccess access,
uint32_t *cmdCountInvalidated, uint32_t *cmdCountInvalidated,
......
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