Flutter Engine
The Flutter Engine
ContextUtils.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_ContextUtils_DEFINED
9#define skgpu_graphite_ContextUtils_DEFINED
10
11#include "src/gpu/Blend.h"
14
15#include <optional>
16#include <tuple>
17
18class SkColorInfo;
19class SkM44;
20class SkPaint;
21
22namespace skgpu {
23class Swizzle;
24}
25
26namespace skgpu::graphite {
27
28class ComputeStep;
29enum class Coverage;
30class DrawParams;
31enum class DstReadRequirement;
32class Geometry;
33class GraphicsPipelineDesc;
34class PaintParams;
35class PipelineDataGatherer;
36class Recorder;
37struct RenderPassDesc;
38class RenderStep;
39class RuntimeEffectDictionary;
40class ShaderNode;
41class UniquePaintParamsID;
42
43struct ResourceBindingRequirements;
44
46 std::string fSkSL;
47
48 std::string fLabel;
49
51};
52
54 std::string fSkSL;
56
57 std::string fLabel;
58
64 bool fHasGradientBuffer = false;
66};
67
68std::tuple<UniquePaintParamsID, const UniformDataBlock*, const TextureDataBlock*> ExtractPaintData(
69 Recorder*,
70 PipelineDataGatherer* gatherer,
71 PaintParamsKeyBuilder* builder,
72 const Layout layout,
73 const SkM44& local2Dev,
74 const PaintParams&,
75 const Geometry& geometry,
76 sk_sp<TextureProxy> dstTexture,
77 SkIPoint dstOffset,
78 const SkColorInfo& targetColorInfo);
79
80std::tuple<const UniformDataBlock*, const TextureDataBlock*> ExtractRenderStepData(
81 UniformDataCache* uniformDataCache,
82 TextureDataCache* textureDataCache,
83 PipelineDataGatherer* gatherer,
84 const Layout layout,
85 const RenderStep* step,
86 const DrawParams& params);
87
88DstReadRequirement GetDstReadRequirement(const Caps*, std::optional<SkBlendMode>, Coverage);
89
90VertSkSLInfo BuildVertexSkSL(const ResourceBindingRequirements&,
91 const RenderStep* step,
92 bool defineShadingSsboIndexVarying,
93 bool defineLocalCoordsVarying);
94
95// TODO(b/347072931): Refactor to return std::unique_ptr<ShaderInfo> instead such that snippet
96// data can remain tied to its snippet ID.
97FragSkSLInfo BuildFragmentSkSL(const Caps* caps,
98 const ShaderCodeDictionary*,
99 const RuntimeEffectDictionary*,
100 const RenderStep* renderStep,
101 UniquePaintParamsID paintID,
102 bool useStorageBuffers,
103 skgpu::Swizzle writeSwizzle);
104
105std::string GetPipelineLabel(const ShaderCodeDictionary*,
106 const RenderPassDesc& renderPassDesc,
107 const RenderStep* renderStep,
108 UniquePaintParamsID paintID);
109
110std::string BuildComputeSkSL(const Caps*, const ComputeStep*);
111
112std::string EmitPaintParamsUniforms(int bufferID,
113 const Layout layout,
115 int* numPaintUniforms,
116 int* paintUniformsTotalBytes,
117 bool* wrotePaintColor);
118std::string EmitRenderStepUniforms(int bufferID,
119 const Layout layout,
120 SkSpan<const Uniform> uniforms,
121 int* renderStepUniformsTotalBytes);
122std::string EmitPaintParamsStorageBuffer(int bufferID,
124 int* numPaintUniforms,
125 bool* wrotePaintColor);
126std::string EmitRenderStepStorageBuffer(int bufferID,
127 SkSpan<const Uniform> uniforms);
128std::string EmitUniformsFromStorageBuffer(const char* bufferNamePrefix,
129 const char* ssboIndex,
130 SkSpan<const Uniform> uniforms);
131std::string EmitStorageBufferAccess(const char* bufferNamePrefix,
132 const char* ssboIndex,
133 const char* uniformName);
134std::string EmitTexturesAndSamplers(const ResourceBindingRequirements&,
136 int* binding);
137std::string EmitSamplerLayout(const ResourceBindingRequirements&, int* binding);
138std::string EmitVaryings(const RenderStep* step,
139 const char* direction,
140 bool emitSsboIndicesVarying,
141 bool emitLocalCoordsVarying);
142
143} // namespace skgpu::graphite
144
145#endif // skgpu_graphite_ContextUtils_DEFINED
static int step(int x, SkScalar min, SkScalar max)
Definition: BlurTest.cpp:215
static bool ComputeStep(const SkPoint &a, const SkPoint &b, SkScalar radius, SkPoint *step)
Definition: SkM44.h:150
const EmbeddedViewParams * params
VertSkSLInfo BuildVertexSkSL(const ResourceBindingRequirements &bindingReqs, const RenderStep *step, bool useStorageBuffers, bool defineLocalCoordsVarying)
std::string EmitPaintParamsUniforms(int bufferID, const Layout layout, SkSpan< const ShaderNode * > nodes, int *numUniforms, int *uniformsTotalBytes, bool *wrotePaintColor)
std::string BuildComputeSkSL(const Caps *caps, const ComputeStep *step)
std::string EmitStorageBufferAccess(const char *bufferNamePrefix, const char *ssboIndex, const char *uniformName)
DstReadRequirement GetDstReadRequirement(const Caps *caps, std::optional< SkBlendMode > blendMode, Coverage coverage)
std::string EmitTexturesAndSamplers(const ResourceBindingRequirements &bindingReqs, SkSpan< const ShaderNode * > nodes, int *binding)
FragSkSLInfo BuildFragmentSkSL(const Caps *caps, const ShaderCodeDictionary *dict, const RuntimeEffectDictionary *rteDict, const RenderStep *step, UniquePaintParamsID paintID, bool useStorageBuffers, skgpu::Swizzle writeSwizzle)
std::string GetPipelineLabel(const ShaderCodeDictionary *dict, const RenderPassDesc &renderPassDesc, const RenderStep *renderStep, UniquePaintParamsID paintID)
std::string EmitRenderStepStorageBuffer(int bufferID, SkSpan< const Uniform > uniforms)
std::string EmitRenderStepUniforms(int bufferID, const Layout layout, SkSpan< const Uniform > uniforms, int *renderStepUniformsTotalBytes)
PipelineDataCache< UniformDataBlock > UniformDataCache
Definition: Recorder.h:60
std::string EmitVaryings(const RenderStep *step, const char *direction, bool emitSsboIndicesVarying, bool emitLocalCoordsVarying)
std::string EmitPaintParamsStorageBuffer(int bufferID, SkSpan< const ShaderNode * > nodes, int *numUniforms, bool *wrotePaintColor)
std::tuple< const UniformDataBlock *, const TextureDataBlock * > ExtractRenderStepData(UniformDataCache *uniformDataCache, TextureDataCache *textureDataCache, PipelineDataGatherer *gatherer, const Layout layout, const RenderStep *step, const DrawParams &params)
DstReadRequirement
Definition: Caps.h:64
std::string EmitSamplerLayout(const ResourceBindingRequirements &bindingReqs, int *binding)
std::tuple< UniquePaintParamsID, const UniformDataBlock *, const TextureDataBlock * > ExtractPaintData(Recorder *recorder, PipelineDataGatherer *gatherer, PaintParamsKeyBuilder *builder, const Layout layout, const SkM44 &local2Dev, const PaintParams &p, const Geometry &geometry, sk_sp< TextureProxy > dstTexture, SkIPoint dstOffset, const SkColorInfo &targetColorInfo)
PipelineDataCache< TextureDataBlock > TextureDataCache
Definition: Recorder.h:61
std::string EmitUniformsFromStorageBuffer(const char *bufferNamePrefix, const char *ssboIndex, SkSpan< const Uniform > uniforms)
Definition: GpuTools.h:21
skia_private::TArray< uint32_t > fData
Definition: ContextUtils.h:65