Ensures that bindings on the pass are not redundantly set or updated. Avoids making the driver do additional checks and makes the frame insights during profiling and instrumentation not complain about the same.
More...
#include <pass_bindings_cache_mtl.h>
Ensures that bindings on the pass are not redundantly set or updated. Avoids making the driver do additional checks and makes the frame insights during profiling and instrumentation not complain about the same.
There should be no change to rendering if this caching was absent.
Definition at line 24 of file pass_bindings_cache_mtl.h.
◆ PassBindingsCacheMTL() [1/3]
impeller::PassBindingsCacheMTL::PassBindingsCacheMTL |
( |
| ) |
|
|
inlineexplicit |
◆ ~PassBindingsCacheMTL()
impeller::PassBindingsCacheMTL::~PassBindingsCacheMTL |
( |
| ) |
|
|
default |
◆ PassBindingsCacheMTL() [2/3]
◆ PassBindingsCacheMTL() [3/3]
◆ SetBuffer()
bool impeller::PassBindingsCacheMTL::SetBuffer |
( |
ShaderStage |
stage, |
|
|
uint64_t |
index, |
|
|
uint64_t |
offset, |
|
|
id< MTLBuffer > |
buffer |
|
) |
| |
Definition at line 31 of file pass_bindings_cache_mtl.mm.
34 {
35 auto& buffers_map = buffers_[stage];
36 auto found = buffers_map.find(index);
37 if (found != buffers_map.end() && found->second.buffer ==
buffer) {
38
39 if (found->second.offset ==
offset) {
40
41 return true;
42 }
43
44
45 found->second.offset =
offset;
46
47 switch (stage) {
49 [encoder_ setVertexBufferOffset:
offset atIndex:index];
50 return true;
52 [encoder_ setFragmentBufferOffset:
offset atIndex:index];
53 return true;
54 default:
55 VALIDATION_LOG <<
"Cannot update buffer offset of an unknown stage.";
56 return false;
57 }
58 return true;
59 }
60 buffers_map[index] = {
buffer,
static_cast<size_t>(
offset)};
61 switch (stage) {
64 return true;
67 return true;
68 default:
70 return false;
71 }
72 return false;
73}
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 defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
◆ SetDepthStencilState()
void impeller::PassBindingsCacheMTL::SetDepthStencilState |
( |
id< MTLDepthStencilState > |
depth_stencil | ) |
|
Definition at line 22 of file pass_bindings_cache_mtl.mm.
23 {
24 if (depth_stencil_ == depth_stencil) {
25 return;
26 }
27 depth_stencil_ = depth_stencil;
28 [encoder_ setDepthStencilState:depth_stencil_];
29}
◆ SetEncoder()
void impeller::PassBindingsCacheMTL::SetEncoder |
( |
id< MTLRenderCommandEncoder > |
encoder | ) |
|
◆ SetRenderPipelineState()
void impeller::PassBindingsCacheMTL::SetRenderPipelineState |
( |
id< MTLRenderPipelineState > |
pipeline | ) |
|
Definition at line 13 of file pass_bindings_cache_mtl.mm.
14 {
15 if (pipeline == pipeline_) {
16 return;
17 }
18 pipeline_ = pipeline;
19 [encoder_ setRenderPipelineState:pipeline_];
20}
◆ SetSampler()
bool impeller::PassBindingsCacheMTL::SetSampler |
( |
ShaderStage |
stage, |
|
|
uint64_t |
index, |
|
|
id< MTLSamplerState > |
sampler |
|
) |
| |
Definition at line 99 of file pass_bindings_cache_mtl.mm.
101 {
102 auto& sampler_map = samplers_[stage];
103 auto found = sampler_map.find(index);
104 if (found != sampler_map.end() && found->second == sampler) {
105
106 return true;
107 }
108 sampler_map[index] = sampler;
109 switch (stage) {
111 [encoder_ setVertexSamplerState:sampler atIndex:index];
112 return true;
114 [encoder_ setFragmentSamplerState:sampler atIndex:index];
115 return true;
116 default:
118 return false;
119 }
120 return false;
121}
◆ SetScissor()
void impeller::PassBindingsCacheMTL::SetScissor |
( |
const IRect & |
scissor | ) |
|
Definition at line 138 of file pass_bindings_cache_mtl.mm.
138 {
139 if (scissor_.has_value() && scissor_.value() == scissor) {
140 return;
141 }
142 [encoder_
143 setScissorRect:MTLScissorRect{
144 .x = static_cast<NSUInteger>(scissor.GetX()),
145 .
y =
static_cast<NSUInteger
>(scissor.GetY()),
146 .
width =
static_cast<NSUInteger
>(scissor.GetWidth()),
147 .
height =
static_cast<NSUInteger
>(scissor.GetHeight()),
148 }];
149 scissor_ = scissor;
150}
◆ SetTexture()
bool impeller::PassBindingsCacheMTL::SetTexture |
( |
ShaderStage |
stage, |
|
|
uint64_t |
index, |
|
|
id< MTLTexture > |
texture |
|
) |
| |
Definition at line 75 of file pass_bindings_cache_mtl.mm.
77 {
78 auto& texture_map = textures_[stage];
79 auto found = texture_map.find(index);
80 if (found != texture_map.end() && found->second ==
texture) {
81
82 return true;
83 }
85 switch (stage) {
87 [encoder_ setVertexTexture:
texture atIndex:index];
88 return true;
90 [encoder_ setFragmentTexture:
texture atIndex:index];
91 return true;
92 default:
94 return false;
95 }
96 return false;
97}
◆ SetViewport()
void impeller::PassBindingsCacheMTL::SetViewport |
( |
const Viewport & |
viewport | ) |
|
Definition at line 123 of file pass_bindings_cache_mtl.mm.
123 {
124 if (viewport_.has_value() && viewport_.value() == viewport) {
125 return;
126 }
127 [encoder_ setViewport:MTLViewport{
128 .originX = viewport.rect.GetX(),
129 .originY = viewport.rect.GetY(),
130 .width = viewport.rect.GetWidth(),
131 .height = viewport.rect.GetHeight(),
132 .znear = viewport.depth_range.z_near,
133 .zfar = viewport.depth_range.z_far,
134 }];
135 viewport_ = viewport;
136}
The documentation for this struct was generated from the following files: