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,19 +125,8 @@ 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
|
|
||||||
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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -145,7 +134,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -225,19 +213,8 @@ 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
|
|
||||||
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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -245,7 +222,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
instancesBuffer.destroy();
|
instancesBuffer.destroy();
|
||||||
|
|
|
||||||
|
|
@ -373,19 +373,8 @@ 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
|
|
||||||
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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -393,7 +382,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
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,19 +480,8 @@ 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
|
|
||||||
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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -512,7 +489,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
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,19 +199,8 @@ 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
|
|
||||||
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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -219,7 +208,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -299,19 +287,8 @@ 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
|
|
||||||
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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -319,7 +296,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
instancesBuffer.destroy();
|
instancesBuffer.destroy();
|
||||||
|
|
|
||||||
|
|
@ -137,19 +137,8 @@ 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
|
|
||||||
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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -157,7 +146,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -237,19 +225,8 @@ 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
|
|
||||||
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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -257,7 +234,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
instancesBuffer.destroy();
|
instancesBuffer.destroy();
|
||||||
|
|
|
||||||
|
|
@ -136,20 +136,8 @@ 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
|
|
||||||
// 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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -157,7 +145,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -238,20 +225,8 @@ 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
|
|
||||||
// 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);
|
VkCommandBuffer commandBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
vkCmdBuildAccelerationStructuresKHR(
|
vkCmdBuildAccelerationStructuresKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
|
|
@ -259,7 +234,6 @@ public:
|
||||||
&accelerationBuildGeometryInfo,
|
&accelerationBuildGeometryInfo,
|
||||||
accelerationBuildStructureRangeInfos.data());
|
accelerationBuildStructureRangeInfos.data());
|
||||||
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
vulkanDevice->flushCommandBuffer(commandBuffer, queue);
|
||||||
}
|
|
||||||
|
|
||||||
deleteScratchBuffer(scratchBuffer);
|
deleteScratchBuffer(scratchBuffer);
|
||||||
instancesBuffer.destroy();
|
instancesBuffer.destroy();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue