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

Public Member Functions

 SortKey (const DrawList::Draw *draw, int renderStep, GraphicsPipelineCache::Index pipelineIndex, UniformCache::Index geomUniformIndex, UniformCache::Index shadingUniformIndex, TextureBindingCache::Index textureBindingIndex)
 
bool operator< (const SortKey &k) const
 
const RenderSteprenderStep () const
 
const DrawList::Drawdraw () const
 
GraphicsPipelineCache::Index pipelineIndex () const
 
UniformCache::Index geometryUniformIndex () const
 
UniformCache::Index shadingUniformIndex () const
 
TextureBindingCache::Index textureBindingIndex () const
 

Detailed Description

Each Draw in a DrawList might be processed by multiple RenderSteps (determined by the Draw's Renderer), which can be sorted independently. Each (step, draw) pair produces its own SortKey.

The goal of sorting draws for the DrawPass is to minimize pipeline transitions and dynamic binds within a pipeline, while still respecting the overall painter's order. This decreases the number of low-level draw commands in a command buffer and increases the size of those, allowing the GPU to operate more efficiently and have fewer bubbles within its own instruction stream.

The Draw's CompresssedPaintersOrder and DisjointStencilINdex represent the most significant bits of the key, and are shared by all SortKeys produced by the same draw. Next, the pipeline description is encoded in two steps:

  1. The index of the RenderStep packed in the high bits to ensure each step for a draw is ordered correctly.
  2. An index into a cache of pipeline descriptions is used to encode the identity of the pipeline (SortKeys that differ in the bits from #1 necessarily would have different descriptions, but then the specific ordering of the RenderSteps isn't enforced). Last, the SortKey encodes an index into the set of uniform bindings accumulated for a DrawPass. This allows the SortKey to cluster draw steps that have both a compatible pipeline and do not require rebinding uniform data or other state (e.g. scissor). Since the uniform data index and the pipeline description index are packed into indices and not actual pointers, a given SortKey is only valid for the a specific DrawList->DrawPass conversion.

Definition at line 339 of file DrawPass.cpp.

Constructor & Destructor Documentation

◆ SortKey()

skgpu::graphite::DrawPass::SortKey::SortKey ( const DrawList::Draw draw,
int  renderStep,
GraphicsPipelineCache::Index  pipelineIndex,
UniformCache::Index  geomUniformIndex,
UniformCache::Index  shadingUniformIndex,
TextureBindingCache::Index  textureBindingIndex 
)
inline

Definition at line 341 of file DrawPass.cpp.

347 : fPipelineKey(ColorDepthOrderField::set(draw->fDrawParams.order().paintOrder().bits()) |
348 StencilIndexField::set(draw->fDrawParams.order().stencilIndex().bits()) |
349 RenderStepField::set(static_cast<uint32_t>(renderStep)) |
350 PipelineField::set(pipelineIndex))
351 , fUniformKey(GeometryUniformField::set(geomUniformIndex) |
352 ShadingUniformField::set(shadingUniformIndex) |
353 TextureBindingsField::set(textureBindingIndex))
354 , fDraw(draw) {
355 SkASSERT(pipelineIndex < GraphicsPipelineCache::kInvalidIndex);
356 SkASSERT(renderStep <= draw->fRenderer->numRenderSteps());
357 }
#define SkASSERT(cond)
Definition SkAssert.h:116
CompressedPaintersOrder paintOrder() const
Definition DrawOrder.h:127
DisjointStencilIndex stencilIndex() const
Definition DrawOrder.h:128
DrawOrder order() const
Definition DrawParams.h:125
UniformCache::Index shadingUniformIndex() const
Definition DrawPass.cpp:376
const DrawList::Draw & draw() const
Definition DrawPass.cpp:368
const RenderStep & renderStep() const
Definition DrawPass.cpp:364
TextureBindingCache::Index textureBindingIndex() const
Definition DrawPass.cpp:379
GraphicsPipelineCache::Index pipelineIndex() const
Definition DrawPass.cpp:370

Member Function Documentation

◆ draw()

const DrawList::Draw & skgpu::graphite::DrawPass::SortKey::draw ( ) const
inline

Definition at line 368 of file DrawPass.cpp.

368{ return *fDraw; }

◆ geometryUniformIndex()

UniformCache::Index skgpu::graphite::DrawPass::SortKey::geometryUniformIndex ( ) const
inline

Definition at line 373 of file DrawPass.cpp.

373 {
374 return GeometryUniformField::get(fUniformKey);
375 }

◆ operator<()

bool skgpu::graphite::DrawPass::SortKey::operator< ( const SortKey k) const
inline

Definition at line 359 of file DrawPass.cpp.

359 {
360 return fPipelineKey < k.fPipelineKey ||
361 (fPipelineKey == k.fPipelineKey && fUniformKey < k.fUniformKey);
362 }

◆ pipelineIndex()

GraphicsPipelineCache::Index skgpu::graphite::DrawPass::SortKey::pipelineIndex ( ) const
inline

Definition at line 370 of file DrawPass.cpp.

370 {
371 return PipelineField::get(fPipelineKey);
372 }

◆ renderStep()

const RenderStep & skgpu::graphite::DrawPass::SortKey::renderStep ( ) const
inline

Definition at line 364 of file DrawPass.cpp.

364 {
365 return fDraw->fRenderer->step(RenderStepField::get(fPipelineKey));
366 }
const RenderStep & step(int i) const
Definition Renderer.h:229
const Renderer * fRenderer
Definition DrawList.h:95

◆ shadingUniformIndex()

UniformCache::Index skgpu::graphite::DrawPass::SortKey::shadingUniformIndex ( ) const
inline

Definition at line 376 of file DrawPass.cpp.

376 {
377 return ShadingUniformField::get(fUniformKey);
378 }

◆ textureBindingIndex()

TextureBindingCache::Index skgpu::graphite::DrawPass::SortKey::textureBindingIndex ( ) const
inline

Definition at line 379 of file DrawPass.cpp.

379 {
380 return TextureBindingsField::get(fUniformKey);
381 }

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