Skip to content

Commit 920f489

Browse files
committed
Remove some downstream hacks from wgpu backend
1 parent 27f456f commit 920f489

File tree

3 files changed

+11
-50
lines changed

3 files changed

+11
-50
lines changed

build.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ pub fn build(b: *std.Build) void {
241241
"libs/imgui/backends/imgui_impl_glfw.cpp",
242242
"libs/imgui/backends/imgui_impl_wgpu.cpp",
243243
},
244-
.flags = &(cflags.* ++ .{"-DGLFW_INCLUDE_NONE"}),
244+
.flags = &(cflags.* ++ .{
245+
"-DGLFW_INCLUDE_NONE",
246+
// TODO: This should be IMGUI_IMPL_WEBGPU_BACKEND_DAWN but we're using an old version of Dawn that looks more like wgpu_native
247+
"-DIMGUI_IMPL_WEBGPU_BACKEND_WGPU",
248+
}),
245249
});
246250
},
247251
.glfw_opengl3 => {

libs/imgui/backends/imgui_impl_wgpu.cpp

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
// When targeting native platforms (i.e. NOT emscripten), one of IMGUI_IMPL_WEBGPU_BACKEND_DAWN
4646
// or IMGUI_IMPL_WEBGPU_BACKEND_WGPU must be provided. See imgui_impl_wgpu.h for more details.
4747

48-
// FIX(zig-gamedev)
49-
#define IMGUI_IMPL_WEBGPU_BACKEND_WGPU
50-
5148
#ifndef __EMSCRIPTEN__
5249
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) == defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
5350
#error exactly one of IMGUI_IMPL_WEBGPU_BACKEND_DAWN or IMGUI_IMPL_WEBGPU_BACKEND_WGPU must be defined!
@@ -61,8 +58,7 @@
6158
#include "imgui.h"
6259
#ifndef IMGUI_DISABLE
6360

64-
// FIX(zig-gamedev):
65-
// #include "imgui_impl_wgpu.h"
61+
#include "imgui_impl_wgpu.h"
6662

6763
#include <limits.h>
6864
#include <webgpu/webgpu.h>
@@ -71,47 +67,6 @@
7167
extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed = 0);
7268
#define MEMALIGN(_SIZE,_ALIGN) (((_SIZE) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1)) // Memory align (copied from IM_ALIGN() macro).
7369

74-
// FIX(zig-gamedev): We removed header file and declare all our external functions here.
75-
extern "C" {
76-
77-
// Initialization data, for ImGui_ImplWGPU_Init()
78-
struct ImGui_ImplWGPU_InitInfo
79-
{
80-
WGPUDevice Device;
81-
int NumFramesInFlight = 3;
82-
WGPUTextureFormat RenderTargetFormat = WGPUTextureFormat_Undefined;
83-
WGPUTextureFormat DepthStencilFormat = WGPUTextureFormat_Undefined;
84-
WGPUMultisampleState PipelineMultisampleState = {};
85-
86-
ImGui_ImplWGPU_InitInfo()
87-
{
88-
PipelineMultisampleState.count = 1;
89-
PipelineMultisampleState.mask = UINT32_MAX;
90-
PipelineMultisampleState.alphaToCoverageEnabled = false;
91-
}
92-
};
93-
94-
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
95-
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info);
96-
IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown();
97-
IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame();
98-
IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder);
99-
100-
// Use if you want to reset your rendering device without losing Dear ImGui state.
101-
IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects();
102-
IMGUI_IMPL_API void ImGui_ImplWGPU_InvalidateDeviceObjects();
103-
104-
// [BETA] Selected render state data shared with callbacks.
105-
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplWGPU_RenderDrawData() call.
106-
// (Please open an issue if you feel you need access to more data)
107-
struct ImGui_ImplWGPU_RenderState
108-
{
109-
WGPUDevice Device;
110-
WGPURenderPassEncoder RenderPassEncoder;
111-
};
112-
113-
} // extern "C"
114-
11570
// WebGPU data
11671
struct RenderResources
11772
{

libs/imgui/backends/imgui_impl_wgpu.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// This requirement will be removed once WebGPU stabilizes and backends converge on a unified interface.
99
//#define IMGUI_IMPL_WEBGPU_BACKEND_DAWN
1010

11-
// FIX(zig-gamedev)
12-
#define IMGUI_IMPL_WEBGPU_BACKEND_WGPU
13-
1411
// Implemented features:
1512
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
1613
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
@@ -32,6 +29,9 @@
3229

3330
#include <webgpu/webgpu.h>
3431

32+
// FIX(zig-gamedev)
33+
extern "C" {
34+
3535
// Initialization data, for ImGui_ImplWGPU_Init()
3636
struct ImGui_ImplWGPU_InitInfo
3737
{
@@ -68,4 +68,6 @@ struct ImGui_ImplWGPU_RenderState
6868
WGPURenderPassEncoder RenderPassEncoder;
6969
};
7070

71+
}
72+
7173
#endif // #ifndef IMGUI_DISABLE

0 commit comments

Comments
 (0)