Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skgpu::graphite::PerEdgeAAQuadRenderStep Class Referencefinal

#include <PerEdgeAAQuadRenderStep.h>

Inheritance diagram for skgpu::graphite::PerEdgeAAQuadRenderStep:
skgpu::graphite::RenderStep

Public Member Functions

 PerEdgeAAQuadRenderStep (StaticBufferManager *bufferManager)
 
 ~PerEdgeAAQuadRenderStep () override
 
std::string vertexSkSL () const override
 
const char * fragmentCoverageSkSL () const override
 
void writeVertices (DrawWriter *, const DrawParams &, skvx::ushort2 ssboIndices) const override
 
void writeUniformsAndTextures (const DrawParams &, PipelineDataGatherer *) const override
 
- Public Member Functions inherited from skgpu::graphite::RenderStep
virtual ~RenderStep ()=default
 
virtual std::string texturesAndSamplersSkSL (const ResourceBindingRequirements &, int *nextBindingIndex) const
 
virtual const char * fragmentColorSkSL () const
 
uint32_t uniqueID () const
 
const char * name () const
 
bool requiresMSAA () const
 
bool performsShading () const
 
bool hasTextures () const
 
bool emitsPrimitiveColor () const
 
bool outsetBoundsForAA () const
 
Coverage coverage () const
 
PrimitiveType primitiveType () const
 
size_t vertexStride () const
 
size_t instanceStride () const
 
size_t numUniforms () const
 
size_t numVertexAttributes () const
 
size_t numInstanceAttributes () const
 
SkSpan< const Uniformuniforms () const
 
SkSpan< const AttributevertexAttributes () const
 
SkSpan< const AttributeinstanceAttributes () const
 
SkSpan< const Varyingvaryings () const
 
const DepthStencilSettingsdepthStencilSettings () const
 
SkEnumBitMask< DepthStencilFlagsdepthStencilFlags () const
 

Additional Inherited Members

- Static Public Member Functions inherited from skgpu::graphite::RenderStep
static const char * ssboIndicesAttribute ()
 
static const char * ssboIndicesVarying ()
 
- Protected Types inherited from skgpu::graphite::RenderStep
enum class  Flags : unsigned {
  kNone = 0b0000000 , kRequiresMSAA = 0b0000001 , kPerformsShading = 0b0000010 , kHasTextures = 0b0000100 ,
  kEmitsCoverage = 0b0001000 , kLCDCoverage = 0b0010000 , kEmitsPrimitiveColor = 0b0100000 , kOutsetBoundsForAA = 0b1000000
}
 
- Protected Member Functions inherited from skgpu::graphite::RenderStep
 RenderStep (std::string_view className, std::string_view variantName, SkEnumBitMask< Flags > flags, std::initializer_list< Uniform > uniforms, PrimitiveType primitiveType, DepthStencilSettings depthStencilSettings, SkSpan< const Attribute > vertexAttrs, SkSpan< const Attribute > instanceAttrs, SkSpan< const Varying > varyings={})
 

Detailed Description

Definition at line 17 of file PerEdgeAAQuadRenderStep.h.

Constructor & Destructor Documentation

◆ PerEdgeAAQuadRenderStep()

skgpu::graphite::PerEdgeAAQuadRenderStep::PerEdgeAAQuadRenderStep ( StaticBufferManager bufferManager)

Definition at line 178 of file PerEdgeAAQuadRenderStep.cpp.

179 : RenderStep("PerEdgeAAQuadRenderStep",
180 "",
182 /*uniforms=*/{},
185 /*vertexAttrs=*/{
187 },
188 /*instanceAttrs=*/
192
193 // TODO: pack depth and ssbo index into one 32-bit attribute, if we can
194 // go without needing both render step and paint ssbo index attributes.
197
201 /*varyings=*/{
202 // Device-space distance to LTRB edges of quad.
203 {"edgeDistances", SkSLType::kFloat4}, // distance to LTRB edges
204 }) {
205 // Initialize the static buffers we'll use when recording draw calls.
206 // NOTE: Each instance of this RenderStep gets its own copy of the data. Since there should only
207 // ever be one PerEdgeAAQuadRenderStep at a time, this shouldn't be an issue.
208 write_vertex_buffer(bufferManager->getVertexWriter(sizeof(Vertex) * kVertexCount,
209 &fVertexBuffer));
210 write_index_buffer(bufferManager->getIndexWriter(sizeof(uint16_t) * kIndexCount,
211 &fIndexBuffer));
212}
RenderStep(std::string_view className, std::string_view variantName, SkEnumBitMask< Flags > flags, std::initializer_list< Uniform > uniforms, PrimitiveType primitiveType, DepthStencilSettings depthStencilSettings, SkSpan< const Attribute > vertexAttrs, SkSpan< const Attribute > instanceAttrs, SkSpan< const Varying > varyings={})
Definition Renderer.cpp:19
static void write_index_buffer(VertexWriter writer)
static constexpr DepthStencilSettings kDirectDepthGreaterPass
static constexpr int kIndexCount
static constexpr int kVertexCount
static void write_vertex_buffer(VertexWriter writer)

