| Flutter Impeller |

Classes | Public Member Functions | List of all members
impeller::ComputePassBindingsCacheMTL Struct Reference

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 <compute_pass_bindings_cache_mtl.h>`

## Public Member Functions
| ComputePassBindingsCacheMTL ()
| ComputePassBindingsCacheMTL (const ComputePassBindingsCacheMTL &)=delete
| ComputePassBindingsCacheMTL (ComputePassBindingsCacheMTL &&)=delete
void | SetComputePipelineState (id< MTLComputePipelineState > pipeline)
id< MTLComputePipelineState > | GetPipeline () const
void | SetEncoder (id< MTLComputeCommandEncoder > encoder)
void | SetBuffer (uint64_t index, uint64_t offset, id< MTLBuffer > buffer)
void | SetTexture (uint64_t index, id< MTLTexture > texture)
void | SetSampler (uint64_t index, id< MTLSamplerState > sampler)

## Detailed Description

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 compute_pass_bindings_cache_mtl.h.

## Constructor & Destructor Documentation

## ◆ ComputePassBindingsCacheMTL() [1/3]

impeller::ComputePassBindingsCacheMTL::ComputePassBindingsCacheMTL | ( |  | ) |
| inlineexplicit

Definition at line 25 of file compute_pass_bindings_cache_mtl.h.

25 {}

## ◆ ComputePassBindingsCacheMTL() [2/3]

impeller::ComputePassBindingsCacheMTL::ComputePassBindingsCacheMTL | ( | const ComputePassBindingsCacheMTL & |  | ) |
| delete

## ◆ ComputePassBindingsCacheMTL() [3/3]

impeller::ComputePassBindingsCacheMTL::ComputePassBindingsCacheMTL | ( | ComputePassBindingsCacheMTL && |  | ) |
| delete

## Member Function Documentation

## ◆ GetPipeline()

id< MTLComputePipelineState > impeller::ComputePassBindingsCacheMTL::GetPipeline | ( |  | ) | const

Definition at line 18 of file compute_pass_bindings_cache_mtl.mm.

18 {
19 return pipeline_;
20 }

## ◆ SetBuffer()

void impeller::ComputePassBindingsCacheMTL::SetBuffer | ( | uint64_t | index,
|  | uint64_t | offset,
|  | id< MTLBuffer > | buffer
| ) |  |

Definition at line 27 of file compute_pass_bindings_cache_mtl.mm.

29 {
30 auto found = buffers_.find(index);
31 if (found != buffers_.end() && found->second.buffer == buffer) {
32 // The right buffer is bound. Check if its offset needs to be updated.
33 if (found->second.offset == offset) {
34 // Buffer and its offset is identical. Nothing to do.
35 return;
36 }
37
38 // Only the offset needs to be updated.
39 found->second.offset = offset;
40
41 [encoder_ setBufferOffset:offset atIndex:index];
42 return;
43 }
44
45 buffers_[index] = {buffer, static_cast<size_t>(offset)};
46 [encoder_ setBuffer:buffer offset:offset atIndex:index];
47 }

## ◆ SetComputePipelineState()

void impeller::ComputePassBindingsCacheMTL::SetComputePipelineState | ( | id< MTLComputePipelineState > | pipeline | ) |

Definition at line 9 of file compute_pass_bindings_cache_mtl.mm.

10 {
11 if (pipeline == pipeline_) {
12 return;
13 }
14 pipeline_ = pipeline;
15 [encoder_ setComputePipelineState:pipeline_];
16 }

## ◆ SetEncoder()

void impeller::ComputePassBindingsCacheMTL::SetEncoder | ( | id< MTLComputeCommandEncoder > | encoder | ) |

Definition at line 22 of file compute_pass_bindings_cache_mtl.mm.

23 {
24 encoder_ = encoder;
25 }

## ◆ SetSampler()

void impeller::ComputePassBindingsCacheMTL::SetSampler | ( | uint64_t | index,
|  | id< MTLSamplerState > | sampler
| ) |  |

Definition at line 61 of file compute_pass_bindings_cache_mtl.mm.

62 {
63 auto found = samplers_.find(index);
64 if (found != samplers_.end() && found->second == sampler) {
65 // Already bound.
66 return;
67 }
68 samplers_[index] = sampler;
69 [encoder_ setSamplerState:sampler atIndex:index];
70 return;
71 }

## ◆ SetTexture()

void impeller::ComputePassBindingsCacheMTL::SetTexture | ( | uint64_t | index,
|  | id< MTLTexture > | texture
| ) |  |

Definition at line 49 of file compute_pass_bindings_cache_mtl.mm.

50 {
51 auto found = textures_.find(index);
52 if (found != textures_.end() && found->second == texture) {
53 // Already bound.
54 return;
55 }
56 textures_[index] = texture;
57 [encoder_ setTexture:texture atIndex:index];
58 return;
59 }

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

- impeller/renderer/backend/metal/compute_pass_bindings_cache_mtl.h
- impeller/renderer/backend/metal/compute_pass_bindings_cache_mtl.mm