Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/vsg/vk/MemoryBufferPools.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ namespace vsg
/// throw vsg::Exception when reserveMemory() fails to allocated memory on device.
bool throwOutOfDeviceMemoryException = true;

/// hint whether the compile traversal should call MemoryBufferPools::reserve(requirements);
bool compileTraversalUseReserve = true;

VkDeviceSize computeMemoryTotalAvailable() const;
VkDeviceSize computeMemoryTotalReserved() const;
VkDeviceSize computeBufferTotalAvailable() const;
Expand Down
7 changes: 5 additions & 2 deletions src/vsg/state/BufferInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ ref_ptr<BufferInfo> vsg::copyDataToStagingBuffer(Context& context, const Data* d
//
bool vsg::createBufferAndTransferData(Context& context, const BufferInfoList& bufferInfoList, VkBufferUsageFlags usage, VkSharingMode sharingMode)
{
debug("vsg::createBufferAndTransferData(.., )");

if (bufferInfoList.empty()) return false;

Device* device = context.device;
Expand All @@ -198,6 +196,9 @@ bool vsg::createBufferAndTransferData(Context& context, const BufferInfoList& bu
else if (usage == VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)
alignment = device->getPhysicalDevice()->getProperties().limits.minStorageBufferOffsetAlignment;


debug("vsg::createBufferAndTransferData(Context& context, const BufferInfoList& bufferInfoList, VkBufferUsageFlags usage, VkSharingMode sharingMode) usage = ", usage, ", alignment = ", alignment);

//transferTask = nullptr;

ref_ptr<BufferInfo> deviceBufferInfo;
Expand Down Expand Up @@ -377,6 +378,8 @@ BufferInfoList vsg::createHostVisibleBuffer(Device* device, const DataList& data
else if (usage == VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)
alignment = device->getPhysicalDevice()->getProperties().limits.minStorageBufferOffsetAlignment;

debug("vsg::createHostVisibleBuffer(Device* device, const DataList& dataList, VkBufferUsageFlags usage, VkSharingMode sharingMode) usage = ", usage, ", alignment = ", alignment);

VkDeviceSize totalSize = 0;
VkDeviceSize offset = 0;
bufferInfoList.reserve(dataList.size());
Expand Down
2 changes: 2 additions & 0 deletions src/vsg/state/DescriptorBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ void DescriptorBuffer::compile(Context& context)

VkDeviceSize totalSize = 0;

debug("DescriptorBuffer::compile() bufferUsageFlags = ",bufferUsageFlags, ", alignment = ", alignment);

// compute the total size of BufferInfo that needs to be allocated.
{
VkDeviceSize offset = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/vsg/vk/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ VkResult Context::reserve(ResourceRequirements& requirements)
{
CPU_INSTRUMENTATION_L2_NC(instrumentation, "Context reserve", COLOR_COMPILE)

VkResult result = deviceMemoryBufferPools->reserve(requirements);
VkResult result = VK_SUCCESS;

if (deviceMemoryBufferPools->compileTraversalUseReserve) result = deviceMemoryBufferPools->reserve(requirements);

resourceRequirements.maxSlots.merge(requirements.maxSlots);

Expand Down
2 changes: 2 additions & 0 deletions src/vsg/vk/MemoryBufferPools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ VkResult MemoryBufferPools::reserve(ResourceRequirements& requirements)
else if ((properties.usageFlags & VK_BUFFER_USAGE_STORAGE_BUFFER_BIT) != 0)
alignment = limits.minStorageBufferOffsetAlignment;

debug("MemoryBufferPools::reserve(ResourceRequirements& requirements) properties.usageFlags = ", properties.usageFlags, ", alignment = ", alignment);

auto newBufferInfo = reserveBuffer(bufferInfo->data->dataSize(), alignment, properties.usageFlags, properties.sharingMode, memoryPropertiesFlags);
if (newBufferInfo)
{
Expand Down
Loading