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
3 changes: 3 additions & 0 deletions source/code/core/core/public/ice/concept/pimpl_type.hxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// Copyright 2025 - 2025, Dandielo <[email protected]>
/// SPDX-License-Identifier: MIT

#pragma once
#include <ice/concept/enum_flags.hxx>

Expand Down
20 changes: 20 additions & 0 deletions source/code/core/memsys/public/ice/mem_allocator_utils.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// Copyright 2025 - 2025, Dandielo <[email protected]>
/// SPDX-License-Identifier: MIT

#pragma once
#include <ice/mem_allocator.hxx>

namespace ice
{

inline auto data_copy(ice::Allocator& alloc, ice::Data data) noexcept -> ice::Memory
{
ice::Memory const result = alloc.allocate({ data.size, data.alignment });
if (result.location != nullptr)
{
ice::memcpy(result, data);
}
return result;
}

} // namespace ice
3 changes: 3 additions & 0 deletions source/code/core/utils/private/detail/refcounted.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// Copyright 2025 - 2025, Dandielo <[email protected]>
/// SPDX-License-Identifier: MIT

#include <ice/detail/refcounted.hxx>
#include <ice/assert.hxx>

Expand Down
3 changes: 3 additions & 0 deletions source/code/core/utils/public/ice/detail/refcounted.hxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// Copyright 2025 - 2025, Dandielo <[email protected]>
/// SPDX-License-Identifier: MIT

#pragma once
#include <ice/base.hxx>
#include <ice/mem_allocator.hxx>
Expand Down
3 changes: 3 additions & 0 deletions source/code/core/utils/public/ice/ptr.hxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// Copyright 2025 - 2025, Dandielo <[email protected]>
/// SPDX-License-Identifier: MIT

#pragma once
#include <ice/detail/refcounted.hxx>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ void TestGame::on_resume(ice::Engine& engine) noexcept
ice::StringID traits[]{
"test"_sid,
"test2"_sid,
ice::devui_trait_name(),
ice::TraitID_GfxShaderStorage,
ice::devui_trait_name()
ice::TraitID_GfxImageStorage,
};

engine.worlds().create_world({ .name = "world"_sid, .traits = traits });
Expand Down
3 changes: 2 additions & 1 deletion source/code/example/webasm/private/example_webasm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@ void TestGame::on_resume(ice::Engine& engine) noexcept
ice::StringID traits[]{
"act"_sid,
"test2"_sid,
ice::TraitID_GfxShaderStorage,
ice::devui_trait_name(),
ice::TraitID_GfxShaderStorage,
ice::TraitID_GfxImageStorage,
};
ice::StringID traits2[]{
"test"_sid,
Expand Down
1 change: 1 addition & 0 deletions source/code/example/webasm/webasm.bff
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'imgui_module'
'shader_tools'
'webgpu_renderer'
'iceshard_pipelines'
}
]
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// Copyright 2025 - 2025, Dandielo <[email protected]>
/// SPDX-License-Identifier: MIT

#pragma once
#include <ice/ecs/ecs_types.hxx>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#include <ice/gfx/gfx_context.hxx>
#include <ice/render/render_buffer.hxx>
#include <ice/render/render_command_buffer.hxx>
#include <ice/render/render_pipeline.hxx>
#include <ice/render/render_device.hxx>
#include <ice/render/render_pass.hxx>
#include <ice/resource_tracker.hxx>
#include <ice/resource.hxx>
#include <ice/shard_container.hxx>
Expand All @@ -36,10 +38,11 @@ namespace ice::gfx
: ice::Trait{ ctx }
, _loaded_images{ alloc }
{
_context.bind<&Trait_GfxImageStorage::gfx_update>(ice::gfx::ShardID_RenderFrameUpdate);
_context.bind<&Trait_GfxImageStorage::gfx_update, Render>(ice::gfx::ShardID_RenderFrameUpdate);
_context.bind<&Trait_GfxImageStorage::gfx_shutdown, Render>(ice::gfx::ShardID_GfxShutdown);
}

