Implement GrGpu::transferFromBufferToBuffer on D3D

Bug: skia:13278
Bug: skia:12720
Change-Id: I83bbbf5c7f259c68f06f29ee474013d678f0073b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550707
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2022-06-17 10:08:45 -04:00 committed by SkCQ
parent b043dae116
commit 024aeb09b1
3 changed files with 30 additions and 4 deletions

View File

@ -209,10 +209,6 @@ void GrD3DBuffer::internalUnmap(size_t size) {
SkASSERT(this->isMapped()); SkASSERT(this->isMapped());
VALIDATE(); VALIDATE();
#ifdef SK_BUILD_FOR_MAC
// In both cases the size needs to be 4-byte aligned on Mac
sizeInBytes = SkAlign4(sizeInBytes);
#endif
if (this->accessPattern() == kStatic_GrAccessPattern) { if (this->accessPattern() == kStatic_GrAccessPattern) {
SkASSERT(fStagingBuffer); SkASSERT(fStagingBuffer);
this->setResourceState(this->getD3DGpu(), D3D12_RESOURCE_STATE_COPY_DEST); this->setResourceState(this->getD3DGpu(), D3D12_RESOURCE_STATE_COPY_DEST);

View File

@ -788,6 +788,30 @@ bool GrD3DGpu::uploadToTexture(GrD3DTexture* tex,
return true; return true;
} }
bool GrD3DGpu::onTransferFromBufferToBuffer(sk_sp<GrGpuBuffer> src,
size_t srcOffset,
sk_sp<GrGpuBuffer> dst,
size_t dstOffset,
size_t size) {
if (!this->currentCommandList()) {
return false;
}
sk_sp<GrD3DBuffer> d3dSrc(static_cast<GrD3DBuffer*>(src.release()));
sk_sp<GrD3DBuffer> d3dDst(static_cast<GrD3DBuffer*>(dst.release()));
fCurrentDirectCommandList->copyBufferToBuffer(std::move(d3dDst),
dstOffset,
d3dSrc->d3dResource(),
srcOffset,
size);
// copyBufferToBuffer refs the dst but not the src
this->currentCommandList()->addGrBuffer(std::move(src));
return true;
}
bool GrD3DGpu::onTransferPixelsTo(GrTexture* texture, bool GrD3DGpu::onTransferPixelsTo(GrTexture* texture,
SkIRect rect, SkIRect rect,
GrColorType surfaceColorType, GrColorType surfaceColorType,

View File

@ -182,6 +182,12 @@ private:
int mipLevelCount, int mipLevelCount,
bool prepForTexSampling) override; bool prepForTexSampling) override;
bool onTransferFromBufferToBuffer(sk_sp<GrGpuBuffer> src,
size_t srcOffset,
sk_sp<GrGpuBuffer> dst,
size_t dstOffset,
size_t size) override;
bool onTransferPixelsTo(GrTexture*, bool onTransferPixelsTo(GrTexture*,
SkIRect, SkIRect,
GrColorType surfaceColorType, GrColorType surfaceColorType,