Fixing staging buffers not getting deleted
remove vgcore
This commit is contained in:
Vendored
+24
@@ -24,5 +24,29 @@
|
|||||||
"traceResponse": true
|
"traceResponse": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Editor (Linux)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceRoot}/bin/Editor",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceRoot}/bin",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+8
-2
@@ -124,14 +124,20 @@ if(MSVC)
|
|||||||
Seele.natvis
|
Seele.natvis
|
||||||
DESTINATION .)
|
DESTINATION .)
|
||||||
else()
|
else()
|
||||||
target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-delete-incomplete -pedantic -std=c++20)
|
target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20 -Wno-missing-field-initializers -Wno-unused-function)
|
||||||
|
target_compile_options(Editor PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(src/)
|
add_subdirectory(src/)
|
||||||
|
|
||||||
|
set(COPY_DLL_COMMAND "true")
|
||||||
|
if(WIN32)
|
||||||
|
set(COPY_DLL_COMMAND "copy $<TARGET_RUNTIME_DLLS:Editor> $<TARGET_FILE_DIR:Engine>")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_target(SeeleEngine ALL
|
add_custom_target(SeeleEngine ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:Engine>
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:Engine>
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:Editor> $<TARGET_FILE_DIR:Engine>
|
COMMAND ${CMAKE_COMMAND} -E ${COPY_DLL_COMMAND}
|
||||||
COMMAND_EXPAND_LISTS
|
COMMAND_EXPAND_LISTS
|
||||||
DEPENDS Editor slang-build)
|
DEPENDS Editor slang-build)
|
||||||
|
|
||||||
|
|||||||
+39
-21
@@ -54,6 +54,10 @@ add_subdirectory(${GLFW_ROOT})
|
|||||||
add_subdirectory(${ENTT_ROOT})
|
add_subdirectory(${ENTT_ROOT})
|
||||||
|
|
||||||
#--------------thread-pool------------------------------
|
#--------------thread-pool------------------------------
|
||||||
|
set(TP_BUILD_TESTS OFF)
|
||||||
|
set(TP_BUILD_EXAMPLES OFF)
|
||||||
|
set(TP_BUILD_BENCHMARKS OFF)
|
||||||
|
|
||||||
add_subdirectory(${THREADPOOL_ROOT})
|
add_subdirectory(${THREADPOOL_ROOT})
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
@@ -63,39 +67,49 @@ endif()
|
|||||||
#--------------SLang------------------------------
|
#--------------SLang------------------------------
|
||||||
string(TOLOWER release_x64 SLANG_CONFIG)
|
string(TOLOWER release_x64 SLANG_CONFIG)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
string(TOLOWER ${SLANG_ROOT}/bin/windows-${CMAKE_PLATFORM}/release SLANG_BINARY_DIR)
|
string(TOLOWER ${SLANG_ROOT}/bin/windows-x64/release SLANG_BINARY_DIR)
|
||||||
ExternalProject_Add(slang-build
|
ExternalProject_Add(slang-build
|
||||||
SOURCE_DIR ${SLANG_ROOT}
|
SOURCE_DIR ${SLANG_ROOT}
|
||||||
BINARY_DIR ${SLANG_ROOT}
|
BINARY_DIR ${SLANG_ROOT}
|
||||||
CONFIGURE_COMMAND ${SLANG_ROOT}/premake.bat vs2019 --file=${SLANG_ROOT}/premake5.lua gmake --arch=x64 --deps=true
|
CONFIGURE_COMMAND ${SLANG_ROOT}/premake.bat vs2019 --file=${SLANG_ROOT}/premake5.lua gmake --arch=x64 --deps=true
|
||||||
BUILD_COMMAND msbuild slang.sln -p:PlatformToolset=v143 -p:Configuration=Release -p:Platform=${CMAKE_PLATFORM}
|
BUILD_COMMAND msbuild slang.sln -p:PlatformToolset=v143 -p:Configuration=Release -p:Platform=x64
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
)
|
)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
|
set(SLANG_BINARY_DIR ${SLANG_ROOT}/bin/linux-x64/release)
|
||||||
ExternalProject_Add(slang-build
|
ExternalProject_Add(slang-build
|
||||||
SOURCE_DIR ${SLANG_ROOT}
|
SOURCE_DIR ${SLANG_ROOT}
|
||||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
CONFIGURE_COMMAND ${CMAKE_SOURCE_DIR}/premake5 --file=${CMAKE_SOURCE_DIR}/external/slang/premake5.lua gmake2 --arch=x64 --deps=true --build-location=build/linux
|
CONFIGURE_COMMAND premake5 --file=${CMAKE_SOURCE_DIR}/external/slang/premake5.lua gmake2 --arch=x64 --deps=true --build-location=build/linux
|
||||||
BUILD_COMMAND make -C ${CMAKE_SOURCE_DIR}/external/slang/build/linux config=${SLANG_CONFIG}
|
BUILD_COMMAND make -C ${CMAKE_SOURCE_DIR}/external/slang/build/linux config=${SLANG_CONFIG}
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(slang-llvm SHARED IMPORTED)
|
add_library(slang-llvm SHARED IMPORTED)
|
||||||
target_link_libraries(slang-llvm INTERFACE
|
if(WIN32)
|
||||||
$<BUILD_INTERFACE:${SLANG_BINARY_DIR}/slang.lib>
|
target_link_libraries(slang-llvm INTERFACE
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/lib/slang.lib>
|
$<BUILD_INTERFACE:${SLANG_BINARY_DIR}/slang.lib>
|
||||||
)
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/lib/slang.lib>
|
||||||
set_target_properties(slang-llvm PROPERTIES IMPORTED_IMPLIB ${SLANG_BINARY_DIR}/slang.lib)
|
)
|
||||||
set_target_properties(slang-llvm PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/slang-llvm.dll)
|
set_target_properties(slang-llvm PROPERTIES IMPORTED_IMPLIB ${SLANG_BINARY_DIR}/slang.lib)
|
||||||
|
set_target_properties(slang-llvm PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/slang-llvm.dll)
|
||||||
|
else()
|
||||||
|
set_target_properties(slang-llvm PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/libslang-llvm.so)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(slang-glslang SHARED IMPORTED)
|
add_library(slang-glslang SHARED IMPORTED)
|
||||||
target_link_libraries(slang-glslang INTERFACE
|
|
||||||
$<BUILD_INTERFACE:${SLANG_BINARY_DIR}/slang.lib>
|
if(WIN32)
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/lib/slang.lib>
|
target_link_libraries(slang-glslang INTERFACE
|
||||||
)
|
$<BUILD_INTERFACE:${SLANG_BINARY_DIR}/slang.lib>
|
||||||
set_target_properties(slang-glslang PROPERTIES IMPORTED_IMPLIB ${SLANG_BINARY_DIR}/slang.lib)
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/lib/slang.lib>
|
||||||
set_target_properties(slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/slang-glslang.dll)
|
)
|
||||||
|
set_target_properties(slang-glslang PROPERTIES IMPORTED_IMPLIB ${SLANG_BINARY_DIR}/slang.lib)
|
||||||
|
set_target_properties(slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/slang-glslang.dll)
|
||||||
|
else()
|
||||||
|
set_target_properties(slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/libslang-glslang.so)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(slang SHARED IMPORTED)
|
add_library(slang SHARED IMPORTED)
|
||||||
|
|
||||||
@@ -103,14 +117,18 @@ target_include_directories(slang INTERFACE
|
|||||||
$<BUILD_INTERFACE:${SLANG_ROOT}/>
|
$<BUILD_INTERFACE:${SLANG_ROOT}/>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
target_link_libraries(slang INTERFACE
|
if(WIN32)
|
||||||
$<BUILD_INTERFACE:${SLANG_BINARY_DIR}/slang.lib>
|
target_link_libraries(slang INTERFACE
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/lib/slang.lib>
|
$<BUILD_INTERFACE:${SLANG_BINARY_DIR}/slang.lib>
|
||||||
)
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/lib/slang.lib>
|
||||||
|
)
|
||||||
|
set_target_properties(slang PROPERTIES IMPORTED_IMPLIB ${SLANG_BINARY_DIR}/slang.lib)
|
||||||
|
set_target_properties(slang PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/slang.dll)
|
||||||
|
else()
|
||||||
|
set_target_properties(slang PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/libslang.so)
|
||||||
|
endif()
|
||||||
target_link_libraries(slang INTERFACE slang-glslang)
|
target_link_libraries(slang INTERFACE slang-glslang)
|
||||||
target_link_libraries(slang INTERFACE slang-llvm)
|
target_link_libraries(slang INTERFACE slang-llvm)
|
||||||
set_target_properties(slang PROPERTIES IMPORTED_IMPLIB ${SLANG_BINARY_DIR}/slang.lib)
|
|
||||||
set_target_properties(slang PROPERTIES IMPORTED_LOCATION ${SLANG_BINARY_DIR}/slang.dll)
|
|
||||||
|
|
||||||
install(DIRECTORY
|
install(DIRECTORY
|
||||||
${SLANG_ROOT}
|
${SLANG_ROOT}
|
||||||
|
|||||||
Vendored
+1
-1
Submodule external/slang updated: 4547125ce9...cc222702a8
@@ -10,7 +10,7 @@ using namespace Seele;
|
|||||||
|
|
||||||
AssetRegistry * instance = new AssetRegistry();
|
AssetRegistry * instance = new AssetRegistry();
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
//if(argc < 2)
|
//if(argc < 2)
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
|||||||
|
|
||||||
uint32 uniformBufferOffset = 0;
|
uint32 uniformBufferOffset = 0;
|
||||||
uint32 bindingCounter = 0; // Uniform buffers are always binding 0
|
uint32 bindingCounter = 0; // Uniform buffers are always binding 0
|
||||||
uint32 uniformBinding = -1;
|
int32 uniformBinding = -1;
|
||||||
Map<std::string, OShaderExpression> expressions;
|
Map<std::string, OShaderExpression> expressions;
|
||||||
uint32 key = 0;
|
uint32 key = 0;
|
||||||
uint32 auxKey = 0;
|
uint32 auxKey = 0;
|
||||||
@@ -205,7 +205,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
|||||||
mat.profile = obj["profile"].get<std::string>();
|
mat.profile = obj["profile"].get<std::string>();
|
||||||
for(auto& val : obj["values"].items())
|
for(auto& val : obj["values"].items())
|
||||||
{
|
{
|
||||||
mat.variables[val.key()] = val.value();
|
mat.variables[val.key()] = referenceExpression(val.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +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 <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@@ -249,13 +250,16 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialAss
|
|||||||
idxInfo.sourceData.data = (uint8 *)indices.data();
|
idxInfo.sourceData.data = (uint8 *)indices.data();
|
||||||
idxInfo.sourceData.owner = Gfx::QueueType::DEDICATED_TRANSFER;
|
idxInfo.sourceData.owner = Gfx::QueueType::DEDICATED_TRANSFER;
|
||||||
idxInfo.sourceData.size = sizeof(uint32) * indices.size();
|
idxInfo.sourceData.size = sizeof(uint32) * indices.size();
|
||||||
Gfx::PIndexBuffer indexBuffer = graphics->createIndexBuffer(idxInfo);
|
Gfx::OIndexBuffer indexBuffer = graphics->createIndexBuffer(idxInfo);
|
||||||
indexBuffer->transferOwnership(Gfx::QueueType::GRAPHICS);
|
indexBuffer->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||||
|
|
||||||
globalMeshes[meshIndex] = new Mesh();
|
globalMeshes[meshIndex] = new Mesh();
|
||||||
globalMeshes[meshIndex]->vertexData = vertexData;
|
globalMeshes[meshIndex]->vertexData = vertexData;
|
||||||
globalMeshes[meshIndex]->id = id;
|
globalMeshes[meshIndex]->id = id;
|
||||||
globalMeshes[meshIndex]->referencedMaterial = materials[mesh->mMaterialIndex]->getMaterial()->instantiate();
|
globalMeshes[meshIndex]->referencedMaterial = materials[mesh->mMaterialIndex]->instantiate(InstantiationParameter{
|
||||||
|
.name = std::format("{0}_Inst_0", materials[mesh->mMaterialIndex]->getName()),
|
||||||
|
.folderPath = materials[mesh->mMaterialIndex]->getFolderPath(),
|
||||||
|
});
|
||||||
globalMeshes[meshIndex]->meshlets = std::move(meshlets);
|
globalMeshes[meshIndex]->meshlets = std::move(meshlets);
|
||||||
globalMeshes[meshIndex]->vertexCount = mesh->mNumVertices;
|
globalMeshes[meshIndex]->vertexCount = mesh->mNumVertices;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,15 @@
|
|||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
#include "Asset/AssetRegistry.h"
|
#include "Asset/AssetRegistry.h"
|
||||||
#include "Graphics/Vulkan/Enums.h"
|
#include "Graphics/Vulkan/Enums.h"
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
#include <stb_image_write.h>
|
#include <stb_image_write.h>
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
#include "ktx.h"
|
#include "ktx.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
@@ -17,7 +22,7 @@ TextureLoader::TextureLoader(Gfx::PGraphics graphics)
|
|||||||
OTextureAsset placeholder = new TextureAsset();
|
OTextureAsset placeholder = new TextureAsset();
|
||||||
placeholderAsset = placeholder;
|
placeholderAsset = placeholder;
|
||||||
import(TextureImportArgs{
|
import(TextureImportArgs{
|
||||||
.filePath = std::filesystem::absolute("./textures/placeholder.png"),
|
.filePath = std::filesystem::absolute("textures/placeholder.png"),
|
||||||
.importPath = "",
|
.importPath = "",
|
||||||
}, placeholderAsset);
|
}, placeholderAsset);
|
||||||
AssetRegistry::get().assetRoot->textures[""] = std::move(placeholder);
|
AssetRegistry::get().assetRoot->textures[""] = std::move(placeholder);
|
||||||
@@ -46,10 +51,9 @@ PTextureAsset TextureLoader::getPlaceholderTexture()
|
|||||||
|
|
||||||
void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
|
void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
|
||||||
{
|
{
|
||||||
|
int totalWidth = 0, totalHeight = 0, n = 0;
|
||||||
int totalWidth, totalHeight, n;
|
|
||||||
unsigned char* data = stbi_load(args.filePath.string().c_str(), &totalWidth, &totalHeight, &n, 4);
|
unsigned char* data = stbi_load(args.filePath.string().c_str(), &totalWidth, &totalHeight, &n, 4);
|
||||||
ktxTexture2* kTexture;
|
ktxTexture2* kTexture = nullptr;
|
||||||
ktxTextureCreateInfo createInfo;
|
ktxTextureCreateInfo createInfo;
|
||||||
createInfo.vkFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
createInfo.vkFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
createInfo.baseDepth = 1;
|
createInfo.baseDepth = 1;
|
||||||
@@ -61,7 +65,7 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
|
|||||||
if (args.type == TextureImportType::TEXTURE_CUBEMAP)
|
if (args.type == TextureImportType::TEXTURE_CUBEMAP)
|
||||||
{
|
{
|
||||||
uint32 faceWidth = totalWidth / 4;
|
uint32 faceWidth = totalWidth / 4;
|
||||||
uint32 faceHeight = totalHeight / 3;
|
// uint32 faceHeight = totalHeight / 3;
|
||||||
// Cube map
|
// Cube map
|
||||||
createInfo.baseWidth = totalWidth / 4;
|
createInfo.baseWidth = totalWidth / 4;
|
||||||
createInfo.baseHeight = totalHeight / 3;
|
createInfo.baseHeight = totalHeight / 3;
|
||||||
@@ -75,9 +79,9 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
|
|||||||
auto loadCubeFace = [&kTexture, &faceWidth, &totalWidth, &data](int xPos, int yPos, int faceName)
|
auto loadCubeFace = [&kTexture, &faceWidth, &totalWidth, &data](int xPos, int yPos, int faceName)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> vec(faceWidth * faceWidth * 4);
|
std::vector<unsigned char> vec(faceWidth * faceWidth * 4);
|
||||||
for (int y = 0; y < faceWidth; ++y)
|
for (uint32 y = 0; y < faceWidth; ++y)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < faceWidth; ++x)
|
for (uint32 x = 0; x < faceWidth; ++x)
|
||||||
{
|
{
|
||||||
int imgX = x + (xPos * faceWidth);
|
int imgX = x + (xPos * faceWidth);
|
||||||
int imgY = y + (yPos * faceWidth);
|
int imgY = y + (yPos * faceWidth);
|
||||||
@@ -114,7 +118,7 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
|
|||||||
.structSize = sizeof(ktxBasisParams),
|
.structSize = sizeof(ktxBasisParams),
|
||||||
.uastc = false,
|
.uastc = false,
|
||||||
.threadCount = std::thread::hardware_concurrency(),
|
.threadCount = std::thread::hardware_concurrency(),
|
||||||
.compressionLevel = 5,
|
.compressionLevel = 0,
|
||||||
.qualityLevel = 0,
|
.qualityLevel = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using namespace Seele;
|
|||||||
using namespace Seele::Editor;
|
using namespace Seele::Editor;
|
||||||
|
|
||||||
PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath)
|
PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath)
|
||||||
: GameView(std::move(graphics), std::move(window), std::move(createInfo), dllPath)
|
: GameView(graphics, window, createInfo, dllPath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,15 +60,11 @@ void SceneView::render()
|
|||||||
renderGraph.render(viewportCamera);
|
renderGraph.render(viewportCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float cameraSpeed = 1;
|
|
||||||
|
|
||||||
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
||||||
{
|
{
|
||||||
cameraSystem.keyCallback(code, action);
|
cameraSystem.keyCallback(code, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mouseDown = false;
|
|
||||||
|
|
||||||
void SceneView::mouseMoveCallback(double xPos, double yPos)
|
void SceneView::mouseMoveCallback(double xPos, double yPos)
|
||||||
{
|
{
|
||||||
cameraSystem.mouseMoveCallback(xPos, yPos);
|
cameraSystem.mouseMoveCallback(xPos, yPos);
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ ViewportControl::ViewportControl(const URect& viewportDimensions, Vector initial
|
|||||||
: position(initialPos)
|
: position(initialPos)
|
||||||
, fieldOfView(glm::radians(70.f))
|
, fieldOfView(glm::radians(70.f))
|
||||||
, aspectRatio(static_cast<float>(viewportDimensions.size.x) / viewportDimensions.size.y)
|
, aspectRatio(static_cast<float>(viewportDimensions.size.x) / viewportDimensions.size.y)
|
||||||
, yaw(glm::pi<float>()/-2.0f)
|
|
||||||
, pitch(0)
|
, pitch(0)
|
||||||
|
, yaw(glm::pi<float>()/-2.0f)
|
||||||
{
|
{
|
||||||
std::cout << yaw << " " << pitch << std::endl;
|
std::cout << yaw << " " << pitch << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
+71
-63
@@ -12,6 +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>
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Editor;
|
using namespace Seele::Editor;
|
||||||
@@ -20,11 +21,17 @@ extern AssetRegistry* instance;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::string outputPath = "C:/Users/Dynamitos/TrackClearGame";
|
#ifdef WIN32
|
||||||
std::string cmakePath = "C:/Users/Dynamitos/TrackClearGame/cmake";
|
std::filesystem::path outputPath = "C:/Users/Dynamitos/TrackClearGame";
|
||||||
|
std::filesystem::path sourcePath= "C:/Users/Dynamitos/TrackClear";
|
||||||
|
std::filesystem::path binaryPath = sourcePath / "bin" / "TrackClear.dll";
|
||||||
|
#else
|
||||||
|
std::filesystem::path outputPath = "/home/dynamitos/TrackClearGame";
|
||||||
|
std::filesystem::path sourcePath= "/home/dynamitos/TrackClear";
|
||||||
|
std::filesystem::path binaryPath = sourcePath / "cmake" / "libTrackClear.so";
|
||||||
|
#endif
|
||||||
std::string gameName = "TrackClear";
|
std::string gameName = "TrackClear";
|
||||||
std::string sourcePath = "C:/Users/Dynamitos/TrackClear/";
|
std::filesystem::path cmakePath = outputPath / "cmake";
|
||||||
std::string binaryPath = "C:/Users/Dynamitos/TrackClear/bin/TrackClear.dll";
|
|
||||||
|
|
||||||
Gfx::OGraphics graphics = new Vulkan::Graphics();
|
Gfx::OGraphics graphics = new Vulkan::Graphics();
|
||||||
|
|
||||||
@@ -33,177 +40,177 @@ int main()
|
|||||||
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
|
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
|
||||||
vd->init(graphics);
|
vd->init(graphics);
|
||||||
PWindowManager windowManager = new WindowManager();
|
PWindowManager windowManager = new WindowManager();
|
||||||
AssetRegistry::init(std::string("C:/Users/Dynamitos/TrackClear/Assets"), graphics);
|
AssetRegistry::init(sourcePath / "Assets", graphics);
|
||||||
AssetImporter::init(graphics, AssetRegistry::getInstance());
|
AssetImporter::init(graphics, AssetRegistry::getInstance());
|
||||||
AssetImporter::importFont(FontImportArgs{
|
AssetImporter::importFont(FontImportArgs{
|
||||||
.filePath = "./fonts/Calibri.ttf",
|
.filePath = "./fonts/Calibri.ttf",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/arena.fbx",
|
.filePath = sourcePath / "old_resources/models/arena.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/train.fbx",
|
.filePath = sourcePath / "old_resources/models/train.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/bird.fbx",
|
.filePath= sourcePath / "old_resources/models/bird.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/cube.fbx",
|
.filePath= sourcePath / "old_resources/models/cube.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/flameThrower.fbx",
|
.filePath= sourcePath / "old_resources/models/flameThrower.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/player.fbx",
|
.filePath= sourcePath / "old_resources/models/player.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/shotgun.fbx",
|
.filePath= sourcePath / "old_resources/models/shotgun.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/track.fbx",
|
.filePath= sourcePath / "old_resources/models/track.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/models/zombie.fbx",
|
.filePath= sourcePath / "old_resources/models/zombie.fbx",
|
||||||
});
|
});
|
||||||
|
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Dirt.png",
|
.filePath= sourcePath / "old_resources/textures/Dirt.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/DirtGrass.png",
|
.filePath= sourcePath / "old_resources/textures/DirtGrass.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Grass.png",
|
.filePath= sourcePath / "old_resources/textures/Grass.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Ice.png",
|
.filePath= sourcePath / "old_resources/textures/Ice.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Lava.png",
|
.filePath= sourcePath / "old_resources/textures/Lava.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Obsidian.png",
|
.filePath= sourcePath / "old_resources/textures/Obsidian.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Rocks.png",
|
.filePath= sourcePath / "old_resources/textures/Rocks.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Sand.png",
|
.filePath= sourcePath / "old_resources/textures/Sand.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Water.png",
|
.filePath= sourcePath / "old_resources/textures/Water.png",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/Wood.png",
|
.filePath= sourcePath / "old_resources/textures/Wood.png",
|
||||||
});
|
});
|
||||||
|
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level0/blendMap.png",
|
.filePath= sourcePath / "old_resources/textures/level0/blendMap.png",
|
||||||
.importPath = "level0",
|
.importPath = "level0",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level0/heightMap.png",
|
.filePath= sourcePath / "old_resources/textures/level0/heightMap.png",
|
||||||
.importPath = "level0",
|
.importPath = "level0",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level0/trackMap.png",
|
.filePath= sourcePath / "old_resources/textures/level0/trackMap.png",
|
||||||
.importPath = "level0",
|
.importPath = "level0",
|
||||||
});
|
});
|
||||||
AssetImporter::importMaterial(MaterialImportArgs{
|
AssetImporter::importMaterial(MaterialImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/shaders/TerrainMaterial.json",
|
.filePath= sourcePath / "old_resources/shaders/TerrainMaterial.json",
|
||||||
.importPath = "level0",
|
.importPath = "level0",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level1/blendMap.png",
|
.filePath= sourcePath / "old_resources/textures/level1/blendMap.png",
|
||||||
.importPath = "level1",
|
.importPath = "level1",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level1/heightMap.png",
|
.filePath= sourcePath / "old_resources/textures/level1/heightMap.png",
|
||||||
.importPath = "level1",
|
.importPath = "level1",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level1/trackMap.png",
|
.filePath= sourcePath / "old_resources/textures/level1/trackMap.png",
|
||||||
.importPath = "level1",
|
.importPath = "level1",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level2/blendMap.png",
|
.filePath= sourcePath / "old_resources/textures/level2/blendMap.png",
|
||||||
.importPath = "level2",
|
.importPath = "level2",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level2/heightMap.png",
|
.filePath= sourcePath / "old_resources/textures/level2/heightMap.png",
|
||||||
.importPath = "level2",
|
.importPath = "level2",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level2/trackMap.png",
|
.filePath= sourcePath / "old_resources/textures/level2/trackMap.png",
|
||||||
.importPath = "level2",
|
.importPath = "level2",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level3/blendMap.png",
|
.filePath= sourcePath / "old_resources/textures/level3/blendMap.png",
|
||||||
.importPath = "level3",
|
.importPath = "level3",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level3/heightMap.png",
|
.filePath= sourcePath / "old_resources/textures/level3/heightMap.png",
|
||||||
.importPath = "level3",
|
.importPath = "level3",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level3/trackMap.png",
|
.filePath= sourcePath / "old_resources/textures/level3/trackMap.png",
|
||||||
.importPath = "level3",
|
.importPath = "level3",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level4/blendMap.png",
|
.filePath= sourcePath / "old_resources/textures/level4/blendMap.png",
|
||||||
.importPath = "level4",
|
.importPath = "level4",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level4/heightMap.png",
|
.filePath= sourcePath / "old_resources/textures/level4/heightMap.png",
|
||||||
.importPath = "level4",
|
.importPath = "level4",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level4/trackMap.png",
|
.filePath= sourcePath / "old_resources/textures/level4/trackMap.png",
|
||||||
.importPath = "level4",
|
.importPath = "level4",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level5/blendMap.png",
|
.filePath= sourcePath / "old_resources/textures/level5/blendMap.png",
|
||||||
.importPath = "level5",
|
.importPath = "level5",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level5/heightMap.png",
|
.filePath= sourcePath / "old_resources/textures/level5/heightMap.png",
|
||||||
.importPath = "level5",
|
.importPath = "level5",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level5/trackMap.png",
|
.filePath= sourcePath / "old_resources/textures/level5/trackMap.png",
|
||||||
.importPath = "level5",
|
.importPath = "level5",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level6/blendMap.png",
|
.filePath= sourcePath / "old_resources/textures/level6/blendMap.png",
|
||||||
.importPath = "level6",
|
.importPath = "level6",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level6/heightMap.png",
|
.filePath= sourcePath / "old_resources/textures/level6/heightMap.png",
|
||||||
.importPath = "level6",
|
.importPath = "level6",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level6/trackMap.png",
|
.filePath= sourcePath / "old_resources/textures/level6/trackMap.png",
|
||||||
.importPath = "level6",
|
.importPath = "level6",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level7/blendMap.png",
|
.filePath= sourcePath / "old_resources/textures/level7/blendMap.png",
|
||||||
.importPath = "level7",
|
.importPath = "level7",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level7/heightMap.png",
|
.filePath= sourcePath / "old_resources/textures/level7/heightMap.png",
|
||||||
.importPath = "level7",
|
.importPath = "level7",
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/textures/level7/trackMap.png",
|
.filePath= sourcePath / "old_resources/textures/level7/trackMap.png",
|
||||||
.importPath = "level7",
|
.importPath = "level7",
|
||||||
});
|
});
|
||||||
|
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/skyboxes/FS000_Day_01.png",
|
.filePath= sourcePath / "old_resources/skyboxes/FS000_Day_01.png",
|
||||||
.type = TextureImportType::TEXTURE_CUBEMAP,
|
.type = TextureImportType::TEXTURE_CUBEMAP,
|
||||||
});
|
});
|
||||||
AssetImporter::importTexture(TextureImportArgs{
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
.filePath = "C:/Users/Dynamitos/TrackClear/old_resources/skyboxes/FS000_Night_01.png",
|
.filePath= sourcePath / "old_resources/skyboxes/FS000_Night_01.png",
|
||||||
.type = TextureImportType::TEXTURE_CUBEMAP,
|
.type = TextureImportType::TEXTURE_CUBEMAP,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -220,7 +227,7 @@ int main()
|
|||||||
sceneViewInfo.dimensions.size.y = 720;
|
sceneViewInfo.dimensions.size.y = 720;
|
||||||
sceneViewInfo.dimensions.offset.x = 0;
|
sceneViewInfo.dimensions.offset.x = 0;
|
||||||
sceneViewInfo.dimensions.offset.y = 0;
|
sceneViewInfo.dimensions.offset.y = 0;
|
||||||
PGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath);
|
OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath);
|
||||||
|
|
||||||
//ViewportCreateInfo inspectorViewInfo;
|
//ViewportCreateInfo inspectorViewInfo;
|
||||||
//inspectorViewInfo.dimensions.size.x = 640;
|
//inspectorViewInfo.dimensions.size.x = 640;
|
||||||
@@ -235,16 +242,17 @@ int main()
|
|||||||
//export game
|
//export game
|
||||||
|
|
||||||
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, binaryPath).c_str());
|
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(std::format("cmake -S {} -B {}", cmakePath, cmakePath).c_str());
|
std::system(std::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str());
|
||||||
std::system(std::format("cmake --build {}", cmakePath).c_str());
|
std::system(std::format("cmake --build {}", cmakePath.generic_string()).c_str());
|
||||||
std::filesystem::copy(std::filesystem::path(sourcePath) / "Assets", std::filesystem::path(outputPath) / "Assets", std::filesystem::copy_options::recursive);
|
std::filesystem::copy(sourcePath / "Assets", outputPath / "Assets", std::filesystem::copy_options::recursive);
|
||||||
std::filesystem::copy("shaders", std::filesystem::path(outputPath) / "shaders", std::filesystem::copy_options::recursive);
|
std::filesystem::copy("shaders", outputPath / "shaders", std::filesystem::copy_options::recursive);
|
||||||
std::filesystem::copy("textures", std::filesystem::path(outputPath) / "textures", std::filesystem::copy_options::recursive);
|
std::filesystem::copy("textures", outputPath / "textures", std::filesystem::copy_options::recursive);
|
||||||
std::filesystem::copy_file("assimp-vc143-mt.dll", std::filesystem::path(outputPath) / "assimp-vc143-mt.dll");
|
#ifdef WIN32
|
||||||
std::filesystem::copy_file("slang.dll", std::filesystem::path(outputPath) / "slang.dll");
|
std::filesystem::copy_file("assimp-vc143-mt.dll", outputPath / "assimp-vc143-mt.dll");
|
||||||
std::filesystem::copy_file("slang-glslang.dll", std::filesystem::path(outputPath) / "slang-glslang.dll");
|
std::filesystem::copy_file("slang.dll", outputPath / "slang.dll");
|
||||||
std::filesystem::copy_file("slang-llvm.dll", std::filesystem::path(outputPath) / "slang-llvm.dll");
|
std::filesystem::copy_file("slang-glslang.dll", outputPath / "slang-glslang.dll");
|
||||||
|
std::filesystem::copy_file("slang-llvm.dll", outputPath / "slang-llvm.dll");
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
Entity::Entity(PScene scene)
|
Entity::Entity(PScene scene)
|
||||||
: identifier(scene->createEntity())
|
: scene(scene)
|
||||||
, scene(scene)
|
, identifier(scene->createEntity())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ Asset::Asset()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
Asset::Asset(std::string_view _folderPath, std::string_view _name)
|
Asset::Asset(std::string_view _folderPath, std::string_view _name)
|
||||||
: status(Status::Uninitialized)
|
: folderPath(_folderPath)
|
||||||
, folderPath(_folderPath)
|
|
||||||
, name(_name)
|
, name(_name)
|
||||||
|
, status(Status::Uninitialized)
|
||||||
{
|
{
|
||||||
if (folderPath.empty())
|
if (folderPath.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ PMeshAsset AssetRegistry::findMesh(const std::string &filePath)
|
|||||||
AssetFolder* folder = get().assetRoot;
|
AssetFolder* folder = get().assetRoot;
|
||||||
std::string fileName = filePath;
|
std::string fileName = filePath;
|
||||||
size_t slashLoc = filePath.rfind("/");
|
size_t slashLoc = filePath.rfind("/");
|
||||||
if(slashLoc != -1)
|
if(slashLoc != std::string::npos)
|
||||||
{
|
{
|
||||||
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
||||||
fileName = filePath.substr(slashLoc+1, filePath.size());
|
fileName = filePath.substr(slashLoc+1, filePath.size());
|
||||||
@@ -44,7 +44,7 @@ PTextureAsset AssetRegistry::findTexture(const std::string &filePath)
|
|||||||
AssetFolder* folder = get().assetRoot;
|
AssetFolder* folder = get().assetRoot;
|
||||||
std::string fileName = filePath;
|
std::string fileName = filePath;
|
||||||
size_t slashLoc = filePath.rfind("/");
|
size_t slashLoc = filePath.rfind("/");
|
||||||
if (slashLoc != -1)
|
if (slashLoc != std::string::npos)
|
||||||
{
|
{
|
||||||
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
||||||
fileName = filePath.substr(slashLoc + 1, filePath.size());
|
fileName = filePath.substr(slashLoc + 1, filePath.size());
|
||||||
@@ -57,7 +57,7 @@ PFontAsset AssetRegistry::findFont(const std::string& filePath)
|
|||||||
AssetFolder* folder = get().assetRoot;
|
AssetFolder* folder = get().assetRoot;
|
||||||
std::string fileName = filePath;
|
std::string fileName = filePath;
|
||||||
size_t slashLoc = filePath.rfind("/");
|
size_t slashLoc = filePath.rfind("/");
|
||||||
if(slashLoc != -1)
|
if(slashLoc != std::string::npos)
|
||||||
{
|
{
|
||||||
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
||||||
fileName = filePath.substr(slashLoc+1, filePath.size());
|
fileName = filePath.substr(slashLoc+1, filePath.size());
|
||||||
@@ -70,7 +70,7 @@ PMaterialAsset AssetRegistry::findMaterial(const std::string &filePath)
|
|||||||
AssetFolder* folder = get().assetRoot;
|
AssetFolder* folder = get().assetRoot;
|
||||||
std::string fileName = filePath;
|
std::string fileName = filePath;
|
||||||
size_t slashLoc = filePath.rfind("/");
|
size_t slashLoc = filePath.rfind("/");
|
||||||
if (slashLoc != -1)
|
if (slashLoc != std::string::npos)
|
||||||
{
|
{
|
||||||
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
||||||
fileName = filePath.substr(slashLoc + 1, filePath.size());
|
fileName = filePath.substr(slashLoc + 1, filePath.size());
|
||||||
@@ -78,6 +78,19 @@ PMaterialAsset AssetRegistry::findMaterial(const std::string &filePath)
|
|||||||
return folder->materials.at(fileName);
|
return folder->materials.at(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PMaterialInstanceAsset AssetRegistry::findMaterialInstance(const std::string &filePath)
|
||||||
|
{
|
||||||
|
AssetFolder* folder = get().assetRoot;
|
||||||
|
std::string fileName = filePath;
|
||||||
|
size_t slashLoc = filePath.rfind("/");
|
||||||
|
if (slashLoc != std::string::npos)
|
||||||
|
{
|
||||||
|
folder = get().getOrCreateFolder(filePath.substr(0, slashLoc));
|
||||||
|
fileName = filePath.substr(slashLoc + 1, filePath.size());
|
||||||
|
}
|
||||||
|
return folder->instances.at(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
std::ofstream AssetRegistry::createWriteStream(const std::filesystem::path& relativePath, std::ios_base::openmode openmode)
|
std::ofstream AssetRegistry::createWriteStream(const std::filesystem::path& relativePath, std::ios_base::openmode openmode)
|
||||||
{
|
{
|
||||||
return get().internalCreateWriteStream(relativePath, openmode);
|
return get().internalCreateWriteStream(relativePath, openmode);
|
||||||
@@ -356,7 +369,7 @@ AssetRegistry::AssetFolder* AssetRegistry::getOrCreateFolder(std::string fullPat
|
|||||||
while(!fullPath.empty())
|
while(!fullPath.empty())
|
||||||
{
|
{
|
||||||
size_t slashLoc = fullPath.find("/");
|
size_t slashLoc = fullPath.find("/");
|
||||||
if(slashLoc == -1)
|
if(slashLoc == std::string::npos)
|
||||||
{
|
{
|
||||||
if (!result->children.contains(fullPath))
|
if (!result->children.contains(fullPath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ private:
|
|||||||
Gfx::PGraphics graphics;
|
Gfx::PGraphics graphics;
|
||||||
ArchiveBuffer assetBuffer;
|
ArchiveBuffer assetBuffer;
|
||||||
bool release = false;
|
bool release = false;
|
||||||
|
friend class MaterialAsset;
|
||||||
friend class TextureLoader;
|
friend class TextureLoader;
|
||||||
friend class FontLoader;
|
friend class FontLoader;
|
||||||
friend class MaterialLoader;
|
friend class MaterialLoader;
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ void FontAsset::save(ArchiveBuffer& buffer) const
|
|||||||
Array<uint8> textureData;
|
Array<uint8> textureData;
|
||||||
ktxTexture2* kTexture;
|
ktxTexture2* kTexture;
|
||||||
ktxTextureCreateInfo createInfo = {
|
ktxTextureCreateInfo createInfo = {
|
||||||
|
.glInternalformat = 0,
|
||||||
.vkFormat = (uint32_t)glyph.texture->getFormat(),
|
.vkFormat = (uint32_t)glyph.texture->getFormat(),
|
||||||
|
.pDfd = nullptr,
|
||||||
.baseWidth = glyph.texture->getSizeX(),
|
.baseWidth = glyph.texture->getSizeX(),
|
||||||
.baseHeight = glyph.texture->getSizeY(),
|
.baseHeight = glyph.texture->getSizeY(),
|
||||||
.baseDepth = glyph.texture->getSizeZ(),
|
.baseDepth = glyph.texture->getSizeZ(),
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ LevelAsset::~LevelAsset()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelAsset::save(ArchiveBuffer& buffer) const
|
void LevelAsset::save(ArchiveBuffer&) const
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelAsset::load(ArchiveBuffer& buffer)
|
void LevelAsset::load(ArchiveBuffer&)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Material/Material.h"
|
#include "Material/Material.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
#include "MaterialInstanceAsset.h"
|
#include "MaterialInstanceAsset.h"
|
||||||
|
#include "Asset/AssetRegistry.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
@@ -30,13 +31,15 @@ void MaterialAsset::load(ArchiveBuffer& buffer)
|
|||||||
material->compile();
|
material->compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
OMaterialInstanceAsset Seele::MaterialAsset::instantiate(const InstantiationParameter& params)
|
PMaterialInstanceAsset MaterialAsset::instantiate(const InstantiationParameter& params)
|
||||||
{
|
{
|
||||||
OMaterialInstance instance = material->instantiate();
|
OMaterialInstance instance = material->instantiate();
|
||||||
instance->setBaseMaterial(this);
|
instance->setBaseMaterial(this);
|
||||||
OMaterialInstanceAsset asset = new MaterialInstanceAsset(params.folderPath, params.name);
|
OMaterialInstanceAsset asset = new MaterialInstanceAsset(params.folderPath, params.name);
|
||||||
asset->setHandle(std::move(instance));
|
asset->setHandle(std::move(instance));
|
||||||
return asset;
|
asset->setBase(this);
|
||||||
|
PMaterialInstanceAsset ref = asset;
|
||||||
|
AssetRegistry::get().saveAsset(ref, MaterialInstanceAsset::IDENTIFIER, ref->getFolderPath(), ref->getName());
|
||||||
|
AssetRegistry::get().registerMaterialInstance(std::move(asset));
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
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;
|
||||||
PMaterial getMaterial() const { return material; }
|
PMaterial getMaterial() const { return material; }
|
||||||
OMaterialInstanceAsset instantiate(const InstantiationParameter& params);
|
PMaterialInstanceAsset instantiate(const InstantiationParameter& params);
|
||||||
private:
|
private:
|
||||||
OMaterial material;
|
OMaterial material;
|
||||||
friend class MaterialLoader;
|
friend class MaterialLoader;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public:
|
|||||||
virtual void load(ArchiveBuffer& buffer) override;
|
virtual void load(ArchiveBuffer& buffer) override;
|
||||||
void setHandle(OMaterialInstance handle) { material = std::move(handle); }
|
void setHandle(OMaterialInstance handle) { material = std::move(handle); }
|
||||||
void setBase(PMaterialAsset base) { baseMaterial = base; }
|
void setBase(PMaterialAsset base) { baseMaterial = base; }
|
||||||
|
PMaterialInstance getHandle() const { return material; }
|
||||||
private:
|
private:
|
||||||
OMaterialInstance material;
|
OMaterialInstance material;
|
||||||
PMaterialAsset baseMaterial;
|
PMaterialAsset baseMaterial;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ MeshAsset::~MeshAsset()
|
|||||||
void MeshAsset::save(ArchiveBuffer& buffer) const
|
void MeshAsset::save(ArchiveBuffer& buffer) const
|
||||||
{
|
{
|
||||||
Serialization::save(buffer, meshes);
|
Serialization::save(buffer, meshes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshAsset::load(ArchiveBuffer& buffer)
|
void MeshAsset::load(ArchiveBuffer& buffer)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
#include "Window/WindowManager.h"
|
#include "Window/WindowManager.h"
|
||||||
#include "Graphics/Vulkan/Enums.h"
|
#include "Graphics/Vulkan/Enums.h"
|
||||||
|
#include "Graphics/Texture.h"
|
||||||
#include "ktx.h"
|
#include "ktx.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
@@ -22,7 +23,7 @@ TextureAsset::~TextureAsset()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAsset::save(ArchiveBuffer& buffer) const
|
void TextureAsset::save(ArchiveBuffer&) const
|
||||||
{
|
{
|
||||||
/*ktxTexture2* kTexture;
|
/*ktxTexture2* kTexture;
|
||||||
ktxTextureCreateInfo createInfo = {
|
ktxTextureCreateInfo createInfo = {
|
||||||
@@ -113,3 +114,8 @@ void TextureAsset::load(ArchiveBuffer& buffer)
|
|||||||
texture->transferOwnership(Gfx::QueueType::GRAPHICS);
|
texture->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||||
ktxTexture_Destroy(ktxTexture(kTexture));
|
ktxTexture_Destroy(ktxTexture(kTexture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureAsset::setTexture(Gfx::OTexture _texture)
|
||||||
|
{
|
||||||
|
texture = std::move(_texture);
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ public:
|
|||||||
virtual ~TextureAsset();
|
virtual ~TextureAsset();
|
||||||
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;
|
||||||
void setTexture(Gfx::OTexture _texture)
|
void setTexture(Gfx::OTexture _texture);
|
||||||
{
|
|
||||||
texture = std::move(_texture);
|
|
||||||
}
|
|
||||||
Gfx::PTexture getTexture()
|
Gfx::PTexture getTexture()
|
||||||
{
|
{
|
||||||
return texture;
|
return texture;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ using namespace Seele::Component;
|
|||||||
using namespace Seele::Math;
|
using namespace Seele::Math;
|
||||||
|
|
||||||
Camera::Camera()
|
Camera::Camera()
|
||||||
: bNeedsViewBuild(false)
|
: viewMatrix(Matrix4())
|
||||||
, viewMatrix(Matrix4())
|
, bNeedsViewBuild(false)
|
||||||
{
|
{
|
||||||
yaw = 0;
|
yaw = 0;
|
||||||
pitch = 0;
|
pitch = 0;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ struct Dependencies<This, Rest...> : public Dependencies<Rest...>
|
|||||||
|
|
||||||
namespace Component
|
namespace Component
|
||||||
{
|
{
|
||||||
#pragma warning(disable: 4505)
|
|
||||||
template<typename Comp>
|
template<typename Comp>
|
||||||
static int accessComponent(Comp& comp);
|
static int accessComponent(Comp& comp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Asset/MeshAsset.h"
|
#include "Asset/MeshAsset.h"
|
||||||
#include "Graphics/VertexData.h"
|
#include "Graphics/VertexData.h"
|
||||||
#include "Material/MaterialInstance.h"
|
#include "Material/MaterialInstance.h"
|
||||||
|
#include "Graphics/Mesh.h"
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -9,9 +10,9 @@ namespace Component
|
|||||||
{
|
{
|
||||||
struct Mesh
|
struct Mesh
|
||||||
{
|
{
|
||||||
VertexData* vertexData;
|
PMeshAsset asset;
|
||||||
MeshId id;
|
Mesh() {}
|
||||||
PMaterialInstance instance;
|
Mesh(PMeshAsset asset) : asset(asset) {}
|
||||||
};
|
};
|
||||||
} // namespace Component
|
} // namespace Component
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ public:
|
|||||||
{
|
{
|
||||||
return (int)(p - other.p);
|
return (int)(p - other.p);
|
||||||
}
|
}
|
||||||
|
constexpr IteratorBase& operator+=(difference_type other)
|
||||||
|
{
|
||||||
|
p+=other;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
constexpr bool operator<(const IteratorBase& other) const
|
constexpr bool operator<(const IteratorBase& other) const
|
||||||
{
|
{
|
||||||
return p < other.p;
|
return p < other.p;
|
||||||
@@ -725,7 +730,7 @@ public:
|
|||||||
}
|
}
|
||||||
StaticArray(T value)
|
StaticArray(T value)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < N; ++i)
|
for (size_t i = 0; i < N; ++i)
|
||||||
{
|
{
|
||||||
_data[i] = value;
|
_data[i] = value;
|
||||||
}
|
}
|
||||||
@@ -736,7 +741,7 @@ public:
|
|||||||
{
|
{
|
||||||
assert(init.size() == N);
|
assert(init.size() == N);
|
||||||
auto beg = init.begin();
|
auto beg = init.begin();
|
||||||
for (int i = 0; i < N; ++i)
|
for (size_t i = 0; i < N; ++i)
|
||||||
{
|
{
|
||||||
_data[i] = *beg;
|
_data[i] = *beg;
|
||||||
beg++;
|
beg++;
|
||||||
|
|||||||
@@ -209,17 +209,17 @@ public:
|
|||||||
constexpr Map(const Map& other)
|
constexpr Map(const Map& other)
|
||||||
: nodeContainer(other.nodeContainer)
|
: nodeContainer(other.nodeContainer)
|
||||||
, root(other.root)
|
, root(other.root)
|
||||||
|
, iteratorsDirty(true)
|
||||||
, _size(other._size)
|
, _size(other._size)
|
||||||
, comp(other.comp)
|
, comp(other.comp)
|
||||||
, iteratorsDirty(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
constexpr Map(Map&& other) noexcept
|
constexpr Map(Map&& other) noexcept
|
||||||
: nodeContainer(std::move(other.nodeContainer))
|
: nodeContainer(std::move(other.nodeContainer))
|
||||||
, root(std::move(other.root))
|
, root(std::move(other.root))
|
||||||
|
, iteratorsDirty(true)
|
||||||
, _size(std::move(other._size))
|
, _size(std::move(other._size))
|
||||||
, comp(std::move(other.comp))
|
, comp(std::move(other.comp))
|
||||||
, iteratorsDirty(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
constexpr ~Map() noexcept
|
constexpr ~Map() noexcept
|
||||||
@@ -502,7 +502,7 @@ private:
|
|||||||
endIt = calcEndIterator();
|
endIt = calcEndIterator();
|
||||||
iteratorsDirty = false;
|
iteratorsDirty = false;
|
||||||
}
|
}
|
||||||
inline Iterator calcBeginIterator() const
|
constexpr Iterator calcBeginIterator() const
|
||||||
{
|
{
|
||||||
size_t beginIndex = root;
|
size_t beginIndex = root;
|
||||||
Array<size_t> beginTraversal;
|
Array<size_t> beginTraversal;
|
||||||
@@ -518,7 +518,7 @@ private:
|
|||||||
}
|
}
|
||||||
return Iterator(beginIndex, &nodeContainer, std::move(beginTraversal));
|
return Iterator(beginIndex, &nodeContainer, std::move(beginTraversal));
|
||||||
}
|
}
|
||||||
inline Iterator calcEndIterator() const
|
constexpr Iterator calcEndIterator() const
|
||||||
{
|
{
|
||||||
size_t endIndex = root;
|
size_t endIndex = root;
|
||||||
Array<size_t> endTraversal;
|
Array<size_t> endTraversal;
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ namespace Seele
|
|||||||
class Game
|
class Game
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Game(AssetRegistry* registry) {}
|
Game(AssetRegistry*) {}
|
||||||
virtual ~Game() {}
|
virtual ~Game() {}
|
||||||
virtual void setupScene(PScene scene, PSystemGraph graph) = 0;
|
virtual void setupScene(PScene scene, PSystemGraph graph) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ target_sources(Engine
|
|||||||
Buffer.h
|
Buffer.h
|
||||||
DebugVertex.h
|
DebugVertex.h
|
||||||
Descriptor.h
|
Descriptor.h
|
||||||
|
Enums.h
|
||||||
Graphics.h
|
Graphics.h
|
||||||
Initializer.h
|
Initializer.h
|
||||||
Mesh.h
|
Mesh.h
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ FormatCompatibilityInfo Gfx::getFormatInfo(SeFormat format)
|
|||||||
.blockExtent = Vector(1, 1, 1),
|
.blockExtent = Vector(1, 1, 1),
|
||||||
.texelsPerBlock = 1,
|
.texelsPerBlock = 1,
|
||||||
};
|
};
|
||||||
|
default:
|
||||||
|
throw new std::logic_error("not yet implemented");
|
||||||
}
|
}
|
||||||
throw new std::logic_error("not yet implemented");
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ namespace Gfx
|
|||||||
static constexpr bool useAsyncCompute = true;
|
static constexpr bool useAsyncCompute = true;
|
||||||
static constexpr bool waitIdleOnSubmit = true;
|
static constexpr bool waitIdleOnSubmit = true;
|
||||||
static constexpr bool useMeshShading = true;
|
static constexpr bool useMeshShading = true;
|
||||||
static constexpr uint32 numFramesBuffered = 8;
|
static constexpr uint32 numFramesBuffered = 3;
|
||||||
|
|
||||||
// meshlet dimensions curated by NVIDIA
|
// meshlet dimensions curated by NVIDIA
|
||||||
static constexpr uint32 numVerticesPerMeshlet = 64;
|
static constexpr uint32 numVerticesPerMeshlet = 64;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
|
#include "Asset/AssetRegistry.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ void Mesh::save(ArchiveBuffer& buffer) const
|
|||||||
Serialization::save(buffer, vertexData->getTypeName());
|
Serialization::save(buffer, vertexData->getTypeName());
|
||||||
Serialization::save(buffer, vertexCount);
|
Serialization::save(buffer, vertexCount);
|
||||||
Serialization::save(buffer, meshlets);
|
Serialization::save(buffer, meshlets);
|
||||||
|
Serialization::save(buffer, referencedMaterial->getAssetIdentifier());
|
||||||
vertexData->serializeMesh(id, vertexCount, buffer);
|
vertexData->serializeMesh(id, vertexCount, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +28,9 @@ void Mesh::load(ArchiveBuffer& buffer)
|
|||||||
Serialization::load(buffer, vertexCount);
|
Serialization::load(buffer, vertexCount);
|
||||||
vertexData = VertexData::findByTypeName(typeName);
|
vertexData = VertexData::findByTypeName(typeName);
|
||||||
Serialization::load(buffer, meshlets);
|
Serialization::load(buffer, meshlets);
|
||||||
|
std::string refId;
|
||||||
|
Serialization::load(buffer, refId);
|
||||||
|
referencedMaterial = AssetRegistry::findMaterialInstance(refId);
|
||||||
id = vertexData->allocateVertexData(vertexCount);
|
id = vertexData->allocateVertexData(vertexCount);
|
||||||
vertexData->loadMesh(id, meshlets);
|
vertexData->loadMesh(id, meshlets);
|
||||||
vertexData->deserializeMesh(id, buffer);
|
vertexData->deserializeMesh(id, buffer);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
VertexData* vertexData;
|
VertexData* vertexData;
|
||||||
MeshId id;
|
MeshId id;
|
||||||
uint64 vertexCount;
|
uint64 vertexCount;
|
||||||
PMaterialInstance referencedMaterial;
|
PMaterialInstanceAsset referencedMaterial;
|
||||||
Array<Meshlet> meshlets;
|
Array<Meshlet> meshlets;
|
||||||
void save(ArchiveBuffer& buffer) const;
|
void save(ArchiveBuffer& buffer) const;
|
||||||
void load(ArchiveBuffer& buffer);
|
void load(ArchiveBuffer& buffer);
|
||||||
@@ -23,12 +23,12 @@ DEFINE_REF(Mesh)
|
|||||||
namespace Serialization
|
namespace Serialization
|
||||||
{
|
{
|
||||||
template<>
|
template<>
|
||||||
static void save(ArchiveBuffer& buffer, const OMesh& ptr)
|
void save(ArchiveBuffer& buffer, const OMesh& ptr)
|
||||||
{
|
{
|
||||||
ptr->save(buffer);
|
ptr->save(buffer);
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
static void load(ArchiveBuffer& buffer, OMesh& ptr)
|
void load(ArchiveBuffer& buffer, OMesh& ptr)
|
||||||
{
|
{
|
||||||
ptr = new Mesh();
|
ptr = new Mesh();
|
||||||
ptr->load(buffer);
|
ptr->load(buffer);
|
||||||
|
|||||||
@@ -152,6 +152,6 @@ void BasePass::createRenderPass()
|
|||||||
tLightGrid = resources->requestTexture("LIGHTCULLING_TLIGHTGRID");
|
tLightGrid = resources->requestTexture("LIGHTCULLING_TLIGHTGRID");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePass::modifyRenderPassMacros(Map<const char*, const char*>& defines)
|
void BasePass::modifyRenderPassMacros(Map<const char*, const char*>&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ LightCullingPass::~LightCullingPass()
|
|||||||
void LightCullingPass::beginFrame(const Component::Camera& cam)
|
void LightCullingPass::beginFrame(const Component::Camera& cam)
|
||||||
{
|
{
|
||||||
RenderPass::beginFrame(cam);
|
RenderPass::beginFrame(cam);
|
||||||
uint32_t viewportWidth = viewport->getSizeX();
|
|
||||||
uint32_t viewportHeight = viewport->getSizeY();
|
|
||||||
|
|
||||||
uint32 reset = 0;
|
uint32 reset = 0;
|
||||||
DataSource counterReset = {
|
DataSource counterReset = {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ void RenderPass::beginFrame(const Component::Camera& cam)
|
|||||||
.projectionMatrix = viewport->getProjectionMatrix(),
|
.projectionMatrix = viewport->getProjectionMatrix(),
|
||||||
.cameraPosition = Vector4(cam.getCameraPosition(), 1),
|
.cameraPosition = Vector4(cam.getCameraPosition(), 1),
|
||||||
.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY())),
|
.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY())),
|
||||||
|
.pad0 = Vector2(0),
|
||||||
};
|
};
|
||||||
DataSource uniformUpdate = {
|
DataSource uniformUpdate = {
|
||||||
.size = sizeof(ViewParameter),
|
.size = sizeof(ViewParameter),
|
||||||
|
|||||||
@@ -75,13 +75,13 @@ public:
|
|||||||
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
||||||
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||||
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
|
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
|
||||||
: loadOp(loadOp)
|
: clear()
|
||||||
|
, componentFlags(0)
|
||||||
|
, loadOp(loadOp)
|
||||||
, storeOp(storeOp)
|
, storeOp(storeOp)
|
||||||
, stencilLoadOp(stencilLoadOp)
|
, stencilLoadOp(stencilLoadOp)
|
||||||
, stencilStoreOp(stencilStoreOp)
|
, stencilStoreOp(stencilStoreOp)
|
||||||
, texture(texture)
|
, texture(texture)
|
||||||
, clear()
|
|
||||||
, componentFlags(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~RenderTargetAttachment()
|
virtual ~RenderTargetAttachment()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
#include "Graphics/RenderPass/DepthPrepass.h"
|
#include "Graphics/RenderPass/DepthPrepass.h"
|
||||||
#include "Graphics/RenderPass/BasePass.h"
|
#include "Graphics/RenderPass/BasePass.h"
|
||||||
|
#include <format>
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Gfx;
|
using namespace Seele::Gfx;
|
||||||
@@ -52,11 +53,9 @@ void ShaderCompiler::compile()
|
|||||||
for (const auto& [name, pass] : passes)
|
for (const auto& [name, pass] : passes)
|
||||||
{
|
{
|
||||||
std::memset(&permutation, 0, sizeof(ShaderPermutation));
|
std::memset(&permutation, 0, sizeof(ShaderPermutation));
|
||||||
permutation = {
|
permutation.hasFragment = pass.hasFragmentShader;
|
||||||
.hasFragment = pass.hasFragmentShader,
|
permutation.useMeshShading = pass.useMeshShading;
|
||||||
.useMeshShading = pass.useMeshShading,
|
permutation.hasTaskShader = pass.hasTaskShader;
|
||||||
.hasTaskShader = pass.hasTaskShader,
|
|
||||||
};
|
|
||||||
std::memcpy(permutation.vertexMeshFile, pass.mainFile.c_str(), sizeof(permutation.vertexMeshFile));
|
std::memcpy(permutation.vertexMeshFile, pass.mainFile.c_str(), sizeof(permutation.vertexMeshFile));
|
||||||
if (pass.hasFragmentShader)
|
if (pass.hasFragmentShader)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
constexpr static uint64 NUM_DEFAULT_ELEMENTS = 1024;
|
constexpr static uint64 NUM_DEFAULT_ELEMENTS = 1024 * 1024;
|
||||||
|
|
||||||
void VertexData::resetMeshData()
|
void VertexData::resetMeshData()
|
||||||
{
|
{
|
||||||
@@ -19,13 +19,13 @@ void VertexData::resetMeshData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexData::updateMesh(const Component::Transform& transform, const Component::Mesh& mesh)
|
void VertexData::updateMesh(const Component::Transform& transform, PMesh mesh)
|
||||||
{
|
{
|
||||||
PMaterial mat = mesh.instance->getBaseMaterial();
|
PMaterial mat = mesh->referencedMaterial->getHandle()->getBaseMaterial();
|
||||||
MaterialData& matData = materialData[mat->getName()];
|
MaterialData& matData = materialData[mat->getName()];
|
||||||
MaterialInstanceData& matInstanceData = matData.instances[mesh.instance->getId()];
|
MaterialInstanceData& matInstanceData = matData.instances[mesh->referencedMaterial->getHandle()->getId()];
|
||||||
matInstanceData.meshes.add(MeshInstanceData{
|
matInstanceData.meshes.add(MeshInstanceData{
|
||||||
.id = mesh.id,
|
.id = mesh->id,
|
||||||
.instance = InstanceData {
|
.instance = InstanceData {
|
||||||
.transformMatrix = transform.toMatrix(),
|
.transformMatrix = transform.toMatrix(),
|
||||||
}
|
}
|
||||||
@@ -45,10 +45,10 @@ void VertexData::loadMesh(MeshId id, Array<Meshlet> loadedMeshlets)
|
|||||||
Meshlet& m = loadedMeshlets[currentMesh + i];
|
Meshlet& m = loadedMeshlets[currentMesh + i];
|
||||||
uint32 vertexOffset = vertexIndices.size();
|
uint32 vertexOffset = vertexIndices.size();
|
||||||
vertexIndices.resize(vertexOffset + m.numVertices);
|
vertexIndices.resize(vertexOffset + m.numVertices);
|
||||||
std::memcpy(vertexIndices.data() + vertexOffset, m.uniqueVertices.data(), sizeof(m.uniqueVertices));
|
std::memcpy(vertexIndices.data() + vertexOffset, m.uniqueVertices.data(), m.numVertices * sizeof(uint32));
|
||||||
uint32 primitiveOffset = primitiveIndices.size();
|
uint32 primitiveOffset = primitiveIndices.size();
|
||||||
primitiveIndices.resize(primitiveOffset + (m.numPrimitives * 3));
|
primitiveIndices.resize(primitiveOffset + (m.numPrimitives * 3));
|
||||||
std::memcpy(primitiveIndices.data() + primitiveOffset, m.primitiveLayout.data(), sizeof(m.primitiveLayout));
|
std::memcpy(primitiveIndices.data() + primitiveOffset, m.primitiveLayout.data(), m.numPrimitives * 3 * sizeof(uint8));
|
||||||
meshlets.add(MeshletDescription{
|
meshlets.add(MeshletDescription{
|
||||||
.boundingBox = MeshletAABB(),
|
.boundingBox = MeshletAABB(),
|
||||||
.vertexCount = m.numVertices,
|
.vertexCount = m.numVertices,
|
||||||
@@ -193,9 +193,9 @@ void Seele::VertexData::init(Gfx::PGraphics graphics)
|
|||||||
|
|
||||||
VertexData::VertexData()
|
VertexData::VertexData()
|
||||||
: idCounter(0)
|
: idCounter(0)
|
||||||
, dirty(false)
|
|
||||||
, head(0)
|
, head(0)
|
||||||
, verticesAllocated(0)
|
, verticesAllocated(0)
|
||||||
|
, dirty(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,7 @@
|
|||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
namespace Component
|
DECLARE_REF(Mesh)
|
||||||
{
|
|
||||||
struct Mesh;
|
|
||||||
}
|
|
||||||
struct MeshId
|
struct MeshId
|
||||||
{
|
{
|
||||||
uint64 id;
|
uint64 id;
|
||||||
@@ -60,7 +57,7 @@ public:
|
|||||||
uint32 indicesOffset;
|
uint32 indicesOffset;
|
||||||
};
|
};
|
||||||
void resetMeshData();
|
void resetMeshData();
|
||||||
void updateMesh(const Component::Transform& transform, const Component::Mesh& mesh);
|
void updateMesh(const Component::Transform& transform, PMesh mesh);
|
||||||
void loadMesh(MeshId id, Array<Meshlet> meshlets);
|
void loadMesh(MeshId id, Array<Meshlet> meshlets);
|
||||||
void createDescriptors();
|
void createDescriptors();
|
||||||
MeshId allocateVertexData(uint64 numVertices);
|
MeshId allocateVertexData(uint64 numVertices);
|
||||||
|
|||||||
@@ -18,22 +18,12 @@ SubAllocation::~SubAllocation()
|
|||||||
owner->markFree(this);
|
owner->markFree(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr VkDeviceMemory SubAllocation::getHandle() const
|
VkDeviceMemory SubAllocation::getHandle() const
|
||||||
{
|
{
|
||||||
return owner->getHandle();
|
return owner->getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr VkDeviceSize SubAllocation::getSize() const
|
bool SubAllocation::isReadable() const
|
||||||
{
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr VkDeviceSize SubAllocation::getOffset() const
|
|
||||||
{
|
|
||||||
return alignedOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr bool SubAllocation::isReadable() const
|
|
||||||
{
|
{
|
||||||
return owner->isReadable();
|
return owner->isReadable();
|
||||||
}
|
}
|
||||||
@@ -203,30 +193,6 @@ void Allocation::markFree(PSubAllocation allocation)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr VkDeviceMemory Allocation::getHandle() const
|
|
||||||
{
|
|
||||||
return allocatedMemory;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void* Allocation::getMappedPointer()
|
|
||||||
{
|
|
||||||
if (!canMap)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
if (!isMapped)
|
|
||||||
{
|
|
||||||
vkMapMemory(device, allocatedMemory, 0, bytesAllocated, 0, &mappedPointer);
|
|
||||||
isMapped = true;
|
|
||||||
}
|
|
||||||
return mappedPointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr bool Allocation::isReadable() const
|
|
||||||
{
|
|
||||||
return readable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Allocation::flushMemory()
|
void Allocation::flushMemory()
|
||||||
{
|
{
|
||||||
VkMappedMemoryRange range = {
|
VkMappedMemoryRange range = {
|
||||||
@@ -260,6 +226,7 @@ Allocator::Allocator(PGraphics graphics)
|
|||||||
VkMemoryHeap memoryHeap = memProperties.memoryHeaps[i];
|
VkMemoryHeap memoryHeap = memProperties.memoryHeaps[i];
|
||||||
HeapInfo heapInfo;
|
HeapInfo heapInfo;
|
||||||
heapInfo.maxSize = memoryHeap.size;
|
heapInfo.maxSize = memoryHeap.size;
|
||||||
|
std::cout << "Creating heap " << i << " with properties " << memoryHeap.flags << " size " << memoryHeap.size << std::endl;
|
||||||
heaps.add(std::move(heapInfo));
|
heaps.add(std::move(heapInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,6 +260,7 @@ OSubAllocation Allocator::allocate(const VkMemoryRequirements2 &memRequirements2
|
|||||||
{
|
{
|
||||||
OAllocation newAllocation = new Allocation(graphics, this, requirements.size, memoryTypeIndex, properties, dedicatedInfo);
|
OAllocation newAllocation = new Allocation(graphics, this, requirements.size, memoryTypeIndex, properties, dedicatedInfo);
|
||||||
heaps[heapIndex].inUse += newAllocation->bytesAllocated;
|
heaps[heapIndex].inUse += newAllocation->bytesAllocated;
|
||||||
|
std::cout << "Heap " << heapIndex << " +" <<newAllocation->bytesAllocated << ": " << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl;
|
||||||
heaps[heapIndex].allocations.add(std::move(newAllocation));
|
heaps[heapIndex].allocations.add(std::move(newAllocation));
|
||||||
return heaps[heapIndex].allocations.back()->getSuballocation(requirements.size, requirements.alignment);
|
return heaps[heapIndex].allocations.back()->getSuballocation(requirements.size, requirements.alignment);
|
||||||
}
|
}
|
||||||
@@ -312,7 +280,7 @@ OSubAllocation Allocator::allocate(const VkMemoryRequirements2 &memRequirements2
|
|||||||
// no suitable allocations found, allocate new block
|
// no suitable allocations found, allocate new block
|
||||||
OAllocation newAllocation = new Allocation(graphics, this, (requirements.size > MemoryBlockSize) ? requirements.size : (VkDeviceSize)MemoryBlockSize, memoryTypeIndex, properties, nullptr);
|
OAllocation newAllocation = new Allocation(graphics, this, (requirements.size > MemoryBlockSize) ? requirements.size : (VkDeviceSize)MemoryBlockSize, memoryTypeIndex, properties, nullptr);
|
||||||
heaps[heapIndex].inUse += newAllocation->bytesAllocated;
|
heaps[heapIndex].inUse += newAllocation->bytesAllocated;
|
||||||
heaps[heapIndex].allocations.add(std::move(newAllocation));
|
std::cout << "Heap " << heapIndex << " +" <<newAllocation->bytesAllocated << ": " << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl; heaps[heapIndex].allocations.add(std::move(newAllocation));
|
||||||
return heaps[heapIndex].allocations.back()->getSuballocation(requirements.size, requirements.alignment);
|
return heaps[heapIndex].allocations.back()->getSuballocation(requirements.size, requirements.alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,12 +289,13 @@ void Allocator::free(Allocation *allocation)
|
|||||||
std::scoped_lock lck(lock);
|
std::scoped_lock lck(lock);
|
||||||
for (auto& heap : heaps)
|
for (auto& heap : heaps)
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < heap.allocations.size(); ++i)
|
for (uint32 heapIndex = 0; heapIndex < heap.allocations.size(); ++heapIndex)
|
||||||
{
|
{
|
||||||
if (heap.allocations[i] == allocation)
|
if (heap.allocations[heapIndex] == allocation)
|
||||||
{
|
{
|
||||||
heap.inUse -= allocation->bytesAllocated;
|
heap.inUse -= allocation->bytesAllocated;
|
||||||
heap.allocations.removeAt(i, false);
|
std::cout << "Heap " << heapIndex << " -" <<allocation->bytesAllocated << ":" << (float)heaps[heapIndex].inUse / heaps[heapIndex].maxSize << "%" << std::endl;
|
||||||
|
heap.allocations.removeAt(heapIndex, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,31 +343,21 @@ void StagingBuffer::invalidateMemory()
|
|||||||
allocation->invalidateMemory();
|
allocation->invalidateMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr VkDeviceMemory StagingBuffer::getMemoryHandle() const
|
VkDeviceMemory StagingBuffer::getMemoryHandle() const
|
||||||
{
|
{
|
||||||
return allocation->getHandle();
|
return allocation->getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr VkDeviceSize StagingBuffer::getOffset() const
|
VkDeviceSize StagingBuffer::getOffset() const
|
||||||
{
|
{
|
||||||
return allocation->getOffset();
|
return allocation->getOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint64 StagingBuffer::getSize() const
|
uint64 StagingBuffer::getSize() const
|
||||||
{
|
{
|
||||||
return allocation->getSize();
|
return allocation->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool StagingBuffer::isReadable() const
|
|
||||||
{
|
|
||||||
return readable;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr VkBufferUsageFlags StagingBuffer::getUsage() const
|
|
||||||
{
|
|
||||||
return usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
StagingManager::StagingManager(PGraphics graphics, PAllocator allocator)
|
StagingManager::StagingManager(PGraphics graphics, PAllocator allocator)
|
||||||
: graphics(graphics), allocator(allocator)
|
: graphics(graphics), allocator(allocator)
|
||||||
{
|
{
|
||||||
@@ -422,8 +381,9 @@ OStagingBuffer StagingManager::allocateStagingBuffer(uint64 size, VkBufferUsageF
|
|||||||
{
|
{
|
||||||
//std::cout << "Reusing staging buffer" << std::endl;
|
//std::cout << "Reusing staging buffer" << std::endl;
|
||||||
activeBuffers.add(freeBuffer);
|
activeBuffers.add(freeBuffer);
|
||||||
|
OStagingBuffer owner = std::move(freeBuffer);
|
||||||
freeBuffers.remove(it, false);
|
freeBuffers.remove(it, false);
|
||||||
return std::move(freeBuffer);
|
return owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//std::cout << "Creating new stagingbuffer" << std::endl;
|
//std::cout << "Creating new stagingbuffer" << std::endl;
|
||||||
@@ -463,6 +423,8 @@ OStagingBuffer StagingManager::allocateStagingBuffer(uint64 size, VkBufferUsageF
|
|||||||
);
|
);
|
||||||
vkBindBufferMemory(graphics->getDevice(), buffer, stagingBuffer->getMemoryHandle(), stagingBuffer->getOffset());
|
vkBindBufferMemory(graphics->getDevice(), buffer, stagingBuffer->getMemoryHandle(), stagingBuffer->getOffset());
|
||||||
|
|
||||||
|
std::cout << "Creating new stagingbuffer size " << stagingBuffer->getSize() << std::endl;
|
||||||
|
|
||||||
activeBuffers.add(stagingBuffer);
|
activeBuffers.add(stagingBuffer);
|
||||||
|
|
||||||
return stagingBuffer;
|
return stagingBuffer;
|
||||||
@@ -471,6 +433,11 @@ OStagingBuffer StagingManager::allocateStagingBuffer(uint64 size, VkBufferUsageF
|
|||||||
void StagingManager::releaseStagingBuffer(OStagingBuffer buffer)
|
void StagingManager::releaseStagingBuffer(OStagingBuffer buffer)
|
||||||
{
|
{
|
||||||
std::scoped_lock l(lock);
|
std::scoped_lock l(lock);
|
||||||
|
if(activeBuffers.find(buffer) == activeBuffers.end())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
activeBuffers.remove(buffer);
|
activeBuffers.remove(buffer);
|
||||||
|
std::cout << "Releasing stagingbuffer size " << buffer->getSize() << std::endl;
|
||||||
freeBuffers.add(std::move(buffer));
|
freeBuffers.add(std::move(buffer));
|
||||||
}
|
}
|
||||||
@@ -17,10 +17,20 @@ class SubAllocation
|
|||||||
public:
|
public:
|
||||||
SubAllocation(PAllocation owner, VkDeviceSize allocatedOffset, VkDeviceSize size, VkDeviceSize alignedOffset, VkDeviceSize allocatedSize);
|
SubAllocation(PAllocation owner, VkDeviceSize allocatedOffset, VkDeviceSize size, VkDeviceSize alignedOffset, VkDeviceSize allocatedSize);
|
||||||
~SubAllocation();
|
~SubAllocation();
|
||||||
constexpr VkDeviceMemory getHandle() const;
|
VkDeviceMemory getHandle() const;
|
||||||
constexpr VkDeviceSize getSize() const;
|
|
||||||
constexpr VkDeviceSize getOffset() const;
|
constexpr VkDeviceSize getSize() const
|
||||||
constexpr bool isReadable() const;
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr VkDeviceSize getOffset() const
|
||||||
|
{
|
||||||
|
return alignedOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isReadable() const;
|
||||||
|
|
||||||
void *getMappedPointer();
|
void *getMappedPointer();
|
||||||
void flushMemory();
|
void flushMemory();
|
||||||
void invalidateMemory();
|
void invalidateMemory();
|
||||||
@@ -43,9 +53,30 @@ public:
|
|||||||
~Allocation();
|
~Allocation();
|
||||||
OSubAllocation getSuballocation(VkDeviceSize size, VkDeviceSize alignment);
|
OSubAllocation getSuballocation(VkDeviceSize size, VkDeviceSize alignment);
|
||||||
void markFree(PSubAllocation alloc);
|
void markFree(PSubAllocation alloc);
|
||||||
constexpr VkDeviceMemory getHandle() const;
|
constexpr VkDeviceMemory getHandle() const
|
||||||
constexpr void* getMappedPointer();
|
{
|
||||||
constexpr bool isReadable() const;
|
return allocatedMemory;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr void* getMappedPointer()
|
||||||
|
{
|
||||||
|
if (!canMap)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (!isMapped)
|
||||||
|
{
|
||||||
|
vkMapMemory(device, allocatedMemory, 0, bytesAllocated, 0, &mappedPointer);
|
||||||
|
isMapped = true;
|
||||||
|
}
|
||||||
|
return mappedPointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isReadable() const
|
||||||
|
{
|
||||||
|
return readable;
|
||||||
|
}
|
||||||
|
|
||||||
void flushMemory();
|
void flushMemory();
|
||||||
void invalidateMemory();
|
void invalidateMemory();
|
||||||
|
|
||||||
@@ -134,11 +165,19 @@ public:
|
|||||||
{
|
{
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
constexpr VkDeviceMemory getMemoryHandle() const;
|
VkDeviceMemory getMemoryHandle() const;
|
||||||
constexpr VkDeviceSize getOffset() const;
|
VkDeviceSize getOffset() const;
|
||||||
constexpr uint64 getSize() const;
|
uint64 getSize() const;
|
||||||
constexpr bool isReadable() const;
|
constexpr bool isReadable() const
|
||||||
constexpr VkBufferUsageFlags getUsage() const;
|
{
|
||||||
|
return readable;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr VkBufferUsageFlags getUsage() const
|
||||||
|
{
|
||||||
|
return usage;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OSubAllocation allocation;
|
OSubAllocation allocation;
|
||||||
VkBuffer buffer;
|
VkBuffer buffer;
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ UniformBuffer::UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo &
|
|||||||
|
|
||||||
UniformBuffer::~UniformBuffer()
|
UniformBuffer::~UniformBuffer()
|
||||||
{
|
{
|
||||||
|
graphics->getStagingManager()->releaseStagingBuffer(std::move(dedicatedStagingBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UniformBuffer::updateContents(const DataSource &sourceData)
|
bool UniformBuffer::updateContents(const DataSource &sourceData)
|
||||||
@@ -363,7 +364,12 @@ VkAccessFlags UniformBuffer::getDestAccessMask()
|
|||||||
ShaderBuffer::ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo &sourceData)
|
ShaderBuffer::ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo &sourceData)
|
||||||
: Gfx::ShaderBuffer(graphics->getFamilyMapping(), sourceData.stride, sourceData.sourceData.size / sourceData.stride, sourceData.sourceData)
|
: Gfx::ShaderBuffer(graphics->getFamilyMapping(), sourceData.stride, sourceData.sourceData.size / sourceData.stride, sourceData.sourceData)
|
||||||
, Vulkan::Buffer(graphics, sourceData.sourceData.size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, currentOwner, sourceData.dynamic)
|
, Vulkan::Buffer(graphics, sourceData.sourceData.size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, currentOwner, sourceData.dynamic)
|
||||||
|
, dedicatedStagingBuffer(nullptr)
|
||||||
{
|
{
|
||||||
|
if(sourceData.dynamic)
|
||||||
|
{
|
||||||
|
dedicatedStagingBuffer = graphics->getStagingManager()->allocateStagingBuffer(sourceData.sourceData.size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
|
||||||
|
}
|
||||||
if (sourceData.sourceData.data != nullptr)
|
if (sourceData.sourceData.data != nullptr)
|
||||||
{
|
{
|
||||||
void *data = lock();
|
void *data = lock();
|
||||||
@@ -374,6 +380,7 @@ ShaderBuffer::ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo &sou
|
|||||||
|
|
||||||
ShaderBuffer::~ShaderBuffer()
|
ShaderBuffer::~ShaderBuffer()
|
||||||
{
|
{
|
||||||
|
graphics->getStagingManager()->releaseStagingBuffer(std::move(dedicatedStagingBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderBuffer::updateContents(const DataSource &sourceData)
|
bool ShaderBuffer::updateContents(const DataSource &sourceData)
|
||||||
@@ -422,13 +429,13 @@ void ShaderBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner)
|
|||||||
|
|
||||||
void ShaderBuffer::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
void ShaderBuffer::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
||||||
{
|
{
|
||||||
Vulkan::ShaderBuffer::executeOwnershipBarrier(newOwner);
|
Vulkan::Buffer::executeOwnershipBarrier(newOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderBuffer::executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
|
void ShaderBuffer::executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
|
||||||
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage)
|
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage)
|
||||||
{
|
{
|
||||||
Vulkan::ShaderBuffer::executePipelineBarrier(srcAccess, srcStage, dstAccess, dstStage);
|
Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess, dstStage);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkAccessFlags ShaderBuffer::getSourceAccessMask()
|
VkAccessFlags ShaderBuffer::getSourceAccessMask()
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ protected:
|
|||||||
struct BufferAllocation
|
struct BufferAllocation
|
||||||
{
|
{
|
||||||
VkBuffer buffer;
|
VkBuffer buffer;
|
||||||
PSubAllocation allocation;
|
OSubAllocation allocation;
|
||||||
};
|
};
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
uint32 currentBuffer;
|
uint32 currentBuffer;
|
||||||
@@ -140,6 +140,5 @@ protected:
|
|||||||
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
|
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
|
||||||
};
|
};
|
||||||
DEFINE_REF(IndexBuffer)
|
DEFINE_REF(IndexBuffer)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,6 +172,8 @@ VkDeviceCreateInfo init::DeviceCreateInfo(VkDeviceQueueCreateInfo *queueInfos, u
|
|||||||
createInfo.enabledLayerCount = layerCount;
|
createInfo.enabledLayerCount = layerCount;
|
||||||
createInfo.ppEnabledLayerNames = layers;
|
createInfo.ppEnabledLayerNames = layers;
|
||||||
#else
|
#else
|
||||||
|
(void)layers;
|
||||||
|
(void)layerCount;
|
||||||
createInfo.enabledLayerCount = 0;
|
createInfo.enabledLayerCount = 0;
|
||||||
layerCount = 0;
|
layerCount = 0;
|
||||||
layers = nullptr;
|
layers = nullptr;
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ void TextureHandle::download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Ar
|
|||||||
auto prevlayout = layout;
|
auto prevlayout = layout;
|
||||||
changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||||
PCmdBuffer cmdBuffer = graphics->getQueueCommands(currentOwner)->getCommands();
|
PCmdBuffer cmdBuffer = graphics->getQueueCommands(currentOwner)->getCommands();
|
||||||
Gfx::FormatCompatibilityInfo formatInfo = Gfx::getFormatInfo(format);
|
//Gfx::FormatCompatibilityInfo formatInfo = Gfx::getFormatInfo(format);
|
||||||
VkBufferImageCopy region = {
|
VkBufferImageCopy region = {
|
||||||
.bufferOffset = 0,
|
.bufferOffset = 0,
|
||||||
.bufferRowLength = 0,
|
.bufferRowLength = 0,
|
||||||
|
|||||||
@@ -14,21 +14,24 @@ MaterialInstance::MaterialInstance(uint64 id,
|
|||||||
Array<std::string> params,
|
Array<std::string> params,
|
||||||
uint32 uniformBinding,
|
uint32 uniformBinding,
|
||||||
uint32 uniformSize)
|
uint32 uniformSize)
|
||||||
: id(id)
|
: graphics(graphics)
|
||||||
, graphics(graphics)
|
|
||||||
, uniformBinding(uniformBinding)
|
, uniformBinding(uniformBinding)
|
||||||
|
, id(id)
|
||||||
{
|
{
|
||||||
uniformBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
if(uniformSize > 0)
|
||||||
.sourceData = {
|
{
|
||||||
.size = uniformSize,
|
uniformBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||||
},
|
.sourceData = {
|
||||||
.dynamic = true,
|
.size = uniformSize,
|
||||||
}
|
},
|
||||||
);
|
.dynamic = true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
uniformData.resize(uniformSize);
|
uniformData.resize(uniformSize);
|
||||||
ArchiveBuffer buffer(graphics);
|
ArchiveBuffer buffer(graphics);
|
||||||
parameters.reserve(params.size());
|
parameters.reserve(params.size());
|
||||||
for (int i = 0; i < params.size(); ++i)
|
for (size_t i = 0; i < params.size(); ++i)
|
||||||
{
|
{
|
||||||
Serialization::save(buffer, expressions[params[i]]);
|
Serialization::save(buffer, expressions[params[i]]);
|
||||||
buffer.rewind();
|
buffer.rewind();
|
||||||
@@ -52,6 +55,14 @@ void MaterialInstance::updateDescriptor()
|
|||||||
{
|
{
|
||||||
param->updateDescriptorSet(descriptor, uniformData.data());
|
param->updateDescriptorSet(descriptor, uniformData.data());
|
||||||
}
|
}
|
||||||
|
if(uniformData.size() > 0)
|
||||||
|
{
|
||||||
|
uniformBuffer->updateContents(DataSource{
|
||||||
|
.size = uniformData.size(),
|
||||||
|
.data = uniformData.data(),
|
||||||
|
});
|
||||||
|
descriptor->updateBuffer(uniformBinding, uniformBuffer);
|
||||||
|
}
|
||||||
descriptor->writeChanges();
|
descriptor->writeChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +73,16 @@ Gfx::PDescriptorSet MaterialInstance::getDescriptorSet() const
|
|||||||
|
|
||||||
void MaterialInstance::setBaseMaterial(PMaterialAsset asset)
|
void MaterialInstance::setBaseMaterial(PMaterialAsset asset)
|
||||||
{
|
{
|
||||||
uniformBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
if(uniformData.size() > 0)
|
||||||
.sourceData = {
|
{
|
||||||
.size = uniformData.size(),
|
uniformBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||||
},
|
.sourceData = {
|
||||||
.dynamic = true,
|
.size = uniformData.size(),
|
||||||
}
|
},
|
||||||
);
|
.dynamic = true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
baseMaterial = asset;
|
baseMaterial = asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#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>
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
@@ -40,6 +41,10 @@ ShaderExpression::ShaderExpression(std::string key)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShaderExpression::~ShaderExpression()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void ShaderExpression::save(ArchiveBuffer& buffer) const
|
void ShaderExpression::save(ArchiveBuffer& buffer) const
|
||||||
{
|
{
|
||||||
Serialization::save(buffer, inputs);
|
Serialization::save(buffer, inputs);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ struct ShaderExpression
|
|||||||
std::string key;
|
std::string key;
|
||||||
ShaderExpression();
|
ShaderExpression();
|
||||||
ShaderExpression(std::string key);
|
ShaderExpression(std::string key);
|
||||||
|
virtual ~ShaderExpression();
|
||||||
virtual uint64 getIdentifier() const = 0;
|
virtual uint64 getIdentifier() const = 0;
|
||||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const = 0;
|
virtual std::string evaluate(Map<std::string, std::string>& varState) const = 0;
|
||||||
virtual void save(ArchiveBuffer& buffer) const;
|
virtual void save(ArchiveBuffer& buffer) const;
|
||||||
@@ -216,14 +217,14 @@ struct MaterialNode
|
|||||||
void load(ArchiveBuffer& buffer);
|
void load(ArchiveBuffer& buffer);
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
static void Serialization::save(ArchiveBuffer& buffer, const OShaderExpression& parameter)
|
void Serialization::save(ArchiveBuffer& buffer, const OShaderExpression& parameter)
|
||||||
{
|
{
|
||||||
Serialization::save(buffer, parameter->getIdentifier());
|
Serialization::save(buffer, parameter->getIdentifier());
|
||||||
parameter->save(buffer);
|
parameter->save(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
static void Serialization::load(ArchiveBuffer& buffer, OShaderExpression& parameter)
|
void Serialization::load(ArchiveBuffer& buffer, OShaderExpression& parameter)
|
||||||
{
|
{
|
||||||
uint64 identifier = 0;
|
uint64 identifier = 0;
|
||||||
Serialization::load(buffer, identifier);
|
Serialization::load(buffer, identifier);
|
||||||
@@ -269,14 +270,14 @@ static void Serialization::load(ArchiveBuffer& buffer, OShaderExpression& parame
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
static void Serialization::save(ArchiveBuffer& buffer, const OShaderParameter& parameter)
|
void Serialization::save(ArchiveBuffer& buffer, const OShaderParameter& parameter)
|
||||||
{
|
{
|
||||||
Serialization::save(buffer, parameter->getIdentifier());
|
Serialization::save(buffer, parameter->getIdentifier());
|
||||||
parameter->save(buffer);
|
parameter->save(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
static void Serialization::load(ArchiveBuffer& buffer, OShaderParameter& parameter)
|
void Serialization::load(ArchiveBuffer& buffer, OShaderParameter& parameter)
|
||||||
{
|
{
|
||||||
uint64 identifier = 0;
|
uint64 identifier = 0;
|
||||||
Serialization::load(buffer, identifier);
|
Serialization::load(buffer, identifier);
|
||||||
|
|||||||
@@ -157,6 +157,10 @@ public:
|
|||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
|
if(pointer != nullptr)
|
||||||
|
{
|
||||||
|
Deleter()(pointer);
|
||||||
|
}
|
||||||
pointer = other.pointer;
|
pointer = other.pointer;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ void BVH::reinsertCollider(entt::entity entity, AABB aabb)
|
|||||||
void BVH::removeCollider(entt::entity entity)
|
void BVH::removeCollider(entt::entity entity)
|
||||||
{
|
{
|
||||||
int32 nodeIndex = -1;
|
int32 nodeIndex = -1;
|
||||||
for (int32 i = 0; i < dynamicNodes.size(); i++)
|
for (size_t i = 0; i < dynamicNodes.size(); i++)
|
||||||
{
|
{
|
||||||
if(dynamicNodes[i].isLeaf && dynamicNodes[i].owner == entity)
|
if(dynamicNodes[i].isLeaf && dynamicNodes[i].owner == entity)
|
||||||
{
|
{
|
||||||
@@ -119,7 +119,6 @@ void BVH::removeCollider(entt::entity entity)
|
|||||||
}
|
}
|
||||||
if(nodeIndex == -1)
|
if(nodeIndex == -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int32 parentIndex = dynamicNodes[nodeIndex].parentIndex;
|
int32 parentIndex = dynamicNodes[nodeIndex].parentIndex;
|
||||||
@@ -354,7 +353,7 @@ int32 BVH::splitNode(Array<AABBCenter> aabbs)
|
|||||||
}
|
}
|
||||||
int32 BVH::allocateNode()
|
int32 BVH::allocateNode()
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < dynamicNodes.size(); i++)
|
for (size_t i = 0; i < dynamicNodes.size(); i++)
|
||||||
{
|
{
|
||||||
if(!dynamicNodes[i].isValid)
|
if(!dynamicNodes[i].isValid)
|
||||||
{
|
{
|
||||||
@@ -377,7 +376,7 @@ void BVH::validateBVH() const
|
|||||||
{
|
{
|
||||||
assert(dynamicNodes[dynamicRoot].parentIndex == -1);
|
assert(dynamicNodes[dynamicRoot].parentIndex == -1);
|
||||||
}
|
}
|
||||||
for(int32 i = 0; i < dynamicNodes.size(); ++i)
|
for(size_t i = 0; i < dynamicNodes.size(); ++i)
|
||||||
{
|
{
|
||||||
int32 nodeIdx = i;
|
int32 nodeIdx = i;
|
||||||
size_t counter = dynamicNodes.size();
|
size_t counter = dynamicNodes.size();
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ bool CollisionSystem::createWitness(Witness& result, const ShapeBase& source, co
|
|||||||
}
|
}
|
||||||
for (size_t i = 0; i < source.indices.size(); i += 3)
|
for (size_t i = 0; i < source.indices.size(); i += 3)
|
||||||
{
|
{
|
||||||
auto findEdgePlane = [=, &result](uint32_t point1Index, uint32_t point2Index)
|
auto findEdgePlane = [this, &source, &other, &result](uint32_t point1Index, uint32_t point2Index)
|
||||||
{
|
{
|
||||||
const glm::vec3 point1 = source.vertices[point1Index];
|
const glm::vec3 point1 = source.vertices[point1Index];
|
||||||
const glm::vec3 point2 = source.vertices[point2Index];
|
const glm::vec3 point2 = source.vertices[point2Index];
|
||||||
|
|||||||
@@ -346,19 +346,19 @@ void PhysicsSystem::calculateContacts(entt::entity id1, const ShapeBase& shape1,
|
|||||||
&& tx >= 0.f
|
&& tx >= 0.f
|
||||||
&& tx <= 1.f)
|
&& tx <= 1.f)
|
||||||
{
|
{
|
||||||
Vector p = p1 + tx * (p2 - p1);
|
// Vector p = p1 + tx * (p2 - p1);
|
||||||
Vector ea = p2 - p1;
|
// Vector ea = p2 - p1;
|
||||||
Vector eb = p4 - p3;
|
// Vector eb = p4 - p3;
|
||||||
Vector n = glm::normalize(glm::cross(eb, ea));
|
// Vector n = glm::normalize(glm::cross(eb, ea));
|
||||||
Contact contact = {
|
// Contact contact = {
|
||||||
.a = id1,
|
// .a = id1,
|
||||||
.b = id2,
|
// .b = id2,
|
||||||
.p = p,
|
// .p = p,
|
||||||
.n = n,
|
// .n = n,
|
||||||
.ea = ea,
|
// .ea = ea,
|
||||||
.eb = eb,
|
// .eb = eb,
|
||||||
.vf = false
|
// .vf = false
|
||||||
};
|
// };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for(size_t j = 0; j < shape2.indices.size(); j+=3)
|
for(size_t j = 0; j < shape2.indices.size(); j+=3)
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
add_subdirectory(Windows/)
|
if(WIN32)
|
||||||
|
add_subdirectory(Windows/)
|
||||||
|
else()
|
||||||
|
add_subdirectory(Linux/)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
target_sources(Engine
|
||||||
|
PRIVATE
|
||||||
|
GameInterface.h
|
||||||
|
GameInterface.cpp)
|
||||||
|
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
GameInterface.h)
|
||||||
@@ -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(AssetRegistry* registry)
|
||||||
|
{
|
||||||
|
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(registry);
|
||||||
|
}
|
||||||
@@ -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(AssetRegistry* registry);
|
||||||
|
private:
|
||||||
|
void* lib;
|
||||||
|
std::string soPath;
|
||||||
|
Game* game;
|
||||||
|
Game* (*createInstance)(AssetRegistry*) = nullptr;
|
||||||
|
void (*destroyInstance)(Game*) = nullptr;
|
||||||
|
};
|
||||||
|
} // namespace Seele
|
||||||
@@ -14,8 +14,8 @@ using namespace Seele;
|
|||||||
|
|
||||||
Scene::Scene(Gfx::PGraphics graphics)
|
Scene::Scene(Gfx::PGraphics graphics)
|
||||||
: graphics(graphics)
|
: graphics(graphics)
|
||||||
, physics(registry)
|
|
||||||
, lightEnv(new LightEnvironment(graphics))
|
, lightEnv(new LightEnvironment(graphics))
|
||||||
|
, physics(registry)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ public:
|
|||||||
Gfx::PGraphics getGraphics() const { return graphics; }
|
Gfx::PGraphics getGraphics() const { return graphics; }
|
||||||
entt::registry registry;
|
entt::registry registry;
|
||||||
private:
|
private:
|
||||||
|
Gfx::PGraphics graphics;
|
||||||
OLightEnvironment lightEnv;
|
OLightEnvironment lightEnv;
|
||||||
PhysicsSystem physics;
|
PhysicsSystem physics;
|
||||||
Gfx::PGraphics graphics;
|
|
||||||
};
|
};
|
||||||
DEFINE_REF(Scene)
|
DEFINE_REF(Scene)
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
@@ -59,7 +59,7 @@ void ArchiveBuffer::seek(int64 s, SeekOp op)
|
|||||||
newPos = position + s;
|
newPos = position + s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(newPos >= 0 && newPos < memory.size());
|
assert(newPos >= 0 && size_t(newPos) < memory.size());
|
||||||
newPos = position;
|
newPos = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,14 @@ public:
|
|||||||
{
|
{
|
||||||
return (deps | ...);
|
return (deps | ...);
|
||||||
}
|
}
|
||||||
|
void setupView(Dependencies<>, dp::thread_pool<>&)
|
||||||
|
{
|
||||||
|
registry.view<Components...>().each([&](Components&... comp){
|
||||||
|
//pool.enqueue_detach([&](){
|
||||||
|
update(comp...);
|
||||||
|
//});
|
||||||
|
});
|
||||||
|
}
|
||||||
template<typename... Deps>
|
template<typename... Deps>
|
||||||
void setupView(Dependencies<Deps...>, dp::thread_pool<>&)
|
void setupView(Dependencies<Deps...>, dp::thread_pool<>&)
|
||||||
{
|
{
|
||||||
@@ -37,20 +45,12 @@ public:
|
|||||||
//});
|
//});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
template<>
|
|
||||||
void setupView(Dependencies<>, dp::thread_pool<>&)
|
|
||||||
{
|
|
||||||
registry.view<Components...>().each([&](Components&... comp){
|
|
||||||
//pool.enqueue_detach([&](){
|
|
||||||
update(comp...);
|
|
||||||
//});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
virtual void run(dp::thread_pool<>& pool, double delta) override
|
virtual void run(dp::thread_pool<>& pool, double delta) override
|
||||||
{
|
{
|
||||||
SystemBase::run(pool, delta);
|
SystemBase::run(pool, delta);
|
||||||
setupView(mergeDependencies((getDependencies<Components>(),...)), pool);
|
setupView(mergeDependencies((getDependencies<Components>(),...)), pool);
|
||||||
}
|
}
|
||||||
|
virtual void update() {}
|
||||||
virtual void update(Components&... components) = 0;
|
virtual void update(Components&... components) = 0;
|
||||||
};
|
};
|
||||||
} // namespace System
|
} // namespace System
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ MeshUpdater::~MeshUpdater()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshUpdater::update(Component::Transform& transform, Component::Mesh& mesh)
|
void MeshUpdater::update(Component::Transform& transform, Component::Mesh& meshComp)
|
||||||
{
|
{
|
||||||
mesh.vertexData->updateMesh(transform, mesh);
|
for(const auto& mesh : meshComp.asset->meshes)
|
||||||
|
{
|
||||||
|
mesh->vertexData->updateMesh(transform, mesh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class SystemBase
|
|||||||
public:
|
public:
|
||||||
SystemBase(PScene scene) : registry(scene->registry), scene(scene) {}
|
SystemBase(PScene scene) : registry(scene->registry), scene(scene) {}
|
||||||
virtual ~SystemBase() {}
|
virtual ~SystemBase() {}
|
||||||
virtual void run(dp::thread_pool<>& pool, double delta)
|
virtual void run(dp::thread_pool<>&, double delta)
|
||||||
{
|
{
|
||||||
deltaTime = delta;
|
deltaTime = delta;
|
||||||
update();
|
update();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void System::update()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::updateViewport(Gfx::PViewport viewport)
|
void System::updateViewport(Gfx::PViewport)
|
||||||
{
|
{
|
||||||
//TODO set viewport FoV to 0
|
//TODO set viewport FoV to 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ using namespace Seele;
|
|||||||
|
|
||||||
GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo, std::string dllPath)
|
GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo, std::string dllPath)
|
||||||
: View(graphics, window, createInfo, "Game")
|
: View(graphics, window, createInfo, "Game")
|
||||||
|
, scene(new Scene(graphics))
|
||||||
, gameInterface(dllPath)
|
, gameInterface(dllPath)
|
||||||
, renderGraph(RenderGraphBuilder::build(
|
, renderGraph(RenderGraphBuilder::build(
|
||||||
std::move(DepthPrepass(graphics, scene)),
|
DepthPrepass(graphics, scene),
|
||||||
std::move(LightCullingPass(graphics, scene)),
|
LightCullingPass(graphics, scene),
|
||||||
std::move(BasePass(graphics, scene)),
|
BasePass(graphics, scene),
|
||||||
std::move(SkyboxRenderPass(graphics, scene))
|
SkyboxRenderPass(graphics, scene)
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
reloadGame();
|
reloadGame();
|
||||||
@@ -75,7 +76,7 @@ void GameView::reloadGame()
|
|||||||
|
|
||||||
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
||||||
{
|
{
|
||||||
scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input)
|
scene->view<Component::KeyboardInput>([=, this](Component::KeyboardInput& input)
|
||||||
{
|
{
|
||||||
//if(code == KeyCode::KEY_R && action == InputAction::PRESS)
|
//if(code == KeyCode::KEY_R && action == InputAction::PRESS)
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -5,7 +5,11 @@
|
|||||||
#include "Graphics/RenderPass/LightCullingPass.h"
|
#include "Graphics/RenderPass/LightCullingPass.h"
|
||||||
#include "Graphics/RenderPass/BasePass.h"
|
#include "Graphics/RenderPass/BasePass.h"
|
||||||
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
||||||
|
#ifdef WIN32
|
||||||
#include "Platform/Windows/GameInterface.h" // TODO
|
#include "Platform/Windows/GameInterface.h" // TODO
|
||||||
|
#else
|
||||||
|
#include "Platform/Linux/GameInterface.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -23,6 +27,8 @@ public:
|
|||||||
|
|
||||||
void reloadGame();
|
void reloadGame();
|
||||||
private:
|
private:
|
||||||
|
OScene scene;
|
||||||
|
PEntity camera;
|
||||||
GameInterface gameInterface;
|
GameInterface gameInterface;
|
||||||
RenderGraph<
|
RenderGraph<
|
||||||
DepthPrepass,
|
DepthPrepass,
|
||||||
@@ -31,8 +37,6 @@ private:
|
|||||||
SkyboxRenderPass
|
SkyboxRenderPass
|
||||||
> renderGraph;
|
> renderGraph;
|
||||||
|
|
||||||
PEntity camera;
|
|
||||||
OScene scene;
|
|
||||||
PSystemGraph systemGraph;
|
PSystemGraph systemGraph;
|
||||||
dp::thread_pool<> threadPool;
|
dp::thread_pool<> threadPool;
|
||||||
float updateTime = 0;
|
float updateTime = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user