1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-01 16:24:12 +01:00

[dxvk] Remove alignment parameter from staging buffers

Just align all suballocations to 256 bytes as usual.
This commit is contained in:
Philip Rebohle 2024-10-05 01:13:58 +02:00 committed by Philip Rebohle
parent 7eec8fb8dc
commit c614e537a9
5 changed files with 11 additions and 13 deletions

View File

@ -3103,7 +3103,7 @@ namespace dxvk {
template<typename ContextType>
DxvkBufferSlice D3D11CommonContext<ContextType>::AllocStagingBuffer(
VkDeviceSize Size) {
return m_staging.alloc(256, Size);
return m_staging.alloc(Size);
}

View File

@ -4513,7 +4513,7 @@ namespace dxvk {
m_stagingBufferAllocated += size;
D3D9BufferSlice result;
result.slice = m_stagingBuffer.alloc(256, size);
result.slice = m_stagingBuffer.alloc(size);
result.mapPtr = result.slice.mapPtr(0);
return result;
}

View File

@ -2540,7 +2540,7 @@ namespace dxvk {
const void* data) {
auto bufferSlice = buffer->getSliceHandle();
auto stagingSlice = m_staging.alloc(CACHE_LINE_SIZE, bufferSlice.length);
auto stagingSlice = m_staging.alloc(bufferSlice.length);
auto stagingHandle = stagingSlice.getSliceHandle();
std::memcpy(stagingHandle.mapPtr, data, bufferSlice.length);
@ -3478,7 +3478,7 @@ namespace dxvk {
}
auto blockCount = util::computeBlockCount(extent, formatInfo->blockSize);
auto stagingSlice = m_staging.alloc(CACHE_LINE_SIZE, elementSize * util::flattenImageExtent(blockCount));
auto stagingSlice = m_staging.alloc(elementSize * util::flattenImageExtent(blockCount));
auto stagingHandle = stagingSlice.getSliceHandle();
util::packImageData(stagingHandle.mapPtr, layerData,

View File

@ -16,7 +16,7 @@ namespace dxvk {
}
DxvkBufferSlice DxvkStagingBuffer::alloc(VkDeviceSize align, VkDeviceSize size) {
DxvkBufferSlice DxvkStagingBuffer::alloc(VkDeviceSize size) {
DxvkBufferCreateInfo info;
info.size = size;
info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT
@ -28,15 +28,14 @@ namespace dxvk {
info.access = VK_ACCESS_TRANSFER_READ_BIT
| VK_ACCESS_SHADER_READ_BIT;
VkDeviceSize alignedSize = dxvk::align(size, align);
VkDeviceSize alignedOffset = dxvk::align(m_offset, align);
VkDeviceSize alignedSize = dxvk::align(size, 256u);
if (2 * alignedSize > m_size) {
return DxvkBufferSlice(m_device->createBuffer(info,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT));
}
if (alignedOffset + alignedSize > m_size || m_buffer == nullptr) {
if (m_offset + alignedSize > m_size || m_buffer == nullptr) {
info.size = m_size;
// Free resources first if possible, in some rare
@ -44,11 +43,11 @@ namespace dxvk {
m_buffer = nullptr;
m_buffer = m_device->createBuffer(info,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
alignedOffset = 0;
m_offset = 0;
}
DxvkBufferSlice slice(m_buffer, alignedOffset, size);
m_offset = alignedOffset + alignedSize;
DxvkBufferSlice slice(m_buffer, m_offset, size);
m_offset += alignedSize;
return slice;
}

View File

@ -38,11 +38,10 @@ namespace dxvk {
*
* Tries to suballocate from existing buffer,
* or creates a new buffer if necessary.
* \param [in] align Minimum alignment
* \param [in] size Number of bytes to allocate
* \returns Allocated slice
*/
DxvkBufferSlice alloc(VkDeviceSize align, VkDeviceSize size);
DxvkBufferSlice alloc(VkDeviceSize size);
/**
* \brief Resets staging buffer and allocator