KhronosGroup / KhronosGroup/Vulkan-Docs

VUID-VkBindAccelerationStructureMemoryInfoNV-size-02595 should not apply to compacted acceleration structures

Open
#1,078 0 comments 0 reactions 1 assignee Assigned to @dgkoch View on GitHub
Ray Tracing
Dominant language
JavaScript
Stars
3.3k
Forks
549
Avg merge
5d 5h
Merged PRs (30d)
2

Description

I am currently getting the following validation error - as per the specification - (though the application works fine) when compacting a bottom-level acceleration structure:
```
ERROR [ VUID-VkBindAccelerationStructureMemoryInfoNV-size-02595 ] Object: 0x7e7cff000000003a (Type = 9) | vkBindAccelerationStructureMemoryNV(): memory size minus memoryOffset is 0xbf9680 but must be at least as large as VkMemoryRequirements::size value 0x17d0000, returned from a call to vkGetAccelerationStructureMemoryRequirementsNV with accelerationStructureand type of VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV. The Vulkan spec states: The size member of the VkMemoryRequirements structure returned from a call to vkGetAccelerationStructureMemoryRequirementsNV with accelerationStructure and type of VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV must be less than or equal to the size of memory minus memoryOffset (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkBindAccelerationStructureMemoryInfoNV-size-02595)
```
which is triggered here: https://android.googlesource.com/platform/external/vulkan-validation-layers/+/HEAD/layers/core_validation.cpp#6922

The original (uncompacted) bottom-level acceleration structure has a size of exactly `24,772,608` bytes and I am querying its compacted size via [vkCmdWriteAccelerationStructuresPropertiesNV](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesNV.html) with `queryType` = `VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV`, which is then reported to be exactly `12,555,904` bytes.

Then I create a dedicated allocation (via VMA) of that size with offset = 0 and after binding this allocation to a newly created acceleration structure via [vkBindAccelerationStructureMemoryNV](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBindAccelerationStructureMemoryNV.html), I get the aforementioned validation error.

After reading the Vulkan specification paragraph about size requirements:
> The size member of the VkMemoryRequirements structure returned from a call to vkGetAccelerationStructureMemoryRequirementsNV with accelerationStructure and type of VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV must be less than or equal to the size of memory minus memoryOffset

I actually don't think that this requirement caters to the use of acceleration structure compaction. It is basically not possible to create a compacted acceleration structure with this (unconditional) memory size requirement mentioned in the specification. Though the compacted acceleration structure definitely is being used in the rendering afterwards since I completely discard the uncompacted acceleration structure and its allocation/memory when the compacted AS has been built.

A solution to this would be to check whether [VkAccelerationStructureCreateInfoNV](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkAccelerationStructureCreateInfoNV.html).compactedSize is greater than zero (or the actual compacted size of the AS) and in that case lift the VkBindAccelerationStructureMemoryInfoNV.size requirement or validate whether the memory size is at least the actual compacted size of the AS.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.