Flutter Engine
The Flutter Engine
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 372 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 374 of file DrawPass.cpp.

382 RenderStepField::set(static_cast<uint32_t>(renderStep)) |
384 , fUniformKey(GeometryUniformField::set(geomUniformIndex) |
387 , fDraw(draw) {
389 SkASSERT(renderStep <= draw->fRenderer->numRenderSteps());
390 }
static constexpr Index kInvalidIndex
Definition: DrawPass.cpp:68
#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:409
const DrawList::Draw & draw() const
Definition: DrawPass.cpp:401
const RenderStep & renderStep() const
Definition: DrawPass.cpp:397
TextureBindingCache::Index textureBindingIndex() const
Definition: DrawPass.cpp:412
GraphicsPipelineCache::Index pipelineIndex() const
Definition: DrawPass.cpp:403
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76

Member Function Documentation

◆ draw()

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

Definition at line 401 of file DrawPass.cpp.

401{ return *fDraw; }

◆ geometryUniformIndex()

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

Definition at line 406 of file DrawPass.cpp.

406 {
407 return GeometryUniformField::get(fUniformKey);
408 }
const myers::Point & get(const myers::Segment &)

◆ operator<()

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

Definition at line 392 of file DrawPass.cpp.

392 {
393 return fPipelineKey < k.fPipelineKey ||
394 (fPipelineKey == k.fPipelineKey && fUniformKey < k.fUniformKey);
395 }

◆ pipelineIndex()

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

Definition at line 403 of file DrawPass.cpp.

403 {
404 return PipelineField::get(fPipelineKey);
405 }

◆ renderStep()

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

Definition at line 397 of file DrawPass.cpp.

397 {
398 return fDraw->fRenderer->step(RenderStepField::get(fPipelineKey));
399 }
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 409 of file DrawPass.cpp.

409 {
410 return ShadingUniformField::get(fUniformKey);
411 }

◆ textureBindingIndex()

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

Definition at line 412 of file DrawPass.cpp.

412 {
413 return TextureBindingsField::get(fUniformKey);
414 }

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