From a34d31322ce7423b54db29ca6da5883c189b82ee Mon Sep 17 00:00:00 2001 From: Victor Ilyushchenko Date: Sun, 28 Sep 2025 14:51:07 +0300 Subject: [PATCH] Fix Metal 3D texture upload stride calculation Signed-off-by: Victor Ilyushchenko --- src/gpu/metal/SDL_gpu_metal.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m index b2341e5d54..8ceb2b3250 100644 --- a/src/gpu/metal/SDL_gpu_metal.m +++ b/src/gpu/metal/SDL_gpu_metal.m @@ -1805,7 +1805,8 @@ static void METAL_UploadToTexture( copyFromBuffer:bufferContainer->activeBuffer->handle sourceOffset:source->offset sourceBytesPerRow:BytesPerRow(destination->w, textureContainer->header.info.format) - sourceBytesPerImage:SDL_CalculateGPUTextureFormatSize(textureContainer->header.info.format, destination->w, destination->h, destination->d) + // sourceBytesPerImage expects the stride between 2D images (slices) of a 3D texture, not the size of the entire region + sourceBytesPerImage:SDL_CalculateGPUTextureFormatSize(textureContainer->header.info.format, destination->w, destination->h, 1) sourceSize:MTLSizeMake(destination->w, destination->h, destination->d) toTexture:metalTexture->handle destinationSlice:destination->layer