 |
Flutter Impeller
|
|
Go to the documentation of this file.
5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_CONTEXT_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_CONTEXT_VK_H_
10 #include "flutter/fml/concurrent_message_loop.h"
11 #include "flutter/fml/mapping.h"
12 #include "flutter/fml/unique_fd.h"
13 #include "fml/thread.h"
31 class CommandEncoderFactoryVK;
32 class CommandEncoderVK;
33 class CommandPoolRecyclerVK;
36 class ResourceManagerVK;
37 class SurfaceContextVK;
39 class DescriptorPoolRecyclerVK;
44 public std::enable_shared_from_this<ContextVK> {
68 uint64_t
GetHash()
const {
return hash_; }
98 const std::shared_ptr<const Capabilities>&
GetCapabilities()
const override;
108 template <
typename T>
113 template <
typename T>
116 std::string_view label) {
122 auto c_handle =
static_cast<typename T::CType
>(handle);
124 vk::DebugUtilsObjectNameInfoEXT info;
125 info.objectType = T::objectType;
126 info.pObjectName = label.data();
127 info.objectHandle =
reinterpret_cast<decltype(info.objectHandle)
>(c_handle);
129 if (device.setDebugUtilsObjectNameEXT(info) != vk::Result::eSuccess) {
138 return device_holder_;
147 const std::shared_ptr<fml::ConcurrentTaskRunner>
183 const vk::Device&
GetDevice()
const override {
return device.get(); }
186 return physical_device;
189 vk::UniqueInstance instance;
190 vk::PhysicalDevice physical_device;
191 vk::UniqueDevice device;
194 std::shared_ptr<DeviceHolderImpl> device_holder_;
195 std::unique_ptr<DriverInfoVK> driver_info_;
196 std::unique_ptr<DebugReportVK> debug_report_;
197 std::shared_ptr<Allocator> allocator_;
198 std::shared_ptr<ShaderLibraryVK> shader_library_;
199 std::shared_ptr<SamplerLibraryVK> sampler_library_;
200 std::shared_ptr<PipelineLibraryVK> pipeline_library_;
201 std::shared_ptr<YUVConversionLibraryVK> yuv_conversion_library_;
203 std::shared_ptr<const Capabilities> device_capabilities_;
204 std::shared_ptr<FenceWaiterVK> fence_waiter_;
205 std::shared_ptr<ResourceManagerVK> resource_manager_;
206 std::shared_ptr<CommandPoolRecyclerVK> command_pool_recycler_;
207 std::string device_name_;
208 std::shared_ptr<fml::ConcurrentMessageLoop> raster_message_loop_;
209 std::shared_ptr<GPUTracerVK> gpu_tracer_;
210 std::shared_ptr<DescriptorPoolRecyclerVK> descriptor_pool_recycler_;
211 std::shared_ptr<CommandQueue> command_queue_vk_;
212 bool should_disable_surface_control_ =
false;
214 const uint64_t hash_;
216 bool is_valid_ =
false;
220 void Setup(Settings settings);
222 ContextVK(
const ContextVK&) =
delete;
224 ContextVK& operator=(
const ContextVK&) =
delete;
229 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_CONTEXT_VK_H_
const std::shared_ptr< const Capabilities > & GetCapabilities() const override
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
Holds a strong reference to the underlying logical Vulkan device. This comes in handy when the contex...
const std::shared_ptr< fml::ConcurrentTaskRunner > GetConcurrentWorkerTaskRunner() const
std::shared_ptr< DeviceHolderVK > GetDeviceHolder() const
static bool SetDebugName(const vk::Device &device, T handle, std::string_view label)
std::shared_ptr< CommandQueue > GetCommandQueue() const override
Return the graphics queue for submitting command buffers.
bool IsValid() const override
Determines if a context is valid. If the caller ever receives an invalid context, they must discard i...
vk::Instance GetInstance() const
vk::PhysicalDevice GetPhysicalDevice() const
std::shared_ptr< Allocator > GetResourceAllocator() const override
Returns the allocator used to create textures and buffers on the device.
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
std::shared_ptr< CommandBuffer > CreateCommandBuffer() const override
Create a new command buffer. Command buffers can be used to encode graphics, blit,...
void RecordFrameEndTime() const
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
bool disable_surface_control
bool fatal_missing_validations
If validations are requested but cannot be enabled, log a fatal error.
std::shared_ptr< SurfaceContextVK > CreateSurfaceContext()
std::shared_ptr< ShaderLibrary > GetShaderLibrary() const override
Returns the library of shaders used to specify the programmable stages of a pipeline.
bool GetShouldDisableSurfaceControlSwapchain() const
Whether the Android Surface control based swapchain should be disabled, even if the device is capable...
PFN_vkGetInstanceProcAddr proc_address_callback
const std::shared_ptr< QueueVK > & GetGraphicsQueue() const
std::shared_ptr< DescriptorPoolRecyclerVK > GetDescriptorPoolRecycler() const
std::vector< std::shared_ptr< fml::Mapping > > shader_libraries_data
static std::shared_ptr< ContextVK > Create(Settings settings)
bool SetDebugName(T handle, std::string_view label) const
std::shared_ptr< CommandPoolRecyclerVK > GetCommandPoolRecycler() const
std::shared_ptr< GPUTracerVK > GetGPUTracer() const
void InitializeCommonlyUsedShadersIfNeeded() const override
fml::UniqueFD cache_directory
std::shared_ptr< SamplerLibrary > GetSamplerLibrary() const override
Returns the library of combined image samplers used in shaders.
To do anything rendering related with Impeller, you need a context.
const vk::Device & GetDevice() const
static size_t ChooseThreadCountForWorkers(size_t hardware_concurrency)
std::shared_ptr< ResourceManagerVK > GetResourceManager() const
const std::unique_ptr< DriverInfoVK > & GetDriverInfo() const
const std::shared_ptr< YUVConversionLibraryVK > & GetYUVConversionLibrary() const
std::shared_ptr< PipelineLibrary > GetPipelineLibrary() const override
Returns the library of pipelines used by render or compute commands.
std::string DescribeGpuModel() const override
std::shared_ptr< FenceWaiterVK > GetFenceWaiter() const
void SetOffscreenFormat(PixelFormat pixel_format)
bool HasValidationLayers()
void Shutdown() override
Force all pending asynchronous work to finish. This is achieved by deleting all owned concurrent mess...
void DisposeThreadLocalCachedResources() override