Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Delgado Kraemer committed Dec 7, 2024
1 parent 203f0ec commit f221400
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions src/cgpu/impl/Cgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,34 +535,29 @@ namespace gtl
VmaAllocator allocator,
VkBufferUsageFlags bufferUsage,
VmaMemoryUsage memoryUsage,
VkDeviceSize blockSize,
uint32_t allocationAlignment = 0)
{
VkBufferCreateInfo createInfoTemplate = {};
createInfoTemplate.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
createInfoTemplate.size = 0x1000; // doesn't matter
createInfoTemplate.usage = bufferUsage;

VkBufferCreateInfo createInfoTemplate = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.size = 0x1000, // doesn't matter
.usage = bufferUsage
};
VmaAllocationCreateInfo allocCreateInfo = {};
allocCreateInfo.usage = memoryUsage;

VmaAllocationCreateInfo allocCreateInfo = {
.usage = memoryUsage
};
uint32_t memTypeIndex;
VkResult result = vmaFindMemoryTypeIndexForBufferInfo(allocator, &createInfoTemplate,
&allocCreateInfo, &memTypeIndex);
if (result != VK_SUCCESS)
{
return result;
}

uint32_t memTypeIndex;
VkResult result = vmaFindMemoryTypeIndexForBufferInfo(allocator, &createInfoTemplate,
&allocCreateInfo, &memTypeIndex);
if (result != VK_SUCCESS)
{
return result;
}
VmaPoolCreateInfo poolCreateInfo = {};
poolCreateInfo.memoryTypeIndex = memTypeIndex;
poolCreateInfo.minAllocationAlignment = allocationAlignment;

VmaPoolCreateInfo poolCreateInfo = {
.memoryTypeIndex = memTypeIndex,
.blockSize = blockSize,
.minAllocationAlignment = allocationAlignment
};
return vmaCreatePool(allocator, &poolCreateInfo, &pool);
return vmaCreatePool(allocator, &poolCreateInfo, &pool);
}

bool cgpuCreateDevice(CgpuDevice* device)
Expand Down Expand Up @@ -1084,7 +1079,6 @@ namespace gtl
result = cgpuCreateMemoryPool(idevice->asScratchMemoryPool, idevice->allocator,
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
8 * 1024 * 1024, // 8 MB, RTXMU default
idevice->properties.minAccelerationStructureScratchOffsetAlignment);

if (result != VK_SUCCESS)
Expand All @@ -1099,6 +1093,8 @@ namespace gtl
CGPU_RETURN_ERROR("failed to create AS scratch memory pool");
}

vmaSetPoolName(idevice->allocator, idevice->asScratchMemoryPool, "[AS scratch memory pool]");

VkPipelineCacheCreateInfo cacheCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO,
.pNext = nullptr,
Expand Down Expand Up @@ -1234,10 +1230,9 @@ namespace gtl
.pQueueFamilyIndices = nullptr,
};

VmaAllocationCreateInfo allocCreateInfo = {
.requiredFlags = (VkMemoryPropertyFlags) memoryProperties,
.pool = memoryPool
};
VmaAllocationCreateInfo allocCreateInfo = {};
allocCreateInfo.requiredFlags = (VkMemoryPropertyFlags) memoryProperties;
allocCreateInfo.pool = memoryPool;

VkResult result;
if (alignment > 0)
Expand Down

0 comments on commit f221400

Please sign in to comment.