◆ ~PerEdgeAAQuadRenderStep()

skgpu::graphite::PerEdgeAAQuadRenderStep::~PerEdgeAAQuadRenderStep ( )
override

Definition at line 214 of file PerEdgeAAQuadRenderStep.cpp.

214{}

Member Function Documentation

◆ fragmentCoverageSkSL()

const char * skgpu::graphite::PerEdgeAAQuadRenderStep::fragmentCoverageSkSL ( ) const
overridevirtual

Reimplemented from skgpu::graphite::RenderStep.

Definition at line 231 of file PerEdgeAAQuadRenderStep.cpp.

231 {
232 // The returned SkSL must write its coverage into a 'half4 outputCoverage' variable (defined in
233 // the calling code) with the actual coverage splatted out into all four channels.
234 return "outputCoverage = per_edge_aa_quad_coverage_fn(sk_FragCoord, edgeDistances);";
235}

◆ vertexSkSL()

std::string skgpu::graphite::PerEdgeAAQuadRenderStep::vertexSkSL ( ) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 216 of file PerEdgeAAQuadRenderStep.cpp.

216 {
217 // Returns the body of a vertex function, which must define a float4 devPosition variable and
218 // must write to an already-defined float2 stepLocalCoords variable.
219 return "float4 devPosition = per_edge_aa_quad_vertex_fn("
220 // Vertex Attributes
221 "normal, "
222 // Instance Attributes
223 "edgeFlags, quadXs, quadYs, depth, "
224 "float3x3(mat0, mat1, mat2), "
225 // Varyings
226 "edgeDistances, "
227 // Render Step
228 "stepLocalCoords);\n";
229}

◆ writeUniformsAndTextures()

void skgpu::graphite::PerEdgeAAQuadRenderStep::writeUniformsAndTextures ( const DrawParams ,
PipelineDataGatherer  
) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 277 of file PerEdgeAAQuadRenderStep.cpp.

278 {
279 // All data is uploaded as instance attributes, so no uniforms are needed.
280}

◆ writeVertices()

void skgpu::graphite::PerEdgeAAQuadRenderStep::writeVertices ( DrawWriter writer,
const DrawParams params,
skvx::ushort2  ssboIndices 
) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 237 of file PerEdgeAAQuadRenderStep.cpp.

239 {
240 SkASSERT(params.geometry().isEdgeAAQuad());
241 const EdgeAAQuad& quad = params.geometry().edgeAAQuad();
242
243 DrawWriter::Instances instance{*writer, fVertexBuffer, fIndexBuffer, kIndexCount};
244 auto vw = instance.append(1);
245
246 // Empty fills should not have been recorded at all.
247 SkDEBUGCODE(Rect bounds = params.geometry().bounds());
248 SkASSERT(!bounds.isEmptyNegativeOrNaN());
249
250 constexpr uint8_t kAAOn = 255;
251 constexpr uint8_t kAAOff = 0;
252 auto edgeSigns = skvx::byte4{quad.edgeFlags() & AAFlags::kLeft ? kAAOn : kAAOff,
253 quad.edgeFlags() & AAFlags::kTop ? kAAOn : kAAOff,
254 quad.edgeFlags() & AAFlags::kRight ? kAAOn : kAAOff,
255 quad.edgeFlags() & AAFlags::kBottom ? kAAOn : kAAOff};
256
257 // The vertex shader expects points to be in clockwise order. EdgeAAQuad is the only
258 // shape that *might* have counter-clockwise input.
259 if (is_clockwise(quad)) {
260 vw << edgeSigns << quad.xs() << quad.ys();
261 } else {
262 vw << skvx::shuffle<2,1,0,3>(edgeSigns) // swap left and right AA bits
263 << skvx::shuffle<1,0,3,2>(quad.xs()) // swap TL with TR, and BL with BR
264 << skvx::shuffle<1,0,3,2>(quad.ys()); // ""
265 }
266
267 // All instance types share the remaining instance attribute definitions
268 const SkM44& m = params.transform().matrix();
269
270 vw << params.order().depthAsFloat()
271 << ssboIndices
272 << m.rc(0,0) << m.rc(1,0) << m.rc(3,0) // mat0
273 << m.rc(0,1) << m.rc(1,1) << m.rc(3,1) // mat1
274 << m.rc(0,3) << m.rc(1,3) << m.rc(3,3); // mat2
275}
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
Definition SkM44.h:150
const EmbeddedViewParams * params
VkInstance instance
Definition main.cc:48
Optional< SkRect > bounds
Definition SkRecords.h:189
static bool is_clockwise(const EdgeAAQuad &quad)

The documentation for this class was generated from the following files: