Merge pull request #812 from tangmi/remove-host-commands

Remove acceleration structure host commands usage
This commit is contained in:
Sascha Willems 2021-05-31 19:35:24 +02:00 committed by GitHub
commit 2735ea213e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 90 additions and 212 deletions

View file

@ -137,27 +137,15 @@ public:
accelerationStructureBuildRangeInfo.transformOffset = 0;
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
if (accelerationStructureFeatures.accelerationStructureHostCommands)
{
// Implementation supports building acceleration structure building on host
vkBuildAccelerationStructuresKHR(
device,
VK_NULL_HANDLE,
1,
&accelerationBuildGeometryInfo,
accelerationBuildStructureRangeInfos.data());
}
else
{
// Acceleration structure needs to be build on the device
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
vkCmdBuildAccelerationStructuresKHR(
commandBuffer,
1,
&accelerationBuildGeometryInfo,
accelerationBuildStructureRangeInfos.data());
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
}
// Build the acceleration structure on the device via a one-time command buffer submission
// Some implementations may support acceleration structure building on the host (VkPhysicalDeviceAccelerationStructureFeaturesKHR->accelerationStructureHostCommands), but we prefer device builds
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
vkCmdBuildAccelerationStructuresKHR(
commandBuffer,
1,
&accelerationBuildGeometryInfo,
accelerationBuildStructureRangeInfos.data());
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
deleteScratchBuffer(scratchBuffer);
}
@ -237,27 +225,15 @@ public:
accelerationStructureBuildRangeInfo.transformOffset = 0;
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
if (accelerationStructureFeatures.accelerationStructureHostCommands)
{
// Implementation supports building acceleration structure building on host
vkBuildAccelerationStructuresKHR(
device,
VK_NULL_HANDLE,
1,
&accelerationBuildGeometryInfo,
accelerationBuildStructureRangeInfos.data());
}
else
{
// Acceleration structure needs to be build on the device
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
vkCmdBuildAccelerationStructuresKHR(
commandBuffer,
1,
&accelerationBuildGeometryInfo,
accelerationBuildStructureRangeInfos.data());
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
}
// Build the acceleration structure on the device via a one-time command buffer submission
// Some implementations may support acceleration structure building on the host (VkPhysicalDeviceAccelerationStructureFeaturesKHR->accelerationStructureHostCommands), but we prefer device builds
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
vkCmdBuildAccelerationStructuresKHR(
commandBuffer,
1,
&accelerationBuildGeometryInfo,
accelerationBuildStructureRangeInfos.data());
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
deleteScratchBuffer(scratchBuffer);
instancesBuffer.destroy();