Chromium Code Reviews| Index: src/gpu/vk/GrVkResourceProvider.h |
| diff --git a/src/gpu/vk/GrVkResourceProvider.h b/src/gpu/vk/GrVkResourceProvider.h |
| index 66a2556a9398ba7e9cfa8e8f1a48875072406456..2cd293e760ba78ecd8a4bc467884bd6ae520b317 100644 |
| --- a/src/gpu/vk/GrVkResourceProvider.h |
| +++ b/src/gpu/vk/GrVkResourceProvider.h |
| @@ -8,7 +8,9 @@ |
| #ifndef GrVkResourceProvider_DEFINED |
| #define GrVkResourceProvider_DEFINED |
| +#include "GrGpu.h" |
| #include "GrVkDescriptorPool.h" |
| +#include "GrVkProgram.h" |
| #include "GrVkResource.h" |
| #include "GrVkUtil.h" |
| #include "SkTArray.h" |
| @@ -61,6 +63,11 @@ public: |
| // The refcount is incremented and a pointer returned. |
| GrVkSampler* findOrCreateCompatibleSampler(const GrTextureParams&); |
| + GrVkProgram* findOrCreateCompatibleProgram(const GrPipeline&, |
| + const GrPrimitiveProcessor&, |
| + GrPrimitiveType, |
| + const GrVkRenderPass& renderPass); |
| + |
| // Destroy any cached resources. To be called before destroying the VkDevice. |
| // The assumption is that all queues are idle and all command buffers are finished. |
| // For resource tracing to work properly, this should be called after unrefing all other |
| @@ -73,6 +80,54 @@ public: |
| void abandonResources(); |
| private: |
| + class ProgramCache : public ::SkNoncopyable { |
| + public: |
| + // typedef GrGpu::DrawArgs DrawArgs; |
|
jvanverth1
2016/03/21 21:16:16
Still need this?
egdaniel
2016/03/22 20:06:14
deleted
|
| + |
| + ProgramCache(GrVkGpu* gpu); |
| + ~ProgramCache(); |
| + |
| + void abandon(); |
| + void release(); |
| + GrVkProgram* refProgram(const GrPipeline&, |
| + const GrPrimitiveProcessor&, |
| + GrPrimitiveType, |
| + const GrVkRenderPass& renderPass); |
| + |
| + private: |
| + enum { |
| + // We may actually have kMaxEntries+1 shaders in the GL context because we create a new |
|
jvanverth1
2016/03/21 21:16:16
GL? And are these values good for Vulkan?
egdaniel
2016/03/21 22:23:52
When I previously looked at the cache stats we wer
bsalomon
2016/03/22 14:00:33
At various times in the past this was tuned to imp
egdaniel
2016/03/22 20:06:14
Fixed comment. For now my rough testing shows dece
|
| + // shader before evicting from the cache. |
| + kMaxEntries = 128, |
| + kHashBits = 6, |
| + }; |
| + |
| + struct Entry; |
| + |
| + struct PipelineDescLess; |
| + |
| + void reset(); |
| + |
| + // binary search for entry matching desc. returns index into fEntries that matches desc or ~ |
| + // of the index of where it should be inserted. |
| + int search(const GrVkProgram::PipelineDesc& desc) const; |
| + |
| + // sorted array of all the entries |
| + Entry* fEntries[kMaxEntries]; |
| + // hash table based on lowest kHashBits bits of the program key. Used to avoid binary |
| + // searching fEntries. |
| + Entry* fHashTable[1 << kHashBits]; |
| + |
| + int fCount; |
| + unsigned int fCurrLRUStamp; |
| + GrVkGpu* fGpu; |
| +#ifdef PROGRAM_CACHE_STATS |
| + int fTotalRequests; |
| + int fCacheMisses; |
| + int fHashMisses; // cache hit but hash table missed |
| +#endif |
| + }; |
| + |
| GrVkGpu* fGpu; |
| // Central cache for creating pipelines |
| @@ -80,7 +135,7 @@ private: |
| // 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, GrVkRenderPass*> fSimpleRenderPasses; |
| // Array of CommandBuffers that are currently in flight |
| SkSTArray<4, GrVkCommandBuffer*> fActiveCommandBuffers; |
| @@ -88,6 +143,9 @@ private: |
| // Stores GrVkSampler objects that we've already created so we can reuse them across multiple |
| // programs |
| SkTDynamicHash<GrVkSampler, uint8_t> fSamplers; |
| + |
| + // Cache of GrVkPrograms |
| + ProgramCache* fProgramCache; |
| }; |
| #endif |