1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[dxvk] Implement buffer uploads on SDMA

This commit is contained in:
Philip Rebohle 2019-06-28 19:01:37 +02:00
parent 0a40e2c868
commit eb71c62b33
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 42 additions and 0 deletions

View File

@ -2054,6 +2054,37 @@ namespace dxvk {
}
void DxvkContext::uploadBuffer(
const Rc<DxvkBuffer>& buffer,
const void* data) {
auto bufferSlice = buffer->getSliceHandle();
auto stagingSlice = m_staging.alloc(CACHE_LINE_SIZE, bufferSlice.length);
auto stagingHandle = stagingSlice.getSliceHandle();
std::memcpy(stagingHandle.mapPtr, data, bufferSlice.length);
VkBufferCopy region;
region.srcOffset = stagingHandle.offset;
region.dstOffset = bufferSlice.offset;
region.size = bufferSlice.length;
m_cmd->cmdCopyBuffer(DxvkCmdBuffer::SdmaBuffer,
stagingHandle.handle, bufferSlice.handle, 1, &region);
m_sdmaBarriers.releaseBuffer(
m_initBarriers, bufferSlice,
m_device->queues().transfer.queueFamily,
VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_ACCESS_TRANSFER_WRITE_BIT,
m_device->queues().graphics.queueFamily,
buffer->info().stages,
buffer->info().access);
m_cmd->trackResource(stagingSlice.buffer());
m_cmd->trackResource(buffer);
}
void DxvkContext::setViewports(
uint32_t viewportCount,
const VkViewport* viewports,

View File

@ -772,6 +772,17 @@ namespace dxvk {
VkDeviceSize pitchPerLayer,
VkFormat format);
/**
* \brief Uses transfer queue to initialize buffer
*
* Only safe to use if the buffer is not in use by the GPU.
* \param [in] buffer The buffer to initialize
* \param [in] data The data to copy to the buffer
*/
void uploadBuffer(
const Rc<DxvkBuffer>& buffer,
const void* data);
/**
* \brief Sets viewports
*