Skip to content
Closed
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
63 changes: 47 additions & 16 deletions source/code/core/collections/public/ice/heap_varstring.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ namespace ice
ice::Allocator* _allocator;
ValueType* _data;

inline explicit HeapVarString(ice::Allocator& alloc) noexcept;
inline HeapVarString(ice::Allocator& allocator, ice::BasicString<CharType> string) noexcept;
inline ~HeapVarString() noexcept;
constexpr explicit HeapVarString(ice::Allocator& alloc) noexcept;
constexpr HeapVarString(ice::Allocator& allocator, ice::BasicString<CharType> string) noexcept;
constexpr ~HeapVarString() noexcept;

inline HeapVarString(HeapVarString&& other) noexcept;
inline HeapVarString(HeapVarString const& other) noexcept;
constexpr HeapVarString(HeapVarString&& other) noexcept;
constexpr HeapVarString(HeapVarString const& other) noexcept;

constexpr auto data() const noexcept -> ValueType*;
constexpr auto size() const noexcept -> SizeType;

inline auto data_view() const noexcept -> ice::Data;
constexpr void clear() noexcept;
constexpr auto deserialize(ice::Data data) noexcept -> ice::Data;

inline operator ice::BasicString<CharType>() const noexcept;
inline operator ice::VarStringBase<CharType>() const noexcept;
constexpr auto data_view() const noexcept -> ice::Data;

constexpr operator ice::BasicString<CharType>() const noexcept;
constexpr operator ice::VarStringBase<CharType>() const noexcept;
};

namespace varstring
Expand Down Expand Up @@ -77,34 +80,34 @@ namespace ice
} // namespace string::detail

template<typename CharT>
inline HeapVarString<CharT>::HeapVarString(ice::Allocator& alloc) noexcept
inline constexpr HeapVarString<CharT>::HeapVarString(ice::Allocator& alloc) noexcept
: _allocator{ ice::addressof(alloc) }
, _data{ nullptr }
{
}

template<typename CharT>
inline HeapVarString<CharT>::HeapVarString(ice::Allocator& alloc, ice::BasicString<CharT> string) noexcept
inline constexpr HeapVarString<CharT>::HeapVarString(ice::Allocator& alloc, ice::BasicString<CharT> string) noexcept
: _allocator{ ice::addressof(alloc) }
, _data{ ice::varstring::create(alloc, string) }
{
}

template<typename CharT>
inline HeapVarString<CharT>::HeapVarString(ice::HeapVarString<CharT>&& other) noexcept
inline constexpr HeapVarString<CharT>::HeapVarString(ice::HeapVarString<CharT>&& other) noexcept
: _allocator{ other._allocator }
, _data{ ice::exchange(other._data, nullptr) }
{
}

template<typename CharT>
inline HeapVarString<CharT>::HeapVarString(ice::HeapVarString<CharT> const& other) noexcept
inline constexpr HeapVarString<CharT>::HeapVarString(ice::HeapVarString<CharT> const& other) noexcept
: HeapVarString{ other._allocator, ice::String{ other } }
{
}

