Merge pull request #812 from tangmi/remove-host-commands
Remove acceleration structure host commands usage
This commit is contained in:
commit
2735ea213e
5 changed files with 90 additions and 212 deletions
|
|
@ -125,27 +125,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
device,
|
commandBuffer,
|
||||||
VK_NULL_HANDLE,
|
1,
|
||||||
1,
|
&accelerationBuildGeometryInfo,
|
||||||
&accelerationBuildGeometryInfo,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
accelerationBuildStructureRangeInfos.data());
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -225,27 +213,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
device,
|
commandBuffer,
|
||||||
VK_NULL_HANDLE,
|
1,
|
||||||
1,
|
&accelerationBuildGeometryInfo,
|
||||||
&accelerationBuildGeometryInfo,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
accelerationBuildStructureRangeInfos.data());
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
instancesBuffer.destroy();
|
instancesBuffer.destroy();
|
||||||
|
|
|
||||||
|
|
@ -373,27 +373,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
device,
|
commandBuffer,
|
||||||
VK_NULL_HANDLE,
|
1,
|
||||||
1,
|
&accelerationBuildGeometryInfo,
|
||||||
&accelerationBuildGeometryInfo,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
accelerationBuildStructureRangeInfos.data());
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
VkAccelerationStructureDeviceAddressInfoKHR accelerationDeviceAddressInfo{};
|
VkAccelerationStructureDeviceAddressInfoKHR accelerationDeviceAddressInfo{};
|
||||||
accelerationDeviceAddressInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR;
|
accelerationDeviceAddressInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR;
|
||||||
|
|
@ -492,27 +480,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
device,
|
commandBuffer,
|
||||||
VK_NULL_HANDLE,
|
1,
|
||||||
1,
|
&accelerationBuildGeometryInfo,
|
||||||
&accelerationBuildGeometryInfo,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
accelerationBuildStructureRangeInfos.data());
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
VkAccelerationStructureDeviceAddressInfoKHR accelerationDeviceAddressInfo{};
|
VkAccelerationStructureDeviceAddressInfoKHR accelerationDeviceAddressInfo{};
|
||||||
accelerationDeviceAddressInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR;
|
accelerationDeviceAddressInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR;
|
||||||
|
|
|
||||||
|
|
@ -199,27 +199,15 @@ public:
|
||||||
}
|
}
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfos[0], &accelerationStructureBuildRangeInfos[1], &accelerationStructureBuildRangeInfos[2] };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfos[0], &accelerationStructureBuildRangeInfos[1], &accelerationStructureBuildRangeInfos[2] };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
device,
|
commandBuffer,
|
||||||
VK_NULL_HANDLE,
|
1,
|
||||||
1,
|
&accelerationBuildGeometryInfo,
|
||||||
&accelerationBuildGeometryInfo,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
accelerationBuildStructureRangeInfos.data());
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -299,27 +287,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
device,
|
commandBuffer,
|
||||||
VK_NULL_HANDLE,
|
1,
|
||||||
1,
|
&accelerationBuildGeometryInfo,
|
||||||
&accelerationBuildGeometryInfo,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
accelerationBuildStructureRangeInfos.data());
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
instancesBuffer.destroy();
|
instancesBuffer.destroy();
|
||||||
|
|
|
||||||
|
|
@ -137,27 +137,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
device,
|
commandBuffer,
|
||||||
VK_NULL_HANDLE,
|
1,
|
||||||
1,
|
&accelerationBuildGeometryInfo,
|
||||||
&accelerationBuildGeometryInfo,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
accelerationBuildStructureRangeInfos.data());
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -237,27 +225,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
device,
|
commandBuffer,
|
||||||
VK_NULL_HANDLE,
|
1,
|
||||||
1,
|
&accelerationBuildGeometryInfo,
|
||||||
&accelerationBuildGeometryInfo,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
accelerationBuildStructureRangeInfos.data());
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
instancesBuffer.destroy();
|
instancesBuffer.destroy();
|
||||||
|
|
|
||||||
|
|
@ -136,28 +136,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
// Implementation supports building acceleration structure building on host
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
vkBuildAccelerationStructuresKHR(
|
commandBuffer,
|
||||||
device,
|
1,
|
||||||
VK_NULL_HANDLE,
|
&accelerationBuildGeometryInfo,
|
||||||
1,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
&accelerationBuildGeometryInfo,
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -238,28 +225,15 @@ public:
|
||||||
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
accelerationStructureBuildRangeInfo.transformOffset = 0;
|
||||||
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
std::vector<VkAccelerationStructureBuildRangeInfoKHR*> accelerationBuildStructureRangeInfos = { &accelerationStructureBuildRangeInfo };
|
||||||
|
|
||||||
if (accelerationStructureFeatures.accelerationStructureHostCommands)
|
// 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
|
||||||
// Implementation supports building acceleration structure building on host
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
// Implementation supports building acceleration structure building on host
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
vkBuildAccelerationStructuresKHR(
|
commandBuffer,
|
||||||
device,
|
1,
|
||||||
VK_NULL_HANDLE,
|
&accelerationBuildGeometryInfo,
|
||||||
1,
|
accelerationBuildStructureRangeInfos.data());
|
||||||
&accelerationBuildGeometryInfo,
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
instancesBuffer.destroy();
|
instancesBuffer.destroy();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue