| 1 |
/* |
| 2 |
* Copyright 2016 Google Inc. |
| 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 GrVkPipeline_DEFINED |
| 9 |
#define GrVkPipeline_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkRefCnt.h" |
| 12 |
#include "include/private/base/SkAssert.h" |
| 13 |
#include "include/private/base/SkDebug.h" |
| 14 |
#include "include/private/gpu/vk/SkiaVulkan.h" |
| 15 |
#include "src/gpu/ganesh/GrGeometryProcessor.h" |
| 16 |
#include "src/gpu/ganesh/GrManagedResource.h" |
| 17 |
#include "src/gpu/ganesh/vk/GrVkManagedResource.h" |
| 18 |
|
| 19 |
#include <cinttypes> |
| 20 |
#include <cstdint> |
| 21 |
|
| 22 |
class GrProgramInfo; |
| 23 |
class GrStencilSettings; |
| 24 |
class GrVkCommandBuffer; |
| 25 |
class GrVkGpu; |
| 26 |
class GrXferProcessor; |
| 27 |
enum GrSurfaceOrigin : int; |
| 28 |
enum class GrPrimitiveType : uint8_t; |
| 29 |
struct SkIRect; |
| 30 |
struct SkISize; |
| 31 |
|
| 32 |
namespace skgpu { |
| 33 |
class Swizzle; |
| 34 |
struct BlendInfo; |
| 35 |
} // namespace skgpu |
| 36 |
|
| 37 |
class GrVkPipeline : public GrVkManagedResource { |
| 38 |
public: |
| 39 |
static sk_sp<GrVkPipeline> Make(GrVkGpu*, |
| 40 |
const GrGeometryProcessor::AttributeSet& vertexAttribs, |
| 41 |
const GrGeometryProcessor::AttributeSet& instanceAttribs, |
| 42 |
GrPrimitiveType, |
| 43 |
GrSurfaceOrigin, |
| 44 |
const GrStencilSettings&, |
| 45 |
int numSamples, |
| 46 |
bool isHWAntialiasState, |
| 47 |
const skgpu::BlendInfo&, |
| 48 |
bool isWireframe, |
| 49 |
bool useConservativeRaster, |
| 50 |
uint32_t subpass, |
| 51 |
VkPipelineShaderStageCreateInfo* shaderStageInfo, |
| 52 |
int shaderStageCount, |
| 53 |
VkRenderPass compatibleRenderPass, |
| 54 |
VkPipelineLayout layout, |
| 55 |
bool ownsLayout, |
| 56 |
VkPipelineCache cache); |
| 57 |
|
| 58 |
static sk_sp<GrVkPipeline> Make(GrVkGpu*, |
| 59 |
const GrProgramInfo&, |
| 60 |
VkPipelineShaderStageCreateInfo* shaderStageInfo, |
| 61 |
int shaderStageCount, |
| 62 |
VkRenderPass compatibleRenderPass, |
| 63 |
VkPipelineLayout layout, |
| 64 |
VkPipelineCache cache, |
| 65 |
uint32_t subpass); |
| 66 |
|
| 67 |
VkPipeline pipeline() const { return fPipeline; } |
| 68 |
VkPipelineLayout layout() const { |
| 69 |
SkASSERT(fPipelineLayout != VK_NULL_HANDLE); |
| 70 |
return fPipelineLayout; |
| 71 |
} |
| 72 |
|
| 73 |
static void SetDynamicScissorRectState(GrVkGpu*, |
| 74 |
GrVkCommandBuffer*, |
| 75 |
SkISize colorAttachmentDimensions, |
| 76 |
GrSurfaceOrigin, const SkIRect& scissorRect); |
| 77 |
static void SetDynamicViewportState(GrVkGpu*, |
| 78 |
GrVkCommandBuffer*, |
| 79 |
SkISize colorAttachmentDimensions); |
| 80 |
static void SetDynamicBlendConstantState(GrVkGpu*, |
| 81 |
GrVkCommandBuffer*, |
| 82 |
const skgpu::Swizzle& writeSwizzle, |
| 83 |
const GrXferProcessor&); |
| 84 |
|
| 85 |
#ifdef SK_TRACE_MANAGED_RESOURCES |
| 86 |
void dumpInfo() const override { |
| 87 |
SkDebugf("GrVkPipeline: %" PRIdPTR " (%d refs)\n", (intptr_t)fPipeline, this->getRefCnt()); |
| 88 |
} |
| 89 |
#endif |
| 90 |
|
| 91 |
protected: |
| 92 |
GrVkPipeline(const GrVkGpu* gpu, VkPipeline pipeline, VkPipelineLayout layout) |
| 93 |
: INHERITED(gpu), fPipeline(pipeline), fPipelineLayout(layout) {} |
| 94 |
|
| 95 |
VkPipeline fPipeline; |
| 96 |
VkPipelineLayout fPipelineLayout; |
| 97 |
|
| 98 |
private: |
| 99 |
void freeGPUData() const override; |
| 100 |
|
| 101 |
using INHERITED = GrVkManagedResource; |
| 102 |
}; |
| 103 |
|
| 104 |
#endif |