7 #include "flutter/fml/trace_event.h"
17 :
Context(parent->GetFlags()), parent_(parent) {}
22 return parent_->GetBackendType();
26 return parent_->DescribeGpuModel();
30 return parent_->IsValid();
34 return parent_->GetResourceAllocator();
38 return parent_->GetShaderLibrary();
42 return parent_->GetSamplerLibrary();
46 return parent_->GetPipelineLibrary();
50 return parent_->CreateCommandBuffer();
54 return parent_->GetCommandQueue();
59 return parent_->GetCapabilities();
63 return parent_->GetIdleWaiter();
83 if (!swapchain || !swapchain->IsValid()) {
87 swapchain_ = std::move(swapchain);
92 TRACE_EVENT0(
"impeller", __FUNCTION__);
93 auto surface = swapchain_ ? swapchain_->AcquireNextDrawable() :
nullptr;
102 if (
auto pipeline_library = parent_->GetPipelineLibrary()) {
106 parent_->DisposeThreadLocalCachedResources();
107 parent_->GetResourceAllocator()->DebugTraceMemoryStatistics();
111 swapchain_->UpdateSurfaceSize(size);
115 return parent_->GetDevice();
119 parent_->InitializeCommonlyUsedShadersIfNeeded();
123 parent_->DisposeThreadLocalCachedResources();
131 std::shared_ptr<CommandBuffer> command_buffer) {
132 return parent_->EnqueueCommandBuffer(std::move(command_buffer));
136 return parent_->FlushCommandBuffers();
140 std::shared_ptr<CommandBuffer> cmd_buffer) {
141 swapchain_->AddFinalCommandBuffer(std::move(cmd_buffer));
146 return parent_->GetRuntimeStageBackend();
static PipelineLibraryVK & Cast(PipelineLibrary &base)
To do anything rendering related with Impeller, you need a context.
void DidAcquireSurfaceFrame()
bool SetWindowSurface(vk::UniqueSurfaceKHR surface, const ISize &size)
SurfaceContextVK(const std::shared_ptr< ContextVK > &parent)
RuntimeStageBackend GetRuntimeStageBackend() const override
Retrieve the runtime stage for this context type.
std::shared_ptr< PipelineLibrary > GetPipelineLibrary() const override
Returns the library of pipelines used by render or compute commands.
void MarkFrameEnd()
Performs frame incrementing processes like AcquireNextSurface but without the surface.
void TeardownSwapchain()
Can be called when the surface is destroyed to reduce memory usage.
bool EnqueueCommandBuffer(std::shared_ptr< CommandBuffer > command_buffer) override
Enqueue command_buffer for submission by the end of the frame.
bool SubmitOnscreen(std::shared_ptr< CommandBuffer > cmd_buffer) override
Submit the command buffer that renders to the onscreen surface.
const std::shared_ptr< ContextVK > & GetParent() const
bool SetSwapchain(std::shared_ptr< SwapchainVK > swapchain)
bool FlushCommandBuffers() override
Flush all pending command buffers.
~SurfaceContextVK() override
const std::shared_ptr< const Capabilities > & GetCapabilities() const override
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
std::string DescribeGpuModel() const override
bool IsValid() const override
Determines if a context is valid. If the caller ever receives an invalid context, they must discard i...
void UpdateSurfaceSize(const ISize &size) const
Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.
std::unique_ptr< Surface > AcquireNextSurface()
std::shared_ptr< const IdleWaiter > GetIdleWaiter() const override
const vk::Device & GetDevice() const
void DisposeThreadLocalCachedResources() override
std::shared_ptr< SamplerLibrary > GetSamplerLibrary() const override
Returns the library of combined image samplers used in shaders.
std::shared_ptr< CommandQueue > GetCommandQueue() const override
Return the graphics queue for submitting command buffers.
void Shutdown() override
Force all pending asynchronous work to finish. This is achieved by deleting all owned concurrent mess...
std::shared_ptr< CommandBuffer > CreateCommandBuffer() const override
Create a new command buffer. Command buffers can be used to encode graphics, blit,...
std::shared_ptr< ShaderLibrary > GetShaderLibrary() const override
Returns the library of shaders used to specify the programmable stages of a pipeline.
void InitializeCommonlyUsedShadersIfNeeded() const override
std::shared_ptr< Allocator > GetResourceAllocator() const override
Returns the allocator used to create textures and buffers on the device.
static std::shared_ptr< SwapchainVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)