Replacing std::format with fmt::format

This commit is contained in:
Dynamitos
2024-01-16 19:24:49 +01:00
parent c0da7d77a1
commit 861c146b46
55 changed files with 304 additions and 186 deletions
+2 -1
View File
@@ -343,4 +343,5 @@ ASALocalRun/
.localhistory/ .localhistory/
# BeatPulse healthcheck temp database # BeatPulse healthcheck temp database
healthchecksdb healthchecksdb
.DS_Store
+16 -2
View File
@@ -12,10 +12,24 @@
], ],
"windowsSdkVersion": "10.0.20348.0", "windowsSdkVersion": "10.0.20348.0",
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe", "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe",
"cStandard": "c17", "cppStandard": "c++20",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64", "intelliSenseMode": "windows-msvc-x64",
"configurationProvider": "ms-vscode.cmake-tools" "configurationProvider": "ms-vscode.cmake-tools"
},
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/src/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "/usr/bin/clang",
"cppStandard": "c++20",
"intelliSenseMode": "clang-arm64",
"configurationProvider": "ms-vscode.cmake-tools"
} }
], ],
"version": 4 "version": 4
+13 -1
View File
@@ -124,7 +124,19 @@
"ranges": "cpp", "ranges": "cpp",
"source_location": "cpp", "source_location": "cpp",
"syncstream": "cpp", "syncstream": "cpp",
"stdfloat": "cpp" "stdfloat": "cpp",
"__bit_reference": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__verbose_abort": "cpp"
}, },
"cmake.skipConfigureIfCachePresent": false, "cmake.skipConfigureIfCachePresent": false,
"cmake.configureArgs": [ "cmake.configureArgs": [
+5 -17
View File
@@ -12,6 +12,8 @@ set(CMAKE_INSTALL_MESSAGE LAZY)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(VCPKG_INSTALL_OPTIONS "--allow-unsupported")
set(ENGINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/Engine) set(ENGINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/Engine)
set(EXTERNAL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/external) set(EXTERNAL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/external)
@@ -45,6 +47,7 @@ find_package(glfw3 CONFIG REQUIRED)
find_package(glm CONFIG REQUIRED) find_package(glm CONFIG REQUIRED)
find_package(Ktx CONFIG REQUIRED) find_package(Ktx CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
if(UNIX) if(UNIX)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
@@ -67,7 +70,8 @@ target_link_libraries(Engine PUBLIC assimp::assimp)
target_link_libraries(Engine PUBLIC KTX::ktx) target_link_libraries(Engine PUBLIC KTX::ktx)
target_link_libraries(Engine PUBLIC nlohmann_json::nlohmann_json) target_link_libraries(Engine PUBLIC nlohmann_json::nlohmann_json)
target_link_libraries(Engine PUBLIC crcpp) target_link_libraries(Engine PUBLIC crcpp)
target_link_libraries(Engine PUBLIC shader-slang) target_link_libraries(Engine PUBLIC slang)
target_link_libraries(Engine PUBLIC fmt::fmt)
if(UNIX) if(UNIX)
target_link_libraries(Engine PUBLIC Threads::Threads) target_link_libraries(Engine PUBLIC Threads::Threads)
target_link_libraries(Engine PUBLIC dl) target_link_libraries(Engine PUBLIC dl)
@@ -82,22 +86,6 @@ target_compile_definitions(Editor PRIVATE EDITOR=1)
add_executable(AssetViewer "") add_executable(AssetViewer "")
target_link_libraries(AssetViewer PRIVATE Engine) target_link_libraries(AssetViewer PRIVATE Engine)
target_include_directories(AssetViewer PRIVATE src/AssetViewer) target_include_directories(AssetViewer PRIVATE src/AssetViewer)
target_precompile_headers(Engine
PUBLIC
<assert.h>
<atomic>
<condition_variable>
<coroutine>
<cstring>
<filesystem>
<functional>
<fstream>
<iostream>
<memory>
<mutex>
<string>
<thread>)
if(MSVC) if(MSVC)
set(_CRT_SECURE_NO_WARNINGS) set(_CRT_SECURE_NO_WARNINGS)
+2 -2
View File
@@ -81,8 +81,8 @@ if(WIN32)
install(FILES install(FILES
${SLANG_ROOT}/lib/slang.lib ${SLANG_ROOT}/lib/slang.lib
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
else() elseif(APPLE)
endif() endif()
target_include_directories(shader-slang INTERFACE target_include_directories(shader-slang INTERFACE
$<BUILD_INTERFACE:${SLANG_ROOT}/include/> $<BUILD_INTERFACE:${SLANG_ROOT}/include/>
+1 -1
+3 -1
View File
@@ -5,6 +5,8 @@
#include "Asset/MaterialAsset.h" #include "Asset/MaterialAsset.h"
#include "Asset/MaterialInstanceAsset.h" #include "Asset/MaterialInstanceAsset.h"
#include "Asset/AssetRegistry.h" #include "Asset/AssetRegistry.h"
#include <fstream>
#include <iostream>
using namespace Seele; using namespace Seele;
@@ -16,7 +18,7 @@ int main(int, char**)
//{ //{
// return -1; // return -1;
//} //}
std::filesystem::path path = "C:\\Users\\Dynamitos\\TrackClear\\Assets\\Dirt.asset"; std::filesystem::path path = std::filesystem::path("C:\\Users\\Dynamitos\\TrackClear\\Assets\\Dirt.asset");
std::ifstream stream = std::ifstream(path, std::ios::binary); std::ifstream stream = std::ifstream(path, std::ios::binary);
ArchiveBuffer buffer; ArchiveBuffer buffer;
+2
View File
@@ -6,6 +6,8 @@
#include "Graphics/Texture.h" #include "Graphics/Texture.h"
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include <iostream>
#include <fstream>
using namespace Seele; using namespace Seele;
+11 -9
View File
@@ -8,7 +8,9 @@
#include "Material/ShaderExpression.h" #include "Material/ShaderExpression.h"
#include "Asset/TextureAsset.h" #include "Asset/TextureAsset.h"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <format> #include <fmt/core.h>
#include <iostream>
#include <fstream>
using namespace Seele; using namespace Seele;
using json = nlohmann::json; using json = nlohmann::json;
@@ -131,14 +133,14 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
{ {
std::string str = obj.get<std::string>(); std::string str = obj.get<std::string>();
OConstantExpression c = new ConstantExpression(str, ExpressionType::UNKNOWN); OConstantExpression c = new ConstantExpression(str, ExpressionType::UNKNOWN);
std::string name = std::format("const_{0}", auxKey++); std::string name = fmt::format("const_{0}", auxKey++);
c->key = name; c->key = name;
expressions.add(std::move(c)); expressions.add(std::move(c));
return name; return name;
} }
else else
{ {
return std::format("{0}", obj.get<uint32>()); return fmt::format("{0}", obj.get<uint32>());
} }
}; };
MaterialNode mat; MaterialNode mat;
@@ -150,7 +152,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if (exp.compare("Const") == 0) if (exp.compare("Const") == 0)
{ {
OConstantExpression p = new ConstantExpression(); OConstantExpression p = new ConstantExpression();
std::string name = std::format("{0}", key++); std::string name = fmt::format("{0}", key++);
p->key = name; p->key = name;
p->expr = obj["value"]; p->expr = obj["value"];
expressions.add(std::move(p)); expressions.add(std::move(p));
@@ -158,7 +160,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Add") == 0) if(exp.compare("Add") == 0)
{ {
OAddExpression p = new AddExpression(); OAddExpression p = new AddExpression();
std::string name = std::format("{0}", key++); std::string name = fmt::format("{0}", key++);
p->key = name; p->key = name;
p->inputs["lhs"].source = referenceExpression(obj["lhs"]); p->inputs["lhs"].source = referenceExpression(obj["lhs"]);
p->inputs["rhs"].source = referenceExpression(obj["rhs"]); p->inputs["rhs"].source = referenceExpression(obj["rhs"]);
@@ -167,7 +169,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Sub") == 0) if(exp.compare("Sub") == 0)
{ {
OSubExpression p = new SubExpression(); OSubExpression p = new SubExpression();
std::string name = std::format("{0}", key++); std::string name = fmt::format("{0}", key++);
p->key = name; p->key = name;
p->inputs["lhs"].source = referenceExpression(obj["lhs"]); p->inputs["lhs"].source = referenceExpression(obj["lhs"]);
p->inputs["rhs"].source = referenceExpression(obj["rhs"]); p->inputs["rhs"].source = referenceExpression(obj["rhs"]);
@@ -176,7 +178,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Mul") == 0) if(exp.compare("Mul") == 0)
{ {
OMulExpression p = new MulExpression(); OMulExpression p = new MulExpression();
std::string name = std::format("{0}", key++); std::string name = fmt::format("{0}", key++);
p->key = name; p->key = name;
p->inputs["lhs"].source = referenceExpression(obj["lhs"]); p->inputs["lhs"].source = referenceExpression(obj["lhs"]);
p->inputs["rhs"].source = referenceExpression(obj["rhs"]); p->inputs["rhs"].source = referenceExpression(obj["rhs"]);
@@ -185,7 +187,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Swizzle") == 0) if(exp.compare("Swizzle") == 0)
{ {
OSwizzleExpression p = new SwizzleExpression(); OSwizzleExpression p = new SwizzleExpression();
std::string name = std::format("{0}", key++); std::string name = fmt::format("{0}", key++);
p->key = name; p->key = name;
p->inputs["target"].source = referenceExpression(obj["target"]); p->inputs["target"].source = referenceExpression(obj["target"]);
int32 i = 0; int32 i = 0;
@@ -198,7 +200,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Sample") == 0) if(exp.compare("Sample") == 0)
{ {
OSampleExpression p = new SampleExpression(); OSampleExpression p = new SampleExpression();
std::string name = std::format("{0}", key++); std::string name = fmt::format("{0}", key++);
p->key = name; p->key = name;
p->inputs["texture"].source = referenceExpression(obj["texture"]); p->inputs["texture"].source = referenceExpression(obj["texture"]);
p->inputs["sampler"].source = referenceExpression(obj["sampler"]); p->inputs["sampler"].source = referenceExpression(obj["sampler"]);
+3 -3
View File
@@ -6,7 +6,7 @@
#include "Asset/AssetImporter.h" #include "Asset/AssetImporter.h"
#include "Asset/MaterialAsset.h" #include "Asset/MaterialAsset.h"
#include <set> #include <set>
#include <format> #include <fmt/core.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
@@ -48,7 +48,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
{ {
aiMaterial* material = scene->mMaterials[i]; aiMaterial* material = scene->mMaterials[i];
json matCode; json matCode;
std::string materialName = std::format("{0}{1}{2}", baseName, material->GetName().C_Str(), i); std::string materialName = fmt::format("{0}{1}{2}", baseName, material->GetName().C_Str(), i);
materialName.erase(std::remove(materialName.begin(), materialName.end(), '.'), materialName.end()); // dots break adding the .asset extension later materialName.erase(std::remove(materialName.begin(), materialName.end(), '.'), materialName.end()); // dots break adding the .asset extension later
matCode["name"] = materialName; matCode["name"] = materialName;
matCode["profile"] = "CelShading"; matCode["profile"] = "CelShading";
@@ -196,7 +196,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
}); });
PMaterialAsset baseMat = AssetRegistry::findMaterial(matCode["name"].get<std::string>()); PMaterialAsset baseMat = AssetRegistry::findMaterial(matCode["name"].get<std::string>());
globalMaterials[i] = baseMat->instantiate(InstantiationParameter{ globalMaterials[i] = baseMat->instantiate(InstantiationParameter{
.name = std::format("{0}_Inst_0", baseMat->getName()), .name = fmt::format("{0}_Inst_0", baseMat->getName()),
.folderPath = baseMat->getFolderPath(), .folderPath = baseMat->getFolderPath(),
}); });
} }
+1
View File
@@ -13,6 +13,7 @@
#include <stb_image_write.h> #include <stb_image_write.h>
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#include "ktx.h" #include "ktx.h"
#include <fstream>
using namespace Seele; using namespace Seele;
+1
View File
@@ -1,5 +1,6 @@
#include "ViewportControl.h" #include "ViewportControl.h"
#include "Component/Camera.h" #include "Component/Camera.h"
#include <iostream>
using namespace Seele; using namespace Seele;
using namespace Seele::Editor; using namespace Seele::Editor;
+4 -4
View File
@@ -12,7 +12,7 @@
#include "Asset/FontLoader.h" #include "Asset/FontLoader.h"
#include "Asset/AssetImporter.h" #include "Asset/AssetImporter.h"
#include "Graphics/StaticMeshVertexData.h" #include "Graphics/StaticMeshVertexData.h"
#include <format> #include <fmt/core.h>
using namespace Seele; using namespace Seele;
using namespace Seele::Editor; using namespace Seele::Editor;
@@ -254,9 +254,9 @@ int main()
if (false) if (false)
{ {
std::filesystem::create_directories(outputPath); std::filesystem::create_directories(outputPath);
std::system(std::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str()); std::system(fmt::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str());
std::system(std::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str()); std::system(fmt::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str());
std::system(std::format("cmake --build {}", cmakePath.generic_string()).c_str()); std::system(fmt::format("cmake --build {}", cmakePath.generic_string()).c_str());
std::filesystem::copy(sourcePath / "Assets", outputPath / "Assets", std::filesystem::copy_options::recursive); std::filesystem::copy(sourcePath / "Assets", outputPath / "Assets", std::filesystem::copy_options::recursive);
std::filesystem::copy("shaders", outputPath / "shaders", std::filesystem::copy_options::recursive); std::filesystem::copy("shaders", outputPath / "shaders", std::filesystem::copy_options::recursive);
std::filesystem::copy("textures", outputPath / "textures", std::filesystem::copy_options::recursive); std::filesystem::copy("textures", outputPath / "textures", std::filesystem::copy_options::recursive);
+1
View File
@@ -3,6 +3,7 @@
#include "Asset.h" #include "Asset.h"
#include "Containers/Map.h" #include "Containers/Map.h"
#include <string> #include <string>
#include <filesystem>
namespace Seele namespace Seele
{ {
+1 -1
View File
@@ -50,7 +50,7 @@ void FontAsset::save(ArchiveBuffer& buffer) const
{ {
// technically, downloading cant be const, because we have to allocate temporary buffers and change layouts // technically, downloading cant be const, because we have to allocate temporary buffers and change layouts
// but practically the texture stays the same // but practically the texture stays the same
usedTextures[x]->download(0, depth, face, textureData); const_cast<Gfx::Texture2D*>(*(usedTextures[x]))->download(0, depth, face, textureData);
ktxTexture_SetImageFromMemory(ktxTexture(kTexture), 0, depth, face, textureData.data(), textureData.size()); ktxTexture_SetImageFromMemory(ktxTexture(kTexture), 0, depth, face, textureData.data(), textureData.size());
} }
} }
+1 -1
View File
@@ -9,8 +9,8 @@ using namespace Seele::Math;
Camera::Camera() Camera::Camera()
: viewMatrix(Matrix4()) : viewMatrix(Matrix4())
, bNeedsViewBuild(false)
, cameraPos(Vector()) , cameraPos(Vector())
, bNeedsViewBuild(false)
{ {
yaw = -3.1415f/2; yaw = -3.1415f/2;
pitch = 0; pitch = 0;
+4 -4
View File
@@ -11,7 +11,7 @@ struct Dependencies<>
{ {
int x; int x;
template<typename... Right> template<typename... Right>
Dependencies<Right...> operator|(const Dependencies<Right...>& other) Dependencies<Right...> operator|(const Dependencies<Right...>&)
{ {
return Dependencies<Right...>(); return Dependencies<Right...>();
} }
@@ -20,7 +20,7 @@ template<typename This, typename... Rest>
struct Dependencies<This, Rest...> : public Dependencies<Rest...> struct Dependencies<This, Rest...> : public Dependencies<Rest...>
{ {
template<typename... Right> template<typename... Right>
Dependencies<This, Rest..., Right...> operator|(const Dependencies<Right...>& other) Dependencies<This, Rest..., Right...> operator|(const Dependencies<Right...>&)
{ {
return Dependencies<This, Rest..., Right...>(); return Dependencies<This, Rest..., Right...>();
} }
@@ -38,8 +38,8 @@ concept has_dependencies = requires(Comp) { Comp::dependencies; };
#define REQUIRE_COMPONENT(x) \ #define REQUIRE_COMPONENT(x) \
private: \ private: \
x& get##x() { return getComponent<##x>(); } \ x& get##x() { return getComponent<x>(); } \
const x& get##x() const { return getComponent<##x>(); } \ const x& get##x() const { return getComponent<x>(); } \
public: \ public: \
constexpr static Dependencies<x> dependencies = {}; constexpr static Dependencies<x> dependencies = {};
+6 -10
View File
@@ -38,14 +38,14 @@ public:
{ {
return p; return p;
} }
constexpr bool operator!=(const IteratorBase &other) const
{
return p != other.p;
}
constexpr bool operator==(const IteratorBase &other) const constexpr bool operator==(const IteratorBase &other) const
{ {
return p == other.p; return p == other.p;
} }
constexpr std::strong_ordering operator<=>(const IteratorBase &other) const
{
return p <=> other.p;
}
constexpr IteratorBase operator+(size_t other) const constexpr IteratorBase operator+(size_t other) const
{ {
IteratorBase tmp(*this); IteratorBase tmp(*this);
@@ -61,10 +61,6 @@ public:
p+=other; p+=other;
return *this; return *this;
} }
constexpr bool operator<(const IteratorBase& other) const
{
return p < other.p;
}
constexpr IteratorBase operator-(difference_type diff) const constexpr IteratorBase operator-(difference_type diff) const
{ {
return IteratorBase(p - diff); return IteratorBase(p - diff);
@@ -537,7 +533,7 @@ public:
assert(index < arraySize); assert(index < arraySize);
return _data[index]; return _data[index];
} }
constexpr const reference operator[](size_type index) const constexpr const_reference operator[](size_type index) const
{ {
assert(index < arraySize); assert(index < arraySize);
return _data[index]; return _data[index];
@@ -674,7 +670,7 @@ constexpr bool operator==(const Array<Type, Alloc> &lhs, const Array<Type, Alloc
template<class Type, class Alloc> template<class Type, class Alloc>
constexpr auto operator<=>(const Array<Type, Alloc>& lhs, const Array<Type, Alloc>& rhs) constexpr auto operator<=>(const Array<Type, Alloc>& lhs, const Array<Type, Alloc>& rhs)
{ {
return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
} }
template <typename T, size_t N> template <typename T, size_t N>
+24 -9
View File
@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <memory_resource> #include <memory_resource>
#include <assert.h>
namespace Seele namespace Seele
{ {
@@ -9,6 +10,16 @@ class List
private: private:
struct Node struct Node
{ {
Node(Node* prev, Node* next, const T& data)
: prev(prev)
, next(next)
, data(std::move(data))
{}
Node(Node* prev, Node* next, T&& data)
: prev(prev)
, next(next)
, data(std::move(data))
{}
Node *prev; Node *prev;
Node *next; Node *next;
T data; T data;
@@ -57,39 +68,43 @@ public:
} }
return *this; return *this;
} }
reference operator*() const constexpr reference operator*() const
{ {
return node->data; return node->data;
} }
pointer operator->() const constexpr pointer operator->() const
{ {
return &node->data; return &node->data;
} }
inline bool operator!=(const IteratorBase &other) constexpr bool operator!=(const IteratorBase &other)
{ {
return node != other.node; return node != other.node;
} }
inline bool operator==(const IteratorBase &other) constexpr bool operator==(const IteratorBase &other)
{ {
return node == other.node; return node == other.node;
} }
IteratorBase &operator--() constexpr std::strong_ordering operator<=>(const IteratorBase& other)
{
return node <=> other.node;
}
constexpr IteratorBase &operator--()
{ {
node = node->prev; node = node->prev;
return *this; return *this;
} }
IteratorBase operator--(int) constexpr IteratorBase operator--(int)
{ {
IteratorBase tmp(*this); IteratorBase tmp(*this);
--*this; --*this;
return tmp; return tmp;
} }
IteratorBase &operator++() constexpr IteratorBase &operator++()
{ {
node = node->next; node = node->next;
return *this; return *this;
} }
IteratorBase operator++(int) constexpr IteratorBase operator++(int)
{ {
IteratorBase tmp(*this); IteratorBase tmp(*this);
++*this; ++*this;
@@ -187,7 +202,7 @@ public:
, beginIt(std::move(other.beginIt)) , beginIt(std::move(other.beginIt))
, endIt(std::move(other.endIt)) , endIt(std::move(other.endIt))
, _size(std::move(other._size)) , _size(std::move(other._size))
, allocator(allocator) , allocator(alloc)
{ {
other._size = 0; other._size = 0;
} }
+21 -7
View File
@@ -15,6 +15,16 @@ struct Tree
protected: protected:
struct Node struct Node
{ {
Node(Node* left, Node* right, const NodeData& nodeData)
: leftChild(left)
, rightChild(right)
, data(nodeData)
{}
Node(Node* left, Node* right, NodeData&& nodeData)
: leftChild(left)
, rightChild(right)
, data(std::move(nodeData))
{}
Node* leftChild; Node* leftChild;
Node* rightChild; Node* rightChild;
NodeData data; NodeData data;
@@ -71,12 +81,16 @@ public:
} }
constexpr bool operator!=(const IteratorBase& other) constexpr bool operator!=(const IteratorBase& other)
{ {
return node != other.node; return node == other.node;
} }
constexpr bool operator==(const IteratorBase& other) constexpr bool operator==(const IteratorBase& other)
{ {
return node == other.node; return node == other.node;
} }
constexpr std::strong_ordering operator<=>(const IteratorBase& other)
{
return node == other.node;
}
constexpr IteratorBase& operator++() constexpr IteratorBase& operator++()
{ {
node = node->rightChild; node = node->rightChild;
@@ -433,8 +447,8 @@ private:
_size++; _size++;
return Pair<Node*, bool>(newNode, true); return Pair<Node*, bool>(newNode, true);
} }
template<class KeyType> template<class K>
Node* _remove(Node* r, KeyType&& key) Node* _remove(Node* r, K&& key)
{ {
markIteratorsDirty(); markIteratorsDirty();
Node* temp; Node* temp;
@@ -463,8 +477,8 @@ private:
_size--; _size--;
return r; return r;
} }
template<class KeyType> template<class K>
Node* _splay(Node* r, KeyType&& key) Node* _splay(Node* r, K&& key)
{ {
markIteratorsDirty(); markIteratorsDirty();
if (r == nullptr || equal(r->data, key)) if (r == nullptr || equal(r->data, key))
@@ -516,8 +530,8 @@ private:
return (r->rightChild == nullptr) ? r : rotateLeft(r); return (r->rightChild == nullptr) ? r : rotateLeft(r);
} }
} }
template<typename KeyType> template<typename K>
bool equal(const NodeData& a, KeyType&& b) const bool equal(const NodeData& a, K&& b) const
{ {
return !comp(keyFun(a), b) && !comp(b, keyFun(a)); return !comp(keyFun(a), b) && !comp(b, keyFun(a));
} }
+11 -27
View File
@@ -1,6 +1,8 @@
#include "DebugPass.h" #include "DebugPass.h"
#include "Graphics/Graphics.h" #include "Graphics/Graphics.h"
#include "Graphics/RenderTarget.h" #include "Graphics/RenderTarget.h"
#include "Graphics/Pipeline.h"
#include "Graphics/Shader.h"
using namespace Seele; using namespace Seele;
@@ -74,10 +76,6 @@ void DebugPass::publishOutputs()
descriptorLayout = graphics->createDescriptorLayout("DebugDescLayout"); descriptorLayout = graphics->createDescriptorLayout("DebugDescLayout");
descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
descriptorLayout->create(); descriptorLayout->create();
pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->create();
} }
void DebugPass::createRenderPass() void DebugPass::createRenderPass()
@@ -92,43 +90,29 @@ void DebugPass::createRenderPass()
}; };
renderPass = graphics->createRenderPass(std::move(layout), viewport); renderPass = graphics->createRenderPass(std::move(layout), viewport);
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->create();
ShaderCreateInfo createInfo; ShaderCreateInfo createInfo;
createInfo.name = "DebugVertex"; createInfo.name = "DebugVertex";
createInfo.mainModule = "Debug"; createInfo.mainModule = "Debug";
createInfo.entryPoint = "vertexMain"; createInfo.entryPoint = "vertexMain";
createInfo.defines["INDEX_VIEW_PARAMS"] = "0"; createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
Gfx::PVertexShader vertexShader = graphics->createVertexShader(createInfo); vertexShader = graphics->createVertexShader(createInfo);
createInfo.name = "DebugFragment"; createInfo.name = "DebugFragment";
createInfo.entryPoint = "fragmentMain"; createInfo.entryPoint = "fragmentMain";
Gfx::PFragmentShader fragmentShader = graphics->createFragmentShader(createInfo); fragmentShader = graphics->createFragmentShader(createInfo);
Gfx::OVertexDeclaration vertexDecl = graphics->createVertexDeclaration({ Gfx::LegacyPipelineCreateInfo gfxInfo;
Gfx::VertexElement {
.streamIndex = 0,
.offset = offsetof(DebugVertex, position),
.vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
.attributeIndex = 0,
.stride = sizeof(DebugVertex),
},
Gfx::VertexElement {
.streamIndex = 0,
.offset = offsetof(DebugVertex, color),
.vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
.attributeIndex = 1,
.stride = sizeof(DebugVertex),
}
});
GraphicsPipelineCreateInfo gfxInfo;
gfxInfo.vertexDeclaration = vertexDecl;
gfxInfo.vertexShader = vertexShader; gfxInfo.vertexShader = vertexShader;
gfxInfo.fragmentShader = fragmentShader; gfxInfo.fragmentShader = fragmentShader;
gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE; gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
gfxInfo.rasterizationState.lineWidth = 5.f; gfxInfo.rasterizationState.lineWidth = 5.f;
gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST; gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST;
gfxInfo.pipelineLayout = pipelineLayout; gfxInfo.pipelineLayout = std::move(pipelineLayout);
gfxInfo.renderPass = renderPass; gfxInfo.renderPass = renderPass;
pipeline = graphics->createGraphicsPipeline(gfxInfo); pipeline = graphics->createGraphicsPipeline(std::move(gfxInfo));
} }
+3 -2
View File
@@ -25,8 +25,9 @@ private:
Gfx::OUniformBuffer viewParamsBuffer; Gfx::OUniformBuffer viewParamsBuffer;
Gfx::ODescriptorLayout descriptorLayout; Gfx::ODescriptorLayout descriptorLayout;
Gfx::PDescriptorSet descriptorSet; Gfx::PDescriptorSet descriptorSet;
Gfx::OPipelineLayout pipelineLayout; Gfx::OVertexShader vertexShader;
Gfx::OGraphicsPipeline pipeline; Gfx::OFragmentShader fragmentShader;
Gfx::PGraphicsPipeline pipeline;
}; };
DEFINE_REF(DebugPass) DEFINE_REF(DebugPass)
} // namespace Seele } // namespace Seele
@@ -1,4 +1,5 @@
#include "RenderGraphResources.h" #include "RenderGraphResources.h"
#include <iostream>
using namespace Seele; using namespace Seele;
@@ -23,7 +23,6 @@ SkyboxRenderPass::~SkyboxRenderPass()
void SkyboxRenderPass::beginFrame(const Component::Camera& cam) void SkyboxRenderPass::beginFrame(const Component::Camera& cam)
{ {
RenderPass::beginFrame(cam); RenderPass::beginFrame(cam);
DataSource uniformUpdate;
skyboxDataLayout->reset(); skyboxDataLayout->reset();
textureLayout->reset(); textureLayout->reset();
+1 -1
View File
@@ -83,7 +83,7 @@ void UIPass::publishOutputs()
colorBuffer = graphics->createTexture2D(colorBufferInfo); colorBuffer = graphics->createTexture2D(colorBufferInfo);
renderTarget = renderTarget =
new Gfx::RenderTargetAttachment(colorBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE); new Gfx::RenderTargetAttachment(colorBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
renderTarget->clear.color = { 0.0f, 0.0f, 0.0f, 1.0f }; renderTarget->clear.color = { {0.0f, 0.0f, 0.0f, 1.0f} };
resources->registerRenderPassOutput("UIPASS_COLOR", renderTarget); resources->registerRenderPassOutput("UIPASS_COLOR", renderTarget);
} }
+2 -2
View File
@@ -2,7 +2,7 @@
#include "Graphics/Initializer.h" #include "Graphics/Initializer.h"
#include "Graphics/RenderPass/DepthPrepass.h" #include "Graphics/RenderPass/DepthPrepass.h"
#include "Graphics/RenderPass/BasePass.h" #include "Graphics/RenderPass/BasePass.h"
#include <format> #include <fmt/core.h>
using namespace Seele; using namespace Seele;
using namespace Seele::Gfx; using namespace Seele::Gfx;
@@ -97,7 +97,7 @@ void ShaderCompiler::createShaders(ShaderPermutation permutation)
ShaderCollection collection; ShaderCollection collection;
ShaderCreateInfo createInfo; ShaderCreateInfo createInfo;
createInfo.name = std::format("Material {0}", permutation.materialName); createInfo.name = fmt::format("Material {0}", permutation.materialName);
if (std::strlen(permutation.materialName) > 0) if (std::strlen(permutation.materialName) > 0)
{ {
createInfo.additionalModules.add(permutation.materialName); createInfo.additionalModules.add(permutation.materialName);
+6 -6
View File
@@ -71,36 +71,36 @@ struct ShaderPermutation
{ {
std::memset(taskFile, 0, sizeof(taskFile)); std::memset(taskFile, 0, sizeof(taskFile));
hasTaskShader = 1; hasTaskShader = 1;
strncpy_s(taskFile, sizeof(taskFile), name.data(), 32); strncpy(taskFile, name.data(), sizeof(taskFile));
} }
void setVertexFile(std::string_view name) void setVertexFile(std::string_view name)
{ {
std::memset(vertexMeshFile, 0, sizeof(vertexMeshFile)); std::memset(vertexMeshFile, 0, sizeof(vertexMeshFile));
useMeshShading = 0; useMeshShading = 0;
strncpy_s(vertexMeshFile, sizeof(vertexMeshFile), name.data(), 32); strncpy(vertexMeshFile, name.data(), sizeof(vertexMeshFile));
} }
void setMeshFile(std::string_view name) void setMeshFile(std::string_view name)
{ {
std::memset(vertexMeshFile, 0, sizeof(vertexMeshFile)); std::memset(vertexMeshFile, 0, sizeof(vertexMeshFile));
useMeshShading = 1; useMeshShading = 1;
strncpy_s(vertexMeshFile, sizeof(vertexMeshFile), name.data(), 32); strncpy(vertexMeshFile, name.data(), sizeof(vertexMeshFile));
} }
void setFragmentFile(std::string_view name) void setFragmentFile(std::string_view name)
{ {
std::memset(fragmentFile, 0, sizeof(fragmentFile)); std::memset(fragmentFile, 0, sizeof(fragmentFile));
hasFragment = 1; hasFragment = 1;
strncpy_s(fragmentFile, sizeof(fragmentFile), name.data(), 32); strncpy(fragmentFile, name.data(), sizeof(fragmentFile));
} }
void setVertexData(std::string_view name) void setVertexData(std::string_view name)
{ {
std::memset(vertexDataName, 0, sizeof(vertexDataName)); std::memset(vertexDataName, 0, sizeof(vertexDataName));
strncpy_s(vertexDataName, sizeof(vertexDataName), name.data(), 32); strncpy(vertexDataName, name.data(), sizeof(vertexDataName));
} }
void setMaterial(std::string_view name) void setMaterial(std::string_view name)
{ {
std::memset(materialName, 0, sizeof(materialName)); std::memset(materialName, 0, sizeof(materialName));
useMaterial = 1; useMaterial = 1;
strncpy_s(materialName, sizeof(materialName), name.data(), 32); strncpy(materialName, name.data(), sizeof(materialName));
} }
}; };
//Hashed ShaderPermutation for fast lookup //Hashed ShaderPermutation for fast lookup
+1 -1
View File
@@ -261,8 +261,8 @@ uint32 Allocator::findMemoryType(uint32 typeFilter, VkMemoryPropertyFlags proper
StagingBuffer::StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBuffer buffer, VkDeviceSize size, Gfx::QueueType owner) StagingBuffer::StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBuffer buffer, VkDeviceSize size, Gfx::QueueType owner)
: owner(owner) : owner(owner)
, graphics(graphics)
, allocation(std::move(allocation)) , allocation(std::move(allocation))
, graphics(graphics)
, buffer(buffer) , buffer(buffer)
, size(size) , size(size)
{ {
+22 -22
View File
@@ -59,19 +59,19 @@ class UniformBuffer : public Gfx::UniformBuffer, public Buffer
public: public:
UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo &sourceData); UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo &sourceData);
virtual ~UniformBuffer(); virtual ~UniformBuffer();
virtual bool updateContents(const DataSource &sourceData); virtual bool updateContents(const DataSource &sourceData) override;
virtual void* map(bool writeOnly = true) override; virtual void* map(bool writeOnly = true) override;
virtual void unmap() override; virtual void unmap() override;
protected: protected:
// Inherited via Vulkan::Buffer // Inherited via Vulkan::Buffer
virtual VkAccessFlags getSourceAccessMask(); virtual VkAccessFlags getSourceAccessMask() override;
virtual VkAccessFlags getDestAccessMask(); virtual VkAccessFlags getDestAccessMask() override;
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner); virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override;
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
private: private:
OStagingBuffer dedicatedStagingBuffer; OStagingBuffer dedicatedStagingBuffer;
@@ -83,19 +83,19 @@ class ShaderBuffer : public Gfx::ShaderBuffer, public Buffer
public: public:
ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo &sourceData); ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo &sourceData);
virtual ~ShaderBuffer(); virtual ~ShaderBuffer();
virtual bool updateContents(const DataSource &sourceData); virtual bool updateContents(const DataSource &sourceData) override;
virtual void* map(bool writeOnly = true) override; virtual void* map(bool writeOnly = true) override;
virtual void unmap() override; virtual void unmap() override;
protected: protected:
// Inherited via Vulkan::Buffer // Inherited via Vulkan::Buffer
virtual VkAccessFlags getSourceAccessMask(); virtual VkAccessFlags getSourceAccessMask() override;
virtual VkAccessFlags getDestAccessMask(); virtual VkAccessFlags getDestAccessMask() override;
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner); virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override;
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
private: private:
OStagingBuffer dedicatedStagingBuffer; OStagingBuffer dedicatedStagingBuffer;
}; };
@@ -111,13 +111,13 @@ public:
virtual void download(Array<uint8>& buffer) override; virtual void download(Array<uint8>& buffer) override;
protected: protected:
// Inherited via Vulkan::Buffer // Inherited via Vulkan::Buffer
virtual VkAccessFlags getSourceAccessMask(); virtual VkAccessFlags getSourceAccessMask() override;
virtual VkAccessFlags getDestAccessMask(); virtual VkAccessFlags getDestAccessMask() override;
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner); virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override;
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
}; };
DEFINE_REF(VertexBuffer) DEFINE_REF(VertexBuffer)
@@ -130,13 +130,13 @@ public:
virtual void download(Array<uint8>& buffer) override; virtual void download(Array<uint8>& buffer) override;
protected: protected:
// Inherited via Vulkan::Buffer // Inherited via Vulkan::Buffer
virtual VkAccessFlags getSourceAccessMask(); virtual VkAccessFlags getSourceAccessMask() override;
virtual VkAccessFlags getDestAccessMask(); virtual VkAccessFlags getDestAccessMask() override;
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner); virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override;
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
}; };
DEFINE_REF(IndexBuffer) DEFINE_REF(IndexBuffer)
} }
+1
View File
@@ -2,6 +2,7 @@
#include "Queue.h" #include "Queue.h"
#include "Graphics/Command.h" #include "Graphics/Command.h"
#include "Buffer.h" #include "Buffer.h"
#include <thread>
namespace Seele namespace Seele
{ {
+1 -1
View File
@@ -126,7 +126,7 @@ public:
DescriptorPool(PGraphics graphics, DescriptorLayout &layout); DescriptorPool(PGraphics graphics, DescriptorLayout &layout);
virtual ~DescriptorPool(); virtual ~DescriptorPool();
virtual Gfx::PDescriptorSet allocateDescriptorSet() override; virtual Gfx::PDescriptorSet allocateDescriptorSet() override;
virtual void reset(); virtual void reset() override;
constexpr VkDescriptorPool getHandle() const constexpr VkDescriptorPool getHandle() const
{ {
+1
View File
@@ -2,6 +2,7 @@
#include "Graphics/Enums.h" #include "Graphics/Enums.h"
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <iostream> #include <iostream>
#include <thread>
#define VK_CHECK(f) \ #define VK_CHECK(f) \
{ \ { \
+6 -6
View File
@@ -583,28 +583,28 @@ void Graphics::createDevice(GraphicsInitializer initializer)
cmdDrawMeshTasks = (PFN_vkCmdDrawMeshTasksEXT)vkGetDeviceProcAddr(handle, "vkCmdDrawMeshTasksEXT"); cmdDrawMeshTasks = (PFN_vkCmdDrawMeshTasksEXT)vkGetDeviceProcAddr(handle, "vkCmdDrawMeshTasksEXT");
graphicsQueue = new Queue(this, Gfx::QueueType::GRAPHICS, graphicsQueueInfo.familyIndex, 0); graphicsQueue = new Queue(this, graphicsQueueInfo.familyIndex, 0);
if (Gfx::useAsyncCompute && asyncComputeInfo.familyIndex != -1) if (Gfx::useAsyncCompute && asyncComputeInfo.familyIndex != -1)
{ {
if (asyncComputeInfo.familyIndex == graphicsQueueInfo.familyIndex) if (asyncComputeInfo.familyIndex == graphicsQueueInfo.familyIndex)
{ {
// Same family as graphics, but different queue // Same family as graphics, but different queue
computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeInfo.familyIndex, 1); computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 1);
} }
else else
{ {
// Different family // Different family
computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeInfo.familyIndex, 0); computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 0);
} }
} }
else else
{ {
computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, computeQueueInfo.familyIndex, 0); computeQueue = new Queue(this, computeQueueInfo.familyIndex, 0);
} }
transferQueue = new Queue(this, Gfx::QueueType::TRANSFER, transferQueueInfo.familyIndex, 0); transferQueue = new Queue(this, transferQueueInfo.familyIndex, 0);
if (dedicatedTransferQueueInfo.familyIndex != -1) if (dedicatedTransferQueueInfo.familyIndex != -1)
{ {
dedicatedTransferQueue = new Queue(this, Gfx::QueueType::DEDICATED_TRANSFER, dedicatedTransferQueueInfo.familyIndex, 0); dedicatedTransferQueue = new Queue(this, dedicatedTransferQueueInfo.familyIndex, 0);
} }
queueMapping.graphicsFamily = graphicsQueue->getFamilyIndex(); queueMapping.graphicsFamily = graphicsQueue->getFamilyIndex();
queueMapping.computeFamily = computeQueue->getFamilyIndex(); queueMapping.computeFamily = computeQueue->getFamilyIndex();
+1 -1
View File
@@ -36,7 +36,7 @@ PipelineCache::PipelineCache(PGraphics graphics, const std::string& cacheFilePat
PipelineCache::~PipelineCache() PipelineCache::~PipelineCache()
{ {
VkDeviceSize cacheSize; size_t cacheSize;
VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, nullptr)); VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, nullptr));
Array<uint8> cacheData(cacheSize); Array<uint8> cacheData(cacheSize);
VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, cacheData.data())); VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, cacheData.data()));
+1 -2
View File
@@ -6,10 +6,9 @@
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
Queue::Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex) Queue::Queue(PGraphics graphics, uint32 familyIndex, uint32 queueIndex)
: graphics(graphics) : graphics(graphics)
, familyIndex(familyIndex) , familyIndex(familyIndex)
, queueType(queueType)
{ {
vkGetDeviceQueue(graphics->getDevice(), familyIndex, queueIndex, &queue); vkGetDeviceQueue(graphics->getDevice(), familyIndex, queueIndex, &queue);
} }
+1 -2
View File
@@ -10,7 +10,7 @@ DECLARE_REF(Graphics)
class Queue class Queue
{ {
public: public:
Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex); Queue(PGraphics graphics, uint32 familyIndex, uint32 queueIndex);
virtual ~Queue(); virtual ~Queue();
void submitCommandBuffer(PCommand command, const Array<VkSemaphore>& signalSemaphore); void submitCommandBuffer(PCommand command, const Array<VkSemaphore>& signalSemaphore);
constexpr uint32 getFamilyIndex() const constexpr uint32 getFamilyIndex() const
@@ -27,7 +27,6 @@ private:
PGraphics graphics; PGraphics graphics;
VkQueue queue; VkQueue queue;
uint32 familyIndex; uint32 familyIndex;
Gfx::QueueType queueType;
}; };
DEFINE_REF(Queue) DEFINE_REF(Queue)
} // namespace Vulkan } // namespace Vulkan
+6 -6
View File
@@ -125,9 +125,9 @@ public:
protected: protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
}; };
DEFINE_REF(Texture2D) DEFINE_REF(Texture2D)
@@ -166,9 +166,9 @@ public:
protected: protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
}; };
DEFINE_REF(Texture3D) DEFINE_REF(Texture3D)
@@ -206,9 +206,9 @@ public:
virtual void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer) override; virtual void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer) override;
protected: protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
}; };
DEFINE_REF(TextureCube) DEFINE_REF(TextureCube)
} }
+1 -1
View File
@@ -23,7 +23,7 @@ public:
virtual void setMouseButtonCallback(std::function<void(MouseButton, InputAction, KeyModifier)> callback) override; virtual void setMouseButtonCallback(std::function<void(MouseButton, InputAction, KeyModifier)> callback) override;
virtual void setScrollCallback(std::function<void(double, double)> callback) override; virtual void setScrollCallback(std::function<void(double, double)> callback) override;
virtual void setFileCallback(std::function<void(int, const char**)> callback) override; virtual void setFileCallback(std::function<void(int, const char**)> callback) override;
virtual void setCloseCallback(std::function<void()> callback); virtual void setCloseCallback(std::function<void()> callback) override;
virtual void setResizeCallback(std::function<void(uint32, uint32)> callback) override; virtual void setResizeCallback(std::function<void(uint32, uint32)> callback) override;
void keyPress(KeyCode code, InputAction action, KeyModifier modifier); void keyPress(KeyCode code, InputAction action, KeyModifier modifier);
+1
View File
@@ -3,6 +3,7 @@
#include "MaterialInstance.h" #include "MaterialInstance.h"
#include "Graphics/Graphics.h" #include "Graphics/Graphics.h"
#include "Graphics/Shader.h" #include "Graphics/Shader.h"
#include <fstream>
using namespace Seele; using namespace Seele;
+14 -13
View File
@@ -4,7 +4,8 @@
#include "Asset/AssetRegistry.h" #include "Asset/AssetRegistry.h"
#include "Graphics/Graphics.h" #include "Graphics/Graphics.h"
#include "Graphics/Descriptor.h" #include "Graphics/Descriptor.h"
#include <format> #include <fstream>
#include <fmt/core.h>
using namespace Seele; using namespace Seele;
@@ -281,9 +282,9 @@ ConstantExpression::~ConstantExpression()
std::string ConstantExpression::evaluate(Map<std::string, std::string>& varState) const std::string ConstantExpression::evaluate(Map<std::string, std::string>& varState) const
{ {
std::string varName = std::format("const_exp_{}", key); std::string varName = fmt::format("const_exp_{}", key);
varState[key] = varName; varState[key] = varName;
return std::format("let {} = {};\n", varName, expr); return fmt::format("let {} = {};\n", varName, expr);
} }
void ConstantExpression::save(ArchiveBuffer& buffer) const void ConstantExpression::save(ArchiveBuffer& buffer) const
@@ -310,9 +311,9 @@ AddExpression::~AddExpression()
std::string AddExpression::evaluate(Map<std::string, std::string>& varState) const std::string AddExpression::evaluate(Map<std::string, std::string>& varState) const
{ {
std::string varName = std::format("exp_{}", key); std::string varName = fmt::format("exp_{}", key);
varState[key] = varName; varState[key] = varName;
return std::format("let {} = {} + {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); return fmt::format("let {} = {} + {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
} }
void AddExpression::save(ArchiveBuffer& buffer) const void AddExpression::save(ArchiveBuffer& buffer) const
@@ -327,9 +328,9 @@ void AddExpression::load(ArchiveBuffer& buffer)
std::string SubExpression::evaluate(Map<std::string, std::string>& varState) const std::string SubExpression::evaluate(Map<std::string, std::string>& varState) const
{ {
std::string varName = std::format("exp_{}", key); std::string varName = fmt::format("exp_{}", key);
varState[key] = varName; varState[key] = varName;
return std::format("let {} = {} - {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); return fmt::format("let {} = {} - {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
} }
void SubExpression::save(ArchiveBuffer& buffer) const void SubExpression::save(ArchiveBuffer& buffer) const
@@ -344,9 +345,9 @@ void SubExpression::load(ArchiveBuffer& buffer)
std::string MulExpression::evaluate(Map<std::string, std::string>& varState) const std::string MulExpression::evaluate(Map<std::string, std::string>& varState) const
{ {
std::string varName = std::format("exp_{}", key); std::string varName = fmt::format("exp_{}", key);
varState[key] = varName; varState[key] = varName;
return std::format("let {} = {} * {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); return fmt::format("let {} = {} * {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]);
} }
void MulExpression::save(ArchiveBuffer& buffer) const void MulExpression::save(ArchiveBuffer& buffer) const
@@ -361,7 +362,7 @@ void MulExpression::load(ArchiveBuffer& buffer)
std::string SwizzleExpression::evaluate(Map<std::string, std::string>& varState) const std::string SwizzleExpression::evaluate(Map<std::string, std::string>& varState) const
{ {
std::string varName = std::format("exp_{}", key); std::string varName = fmt::format("exp_{}", key);
std::string swizzle = ""; std::string swizzle = "";
for(uint32 i = 0; i < 4; ++i) for(uint32 i = 0; i < 4; ++i)
{ {
@@ -388,7 +389,7 @@ std::string SwizzleExpression::evaluate(Map<std::string, std::string>& varState)
} }
} }
varState[key] = varName; varState[key] = varName;
return std::format("let {} = {}.{};\n", varName, varState[inputs.at("target").source], swizzle); return fmt::format("let {} = {}.{};\n", varName, varState[inputs.at("target").source], swizzle);
} }
void SwizzleExpression::save(ArchiveBuffer& buffer) const void SwizzleExpression::save(ArchiveBuffer& buffer) const
@@ -405,9 +406,9 @@ void SwizzleExpression::load(ArchiveBuffer& buffer)
std::string SampleExpression::evaluate(Map<std::string, std::string>& varState) const std::string SampleExpression::evaluate(Map<std::string, std::string>& varState) const
{ {
std::string varName = std::format("exp_{}", key); std::string varName = fmt::format("exp_{}", key);
varState[key] = varName; varState[key] = varName;
return std::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source], varState[inputs.at("sampler").source], varState[inputs.at("coords").source]); return fmt::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source], varState[inputs.at("sampler").source], varState[inputs.at("coords").source]);
} }
void SampleExpression::save(ArchiveBuffer& buffer) const void SampleExpression::save(ArchiveBuffer& buffer) const
+9 -9
View File
@@ -58,10 +58,10 @@ struct ShaderParameter : public ShaderExpression
// update a descriptorset, in case of a uniform buffer, copy the data to the dst + byteOffset // update a descriptorset, in case of a uniform buffer, copy the data to the dst + byteOffset
virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) = 0; virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) = 0;
virtual void generateDeclaration(std::ofstream& stream) const = 0; virtual void generateDeclaration(std::ofstream& stream) const = 0;
virtual uint64 getIdentifier() const = 0; virtual uint64 getIdentifier() const override = 0;
virtual std::string evaluate(Map<std::string, std::string>& varState) const override; virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
virtual void save(ArchiveBuffer& buffer) const; virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer); virtual void load(ArchiveBuffer& buffer) override;
}; };
DEFINE_REF(ShaderParameter) DEFINE_REF(ShaderParameter)
struct FloatParameter : public ShaderParameter struct FloatParameter : public ShaderParameter
@@ -145,7 +145,7 @@ struct ConstantExpression : public ShaderExpression
ConstantExpression(); ConstantExpression();
ConstantExpression(std::string expr, ExpressionType type); ConstantExpression(std::string expr, ExpressionType type);
virtual ~ConstantExpression(); virtual ~ConstantExpression();
virtual uint64 getIdentifier() const { return IDENTIFIER; } virtual uint64 getIdentifier() const override { return IDENTIFIER; }
virtual std::string evaluate(Map<std::string, std::string>& varState) const override; virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
virtual void save(ArchiveBuffer& buffer) const override; virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer) override; virtual void load(ArchiveBuffer& buffer) override;
@@ -156,7 +156,7 @@ struct AddExpression : public ShaderExpression
static constexpr uint64 IDENTIFIER = 0x12; static constexpr uint64 IDENTIFIER = 0x12;
AddExpression(); AddExpression();
virtual ~AddExpression(); virtual ~AddExpression();
virtual uint64 getIdentifier() const { return IDENTIFIER; } virtual uint64 getIdentifier() const override { return IDENTIFIER; }
virtual std::string evaluate(Map<std::string, std::string>& varState) const override; virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
virtual void save(ArchiveBuffer& buffer) const override; virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer) override; virtual void load(ArchiveBuffer& buffer) override;
@@ -167,7 +167,7 @@ struct SubExpression : public ShaderExpression
static constexpr uint64 IDENTIFIER = 0x13; static constexpr uint64 IDENTIFIER = 0x13;
SubExpression() {} SubExpression() {}
virtual ~SubExpression() {} virtual ~SubExpression() {}
virtual uint64 getIdentifier() const { return IDENTIFIER; } virtual uint64 getIdentifier() const override { return IDENTIFIER; }
virtual std::string evaluate(Map<std::string, std::string>& varState) const override; virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
virtual void save(ArchiveBuffer& buffer) const override; virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer) override; virtual void load(ArchiveBuffer& buffer) override;
@@ -178,7 +178,7 @@ struct MulExpression : public ShaderExpression
static constexpr uint64 IDENTIFIER = 0x14; static constexpr uint64 IDENTIFIER = 0x14;
MulExpression() {} MulExpression() {}
virtual ~MulExpression() {} virtual ~MulExpression() {}
virtual uint64 getIdentifier() const { return IDENTIFIER; } virtual uint64 getIdentifier() const override { return IDENTIFIER; }
virtual std::string evaluate(Map<std::string, std::string>& varState) const override; virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
virtual void save(ArchiveBuffer& buffer) const override; virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer) override; virtual void load(ArchiveBuffer& buffer) override;
@@ -190,7 +190,7 @@ struct SwizzleExpression : public ShaderExpression
StaticArray<int32, 4> comp = {-1, -1, -1, -1}; StaticArray<int32, 4> comp = {-1, -1, -1, -1};
SwizzleExpression() {} SwizzleExpression() {}
virtual ~SwizzleExpression() {} virtual ~SwizzleExpression() {}
virtual uint64 getIdentifier() const { return IDENTIFIER; } virtual uint64 getIdentifier() const override { return IDENTIFIER; }
virtual std::string evaluate(Map<std::string, std::string>& varState) const override; virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
virtual void save(ArchiveBuffer& buffer) const override; virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer) override; virtual void load(ArchiveBuffer& buffer) override;
@@ -201,7 +201,7 @@ struct SampleExpression : public ShaderExpression
static constexpr uint64 IDENTIFIER = 0x16; static constexpr uint64 IDENTIFIER = 0x16;
SampleExpression() {} SampleExpression() {}
virtual ~SampleExpression() {} virtual ~SampleExpression() {}
virtual uint64 getIdentifier() const { return IDENTIFIER; } virtual uint64 getIdentifier() const override { return IDENTIFIER; }
virtual std::string evaluate(Map<std::string, std::string>& varState) const override; virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
virtual void save(ArchiveBuffer& buffer) const override; virtual void save(ArchiveBuffer& buffer) const override;
virtual void load(ArchiveBuffer& buffer) override; virtual void load(ArchiveBuffer& buffer) override;
+3 -2
View File
@@ -1,6 +1,7 @@
#include "Vector.h" #include "Vector.h"
#include <regex> #include <regex>
#include <format> #include <fmt/core.h>
#include <sstream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "Serialization/ArchiveBuffer.h" #include "Serialization/ArchiveBuffer.h"
@@ -8,7 +9,7 @@ using namespace Seele;
void to_json(nlohmann::json& j, const Vector& vec) void to_json(nlohmann::json& j, const Vector& vec)
{ {
j = nlohmann::json{std::format("({}, {}, {})", vec.x, vec.y, vec.z)}; j = nlohmann::json{fmt::format("({}, {}, {})", vec.x, vec.y, vec.z)};
} }
void from_json(const nlohmann::json& j, Vector& vec) void from_json(const nlohmann::json& j, Vector& vec)
+4 -1
View File
@@ -1,6 +1,9 @@
#pragma once #pragma once
#include "EngineTypes.h" #include "EngineTypes.h"
#include <map> #include <assert.h>
#include <cstddef>
#include <utility>
#include <memory>
#define DEFINE_REF(x) \ #define DEFINE_REF(x) \
typedef ::Seele::RefPtr<x> P##x; \ typedef ::Seele::RefPtr<x> P##x; \
+10 -1
View File
@@ -339,7 +339,16 @@ int32 BVH::splitNode(Array<AABBCenter> aabbs)
{ {
longestAxis = 2; longestAxis = 2;
} }
std::sort(aabbs.begin(), aabbs.end(), [longestAxis](AABBCenter lhs, AABBCenter rhs){ return lhs.center[longestAxis] < rhs.center[longestAxis];}); struct
{
bool operator()(const AABBCenter& lhs, const AABBCenter& rhs)
{
return lhs.center[longestAxis] < rhs.center[longestAxis];
}
int32 longestAxis;
} compare = {longestAxis};
std::sort(aabbs.begin(), aabbs.end(), compare);
Array<AABBCenter> left((aabbs.size()+1)/2); Array<AABBCenter> left((aabbs.size()+1)/2);
Array<AABBCenter> right(aabbs.size()/2); Array<AABBCenter> right(aabbs.size()/2);
std::copy(aabbs.begin(), aabbs.begin()+left.size(), left.begin()); std::copy(aabbs.begin(), aabbs.begin()+left.size(), left.begin());
+1
View File
@@ -1,5 +1,6 @@
#include "PhysicsSystem.h" #include "PhysicsSystem.h"
#include <random> #include <random>
#include <iostream>
using namespace Seele; using namespace Seele;
using namespace Seele::Component; using namespace Seele::Component;
+2
View File
@@ -1,5 +1,7 @@
if(WIN32) if(WIN32)
add_subdirectory(Windows/) add_subdirectory(Windows/)
elseif(APPLE)
add_subdirectory(Mac/)
else() else()
add_subdirectory(Linux/) add_subdirectory(Linux/)
endif() endif()
+2 -2
View File
@@ -18,7 +18,7 @@ Game* GameInterface::getGame()
return game; return game;
} }
void GameInterface::reload(AssetRegistry* registry) void GameInterface::reload()
{ {
if(lib != NULL) if(lib != NULL)
{ {
@@ -28,5 +28,5 @@ void GameInterface::reload(AssetRegistry* registry)
lib = dlopen(soPath.c_str(), RTLD_NOW); lib = dlopen(soPath.c_str(), RTLD_NOW);
createInstance = (decltype(createInstance))dlsym(lib, "createInstance"); createInstance = (decltype(createInstance))dlsym(lib, "createInstance");
destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance"); destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance");
game = createInstance(registry); game = createInstance();
} }
+2 -2
View File
@@ -10,12 +10,12 @@ public:
GameInterface(std::string soPath); GameInterface(std::string soPath);
~GameInterface(); ~GameInterface();
Game* getGame(); Game* getGame();
void reload(AssetRegistry* registry); void reload();
private: private:
void* lib; void* lib;
std::string soPath; std::string soPath;
Game* game; Game* game;
Game* (*createInstance)(AssetRegistry*) = nullptr; Game* (*createInstance)() = nullptr;
void (*destroyInstance)(Game*) = nullptr; void (*destroyInstance)(Game*) = nullptr;
}; };
} // namespace Seele } // namespace Seele
+10
View File
@@ -0,0 +1,10 @@
target_sources(Engine
PRIVATE
GameInterface.h
GameInterface.cpp)
target_sources(Engine
PUBLIC FILE_SET HEADERS
FILES
GameInterface.h)
+32
View File
@@ -0,0 +1,32 @@
#include "GameInterface.h"
using namespace Seele;
GameInterface::GameInterface(std::string soPath)
: lib(NULL)
, soPath(soPath)
{
}
GameInterface::~GameInterface()
{
}
Game* GameInterface::getGame()
{
return game;
}
void GameInterface::reload()
{
if(lib != NULL)
{
destroyInstance(game);
dlclose(lib);
}
lib = dlopen(soPath.c_str(), RTLD_NOW);
createInstance = (decltype(createInstance))dlsym(lib, "createInstance");
destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance");
game = createInstance();
}
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include "Game.h"
#include "dlfcn.h"
namespace Seele
{
class GameInterface
{
public:
GameInterface(std::string soPath);
~GameInterface();
Game* getGame();
void reload();
private:
void* lib;
std::string soPath;
Game* game;
Game* (*createInstance)() = nullptr;
void (*destroyInstance)(Game*) = nullptr;
};
} // namespace Seele
@@ -1,5 +1,7 @@
#include "ArchiveBuffer.h" #include "ArchiveBuffer.h"
#include "Graphics/Graphics.h" #include "Graphics/Graphics.h"
#include <ostream>
#include <istream>
using namespace Seele; using namespace Seele;
+1 -1
View File
@@ -40,7 +40,7 @@ public:
SystemBase::run(pool, delta); SystemBase::run(pool, delta);
setupView((getDependencies<Components>() | ...), pool); setupView((getDependencies<Components>() | ...), pool);
} }
virtual void update() {} virtual void update() override {}
virtual void update(Components&... components) = 0; virtual void update(Components&... components) = 0;
}; };
} // namespace System } // namespace System
+1 -1
View File
@@ -6,8 +6,8 @@ using namespace Seele;
View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &viewportInfo, std::string name) View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &viewportInfo, std::string name)
: graphics(graphics) : graphics(graphics)
, owner(window)
, createInfo(viewportInfo) , createInfo(viewportInfo)
, owner(window)
, name(name) , name(name)
{ {
viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo); viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo);
+1
View File
@@ -9,6 +9,7 @@
"glm", "glm",
"ktx", "ktx",
"nlohmann-json", "nlohmann-json",
"fmt",
"shader-slang", "shader-slang",
"gtest" "gtest"
] ]