Skip to content

Commit 86b206d

Browse files
GPU: Special case to avoid assert on GenerateMipmaps (#12995)
1 parent 7b3bd8c commit 86b206d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/gpu/SDL_gpu.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,11 @@ void SDL_BindGPUVertexSamplers(
17561756

17571757
if (RENDERPASS_DEVICE->debug_mode) {
17581758
CHECK_RENDERPASS
1759-
CHECK_SAMPLER_TEXTURES
1759+
1760+
if (!((CommandBufferCommonHeader*)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation)
1761+
{
1762+
CHECK_SAMPLER_TEXTURES
1763+
}
17601764
}
17611765

17621766
RENDERPASS_DEVICE->BindVertexSamplers(
@@ -1836,7 +1840,11 @@ void SDL_BindGPUFragmentSamplers(
18361840

18371841
if (RENDERPASS_DEVICE->debug_mode) {
18381842
CHECK_RENDERPASS
1839-
CHECK_SAMPLER_TEXTURES
1843+
1844+
if (!((CommandBufferCommonHeader*)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation)
1845+
{
1846+
CHECK_SAMPLER_TEXTURES
1847+
}
18401848
}
18411849

18421850
RENDERPASS_DEVICE->BindFragmentSamplers(
@@ -2605,11 +2613,19 @@ void SDL_GenerateMipmapsForGPUTexture(
26052613
SDL_assert_release(!"GenerateMipmaps texture must be created with SAMPLER and COLOR_TARGET usage flags!");
26062614
return;
26072615
}
2616+
2617+
CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
2618+
commandBufferHeader->ignore_render_pass_texture_validation = true;
26082619
}
26092620

26102621
COMMAND_BUFFER_DEVICE->GenerateMipmaps(
26112622
command_buffer,
26122623
texture);
2624+
2625+
if (COMMAND_BUFFER_DEVICE->debug_mode) {
2626+
CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
2627+
commandBufferHeader->ignore_render_pass_texture_validation = false;
2628+
}
26132629
}
26142630

26152631
void SDL_BlitGPUTexture(

src/gpu/SDL_sysgpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ typedef struct CommandBufferCommonHeader
6666
Pass copy_pass;
6767
bool swapchain_texture_acquired;
6868
bool submitted;
69+
// used to avoid tripping assert on GenerateMipmaps
70+
bool ignore_render_pass_texture_validation;
6971
} CommandBufferCommonHeader;
7072

7173
typedef struct TextureCommonHeader

0 commit comments

Comments
 (0)