Skip to content

Commit 0457bf0

Browse files
authored
Introduced simple resource filtering API (#201)
Introduced ResourceFilter interface to allow systems to filter for resources. * Only meant to be used for editor / development tools. Changes: * Added helper function for handling HeapString using ImGui. * Added new pipeline state for Vulkan wrapper. * Added helper macros for Tracy fibers. * Added helper function to await TaskExpected results. * Improve image storage to load up to 4 textures at once. * Implemented texture preview for the ImageStorage trait. * Data Bound Asset entries will not create the 'metadata' entry if metadata is empty. Fixes: * Fixed crash in 'data_copy' if the data is empty. * Fixed the imgui font texture data binding for the Asset system. * Fixed Asset object reference count being too high after resolved from a Runtime request. * Fixed Asset Shelves storing the asset handles under the wrong hash. * Fixed bug in TaskExpected promise, that checked Expected values instead of status codes. * Fixed compiler error in Expected move cosntructor. * Fix missing translation for Home and End keys. (Windows / Linux)
1 parent 33c9620 commit 0457bf0

File tree

35 files changed

+620
-116
lines changed

35 files changed

+620
-116
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
# Temporary files to ignore
1919
compile_commands.json
20+
settings.VisualStudio.json
2021
*.patch
2122
*.cso
2223
*.sln

source/code/core/core/public/ice/profiler.hxx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@
3434
# define IPT_DEALLOC_POOL( ptr, name ) TracyFreeN( ptr, ice::string::begin(name) )
3535

3636
# define IPT_MESSAGE( txt ) TracyMessage( txt, ice::count(txt) )
37+
# define IPT_MESSAGE_STR( txt ) TracyMessage( ice::string::begin(txt), ice::string::size(txt) )
38+
39+
40+
# if defined(TRACY_FIBERS)
41+
# define IPT_FIBERS 1
42+
# define IPT_FIBER_START( name ) TracyFiberEnter( name )
43+
# define IPT_FIBER_END TracyFiberLeave
44+
# else
45+
# define IPT_FIBERS 0
46+
# define IPT_FIBER_START( name )
47+
# define IPT_FIBER_END
48+
# endif
3749

3850
#else // #if ICE_PROFILE
3951

@@ -55,5 +67,18 @@
5567
# define IPT_DEALLOC_POOL( ptr, name )
5668

5769
# define IPT_MESSAGE( txt )
70+
# define IPT_MESSAGE_STR( txt )
71+
72+
# define IPT_FIBERS 0
73+
# define IPT_FIBER_START( name )
74+
# define IPT_FIBER_END
5875

5976
#endif // #if ICE_PROFILE
77+
78+
namespace ice::profiling
79+
{
80+
81+
static constexpr bool is_enabled = IPT_ENABLED;
82+
static constexpr bool has_fiber_support = IPT_FIBERS;
83+
84+
} // namespace ice::profiling

source/code/core/devui/private/devui_imgui.cxx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/// SPDX-License-Identifier: MIT
33

44
#include <ice/devui_imgui.hxx>
5+
#include <ice/string/heap_string.hxx>
56
#include <imgui/imgui_internal.h>
67

78
namespace ice::detail
@@ -19,6 +20,25 @@ namespace ice::detail
1920
}
2021
#endif
2122

23+
auto textinput_heapstring_callback(ImGuiInputTextCallbackData* data) noexcept -> ice::i32
24+
{
25+
ice::HeapString<>* const str = reinterpret_cast<ice::HeapString<>*>(data->UserData);
26+
ICE_ASSERT_CORE(str != nullptr);
27+
28+
if ((data->EventFlag & ImGuiInputTextFlags_CallbackResize) == ImGuiInputTextFlags_CallbackResize)
29+
{
30+
ICE_ASSERT_CORE(ice::string::begin(*str) == data->Buf);
31+
if (ice::string::capacity(*str) <= ice::ucount(data->BufTextLen))
32+
{
33+
ice::string::grow(*str, data->BufSize);
34+
}
35+
36+
ice::string::resize(*str, data->BufTextLen);
37+
data->Buf = ice::string::begin(*str);
38+
}
39+
return 0;
40+
}
41+
2242
} // namespace ice
2343

2444
namespace ImGui
@@ -39,6 +59,20 @@ namespace ImGui
3959
ImGui::TextEx(begin, end, ImGuiTextFlags_NoWidthForLargeClippedText);
4060
}
4161

