Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: src/gpu/vk/GrVkResourceProvider.h

Issue 1977403002: Refactor creation of GrVkRenderPasses to make them move general (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review nits Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkRenderTarget.cpp ('k') | src/gpu/vk/GrVkResourceProvider.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkResourceProvider.h
diff --git a/src/gpu/vk/GrVkResourceProvider.h b/src/gpu/vk/GrVkResourceProvider.h
index 37ec6fdee5160b47f1fe2529bbe785e291ff7e05..5368a212b4563fa1cd9cc248b94d2cec470a234e 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,31 @@ private:
#endif
};
+
+ class CompatibleRenderPassSet {
+ public:
+ // This will always construct the basic load store render pass (all attachments load and
+ // store their data) 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 {
+ // The first GrVkRenderpass should always exist since we create the basic load store
+ // render pass on create
+ SkASSERT(fRenderPasses[0]);
+ return fRenderPasses[0];
+ }
+
+ void releaseResources(const GrVkGpu* gpu);
+ void abandonResources();
+
+ private:
+ SkSTArray<4, GrVkRenderPass*> fRenderPasses;
+ int fLastReturnedIndex;
+ };
+
// Initialiaze the vkDescriptorSetLayout used for allocating new uniform buffer descritpor sets.
void initUniformDescObjects();
@@ -142,9 +191,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;
« no previous file with comments | « src/gpu/vk/GrVkRenderTarget.cpp ('k') | src/gpu/vk/GrVkResourceProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698