# SDL: gpu: Poll and drain the ID3D12InfoQueue for log messages when ID3D12InfoQueue1 is not supported (#16328)

**URL:** <https://discourse.libsdl.org/t/sdl-gpu-poll-and-drain-the-id3d12infoqueue-for-log-messages-when-id3d12infoqueue1-is-not-supported-16328/69373>\
**Category:** SDL Commits\
**Created:** [September 22, 2026, 2:36am UTC](https://discourse.libsdl.org/t/sdl-gpu-poll-and-drain-the-id3d12infoqueue-for-log-messages-when-id3d12infoqueue1-is-not-supported-16328/69373 "2026-09-22T02:36:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [September 22, 2026, 2:36am UTC](https://discourse.libsdl.org/t/sdl-gpu-poll-and-drain-the-id3d12infoqueue-for-log-messages-when-id3d12infoqueue1-is-not-supported-16328/69373/1 "2026-09-22T02:36:24Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/081dc4110abff604bfb9593b33953cccac01e270>

```diff
From 081dc4110abff604bfb9593b33953cccac01e270 Mon Sep 17 00:00:00 2001
From: Chicken-Bones <[EMAIL REDACTED]>
Date: Tue, 22 Sep 2026 11:45:52 +1000
Subject: [PATCH] gpu: Poll and drain the ID3D12InfoQueue for log messages when
 ID3D12InfoQueue1 is not supported (#16328)

---
 src/gpu/d3d12/SDL_gpu_d3d12.c | 54 +++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c
index 8ff0359191177..8b41ecc311bfa 100644
--- a/src/gpu/d3d12/SDL_gpu_d3d12.c
+++ b/src/gpu/d3d12/SDL_gpu_d3d12.c
@@ -914,6 +914,10 @@ struct D3D12Renderer
     WinPixEventRuntimeFns winpixeventruntimeFns;
 #endif
     ID3D12Debug *d3d12Debug;
+#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
+ ID3D12InfoQueue *debugInfoQueue;
+ BOOL InfoQueueMessageCallbackSupported;
+#endif
     BOOL supportsTearing;
     SDL_SharedObject *d3d12_dll;
     ID3D12Device *device;
@@ -1250,6 +1254,7 @@ static void D3D12_ReleaseWindow(SDL_GPURenderer *driverData, SDL_Window *window)
 static bool D3D12_Wait(SDL_GPURenderer *driverData);
 static bool D3D12_WaitForFences(SDL_GPURenderer *driverData, bool waitAll, SDL_GPUFence *const *fences, Uint32 numFences);
 static void D3D12_INTERNAL_ReleaseBlitPipelines(SDL_GPURenderer *driverData);
+static void D3D12_INTERNAL_DrainInfoQueueMessages(D3D12Renderer *renderer);
 
 // Helpers
 
@@ -1720,6 +1725,10 @@ static void D3D12_INTERNAL_DestroyRenderer(D3D12Renderer *renderer)
         ID3D12CommandQueue_Release(renderer->commandQueue);
         renderer->commandQueue = NULL;
     }
+ if (renderer->debugInfoQueue) {
+ ID3D12InfoQueue_Release(renderer->debugInfoQueue);
+ renderer->debugInfoQueue = NULL;
+ }
     if (renderer->device) {
         ID3D12Device_Release(renderer->device);
         renderer->device = NULL;
@@ -7964,6 +7973,9 @@ static bool D3D12_INTERNAL_Submit(
 
     // Notify the command buffer that we have completed recording
     res = ID3D12GraphicsCommandList_Close(d3d12CommandBuffer->graphicsCommandList);
+#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
+ D3D12_INTERNAL_DrainInfoQueueMessages(renderer);
+#endif
     CHECK_D3D12_ERROR_AND_RETURN("Failed to close command list!", false);
 
     res = ID3D12GraphicsCommandList_QueryInterface(
@@ -8122,6 +8134,9 @@ static bool D3D12_Cancel(
 
     // Notify the command buffer that we have completed recording
     res = ID3D12GraphicsCommandList_Close(d3d12CommandBuffer->graphicsCommandList);
+#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
+ D3D12_INTERNAL_DrainInfoQueueMessages(renderer);
+#endif
     CHECK_D3D12_ERROR_AND_RETURN("Failed to close command list!", false);
 
     d3d12CommandBuffer->autoReleaseFence = false;
@@ -8796,7 +8811,7 @@ static void D3D12_INTERNAL_TryInitializeD3D12DebugInfoQueue(D3D12Renderer *rende
         D3D12_MESSAGE_SEVERITY_CORRUPTION,
         true);
 
- ID3D12InfoQueue_Release(infoQueue);
+ renderer->debugInfoQueue = infoQueue;
 }
 
 static void WINAPI D3D12_INTERNAL_OnD3D12DebugInfoMsg(
@@ -8902,15 +8917,50 @@ static void D3D12_INTERNAL_TryInitializeD3D12DebugInfoLogger(D3D12Renderer *rend
         return;
     }
 
- ID3D12InfoQueue1_RegisterMessageCallback(
+ res = ID3D12InfoQueue1_RegisterMessageCallback(
         infoQueue,
         D3D12_INTERNAL_OnD3D12DebugInfoMsg,
         D3D12_MESSAGE_CALLBACK_FLAG_NONE,
         NULL,
         &callbackCookie);
+ if (SUCCEEDED(res)) {
+ renderer->InfoQueueMessageCallbackSupported = true;
+ }
 
     ID3D12InfoQueue1_Release(infoQueue);
 }
+
+static void D3D12_INTERNAL_DrainInfoQueueMessages(D3D12Renderer *renderer)
+{
+ ID3D12InfoQueue *infoQueue = renderer->debugInfoQueue;
+ UINT64 count, i;
+
+ if (renderer->InfoQueueMessageCallbackSupported || infoQueue == NULL) {
+ return;
+ }
+
+ count = ID3D12InfoQueue_GetNumStoredMessages(infoQueue);
+ if (count == 0) {
+ return;
+ }
+
+ for (i = 0; i < count; i += 1) {
+ SIZE_T size = 0;
+ ID3D12InfoQueue_GetMessage(infoQueue, i, NULL, &size);
+ D3D12_MESSAGE *message = (D3D12_MESSAGE *)SDL_malloc(size);
+ if (message && SUCCEEDED(ID3D12InfoQueue_GetMessage(infoQueue, i, message, &size))) {
+ D3D12_INTERNAL_OnD3D12DebugInfoMsg(
+ message->Category,
+ message->Severity,
+ message->ID,
+ message->pDescription,
+ NULL);
+ }
+ SDL_free(message);
+ }
+
+ ID3D12InfoQueue_ClearStoredMessages(infoQueue);
+}
 #endif
 
 // OpenXR D3D12 Support

```
