The open source OpenXR runtime
0
fork

Configure Feed

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

c/render: Do not use a local that isn't a macro parameter.

Makes logic hard to follow, and it can be fragile

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2380>

+19 -21
+1 -1
src/xrt/compositor/render/render_compute.c
··· 295 295 struct vk_bundle *vk = r->vk; 296 296 render->r = r; 297 297 298 - for (uint32_t i = 0; i < RENDER_MAX_LAYER_RUNS_COUNT; i++) { 298 + for (uint32_t i = 0; i < RENDER_MAX_LAYER_RUNS_COUNT(r); i++) { 299 299 ret = vk_create_descriptor_set( // 300 300 vk, // vk_bundle 301 301 r->compute.descriptor_pool, // descriptor_pool
+5 -5
src/xrt/compositor/render/render_distortion.c
··· 324 324 VK_CHK_WITH_GOTO(ret, "vk_cmd_pool_create_and_begin_cmd_buffer_locked", err_unlock); 325 325 VK_NAME_COMMAND_BUFFER(vk, upload_buffer, "render_resources distortion command buffer"); 326 326 327 - for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) { 327 + for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) { 328 328 ret = create_and_queue_upload_locked( // 329 329 vk, // vk_bundle 330 330 pool, // pool ··· 347 347 348 348 r->distortion.pre_rotated = pre_rotate; 349 349 350 - for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) { 350 + for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) { 351 351 r->distortion.device_memories[i] = device_memories[i]; 352 352 r->distortion.images[i] = images[i]; 353 353 r->distortion.image_views[i] = image_views[i]; ··· 358 358 * Tidy 359 359 */ 360 360 361 - for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) { 361 + for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) { 362 362 render_buffer_fini(vk, &bufs[i]); 363 363 } 364 364 ··· 372 372 vk_cmd_pool_unlock(pool); 373 373 374 374 err_resources: 375 - for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) { 375 + for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) { 376 376 D(ImageView, image_views[i]); 377 377 D(Image, images[i]); 378 378 DF(Memory, device_memories[i]); ··· 394 394 { 395 395 struct vk_bundle *vk = r->vk; 396 396 397 - for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) { 397 + for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) { 398 398 D(ImageView, r->distortion.image_views[i]); 399 399 D(Image, r->distortion.images[i]); 400 400 DF(Memory, r->distortion.device_memories[i]);
+3 -3
src/xrt/compositor/render/render_interface.h
··· 62 62 * squasher in a single dispatch. 63 63 */ 64 64 #define RENDER_MAX_IMAGES_SIZE (RENDER_MAX_LAYERS * XRT_MAX_VIEWS) 65 - #define RENDER_MAX_IMAGES_COUNT (RENDER_MAX_LAYERS * r->view_count) 65 + #define RENDER_MAX_IMAGES_COUNT(RENDER_RESOURCES) (RENDER_MAX_LAYERS * RENDER_RESOURCES->view_count) 66 66 67 67 /*! 68 68 * Maximum number of times that the layer squasher shader can run per ··· 72 72 * composition (which is this number divided by number of composition). 73 73 */ 74 74 #define RENDER_MAX_LAYER_RUNS_SIZE (XRT_MAX_VIEWS) 75 - #define RENDER_MAX_LAYER_RUNS_COUNT (r->view_count) 75 + #define RENDER_MAX_LAYER_RUNS_COUNT(RENDER_RESOURCES) (RENDER_RESOURCES->view_count) 76 76 77 77 //! Distortion image dimension in pixels 78 78 #define RENDER_DISTORTION_IMAGE_DIMENSIONS (128) 79 79 80 80 //! How many distortion images we have, one for each channel (3 rgb) and per view. 81 81 #define RENDER_DISTORTION_IMAGES_SIZE (3 * XRT_MAX_VIEWS) 82 - #define RENDER_DISTORTION_IMAGES_COUNT (3 * r->view_count) 82 + #define RENDER_DISTORTION_IMAGES_COUNT(RENDER_RESOURCES) (3 * RENDER_RESOURCES->view_count) 83 83 84 84 //! The binding that the layer projection and quad shader have their UBO on. 85 85 #define RENDER_BINDING_LAYER_SHARED_UBO 0
+10 -12
src/xrt/compositor/render/render_resources.c
··· 542 542 r->compute.target_binding = 2; 543 543 r->compute.ubo_binding = 3; 544 544 545 - r->compute.layer.image_array_size = vk->features.max_per_stage_descriptor_sampled_images; 546 - if (r->compute.layer.image_array_size > RENDER_MAX_IMAGES_COUNT) { 547 - r->compute.layer.image_array_size = RENDER_MAX_IMAGES_COUNT; 548 - } 545 + r->compute.layer.image_array_size = 546 + MAX(vk->features.max_per_stage_descriptor_sampled_images, RENDER_MAX_IMAGES_COUNT(r)); 549 547 550 548 551 549 /* ··· 697 695 698 696 { 699 697 // Number of layer shader runs (views) times number of layers. 700 - const uint32_t layer_shader_count = RENDER_MAX_LAYER_RUNS_COUNT * RENDER_MAX_LAYERS; 698 + const uint32_t layer_shader_count = RENDER_MAX_LAYER_RUNS_COUNT(r) * RENDER_MAX_LAYERS; 701 699 702 700 // Two mesh distortion runs. 703 - const uint32_t mesh_shader_count = RENDER_MAX_LAYER_RUNS_COUNT; 701 + const uint32_t mesh_shader_count = RENDER_MAX_LAYER_RUNS_COUNT(r); 704 702 705 703 struct vk_descriptor_pool_info mesh_pool_info = { 706 704 .uniform_per_descriptor_count = 1, ··· 731 729 buffer_count += layer_shader_count; 732 730 733 731 // One UBO per mesh shader. 734 - buffer_count += RENDER_MAX_LAYER_RUNS_COUNT; 732 + buffer_count += RENDER_MAX_LAYER_RUNS_COUNT(r); 735 733 736 734 // We currently use the aligmnent as max UBO size. 737 735 static_assert(sizeof(struct render_gfx_mesh_ubo_data) <= RENDER_ALWAYS_SAFE_UBO_ALIGNMENT, "MAX"); ··· 831 829 832 830 const uint32_t compute_descriptor_count = // 833 831 1 + // Shared/distortion run(s). 834 - RENDER_MAX_LAYER_RUNS_COUNT; // Layer shader run(s). 832 + RENDER_MAX_LAYER_RUNS_COUNT(r); // Layer shader run(s). 835 833 836 834 struct vk_descriptor_pool_info compute_pool_info = { 837 835 .uniform_per_descriptor_count = 1, 838 836 // layer images 839 - .sampler_per_descriptor_count = r->compute.layer.image_array_size + RENDER_DISTORTION_IMAGES_COUNT, 837 + .sampler_per_descriptor_count = r->compute.layer.image_array_size + RENDER_DISTORTION_IMAGES_COUNT(r), 840 838 .storage_image_per_descriptor_count = 1, 841 839 .storage_buffer_per_descriptor_count = 0, 842 840 .descriptor_count = compute_descriptor_count, ··· 1041 1039 * Compute distortion textures, not created until later. 1042 1040 */ 1043 1041 1044 - for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) { 1042 + for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) { 1045 1043 r->distortion.image_views[i] = VK_NULL_HANDLE; 1046 1044 } 1047 - for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) { 1045 + for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) { 1048 1046 r->distortion.images[i] = VK_NULL_HANDLE; 1049 1047 } 1050 - for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) { 1048 + for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) { 1051 1049 r->distortion.device_memories[i] = VK_NULL_HANDLE; 1052 1050 } 1053 1051