Flutter Engine
The Flutter Engine
DawnGraphicsPipeline.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 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_DawnGraphicsPipeline_DEFINED
9#define skgpu_graphite_DawnGraphicsPipeline_DEFINED
10
12#include "include/core/SkSpan.h"
17
18#include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
19
20class SkUniform;
21
22namespace SkSL {
23 class Compiler;
24}
25namespace skgpu {
26struct BlendInfo;
27}
28
29namespace skgpu::graphite {
30
31class Attribute;
32class Context;
33class GraphicsPipelineDesc;
34class DawnResourceProvider;
35class DawnSharedContext;
36struct DepthStencilSettings;
37struct RenderPassDesc;
38class RuntimeEffectDictionary;
39
41public:
42 inline static constexpr unsigned int kUniformBufferBindGroupIndex = 0;
43 inline static constexpr unsigned int kTextureBindGroupIndex = 1;
44 inline static constexpr unsigned int kBindGroupCount = 2;
45
46 inline static constexpr unsigned int kIntrinsicUniformBufferIndex = 0;
47 inline static constexpr unsigned int kRenderStepUniformBufferIndex = 1;
48 inline static constexpr unsigned int kPaintUniformBufferIndex = 2;
49 inline static constexpr unsigned int kGradientBufferIndex = 3;
50 inline static constexpr unsigned int kNumUniformBuffers = 4;
51
52 inline static constexpr unsigned int kVertexBufferIndex = 0;
53 inline static constexpr unsigned int kInstanceBufferIndex = 1;
54 inline static constexpr unsigned int kNumVertexBuffers = 2;
55
57 DawnResourceProvider* resourceProvider,
58 const RuntimeEffectDictionary* runtimeDict,
59 const GraphicsPipelineDesc& pipelineDesc,
60 const RenderPassDesc& renderPassDesc);
61
62 ~DawnGraphicsPipeline() override;
63
64 uint32_t stencilReferenceValue() const { return fStencilReferenceValue; }
65 PrimitiveType primitiveType() const { return fPrimitiveType; }
66 bool hasStepUniforms() const { return fHasStepUniforms; }
67 bool hasPaintUniforms() const { return fHasPaintUniforms; }
68 bool hasGradientBuffer() const { return fHasGradientBuffer; }
69 int numTexturesAndSamplers() const { return fNumFragmentTexturesAndSamplers; }
70 const wgpu::RenderPipeline& dawnRenderPipeline() const;
71
72 using BindGroupLayouts = std::array<wgpu::BindGroupLayout, kBindGroupCount>;
73 const BindGroupLayouts& dawnGroupLayouts() const { return fGroupLayouts; }
74
75private:
76 struct AsyncPipelineCreation;
77
79 PipelineInfo* pipelineInfo,
80 std::unique_ptr<AsyncPipelineCreation> pipelineCreationInfo,
81 BindGroupLayouts groupLayouts,
83 uint32_t refValue,
84 bool hasStepUniforms,
87 int numFragmentTexturesAndSamplers);
88
89 void freeGpuData() override;
90
91 std::unique_ptr<AsyncPipelineCreation> fAsyncPipelineCreation;
92 BindGroupLayouts fGroupLayouts;
93 const PrimitiveType fPrimitiveType;
94 const uint32_t fStencilReferenceValue;
95 const bool fHasStepUniforms;
96 const bool fHasPaintUniforms;
97 const bool fHasGradientBuffer;
98 const int fNumFragmentTexturesAndSamplers;
99};
100
101} // namespace skgpu::graphite
102
103#endif // skgpu_graphite_DawnGraphicsPipeline_DEFINED
static constexpr unsigned int kUniformBufferBindGroupIndex
static constexpr unsigned int kTextureBindGroupIndex
static constexpr unsigned int kRenderStepUniformBufferIndex
std::array< wgpu::BindGroupLayout, kBindGroupCount > BindGroupLayouts
const wgpu::RenderPipeline & dawnRenderPipeline() const
static constexpr unsigned int kPaintUniformBufferIndex
static constexpr unsigned int kBindGroupCount
static constexpr unsigned int kInstanceBufferIndex
const BindGroupLayouts & dawnGroupLayouts() const
static constexpr unsigned int kNumUniformBuffers
static constexpr unsigned int kGradientBufferIndex
static sk_sp< DawnGraphicsPipeline > Make(const DawnSharedContext *sharedContext, DawnResourceProvider *resourceProvider, const RuntimeEffectDictionary *runtimeDict, const GraphicsPipelineDesc &pipelineDesc, const RenderPassDesc &renderPassDesc)
static constexpr unsigned int kNumVertexBuffers
static constexpr unsigned int kVertexBufferIndex
static constexpr unsigned int kIntrinsicUniformBufferIndex
const SharedContext * sharedContext() const
Definition: Resource.h:189
Definition: GpuTools.h:21