Skip to content

Commit a34d313

Browse files
mr1nameslouken
authored andcommitted
Fix Metal 3D texture upload stride calculation
Signed-off-by: Victor Ilyushchenko <[email protected]>
1 parent da84d78 commit a34d313

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
@@ -1805,7 +1805,8 @@ static void METAL_UploadToTexture(
18051805
copyFromBuffer:bufferContainer->activeBuffer->handle
18061806
sourceOffset:source->offset
18071807
sourceBytesPerRow:BytesPerRow(destination->w, textureContainer->header.info.format)
1808-
sourceBytesPerImage:SDL_CalculateGPUTextureFormatSize(textureContainer->header.info.format, destination->w, destination->h, destination->d)
1808+
// sourceBytesPerImage expects the stride between 2D images (slices) of a 3D texture, not the size of the entire region
1809+
sourceBytesPerImage:SDL_CalculateGPUTextureFormatSize(textureContainer->header.info.format, destination->w, destination->h, 1)
18091810
sourceSize:MTLSizeMake(destination->w, destination->h, destination->d)
18101811
toTexture:metalTexture->handle
18111812
destinationSlice:destination->layer

0 commit comments

Comments
 (0)