23 std::unique_ptr<ProcTableGLES> gl,
24 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries,
25 bool enable_gpu_tracing,
26 std::shared_ptr<fml::BasicTaskRunner> io_task_runner) {
27 return std::shared_ptr<ContextGLES>(
28 new ContextGLES(flags, std::move(gl), shader_libraries,
29 enable_gpu_tracing, std::move(io_task_runner)));
32ContextGLES::ContextGLES(
34 std::unique_ptr<ProcTableGLES> gl,
35 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_mappings,
36 bool enable_gpu_tracing,
37 std::shared_ptr<fml::BasicTaskRunner> io_task_runner)
39 reactor_ = std::make_shared<ReactorGLES>(std::move(gl));
40 if (!reactor_->IsValid()) {
47 auto library = std::shared_ptr<ShaderLibraryGLES>(
48 new ShaderLibraryGLES(shader_libraries_mappings));
49 if (!library->IsValid()) {
53 shader_library_ = std::move(library);
58 pipeline_library_ = std::shared_ptr<PipelineLibraryGLES>(
59 new PipelineLibraryGLES(reactor_, std::move(io_task_runner)));
65 std::shared_ptr<AllocatorGLES>(
new AllocatorGLES(reactor_));
66 if (!resource_allocator_->IsValid()) {
72 device_capabilities_ = reactor_->GetProcTable().GetCapabilities();
77 std::shared_ptr<SamplerLibraryGLES>(
new SamplerLibraryGLES(
78 device_capabilities_->SupportsDecalSamplerAddressMode()));
82 command_queue_ = std::make_shared<CommandQueue>();
97 const std::shared_ptr<ReactorGLES::Worker>& worker) {
101 return reactor_->AddWorker(worker);
108 return reactor_->RemoveWorker(
id);
111bool ContextGLES::IsValid()
const {
115void ContextGLES::Shutdown() {}
118std::string ContextGLES::DescribeGpuModel()
const {
119 return reactor_->GetProcTable().GetDescription()->GetString();
123std::shared_ptr<Allocator> ContextGLES::GetResourceAllocator()
const {
124 return resource_allocator_;
127std::shared_ptr<const GpuSubmissionTracker> ContextGLES::GetSubmissionTracker()
129 return submission_tracker_;
132const std::shared_ptr<GpuSubmissionTracker>&
134 return submission_tracker_;
138std::shared_ptr<ShaderLibrary> ContextGLES::GetShaderLibrary()
const {
139 return shader_library_;
143std::shared_ptr<SamplerLibrary> ContextGLES::GetSamplerLibrary()
const {
144 return sampler_library_;
148std::shared_ptr<PipelineLibrary> ContextGLES::GetPipelineLibrary()
const {
149 return pipeline_library_;
153std::shared_ptr<CommandBuffer> ContextGLES::CreateCommandBuffer()
const {
154 return std::shared_ptr<CommandBufferGLES>(
155 new CommandBufferGLES(weak_from_this(), reactor_));
159const std::shared_ptr<const Capabilities>& ContextGLES::GetCapabilities()
161 return device_capabilities_;
165std::shared_ptr<CommandQueue> ContextGLES::GetCommandQueue()
const {
166 return command_queue_;
170void ContextGLES::ResetThreadLocalState()
const {
174 [[maybe_unused]]
auto result =
175 reactor_->AddOperation([](
const ReactorGLES&
reactor) {
180bool ContextGLES::EnqueueCommandBuffer(
186[[nodiscard]]
bool ContextGLES::FlushCommandBuffers() {
187 return reactor_->React();
190bool ContextGLES::FinishQueue() {
191 reactor_->GetProcTable().Finish();
196bool ContextGLES::AddTrackingFence(
197 const std::shared_ptr<Texture>&
texture)
const {
198 if (!reactor_->GetProcTable().FenceSync.IsAvailable()) {
static TextureGLES & Cast(Texture &base)
const std::shared_ptr< GpuSubmissionTracker > & GetMutableSubmissionTracker() const
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
bool RemoveReactorWorker(ReactorGLES::WorkerID id)
static std::shared_ptr< ContextGLES > Create(const Flags &flags, std::unique_ptr< ProcTableGLES > gl, const std::vector< std::shared_ptr< fml::Mapping > > &shader_libraries, bool enable_gpu_tracing, std::shared_ptr< fml::BasicTaskRunner > io_task_runner=nullptr)
const std::shared_ptr< ReactorGLES > & GetReactor() const
std::optional< ReactorGLES::WorkerID > AddReactorWorker(const std::shared_ptr< ReactorGLES::Worker > &worker)
To do anything rendering related with Impeller, you need a context.
static void ResetGLState(const ProcTableGLES &gl)
void SetFence(HandleGLES fence)
Attach a sync fence to this texture that will be waited on before encoding a rendering operation that...
const ProcTable & GetProcTable()
std::shared_ptr< ReactorGLES > reactor
std::shared_ptr< CommandBuffer > command_buffer