Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# Temporary files to ignore
compile_commands.json
settings.VisualStudio.json
*.patch
*.cso
*.sln
Expand Down
25 changes: 25 additions & 0 deletions source/code/core/core/public/ice/profiler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
# define IPT_DEALLOC_POOL( ptr, name ) TracyFreeN( ptr, ice::string::begin(name) )

# define IPT_MESSAGE( txt ) TracyMessage( txt, ice::count(txt) )
# define IPT_MESSAGE_STR( txt ) TracyMessage( ice::string::begin(txt), ice::string::size(txt) )


# if defined(TRACY_FIBERS)
# define IPT_FIBERS 1
# define IPT_FIBER_START( name ) TracyFiberEnter( name )
# define IPT_FIBER_END TracyFiberLeave
# else
# define IPT_FIBERS 0
# define IPT_FIBER_START( name )
# define IPT_FIBER_END
# endif

#else // #if ICE_PROFILE

Expand All @@ -55,5 +67,18 @@
# define IPT_DEALLOC_POOL( ptr, name )

# define IPT_MESSAGE( txt )
# define IPT_MESSAGE_STR( txt )

# define IPT_FIBERS 0
# define IPT_FIBER_START( name )
# define IPT_FIBER_END

#endif // #if ICE_PROFILE

namespace ice::profiling
{

static constexpr bool is_enabled = IPT_ENABLED;
static constexpr bool has_fiber_support = IPT_FIBERS;

} // namespace ice::profiling
34 changes: 34 additions & 0 deletions source/code/core/devui/private/devui_imgui.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/// SPDX-License-Identifier: MIT

#include <ice/devui_imgui.hxx>
#include <ice/string/heap_string.hxx>
#include <imgui/imgui_internal.h>

namespace ice::detail
Expand All @@ -19,6 +20,25 @@ namespace ice::detail
}
#endif

auto textinput_heapstring_callback(ImGuiInputTextCallbackData* data) noexcept -> ice::i32
{
ice::HeapString<>* const str = reinterpret_cast<ice::HeapString<>*>(data->UserData);
ICE_ASSERT_CORE(str != nullptr);

if ((data->EventFlag & ImGuiInputTextFlags_CallbackResize) == ImGuiInputTextFlags_CallbackResize)
{
ICE_ASSERT_CORE(ice::string::begin(*str) == data->Buf);
if (ice::string::capacity(*str) <= ice::ucount(data->BufTextLen))
{
ice::string::grow(*str, data->BufSize);
}

ice::string::resize(*str, data->BufTextLen);
data->Buf = ice::string::begin(*str);
}
return 0;
}

} // namespace ice

namespace ImGui
Expand All @@ -39,6 +59,20 @@ namespace ImGui
ImGui::TextEx(begin, end, ImGuiTextFlags_NoWidthForLargeClippedText);
}

bool InputText(ice::String label, ice::HeapString<>& out_string, ImGuiInputTextFlags flags) noexcept
{
ice::string::reserve(out_string, 1);

return ImGui::InputText(
ice::string::begin(label),
ice::string::begin(out_string),
ice::string::capacity(out_string),
flags | ImGuiInputTextFlags_CallbackResize,
ice::detail::textinput_heapstring_callback,
ice::addressof(out_string)
);
}

