Skip to content

Commit

Permalink
Fixed: Amalgamation issues
Browse files Browse the repository at this point in the history
Tweaked: Minor cleanup
  • Loading branch information
richardbiely committed Oct 12, 2024
1 parent c78ea9f commit 45aaa0d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 42 deletions.
10 changes: 5 additions & 5 deletions include/gaia/ecs/chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ namespace gaia {

//! Updates the version numbers for this chunk.
void update_versions() {
update_version(m_header.worldVersion);
::gaia::ecs::update_version(m_header.worldVersion);
update_world_version();
}

Expand Down Expand Up @@ -567,7 +567,7 @@ namespace gaia {
++m_header.countEnabled;
entity_view_mut()[row] = entity;

update_version(m_header.worldVersion);
::gaia::ecs::update_version(m_header.worldVersion);
update_world_version();

return row;
Expand Down Expand Up @@ -1056,7 +1056,7 @@ namespace gaia {
"Set providing a row can only be used with generic components");

// Update the world version
update_version(m_header.worldVersion);
::gaia::ecs::update_version(m_header.worldVersion);

GAIA_ASSERT(row < m_header.capacity);
return view_mut<T>()[row];
Expand All @@ -1077,7 +1077,7 @@ namespace gaia {
GAIA_ASSERT(type.kind() == entity_kind_v<T>);

// Update the world version
update_version(m_header.worldVersion);
::gaia::ecs::update_version(m_header.worldVersion);

GAIA_ASSERT(row < m_header.capacity);

Expand Down Expand Up @@ -1291,7 +1291,7 @@ namespace gaia {
//! Returns true if the provided version is newer than the one stored internally
GAIA_NODISCARD bool changed(uint32_t version, uint32_t compIdx) const {
auto versions = comp_version_view();
return version_changed(versions[compIdx], version);
return ::gaia::ecs::version_changed(versions[compIdx], version);
}

//! Update the version of a component at the index \param compIdx
Expand Down
37 changes: 17 additions & 20 deletions include/gaia/ecs/chunk_allocator.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#pragma once
#include "../config/config.h"

#include <cinttypes>
#include <cstdint>

#if GAIA_ECS_CHUNK_ALLOCATOR
#include <cinttypes>

#include "../cnt/darray.h"
#include "../cnt/sarray.h"
#include "../cnt/sarray_ext.h"
#include "../config/logging.h"
#include "../config/profiler.h"
#include "../core/bit_utils.h"
#include "../core/dyn_singleton.h"
#include "../core/span.h"
#include "../core/utility.h"
#include "../mem/mem_alloc.h"
#include "common.h"
#endif
#include "../cnt/darray.h"
#include "../cnt/sarray.h"
#include "../config/logging.h"
#include "../core/bit_utils.h"
#include "../core/dyn_singleton.h"
#include "../core/utility.h"
#include "../mem/mem_alloc.h"
#include "common.h"

namespace gaia {
namespace ecs {
Expand Down Expand Up @@ -59,7 +53,7 @@ namespace gaia {

//! Allocator for ECS Chunks. Memory is organized in pages of chunks.
class ChunkAllocatorImpl {
friend gaia::ecs::ChunkAllocator;
friend ::gaia::ecs::ChunkAllocator;

struct MemoryPage {
static constexpr uint16_t NBlocks = 62;
Expand Down Expand Up @@ -371,17 +365,20 @@ namespace gaia {
}

private:
static constexpr const char* s_strChunkAlloc_Chunk = "Chunk";
static constexpr const char* s_strChunkAlloc_MemPage = "MemoryPage";

static MemoryPage* alloc_page(uint8_t sizeType) {
const uint32_t size = mem_block_size(sizeType) * MemoryPage::NBlocks;
auto* pPageData = mem::AllocHelper::alloc_alig<uint8_t>("Chunk", 16U, size);
auto* pMemoryPage = mem::AllocHelper::alloc<MemoryPage>("MemoryPage");
auto* pPageData = mem::AllocHelper::alloc_alig<uint8_t>(s_strChunkAlloc_Chunk, 16U, size);
auto* pMemoryPage = mem::AllocHelper::alloc<MemoryPage>(s_strChunkAlloc_MemPage);
return new (pMemoryPage) MemoryPage(pPageData, sizeType);
}

static void free_page(MemoryPage* pMemoryPage) {
mem::AllocHelper::free_alig("Chunk", pMemoryPage->m_data);
mem::AllocHelper::free_alig(s_strChunkAlloc_Chunk, pMemoryPage->m_data);
pMemoryPage->~MemoryPage();
mem::AllocHelper::free("MemoryPage", pMemoryPage);
mem::AllocHelper::free(s_strChunkAlloc_MemPage, pMemoryPage);
}

void done() {
Expand Down
2 changes: 1 addition & 1 deletion include/gaia/ecs/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ namespace gaia {
template <typename TIter, typename Func>
void run_query_on_chunks(QueryInfo& queryInfo, Func func) {
// Update the world version
update_version(*m_worldVersion);
::gaia::ecs::update_version(*m_worldVersion);

const bool hasFilters = queryInfo.has_filters();
if (hasFilters)
Expand Down
1 change: 1 addition & 0 deletions make_single_header.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ echo off

set PATH_TO_AMALGAMATE_DIR="%1"
set PATH_TO_AMALGAMATE=%PATH_TO_AMALGAMATE_DIR%\\amalgamate
del single_include/gaia.h
%PATH_TO_AMALGAMATE% -i include -w "*.cpp;*.h;*.hpp;*.inl" include/gaia.h single_include/gaia.h
1 change: 1 addition & 0 deletions make_single_header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

PATH_TO_AMALGAMATE_DIR="${@:1}"
PATH_TO_AMALGAMATE=${PATH_TO_AMALGAMATE_DIR}/amalgamate
rm -f ./single_include/gaia.h
${PATH_TO_AMALGAMATE} -i ./include -w "*.cpp;*.h;*.hpp;*.inl" ./include/gaia.h ./single_include/gaia.h
31 changes: 15 additions & 16 deletions single_include/gaia.h
Original file line number Diff line number Diff line change
Expand Up @@ -16240,11 +16240,9 @@ namespace gaia {
/*** Start of inlined file: chunk_allocator.h ***/
#pragma once

#include <cinttypes>
#include <cstdint>

#if GAIA_ECS_CHUNK_ALLOCATOR
#include <cinttypes>


/*** Start of inlined file: dyn_singleton.h ***/
#pragma once
Expand Down Expand Up @@ -16321,8 +16319,6 @@ namespace gaia {

/*** End of inlined file: common.h ***/

#endif

namespace gaia {
namespace ecs {
//! Size of one allocated block of memory
Expand Down Expand Up @@ -16363,7 +16359,7 @@ namespace gaia {

//! Allocator for ECS Chunks. Memory is organized in pages of chunks.
class ChunkAllocatorImpl {
friend gaia::ecs::ChunkAllocator;
friend ::gaia::ecs::ChunkAllocator;

struct MemoryPage {
static constexpr uint16_t NBlocks = 62;
Expand Down Expand Up @@ -16675,17 +16671,20 @@ namespace gaia {
}

private:
static constexpr const char* s_strChunkAlloc_Chunk = "Chunk";
static constexpr const char* s_strChunkAlloc_MemPage = "MemoryPage";

static MemoryPage* alloc_page(uint8_t sizeType) {
const uint32_t size = mem_block_size(sizeType) * MemoryPage::NBlocks;
auto* pPageData = mem::AllocHelper::alloc_alig<uint8_t>("Chunk", 16U, size);
auto* pMemoryPage = mem::AllocHelper::alloc<MemoryPage>("MemoryPage");
auto* pPageData = mem::AllocHelper::alloc_alig<uint8_t>(s_strChunkAlloc_Chunk, 16U, size);
auto* pMemoryPage = mem::AllocHelper::alloc<MemoryPage>(s_strChunkAlloc_MemPage);
return new (pMemoryPage) MemoryPage(pPageData, sizeType);
}

static void free_page(MemoryPage* pMemoryPage) {
mem::AllocHelper::free_alig("Chunk", pMemoryPage->m_data);
mem::AllocHelper::free_alig(s_strChunkAlloc_Chunk, pMemoryPage->m_data);
pMemoryPage->~MemoryPage();
mem::AllocHelper::free("MemoryPage", pMemoryPage);
mem::AllocHelper::free(s_strChunkAlloc_MemPage, pMemoryPage);
}

void done() {
Expand Down Expand Up @@ -18034,7 +18033,7 @@ namespace gaia {

//! Updates the version numbers for this chunk.
void update_versions() {
update_version(m_header.worldVersion);
::gaia::ecs::update_version(m_header.worldVersion);
update_world_version();
}

Expand Down Expand Up @@ -18215,7 +18214,7 @@ namespace gaia {
++m_header.countEnabled;
entity_view_mut()[row] = entity;

update_version(m_header.worldVersion);
::gaia::ecs::update_version(m_header.worldVersion);
update_world_version();

return row;
Expand Down Expand Up @@ -18704,7 +18703,7 @@ namespace gaia {
"Set providing a row can only be used with generic components");

// Update the world version
update_version(m_header.worldVersion);
::gaia::ecs::update_version(m_header.worldVersion);

GAIA_ASSERT(row < m_header.capacity);
return view_mut<T>()[row];
Expand All @@ -18725,7 +18724,7 @@ namespace gaia {
GAIA_ASSERT(type.kind() == entity_kind_v<T>);

// Update the world version
update_version(m_header.worldVersion);
::gaia::ecs::update_version(m_header.worldVersion);

GAIA_ASSERT(row < m_header.capacity);

Expand Down Expand Up @@ -18939,7 +18938,7 @@ namespace gaia {
//! Returns true if the provided version is newer than the one stored internally
GAIA_NODISCARD bool changed(uint32_t version, uint32_t compIdx) const {
auto versions = comp_version_view();
return version_changed(versions[compIdx], version);
return ::gaia::ecs::version_changed(versions[compIdx], version);
}

//! Update the version of a component at the index \param compIdx
Expand Down Expand Up @@ -23359,7 +23358,7 @@ namespace gaia {
template <typename TIter, typename Func>
void run_query_on_chunks(QueryInfo& queryInfo, Func func) {
// Update the world version
update_version(*m_worldVersion);
::gaia::ecs::update_version(*m_worldVersion);

const bool hasFilters = queryInfo.has_filters();
if (hasFilters)
Expand Down

0 comments on commit 45aaa0d

Please sign in to comment.