template<typename CharT>
inline HeapVarString<CharT>::~HeapVarString() noexcept
inline constexpr HeapVarString<CharT>::~HeapVarString() noexcept
{
if (_data != nullptr)
{
Expand All @@ -125,7 +128,35 @@ namespace ice
}

template<typename CharT>
inline auto HeapVarString<CharT>::data_view() const noexcept -> ice::Data
inline constexpr void HeapVarString<CharT>::clear() noexcept
{
_allocator->deallocate(std::exchange(_data, nullptr));
}

template<typename CharT>
inline constexpr auto HeapVarString<CharT>::deserialize(ice::Data data) noexcept -> ice::Data
{
ICE_ASSERT_CORE(data.size >= 2_B); // 1 byte for size + 1 for a single character
this->clear(); // Clear the current contents

ice::usize bytes;
ice::ncount const size = ice::varstring::read_size(reinterpret_cast<char const*>(data.location), bytes);
if (size > 0)
{
char* const new_str = ice::varstring::allocate_exact(*_allocator, size, bytes);
if (new_str != nullptr)
{
ice::memcpy(new_str + bytes.value, ice::ptr_add(data.location, bytes), size.bytes());
new_str[bytes.value + size.native()] = '\0';
}
_data = new_str; // Assign the new allocated data
}

return ice::ptr_add(data, bytes + size.bytes());
}

template<typename CharT>
inline constexpr auto HeapVarString<CharT>::data_view() const noexcept -> ice::Data
{
ice::usize bytes = 0_B;
ice::ncount const size = ice::varstring::read_size(_data, bytes);
Expand All @@ -138,7 +169,7 @@ namespace ice
}

template<typename CharT>
inline HeapVarString<CharT>::operator ice::BasicString<typename HeapVarString<CharT>::CharType>() const noexcept
inline constexpr HeapVarString<CharT>::operator ice::BasicString<typename HeapVarString<CharT>::CharType>() const noexcept
{
ice::usize bytes = 0_B;
ice::ncount const size = ice::varstring::read_size(_data, bytes);
Expand All @@ -153,7 +184,7 @@ namespace ice
}

template<typename CharT>
inline HeapVarString<CharT>::operator ice::VarStringBase<typename HeapVarString<CharT>::CharType>() const noexcept
inline constexpr HeapVarString<CharT>::operator ice::VarStringBase<typename HeapVarString<CharT>::CharType>() const noexcept
{
return _data;
}
Expand Down
18 changes: 13 additions & 5 deletions source/code/core/collections/public/ice/multi_hashmap.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,20 @@ namespace ice
{
ICE_ASSERT_CORE(valid());

_current = _entries[_current].next;
if (_current == ice::detail::hashmap::Constant_EndOfList)
ice::u64 const expected_key = this->key();

do
{
_entries = nullptr;
_values = nullptr;
}
_current = _entries[_current].next;
if (_current == ice::detail::hashmap::Constant_EndOfList)
{
_entries = nullptr;
_values = nullptr;
break;
}

// Test against the new key if we are not at the end.
} while (this->key() != expected_key);
}

constexpr auto key() const noexcept -> ice::u64 const& { return _entries[_current].key; }
Expand Down
10 changes: 10 additions & 0 deletions source/code/core/collections/public/ice/shard_container.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ice
struct ShardContainer : public ice::Array<ice::Shard>
{
using ice::Array<ice::Shard>::Array;
using ice::Array<ice::Shard>::push_back;

constexpr bool contains(ice::ShardID shardid) const noexcept;
constexpr auto count_of(ice::ShardID shardid) const noexcept -> ice::ncount;
Expand Down Expand Up @@ -60,6 +61,9 @@ namespace ice
this ShardContainer& self,
ice::ShardID shardid
) noexcept;

template<std::size_t Count>
inline constexpr void push_back(ice::Shard const(&shards_array)[Count]) noexcept;
};

inline constexpr bool ShardContainer::contains(ice::ShardID expected_shard) const noexcept
Expand Down Expand Up @@ -203,4 +207,10 @@ namespace ice
self.resize(count);
}

