Skip to content

Commit 252129f

Browse files
committed
GPU: Debug mode layer and level index checks
Resolves #13033
1 parent db154c8 commit 252129f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/gpu/SDL_gpu.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,14 @@ SDL_GPURenderPass *SDL_BeginGPURenderPass(
15461546
}
15471547
}
15481548
}
1549+
1550+
if (color_target_infos[i].layer_or_depth_plane >= textureHeader->info.layer_count_or_depth) {
1551+
SDL_assert_release(!"Color target layer index must be less than the texture's layer count!");
1552+
}
1553+
1554+
if (color_target_infos[i].mip_level >= textureHeader->info.num_levels) {
1555+
SDL_assert_release(!"Color target mip level must be less than the texture's level count!");
1556+
}
15491557
}
15501558

15511559
if (depth_stencil_target_info != NULL) {
@@ -2082,6 +2090,14 @@ SDL_GPUComputePass *SDL_BeginGPUComputePass(
20822090
SDL_assert_release(!"Texture must be created with COMPUTE_STORAGE_WRITE or COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE flag");
20832091
return NULL;
20842092
}
2093+
2094+
if (storage_texture_bindings[i].layer >= header->info.layer_count_or_depth) {
2095+
SDL_assert_release(!"Storage texture layer index must be less than the texture's layer count!");
2096+
}
2097+
2098+
if (storage_texture_bindings[i].mip_level >= header->info.num_levels) {
2099+
SDL_assert_release(!"Storage texture mip level must be less than the texture's level count!");
2100+
}
20852101
}
20862102

20872103
// TODO: validate buffer usage?

0 commit comments

Comments
 (0)