7 #include <Metal/Metal.h>
12 #include "flutter/fml/concurrent_message_loop.h"
13 #include "flutter/fml/macros.h"
14 #include "flutter/fml/synchronization/sync_switch.h"
24 #if TARGET_OS_SIMULATOR
25 #define IMPELLER_CA_METAL_LAYER_AVAILABLE API_AVAILABLE(macos(10.11), ios(13.0))
26 #else // TARGET_OS_SIMULATOR
27 #define IMPELLER_CA_METAL_LAYER_AVAILABLE API_AVAILABLE(macos(10.11), ios(8.0))
28 #endif // TARGET_OS_SIMULATOR
34 public std::enable_shared_from_this<ContextMTL> {
36 static std::shared_ptr<ContextMTL>
Create(
37 const std::vector<std::string>& shader_library_paths,
38 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch);
40 static std::shared_ptr<ContextMTL>
Create(
41 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data,
42 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
43 const std::string& label);
45 static std::shared_ptr<ContextMTL>
Create(
47 id<MTLCommandQueue> command_queue,
48 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data,
49 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
50 const std::string& label);
82 const std::shared_ptr<const Capabilities>&
GetCapabilities()
const override;
97 id<MTLDevice> device_ =
nullptr;
98 id<MTLCommandQueue> command_queue_ =
nullptr;
99 std::shared_ptr<ShaderLibraryMTL> shader_library_;
100 std::shared_ptr<PipelineLibraryMTL> pipeline_library_;
101 std::shared_ptr<SamplerLibrary> sampler_library_;
102 std::shared_ptr<AllocatorMTL> resource_allocator_;
103 std::shared_ptr<const Capabilities> device_capabilities_;
104 std::shared_ptr<fml::ConcurrentMessageLoop> raster_message_loop_;
105 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch_;
106 bool is_valid_ =
false;
109 id<MTLDevice> device,
110 id<MTLCommandQueue> command_queue,
111 NSArray<id<MTLLibrary>>* shader_libraries,
112 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch);
114 std::shared_ptr<CommandBuffer> CreateCommandBufferInQueue(
115 id<MTLCommandQueue> queue)
const;