The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

c/main: Fix rounding math and ensure even image sizes for readback

authored by

Moses Turner and committed by
Moses Turner
633439e4 18678786

+13 -3
+13 -3
src/xrt/compositor/main/comp_renderer.c
··· 569 569 double orig_width = r->lr->extent.width; 570 570 double orig_height = r->lr->extent.height; 571 571 572 - double mul = 1080.0 / orig_height; 572 + double target_height = 1080; 573 573 574 - r->mirror_to_debug_gui.image_extent.width = (uint32_t)(orig_width * mul); 575 - r->mirror_to_debug_gui.image_extent.height = (uint32_t)(orig_height * mul); 574 + double mul = target_height / orig_height; 575 + 576 + // Casts seem to always round down; we don't want that here. 577 + r->mirror_to_debug_gui.image_extent.width = (uint32_t)(round(orig_width * mul)); 578 + r->mirror_to_debug_gui.image_extent.height = (uint32_t)target_height; 579 + 580 + 581 + // gui_window_record expects the images to have even widths/heights 582 + if (r->mirror_to_debug_gui.image_extent.width % 2 == 1) { 583 + r->mirror_to_debug_gui.image_extent.width += 1; 584 + } 585 + 576 586 u_sink_debug_init(&r->mirror_to_debug_gui.debug_sink); 577 587 578 588 vk_image_readback_to_xf_pool_create(vk, r->mirror_to_debug_gui.image_extent, &r->mirror_to_debug_gui.pool,