Просмотр исходного кода

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

ocornut 1 месяц назад
Родитель
Сommit
8d6e66d38c

+ 2 - 1
backends/imgui_impl_dx10.cpp

@@ -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!");
 }
 
 //-----------------------------------------------------------------------------

+ 2 - 1
backends/imgui_impl_dx11.cpp

@@ -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!");
 }
 
 //-----------------------------------------------------------------------------

+ 2 - 1
backends/imgui_impl_dx12.cpp

@@ -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!");
 }
 
 //-----------------------------------------------------------------------------

+ 8 - 4
backends/imgui_impl_opengl3.cpp

@@ -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);

+ 2 - 1
backends/imgui_impl_vulkan.cpp

@@ -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;
 }

+ 2 - 1
backends/imgui_impl_wgpu.cpp

@@ -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!");
 }
 
 //-----------------------------------------------------------------------------