From d527eedb15a6f74fd0c91b485bdb3e13e991cda6 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Fri, 31 Oct 2025 09:11:17 +0100 Subject: [PATCH] lavapipe: Bump maxPrimitiveCount The vulkan spec requires at least 2^29-1. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14212 cc: mesa-stable Reviewed-by: Dave Airlie (cherry picked from commit ff145d2ddc13ef36129bae10c73816e2b83757e3) Part-of: --- .pick_status.json | 2 +- src/gallium/frontends/lavapipe/lvp_acceleration_structure.c | 2 +- src/gallium/frontends/lavapipe/lvp_device.c | 4 ++-- src/gallium/frontends/lavapipe/lvp_private.h | 3 +++ src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c | 2 +- .../frontends/lavapipe/nir/lvp_nir_lower_ray_queries.c | 3 ++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 6cf147045e5..8685a4d66df 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -304,7 +304,7 @@ "description": "lavapipe: Bump maxPrimitiveCount", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/frontends/lavapipe/lvp_acceleration_structure.c b/src/gallium/frontends/lavapipe/lvp_acceleration_structure.c index 7e08c7ff486..b24c6e737a5 100644 --- a/src/gallium/frontends/lavapipe/lvp_acceleration_structure.c +++ b/src/gallium/frontends/lavapipe/lvp_acceleration_structure.c @@ -574,7 +574,7 @@ lvp_encode_as(struct vk_acceleration_structure *dst, VkDeviceAddress intermediat /* The BVH exceeds the maximum depth supported by the traversal stack, * flatten the offending parts of the tree. */ - if (max_node_depth >= 24) + if (max_node_depth >= (geometry_type == VK_GEOMETRY_TYPE_INSTANCES_KHR ? LVP_MAX_TLAS_DEPTH : LVP_MAX_BLAS_DEPTH)) lvp_flatten_as(header, ir_box_nodes, root_offset, node_depth, output); free(node_depth); diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index 7789236646f..94f1e7fa6ae 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -1271,8 +1271,8 @@ lvp_get_properties(const struct lvp_physical_device *device, struct vk_propertie /* VK_KHR_acceleration_structure */ .maxGeometryCount = (1 << 24) - 1, - .maxInstanceCount = (1 << 24) - 1, - .maxPrimitiveCount = (1 << 24) - 1, + .maxInstanceCount = (1 << LVP_MAX_TLAS_DEPTH) - 1, + .maxPrimitiveCount = (1 << LVP_MAX_BLAS_DEPTH) - 1, .maxPerStageDescriptorAccelerationStructures = MAX_DESCRIPTORS, .maxPerStageDescriptorUpdateAfterBindAccelerationStructures = MAX_DESCRIPTORS, .maxDescriptorSetAccelerationStructures = MAX_DESCRIPTORS, diff --git a/src/gallium/frontends/lavapipe/lvp_private.h b/src/gallium/frontends/lavapipe/lvp_private.h index 9e7b1b3bc5c..7e1ae63488f 100644 --- a/src/gallium/frontends/lavapipe/lvp_private.h +++ b/src/gallium/frontends/lavapipe/lvp_private.h @@ -107,6 +107,9 @@ extern "C" { /* Currently lavapipe does not support more than 1 image plane */ #define LVP_MAX_PLANE_COUNT 1 +#define LVP_MAX_TLAS_DEPTH 24 +#define LVP_MAX_BLAS_DEPTH 29 + #ifdef _WIN32 #define lvp_printflike(a, b) #else diff --git a/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c b/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c index 45b0137e440..00132eee8ce 100644 --- a/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c @@ -356,7 +356,7 @@ lvp_ray_traversal_state_init(nir_function_impl *impl, struct lvp_ray_traversal_s state->current_node = nir_local_variable_create(impl, glsl_uint_type(), "traversal.current_node"); state->stack_base = nir_local_variable_create(impl, glsl_uint_type(), "traversal.stack_base"); state->stack_ptr = nir_local_variable_create(impl, glsl_uint_type(), "traversal.stack_ptr"); - state->stack = nir_local_variable_create(impl, glsl_array_type(glsl_uint_type(), 24 * 2, 0), "traversal.stack"); + state->stack = nir_local_variable_create(impl, glsl_array_type(glsl_uint_type(), LVP_MAX_TLAS_DEPTH + LVP_MAX_BLAS_DEPTH, 0), "traversal.stack"); state->hit = nir_local_variable_create(impl, glsl_bool_type(), "traversal.hit"); state->instance_addr = nir_local_variable_create(impl, glsl_uint64_t_type(), "traversal.instance_addr"); diff --git a/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_ray_queries.c b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_ray_queries.c index c71d173e8af..0ad9a8211a3 100644 --- a/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_ray_queries.c +++ b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_ray_queries.c @@ -171,7 +171,8 @@ init_ray_query_traversal_vars(void *ctx, nir_shader *shader, unsigned array_leng result.stack_base = rq_variable_create(ctx, shader, array_length, glsl_uint_type(), VAR_NAME("_stack_base")); result.stack_ptr = rq_variable_create(ctx, shader, array_length, glsl_uint_type(), VAR_NAME("_stack_ptr")); - result.stack = rq_variable_create(ctx, shader, array_length, glsl_array_type(glsl_uint_type(), 24 * 2, 0), VAR_NAME("_stack")); + result.stack = rq_variable_create(ctx, shader, array_length, + glsl_array_type(glsl_uint_type(), LVP_MAX_TLAS_DEPTH + LVP_MAX_BLAS_DEPTH, 0), VAR_NAME("_stack")); return result; }