Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
40 using MSLFunction = std::pair<id<MTLLibrary>, std::string>;
42 const std::string& label,
43 MSLFunction vertexMain,
44 SkSpan<const Attribute> vertexAttrs,
45 SkSpan<const Attribute> instanceAttrs,
46 MSLFunction fragmentMain,
47 sk_cfp<id<MTLDepthStencilState>>,
48 uint32_t stencilRefValue,
49 const BlendInfo& blendInfo,
50 const RenderPassDesc&,
51 PipelineInfo* pipelineInfo);
52
54
55 id<MTLRenderPipelineState> mtlPipelineState() const { return fPipelineState.get(); }
56 id<MTLDepthStencilState> mtlDepthStencilState() const { return fDepthStencilState.get(); }
57 uint32_t stencilReferenceValue() const { return fStencilReferenceValue; }
58
59private:
61 PipelineInfo* pipelineInfo,
62 sk_cfp<id<MTLRenderPipelineState>> pso,
63 sk_cfp<id<MTLDepthStencilState>> dss,
64 uint32_t refValue);
65
66 void freeGpuData() override;
67
68 sk_cfp<id<MTLRenderPipelineState>> fPipelineState;
69 sk_cfp<id<MTLDepthStencilState>> fDepthStencilState;
70 uint32_t fStencilReferenceValue;
71};
72
73} // namespace skgpu::graphite
74
75#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)
const SharedContext * sharedContext() const
Definition Resource.h:187