diff --git a/src/gallium/frontends/lavapipe/lvp_acceleration_structure.c b/src/gallium/frontends/lavapipe/lvp_acceleration_structure.c index 938d9e845fb..6f8ae4efe4d 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 ad160813b75..f50948f403f 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -1274,8 +1274,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 89f9972130d..929bcf79bf5 100644 --- a/src/gallium/frontends/lavapipe/lvp_private.h +++ b/src/gallium/frontends/lavapipe/lvp_private.h @@ -108,6 +108,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 691705e38ca..9e24355f53b 100644 --- a/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c @@ -358,7 +358,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 e1066bfa6db..cfe7d78e351 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; }