Flutter Engine
The Flutter Engine
MtlGraphicsPipeline.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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_MtlGraphicsPipeline_DEFINED
9#define skgpu_graphite_MtlGraphicsPipeline_DEFINED
10
12#include "include/core/SkSpan.h"
15#include <memory>
16
17#import <Metal/Metal.h>
18
19namespace skgpu {
20struct BlendInfo;
21}
22
23namespace skgpu::graphite {
24
25class Attribute;
26class Context;
27class GraphicsPipelineDesc;
28class MtlResourceProvider;
29class MtlSharedContext;
30struct RenderPassDesc;
31
33public:
34 inline static constexpr unsigned int kIntrinsicUniformBufferIndex = 0;
35 inline static constexpr unsigned int kRenderStepUniformBufferIndex = 1;
36 inline static constexpr unsigned int kPaintUniformBufferIndex = 2;
37 inline static constexpr unsigned int kVertexBufferIndex = 3;
38 inline static constexpr unsigned int kInstanceBufferIndex = 4;
39 inline static constexpr unsigned int kGradientBufferIndex = 5;
40
41 using MSLFunction = std::pair<id<MTLLibrary>, std::string>;
43 const std::string& label,
44 MSLFunction vertexMain,
45 SkSpan<const Attribute> vertexAttrs,
46 SkSpan<const Attribute> instanceAttrs,
47 MSLFunction fragmentMain,
48 sk_cfp<id<MTLDepthStencilState>>,
49 uint32_t stencilRefValue,
50 const BlendInfo& blendInfo,
51 const RenderPassDesc&,
52 PipelineInfo* pipelineInfo);
53
55
56 id<MTLRenderPipelineState> mtlPipelineState() const { return fPipelineState.get(); }
57 id<MTLDepthStencilState> mtlDepthStencilState() const { return fDepthStencilState.get(); }
58 uint32_t stencilReferenceValue() const { return fStencilReferenceValue; }
59
60private:
62 PipelineInfo* pipelineInfo,
63 sk_cfp<id<MTLRenderPipelineState>> pso,
64 sk_cfp<id<MTLDepthStencilState>> dss,
65 uint32_t refValue);
66
67 void freeGpuData() override;
68
69 sk_cfp<id<MTLRenderPipelineState>> fPipelineState;
70 sk_cfp<id<MTLDepthStencilState>> fDepthStencilState;
71 uint32_t fStencilReferenceValue;
72};
73
74} // namespace skgpu::graphite
75
76#endif // skgpu_graphite_MtlGraphicsPipeline_DEFINED
std::pair< id< MTLLibrary >, std::string > MSLFunction
id< MTLDepthStencilState > mtlDepthStencilState() const
static constexpr unsigned int kVertexBufferIndex
static constexpr unsigned int kInstanceBufferIndex
static constexpr unsigned int kPaintUniformBufferIndex
id< MTLRenderPipelineState > mtlPipelineState() const
static constexpr unsigned int kRenderStepUniformBufferIndex
static constexpr unsigned int kIntrinsicUniformBufferIndex
static sk_sp< MtlGraphicsPipeline > Make(const MtlSharedContext *, const std::string &label, MSLFunction vertexMain, SkSpan< const Attribute > vertexAttrs, SkSpan< const Attribute > instanceAttrs, MSLFunction fragmentMain, sk_cfp< id< MTLDepthStencilState > >, uint32_t stencilRefValue, const BlendInfo &blendInfo, const RenderPassDesc &, PipelineInfo *pipelineInfo)
static constexpr unsigned int kGradientBufferIndex
const SharedContext * sharedContext() const
Definition: Resource.h:189
Definition: GpuTools.h:21