The open source OpenXR runtime

c/main: More propagate errors

+48 -25
+8 -5
src/xrt/compositor/main/comp_mirror_to_debug_gui.c
··· 8 8 * @ingroup comp_main 9 9 */ 10 10 11 + #include "xrt/xrt_results.h" 11 12 #include "math/m_mathinclude.h" 12 13 #include "main/comp_mirror_to_debug_gui.h" 13 14 ··· 410 411 return true; 411 412 } 412 413 413 - void 414 + XRT_CHECK_RESULT xrt_result_t 414 415 comp_mirror_do_blit(struct comp_mirror_to_debug_gui *m, 415 416 struct vk_bundle *vk, 416 417 uint64_t frame_id, ··· 428 429 struct vk_image_readback_to_xf *wrap = NULL; 429 430 430 431 if (!vk_image_readback_to_xf_pool_get_unused_frame(vk, m->pool, &wrap)) { 431 - return; 432 + return XRT_ERROR_VULKAN; 432 433 } 433 434 434 435 if (!ensure_scratch(m, vk)) { 435 - return; 436 + return XRT_ERROR_VULKAN; 436 437 } 437 438 438 439 VkDescriptorSet descriptor_set = VK_NULL_HANDLE; ··· 443 444 &descriptor_set); // descriptor_set 444 445 if (ret != VK_SUCCESS) { 445 446 VK_ERROR(vk, "vk_create_descriptor_set: %s", vk_result_string(ret)); 446 - return; 447 + return XRT_ERROR_VULKAN; 447 448 } 448 449 449 450 VK_NAME_DESCRIPTOR_SET(vk, descriptor_set, "comp_mirror_to_debug_ui blit descriptor set"); ··· 458 459 if (ret != VK_SUCCESS) { 459 460 vk->vkResetDescriptorPool(vk->device, m->blit.descriptor_pool, 0); 460 461 vk_cmd_pool_unlock(pool); 461 - return; 462 + return XRT_ERROR_VULKAN; 462 463 } 463 464 464 465 VK_NAME_COMMAND_BUFFER(vk, cmd, "comp_mirror_to_debug_ui command buffer"); ··· 637 638 if (ret != VK_SUCCESS) { 638 639 //! @todo Better handling of error? 639 640 VK_ERROR(vk, "vk_cmd_pool_end_submit_wait_and_free_cmd_buffer_locked: %s", vk_result_string(ret)); 641 + return XRT_ERROR_VULKAN; 640 642 } 641 643 642 644 wrap->base_frame.source_timestamp = wrap->base_frame.timestamp = predicted_display_time_ns; ··· 653 655 654 656 // Tidies the descriptor we created. 655 657 vk->vkResetDescriptorPool(vk->device, m->blit.descriptor_pool, 0); 658 + return XRT_ERROR_VULKAN; 656 659 } 657 660 658 661 void
+4 -1
src/xrt/compositor/main/comp_mirror_to_debug_gui.h
··· 9 9 */ 10 10 #pragma once 11 11 12 + #include "xrt/xrt_compiler.h" 13 + #include "xrt/xrt_results.h" 12 14 #include "util/u_sink.h" 13 15 #include "vk/vk_image_readback_to_xf_pool.h" 16 + 14 17 #include "main/comp_compositor.h" 15 18 16 19 ··· 115 118 * 116 119 * @public @memberof comp_mirror_to_debug_gui 117 120 */ 118 - void 121 + XRT_CHECK_RESULT xrt_result_t 119 122 comp_mirror_do_blit(struct comp_mirror_to_debug_gui *m, 120 123 struct vk_bundle *vk, 121 124 uint64_t frame_id,
+35 -18
src/xrt/compositor/main/comp_renderer.c
··· 14 14 #include "xrt/xrt_defines.h" 15 15 #include "xrt/xrt_frame.h" 16 16 #include "xrt/xrt_compositor.h" 17 + #include "xrt/xrt_results.h" 17 18 18 19 #include "os/os_time.h" 19 20 ··· 547 548 r->fenced_buffer = -1; 548 549 } 549 550 550 - static void 551 + static XRT_CHECK_RESULT VkResult 551 552 renderer_submit_queue(struct comp_renderer *r, VkCommandBuffer cmd, VkPipelineStageFlags pipeline_stage_flag) 552 553 { 553 554 COMP_TRACE_MARKER(); ··· 568 569 ret = vk->vkResetFences(vk->device, 1, &r->fences[r->acquired_buffer]); 569 570 if (ret != VK_SUCCESS) { 570 571 COMP_ERROR(r->c, "vkResetFences: %s", vk_result_string(ret)); 572 + return ret; 571 573 } 572 574 573 575 ··· 634 636 ret = vk_cmd_submit_locked(vk, 1, &comp_submit_info, r->fences[r->acquired_buffer]); 635 637 if (ret != VK_SUCCESS) { 636 638 COMP_ERROR(r->c, "vkQueueSubmit: %s", vk_result_string(ret)); 639 + return ret; 637 640 } 638 641 639 642 // This buffer now have a pending fence. 640 643 r->fenced_buffer = r->acquired_buffer; 644 + return ret; 641 645 } 642 646 643 647 static void ··· 753 757 /*! 754 758 * @pre render_gfx_init(rr, &c->nr) 755 759 */ 756 - static void 760 + static XRT_CHECK_RESULT VkResult 757 761 dispatch_graphics(struct comp_renderer *r, struct render_gfx *rr) 758 762 { 759 763 COMP_TRACE_MARKER(); ··· 792 796 render_gfx_begin(rr); 793 797 794 798 799 + VkResult ret = VK_SUCCESS; 800 + 795 801 comp_render_gfx_dispatch( // 796 802 rr, // rr 797 803 &r->scratch, // rsi ··· 812 818 render_gfx_end(rr); 813 819 814 820 // Everything is ready, submit to the queue. 815 - renderer_submit_queue(r, rr->r->cmd, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); 821 + ret = renderer_submit_queue(r, rr->r->cmd, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); 816 822 817 823 // We mark afterwards to not include CPU time spent. 818 824 comp_target_mark_submit(ct, c->frame.rendering.id, os_monotonic_get_ns()); 825 + 826 + return ret; 819 827 } 820 828 821 829 ··· 828 836 /*! 829 837 * @pre render_compute_init(crc, &c->nr) 830 838 */ 831 - static void 839 + static XRT_CHECK_RESULT VkResult 832 840 dispatch_compute(struct comp_renderer *r, struct render_compute *crc) 833 841 { 834 842 COMP_TRACE_MARKER(); ··· 876 884 877 885 comp_target_mark_submit(ct, c->frame.rendering.id, os_monotonic_get_ns()); 878 886 879 - renderer_submit_queue(r, crc->r->cmd, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT); 887 + return renderer_submit_queue(r, crc->r->cmd, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT); 880 888 } 881 889 882 890 ··· 886 894 * 887 895 */ 888 896 889 - void 897 + XRT_CHECK_RESULT xrt_result_t 890 898 comp_renderer_draw(struct comp_renderer *r) 891 899 { 892 900 COMP_TRACE_MARKER(); ··· 912 920 913 921 // Clear the rendering frame. 914 922 comp_frame_clear_locked(&c->frame.rendering); 915 - return; 923 + return XRT_SUCCESS; 916 924 } 917 925 918 926 comp_target_flush(ct); ··· 929 937 bool use_compute = r->settings->use_compute; 930 938 struct render_gfx rr = {0}; 931 939 struct render_compute crc = {0}; 940 + 941 + VkResult res = VK_SUCCESS; 932 942 if (use_compute) { 933 943 render_compute_init(&crc, &c->nr); 934 - dispatch_compute(r, &crc); 944 + res = dispatch_compute(r, &crc); 935 945 } else { 936 946 render_gfx_init(&rr, &c->nr); 937 - dispatch_graphics(r, &rr); 947 + res = dispatch_graphics(r, &rr); 948 + } 949 + if (res != VK_SUCCESS) { 950 + return XRT_ERROR_VULKAN; 938 951 } 939 952 940 953 #ifdef XRT_FEATURE_WINDOW_PEEK ··· 974 987 // Clear the rendered frame. 975 988 comp_frame_clear_locked(&c->frame.rendering); 976 989 990 + xrt_result_t xret = XRT_SUCCESS; 977 991 comp_mirror_fixup_ui_state(&r->mirror_to_debug_gui, c); 978 992 if (comp_mirror_is_ready_and_active(&r->mirror_to_debug_gui, c, predicted_display_time_ns)) { 979 993 ··· 983 997 // Covers the whole view. 984 998 struct xrt_normalized_rect rect = {0, 0, 1.0f, 1.0f}; 985 999 986 - comp_mirror_do_blit( // 1000 + xret = comp_mirror_do_blit( // 987 1001 &r->mirror_to_debug_gui, // 988 1002 &c->base.vk, // 989 1003 frame_id, // ··· 1004 1018 */ 1005 1019 renderer_wait_queue_idle(r); 1006 1020 1007 - 1008 - /* 1009 - * Get timestamps of GPU work (if available). 1010 - */ 1021 + if (xret == XRT_SUCCESS) { 1022 + /* 1023 + * Get timestamps of GPU work (if available). 1024 + */ 1011 1025 1012 - uint64_t gpu_start_ns, gpu_end_ns; 1013 - if (render_resources_get_timestamps(&c->nr, &gpu_start_ns, &gpu_end_ns)) { 1014 - uint64_t now_ns = os_monotonic_get_ns(); 1015 - comp_target_info_gpu(ct, frame_id, gpu_start_ns, gpu_end_ns, now_ns); 1026 + uint64_t gpu_start_ns, gpu_end_ns; 1027 + if (render_resources_get_timestamps(&c->nr, &gpu_start_ns, &gpu_end_ns)) { 1028 + uint64_t now_ns = os_monotonic_get_ns(); 1029 + comp_target_info_gpu(ct, frame_id, gpu_start_ns, gpu_end_ns, now_ns); 1030 + } 1016 1031 } 1017 1032 1018 1033 ··· 1057 1072 } 1058 1073 1059 1074 comp_target_update_timings(ct); 1075 + 1076 + return xret; 1060 1077 } 1061 1078 1062 1079 struct comp_renderer *
+1 -1
src/xrt/compositor/main/comp_renderer.h
··· 57 57 * @public @memberof comp_renderer 58 58 * @ingroup comp_main 59 59 */ 60 - void 60 + XRT_CHECK_RESULT xrt_result_t 61 61 comp_renderer_draw(struct comp_renderer *r); 62 62 63 63 void