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