Flutter Engine
The Flutter Engine
GrD3DPipelineState.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 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 GrD3DPipelineState_DEFINED
9#define GrD3DPipelineState_DEFINED
10
12#include "include/gpu/GrTypes.h"
18
19#include <vector>
20
22class GrD3DGpu;
23class GrD3DPipeline;
25class GrProgramInfo;
26
28public:
30
33 const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
34 const UniformInfoArray& uniforms,
35 uint32_t uniformSize,
36 uint32_t numSamplers,
37 std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
38 std::unique_ptr<GrXferProcessor::ProgramImpl> xpImpl,
39 std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls,
40 size_t vertexStride,
41 size_t instanceStride);
42
43 const sk_sp<GrD3DPipeline>& pipeline() const { return fPipeline; }
44 const sk_sp<GrD3DRootSignature>& rootSignature() const { return fRootSignature; }
45
47
50 const GrSurfaceProxy* const geomProcTextures[],
51 const GrPipeline&);
52
54 sk_sp<const GrBuffer> instanceBuffer, sk_sp<const GrBuffer> vertexBuffer,
55 GrD3DDirectCommandList* commandList);
56
57 // We can only cache non dirty uniform values until we submit a command list. After that, the
58 // next frame will get a completely different uniform buffer and/or offset into the buffer. Thus
59 // we need a way to mark them all as dirty during submit.
60 void markUniformsDirty() { fDataManager.markDirty(); }
61
62private:
63 /**
64 * We use the RT's size and origin to adjust from Skia device space to d3d normalized device
65 * space and to make device space positions have the correct origin for processors that require
66 * them.
67 */
68 struct RenderTargetState {
69 SkISize fRenderTargetSize;
70 GrSurfaceOrigin fRenderTargetOrigin;
71
72 RenderTargetState() { this->invalidate(); }
73 void invalidate() {
74 fRenderTargetSize.fWidth = -1;
75 fRenderTargetSize.fHeight = -1;
76 fRenderTargetOrigin = (GrSurfaceOrigin)-1;
77 }
78 };
79
80 // Helper for setData() that sets the view matrix and loads the render target height uniform
81 void setRenderTargetState(const GrRenderTarget*, GrSurfaceOrigin);
82
83 sk_sp<GrD3DPipeline> fPipeline;
84 sk_sp<GrD3DRootSignature> fRootSignature;
85
86 // Tracks the current render target uniforms stored in the vertex buffer.
87 RenderTargetState fRenderTargetState;
88 GrGLSLBuiltinUniformHandles fBuiltinUniformHandles;
89
90 // Processors in the GrD3DPipelineState
91 std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
92 std::unique_ptr<GrXferProcessor::ProgramImpl> fXPImpl;
93 std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
94
96
97 unsigned int fNumSamplers;
98 size_t fVertexStride;
99 size_t fInstanceStride;
100};
101
102#endif
GrSurfaceOrigin
Definition: GrTypes.h:147
GrSPIRVUniformHandler::UniformInfoArray UniformInfoArray
void setAndBindTextures(GrD3DGpu *, const GrGeometryProcessor &, const GrSurfaceProxy *const geomProcTextures[], const GrPipeline &)
const sk_sp< GrD3DPipeline > & pipeline() const
void setAndBindConstants(GrD3DGpu *, const GrRenderTarget *, const GrProgramInfo &)
const sk_sp< GrD3DRootSignature > & rootSignature() const
void bindBuffers(GrD3DGpu *, sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrD3DDirectCommandList *commandList)
GrD3DPipelineState(sk_sp< GrD3DPipeline > pipeline, sk_sp< GrD3DRootSignature > rootSignature, const GrGLSLBuiltinUniformHandles &builtinUniformHandles, const UniformInfoArray &uniforms, uint32_t uniformSize, uint32_t numSamplers, std::unique_ptr< GrGeometryProcessor::ProgramImpl > gpImpl, std::unique_ptr< GrXferProcessor::ProgramImpl > xpImpl, std::vector< std::unique_ptr< GrFragmentProcessor::ProgramImpl > > fpImpls, size_t vertexStride, size_t instanceStride)
Definition: SkSize.h:16
int32_t fHeight
Definition: SkSize.h:18
int32_t fWidth
Definition: SkSize.h:17