Browse Source

GPU: Special case to avoid assert on GenerateMipmaps (#12995)

Evan Hemsley 3 months ago
parent
commit
86b206dadf
2 changed files with 20 additions and 2 deletions
  1. 18 2
      src/gpu/SDL_gpu.c
  2. 2 0
      src/gpu/SDL_sysgpu.h

+ 18 - 2
src/gpu/SDL_gpu.c

@@ -1756,7 +1756,11 @@ void SDL_BindGPUVertexSamplers(
 
 
     if (RENDERPASS_DEVICE->debug_mode) {
     if (RENDERPASS_DEVICE->debug_mode) {
         CHECK_RENDERPASS
         CHECK_RENDERPASS
-        CHECK_SAMPLER_TEXTURES
+
+        if (!((CommandBufferCommonHeader*)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation)
+        {
+            CHECK_SAMPLER_TEXTURES
+        }
     }
     }
 
 
     RENDERPASS_DEVICE->BindVertexSamplers(
     RENDERPASS_DEVICE->BindVertexSamplers(
@@ -1836,7 +1840,11 @@ void SDL_BindGPUFragmentSamplers(
 
 
     if (RENDERPASS_DEVICE->debug_mode) {
     if (RENDERPASS_DEVICE->debug_mode) {
         CHECK_RENDERPASS
         CHECK_RENDERPASS
-        CHECK_SAMPLER_TEXTURES
+
+        if (!((CommandBufferCommonHeader*)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation)
+        {
+            CHECK_SAMPLER_TEXTURES
+        }
     }
     }
 
 
     RENDERPASS_DEVICE->BindFragmentSamplers(
     RENDERPASS_DEVICE->BindFragmentSamplers(
@@ -2605,11 +2613,19 @@ void SDL_GenerateMipmapsForGPUTexture(
             SDL_assert_release(!"GenerateMipmaps texture must be created with SAMPLER and COLOR_TARGET usage flags!");
             SDL_assert_release(!"GenerateMipmaps texture must be created with SAMPLER and COLOR_TARGET usage flags!");
             return;
             return;
         }
         }
+
+        CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
+        commandBufferHeader->ignore_render_pass_texture_validation = true;
     }
     }
 
 
     COMMAND_BUFFER_DEVICE->GenerateMipmaps(
     COMMAND_BUFFER_DEVICE->GenerateMipmaps(
         command_buffer,
         command_buffer,
         texture);
         texture);
+
+    if (COMMAND_BUFFER_DEVICE->debug_mode) {
+        CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
+        commandBufferHeader->ignore_render_pass_texture_validation = false;
+    }
 }
 }
 
 
 void SDL_BlitGPUTexture(
 void SDL_BlitGPUTexture(

+ 2 - 0
src/gpu/SDL_sysgpu.h

@@ -66,6 +66,8 @@ typedef struct CommandBufferCommonHeader
     Pass copy_pass;
     Pass copy_pass;
     bool swapchain_texture_acquired;
     bool swapchain_texture_acquired;
     bool submitted;
     bool submitted;
+    // used to avoid tripping assert on GenerateMipmaps
+    bool ignore_render_pass_texture_validation;
 } CommandBufferCommonHeader;
 } CommandBufferCommonHeader;
 
 
 typedef struct TextureCommonHeader
 typedef struct TextureCommonHeader