5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_PASS_BINDINGS_CACHE_MTL_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_PASS_BINDINGS_CACHE_MTL_H_
8 #include <Metal/Metal.h>
33 void SetEncoder(id<MTLRenderCommandEncoder> encoder);
42 id<MTLBuffer> buffer);
48 id<MTLSamplerState> sampler);
55 struct BufferOffsetPair {
56 id<MTLBuffer> buffer =
nullptr;
59 using BufferMap = std::map<uint64_t, BufferOffsetPair>;
60 using TextureMap = std::map<uint64_t, id<MTLTexture>>;
61 using SamplerMap = std::map<uint64_t, id<MTLSamplerState>>;
63 id<MTLRenderCommandEncoder> encoder_;
64 id<MTLRenderPipelineState> pipeline_ =
nullptr;
65 id<MTLDepthStencilState> depth_stencil_ =
nullptr;
66 std::map<ShaderStage, BufferMap> buffers_;
67 std::map<ShaderStage, TextureMap> textures_;
68 std::map<ShaderStage, SamplerMap> samplers_;
69 std::optional<Viewport> viewport_;
70 std::optional<IRect> scissor_;
Ensures that bindings on the pass are not redundantly set or updated. Avoids making the driver do add...
PassBindingsCacheMTL(const PassBindingsCacheMTL &)=delete
void SetScissor(const IRect &scissor)
~PassBindingsCacheMTL()=default
void SetRenderPipelineState(id< MTLRenderPipelineState > pipeline)
bool SetSampler(ShaderStage stage, uint64_t index, id< MTLSamplerState > sampler)
bool SetBuffer(ShaderStage stage, uint64_t index, uint64_t offset, id< MTLBuffer > buffer)
void SetViewport(const Viewport &viewport)
void SetDepthStencilState(id< MTLDepthStencilState > depth_stencil)
void SetEncoder(id< MTLRenderCommandEncoder > encoder)
bool SetTexture(ShaderStage stage, uint64_t index, id< MTLTexture > texture)
PassBindingsCacheMTL(PassBindingsCacheMTL &&)=delete