radv/rra: Use the accel struct type for header validation
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Sat, 15 Oct 2022 10:02:05 +0000 (12:02 +0200)
committerMarge Bot <emma+marge@anholt.net>
Sun, 16 Oct 2022 14:37:02 +0000 (14:37 +0000)
Reviewed-by: Friedrich Vock <friedrich.vock@gmx.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19089>

src/amd/vulkan/radv_acceleration_structure.c
src/amd/vulkan/radv_acceleration_structure.h
src/amd/vulkan/radv_rra.c

index d0786ff..b7217ac 100644 (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;
index fde3a0c..df738d8 100644 (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,
index 8c41f7b..536840a 100644 (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;