Chromium Code Reviews| Index: src/gpu/vk/GrVkResourceProvider.h |
| diff --git a/src/gpu/vk/GrVkResourceProvider.h b/src/gpu/vk/GrVkResourceProvider.h |
| index 37ec6fdee5160b47f1fe2529bbe785e291ff7e05..3468859a24239fcb2f8492a56b79c920ca07936b 100644 |
| --- a/src/gpu/vk/GrVkResourceProvider.h |
| +++ b/src/gpu/vk/GrVkResourceProvider.h |
| @@ -9,6 +9,7 @@ |
| #define GrVkResourceProvider_DEFINED |
| #include "GrGpu.h" |
| +#include "GrResourceHandle.h" |
| #include "GrVkDescriptorPool.h" |
| #include "GrVkPipelineState.h" |
| #include "GrVkResource.h" |
| @@ -46,9 +47,33 @@ public: |
| const GrVkRenderPass& renderPass, |
| VkPipelineLayout layout); |
| + GR_DEFINE_RESOURCE_HANDLE_CLASS(CompatibleRPHandle); |
| + |
| // Finds or creates a simple render pass that matches the target, increments the refcount, |
| - // and returns. |
| - const GrVkRenderPass* findOrCreateCompatibleRenderPass(const GrVkRenderTarget& target); |
| + // and returns. The caller can optionally pass in a pointer to a CompatibleRPHandle. If this is |
| + // non null it will be set to a handle that can be used in the furutre to quickly return a |
| + // compatible GrVkRenderPasses without the need inspecting a GrVkRenderTarget. |
| + const GrVkRenderPass* findCompatibleRenderPass(const GrVkRenderTarget& target, |
| + CompatibleRPHandle* compatibleHandle = nullptr); |
| + // The CompatibleRPHandle must be a valid handle previously set by a call to |
| + // findCompatibleRenderPass(GrVkRenderTarget&, CompatibleRPHandle*). |
| + const GrVkRenderPass* findCompatibleRenderPass(const CompatibleRPHandle& compatibleHandle); |
| + |
| +#if 0 |
| + // TODO: |
| + const GrVkRenderPass* findRenderPass(const GrVkRenderTarget& target, |
| + VkAttachmentLoadOp colorLoad, |
| + VkAttachmentStoreOp colorStore, |
| + VkAttachmentLoadOp stencilLoad, |
| + VkAttachmentStoreOp stencilStore, |
| + CompatibleRPHandle* compatibleHandle = nullptr); |
| + |
| + const GrVkRenderPass* findRenderPass(const CompatibleRPHandle& compatibleHandle, |
| + VkAttachmentLoadOp colorLoad, |
| + VkAttachmentStoreOp colorStore, |
| + VkAttachmentLoadOp stencilLoad, |
| + VkAttachmentStoreOp stencilStore); |
| +#endif |
| GrVkCommandBuffer* createCommandBuffer(); |
| void checkCommandBuffers(); |
| @@ -94,7 +119,6 @@ public: |
| void abandonResources(); |
| private: |
| - |
| #ifdef SK_DEBUG |
| #define GR_PIPELINE_STATE_CACHE_STATS |
| #endif |
| @@ -134,6 +158,39 @@ private: |
| #endif |
| }; |
| + |
| + class CompatibleRenderPassSet { |
| + public: |
| + // This will always construct the basic load store render pass so that there is at least |
| + // one compatible VkRenderPass that can be used with this set. |
| + CompatibleRenderPassSet(const GrVkGpu* gpu, const GrVkRenderTarget& target); |
| + |
| + bool isCompatible(const GrVkRenderTarget& target) const; |
| + |
| + GrVkRenderPass* getCompatibleRenderPass() const { |
| + SkASSERT(fRenderPasses[kLoadStore_LoadStoreOp]) |
| + return fRenderPasses[kLoadStore_LoadStoreOp]; |
| + } |
| + |
| + void releaseResources(const GrVkGpu* gpu); |
| + void abandonResources(); |
| + |
| + private: |
| + enum LoadStoreOp { |
| + kLoadStore_LoadStoreOp, |
| + kDCStore_LoadStoreOp, |
|
jvanverth1
2016/05/18 20:42:21
It would be clearer to write out DontCare or Disca
egdaniel
2016/06/02 17:26:25
Removed enum.
|
| + kClearStore_LoadStoreOp, |
| + kLoadDC_LoadStoreOp, |
| + kDCDC_LoadStoreOp, |
| + kClearDC_LoadStoreOp, |
| + |
| + kLast_LoadStoreOp = kClearDC_LoadStoreOp |
| + }; |
| + static const int kLoadStoreOpCount = kLast_LoadStoreOp + 1; |
| + |
| + GrVkRenderPass* fRenderPasses[kLoadStoreOpCount]; |
| + }; |
| + |
| // Initialiaze the vkDescriptorSetLayout used for allocating new uniform buffer descritpor sets. |
| void initUniformDescObjects(); |
| @@ -142,9 +199,7 @@ private: |
| // Central cache for creating pipelines |
| VkPipelineCache fPipelineCache; |
| - // Array of RenderPasses that only have a single color attachment, optional stencil attachment, |
| - // optional resolve attachment, and only one subpass |
| - SkSTArray<4, GrVkRenderPass*> fSimpleRenderPasses; |
| + SkSTArray<4, CompatibleRenderPassSet> fRenderPassArray; |
| // Array of CommandBuffers that are currently in flight |
| SkSTArray<4, GrVkCommandBuffer*> fActiveCommandBuffers; |