Backends: WebGPU: added smaller and debug helpers. (#8381, #8831, #8567, #8191, #7435)

This commit is contained in:
BrutPitt
2025-10-31 18:55:39 +01:00
committed by ocornut
parent d0e3b1d4e2
commit c5b2a848fa
3 changed files with 124 additions and 3 deletions

View File

@@ -41,6 +41,11 @@
#endif
#include <webgpu/webgpu.h>
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN)
#include <webgpu/webgpu_cpp.h> // for wgpu::Device, wgpu::DeviceLostReason, wgpu::ErrorType used by validation layer callbacks.
#elif !defined(__EMSCRIPTEN__)
#include <webgpu/wgpu.h> // WGPULogLevel
#endif
// Initialization data, for ImGui_ImplWGPU_Init()
struct ImGui_ImplWGPU_InitInfo
@@ -86,6 +91,21 @@ struct ImGui_ImplWGPU_RenderState
// Those are currently used by our example applications.
//-------------------------------------------------------------------------
// (Optional) Helper to wrap some of the Dawn/WGPU/Emscripten quirks
bool ImGui_ImplWGPU_IsSurfaceStatusError(WGPUSurfaceGetCurrentTextureStatus status);
bool ImGui_ImplWGPU_IsSurfaceStatusSubOptimal(WGPUSurfaceGetCurrentTextureStatus status); // Return whether the texture is suboptimal and may need to be recreated.
// (Optional) Helper for debugging/logging
void ImGui_ImplWGPU_DebugPrintAdapterInfo(const WGPUAdapter& adapter);
const char* ImGui_ImplWGPU_GetBackendTypeName(WGPUBackendType type);
const char* ImGui_ImplWGPU_GetAdapterTypeName(WGPUAdapterType type);
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN)
const char* ImGui_ImplWGPU_GetDeviceLostReasonName(WGPUDeviceLostReason type);
const char* ImGui_ImplWGPU_GetErrorTypeName(WGPUErrorType type);
#elif defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) && !defined(__EMSCRIPTEN__)
const char* ImGui_ImplWGPU_GetLogLevelName(WGPULogLevel level);
#endif
// (Optional) Helper to create a surface on macOS/Wayland/X11/Window
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) || defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) && !defined(__EMSCRIPTEN__)
struct ImGui_ImplWGPU_CreateSurfaceInfo