[js/webgpu] fix GPU to GPU memcpy (#16393)

### Description
Fixes a GPU to GPU memory copy bug which causes #16267
This commit is contained in:
Yulong Wang 2023-06-21 15:50:08 -07:00 committed by GitHub
parent 52e2bdf541
commit da532f3f5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -134,8 +134,11 @@ class GpuDataManagerImpl implements GpuDataManager {
throw new Error('inconsistent source and destination gpu data size');
}
const size = calcNormalizedBufferSize(sourceGpuDataCache.originalSize);
// GPU copy
this.backend.getCommandEncoder().copyBufferToBuffer(
const commandEncoder = this.backend.getCommandEncoder();
this.backend.endComputePass();
commandEncoder.copyBufferToBuffer(
sourceGpuDataCache.gpuData.buffer, 0, destinationGpuDataCache.gpuData.buffer, 0, size);
}