mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 02:58:05 +02:00
radv: Use common helper to set BLAS node pointer flags on gfx11+
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32417>
This commit is contained in:
parent
06a06bbe09
commit
e82717a5cf
4 changed files with 38 additions and 16 deletions
|
|
@ -87,6 +87,28 @@ radv_encode_sbt_offset_and_flags(uint32_t src)
|
|||
return ret;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
radv_encode_blas_pointer_flags(uint32_t flags, uint32_t geometry_type)
|
||||
{
|
||||
uint64_t ptr_flags = 0;
|
||||
if ((flags & VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR) != 0)
|
||||
ptr_flags |= RADV_BLAS_POINTER_FORCE_OPAQUE;
|
||||
if ((flags & VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR) != 0)
|
||||
ptr_flags |= RADV_BLAS_POINTER_FORCE_NON_OPAQUE;
|
||||
if ((flags & VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR) != 0 ||
|
||||
geometry_type == VK_GEOMETRY_TYPE_AABBS_KHR)
|
||||
ptr_flags |= RADV_BLAS_POINTER_DISABLE_TRI_CULL;
|
||||
if ((flags & VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR) != 0)
|
||||
ptr_flags |= RADV_BLAS_POINTER_FLIP_FACING;
|
||||
|
||||
if (geometry_type == VK_GEOMETRY_TYPE_TRIANGLES_KHR)
|
||||
ptr_flags |= RADV_BLAS_POINTER_SKIP_AABBS;
|
||||
else
|
||||
ptr_flags |= RADV_BLAS_POINTER_SKIP_TRIANGLES;
|
||||
|
||||
return ptr_flags;
|
||||
}
|
||||
|
||||
/** Compute ceiling of integer quotient of A divided by B.
|
||||
From macros.h */
|
||||
#define DIV_ROUND_UP(A, B) (((A) + (B)-1) / (B))
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@
|
|||
#define RADV_INSTANCE_TRIANGLE_FACING_CULL_DISABLE (1u << 29)
|
||||
#define RADV_INSTANCE_TRIANGLE_FLIP_FACING (1u << 28)
|
||||
|
||||
#define RADV_BLAS_POINTER_FORCE_OPAQUE (1ul << 54)
|
||||
#define RADV_BLAS_POINTER_FORCE_NON_OPAQUE (1ul << 55)
|
||||
#define RADV_BLAS_POINTER_DISABLE_TRI_CULL (1ul << 56)
|
||||
#define RADV_BLAS_POINTER_FLIP_FACING (1ul << 57)
|
||||
#define RADV_BLAS_POINTER_SKIP_TRIANGLES (1ul << 62)
|
||||
#define RADV_BLAS_POINTER_SKIP_AABBS (1ul << 63)
|
||||
|
||||
#ifdef VULKAN
|
||||
#define VK_UUID_SIZE 16
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -41,7 +41,11 @@ radv_encode_instance_gfx10_3(VOID_REF dst_addr, vk_ir_instance_node src)
|
|||
|
||||
radv_accel_struct_header blas_header = DEREF(REF(radv_accel_struct_header)(src.base_ptr));
|
||||
|
||||
DEREF(dst).bvh_ptr = addr_to_node(src.base_ptr + blas_header.bvh_offset);
|
||||
uint64_t ptr = addr_to_node(src.base_ptr + blas_header.bvh_offset);
|
||||
if (VK_BUILD_FLAG(VK_BUILD_FLAG_PROPAGATE_CULL_FLAGS))
|
||||
ptr |= radv_encode_blas_pointer_flags(src.sbt_offset_and_flags >> 24, blas_header.geometry_type);
|
||||
|
||||
DEREF(dst).bvh_ptr = ptr;
|
||||
DEREF(dst).bvh_offset = blas_header.bvh_offset;
|
||||
|
||||
mat4 transform = mat4(src.otw_matrix);
|
||||
|
|
@ -252,24 +256,11 @@ radv_encode_instance_gfx12(VOID_REF dst, vk_ir_instance_node src)
|
|||
|
||||
uint32_t flags = src.sbt_offset_and_flags >> 24;
|
||||
uint32_t instance_pointer_flags = 0;
|
||||
if ((flags & VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR) != 0)
|
||||
instance_pointer_flags |= 1;
|
||||
if ((flags & VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR) != 0)
|
||||
instance_pointer_flags |= 2;
|
||||
if ((flags & VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR) != 0 ||
|
||||
blas_header.geometry_type == VK_GEOMETRY_TYPE_AABBS_KHR)
|
||||
instance_pointer_flags |= 4;
|
||||
if ((flags & VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR) != 0)
|
||||
instance_pointer_flags |= 8;
|
||||
|
||||
if (blas_header.geometry_type == VK_GEOMETRY_TYPE_TRIANGLES_KHR)
|
||||
instance_pointer_flags |= 512;
|
||||
else
|
||||
instance_pointer_flags |= 256;
|
||||
|
||||
uint64_t bvh_addr = addr_to_node(src.base_ptr + blas_header.bvh_offset);
|
||||
bvh_addr |= radv_encode_blas_pointer_flags(flags, blas_header.geometry_type);
|
||||
bit_writer_write(child_writer, uint32_t(bvh_addr & 0xffffffff), 32);
|
||||
bit_writer_write(child_writer, uint32_t(bvh_addr >> 32) | (instance_pointer_flags << (54 - 32)), 32);
|
||||
bit_writer_write(child_writer, uint32_t(bvh_addr >> 32), 32);
|
||||
bit_writer_write(child_writer, src.custom_instance_and_mask & 0xffffff, 32);
|
||||
bit_writer_write(child_writer, src.sbt_offset_and_flags & 0xffffff, 24);
|
||||
bit_writer_write(child_writer, src.custom_instance_and_mask >> 24, 8);
|
||||
|
|
|
|||
|
|
@ -476,6 +476,8 @@ radv_build_flags(VkCommandBuffer commandBuffer, uint32_t key)
|
|||
/* gfx11 box intersection tests can return garbage with infs and non-standard box sorting */
|
||||
if (pdev->info.gfx_level == GFX11)
|
||||
flags |= RADV_BUILD_FLAG_NO_INFS;
|
||||
if (pdev->info.gfx_level >= GFX11)
|
||||
flags |= VK_BUILD_FLAG_PROPAGATE_CULL_FLAGS;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue