, m_storageSize(storageSize)
{
const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(storageSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
- m_buffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ try
+ {
+ m_buffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::Cached | MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ }
+ catch (const tcu::NotSupportedError&)
+ {
+ // retry without Cached flag
+ m_buffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ }
}
VkDeviceOrHostAddressKHR SerialStorage::getAddress (const DeviceInterface& vk,
de::MovePtr<BufferWithMemory> m_accelerationStructureBuffer;
de::MovePtr<BufferWithMemory> m_vertexBuffer;
de::MovePtr<BufferWithMemory> m_indexBuffer;
- de::MovePtr<BufferWithMemory> m_scratchBuffer;
+ de::MovePtr<BufferWithMemory> m_deviceScratchBuffer;
+ std::vector<deUint8> m_hostScratchBuffer;
Move<VkAccelerationStructureKHR> m_accelerationStructureKHR;
VkBuffer m_indirectBuffer;
VkDeviceSize m_indirectBufferOffset;
/*
de::MovePtr<BufferWithMemory> m_geometryBuffer; // but only when m_buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR
de::MovePtr<Allocation> m_accelerationStructureAlloc;
- de::MovePtr<BufferWithMemory> m_scratchBuffer;
+ de::MovePtr<BufferWithMemory> m_deviceScratchBuffer;
*/
return 3u;
}
, m_accelerationStructureBuffer (DE_NULL)
, m_vertexBuffer (DE_NULL)
, m_indexBuffer (DE_NULL)
- , m_scratchBuffer (DE_NULL)
+ , m_deviceScratchBuffer (DE_NULL)
, m_accelerationStructureKHR ()
, m_indirectBuffer (DE_NULL)
, m_indirectBufferOffset (0)
{
const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(m_structureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
- m_accelerationStructureBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ try
+ {
+ m_accelerationStructureBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::Cached | MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ }
+ catch (const tcu::NotSupportedError&)
+ {
+ // retry without Cached flag
+ m_accelerationStructureBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ }
}
{
if (m_buildScratchSize > 0u)
{
- const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(m_buildScratchSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
- m_scratchBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ if (m_buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR)
+ {
+ const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(m_buildScratchSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
+ m_deviceScratchBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ }
+ else
+ {
+ m_hostScratchBuffer.resize(static_cast<size_t>(m_buildScratchSize));
+ }
}
if (m_buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR && !m_geometriesData.empty())
const VkAccelerationStructureGeometryKHR* accelerationStructureGeometriesKHRPointer = accelerationStructureGeometriesKHR.data();
const VkAccelerationStructureGeometryKHR* const* accelerationStructureGeometry = accelerationStructureGeometriesKHRPointers.data();
VkDeviceOrHostAddressKHR scratchData = (m_buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR)
- ? makeDeviceOrHostAddressKHR(vk, device, m_scratchBuffer->get(), 0)
- : makeDeviceOrHostAddressKHR(m_scratchBuffer->getAllocation().getHostPtr());
+ ? makeDeviceOrHostAddressKHR(vk, device, m_deviceScratchBuffer->get(), 0)
+ : makeDeviceOrHostAddressKHR(m_hostScratchBuffer.data());
const deUint32 geometryCount = (m_buildWithoutGeometries
? 0u
: static_cast<deUint32>(accelerationStructureGeometriesKHR.size()));
const VkDeviceSize bufferSizeBytes = bottomLevelInstances.size() * sizeof(VkAccelerationStructureInstanceKHR);
const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(bufferSizeBytes, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
- return new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress);
+ try
+ {
+ return new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::Cached | MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress);
+ }
+ catch (const tcu::NotSupportedError&)
+ {
+ // retry without Cached flag
+ return new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress);
+ }
}
void updateInstanceBuffer (const DeviceInterface& vk,
de::MovePtr<BufferWithMemory> m_accelerationStructureBuffer;
de::MovePtr<BufferWithMemory> m_instanceBuffer;
de::MovePtr<BufferWithMemory> m_instanceAddressBuffer;
- de::MovePtr<BufferWithMemory> m_scratchBuffer;
+ de::MovePtr<BufferWithMemory> m_deviceScratchBuffer;
+ std::vector<deUint8> m_hostScratchBuffer;
Move<VkAccelerationStructureKHR> m_accelerationStructureKHR;
VkBuffer m_indirectBuffer;
VkDeviceSize m_indirectBufferOffset;
/*
de::MovePtr<BufferWithMemory> m_instanceBuffer;
de::MovePtr<Allocation> m_accelerationStructureAlloc;
- de::MovePtr<BufferWithMemory> m_scratchBuffer;
+ de::MovePtr<BufferWithMemory> m_deviceScratchBuffer;
*/
return 3u;
}
, m_accelerationStructureBuffer (DE_NULL)
, m_instanceBuffer (DE_NULL)
, m_instanceAddressBuffer (DE_NULL)
- , m_scratchBuffer (DE_NULL)
+ , m_deviceScratchBuffer (DE_NULL)
, m_accelerationStructureKHR ()
, m_indirectBuffer (DE_NULL)
, m_indirectBufferOffset (0)
{
const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(m_structureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
- m_accelerationStructureBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ try
+ {
+ m_accelerationStructureBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::Cached | MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ }
+ catch (const tcu::NotSupportedError&)
+ {
+ // retry without Cached flag
+ m_accelerationStructureBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ }
}
{
if (m_buildScratchSize > 0u)
{
- const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(m_buildScratchSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
- m_scratchBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ if (m_buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR)
+ {
+ const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(m_buildScratchSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
+ m_deviceScratchBuffer = de::MovePtr<BufferWithMemory>(new BufferWithMemory(vk, device, allocator, bufferCreateInfo, MemoryRequirement::HostVisible | MemoryRequirement::Coherent | MemoryRequirement::DeviceAddress));
+ }
+ else
+ {
+ m_hostScratchBuffer.resize(static_cast<size_t>(m_buildScratchSize));
+ }
}
if (m_useArrayOfPointers)
prepareInstances(vk, device, accelerationStructureGeometryKHR, maxPrimitiveCounts);
VkDeviceOrHostAddressKHR scratchData = (m_buildType == VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR)
- ? makeDeviceOrHostAddressKHR(vk, device, m_scratchBuffer->get(), 0)
- : makeDeviceOrHostAddressKHR(m_scratchBuffer->getAllocation().getHostPtr());
+ ? makeDeviceOrHostAddressKHR(vk, device, m_deviceScratchBuffer->get(), 0)
+ : makeDeviceOrHostAddressKHR(m_hostScratchBuffer.data());
VkAccelerationStructureBuildGeometryInfoKHR accelerationStructureBuildGeometryInfoKHR =
{