radv/rra: Use the accel struct type for header validation

Reviewed-by: Friedrich Vock <friedrich.vock@gmx.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19089>
This commit is contained in:
Konstantin Seurer 2022-10-15 12:02:05 +02:00 committed by Marge Bot
parent 43756a9f76
commit 6905c25829
3 changed files with 8 additions and 0 deletions

View File

@ -212,6 +212,7 @@ radv_CreateAccelerationStructureKHR(VkDevice _device,
accel->size = pCreateInfo->size;
accel->bo = buffer->bo;
accel->va = radv_buffer_get_va(accel->bo) + accel->mem_offset;
accel->type = pCreateInfo->type;
*pAccelerationStructure = radv_acceleration_structure_to_handle(accel);
return VK_SUCCESS;

View File

@ -35,6 +35,7 @@ struct radv_acceleration_structure {
uint64_t mem_offset;
uint64_t size;
uint64_t va;
VkAccelerationStructureTypeKHR type;
};
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_acceleration_structure, base, VkAccelerationStructureKHR,

View File

@ -419,6 +419,12 @@ rra_validate_header(struct radv_acceleration_structure *accel_struct,
{
bool result = true;
if (accel_struct->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
header->instance_count > 0) {
rra_accel_struct_validation_fail(0, "BLAS contains instances");
result = false;
}
if (header->bvh_offset >= accel_struct->size) {
rra_accel_struct_validation_fail(0, "Invalid BVH offset %u", header->bvh_offset);
result = false;