From 7a827b145afe1fce20d466d00ebff41619f72687 Mon Sep 17 00:00:00 2001 From: Evan Hemsley <2342303+thatcosmonaut@users.noreply.github.com> Date: Thu, 7 May 2026 19:20:21 -0700 Subject: [PATCH] GPU: Validate that 2D textures don't have layers (#15535) (cherry picked from commit cbe3fbe9f367340dcd924de29c225c9f4ffea1f5) --- src/gpu/SDL_gpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c index f1a2ad4aa9..7c46ec3ee9 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -1258,6 +1258,11 @@ SDL_GPUTexture *SDL_CreateGPUTexture( SDL_assert_release(!"For any texture: num_levels must be >= 1"); failed = true; } + if (createinfo->type == SDL_GPU_TEXTURETYPE_2D && createinfo->layer_count_or_depth != 1) + { + SDL_assert_release(!"2D textures must have a layer count of 1"); + failed = true; + } if ((createinfo->usage & SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ) && (createinfo->usage & SDL_GPU_TEXTUREUSAGE_SAMPLER)) { SDL_assert_release(!"For any texture: usage cannot contain both GRAPHICS_STORAGE_READ and SAMPLER"); failed = true;