Skip to content
Merged
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
16 changes: 9 additions & 7 deletions pxr/imaging/hgiVulkan/blitCmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,25 @@ void HgiVulkanBlitCmds::CopyBufferCpuToGpu(
if (!buffer->IsCPUStagingAddress(copyOp.cpuSourceBuffer) ||
copyOp.sourceByteOffset != copyOp.destinationByteOffset) {

uint8_t* dst = static_cast<uint8_t*>(buffer->GetCPUStagingAddress());
size_t dstOffset = copyOp.destinationByteOffset;

// Offset into the src buffer
uint8_t* src = ((uint8_t*) copyOp.cpuSourceBuffer) +
const uint8_t* src = static_cast<const uint8_t*>(copyOp.cpuSourceBuffer) +
copyOp.sourceByteOffset;

// Offset into the dst buffer
memcpy(dst + dstOffset, src, copyOp.byteSize);
// Offset into the dst buffer.
uint8_t* dst = static_cast<uint8_t*>(buffer->GetCPUStagingAddress()) +
copyOp.destinationByteOffset;

memcpy(dst, src, copyOp.byteSize);
}

// Schedule copy data from staging buffer to device-local buffer.
HgiVulkanBuffer* stagingBuffer = buffer->GetStagingBuffer();

if (TF_VERIFY(stagingBuffer)) {
VkBufferCopy copyRegion = {};
copyRegion.srcOffset = copyOp.sourceByteOffset;
// Note we use the destinationByteOffset as the srcOffset here. The staging buffer
// should be prepared with the same data layout of the destination buffer.
copyRegion.srcOffset = copyOp.destinationByteOffset;
copyRegion.dstOffset = copyOp.destinationByteOffset;
copyRegion.size = copyOp.byteSize;

Expand Down