Forráskód Böngészése

Fix Metal 3D texture upload stride calculation

Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
(cherry picked from commit a34d31322ce7423b54db29ca6da5883c189b82ee)
Victor Ilyushchenko 5 hónapja
szülő
commit
5d47efe7fb
1 módosított fájl, 2 hozzáadás és 1 törlés
  1. 2 1
      src/gpu/metal/SDL_gpu_metal.m

+ 2 - 1
src/gpu/metal/SDL_gpu_metal.m

@@ -1778,7 +1778,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