···295295 struct vk_bundle *vk = r->vk;
296296 render->r = r;
297297298298- for (uint32_t i = 0; i < RENDER_MAX_LAYER_RUNS_COUNT; i++) {
298298+ for (uint32_t i = 0; i < RENDER_MAX_LAYER_RUNS_COUNT(r); i++) {
299299 ret = vk_create_descriptor_set( //
300300 vk, // vk_bundle
301301 r->compute.descriptor_pool, // descriptor_pool
+5-5
src/xrt/compositor/render/render_distortion.c
···324324 VK_CHK_WITH_GOTO(ret, "vk_cmd_pool_create_and_begin_cmd_buffer_locked", err_unlock);
325325 VK_NAME_COMMAND_BUFFER(vk, upload_buffer, "render_resources distortion command buffer");
326326327327- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) {
327327+ for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
328328 ret = create_and_queue_upload_locked( //
329329 vk, // vk_bundle
330330 pool, // pool
···347347348348 r->distortion.pre_rotated = pre_rotate;
349349350350- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) {
350350+ for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
351351 r->distortion.device_memories[i] = device_memories[i];
352352 r->distortion.images[i] = images[i];
353353 r->distortion.image_views[i] = image_views[i];
···358358 * Tidy
359359 */
360360361361- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) {
361361+ for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
362362 render_buffer_fini(vk, &bufs[i]);
363363 }
364364···372372 vk_cmd_pool_unlock(pool);
373373374374err_resources:
375375- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) {
375375+ for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
376376 D(ImageView, image_views[i]);
377377 D(Image, images[i]);
378378 DF(Memory, device_memories[i]);
···394394{
395395 struct vk_bundle *vk = r->vk;
396396397397- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) {
397397+ for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
398398 D(ImageView, r->distortion.image_views[i]);
399399 D(Image, r->distortion.images[i]);
400400 DF(Memory, r->distortion.device_memories[i]);
+3-3
src/xrt/compositor/render/render_interface.h
···6262 * squasher in a single dispatch.
6363 */
6464#define RENDER_MAX_IMAGES_SIZE (RENDER_MAX_LAYERS * XRT_MAX_VIEWS)
6565-#define RENDER_MAX_IMAGES_COUNT (RENDER_MAX_LAYERS * r->view_count)
6565+#define RENDER_MAX_IMAGES_COUNT(RENDER_RESOURCES) (RENDER_MAX_LAYERS * RENDER_RESOURCES->view_count)
66666767/*!
6868 * Maximum number of times that the layer squasher shader can run per
···7272 * composition (which is this number divided by number of composition).
7373 */
7474#define RENDER_MAX_LAYER_RUNS_SIZE (XRT_MAX_VIEWS)
7575-#define RENDER_MAX_LAYER_RUNS_COUNT (r->view_count)
7575+#define RENDER_MAX_LAYER_RUNS_COUNT(RENDER_RESOURCES) (RENDER_RESOURCES->view_count)
76767777//! Distortion image dimension in pixels
7878#define RENDER_DISTORTION_IMAGE_DIMENSIONS (128)
79798080//! How many distortion images we have, one for each channel (3 rgb) and per view.
8181#define RENDER_DISTORTION_IMAGES_SIZE (3 * XRT_MAX_VIEWS)
8282-#define RENDER_DISTORTION_IMAGES_COUNT (3 * r->view_count)
8282+#define RENDER_DISTORTION_IMAGES_COUNT(RENDER_RESOURCES) (3 * RENDER_RESOURCES->view_count)
83838484//! The binding that the layer projection and quad shader have their UBO on.
8585#define RENDER_BINDING_LAYER_SHARED_UBO 0
+10-12
src/xrt/compositor/render/render_resources.c
···542542 r->compute.target_binding = 2;
543543 r->compute.ubo_binding = 3;
544544545545- r->compute.layer.image_array_size = vk->features.max_per_stage_descriptor_sampled_images;
546546- if (r->compute.layer.image_array_size > RENDER_MAX_IMAGES_COUNT) {
547547- r->compute.layer.image_array_size = RENDER_MAX_IMAGES_COUNT;
548548- }
545545+ r->compute.layer.image_array_size =
546546+ MAX(vk->features.max_per_stage_descriptor_sampled_images, RENDER_MAX_IMAGES_COUNT(r));
549547550548551549 /*
···697695698696 {
699697 // Number of layer shader runs (views) times number of layers.
700700- const uint32_t layer_shader_count = RENDER_MAX_LAYER_RUNS_COUNT * RENDER_MAX_LAYERS;
698698+ const uint32_t layer_shader_count = RENDER_MAX_LAYER_RUNS_COUNT(r) * RENDER_MAX_LAYERS;
701699702700 // Two mesh distortion runs.
703703- const uint32_t mesh_shader_count = RENDER_MAX_LAYER_RUNS_COUNT;
701701+ const uint32_t mesh_shader_count = RENDER_MAX_LAYER_RUNS_COUNT(r);
704702705703 struct vk_descriptor_pool_info mesh_pool_info = {
706704 .uniform_per_descriptor_count = 1,
···731729 buffer_count += layer_shader_count;
732730733731 // One UBO per mesh shader.
734734- buffer_count += RENDER_MAX_LAYER_RUNS_COUNT;
732732+ buffer_count += RENDER_MAX_LAYER_RUNS_COUNT(r);
735733736734 // We currently use the aligmnent as max UBO size.
737735 static_assert(sizeof(struct render_gfx_mesh_ubo_data) <= RENDER_ALWAYS_SAFE_UBO_ALIGNMENT, "MAX");
···831829832830 const uint32_t compute_descriptor_count = //
833831 1 + // Shared/distortion run(s).
834834- RENDER_MAX_LAYER_RUNS_COUNT; // Layer shader run(s).
832832+ RENDER_MAX_LAYER_RUNS_COUNT(r); // Layer shader run(s).
835833836834 struct vk_descriptor_pool_info compute_pool_info = {
837835 .uniform_per_descriptor_count = 1,
838836 // layer images
839839- .sampler_per_descriptor_count = r->compute.layer.image_array_size + RENDER_DISTORTION_IMAGES_COUNT,
837837+ .sampler_per_descriptor_count = r->compute.layer.image_array_size + RENDER_DISTORTION_IMAGES_COUNT(r),
840838 .storage_image_per_descriptor_count = 1,
841839 .storage_buffer_per_descriptor_count = 0,
842840 .descriptor_count = compute_descriptor_count,
···10411039 * Compute distortion textures, not created until later.
10421040 */
1043104110441044- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) {
10421042+ for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
10451043 r->distortion.image_views[i] = VK_NULL_HANDLE;
10461044 }
10471047- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) {
10451045+ for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
10481046 r->distortion.images[i] = VK_NULL_HANDLE;
10491047 }
10501050- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT; i++) {
10481048+ for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
10511049 r->distortion.device_memories[i] = VK_NULL_HANDLE;
10521050 }
10531051