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.h>
|
| | PassBindingsCache (id< MTLRenderCommandEncoder > encoder) |
| |
| | PassBindingsCache (const PassBindingsCache &)=delete |
| |
| | PassBindingsCache (PassBindingsCache &&)=delete |
| |
| void | SetRenderPipelineState (id< MTLRenderPipelineState > pipeline) |
| |
| void | SetDepthStencilState (id< MTLDepthStencilState > depth_stencil) |
| |
| bool | SetBuffer (ShaderStage stage, uint64_t index, uint64_t offset, id< MTLBuffer > buffer) |
| |
| bool | SetTexture (ShaderStage stage, uint64_t index, id< MTLTexture > texture) |
| |
| bool | SetSampler (ShaderStage stage, uint64_t index, id< MTLSamplerState > sampler) |
| |
| void | SetViewport (const Viewport &viewport) |
| |
| void | SetScissor (const IRect &scissor) |
| |
| void | BindPipeline (vk::CommandBuffer command_buffer, vk::PipelineBindPoint pipeline_bind_point, vk::Pipeline pipeline) |
| |
| void | SetStencilReference (vk::CommandBuffer command_buffer, vk::StencilFaceFlags face_mask, uint32_t reference) |
| |
| void | SetScissor (vk::CommandBuffer command_buffer, uint32_t first_scissor, uint32_t scissor_count, const vk::Rect2D *scissors) |
| |
| void | SetViewport (vk::CommandBuffer command_buffer, uint32_t first_viewport, uint32_t viewport_count, const vk::Viewport *viewports) |
| |
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 195 of file render_pass_mtl.mm.
◆ PassBindingsCache() [1/3]
| impeller::PassBindingsCache::PassBindingsCache |
( |
id< MTLRenderCommandEncoder > |
encoder | ) |
|
|
inlineexplicit |
◆ PassBindingsCache() [2/3]
◆ PassBindingsCache() [3/3]
◆ BindPipeline()
| void impeller::PassBindingsCache::BindPipeline |
( |
vk::CommandBuffer |
command_buffer, |
|
|
vk::PipelineBindPoint |
pipeline_bind_point, |
|
|
vk::Pipeline |
pipeline |
|
) |
| |
Definition at line 8 of file pass_bindings_cache.cc.
11 switch (pipeline_bind_point) {
12 case vk::PipelineBindPoint::eGraphics:
13 if (graphics_pipeline_.has_value() &&
14 graphics_pipeline_.value() == pipeline) {
17 graphics_pipeline_ = pipeline;
19 case vk::PipelineBindPoint::eCompute:
20 if (compute_pipeline_.has_value() &&
21 compute_pipeline_.value() == pipeline) {
24 compute_pipeline_ = pipeline;
29 command_buffer.bindPipeline(pipeline_bind_point, pipeline);
Referenced by impeller::testing::TEST().
◆ SetBuffer()
| bool impeller::PassBindingsCache::SetBuffer |
( |
ShaderStage |
stage, |
|
|
uint64_t |
index, |
|
|
uint64_t |
offset, |
|
|
id< MTLBuffer > |
buffer |
|
) |
| |
|
inline |
Definition at line 219 of file render_pass_mtl.mm.
223 auto& buffers_map = buffers_[stage];
224 auto found = buffers_map.find(index);
225 if (found != buffers_map.end() && found->second.buffer == buffer) {
227 if (found->second.offset == offset) {
233 found->second.offset = offset;
237 [encoder_ setVertexBufferOffset:offset atIndex:index];
240 [encoder_ setFragmentBufferOffset:offset atIndex:index];
243 VALIDATION_LOG <<
"Cannot update buffer offset of an unknown stage.";
248 buffers_map[index] = {buffer,
static_cast<size_t>(offset)};
251 [encoder_ setVertexBuffer:buffer offset:offset atIndex:index];
254 [encoder_ setFragmentBuffer:buffer offset:offset atIndex:index];
References VALIDATION_LOG.
Referenced by impeller::Bind().
◆ SetDepthStencilState()
| void impeller::PassBindingsCache::SetDepthStencilState |
( |
id< MTLDepthStencilState > |
depth_stencil | ) |
|
|
inline |
Definition at line 211 of file render_pass_mtl.mm.
212 if (depth_stencil_ == depth_stencil) {
215 depth_stencil_ = depth_stencil;
216 [encoder_ setDepthStencilState:depth_stencil_];
◆ SetRenderPipelineState()
| void impeller::PassBindingsCache::SetRenderPipelineState |
( |
id< MTLRenderPipelineState > |
pipeline | ) |
|
|
inline |
Definition at line 203 of file render_pass_mtl.mm.
204 if (pipeline == pipeline_) {
207 pipeline_ = pipeline;
208 [encoder_ setRenderPipelineState:pipeline_];
◆ SetSampler()
| bool impeller::PassBindingsCache::SetSampler |
( |
ShaderStage |
stage, |
|
|
uint64_t |
index, |
|
|
id< MTLSamplerState > |
sampler |
|
) |
| |
|
inline |
Definition at line 285 of file render_pass_mtl.mm.
288 auto& sampler_map = samplers_[stage];
289 auto found = sampler_map.find(index);
290 if (found != sampler_map.end() && found->second == sampler) {
294 sampler_map[index] = sampler;
297 [encoder_ setVertexSamplerState:sampler atIndex:index];
300 [encoder_ setFragmentSamplerState:sampler atIndex:index];
References VALIDATION_LOG.
Referenced by impeller::Bind().
◆ SetScissor() [1/2]
| void impeller::PassBindingsCache::SetScissor |
( |
const IRect & |
scissor | ) |
|
|
inline |
◆ SetScissor() [2/2]
| void impeller::PassBindingsCache::SetScissor |
( |
vk::CommandBuffer |
command_buffer, |
|
|
uint32_t |
first_scissor, |
|
|
uint32_t |
scissor_count, |
|
|
const vk::Rect2D * |
scissors |
|
) |
| |
Definition at line 45 of file pass_bindings_cache.cc.
49 if (first_scissor == 0 && scissor_count == 1) {
50 if (scissors_.has_value() && scissors_.value() == scissors[0]) {
53 scissors_ = scissors[0];
55 command_buffer.setScissor(first_scissor, scissor_count, scissors);
◆ SetStencilReference()
| void impeller::PassBindingsCache::SetStencilReference |
( |
vk::CommandBuffer |
command_buffer, |
|
|
vk::StencilFaceFlags |
face_mask, |
|
|
uint32_t |
reference |
|
) |
| |
Definition at line 32 of file pass_bindings_cache.cc.
35 if (stencil_face_flags_.has_value() &&
36 face_mask == stencil_face_flags_.value() &&
37 reference == stencil_reference_) {
40 stencil_face_flags_ = face_mask;
41 stencil_reference_ = reference;
42 command_buffer.setStencilReference(face_mask, reference);
Referenced by impeller::testing::TEST().
◆ SetTexture()
| bool impeller::PassBindingsCache::SetTexture |
( |
ShaderStage |
stage, |
|
|
uint64_t |
index, |
|
|
id< MTLTexture > |
texture |
|
) |
| |
|
inline |
Definition at line 263 of file render_pass_mtl.mm.
264 auto& texture_map = textures_[stage];
265 auto found = texture_map.find(index);
266 if (found != texture_map.end() && found->second == texture) {
270 texture_map[index] = texture;
273 [encoder_ setVertexTexture:texture atIndex:index];
276 [encoder_ setFragmentTexture:texture atIndex:index];
References VALIDATION_LOG.
Referenced by impeller::Bind().
◆ SetViewport() [1/2]
| void impeller::PassBindingsCache::SetViewport |
( |
const Viewport & |
viewport | ) |
|
|
inline |
Definition at line 309 of file render_pass_mtl.mm.
310 if (viewport_.has_value() && viewport_.value() == viewport) {
313 [encoder_ setViewport:MTLViewport{
314 .originX = viewport.rect.GetX(),
315 .originY = viewport.rect.GetY(),
316 .width = viewport.rect.GetWidth(),
317 .height = viewport.rect.GetHeight(),
318 .znear = viewport.depth_range.z_near,
319 .zfar = viewport.depth_range.z_far,
321 viewport_ = viewport;
References impeller::Viewport::depth_range, impeller::TRect< T >::GetHeight(), impeller::TRect< T >::GetWidth(), impeller::TRect< T >::GetX(), impeller::TRect< T >::GetY(), impeller::Viewport::rect, impeller::DepthRange::z_far, and impeller::DepthRange::z_near.
Referenced by impeller::SetViewportAndScissor(), and impeller::testing::TEST().
◆ SetViewport() [2/2]
| void impeller::PassBindingsCache::SetViewport |
( |
vk::CommandBuffer |
command_buffer, |
|
|
uint32_t |
first_viewport, |
|
|
uint32_t |
viewport_count, |
|
|
const vk::Viewport * |
viewports |
|
) |
| |
Definition at line 58 of file pass_bindings_cache.cc.
62 if (first_viewport == 0 && viewport_count == 1) {
64 if (viewport_.has_value() && viewport_.value() == viewports[0]) {
67 viewport_ = viewports[0];
69 command_buffer.setViewport(first_viewport, viewport_count, viewports);
The documentation for this class was generated from the following files: