mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-06 21:37:46 +00:00
Backends: using range-for to iterate draw_data->CmdLists[].
This commit is contained in:
@@ -160,10 +160,8 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImGui_ImplAllegro5_SetupRenderState(draw_data);
|
ImGui_ImplAllegro5_SetupRenderState(draw_data);
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
|
|
||||||
ImVector<ImDrawVertAllegro>& vertices = bd->BufVertices;
|
ImVector<ImDrawVertAllegro>& vertices = bd->BufVertices;
|
||||||
#if ALLEGRO_HAS_DRAW_INDEXED_PRIM
|
#if ALLEGRO_HAS_DRAW_INDEXED_PRIM
|
||||||
vertices.resize(draw_list->VtxBuffer.Size);
|
vertices.resize(draw_list->VtxBuffer.Size);
|
||||||
|
|||||||
@@ -200,9 +200,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImDrawIdx* idx_dst = nullptr;
|
ImDrawIdx* idx_dst = nullptr;
|
||||||
bd->pVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&vtx_dst);
|
bd->pVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&vtx_dst);
|
||||||
bd->pIB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&idx_dst);
|
bd->pIB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&idx_dst);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -268,9 +267,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -208,9 +208,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
return;
|
return;
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -282,9 +281,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -262,9 +262,8 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
return;
|
return;
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource;
|
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource;
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource;
|
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -295,9 +294,8 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -228,9 +228,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and
|
// FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and
|
||||||
// 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR
|
// 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
// 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; }
|
// 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; }
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_src = draw_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_src = draw_list->VtxBuffer.Data;
|
||||||
for (int i = 0; i < draw_list->VtxBuffer.Size; i++)
|
for (int i = 0; i < draw_list->VtxBuffer.Size; i++)
|
||||||
{
|
{
|
||||||
@@ -260,9 +259,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdListsCount == 0)
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
||||||
@@ -259,10 +259,8 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
// Render command lists
|
// Render command lists
|
||||||
size_t vertexBufferOffset = 0;
|
size_t vertexBufferOffset = 0;
|
||||||
size_t indexBufferOffset = 0;
|
size_t indexBufferOffset = 0;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
|
|
||||||
memcpy((char*)vertexBuffer.buffer.contents + vertexBufferOffset, draw_list->VtxBuffer.Data, (size_t)draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy((char*)vertexBuffer.buffer.contents + vertexBufferOffset, draw_list->VtxBuffer.Data, (size_t)draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy((char*)indexBuffer.buffer.contents + indexBufferOffset, draw_list->IdxBuffer.Data, (size_t)draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy((char*)indexBuffer.buffer.contents + indexBufferOffset, draw_list->IdxBuffer.Data, (size_t)draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
|
|
||||||
|
|||||||
@@ -208,9 +208,8 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
||||||
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, pos)));
|
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, pos)));
|
||||||
|
|||||||
@@ -584,10 +584,8 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
|
|
||||||
// Upload vertex/index buffers
|
// Upload vertex/index buffers
|
||||||
// - OpenGL drivers are in a very sorry state nowadays....
|
// - OpenGL drivers are in a very sorry state nowadays....
|
||||||
// During 2021 we attempted to switch from glBufferData() to orphaning+glBufferSubData() following reports
|
// During 2021 we attempted to switch from glBufferData() to orphaning+glBufferSubData() following reports
|
||||||
|
|||||||
@@ -180,9 +180,8 @@ void ImGui_ImplSDLGPU3_PrepareDrawData(ImDrawData* draw_data, SDL_GPUCommandBuff
|
|||||||
|
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)SDL_MapGPUTransferBuffer(v->Device, fd->VertexTransferBuffer, true);
|
ImDrawVert* vtx_dst = (ImDrawVert*)SDL_MapGPUTransferBuffer(v->Device, fd->VertexTransferBuffer, true);
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)SDL_MapGPUTransferBuffer(v->Device, fd->IndexTransferBuffer, true);
|
ImDrawIdx* idx_dst = (ImDrawIdx*)SDL_MapGPUTransferBuffer(v->Device, fd->IndexTransferBuffer, true);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -238,9 +237,8 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -169,9 +169,8 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
ImVec2 clip_scale = render_scale;
|
ImVec2 clip_scale = render_scale;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
||||||
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
||||||
|
|
||||||
|
|||||||
@@ -189,9 +189,8 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
ImVec2 clip_scale = render_scale;
|
ImVec2 clip_scale = render_scale;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
||||||
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
||||||
|
|
||||||
|
|||||||
@@ -550,9 +550,8 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, index_size, 0, (void**)&idx_dst);
|
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, index_size, 0, (void**)&idx_dst);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -590,9 +589,8 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
// Avoid rendering when minimized
|
// Avoid rendering when minimized
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdListsCount == 0)
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
||||||
@@ -442,9 +442,8 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
// Upload vertex/index data into a single contiguous GPU buffer
|
// Upload vertex/index data into a single contiguous GPU buffer
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)fr->VertexBufferHost;
|
ImDrawVert* vtx_dst = (ImDrawVert*)fr->VertexBufferHost;
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)fr->IndexBufferHost;
|
ImDrawIdx* idx_dst = (ImDrawIdx*)fr->IndexBufferHost;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -471,9 +470,8 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -245,9 +245,8 @@ void MyImGuiBackend_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// Render command lists
|
// Render command lists
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui
|
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui
|
||||||
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui
|
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui
|
||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
|
|||||||
2
imgui.h
2
imgui.h
@@ -3361,7 +3361,7 @@ struct ImDrawList
|
|||||||
struct ImDrawData
|
struct ImDrawData
|
||||||
{
|
{
|
||||||
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
|
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
|
||||||
int CmdListsCount; // Number of ImDrawList* to render. (== CmdLists.Size). Exists for legacy reason.
|
int CmdListsCount; // == CmdLists.Size. (OBSOLETE: exists for legacy reasons). Number of ImDrawList* to render.
|
||||||
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
||||||
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
||||||
ImVector<ImDrawList*> CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here.
|
ImVector<ImDrawList*> CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here.
|
||||||
|
|||||||
@@ -2312,17 +2312,16 @@ void ImDrawData::DeIndexAllBuffers()
|
|||||||
{
|
{
|
||||||
ImVector<ImDrawVert> new_vtx_buffer;
|
ImVector<ImDrawVert> new_vtx_buffer;
|
||||||
TotalVtxCount = TotalIdxCount = 0;
|
TotalVtxCount = TotalIdxCount = 0;
|
||||||
for (int i = 0; i < CmdListsCount; i++)
|
for (ImDrawList* draw_list : CmdLists)
|
||||||
{
|
{
|
||||||
ImDrawList* cmd_list = CmdLists[i];
|
if (draw_list->IdxBuffer.empty())
|
||||||
if (cmd_list->IdxBuffer.empty())
|
|
||||||
continue;
|
continue;
|
||||||
new_vtx_buffer.resize(cmd_list->IdxBuffer.Size);
|
new_vtx_buffer.resize(draw_list->IdxBuffer.Size);
|
||||||
for (int j = 0; j < cmd_list->IdxBuffer.Size; j++)
|
for (int j = 0; j < draw_list->IdxBuffer.Size; j++)
|
||||||
new_vtx_buffer[j] = cmd_list->VtxBuffer[cmd_list->IdxBuffer[j]];
|
new_vtx_buffer[j] = draw_list->VtxBuffer[draw_list->IdxBuffer[j]];
|
||||||
cmd_list->VtxBuffer.swap(new_vtx_buffer);
|
draw_list->VtxBuffer.swap(new_vtx_buffer);
|
||||||
cmd_list->IdxBuffer.resize(0);
|
draw_list->IdxBuffer.resize(0);
|
||||||
TotalVtxCount += cmd_list->VtxBuffer.Size;
|
TotalVtxCount += draw_list->VtxBuffer.Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user