Skip to content

Commit 77e44e7

Browse files
committed
Set renderTargetArrayLength in GPU for Metal
Requested in the GitHub comment: libsdl-org#15184 (comment) Apple Docs: https://developer.apple.com/documentation/metal/rendering-to-multiple-texture-slices-in-a-draw-command
1 parent 66a5e17 commit 77e44e7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/gpu/metal/SDL_gpu_metal.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,17 @@ static void METAL_BeginRenderPass(
23712371
METAL_INTERNAL_TrackTexture(metalCommandBuffer, texture);
23722372
}
23732373

2374+
Uint32 layerCount = 1;
2375+
for (Uint32 i = 0; i < numColorTargets; i += 1) {
2376+
MetalTextureContainer *container = (MetalTextureContainer *)colorTargetInfos[i].texture;
2377+
if (container->header.info.type == SDL_GPU_TEXTURETYPE_2D_ARRAY ||
2378+
container->header.info.type == SDL_GPU_TEXTURETYPE_CUBE ||
2379+
container->header.info.type == SDL_GPU_TEXTURETYPE_CUBE_ARRAY) {
2380+
layerCount = SDL_max(layerCount, container->header.info.layer_count_or_depth);
2381+
}
2382+
}
2383+
passDescriptor.renderTargetArrayLength = layerCount;
2384+
23742385
metalCommandBuffer->renderEncoder = [metalCommandBuffer->handle renderCommandEncoderWithDescriptor:passDescriptor];
23752386

23762387
// The viewport cannot be larger than the smallest target.

0 commit comments

Comments
 (0)