diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm index 1ca829a921..04cecd9db8 100644 --- a/src/gpu/mtl/GrMtlGpu.mm +++ b/src/gpu/mtl/GrMtlGpu.mm @@ -252,15 +252,13 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex, int left, int top, int width, return true; } - sk_sp transferBuffer = GrMtlBuffer::Make(this, combinedBufferSize, - GrGpuBufferType::kXferCpuToGpu, - kStream_GrAccessPattern); + size_t bufferOffset; + id transferBuffer = this->resourceProvider().getDynamicBuffer(combinedBufferSize, + &bufferOffset); if (!transferBuffer) { return false; } - - char* buffer = (char*) transferBuffer->map(); - size_t bufferOffset = transferBuffer->offset(); + char* buffer = (char*) transferBuffer.contents + bufferOffset; currentWidth = width; currentHeight = height; @@ -274,12 +272,12 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex, int left, int top, int width, const size_t trimRowBytes = currentWidth * bpp; const size_t rowBytes = texels[currentMipLevel].fRowBytes; - // copy data into the buffer, skipping the trailing bytes + // copy data into the buffer, skipping any trailing bytes char* dst = buffer + individualMipOffsets[currentMipLevel]; const char* src = (const char*)texels[currentMipLevel].fPixels; SkRectMemcpy(dst, trimRowBytes, src, rowBytes, trimRowBytes, currentHeight); - [blitCmdEncoder copyFromBuffer: transferBuffer->mtlBuffer() + [blitCmdEncoder copyFromBuffer: transferBuffer sourceOffset: bufferOffset + individualMipOffsets[currentMipLevel] sourceBytesPerRow: trimRowBytes sourceBytesPerImage: trimRowBytes*currentHeight @@ -293,7 +291,9 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex, int left, int top, int width, currentHeight = SkTMax(1, currentHeight/2); layerHeight = currentHeight; } - transferBuffer->unmap(); +#ifdef SK_BUILD_FOR_MAC + [transferBuffer didModifyRange: NSMakeRange(bufferOffset, combinedBufferSize)]; +#endif if (mipLevelCount < (int) tex->mtlTexture().mipmapLevelCount) { tex->texturePriv().markMipMapsDirty();