Skip to content

Commit 5d47efe

Browse files
mr1nameslouken
authored andcommitted
Fix Metal 3D texture upload stride calculation
Signed-off-by: Victor Ilyushchenko <[email protected]> (cherry picked from commit a34d313)
1 parent 824234a commit 5d47efe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/gpu/metal/SDL_gpu_metal.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,8 @@ static void METAL_UploadToTexture(
17781778
copyFromBuffer:bufferContainer->activeBuffer->handle
17791779
sourceOffset:source->offset
17801780
sourceBytesPerRow:BytesPerRow(destination->w, textureContainer->header.info.format)
1781-
sourceBytesPerImage:SDL_CalculateGPUTextureFormatSize(textureContainer->header.info.format, destination->w, destination->h, destination->d)
1781+
// sourceBytesPerImage expects the stride between 2D images (slices) of a 3D texture, not the size of the entire region
1782+
sourceBytesPerImage:SDL_CalculateGPUTextureFormatSize(textureContainer->header.info.format, destination->w, destination->h, 1)
17821783
sourceSize:MTLSizeMake(destination->w, destination->h, destination->d)
17831784
toTexture:metalTexture->handle
17841785
destinationSlice:destination->layer

0 commit comments

Comments
 (0)