Flutter Engine
The Flutter Engine
GrMtlPipelineState.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 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 GrMtlPipelineState_DEFINED
9#define GrMtlPipelineState_DEFINED
10
17
18#import <Metal/Metal.h>
19
21class GrMtlGpu;
25class GrMtlSampler;
26class GrMtlTexture;
27class GrPipeline;
28
29/**
30 * Wraps a MTLRenderPipelineState object and also contains more info about the pipeline as needed
31 * by Ganesh
32 */
34public:
36 using UniformHandle = GrGLSLProgramDataManager::UniformHandle;
37
40 MTLPixelFormat,
41 const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
42 const UniformInfoArray& uniforms,
43 uint32_t uniformBufferSize,
44 uint32_t numSamplers,
45 std::unique_ptr<GrGeometryProcessor::ProgramImpl>,
46 std::unique_ptr<GrXferProcessor::ProgramImpl>,
47 std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls);
48
49 const sk_sp<GrMtlRenderPipeline>& pipeline() const { return fPipeline; }
50
52
54 const GrPipeline&,
55 const GrSurfaceProxy* const geomProcTextures[]);
56 void bindTextures(GrMtlRenderCommandEncoder* renderCmdEncoder);
57
59 const skgpu::Swizzle& writeSwizzle,
60 const GrXferProcessor&);
61
62 static void SetDynamicScissorRectState(GrMtlRenderCommandEncoder* renderCmdEncoder,
63 SkISize colorAttachmentDimensions,
64 GrSurfaceOrigin rtOrigin,
65 SkIRect scissorRect);
66
67 bool doesntSampleAttachment(const MTLRenderPassAttachmentDescriptor*) const;
68
69private:
70 /**
71 * We use the RT's size and origin to adjust from Skia device space to Metal normalized device
72 * space and to make device space positions have the correct origin for processors that require
73 * them.
74 */
75 struct RenderTargetState {
76 SkISize fRenderTargetSize;
77 GrSurfaceOrigin fRenderTargetOrigin;
78
79 RenderTargetState() { this->invalidate(); }
80 void invalidate() {
81 fRenderTargetSize.fWidth = -1;
82 fRenderTargetSize.fHeight = -1;
83 fRenderTargetOrigin = (GrSurfaceOrigin)-1;
84 }
85 };
86
87 void setRenderTargetState(SkISize colorAttachmentDimensions, GrSurfaceOrigin);
88
89 void bindUniforms(GrMtlRenderCommandEncoder*);
90
91 void setBlendConstants(GrMtlRenderCommandEncoder*,
92 const skgpu::Swizzle&,
93 const GrXferProcessor&);
94
95 void setDepthStencilState(GrMtlRenderCommandEncoder* renderCmdEncoder);
96
97 struct SamplerBindings {
98 GrMtlSampler* fSampler;
99 id<MTLTexture> fTexture;
100
101 SamplerBindings(GrSamplerState state, GrTexture* texture, GrMtlGpu*);
102 };
103
104 GrMtlGpu* fGpu;
106 MTLPixelFormat fPixelFormat;
107
108 RenderTargetState fRenderTargetState;
109 GrGLSLBuiltinUniformHandles fBuiltinUniformHandles;
110
111 GrStencilSettings fStencil;
112
113 int fNumSamplers;
115
116 std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
117 std::unique_ptr<GrXferProcessor::ProgramImpl> fXPImpl;
118 std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
119
121};
122
123#endif
GrSurfaceOrigin
Definition: GrTypes.h:147
GrMtlUniformHandler::UniformInfoArray UniformInfoArray
void setDrawState(GrMtlRenderCommandEncoder *, const skgpu::Swizzle &writeSwizzle, const GrXferProcessor &)
GrMtlPipelineState(GrMtlGpu *, sk_sp< GrMtlRenderPipeline > pipeline, MTLPixelFormat, const GrGLSLBuiltinUniformHandles &builtinUniformHandles, const UniformInfoArray &uniforms, uint32_t uniformBufferSize, uint32_t numSamplers, std::unique_ptr< GrGeometryProcessor::ProgramImpl >, std::unique_ptr< GrXferProcessor::ProgramImpl >, std::vector< std::unique_ptr< GrFragmentProcessor::ProgramImpl > > fpImpls)
static void SetDynamicScissorRectState(GrMtlRenderCommandEncoder *renderCmdEncoder, SkISize colorAttachmentDimensions, GrSurfaceOrigin rtOrigin, SkIRect scissorRect)
bool doesntSampleAttachment(const MTLRenderPassAttachmentDescriptor *) const
void bindTextures(GrMtlRenderCommandEncoder *renderCmdEncoder)
void setTextures(const GrGeometryProcessor &, const GrPipeline &, const GrSurfaceProxy *const geomProcTextures[])
void setData(GrMtlFramebuffer *, const GrProgramInfo &)
GrGLSLProgramDataManager::UniformHandle UniformHandle
const sk_sp< GrMtlRenderPipeline > & pipeline() const
AtkStateType state
FlTexture * texture
Definition: SkRect.h:32
Definition: SkSize.h:16
int32_t fHeight
Definition: SkSize.h:18
int32_t fWidth
Definition: SkSize.h:17