MayaFlux 0.3.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 203 of file RootGraphicsBuffer.cpp.

204{
205 const auto& renderable_buffers = root->get_renderable_buffers();
206 if (renderable_buffers.empty()) {
207 return;
208 }
209
210 std::unordered_map<Core::Window*, std::vector<const RootGraphicsBuffer::RenderableBufferInfo*>> buffers_by_window;
211 for (const auto& renderable : renderable_buffers) {
212 if (renderable.target_window && renderable.target_window->is_graphics_registered()
213 && renderable.command_buffer_id != Portal::Graphics::INVALID_COMMAND_BUFFER) {
214 buffers_by_window[renderable.target_window.get()].push_back(&renderable);
215 }
216 }
217
218 if (buffers_by_window.empty()) {
219 root->clear_renderable_buffers();
220 return;
221 }
222
224 "PresentProcessor submitting to {} windows", buffers_by_window.size());
225
226 auto& foundry = Portal::Graphics::get_shader_foundry();
228 auto display_service = Registry::BackendRegistry::instance()
229 .get_service<Registry::Service::DisplayService>();
230
231 if (!display_service) {
233 "DisplayService not available for dynamic rendering");
234 return;
235 }
236
237 for (const auto& [window_ptr, buffer_infos] : buffers_by_window) {
238 auto window = buffer_infos[0]->target_window;
239
240 uint64_t image_bits = display_service->acquire_next_swapchain_image(window);
241 if (image_bits == 0) {
243 "Failed to acquire swapchain image for window '{}'",
244 window->get_create_info().title);
245 continue;
246 }
247 vk::Image swapchain_image { reinterpret_cast<VkImage>(image_bits) };
248
249 auto primary_cmd_id = foundry.begin_commands(Portal::Graphics::ShaderFoundry::CommandBufferType::GRAPHICS);
250 auto primary_cmd = foundry.get_command_buffer(primary_cmd_id);
251
252 if (!primary_cmd) {
254 "Failed to create primary command buffer for window '{}'",
255 window->get_create_info().title);
256 for (const auto* info : buffer_infos) {
257 info->buffer->clear_pipeline_commands();
258 }
259 continue;
260 }
261
262 try {
263 bool window_needs_depth = false;
264 for (const auto* info : buffer_infos) {
265 if (info->needs_depth) {
266 window_needs_depth = true;
267 break;
268 }
269 }
270
271 vk::ImageView depth_view = nullptr;
272 if (window_needs_depth) {
273 display_service->ensure_depth_attachment(window);
274 auto* view_ptr = display_service->get_depth_image_view(window);
275 if (view_ptr) {
276 depth_view = *static_cast<vk::ImageView*>(view_ptr);
277 }
278 }
279
280 flow.begin_rendering(primary_cmd_id, window, swapchain_image,
282
283 std::vector<vk::CommandBuffer> secondary_buffers;
284 for (const auto* info : buffer_infos) {
285 auto secondary = foundry.get_command_buffer(info->command_buffer_id);
286 if (secondary) {
287 secondary_buffers.push_back(secondary);
288 }
289 }
290
291 if (!secondary_buffers.empty()) {
292 primary_cmd.executeCommands(secondary_buffers);
293 }
294
295 flow.end_rendering(primary_cmd_id, window);
296
297 foundry.end_commands(primary_cmd_id);
298 uint64_t primary_bits = *reinterpret_cast<uint64_t*>(&primary_cmd);
299 display_service->submit_and_present(window, primary_bits);
300
302 "Presented {} buffers to window '{}'",
303 secondary_buffers.size(), window->get_create_info().title);
304
305 } catch (const std::exception& e) {
307 "Failed to submit/present for window '{}': {}",
308 window->get_create_info().title,
309 e.what());
310 }
311
312 for (const auto* info : buffer_infos) {
313 info->buffer->clear_pipeline_commands();
314 }
315 }
316
317 root->clear_renderable_buffers();
318}
#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.
const std::array< float, 4 > default_color
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::default_color, 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: