Skip to content

Commit

Permalink
Adapt to wgpu-native Drop methods
Browse files Browse the repository at this point in the history
Fix include for wgpu-native
  • Loading branch information
eliemichel authored and ocornut committed Apr 11, 2023
1 parent d81f2ae commit 33b8978
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion backends/imgui_impl_wgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2023-04-11: Align buffer sizes. Use WGSL shaders instead of precompiled SPIR-V.
// 2023-04-11: Align buffer sizes. Use WGSL shaders instead of precompiled SPIR-V. Adapt to wgpu-native backend. Define WEBGPU_BACKEND_WGPU when using the wgpu-backend.
// 2023-04-11: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
// 2023-01-25: Revert automatic pipeline layout generation (see https://github.com/gpuweb/gpuweb/issues/2470)
// 2022-11-24: Fixed validation error with default depth buffer settings.
Expand All @@ -32,6 +32,20 @@
#include <limits.h>
#include <webgpu/webgpu.h>

// These differences of implementation should vanish as soon as WebGPU gets in version 1.0 stable
#ifdef WEBGPU_BACKEND_WGPU
#include <webgpu/wgpu.h>
#define wgpuBindGroupLayoutRelease wgpuBindGroupLayoutDrop
#define wgpuBindGroupRelease wgpuBindGroupDrop
#define wgpuRenderPipelineRelease wgpuRenderPipelineDrop
#define wgpuSamplerRelease wgpuSamplerDrop
#define wgpuShaderModuleRelease wgpuShaderModuleDrop
#define wgpuTextureViewRelease wgpuTextureViewDrop
#define wgpuTextureRelease wgpuTextureDrop
#define wgpuBufferRelease wgpuBufferDrop
#define wgpuQueueRelease(...)
#endif // WEBGPU_BACKEND_WGPU

// Dear ImGui prototypes from imgui_internal.h
extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed = 0);
#define MEMALIGN(_SIZE,_ALIGN) (((_SIZE) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1)) // Memory align (copied from IM_ALIGN() macro).
Expand Down Expand Up @@ -230,7 +244,11 @@ static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModule(const c

WGPUShaderModuleWGSLDescriptor wgsl_desc = {};
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
#if defined(WEBGPU_BACKEND_WGPU)
wgsl_desc.code = wgsl_source;
#else
wgsl_desc.source = wgsl_source;
#endif

WGPUShaderModuleDescriptor desc = {};
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);
Expand Down

0 comments on commit 33b8978

Please sign in to comment.