template<std::size_t Count>
inline constexpr void ShardContainer::push_back(ice::Shard const(&shards_array)[Count]) noexcept
{
this->push_back(ice::Span{ shards_array });
}

} // namespace ice
2 changes: 1 addition & 1 deletion source/code/core/collections/public/ice/sort.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ namespace ice
inline void sort_many(ice::Span<Key> keys, Pred&& pred, ice::Span<Values>... values) noexcept
{
ice::i32 const first_index = 0;
ice::i32 const last_index = ice::count(keys) - 1;
ice::i32 const last_index = keys.size().u32() - 1;

ice::detail::qsort_many(std::forward<Pred>(pred), first_index, last_index, keys, values...);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ auto ice_resume(
runtime.input_tracker->register_device_type(ice::input::DeviceType::Keyboard, ice::input::get_default_device_factory());

//runtime.gfx_rendergraph_runtime = state.game->rendergraph(runtime.gfx_runner->device());
ice::wait_for(runtime.gfx_runner->update_rendergraph(state.game->rendergraph(runtime.gfx_runner->context())));
runtime.gfx_runner->update_rendergraph(state.game->rendergraph(runtime.gfx_runner->context()));
runtime.gfx_wait.set();
}

Expand Down Expand Up @@ -660,7 +660,7 @@ auto ice_update(

//runtime.gfx_wait.wait();
runtime.gfx_runner->context().recreate_swapchain();
ice::wait_for(runtime.gfx_runner->update_rendergraph(state.game->rendergraph(runtime.gfx_runner->context())));
runtime.gfx_runner->update_rendergraph(state.game->rendergraph(runtime.gfx_runner->context()));
}

// Since the frame updates the values we are safe to access them any time. They won't change until a new frame is awaited, and awaitng frames is happening on the same thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ namespace ice::ecs
ice::ecs::detail::ArchetypeInstanceInfo const* arch = nullptr;
ice::ecs::detail::DataBlock const* block = nullptr;

ice::u32 const arch_count = ice::count(query.archetype_instances);
ice::u32 const arch_count = query.archetype_instances.size().u32();
for (; arch_idx < arch_count; ++arch_idx)
{
arch = query.archetype_instances[arch_idx];
Expand Down Expand Up @@ -552,7 +552,7 @@ namespace ice::ecs

void* helper_pointer_array[component_count]{ nullptr };

ice::u32 const arch_count = ice::count(query.archetype_instances);
ice::u32 const arch_count = query.archetype_instances.size().u32();
for (ice::u32 arch_idx = 0; arch_idx < arch_count; ++arch_idx)
{
ice::ecs::detail::ArchetypeInstanceInfo const* arch = query.archetype_instances[arch_idx];
Expand Down
6 changes: 4 additions & 2 deletions source/code/iceshard/engine/public/ice/gfx/gfx_runner.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ namespace ice::gfx
{
virtual ~GfxRunner() noexcept = default;

virtual bool has_rendergraph() const noexcept = 0;

//! \brief Sets a rendergraph to used for execution each frame.
virtual auto update_rendergraph(
virtual void update_rendergraph(
ice::UniquePtr<ice::gfx::GfxGraphRuntime> rendergraph
) noexcept -> ice::Task<> = 0;
) noexcept = 0;

virtual auto update_data(
ice::EngineFrame& frame,
Expand Down
17 changes: 10 additions & 7 deletions source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ namespace ice::gfx
_context->device().destroy_fence(_present_fence);
}

auto IceshardGfxRunner::update_rendergraph(
void IceshardGfxRunner::update_rendergraph(
ice::UniquePtr<ice::gfx::GfxGraphRuntime> rendergraph
) noexcept -> ice::Task<>
) noexcept
{
co_await _scheduler;

if (_rendergraph != nullptr)
{
ice::gfx::GfxFrameStages gpu_stages{
Expand All @@ -135,8 +133,8 @@ namespace ice::gfx
}
}
}
_rendergraph = ice::move(rendergraph);

_scheduled_rendergraph = ice::move(rendergraph);
}

auto IceshardGfxRunner::update_data(
Expand Down Expand Up @@ -214,7 +212,7 @@ namespace ice::gfx
}

// Check if we have a scheduled render graph and if we can replace
if (_scheduled_rendergraph != nullptr && _rendergraph->ready())
if (_scheduled_rendergraph != nullptr && (_rendergraph == nullptr || _rendergraph->ready()))
{
_rendergraph = ice::move(_scheduled_rendergraph);
}
Expand All @@ -227,6 +225,11 @@ namespace ice::gfx
ice::execute_tasks(tasks);
}

if (_rendergraph->ready() == false)
{
co_return;
}

if (_queue_transfer.not_empty() || _gfx_tasks.running_tasks() > 0)
{
IPT_ZONE_SCOPED_NAMED("gfx_await_tasks");
Expand Down
6 changes: 4 additions & 2 deletions source/code/iceshard/iceshard/private/iceshard_gfx_runner.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ namespace ice::gfx
) noexcept;
~IceshardGfxRunner() noexcept override;

auto update_rendergraph(
bool has_rendergraph() const noexcept override { return _rendergraph != nullptr; }

void update_rendergraph(
ice::UniquePtr<ice::gfx::GfxGraphRuntime> rendergraph
) noexcept -> ice::Task<> override;
) noexcept override;

auto update_data(
ice::EngineFrame& frame,
Expand Down
Loading