Skip to content

Commit 604c192

Browse files
committed
GPU: Always return NULL if beginning a pass fails an assert check
1 parent 252129f commit 604c192

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/gpu/SDL_gpu.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,37 +1522,46 @@ SDL_GPURenderPass *SDL_BeginGPURenderPass(
15221522

15231523
if (color_target_infos[i].cycle && color_target_infos[i].load_op == SDL_GPU_LOADOP_LOAD) {
15241524
SDL_assert_release(!"Cannot cycle color target when load op is LOAD!");
1525+
return NULL;
15251526
}
15261527

15271528
if (color_target_infos[i].store_op == SDL_GPU_STOREOP_RESOLVE || color_target_infos[i].store_op == SDL_GPU_STOREOP_RESOLVE_AND_STORE) {
15281529
if (color_target_infos[i].resolve_texture == NULL) {
15291530
SDL_assert_release(!"Store op is RESOLVE or RESOLVE_AND_STORE but resolve_texture is NULL!");
1531+
return NULL;
15301532
} else {
15311533
TextureCommonHeader *resolveTextureHeader = (TextureCommonHeader *)color_target_infos[i].resolve_texture;
15321534
if (textureHeader->info.sample_count == SDL_GPU_SAMPLECOUNT_1) {
15331535
SDL_assert_release(!"Store op is RESOLVE or RESOLVE_AND_STORE but texture is not multisample!");
1536+
return NULL;
15341537
}
15351538
if (resolveTextureHeader->info.sample_count != SDL_GPU_SAMPLECOUNT_1) {
15361539
SDL_assert_release(!"Resolve texture must have a sample count of 1!");
1540+
return NULL;
15371541
}
15381542
if (resolveTextureHeader->info.format != textureHeader->info.format) {
15391543
SDL_assert_release(!"Resolve texture must have the same format as its corresponding color target!");
1544+
return NULL;
15401545
}
15411546
if (resolveTextureHeader->info.type == SDL_GPU_TEXTURETYPE_3D) {
15421547
SDL_assert_release(!"Resolve texture must not be of TEXTURETYPE_3D!");
1548+
return NULL;
15431549
}
15441550
if (!(resolveTextureHeader->info.usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) {
15451551
SDL_assert_release(!"Resolve texture usage must include COLOR_TARGET!");
1552+
return NULL;
15461553
}
15471554
}
15481555
}
15491556

15501557
if (color_target_infos[i].layer_or_depth_plane >= textureHeader->info.layer_count_or_depth) {
15511558
SDL_assert_release(!"Color target layer index must be less than the texture's layer count!");
1559+
return NULL;
15521560
}
15531561

15541562
if (color_target_infos[i].mip_level >= textureHeader->info.num_levels) {
15551563
SDL_assert_release(!"Color target mip level must be less than the texture's level count!");
1564+
return NULL;
15561565
}
15571566
}
15581567

@@ -1561,17 +1570,20 @@ SDL_GPURenderPass *SDL_BeginGPURenderPass(
15611570
TextureCommonHeader *textureHeader = (TextureCommonHeader *)depth_stencil_target_info->texture;
15621571
if (!(textureHeader->info.usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) {
15631572
SDL_assert_release(!"Depth target must have been created with the DEPTH_STENCIL_TARGET usage flag!");
1573+
return NULL;
15641574
}
15651575

15661576
if (depth_stencil_target_info->cycle && (depth_stencil_target_info->load_op == SDL_GPU_LOADOP_LOAD || depth_stencil_target_info->stencil_load_op == SDL_GPU_LOADOP_LOAD)) {
15671577
SDL_assert_release(!"Cannot cycle depth target when load op or stencil load op is LOAD!");
1578+
return NULL;
15681579
}
15691580

15701581
if (depth_stencil_target_info->store_op == SDL_GPU_STOREOP_RESOLVE ||
15711582
depth_stencil_target_info->stencil_store_op == SDL_GPU_STOREOP_RESOLVE ||
15721583
depth_stencil_target_info->store_op == SDL_GPU_STOREOP_RESOLVE_AND_STORE ||
15731584
depth_stencil_target_info->stencil_store_op == SDL_GPU_STOREOP_RESOLVE_AND_STORE) {
15741585
SDL_assert_release(!"RESOLVE store ops are not supported for depth-stencil targets!");
1586+
return NULL;
15751587
}
15761588
}
15771589
}
@@ -2093,10 +2105,12 @@ SDL_GPUComputePass *SDL_BeginGPUComputePass(
20932105

20942106
if (storage_texture_bindings[i].layer >= header->info.layer_count_or_depth) {
20952107
SDL_assert_release(!"Storage texture layer index must be less than the texture's layer count!");
2108+
return NULL;
20962109
}
20972110

20982111
if (storage_texture_bindings[i].mip_level >= header->info.num_levels) {
20992112
SDL_assert_release(!"Storage texture mip level must be less than the texture's level count!");
2113+
return NULL;
21002114
}
21012115
}
21022116

0 commit comments

Comments
 (0)