MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ fallback_renderer()

void MayaFlux::Buffers::PresentProcessor::fallback_renderer ( const std::shared_ptr< RootGraphicsBuffer > &  root)
private

Definition at line 202 of file RootGraphicsBuffer.cpp.

203{
204 const auto& renderable_buffers = root->get_renderable_buffers();
205 if (renderable_buffers.empty()) {
207 "No renderable buffers found in fallback renderer");
208 return;
209 }
210
211 std::unordered_map<Core::Window*, std::vector<const RootGraphicsBuffer::RenderableBufferInfo*>> buffers_by_window;
212 for (const auto& renderable : renderable_buffers) {
213 if (renderable.target_window && renderable.target_window->is_graphics_registered()
214 && renderable.command_buffer_id != Portal::Graphics::INVALID_COMMAND_BUFFER) {
215 buffers_by_window[renderable.target_window.get()].push_back(&renderable);
216 }
217 }
218
219 if (buffers_by_window.empty()) {
220 root->clear_renderable_buffers();
221 return;
222 }
223
225 "PresentProcessor submitting to {} windows", buffers_by_window.size());
226
227 auto& foundry = Portal::Graphics::get_shader_foundry();
229 auto display_service = Registry::BackendRegistry::instance()
230 .get_service<Registry::Service::DisplayService>();
231
232 if (!display_service) {
234 "DisplayService not available for dynamic rendering");
235 return;
236 }
237
238 for (const auto& [window_ptr, buffer_infos] : buffers_by_window) {
239 auto window = buffer_infos[0]->target_window;
240
241 uint64_t image_bits = display_service->acquire_next_swapchain_image(window);
242 if (image_bits == 0) {
244 "Failed to acquire swapchain image for window '{}'",
245 window->get_create_info().title);
246 continue;
247 }
248 vk::Image swapchain_image { reinterpret_cast<VkImage>(image_bits) };
249
250 auto primary_cmd_id = foundry.begin_commands(Portal::Graphics::ShaderFoundry::CommandBufferType::GRAPHICS);
251 auto primary_cmd = foundry.get_command_buffer(primary_cmd_id);
252
253 if (!primary_cmd) {
255 "Failed to create primary command buffer for window '{}'",
256 window->get_create_info().title);
257 for (const auto* info : buffer_infos) {
258 info->buffer->clear_pipeline_commands();
259 }
260 continue;
261 }
262
263 try {
264 flow.begin_rendering(primary_cmd_id, window, swapchain_image);
265
266 std::vector<vk::CommandBuffer> secondary_buffers;
267 for (const auto* info : buffer_infos) {
268 auto secondary = foundry.get_command_buffer(info->command_buffer_id);
269 if (secondary) {
270 secondary_buffers.push_back(secondary);
271 }
272 }
273
274 if (!secondary_buffers.empty()) {
275 primary_cmd.executeCommands(secondary_buffers);
276 }
277
278 flow.end_rendering(primary_cmd_id, window);
279
280 foundry.end_commands(primary_cmd_id);
281 uint64_t primary_bits = *reinterpret_cast<uint64_t*>(&primary_cmd);
282 display_service->submit_and_present(window, primary_bits);
283
285 "Presented {} buffers to window '{}'",
286 secondary_buffers.size(), window->get_create_info().title);
287
288 } catch (const std::exception& e) {
290 "Failed to submit/present for window '{}': {}",
291 window->get_create_info().title,
292 e.what());
293 }
294
295 for (const auto* info : buffer_infos) {
296 info->buffer->clear_pipeline_commands();
297 }
298 }
299
300 root->clear_renderable_buffers();
301}
#define MF_RT_WARN(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
#define MF_RT_DEBUG(comp, ctx,...)
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
MAYAFLUX_API RenderFlow & get_render_flow()
Get the global render flow instance.
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.
constexpr CommandBufferID INVALID_COMMAND_BUFFER

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Portal::Graphics::get_render_flow(), MayaFlux::Registry::BackendRegistry::get_service(), MayaFlux::Portal::Graphics::get_shader_foundry(), MayaFlux::Portal::Graphics::ShaderFoundry::GRAPHICS, MayaFlux::Registry::BackendRegistry::instance(), MayaFlux::Portal::Graphics::INVALID_COMMAND_BUFFER, MF_RT_DEBUG, MF_RT_ERROR, and MF_RT_WARN.

Referenced by processing_function().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: