anv: Add stub support for acceleration structures
This just adds a base struct and trivial implementations of all the create/destroy/bind functions. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8637>
This commit is contained in:
parent
e97002ebcf
commit
4664c92478
3 changed files with 104 additions and 8 deletions
|
|
@ -31,27 +31,85 @@ anv_GetAccelerationStructureBuildSizesKHR(
|
|||
const uint32_t* pMaxPrimitiveCounts,
|
||||
VkAccelerationStructureBuildSizesInfoKHR* pSizeInfo)
|
||||
{
|
||||
unreachable("Unimplemented");
|
||||
assert(pSizeInfo->sType ==
|
||||
VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR);
|
||||
|
||||
uint64_t max_prim_count = 0;
|
||||
for (uint32_t i = 0; i < pBuildInfo->geometryCount; i++)
|
||||
max_prim_count += pMaxPrimitiveCounts[i];
|
||||
|
||||
pSizeInfo->accelerationStructureSize = 0; /* TODO */
|
||||
|
||||
uint64_t cpu_build_scratch_size = 0; /* TODO */
|
||||
uint64_t cpu_update_scratch_size = cpu_build_scratch_size;
|
||||
|
||||
uint64_t gpu_build_scratch_size = 0; /* TODO */
|
||||
uint64_t gpu_update_scratch_size = gpu_build_scratch_size;
|
||||
|
||||
switch (buildType) {
|
||||
case VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_KHR:
|
||||
pSizeInfo->buildScratchSize = cpu_build_scratch_size;
|
||||
pSizeInfo->updateScratchSize = cpu_update_scratch_size;
|
||||
break;
|
||||
|
||||
case VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR:
|
||||
pSizeInfo->buildScratchSize = gpu_build_scratch_size;
|
||||
pSizeInfo->updateScratchSize = gpu_update_scratch_size;
|
||||
break;
|
||||
|
||||
case VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR:
|
||||
pSizeInfo->buildScratchSize = MAX2(cpu_build_scratch_size,
|
||||
gpu_build_scratch_size);
|
||||
pSizeInfo->updateScratchSize = MAX2(cpu_update_scratch_size,
|
||||
gpu_update_scratch_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
unreachable("Invalid acceleration structure build type");
|
||||
}
|
||||
}
|
||||
|
||||
VkResult
|
||||
anv_CreateAccelerationStructureKHR(
|
||||
VkDevice device,
|
||||
VkDevice _device,
|
||||
const VkAccelerationStructureCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkAccelerationStructureKHR* pAccelerationStructure)
|
||||
{
|
||||
unreachable("Unimplemented");
|
||||
return vk_error(VK_ERROR_FEATURE_NOT_PRESENT);
|
||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
ANV_FROM_HANDLE(anv_buffer, buffer, pCreateInfo->buffer);
|
||||
struct anv_acceleration_structure *accel;
|
||||
|
||||
accel = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*accel), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (accel == NULL)
|
||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
vk_object_base_init(&device->vk, &accel->base,
|
||||
VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR);
|
||||
|
||||
accel->size = pCreateInfo->size;
|
||||
accel->address = anv_address_add(buffer->address, pCreateInfo->offset);
|
||||
|
||||
*pAccelerationStructure = anv_acceleration_structure_to_handle(accel);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
anv_DestroyAccelerationStructureKHR(
|
||||
VkDevice device,
|
||||
VkDevice _device,
|
||||
VkAccelerationStructureKHR accelerationStructure,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
unreachable("Unimplemented");
|
||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
ANV_FROM_HANDLE(anv_acceleration_structure, accel, accelerationStructure);
|
||||
|
||||
if (!accel)
|
||||
return;
|
||||
|
||||
vk_object_base_finish(&accel->base);
|
||||
vk_free2(&device->vk.alloc, pAllocator, accel);
|
||||
}
|
||||
|
||||
VkDeviceAddress
|
||||
|
|
@ -59,8 +117,13 @@ anv_GetAccelerationStructureDeviceAddressKHR(
|
|||
VkDevice device,
|
||||
const VkAccelerationStructureDeviceAddressInfoKHR* pInfo)
|
||||
{
|
||||
unreachable("Unimplemented");
|
||||
return 0;
|
||||
ANV_FROM_HANDLE(anv_acceleration_structure, accel,
|
||||
pInfo->accelerationStructure);
|
||||
|
||||
assert(!anv_address_is_null(accel->address));
|
||||
assert(accel->address.bo->flags & EXEC_OBJECT_PINNED);
|
||||
|
||||
return anv_address_physical(accel->address);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1357,6 +1357,16 @@ void anv_GetPhysicalDeviceFeatures2(
|
|||
break;
|
||||
}
|
||||
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR: {
|
||||
VkPhysicalDeviceAccelerationStructureFeaturesKHR *features = (void *)ext;
|
||||
features->accelerationStructure = false;
|
||||
features->accelerationStructureCaptureReplay = false;
|
||||
features->accelerationStructureIndirectBuild = false;
|
||||
features->accelerationStructureHostCommands = false;
|
||||
features->descriptorBindingAccelerationStructureUpdateAfterBind = false;
|
||||
break;
|
||||
}
|
||||
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT: {
|
||||
VkPhysicalDeviceBufferDeviceAddressFeaturesEXT *features = (void *)ext;
|
||||
features->bufferDeviceAddress = pdevice->has_a64_buffer_access;
|
||||
|
|
@ -2146,6 +2156,19 @@ void anv_GetPhysicalDeviceProperties2(
|
|||
|
||||
vk_foreach_struct(ext, pProperties->pNext) {
|
||||
switch (ext->sType) {
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR: {
|
||||
VkPhysicalDeviceAccelerationStructurePropertiesKHR *props = (void *)ext;
|
||||
props->maxGeometryCount = (1u << 24) - 1;
|
||||
props->maxInstanceCount = (1u << 24) - 1;
|
||||
props->maxPrimitiveCount = (1u << 29) - 1;
|
||||
props->maxPerStageDescriptorAccelerationStructures = 0;
|
||||
props->maxPerStageDescriptorUpdateAfterBindAccelerationStructures = 0;
|
||||
props->maxDescriptorSetAccelerationStructures = 0;
|
||||
props->maxDescriptorSetUpdateAfterBindAccelerationStructures = 0;
|
||||
props->minAccelerationStructureScratchOffsetAlignment = 64;
|
||||
break;
|
||||
}
|
||||
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT: {
|
||||
/* TODO: Real limits */
|
||||
VkPhysicalDeviceConservativeRasterizationPropertiesEXT *properties =
|
||||
|
|
|
|||
|
|
@ -4550,6 +4550,13 @@ static inline uint32_t khr_perf_query_preamble_offset(const struct anv_query_poo
|
|||
return pool->pass_size * pass + 8;
|
||||
}
|
||||
|
||||
struct anv_acceleration_structure {
|
||||
struct vk_object_base base;
|
||||
|
||||
VkDeviceSize size;
|
||||
struct anv_address address;
|
||||
};
|
||||
|
||||
int anv_get_instance_entrypoint_index(const char *name);
|
||||
int anv_get_device_entrypoint_index(const char *name);
|
||||
int anv_get_physical_device_entrypoint_index(const char *name);
|
||||
|
|
@ -4630,6 +4637,9 @@ VK_DEFINE_HANDLE_CASTS(anv_physical_device, vk.base, VkPhysicalDevice,
|
|||
VK_OBJECT_TYPE_PHYSICAL_DEVICE)
|
||||
VK_DEFINE_HANDLE_CASTS(anv_queue, base, VkQueue, VK_OBJECT_TYPE_QUEUE)
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(anv_acceleration_structure, base,
|
||||
VkAccelerationStructureKHR,
|
||||
VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(anv_cmd_pool, base, VkCommandPool,
|
||||
VK_OBJECT_TYPE_COMMAND_POOL)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer, base, VkBuffer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue