Skip to content

Commit 634e5dd

Browse files
committed
[devui-imgui] Updated ImGui to version 1.92.4.
* Moved to the new input-handling API. * Moved to the new Texture resolving API. * Other smaller improvements
1 parent 8745a35 commit 634e5dd

File tree

7 files changed

+323
-153
lines changed

7 files changed

+323
-153
lines changed

source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ namespace ice::gfx
170170

171171
device.destroy_buffer(transfer_buffer);
172172

173-
ICE_LOG(LogSeverity::Info, LogTag::Game, "ShaderStorage - Loaded image: {}", request->asset_name());
173+
ICE_LOG(LogSeverity::Info, LogTag::Game, "TextureStorage - Loaded image: {}", request->asset_name());
174174

175175
// Allocates a handle for it... (TODO: Rework?)
176176
ice::Memory const result = request->allocate(ice::size_of<ice::render::Image>);

source/code/modules/imgui_module/private/imgui_gfx_stage.cxx

Lines changed: 7 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,10 @@ namespace ice::devui
3838
using namespace ice::gfx;
3939
using namespace ice::render;
4040

41-
auto scheduler = stages.scheduler;
42-
auto stage_transfer = stages.frame_transfer;
43-
auto stage_end = stages.frame_end;
41+
ice::TaskScheduler scheduler = stages.scheduler;
4442

4543
RenderDevice& device = gfx.device();
4644

47-
ImGuiIO& io = ImGui::GetIO();
48-
49-
ice::u8* pixels;
50-
ice::i32 font_texture_width, font_texture_height;
51-
io.Fonts->GetTexDataAsRGBA32(&pixels, &font_texture_width, &font_texture_height);
52-
53-
// ice::u32 upload_size = font_texture_width * font_texture_height * 4 * sizeof(char);
54-
ice::render::ImageInfo font_info;
55-
font_info.type = ImageType::Image2D;
56-
font_info.usage = ImageUsageFlags::Sampled | ImageUsageFlags::TransferDst;
57-
font_info.format = ImageFormat::UNORM_RGBA;
58-
font_info.width = font_texture_width;
59-
font_info.height = font_texture_height;
60-
font_info.data = pixels;
61-
62-
_font_texture = device.create_image(font_info, { });
63-
6445
ice::Expected r_vert = co_await ice::gfx::load_shader_program("shaders/debug/imgui-vert", _assets);
6546
ice::Expected r_frag = co_await ice::gfx::load_shader_program("shaders/debug/imgui-frag", _assets);
6647
ICE_ASSERT_CORE(r_vert && r_frag);
@@ -132,14 +113,6 @@ namespace ice::devui
132113

133114
ResourceUpdateInfo resource_update[]
134115
{
135-
ResourceUpdateInfo
136-
{
137-
.sampler = _sampler
138-
},
139-
ResourceUpdateInfo
140-
{
141-
.image = _font_texture,
142-
},
143116
ResourceUpdateInfo
144117
{
145118
.uniform_buffer = {.buffer = _uniform_buffer, .offset = 0, .size = 64},
@@ -148,29 +121,13 @@ namespace ice::devui
148121

149122
ResourceSetUpdateInfo update_infos[]
150123
{
151-
ResourceSetUpdateInfo
152-
{
153-
.resource_set = _resources[1],
154-
.resource_type = ResourceType::Sampler,
155-
.binding_index = 1,
156-
.array_element = 0,
157-
.resources = { resource_update + 0, 1 }
158-
},
159-
ResourceSetUpdateInfo
160-
{
161-
.resource_set = _resources[1],
162-
.resource_type = ResourceType::SampledImage,
163-
.binding_index = 2,
164-
.array_element = 0,
165-
.resources = { resource_update + 1, 1 }
166-
},
167124
ResourceSetUpdateInfo
168125
{
169126
.resource_set = _resources[0],
170127
.resource_type = ResourceType::UniformBuffer,
171128
.binding_index = 3,
172129
.array_element = 0,
173-
.resources = { resource_update + 2, 1 }
130+
.resources = { resource_update, 1 }
174131
},
175132
};
176133

@@ -240,50 +197,6 @@ namespace ice::devui
240197
device.create_buffer(BufferType::Vertex, 1024 * 1024 * 64)
241198
);
242199

243-
#if 1
244-
//auto update_texture_task = [](GfxContext& gfx_ctx, GfxFrame& gfx_frame, Image image, ImageInfo image_info) noexcept -> ice::Task<>
245-
{
246-
ice::u32 const image_data_size = font_info.width * font_info.height * 4;
247-
248-
// Currently we start the task on the graphics thread, so we can dont race for access to the render device.
249-
// It is planned to create an awaiter for graphics thread access so we can schedule this at any point from any thread.
250-
ice::render::Buffer const data_buffer = device.create_buffer(
251-
ice::render::BufferType::Transfer,
252-
image_data_size
253-
);
254-
255-
ice::render::BufferUpdateInfo updates[]
256-
{
257-
ice::render::BufferUpdateInfo
258-
{
259-
.buffer = data_buffer,
260-
.data =
261-
{
262-
.location = font_info.data,
263-
.size = { image_data_size },
264-
.alignment = ice::ualign::b_4
265-
}
266-
}
267-
};
268-
269-
device.update_buffers(updates);
270-
271-
ice::render::RenderCommands& api = device.get_commands();
272-
ice::render::CommandBuffer const cmds = co_await stage_transfer;
273-
274-
api.update_texture(
275-
cmds,
276-
_font_texture,
277-
data_buffer,
278-
{ font_info.width, font_info.height }
279-
);
280-
281-
co_await stage_end;
282-
283-
device.destroy_buffer(data_buffer);
284-
}
285-
#endif
286-
287200
co_return;
288201
}
289202

