| 1 |
/* |
| 2 |
* Copyright 2023 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef skgpu_graphite_VulkanRenderPass_DEFINED |
| 9 |
#define skgpu_graphite_VulkanRenderPass_DEFINED |
| 10 |
|
| 11 |
#include "src/gpu/graphite/Resource.h" |
| 12 |
|
| 13 |
#include "include/gpu/vk/VulkanTypes.h" |
| 14 |
#include "include/private/base/SkTArray.h" |
| 15 |
#include "src/gpu/graphite/RenderPassDesc.h" |
| 16 |
|
| 17 |
namespace skgpu::graphite { |
| 18 |
|
| 19 |
class VulkanCommandBuffer; |
| 20 |
class VulkanSharedContext; |
| 21 |
|
| 22 |
/** |
| 23 |
* Wrapper around VkRenderPass. |
| 24 |
*/ |
| 25 |
class VulkanRenderPass : public Resource { |
| 26 |
public: |
| 27 |
VkRenderPass renderPass() const { |
| 28 |
SkASSERT(fRenderPass != VK_NULL_HANDLE); |
| 29 |
return fRenderPass; |
| 30 |
} |
| 31 |
|
| 32 |
VkExtent2D granularity() { return fGranularity; } |
| 33 |
|
| 34 |
const char* getResourceType() const override { return "Vulkan RenderPass"; } |
| 35 |
|
| 36 |
// The relevant information in RenderPassDesc to identify a VkRenderPass fits in one uint32. If |
| 37 |
// compatibleForPipelineKey, the load/store ops do not contribute to the key (with the exception |
| 38 |
// of load-from-resolve info if necessary). |
| 39 |
static uint32_t GetRenderPassKey(const RenderPassDesc& renderPassDesc, |
| 40 |
bool compatibleForPipelineKey); |
| 41 |
// A way back from the render pass key to RenderPassDesc. The write swizzle and dst read |
| 42 |
// strategy is not part of the key as calculated by GetRenderPassKey and so must be passed in to |
| 43 |
// reconstruct RenderPassDesc fully. |
| 44 |
static void ExtractRenderPassDesc(uint32_t key, |
| 45 |
Swizzle writeSwizzle, |
| 46 |
DstReadStrategy dstReadStrategy, |
| 47 |
RenderPassDesc* renderPassDesc); |
| 48 |
|
| 49 |
static sk_sp<VulkanRenderPass> Make(const VulkanSharedContext*, const RenderPassDesc&); |
| 50 |
|
| 51 |
private: |
| 52 |
void freeGpuData() override; |
| 53 |
|
| 54 |
VulkanRenderPass(const VulkanSharedContext*, VkRenderPass, VkExtent2D granularity); |
| 55 |
|
| 56 |
const VulkanSharedContext* fSharedContext; |
| 57 |
VkRenderPass fRenderPass; |
| 58 |
VkExtent2D fGranularity; |
| 59 |
}; |
| 60 |
} // namespace skgpu::graphite |
| 61 |
|
| 62 |
#endif // skgpu_graphite_VulkanRenderPass_DEFINED |