bool BeginLargeButton(std::string_view label, int& inout_status, ImVec2 const& size_arg, ImGuiButtonFlags flags) noexcept
{
ImGuiWindow* window = GetCurrentWindow();
Expand Down
35 changes: 35 additions & 0 deletions source/code/core/devui/public/ice/devui_imgui.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,35 @@
namespace ImGui
{

// Helpers

inline bool Begin(ice::String name, bool* inout_open = nullptr, ImGuiWindowFlags flags = 0) noexcept
{
return ImGui::Begin(ice::string::begin(name), inout_open, flags);
}

inline bool BeginListBox(ice::String label, ice::vec2f size = {}) noexcept
{
return ImGui::BeginListBox(ice::string::begin(label), ImVec2{ size.x, size.y });
}

inline void TextUnformatted(ice::String text) noexcept
{
ImGui::TextUnformatted(ice::string::begin(text), ice::string::end(text));
}

inline bool Selectable(
ice::String label,
bool selected = false,
ImGuiSelectableFlags flags = 0,
ice::vec2f size = {}
) noexcept
{
return ImGui::Selectable(ice::begin(label), selected, flags, ImVec2{ size.x, size.y });
}

// Extensions

namespace Detail
{

Expand Down Expand Up @@ -84,6 +113,12 @@ namespace ImGui
ImGui::PopStyleColor();
}

bool InputText(
ice::String label,
ice::HeapString<>& out_string,
ImGuiInputTextFlags flags = ImGuiInputTextFlags_None
) noexcept;

bool BeginLargeButton(
std::string_view label,
int& inout_status,
Expand Down
5 changes: 5 additions & 0 deletions source/code/core/memsys/public/ice/mem_allocator_utils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace ice

inline auto data_copy(ice::Allocator& alloc, ice::Data data) noexcept -> ice::Memory
{
if (data.size == 0_B)
{
return {};
}

ice::Memory const result = alloc.allocate({ data.size, data.alignment });
if (result.location != nullptr)
{
Expand Down
15 changes: 15 additions & 0 deletions source/code/core/tasks/public/ice/impl/task_utils.inl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ namespace ice
out_result = co_await ice::move(task);
}

template<typename T>
auto output_result_task(ice::TaskExpected<T> task, ice::Expected<T>& out_result) noexcept -> ice::Task<>
{
out_result = co_await ice::move(task);
}

} // namespace detail

inline auto resume_on(ice::TaskScheduler& scheduler) noexcept
Expand Down Expand Up @@ -118,4 +124,13 @@ namespace ice
barrier.wait();
}

template<typename T>
inline auto wait_for_expected(ice::TaskExpected<T> task) noexcept -> ice::Expected<T>
{
ice::Expected<T> result;
ice::wait_for(ice::detail::output_result_task(ice::move(task), result));
return result;
}

} // namespace ice

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace ice
inline void return_value(TypeExpected&& expected) noexcept(std::is_nothrow_move_constructible_v<Result>)
{
ICE_ASSERT_CORE(expected.valid());
if (expected)
if (expected.succeeded())
{
new (&_value) Result{ ice::forward<TypeExpected>(expected).value() };
}
Expand Down
5 changes: 5 additions & 0 deletions source/code/core/tasks/public/ice/task_utils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ namespace ice
void manual_wait_for_scheduled(ice::ManualResetBarrier& evnt, ice::Span<ice::Task<>> tasks, ice::TaskScheduler& scheduler) noexcept;


////////////////////////////////////////////////////////////////

template<typename T>
inline auto wait_for_expected(ice::TaskExpected<T> task) noexcept -> ice::Expected<T>;

////////////////////////////////////////////////////////////////


Expand Down
2 changes: 1 addition & 1 deletion source/code/core/utils/public/ice/expected.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace ice
{
if (_state == 1u) // Already checking our state
{
new (ice::addressof(_value)) Value { ice::forward(other)._value };
new (ice::addressof(_value)) Value { ice::forward<Value>(other) };
}
else
{
Expand Down
15 changes: 15 additions & 0 deletions source/code/iceshard/engine/public/ice/engine_asset_categories.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// Copyright 2025 - 2025, Dandielo <[email protected]>
/// SPDX-License-Identifier: MIT

#pragma once
#include <ice/engine_types.hxx>
#include <ice/asset_category.hxx>

namespace ice
{

static constexpr ice::AssetCategory AssetCategory_StaticObject = ice::make_asset_category("ice/object/static-object");
static constexpr ice::AssetCategory AssetCategory_DynamicObject = ice::make_asset_category("ice/object/dynamic-object");
static constexpr ice::AssetCategory AssetCategory_Tileset = ice::make_asset_category("ice/object/tileset");

} // namespace ice
Loading