auto Trait_GfxImageStorage::on_asset_released(ice::Asset const &asset) noexcept -> ice::Task<>
auto Trait_GfxImageStorage::on_asset_released(ice::Asset const& asset) noexcept -> ice::Task<>
{
GfxImageEntry* entry = ice::hashmap::try_get(_loaded_images, ice::hash(asset.name()));
ICE_ASSERT_CORE(entry != nullptr);
Expand All @@ -59,8 +62,8 @@ namespace ice::gfx
ice::AssetState const state = request->state();
ICE_ASSERT_CORE(state == AssetState::Loaded); // The image needs to be loaded.

ice::u64 const image_hash = ice::hash(request->asset_name());
GfxImageEntry* entry = ice::hashmap::try_get(_loaded_images, image_hash);
ice::StringID const image_hash = request->asset_name();
GfxImageEntry* entry = ice::hashmap::try_get(_loaded_images, ice::hash(image_hash));
ICE_ASSERT_CORE(entry == nullptr || entry->released);

using namespace ice::render;
Expand All @@ -76,6 +79,7 @@ namespace ice::gfx
if (metadata_data.location == nullptr)
{
request->resolve({ .result = ice::AssetRequestResult::Error });
request = assets.aquire_request(ice::render::AssetCategory_Texture2D, AssetState::Runtime);
continue;
}

Expand All @@ -90,7 +94,7 @@ namespace ice::gfx
valid_data &= ice::config::get(meta, "texture.size.y", size.y);

[[maybe_unused]]
ice::Data const* d = reinterpret_cast<ice::Data const*>(request->data().location);
ice::Data const texture_data = request->data();

// Creates the image object
ImageInfo image_info{
Expand All @@ -100,54 +104,106 @@ namespace ice::gfx
.width = (ice::u32) size.x,
.height = (ice::u32) size.y,
};
Image image = device.create_image(image_info, {});
Image image = device.create_image(image_info, texture_data);
if (image == Image::Invalid)
{
request->resolve({ .result = AssetRequestResult::Error });
co_return;
}

ice::render::Buffer buffer = device.create_buffer(BufferType::Transfer, size.x * size.y);
ice::render::Buffer transfer_buffer = device.create_buffer(BufferType::Transfer, ice::u32(texture_data.size.value));
BufferUpdateInfo const buffer_updates[]{
BufferUpdateInfo{
.buffer = buffer,
.data = *d,
.buffer = transfer_buffer,
.data = texture_data,
.offset = 0
}
};

device.update_buffers(buffer_updates);

// RenderCommands& api = device.get_commands();
// CommandBuffer const cmds = co_await params.frame_transfer;
RenderCommands& api = device.get_commands();
CommandBuffer const cmds = co_await params.stages.frame_transfer;

// api.update_texture_v2(
// cmds,
// image,
// buffer,
// ice::vec2u{ size }
// );
ImageBarrier barriers[4]{ };

// co_await params.frame_end;
for (ice::u32 idx = 0; idx < 1; ++idx)
{
barriers[idx].image = image;
barriers[idx].source_layout = ImageLayout::Undefined;
barriers[idx].destination_layout = ImageLayout::TransferDstOptimal;
barriers[idx].source_access = AccessFlags::None;
barriers[idx].destination_access = AccessFlags::TransferWrite;
}

api.pipeline_image_barrier(
cmds,
PipelineStage::TopOfPipe,
PipelineStage::Transfer,
{ barriers, 1 }
);

api.update_texture_v2(
cmds,
image,
transfer_buffer,
ice::vec2u{ size }
);

for (ice::u32 idx = 0; idx < 1; ++idx)
{
barriers[idx].image = image;
barriers[idx].source_layout = ImageLayout::TransferDstOptimal;
barriers[idx].destination_layout = ImageLayout::ShaderReadOnly;
barriers[idx].source_access = AccessFlags::TransferWrite;
barriers[idx].destination_access = AccessFlags::ShaderRead;
}

api.pipeline_image_barrier(
cmds,
PipelineStage::Transfer,
PipelineStage::FramentShader,
{ barriers, 1 }
);

co_await params.stages.frame_end;

device.destroy_buffer(transfer_buffer);

// device.destroy_buffer(data_buffer);
ICE_LOG(LogSeverity::Info, LogTag::Game, "TextureStorage - Loaded image: {}", request->asset_name());

// ICE_LOG(LogSeverity::Info, LogTag::Game, "ShaderStorage - Loaded image: {}", request->asset_name());
// Allocates a handle for it... (TODO: Rework?)
ice::Memory const result = request->allocate(ice::size_of<ice::render::Image>);
*reinterpret_cast<Image*>(result.location) = image;

// // Allocates a handle for it... (TODO: Rework?)
// ice::Memory const result = request->allocate(ice::size_of<ice::render::Image>);
// *reinterpret_cast<Image*>(result.location) = image;
// Reslove the request (will resume all awaiting tasks)
ice::Asset asset = request->resolve({ .resolver = this, .result = AssetRequestResult::Success, .memory = result });
// send("iceshard:images-internal:loaded"_shardid, asset);

// // Save the image handle
// ice::hashmap::set(_loaded_images, image_hash, { .image = image });
// Save the image handle
ice::hashmap::set(_loaded_images, ice::hash(image_hash), { .asset = ice::move(asset), .image = image});

// // Reslove the request (will resume all awaiting tasks)
// request->resolve({ .resolver = this, .result = AssetRequestResult::Success, .memory = result });

// // Get the next queued request
// request = update.assets.aquire_request(ice::render::AssetCategory_Texture2D, AssetState::Runtime);
// Get the next queued request
request = assets.aquire_request(ice::render::AssetCategory_Texture2D, AssetState::Runtime);
}

