Minor TODOs completed

- Rename states -> regions
- Threads unregistering from Logger
- Remove unnecessary references for primitive arguments in functions
- Marking classes as final for optimization
- Remove typo in Materials implementation file name
- Move some modules to partitions
This commit is contained in:
legatt 2026-02-11 03:28:33 +03:00
parent 5837def95c
commit 0f26b7423d
23 changed files with 53 additions and 56 deletions

View File

@ -1,5 +1,5 @@
struct Province {
uint stateId;
uint regionId;
uint color;
};
layout(std430, binding=0) buffer Data {

View File

@ -7,7 +7,7 @@ module;
export module AssetData;
import GameData;
import MapView;
import views;
export namespace ee_assets
{

View File

@ -8,8 +8,8 @@ module;
#include <cstddef>
export module Render;
import worker;
import MapView;
import utils;
import views;
import AssetData;
export namespace ee_engine

View File

@ -5,8 +5,7 @@ module;
#include <unordered_map>
#include <cstdint>
//TODO: module Views
export module MapView;
export module views:MapView;
export namespace ee_engine
{

View File

@ -0,0 +1,2 @@
export module views;
export import :MapView;

View File

@ -5,8 +5,7 @@ module;
#include <cstddef>
module AssetData;
import allocator;
import buffers;
import utils;
/*
@ -40,10 +39,10 @@ ee_assets::AssetMapMesh::AssetMapMesh(std::uint8_t* &source, const std::size_t s
std::size_t leftoverSize = sourceSize;
source = nullptr;
std::uint32_t statesCount = 0;
ee_utils::readNext(&statesCount, pointer, leftoverSize, sizeof(std::uint32_t));
std::uint32_t regionsCount = 0;
ee_utils::readNext(&regionsCount, pointer, leftoverSize, sizeof(std::uint32_t));
for (std::uint32_t state = 0; state < statesCount; state++)
for (std::uint32_t region = 0; region < regionsCount; region++)
{
std::uint32_t id = 0;
glm::u8vec3 color {};

View File

@ -17,8 +17,7 @@ module;
export module AssetManager;
export import AssetData;
import allocator;
import worker;
import utils;
import FileSystem;
export
@ -153,7 +152,7 @@ export
return *reinterpret_cast<AssetHandle*>(command.out->load());
}
AssetHandle& Find(const std::uint32_t &id)
AssetHandle& Find(const std::uint32_t id)
{
std::atomic<void*> result;
AssetStreamCommand command;
@ -173,7 +172,7 @@ export
}
// Returned resource reference should not be stored
template <ee_assets::Asset T> T& FindOnce(const std::uint32_t &id)
template <ee_assets::Asset T> T& FindOnce(const std::uint32_t id)
{
return Get<T>(Find(id));
}
@ -294,9 +293,6 @@ export
mapMeshesStorage.clear();
shadersStorage.clear();
materialsStorage.clear();
LOG(INFO, "Asset Streaming is released");
isRunning.store(false);
}
private:

View File

@ -3,7 +3,7 @@ module;
#include <cstdint>
export module Client;
import worker;
import utils;
import GameData;
import DataChannel;
import AssetManager;

View File

@ -8,8 +8,7 @@ export module Engine;
export import AssetManager;
export import Client;
import allocator;
import worker;
import utils;
export
{

View File

@ -56,7 +56,7 @@ export
std::vector<std::size_t> freeFileSlots;
};
class NativeFileSystem : public IFileSystem {
class NativeFileSystem final : public IFileSystem {
public:
FileHandle &Open(const std::filesystem::path &path, const std::uint32_t flags) override;

View File

@ -6,7 +6,7 @@ export module GLFWInput;
import Input;
export {
class GLFWInput : public ee_engine::IInput
class GLFWInput final : public ee_engine::IInput
{
public:
GLFWInput(ee_engine::InputHandlers handlers);

View File

@ -6,8 +6,8 @@ module;
#include <stdexcept>
module Client;
import allocator;
import MapView;
import utils;
import views;
import Engine;
Client::Client() : ee_utils::ThreadedWorker<ClientCommand, ClientCommand::COMPLETED>(L"Client")

View File

@ -6,7 +6,7 @@ module;
#include <cstddef>
module FileSystem;
import allocator;
import utils;
IFileSystem::~IFileSystem()

View File

@ -1,4 +1,4 @@
import allocator;
import utils;
import Engine;
import Actions;
@ -11,7 +11,6 @@ import GLFWInput;
#include <vector>
IP7_Trace* Logger::trace;
int main(int argc, char **argv)
{
// Setup P7 logger
@ -53,8 +52,8 @@ int main(int argc, char **argv)
// Setup renderer TODO: builder
Engine::renderer = reinterpret_cast<ee_engine::IRenderer*>(Allocate<ee_magnum::MagnumRenderer>(window));
ee_assets::AssetMapMesh &states = Engine::assetManager->FindOnce<ee_assets::AssetMapMesh>("assets/map/ET.map");
Engine::renderer->RegisterMapMesh(&states.content);
ee_assets::AssetMapMesh &regions = Engine::assetManager->FindOnce<ee_assets::AssetMapMesh>("assets/map/ET.map");
Engine::renderer->RegisterMapMesh(&regions.content);
//TODO: ShaderRefs builder from set of AssetMaterial
ee_assets::AssetMaterial &provincesMaterial =
@ -98,7 +97,6 @@ int main(int argc, char **argv)
// Free memory
LOG(INFO, "Exit...");
Engine::Shutdown();
//TODO: check Unregister in other threads and make threaded module base class
Logger::trace->Unregister_Thread(0);
Logger::trace->Release();
p7client->Release();
@ -106,9 +104,5 @@ int main(int argc, char **argv)
return 0;
}
// TODO: Rename states to regions in old sources
// TODO: Remove unneccesary address providing like (const type &arg) for small primitives
// TODO: Use CRTP where possible in classes with virtual/override
// TODO: Use final in classes with override
// TODO: Implementations of API as partition modules
// TODO: Leaks detection

View File

@ -9,7 +9,7 @@ module;
#include <string>
#include <cstdint>
export module Materials;
export module MagnumRender:Materials;
using namespace Magnum;
@ -29,7 +29,7 @@ export namespace ee_magnum
explicit BaseMaterial(const std::string &vertSrc, const std::string &fragSrc);
};
class ProvinceMaterial : public BaseMaterial
class ProvinceMaterial final : public BaseMaterial
{
public:
inline static constexpr std::int32_t PROVINCES_DATA_BINDING = 0;
@ -37,6 +37,6 @@ export namespace ee_magnum
explicit ProvinceMaterial(const std::string &vertSrc, const std::string &fragSrc);
void setId(const std::uint32_t &id);
void setId(const std::uint32_t id);
};
}

View File

@ -9,8 +9,8 @@ module;
#include <cstddef>
export module MagnumRender;
import MapView;
import Materials;
import :Materials;
import views;
import Render;
using namespace Magnum;

View File

@ -11,7 +11,8 @@ module;
#include <string>
#include <cstdint>
module Materials;
module MagnumRender;
import :Materials;
ee_magnum::BaseMaterial::BaseMaterial(const std::string &vertSrc, const std::string &fragSrc)
{
@ -47,7 +48,7 @@ ee_magnum::ProvinceMaterial::ProvinceMaterial(const std::string &vertSrc, const
}
void ee_magnum::ProvinceMaterial::setId(const uint32_t &id)
void ee_magnum::ProvinceMaterial::setId(const uint32_t id)
{
setUniform(PROVINCES_ID_BINDING, id);
}

View File

@ -19,7 +19,7 @@ module;
#include <string>
module MagnumRender;
import allocator;
import utils;
using namespace Math::Literals;
@ -96,18 +96,17 @@ void ee_magnum::MagnumRenderer::LoadProvinces()
{
for (ee_engine::MapMesh::Province &province: provs)
{
GL::Mesh stateMesh;
GL::Mesh regionMesh;
stateMesh.setPrimitive(GL::MeshPrimitive::Triangles)
regionMesh.setPrimitive(GL::MeshPrimitive::Triangles)
.setCount(static_cast<Magnum::Int>(province.indices.size()))
.addVertexBuffer(GL::Buffer{province.vertices}, 0, GL::Attribute<0, Magnum::Vector2>{})
.setIndexBuffer(GL::Buffer{province.indices}, 0, GL::MeshIndexType::UnsignedShort);
provinceMeshes.push_back(std::move(stateMesh));
provinceMeshes.push_back(std::move(regionMesh));
ee_engine::ProvinceSSBO data {
.regionId = region,
//.color = region
.color = 0xFFFFFF
};

View File

@ -2,7 +2,7 @@ module;
#include <utility>
export module allocator;
export module utils:allocator;
export {
template<typename T, typename... Args> T* Allocate(Args&&... args)

View File

@ -3,10 +3,10 @@ module;
#include <cstdint>
#include <cstddef>
export module buffers;
export module utils:buffers;
export namespace ee_utils
{
bool readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLeftoverSize, const std::size_t &readSize);
bool writeNext(std::uint8_t* &dstPointer, void* src, std::size_t &dstLeftoverSize, const std::size_t &writeSize);
bool readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLeftoverSize, const std::size_t readSize);
bool writeNext(std::uint8_t* &dstPointer, void* src, std::size_t &dstLeftoverSize, const std::size_t writeSize);
}

6
utils/modules/utils.cppm Normal file
View File

@ -0,0 +1,6 @@
export module utils;
export import :allocator;
export import :worker;
export import :buffers;
export namespace ee_utils {}

View File

@ -11,7 +11,7 @@ module;
#include <type_traits>
#include <concepts>
export module worker;
export module utils:worker;
export namespace ee_utils
{
@ -144,7 +144,8 @@ export namespace ee_utils
void ReleaseStop()
{
Release();
LOG(INFO, "Client is released");
LOG(INFO, "Thread is released");
Logger::trace->Unregister_Thread(0);
isRunning.store(false);
}
};

View File

@ -4,9 +4,10 @@ module;
#include <cstddef>
#include <cstring>
module buffers;
module utils;
import :buffers;
bool ee_utils::readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLeftoverSize, const std::size_t &readSize)
bool ee_utils::readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLeftoverSize, const std::size_t readSize)
{
if (srcLeftoverSize >= readSize)
{
@ -20,7 +21,7 @@ bool ee_utils::readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLe
return false;
}
bool ee_utils::writeNext(std::uint8_t* &dstPointer, void* src, std::size_t &dstLeftoverSize, const std::size_t &writeSize)
bool ee_utils::writeNext(std::uint8_t* &dstPointer, void* src, std::size_t &dstLeftoverSize, const std::size_t writeSize)
{
if (dstLeftoverSize >= writeSize)
{