@@ -306,7 +219,6 @@ namespace ice::devui
306219
ice::array::clear(_vertex_buffers);
307220

308221
device.destroy_buffer(_uniform_buffer);
309-
device.destroy_image(_font_texture);
310222
device.destroy_pipeline(_pipeline);
311223
device.destroy_pipeline_layout(_pipeline_layout);
312224
device.destroy_sampler(_sampler);
@@ -324,7 +236,7 @@ namespace ice::devui
324236
using namespace ice::render;
325237

326238
ImDrawData* draw_data = ImGui::GetDrawData();
327-
if (draw_data == nullptr)
239+
if (draw_data == nullptr || ice::array::empty(draw_commands))
328240
{
329241
return;
330242
}
@@ -360,7 +272,7 @@ namespace ice::devui
360272
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
361273
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
362274

363-
ImTextureID last_texid = nullptr; // ImGui::GetIO().tex
275+
ImTextureID last_texid = ImTextureID_Invalid; // ImGui::GetIO().tex
364276
ice::u32 next_resource_idx = 2;
365277
ResourceUpdateInfo resource_update[]
366278
{
@@ -403,11 +315,10 @@ namespace ice::devui
403315
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
404316
{
405317
ImDrawCmd const* pcmd = &cmd_list->CmdBuffer[cmd_i];
406-
407-
if (pcmd->TextureId != nullptr && pcmd->TextureId != last_texid)
318+
if (pcmd->GetTexID() != ImTextureID_Invalid && pcmd->GetTexID() != last_texid)
408319
{
409-
last_texid = pcmd->TextureId;
410-
resource_update[1].image = static_cast<Image>(reinterpret_cast<ice::uptr>(last_texid));
320+
last_texid = pcmd->GetTexID();
321+
resource_update[1].image = static_cast<Image>(last_texid);
411322
resource_set_update[0].resource_set = _resources[next_resource_idx];
412323
resource_set_update[1].resource_set = _resources[next_resource_idx];
413324

source/code/modules/imgui_module/private/imgui_gfx_stage.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ namespace ice::devui
6262
ice::render::Pipeline _pipeline;
6363

6464
ice::render::Sampler _sampler;
65-
ice::render::Image _font_texture;
6665

6766
ice::u16* _index_buffer_host;
6867
ice::Array<ice::render::Buffer> _index_buffers;

source/code/modules/imgui_module/private/imgui_system.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ namespace ice::devui
171171
ImGui::ShowDemoWindow(&show_demo);
172172
}
173173

174-
ImGui::DockSpaceOverViewport(ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode);
174+
ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode);
175175

176176
for (auto const& runtime : _widget_manager.widgets())
177177
{

0 commit comments

Comments
 (0)