Debian Codegraph @

extern/imgui_patched/backends/imgui_impl_wgpu.h

raw
1 // dear imgui: Renderer for WebGPU
2 // This needs to be used along with a Platform Binding (e.g. GLFW)
3 // (Please note that WebGPU is currently experimental, will not run on non-beta browsers, and may break.)
4
5 // Important note to dawn and/or wgpu users: when targeting native platforms (i.e. NOT emscripten),
6 // one of IMGUI_IMPL_WEBGPU_BACKEND_DAWN or IMGUI_IMPL_WEBGPU_BACKEND_WGPU must be provided.
7 // Add #define to your imconfig.h file, or as a compilation flag in your build system.
8 // This requirement will be removed once WebGPU stabilizes and backends converge on a unified interface.
9 //#define IMGUI_IMPL_WEBGPU_BACKEND_DAWN
10 //#define IMGUI_IMPL_WEBGPU_BACKEND_WGPU
11
12 // Implemented features:
13 // [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID/ImTextureRef!
14 // [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
15 // [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
16 // [X] Renderer: Texture updates support for dynamic font system (ImGuiBackendFlags_RendererHasTextures).
17 // Missing features or Issues:
18 // [ ] Renderer: Multi-viewport support (multiple windows), useful for desktop.
19
20 // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
21 // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
22 // Learn about Dear ImGui:
23 // - FAQ https://dearimgui.com/faq
24 // - Getting Started https://dearimgui.com/getting-started
25 // - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
26 // - Introduction, links and more at the top of imgui.cpp
27
28 #pragma once
29 #include "imgui.h" // IMGUI_IMPL_API
30 #ifndef IMGUI_DISABLE
31
32 #include <webgpu/webgpu.h>
33
34 // Initialization data, for ImGui_ImplWGPU_Init()
35 struct ImGui_ImplWGPU_InitInfo
36 {
37 WGPUDevice Device;
38 int NumFramesInFlight = 3;
39 WGPUTextureFormat RenderTargetFormat = WGPUTextureFormat_Undefined;
40 WGPUTextureFormat DepthStencilFormat = WGPUTextureFormat_Undefined;
41 WGPUMultisampleState PipelineMultisampleState = {};
42
43 ImGui_ImplWGPU_InitInfo()
44 {
45 PipelineMultisampleState.count = 1;
46 PipelineMultisampleState.mask = UINT32_MAX;
47 PipelineMultisampleState.alphaToCoverageEnabled = false;
48 }
49 };
50
51 // Follow "Getting Started" link and check examples/ folder to learn about using backends!
52 IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info);
53 IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown();
54 IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame();
55 IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder);
56
57 // Use if you want to reset your rendering device without losing Dear ImGui state.
58 IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects();
59 IMGUI_IMPL_API void ImGui_ImplWGPU_InvalidateDeviceObjects();
60
61 // (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
62 IMGUI_IMPL_API void ImGui_ImplWGPU_UpdateTexture(ImTextureData* tex);
63
64 // [BETA] Selected render state data shared with callbacks.
65 // This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplWGPU_RenderDrawData() call.
66 // (Please open an issue if you feel you need access to more data)
67 struct ImGui_ImplWGPU_RenderState
68 {
69 WGPUDevice Device;
70 WGPURenderPassEncoder RenderPassEncoder;
71 };
72
73 #endif // #ifndef IMGUI_DISABLE