mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Backends: WebGPU: Align buffer sizes upon creation. (#6188)
Amend from original pr to use a macro.
This commit is contained in:
parent
cbdac1e150
commit
e67f2f4791
@ -13,6 +13,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2023-04-11: Align buffer sizes.
|
||||
// 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.
|
||||
@ -33,6 +34,7 @@
|
||||
|
||||
// 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).
|
||||
|
||||
// WebGPU data
|
||||
struct RenderResources
|
||||
@ -370,7 +372,7 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
||||
nullptr,
|
||||
"Dear ImGui Vertex buffer",
|
||||
WGPUBufferUsage_CopyDst | WGPUBufferUsage_Vertex,
|
||||
fr->VertexBufferSize * sizeof(ImDrawVert),
|
||||
MEMALIGN(fr->VertexBufferSize * sizeof(ImDrawVert), 4),
|
||||
false
|
||||
};
|
||||
fr->VertexBuffer = wgpuDeviceCreateBuffer(bd->wgpuDevice, &vb_desc);
|
||||
@ -394,7 +396,7 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
||||
nullptr,
|
||||
"Dear ImGui Index buffer",
|
||||
WGPUBufferUsage_CopyDst | WGPUBufferUsage_Index,
|
||||
fr->IndexBufferSize * sizeof(ImDrawIdx),
|
||||
MEMALIGN(fr->IndexBufferSize * sizeof(ImDrawIdx), 4),
|
||||
false
|
||||
};
|
||||
fr->IndexBuffer = wgpuDeviceCreateBuffer(bd->wgpuDevice, &ib_desc);
|
||||
@ -415,8 +417,8 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
||||
vtx_dst += cmd_list->VtxBuffer.Size;
|
||||
idx_dst += cmd_list->IdxBuffer.Size;
|
||||
}
|
||||
int64_t vb_write_size = ((char*)vtx_dst - (char*)fr->VertexBufferHost + 3) & ~3;
|
||||
int64_t ib_write_size = ((char*)idx_dst - (char*)fr->IndexBufferHost + 3) & ~3;
|
||||
int64_t vb_write_size = MEMALIGN((char*)vtx_dst - (char*)fr->VertexBufferHost, 4);
|
||||
int64_t ib_write_size = MEMALIGN((char*)idx_dst - (char*)fr->IndexBufferHost, 4);
|
||||
wgpuQueueWriteBuffer(bd->defaultQueue, fr->VertexBuffer, 0, fr->VertexBufferHost, vb_write_size);
|
||||
wgpuQueueWriteBuffer(bd->defaultQueue, fr->IndexBuffer, 0, fr->IndexBufferHost, ib_write_size);
|
||||
|
||||
@ -553,7 +555,7 @@ static void ImGui_ImplWGPU_CreateUniformBuffer()
|
||||
nullptr,
|
||||
"Dear ImGui Uniform buffer",
|
||||
WGPUBufferUsage_CopyDst | WGPUBufferUsage_Uniform,
|
||||
sizeof(Uniforms),
|
||||
MEMALIGN(sizeof(Uniforms), 4),
|
||||
false
|
||||
};
|
||||
bd->renderResources.Uniforms = wgpuDeviceCreateBuffer(bd->wgpuDevice, &ub_desc);
|
||||
|
@ -90,6 +90,7 @@ Other changes:
|
||||
(#6315) [@PathogenDavid]
|
||||
- Backends: OSX: Added support for io.AddMouseSourceEvent() to discriminate Mouse/Pen.
|
||||
(#6314) [@PathogenDavid]
|
||||
- Backends: WebGPU: Align buffers. (#6188) [@eliemichel]
|
||||
- Backends: WebGPU: Reorganized to store data in io.BackendRendererUserData like other backends.
|
||||
- Examples: Windows: Added 'misc/debuggers/imgui.natstepfilter' file to all Visual Studio projects,
|
||||
now that VS 2022 17.6 Preview 2 support adding Debug Step Filter spec files into projects.
|
||||
|
Loading…
Reference in New Issue
Block a user