co_return;
}

auto Trait_GfxImageStorage::gfx_shutdown(
ice::render::RenderDevice& device
) noexcept -> ice::Task<>
{
for (ice::gfx::GfxImageEntry& entry : ice::hashmap::values(_loaded_images))
{
device.destroy_image(entry.image);
entry.asset.release();
}

ice::hashmap::clear(_loaded_images);
co_return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace ice::gfx

struct GfxImageEntry
{
ice::Asset asset;
ice::render::Image image;
bool released = false;
};
Expand All @@ -35,6 +36,10 @@ namespace ice::gfx
ice::AssetStorage& assets
) noexcept -> ice::Task<>;

auto gfx_shutdown(
ice::render::RenderDevice& device
) noexcept -> ice::Task<>;

private:
ice::HashMap<GfxImageEntry> _loaded_images;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace ice::gfx
}
}

auto Trait_GfxShaderStorage::on_asset_released(ice::Asset const &asset) noexcept -> ice::Task<>
auto Trait_GfxShaderStorage::on_asset_released(ice::Asset const& asset) noexcept -> ice::Task<>
{
GfxShaderEntry* entry = ice::hashmap::try_get(_loaded_shaders, ice::hash(asset.name()));
ICE_ASSERT_CORE(entry != nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ namespace ice::gfx
ice::gfx::RenderFrameUpdate const& update,
ice::AssetStorage& assets
) noexcept -> ice::Task<>;
auto gfx_shutdown(ice::render::RenderDevice& device) noexcept -> ice::Task<>;

auto gfx_shutdown(
ice::render::RenderDevice& device
) noexcept -> ice::Task<>;

private:
ice::HashMap<GfxShaderEntry> _loaded_shaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace ice
{
IceshardWorldContext const& ctx = _context;

static auto make_handler_list = [this](ice::String handler_type, auto const& hashmap) noexcept
auto make_handler_list = [this](ice::String handler_type, auto const& hashmap) noexcept
{
ImGui::TextT("{} handlers (count: {})", handler_type, ice::hashmap::count(hashmap));
if (ice::hashmap::any(hashmap))
Expand Down
33 changes: 25 additions & 8 deletions source/code/modules/iceshard_pipelines/iceshard_pipelines.bff
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@

.BaseDir = '$WorkspaceCodeDir$/modules/iceshard_pipelines'

.Requires = {
'Windows'
}

.Private =
[
.Modules = {
'arctic'
'assimp'
'freetype'
'msdfgen'
'msdf_atlas_gen'
'rapidxml_ns'
}
.Uses = {
Expand All @@ -32,5 +24,30 @@
'engine'
}
]

.Rule_Monolythic =
[
.Name = 'Monolythic'
.Requires = { 'Monolythic' }
.Kind = .Kind_ObjectList
]
.Rule_Win32Plugins =
[
.Name = 'EditorPlugins'
.Requires = { 'Windows' }
.Private =
[
.Modules = {
'assimp'
'freetype'
'msdfgen'
'msdf_atlas_gen'
}
]
]
.Rules = {
.Rule_Monolythic
.Rule_Win32Plugins
}
]
.Projects + .Project
4 changes: 4 additions & 0 deletions source/code/modules/iceshard_pipelines/private/asset_font.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <ice/font_utils.hxx>
#include <ice/task_utils.hxx>

#if ISP_WINDOWS

ISC_WARNING_PUSH
ISCW_DECLARATION_HIDES_CLASS_MEMBER(ISCW_OP_DISABLE)
ISCW_UNREFERENCED_INTERNAL_FUNCTION_REMOVED(ISCW_OP_DISABLE)
Expand Down Expand Up @@ -246,3 +248,5 @@ namespace ice
}

} // namespace ice

#endif
Loading