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