| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrVkResourceProvider_DEFINED | 8 #ifndef GrVkResourceProvider_DEFINED |
| 9 #define GrVkResourceProvider_DEFINED | 9 #define GrVkResourceProvider_DEFINED |
| 10 | 10 |
| 11 #include "GrVkDescriptorPool.h" | 11 #include "GrVkDescriptorPool.h" |
| 12 #include "GrVkResource.h" | 12 #include "GrVkResource.h" |
| 13 #include "GrVkUtil.h" | 13 #include "GrVkUtil.h" |
| 14 #include "SkTArray.h" | 14 #include "SkTArray.h" |
| 15 #include "SkTDynamicHash.h" |
| 15 | 16 |
| 16 #include "vulkan/vulkan.h" | 17 #include "vulkan/vulkan.h" |
| 17 | 18 |
| 18 class GrPipeline; | 19 class GrPipeline; |
| 19 class GrPrimitiveProcessor; | 20 class GrPrimitiveProcessor; |
| 21 class GrTextureParams; |
| 20 class GrVkCommandBuffer; | 22 class GrVkCommandBuffer; |
| 21 class GrVkGpu; | 23 class GrVkGpu; |
| 22 class GrVkPipeline; | 24 class GrVkPipeline; |
| 23 class GrVkRenderPass; | 25 class GrVkRenderPass; |
| 24 class GrVkRenderTarget; | 26 class GrVkRenderTarget; |
| 27 class GrVkSampler; |
| 25 | 28 |
| 26 class GrVkResourceProvider { | 29 class GrVkResourceProvider { |
| 27 public: | 30 public: |
| 28 GrVkResourceProvider(GrVkGpu* gpu); | 31 GrVkResourceProvider(GrVkGpu* gpu); |
| 29 ~GrVkResourceProvider(); | 32 ~GrVkResourceProvider(); |
| 30 | 33 |
| 31 // Set up any initial vk objects | 34 // Set up any initial vk objects |
| 32 void init(); | 35 void init(); |
| 33 | 36 |
| 34 GrVkPipeline* createPipeline(const GrPipeline& pipeline, | 37 GrVkPipeline* createPipeline(const GrPipeline& pipeline, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 48 | 51 |
| 49 // Finds or creates a compatible GrVkDescriptorPool for the requested Descri
ptorTypeCount. | 52 // Finds or creates a compatible GrVkDescriptorPool for the requested Descri
ptorTypeCount. |
| 50 // The refcount is incremented and a pointer returned. | 53 // The refcount is incremented and a pointer returned. |
| 51 // TODO: Currently this will just create a descriptor pool without holding o
nto a ref itself | 54 // TODO: Currently this will just create a descriptor pool without holding o
nto a ref itself |
| 52 // so we currently do not reuse them. Rquires knowing if another draw
is currently using | 55 // so we currently do not reuse them. Rquires knowing if another draw
is currently using |
| 53 // the GrVkDescriptorPool, the ability to reset pools, and the ability
to purge pools out | 56 // the GrVkDescriptorPool, the ability to reset pools, and the ability
to purge pools out |
| 54 // of our cache of GrVkDescriptorPools. | 57 // of our cache of GrVkDescriptorPools. |
| 55 GrVkDescriptorPool* findOrCreateCompatibleDescriptorPool( | 58 GrVkDescriptorPool* findOrCreateCompatibleDescriptorPool( |
| 56 const GrVkDescriptorPool::DescriptorType
Counts& typeCounts); | 59 const GrVkDescriptorPool::DescriptorType
Counts& typeCounts); |
| 57 | 60 |
| 61 // Finds or creates a compatible GrVkSampler based on the GrTextureParams. |
| 62 // The refcount is incremented and a pointer returned. |
| 63 GrVkSampler* findOrCreateCompatibleSampler(const GrTextureParams&); |
| 64 |
| 58 // Destroy any cached resources. To be called before destroying the VkDevice
. | 65 // Destroy any cached resources. To be called before destroying the VkDevice
. |
| 59 // The assumption is that all queues are idle and all command buffers are fi
nished. | 66 // The assumption is that all queues are idle and all command buffers are fi
nished. |
| 60 // For resource tracing to work properly, this should be called after unrefi
ng all other | 67 // For resource tracing to work properly, this should be called after unrefi
ng all other |
| 61 // resource usages. | 68 // resource usages. |
| 62 void destroyResources(); | 69 void destroyResources(); |
| 63 | 70 |
| 64 // Abandon any cached resources. To be used when the context/VkDevice is los
t. | 71 // Abandon any cached resources. To be used when the context/VkDevice is los
t. |
| 65 // For resource tracing to work properly, this should be called after unrefi
ng all other | 72 // For resource tracing to work properly, this should be called after unrefi
ng all other |
| 66 // resource usages. | 73 // resource usages. |
| 67 void abandonResources(); | 74 void abandonResources(); |
| 68 | 75 |
| 69 private: | 76 private: |
| 70 GrVkGpu* fGpu; | 77 GrVkGpu* fGpu; |
| 71 | 78 |
| 72 // Central cache for creating pipelines | 79 // Central cache for creating pipelines |
| 73 VkPipelineCache fPipelineCache; | 80 VkPipelineCache fPipelineCache; |
| 74 | 81 |
| 75 // Array of RenderPasses that only have a single color attachment, optional
stencil attachment, | 82 // Array of RenderPasses that only have a single color attachment, optional
stencil attachment, |
| 76 // optional resolve attachment, and only one subpass | 83 // optional resolve attachment, and only one subpass |
| 77 SkSTArray<4, GrVkRenderPass*> fSimpleRenderPasses; | 84 SkSTArray<4, GrVkRenderPass*> fSimpleRenderPasses; |
| 78 | 85 |
| 79 // Array of CommandBuffers that are currently in flight | 86 // Array of CommandBuffers that are currently in flight |
| 80 SkSTArray<4, GrVkCommandBuffer*> fActiveCommandBuffers; | 87 SkSTArray<4, GrVkCommandBuffer*> fActiveCommandBuffers; |
| 88 |
| 89 // Stores GrVkSampler objects that we've already created so we can reuse the
m across multiple |
| 90 // programs |
| 91 SkTDynamicHash<GrVkSampler, uint8_t> fSamplers; |
| 81 }; | 92 }; |
| 82 | 93 |
| 83 #endif | 94 #endif |
| OLD | NEW |