62+
bool InputText(ice::String label, ice::HeapString<>& out_string, ImGuiInputTextFlags flags) noexcept
63+
{
64+
ice::string::reserve(out_string, 1);
65+
66+
return ImGui::InputText(
67+
ice::string::begin(label),
68+
ice::string::begin(out_string),
69+
ice::string::capacity(out_string),
70+
flags | ImGuiInputTextFlags_CallbackResize,
71+
ice::detail::textinput_heapstring_callback,
72+
ice::addressof(out_string)
73+
);
74+
}
75+
4276
bool BeginLargeButton(std::string_view label, int& inout_status, ImVec2 const& size_arg, ImGuiButtonFlags flags) noexcept
4377
{
4478
ImGuiWindow* window = GetCurrentWindow();

source/code/core/devui/public/ice/devui_imgui.hxx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,35 @@
1818
namespace ImGui
1919
{
2020

21+
// Helpers
22+
23+
inline bool Begin(ice::String name, bool* inout_open = nullptr, ImGuiWindowFlags flags = 0) noexcept
24+
{
25+
return ImGui::Begin(ice::string::begin(name), inout_open, flags);
26+
}
27+
28+
inline bool BeginListBox(ice::String label, ice::vec2f size = {}) noexcept
29+
{
30+
return ImGui::BeginListBox(ice::string::begin(label), ImVec2{ size.x, size.y });
31+
}
32+
33+
inline void TextUnformatted(ice::String text) noexcept
34+
{
35+
ImGui::TextUnformatted(ice::string::begin(text), ice::string::end(text));
36+
}
37+
38+
inline bool Selectable(
39+
ice::String label,
40+
bool selected = false,
41+
ImGuiSelectableFlags flags = 0,
42+
ice::vec2f size = {}
43+
) noexcept
44+
{
45+
return ImGui::Selectable(ice::begin(label), selected, flags, ImVec2{ size.x, size.y });
46+
}
47+
48+
// Extensions
49+
2150
namespace Detail
2251
{
2352

@@ -84,6 +113,12 @@ namespace ImGui
84113
ImGui::PopStyleColor();
85114
}
86115

116+
bool InputText(
117+
ice::String label,
118+
ice::HeapString<>& out_string,
119+
ImGuiInputTextFlags flags = ImGuiInputTextFlags_None
120+
) noexcept;
121+
87122
bool BeginLargeButton(
88123
std::string_view label,
89124
int& inout_status,

source/code/core/memsys/public/ice/mem_allocator_utils.hxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ namespace ice
99

1010
inline auto data_copy(ice::Allocator& alloc, ice::Data data) noexcept -> ice::Memory
1111
{
12+
if (data.size == 0_B)
13+
{
14+
return {};
15+
}
16+
1217
ice::Memory const result = alloc.allocate({ data.size, data.alignment });
1318
if (result.location != nullptr)
1419
{

source/code/core/tasks/public/ice/impl/task_utils.inl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ namespace ice
1414
out_result = co_await ice::move(task);
1515
}
1616

17+
template<typename T>
18+
auto output_result_task(ice::TaskExpected<T> task, ice::Expected<T>& out_result) noexcept -> ice::Task<>
19+
{
20+
out_result = co_await ice::move(task);
21+
}
22+
1723
} // namespace detail
1824

1925
inline auto resume_on(ice::TaskScheduler& scheduler) noexcept
@@ -118,4 +124,13 @@ namespace ice
118124
barrier.wait();
119125
}
120126

127+
template<typename T>
128+
inline auto wait_for_expected(ice::TaskExpected<T> task) noexcept -> ice::Expected<T>
129+
{
130+
ice::Expected<T> result;
131+
ice::wait_for(ice::detail::output_result_task(ice::move(task), result));
132+
return result;
133+
}
134+
121135
} // namespace ice
136+

source/code/core/tasks/public/ice/task_expected_promise.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace ice
7373
inline void return_value(TypeExpected&& expected) noexcept(std::is_nothrow_move_constructible_v<Result>)
7474
{
7575
ICE_ASSERT_CORE(expected.valid());
76-
if (expected)
76+
if (expected.succeeded())
7777
{
7878
new (&_value) Result{ ice::forward<TypeExpected>(expected).value() };
7979
}

source/code/core/tasks/public/ice/task_utils.hxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ namespace ice
103103
void manual_wait_for_scheduled(ice::ManualResetBarrier& evnt, ice::Span<ice::Task<>> tasks, ice::TaskScheduler& scheduler) noexcept;
104104

105105

106+
////////////////////////////////////////////////////////////////
107+
108+
template<typename T>
109+
inline auto wait_for_expected(ice::TaskExpected<T> task) noexcept -> ice::Expected<T>;
110+
106111
////////////////////////////////////////////////////////////////
107112

108113

source/code/core/utils/public/ice/expected.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace ice
4040
{
4141
if (_state == 1u) // Already checking our state
4242
{
43-
new (ice::addressof(_value)) Value { ice::forward(other)._value };
43+
new (ice::addressof(_value)) Value { ice::forward<Value>(other) };
4444
}
4545
else
4646
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// Copyright 2025 - 2025, Dandielo <[email protected]>
2+
/// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
#include <ice/engine_types.hxx>
6+
#include <ice/asset_category.hxx>
7+
8+
namespace ice
9+
{
10+
11+
static constexpr ice::AssetCategory AssetCategory_StaticObject = ice::make_asset_category("ice/object/static-object");
12+
static constexpr ice::AssetCategory AssetCategory_DynamicObject = ice::make_asset_category("ice/object/dynamic-object");
13+
static constexpr ice::AssetCategory AssetCategory_Tileset = ice::make_asset_category("ice/object/tileset");
14+
15+
} // namespace ice

0 commit comments

Comments
 (0)