Chromium Code Reviews| Index: src/gpu/vk/GrVkCommandBuffer.h |
| diff --git a/src/gpu/vk/GrVkCommandBuffer.h b/src/gpu/vk/GrVkCommandBuffer.h |
| index b513a47f29b6aef935a002ad28fd9d69aacd5778..a287e78d7ecc1d6470ed6812b0d27a30243a5167 100644 |
| --- a/src/gpu/vk/GrVkCommandBuffer.h |
| +++ b/src/gpu/vk/GrVkCommandBuffer.h |
| @@ -13,6 +13,7 @@ |
| #include "GrVkUtil.h" |
| #include "vk/GrVkDefines.h" |
| +class GrVkFramebuffer; |
| class GrVkPipeline; |
| class GrVkRenderPass; |
| class GrVkRenderTarget; |
| @@ -20,24 +21,10 @@ class GrVkTransferBuffer; |
| class GrVkCommandBuffer : public GrVkResource { |
| public: |
| - static GrVkCommandBuffer* Create(const GrVkGpu* gpu, VkCommandPool cmdPool); |
| ~GrVkCommandBuffer() override; |
| - void begin(const GrVkGpu* gpu); |
| - void end(const GrVkGpu* gpu); |
| - |
| void invalidateState(); |
| - // Begins render pass on this command buffer. The framebuffer from GrVkRenderTarget will be used |
| - // in the render pass. |
| - void beginRenderPass(const GrVkGpu* gpu, |
| - const GrVkRenderPass* renderPass, |
| - const GrVkRenderTarget& target); |
| - void endRenderPass(const GrVkGpu* gpu); |
| - |
| - void submitToQueue(const GrVkGpu* gpu, VkQueue queue, GrVkGpu::SyncQueue sync); |
| - bool finished(const GrVkGpu* gpu) const; |
| - |
| //////////////////////////////////////////////////////////////////////////// |
| // CommandBuffer commands |
| //////////////////////////////////////////////////////////////////////////// |
| @@ -105,6 +92,95 @@ public: |
| void setBlendConstants(const GrVkGpu* gpu, const float blendConstants[4]); |
| + // Commands that only work inside of a render pass |
| + void clearAttachments(const GrVkGpu* gpu, |
| + int numAttachments, |
| + const VkClearAttachment* attachments, |
| + int numRects, |
| + const VkClearRect* clearRects) const; |
| + |
| + void drawIndexed(const GrVkGpu* gpu, |
| + uint32_t indexCount, |
| + uint32_t instanceCount, |
| + uint32_t firstIndex, |
| + int32_t vertexOffset, |
| + uint32_t firstInstance) const; |
| + |
| + void draw(const GrVkGpu* gpu, |
| + uint32_t vertexCount, |
| + uint32_t instanceCount, |
| + uint32_t firstVertex, |
| + uint32_t firstInstance) const; |
| + |
| + // Add ref-counted resource that will be tracked and released when this |
| + // command buffer finishes execution |
| + void addResource(const GrVkResource* resource) { |
| + resource->ref(); |
| + fTrackedResources.push_back(resource); |
| + } |
| + |
| +protected: |
| + GrVkCommandBuffer(VkCommandBuffer cmdBuffer, const GrVkRenderPass* rp = VK_NULL_HANDLE) |
| + : fTrackedResources(kInitialTrackedResourcesCount) |
| + , fIsActive(false) |
| + , fActiveRenderPass(rp) |
| + , fCmdBuffer(cmdBuffer) |
| + , fSubmitFence(VK_NULL_HANDLE) |
| + , fBoundVertexBufferIsValid(false) |
| + , fBoundIndexBufferIsValid(false) { |
| + this->invalidateState(); |
| + } |
| + SkTArray<const GrVkResource*, true> fTrackedResources; |
| + |
| + // Tracks whether we are in the middle of a command buffer begin/end calls and thus can add |
| + // new commands to the buffer; |
| + bool fIsActive; |
| + |
| + // Stores a pointer to the current active render pass (i.e. begin has been called but not |
| + // end). A nullptr means there is no active render pass. The GrVKCommandBuffer does not own |
| + // the render pass. |
| + const GrVkRenderPass* fActiveRenderPass; |
| + |
| + VkCommandBuffer fCmdBuffer; |
| + VkFence fSubmitFence; |
| + |
| +private: |
| + static const int kInitialTrackedResourcesCount = 32; |
| + |
| + void freeGPUData(const GrVkGpu* gpu) const override; |
| + void abandonSubResources() const override; |
| + |
| + VkBuffer fBoundVertexBuffer; |
| + bool fBoundVertexBufferIsValid; |
| + |
| + VkBuffer fBoundIndexBuffer; |
| + bool fBoundIndexBufferIsValid; |
| + |
| + // Cached values used for dynamic state updates |
| + VkViewport fCachedViewport; |
| + VkRect2D fCachedScissor; |
| + float fCachedBlendConstant[4]; |
| +}; |
| + |
| +class GrVkSecondaryCommandBuffer; |
| + |
| +class GrVkPrimaryCommandBuffer : public GrVkCommandBuffer { |
| +public: |
| + static GrVkPrimaryCommandBuffer* Create(const GrVkGpu* gpu, VkCommandPool cmdPool); |
| + |
| + void begin(const GrVkGpu* gpu); |
| + void end(const GrVkGpu* gpu); |
| + |
| + // Begins render pass on this command buffer. The framebuffer from GrVkRenderTarget will be used |
| + // in the render pass. |
| + void beginRenderPass(const GrVkGpu* gpu, |
| + const GrVkRenderPass* renderPass, |
| + const GrVkRenderTarget& target); |
| + void endRenderPass(const GrVkGpu* gpu); |
| + |
| + void executeCommands(const GrVkGpu* gpu, |
|
jvanverth1
2016/06/01 14:10:46
Where is this defined? Also, maybe appendCommands?
egdaniel
2016/06/01 17:50:49
Sorry the definition happen to be sitting in anoth
|
| + const GrVkSecondaryCommandBuffer* secondaryBuffer); |
| + |
| // Commands that only work outside of a render pass |
| void clearColorImage(const GrVkGpu* gpu, |
| GrVkImage* image, |
| @@ -169,75 +245,30 @@ public: |
| uint32_t copyRegionCount, |
| const VkBufferImageCopy* copyRegions); |
| - // Commands that only work inside of a render pass |
| - void clearAttachments(const GrVkGpu* gpu, |
| - int numAttachments, |
| - const VkClearAttachment* attachments, |
| - int numRects, |
| - const VkClearRect* clearRects) const; |
| - |
| - void drawIndexed(const GrVkGpu* gpu, |
| - uint32_t indexCount, |
| - uint32_t instanceCount, |
| - uint32_t firstIndex, |
| - int32_t vertexOffset, |
| - uint32_t firstInstance) const; |
| - |
| - void draw(const GrVkGpu* gpu, |
| - uint32_t vertexCount, |
| - uint32_t instanceCount, |
| - uint32_t firstVertex, |
| - uint32_t firstInstance) const; |
| - |
| - // Add ref-counted resource that will be tracked and released when this |
| - // command buffer finishes execution |
| - void addResource(const GrVkResource* resource) { |
| - resource->ref(); |
| - fTrackedResources.push_back(resource); |
| - } |
| + void submitToQueue(const GrVkGpu* gpu, VkQueue queue, GrVkGpu::SyncQueue sync); |
| + bool finished(const GrVkGpu* gpu) const; |
| private: |
| - static const int kInitialTrackedResourcesCount = 32; |
| - |
| - explicit GrVkCommandBuffer(VkCommandBuffer cmdBuffer) |
| - : fTrackedResources(kInitialTrackedResourcesCount) |
| - , fCmdBuffer(cmdBuffer) |
| - , fSubmitFence(VK_NULL_HANDLE) |
| - , fBoundVertexBufferIsValid(false) |
| - , fBoundIndexBufferIsValid(false) |
| - , fIsActive(false) |
| - , fActiveRenderPass(nullptr) { |
| - this->invalidateState(); |
| - } |
| - |
| - void freeGPUData(const GrVkGpu* gpu) const override; |
| - void abandonSubResources() const override; |
| - |
| - SkTArray<const GrVkResource*, true> fTrackedResources; |
| + explicit GrVkPrimaryCommandBuffer(VkCommandBuffer cmdBuffer) : INHERITED(cmdBuffer) {} |
| - VkCommandBuffer fCmdBuffer; |
| - VkFence fSubmitFence; |
| - |
| - VkBuffer fBoundVertexBuffer; |
| - bool fBoundVertexBufferIsValid; |
| + typedef GrVkCommandBuffer INHERITED; |
| +}; |
| - VkBuffer fBoundIndexBuffer; |
| - bool fBoundIndexBufferIsValid; |
| +class GrVkSecondaryCommandBuffer : public GrVkCommandBuffer { |
| +public: |
| + static GrVkSecondaryCommandBuffer* Create(const GrVkGpu* gpu, VkCommandPool cmdPool, |
| + const GrVkRenderPass* compatibleRenderPass); |
| - // Tracks whether we are in the middle of a command buffer begin/end calls and thus can add new |
| - // commands to the buffer; |
| - bool fIsActive; |
| + void begin(const GrVkGpu* gpu, const GrVkFramebuffer* framebuffer); |
| + void end(const GrVkGpu* gpu); |
| - // Stores a pointer to the current active render pass (i.e. begin has been called but not end). |
| - // A nullptr means there is no active render pass. The GrVKCommandBuffer does not own the render |
| - // pass. |
| - const GrVkRenderPass* fActiveRenderPass; |
| +private: |
| + explicit GrVkSecondaryCommandBuffer(VkCommandBuffer cmdBuffer, |
| + const GrVkRenderPass* compatibleRenderPass) |
| + : INHERITED(cmdBuffer, compatibleRenderPass) { |
| + } |
| - // Cached values used for dynamic state updates |
| - VkViewport fCachedViewport; |
| - VkRect2D fCachedScissor; |
| - float fCachedBlendConstant[4]; |
| + typedef GrVkCommandBuffer INHERITED; |
| }; |
| - |
| #endif |