Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
compute_pass_bindings_cache_mtl.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_COMPUTE_PASS_BINDINGS_CACHE_MTL_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_COMPUTE_PASS_BINDINGS_CACHE_MTL_H_
7
8#include <Metal/Metal.h>
9
10#include "flutter/fml/macros.h"
13
14namespace impeller {
15
16//-----------------------------------------------------------------------------
17/// @brief Ensures that bindings on the pass are not redundantly set or
18/// updated. Avoids making the driver do additional checks and makes
19/// the frame insights during profiling and instrumentation not
20/// complain about the same.
21///
22/// There should be no change to rendering if this caching was
23/// absent.
24///
27
29
31
32 void SetComputePipelineState(id<MTLComputePipelineState> pipeline);
33
34 id<MTLComputePipelineState> GetPipeline() const;
35
36 void SetEncoder(id<MTLComputeCommandEncoder> encoder);
37
38 void SetBuffer(uint64_t index, uint64_t offset, id<MTLBuffer> buffer);
39
40 void SetTexture(uint64_t index, id<MTLTexture> texture);
41
42 void SetSampler(uint64_t index, id<MTLSamplerState> sampler);
43
44 private:
45 struct BufferOffsetPair {
46 id<MTLBuffer> buffer = nullptr;
47 size_t offset = 0u;
48 };
49 using BufferMap = std::map<uint64_t, BufferOffsetPair>;
50 using TextureMap = std::map<uint64_t, id<MTLTexture>>;
51 using SamplerMap = std::map<uint64_t, id<MTLSamplerState>>;
52
53 id<MTLComputeCommandEncoder> encoder_;
54 id<MTLComputePipelineState> pipeline_ = nullptr;
55 BufferMap buffers_;
56 TextureMap textures_;
57 SamplerMap samplers_;
58};
59
60} // namespace impeller
61
62#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_COMPUTE_PASS_BINDINGS_CACHE_MTL_H_
static const uint8_t buffer[]
FlTexture * texture
std::unordered_map< SamplerDescriptor, std::unique_ptr< const Sampler >, ComparableHash< SamplerDescriptor >, ComparableEqual< SamplerDescriptor > > SamplerMap
Definition sampler.h:35
Point offset
Ensures that bindings on the pass are not redundantly set or updated. Avoids making the driver do add...
void SetEncoder(id< MTLComputeCommandEncoder > encoder)
void SetComputePipelineState(id< MTLComputePipelineState > pipeline)
void SetBuffer(uint64_t index, uint64_t offset, id< MTLBuffer > buffer)
ComputePassBindingsCacheMTL(ComputePassBindingsCacheMTL &&)=delete
void SetSampler(uint64_t index, id< MTLSamplerState > sampler)
ComputePassBindingsCacheMTL(const ComputePassBindingsCacheMTL &)=delete
id< MTLComputePipelineState > GetPipeline() const
void SetTexture(uint64_t index, id< MTLTexture > texture)