mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-10 22:20:40 +01:00
anv: Improve bvh_no_build option
We can't guarantee that skipping the BVH build would let the BVH memory all zero. So explicitly set it to zero when running things with BVH_NO_BUILD option. This will help us to narrow down isuse if it's in BVH encoding or application shader. Leaving uninitialized blob of memory would hit intermittent hangs and would lead us to nowhere. Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40276>
This commit is contained in:
parent
8ad49647f7
commit
f7e3085e6a
1 changed files with 27 additions and 8 deletions
|
|
@ -367,29 +367,48 @@ anv_encode_bind_pipeline(VkCommandBuffer commandBuffer, const struct vk_accelera
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
/* Helper to zero out the output BVH. */
|
||||
static void
|
||||
anv_clear_out_bvh(struct anv_cmd_buffer *cmd_buffer,
|
||||
VkDeviceAddress output_bvh_addr, uint64_t bvh_size)
|
||||
{
|
||||
assert(bvh_size % 4 == 0);
|
||||
struct anv_address anv_bvh_addr = anv_address_from_u64(output_bvh_addr);
|
||||
|
||||
anv_cmd_buffer_fill_area(cmd_buffer, anv_bvh_addr, bvh_size, 0 /* data */);
|
||||
|
||||
vk_barrier_compute_w_to_compute_r(vk_command_buffer_to_handle(&cmd_buffer->vk));
|
||||
genX(cmd_buffer_apply_pipe_flushes)(cmd_buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
anv_encode_as(VkCommandBuffer commandBuffer, const struct vk_acceleration_structure_build_state *state)
|
||||
{
|
||||
if (INTEL_DEBUG(DEBUG_BVH_NO_BUILD))
|
||||
return;
|
||||
|
||||
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
||||
VK_FROM_HANDLE(vk_acceleration_structure, dst, state->build_info->dstAccelerationStructure);
|
||||
|
||||
struct bvh_layout bvh_layout;
|
||||
VkGeometryTypeKHR geometry_type = vk_get_as_geometry_type(state->build_info);
|
||||
get_bvh_layout(geometry_type, state->leaf_node_count, &bvh_layout);
|
||||
|
||||
if (INTEL_DEBUG(DEBUG_BVH_NO_BUILD)) {
|
||||
/* Zero out the whole BVH when we run with BVH_NO_BUILD debug option. */
|
||||
anv_clear_out_bvh(cmd_buffer,
|
||||
vk_acceleration_structure_get_va(dst) + bvh_layout.bvh_offset,
|
||||
bvh_layout.size);
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t intermediate_header_addr = state->build_info->scratchData.deviceAddress + state->scratch.header_offset;
|
||||
uint64_t intermediate_bvh_addr = state->build_info->scratchData.deviceAddress + state->scratch.ir_offset;
|
||||
|
||||
VkGeometryTypeKHR geometry_type = vk_get_as_geometry_type(state->build_info);
|
||||
|
||||
STATIC_ASSERT(sizeof(struct anv_accel_struct_header) == ANV_RT_BVH_HEADER_SIZE);
|
||||
STATIC_ASSERT(sizeof(struct anv_instance_leaf) == ANV_RT_INSTANCE_LEAF_SIZE);
|
||||
STATIC_ASSERT(sizeof(struct anv_quad_leaf_node) == ANV_RT_QUAD_LEAF_SIZE);
|
||||
STATIC_ASSERT(sizeof(struct anv_procedural_leaf_node) == ANV_RT_PROCEDURAL_LEAF_SIZE);
|
||||
STATIC_ASSERT(sizeof(struct anv_internal_node) == ANV_RT_INTERNAL_NODE_SIZE);
|
||||
|
||||
struct bvh_layout bvh_layout;
|
||||
get_bvh_layout(geometry_type, state->leaf_node_count, &bvh_layout);
|
||||
|
||||
const struct encode_args args = {
|
||||
.intermediate_bvh = intermediate_bvh_addr,
|
||||
.output_bvh = vk_acceleration_structure_get_va(dst) +
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue