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