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:
parent
5837def95c
commit
0f26b7423d
@ -1,5 +1,5 @@
|
|||||||
struct Province {
|
struct Province {
|
||||||
uint stateId;
|
uint regionId;
|
||||||
uint color;
|
uint color;
|
||||||
};
|
};
|
||||||
layout(std430, binding=0) buffer Data {
|
layout(std430, binding=0) buffer Data {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ module;
|
|||||||
|
|
||||||
export module AssetData;
|
export module AssetData;
|
||||||
import GameData;
|
import GameData;
|
||||||
import MapView;
|
import views;
|
||||||
|
|
||||||
export namespace ee_assets
|
export namespace ee_assets
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,8 +8,8 @@ module;
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
export module Render;
|
export module Render;
|
||||||
import worker;
|
import utils;
|
||||||
import MapView;
|
import views;
|
||||||
import AssetData;
|
import AssetData;
|
||||||
|
|
||||||
export namespace ee_engine
|
export namespace ee_engine
|
||||||
|
|||||||
@ -5,8 +5,7 @@ module;
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
//TODO: module Views
|
export module views:MapView;
|
||||||
export module MapView;
|
|
||||||
|
|
||||||
export namespace ee_engine
|
export namespace ee_engine
|
||||||
{
|
{
|
||||||
|
|||||||
2
engine-api/modules/views/views.cppm
Normal file
2
engine-api/modules/views/views.cppm
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export module views;
|
||||||
|
export import :MapView;
|
||||||
@ -5,8 +5,7 @@ module;
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
module AssetData;
|
module AssetData;
|
||||||
import allocator;
|
import utils;
|
||||||
import buffers;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -40,10 +39,10 @@ ee_assets::AssetMapMesh::AssetMapMesh(std::uint8_t* &source, const std::size_t s
|
|||||||
std::size_t leftoverSize = sourceSize;
|
std::size_t leftoverSize = sourceSize;
|
||||||
source = nullptr;
|
source = nullptr;
|
||||||
|
|
||||||
std::uint32_t statesCount = 0;
|
std::uint32_t regionsCount = 0;
|
||||||
ee_utils::readNext(&statesCount, pointer, leftoverSize, sizeof(std::uint32_t));
|
ee_utils::readNext(®ionsCount, 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;
|
std::uint32_t id = 0;
|
||||||
glm::u8vec3 color {};
|
glm::u8vec3 color {};
|
||||||
|
|||||||
@ -17,8 +17,7 @@ module;
|
|||||||
export module AssetManager;
|
export module AssetManager;
|
||||||
export import AssetData;
|
export import AssetData;
|
||||||
|
|
||||||
import allocator;
|
import utils;
|
||||||
import worker;
|
|
||||||
import FileSystem;
|
import FileSystem;
|
||||||
|
|
||||||
export
|
export
|
||||||
@ -153,7 +152,7 @@ export
|
|||||||
return *reinterpret_cast<AssetHandle*>(command.out->load());
|
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;
|
std::atomic<void*> result;
|
||||||
AssetStreamCommand command;
|
AssetStreamCommand command;
|
||||||
@ -173,7 +172,7 @@ export
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returned resource reference should not be stored
|
// 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));
|
return Get<T>(Find(id));
|
||||||
}
|
}
|
||||||
@ -294,9 +293,6 @@ export
|
|||||||
mapMeshesStorage.clear();
|
mapMeshesStorage.clear();
|
||||||
shadersStorage.clear();
|
shadersStorage.clear();
|
||||||
materialsStorage.clear();
|
materialsStorage.clear();
|
||||||
|
|
||||||
LOG(INFO, "Asset Streaming is released");
|
|
||||||
isRunning.store(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -3,7 +3,7 @@ module;
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
export module Client;
|
export module Client;
|
||||||
import worker;
|
import utils;
|
||||||
import GameData;
|
import GameData;
|
||||||
import DataChannel;
|
import DataChannel;
|
||||||
import AssetManager;
|
import AssetManager;
|
||||||
|
|||||||
@ -8,8 +8,7 @@ export module Engine;
|
|||||||
export import AssetManager;
|
export import AssetManager;
|
||||||
export import Client;
|
export import Client;
|
||||||
|
|
||||||
import allocator;
|
import utils;
|
||||||
import worker;
|
|
||||||
|
|
||||||
export
|
export
|
||||||
{
|
{
|
||||||
|
|||||||
@ -56,7 +56,7 @@ export
|
|||||||
std::vector<std::size_t> freeFileSlots;
|
std::vector<std::size_t> freeFileSlots;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NativeFileSystem : public IFileSystem {
|
class NativeFileSystem final : public IFileSystem {
|
||||||
public:
|
public:
|
||||||
FileHandle &Open(const std::filesystem::path &path, const std::uint32_t flags) override;
|
FileHandle &Open(const std::filesystem::path &path, const std::uint32_t flags) override;
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export module GLFWInput;
|
|||||||
import Input;
|
import Input;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
class GLFWInput : public ee_engine::IInput
|
class GLFWInput final : public ee_engine::IInput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GLFWInput(ee_engine::InputHandlers handlers);
|
GLFWInput(ee_engine::InputHandlers handlers);
|
||||||
|
|||||||
@ -6,8 +6,8 @@ module;
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
module Client;
|
module Client;
|
||||||
import allocator;
|
import utils;
|
||||||
import MapView;
|
import views;
|
||||||
import Engine;
|
import Engine;
|
||||||
|
|
||||||
Client::Client() : ee_utils::ThreadedWorker<ClientCommand, ClientCommand::COMPLETED>(L"Client")
|
Client::Client() : ee_utils::ThreadedWorker<ClientCommand, ClientCommand::COMPLETED>(L"Client")
|
||||||
|
|||||||
@ -6,7 +6,7 @@ module;
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
module FileSystem;
|
module FileSystem;
|
||||||
import allocator;
|
import utils;
|
||||||
|
|
||||||
|
|
||||||
IFileSystem::~IFileSystem()
|
IFileSystem::~IFileSystem()
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import allocator;
|
import utils;
|
||||||
|
|
||||||
import Engine;
|
import Engine;
|
||||||
import Actions;
|
import Actions;
|
||||||
@ -11,7 +11,6 @@ import GLFWInput;
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
IP7_Trace* Logger::trace;
|
IP7_Trace* Logger::trace;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// Setup P7 logger
|
// Setup P7 logger
|
||||||
@ -53,8 +52,8 @@ int main(int argc, char **argv)
|
|||||||
// Setup renderer TODO: builder
|
// Setup renderer TODO: builder
|
||||||
Engine::renderer = reinterpret_cast<ee_engine::IRenderer*>(Allocate<ee_magnum::MagnumRenderer>(window));
|
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");
|
ee_assets::AssetMapMesh ®ions = Engine::assetManager->FindOnce<ee_assets::AssetMapMesh>("assets/map/ET.map");
|
||||||
Engine::renderer->RegisterMapMesh(&states.content);
|
Engine::renderer->RegisterMapMesh(®ions.content);
|
||||||
|
|
||||||
//TODO: ShaderRefs builder from set of AssetMaterial
|
//TODO: ShaderRefs builder from set of AssetMaterial
|
||||||
ee_assets::AssetMaterial &provincesMaterial =
|
ee_assets::AssetMaterial &provincesMaterial =
|
||||||
@ -98,7 +97,6 @@ int main(int argc, char **argv)
|
|||||||
// Free memory
|
// Free memory
|
||||||
LOG(INFO, "Exit...");
|
LOG(INFO, "Exit...");
|
||||||
Engine::Shutdown();
|
Engine::Shutdown();
|
||||||
//TODO: check Unregister in other threads and make threaded module base class
|
|
||||||
Logger::trace->Unregister_Thread(0);
|
Logger::trace->Unregister_Thread(0);
|
||||||
Logger::trace->Release();
|
Logger::trace->Release();
|
||||||
p7client->Release();
|
p7client->Release();
|
||||||
@ -106,9 +104,5 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
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 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
|
// TODO: Leaks detection
|
||||||
@ -9,7 +9,7 @@ module;
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
export module Materials;
|
export module MagnumRender:Materials;
|
||||||
|
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ export namespace ee_magnum
|
|||||||
explicit BaseMaterial(const std::string &vertSrc, const std::string &fragSrc);
|
explicit BaseMaterial(const std::string &vertSrc, const std::string &fragSrc);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProvinceMaterial : public BaseMaterial
|
class ProvinceMaterial final : public BaseMaterial
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline static constexpr std::int32_t PROVINCES_DATA_BINDING = 0;
|
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);
|
explicit ProvinceMaterial(const std::string &vertSrc, const std::string &fragSrc);
|
||||||
|
|
||||||
void setId(const std::uint32_t &id);
|
void setId(const std::uint32_t id);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,8 +9,8 @@ module;
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
export module MagnumRender;
|
export module MagnumRender;
|
||||||
import MapView;
|
import :Materials;
|
||||||
import Materials;
|
import views;
|
||||||
import Render;
|
import Render;
|
||||||
|
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
|
|||||||
@ -11,7 +11,8 @@ module;
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
module Materials;
|
module MagnumRender;
|
||||||
|
import :Materials;
|
||||||
|
|
||||||
ee_magnum::BaseMaterial::BaseMaterial(const std::string &vertSrc, const std::string &fragSrc)
|
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);
|
setUniform(PROVINCES_ID_BINDING, id);
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ module;
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
module MagnumRender;
|
module MagnumRender;
|
||||||
import allocator;
|
import utils;
|
||||||
|
|
||||||
using namespace Math::Literals;
|
using namespace Math::Literals;
|
||||||
|
|
||||||
@ -96,18 +96,17 @@ void ee_magnum::MagnumRenderer::LoadProvinces()
|
|||||||
{
|
{
|
||||||
for (ee_engine::MapMesh::Province &province: provs)
|
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()))
|
.setCount(static_cast<Magnum::Int>(province.indices.size()))
|
||||||
.addVertexBuffer(GL::Buffer{province.vertices}, 0, GL::Attribute<0, Magnum::Vector2>{})
|
.addVertexBuffer(GL::Buffer{province.vertices}, 0, GL::Attribute<0, Magnum::Vector2>{})
|
||||||
.setIndexBuffer(GL::Buffer{province.indices}, 0, GL::MeshIndexType::UnsignedShort);
|
.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 {
|
ee_engine::ProvinceSSBO data {
|
||||||
.regionId = region,
|
.regionId = region,
|
||||||
//.color = region
|
|
||||||
.color = 0xFFFFFF
|
.color = 0xFFFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ module;
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
export module allocator;
|
export module utils:allocator;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
template<typename T, typename... Args> T* Allocate(Args&&... args)
|
template<typename T, typename... Args> T* Allocate(Args&&... args)
|
||||||
|
|||||||
@ -3,10 +3,10 @@ module;
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
export module buffers;
|
export module utils:buffers;
|
||||||
|
|
||||||
export namespace ee_utils
|
export namespace ee_utils
|
||||||
{
|
{
|
||||||
bool readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLeftoverSize, const std::size_t &readSize);
|
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 writeNext(std::uint8_t* &dstPointer, void* src, std::size_t &dstLeftoverSize, const std::size_t writeSize);
|
||||||
}
|
}
|
||||||
6
utils/modules/utils.cppm
Normal file
6
utils/modules/utils.cppm
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export module utils;
|
||||||
|
export import :allocator;
|
||||||
|
export import :worker;
|
||||||
|
export import :buffers;
|
||||||
|
|
||||||
|
export namespace ee_utils {}
|
||||||
@ -11,7 +11,7 @@ module;
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
|
|
||||||
export module worker;
|
export module utils:worker;
|
||||||
|
|
||||||
export namespace ee_utils
|
export namespace ee_utils
|
||||||
{
|
{
|
||||||
@ -144,7 +144,8 @@ export namespace ee_utils
|
|||||||
void ReleaseStop()
|
void ReleaseStop()
|
||||||
{
|
{
|
||||||
Release();
|
Release();
|
||||||
LOG(INFO, "Client is released");
|
LOG(INFO, "Thread is released");
|
||||||
|
Logger::trace->Unregister_Thread(0);
|
||||||
isRunning.store(false);
|
isRunning.store(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,9 +4,10 @@ module;
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstring>
|
#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)
|
if (srcLeftoverSize >= readSize)
|
||||||
{
|
{
|
||||||
@ -20,7 +21,7 @@ bool ee_utils::readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLe
|
|||||||
return false;
|
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)
|
if (dstLeftoverSize >= writeSize)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user