Backends: DX10, DX11, DX12, OpenGL3, Vulkan, WGPU: Assert when CreateDeviceObjects() calls return false.

This commit is contained in:
ocornut
2025-06-20 09:49:06 +02:00
parent f7dabede8b
commit 8d6e66d38c
6 changed files with 18 additions and 9 deletions

View File

@@ -642,7 +642,8 @@ void ImGui_ImplDX10_NewFrame()
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX10_Init()?");
if (!bd->pVertexShader)
ImGui_ImplDX10_CreateDeviceObjects();
if (!ImGui_ImplDX10_CreateDeviceObjects())
IM_ASSERT(0 && "ImGui_ImplDX10_CreateDeviceObjects() failed!");
}
//-----------------------------------------------------------------------------

View File

@@ -662,7 +662,8 @@ void ImGui_ImplDX11_NewFrame()
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX11_Init()?");
if (!bd->pVertexShader)
ImGui_ImplDX11_CreateDeviceObjects();
if (!ImGui_ImplDX11_CreateDeviceObjects())
IM_ASSERT(0 && "ImGui_ImplDX11_CreateDeviceObjects() failed!");
}
//-----------------------------------------------------------------------------

View File

@@ -914,7 +914,8 @@ void ImGui_ImplDX12_NewFrame()
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX12_Init()?");
if (!bd->pPipelineState)
ImGui_ImplDX12_CreateDeviceObjects();
if (!ImGui_ImplDX12_CreateDeviceObjects())
IM_ASSERT(0 && "ImGui_ImplDX12_CreateDeviceObjects() failed!");
}
//-----------------------------------------------------------------------------

View File

@@ -431,7 +431,8 @@ void ImGui_ImplOpenGL3_NewFrame()
ImGui_ImplOpenGL3_InitLoader(); // Lazily init loader if not already done for e.g. DLL boundaries.
if (!bd->ShaderHandle)
ImGui_ImplOpenGL3_CreateDeviceObjects();
if (!ImGui_ImplOpenGL3_CreateDeviceObjects())
IM_ASSERT(0 && "ImGui_ImplOpenGL3_CreateDeviceObjects() failed!");
}
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
@@ -965,21 +966,24 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
GL_CALL(vert_handle = glCreateShader(GL_VERTEX_SHADER));
glShaderSource(vert_handle, 2, vertex_shader_with_version, nullptr);
glCompileShader(vert_handle);
CheckShader(vert_handle, "vertex shader");
if (!CheckShader(vert_handle, "vertex shader"))
return false;
const GLchar* fragment_shader_with_version[2] = { bd->GlslVersionString, fragment_shader };
GLuint frag_handle;
GL_CALL(frag_handle = glCreateShader(GL_FRAGMENT_SHADER));
glShaderSource(frag_handle, 2, fragment_shader_with_version, nullptr);
glCompileShader(frag_handle);
CheckShader(frag_handle, "fragment shader");
if (!CheckShader(frag_handle, "fragment shader"))
return false;
// Link
bd->ShaderHandle = glCreateProgram();
glAttachShader(bd->ShaderHandle, vert_handle);
glAttachShader(bd->ShaderHandle, frag_handle);
glLinkProgram(bd->ShaderHandle);
CheckProgram(bd->ShaderHandle, "shader program");
if (!CheckProgram(bd->ShaderHandle, "shader program"))
return false;
glDetachShader(bd->ShaderHandle, vert_handle);
glDetachShader(bd->ShaderHandle, frag_handle);

View File

@@ -1236,7 +1236,8 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
}
#endif
ImGui_ImplVulkan_CreateDeviceObjects();
if (!ImGui_ImplVulkan_CreateDeviceObjects())
IM_ASSERT(0 && "ImGui_ImplVulkan_CreateDeviceObjects() failed!"); // <- Can't be hit yet.
return true;
}

View File

@@ -901,7 +901,8 @@ void ImGui_ImplWGPU_NewFrame()
{
ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData();
if (!bd->pipelineState)
ImGui_ImplWGPU_CreateDeviceObjects();
if (!ImGui_ImplWGPU_CreateDeviceObjects())
IM_ASSERT(0 && "ImGui_ImplWGPU_CreateDeviceObjects() failed!");
}
//-----------------------------------------------------------------------------