Fixing a boatload of warnings

This commit is contained in:
Stefan Högler
2021-04-01 16:40:14 +02:00
parent f042480540
commit d5f0fe644f
84 changed files with 496 additions and 407 deletions
+2 -4
View File
@@ -11,11 +11,9 @@
"UNICODE", "UNICODE",
"_UNICODE" "_UNICODE"
], ],
"windowsSdkVersion": "10.0.18362.0", "intelliSenseMode": "clang-x64",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe",
"intelliSenseMode": "msvc-x64",
"configurationProvider": "ms-vscode.cmake-tools", "configurationProvider": "ms-vscode.cmake-tools",
"cppStandard": "c++17", "cppStandard": "c++20",
"browse": { "browse": {
"path": [ "path": [
"${VULKAN_SDK}/**" "${VULKAN_SDK}/**"
+3 -1
View File
@@ -104,7 +104,9 @@
"hash_map": "cpp", "hash_map": "cpp",
"hash_set": "cpp", "hash_set": "cpp",
"scoped_allocator": "cpp", "scoped_allocator": "cpp",
"stack": "cpp" "stack": "cpp",
"coroutine": "cpp",
"*.tcc": "cpp"
}, },
"cmake.skipConfigureIfCachePresent": false, "cmake.skipConfigureIfCachePresent": false,
"cmake.configureArgs": [ "cmake.configureArgs": [
+22 -20
View File
@@ -16,10 +16,11 @@ set(GLFW_ROOT ${EXTERNAL_ROOT}/glfw)
set(JSON_ROOT ${EXTERNAL_ROOT}/json) set(JSON_ROOT ${EXTERNAL_ROOT}/json)
set(STB_ROOT ${EXTERNAL_ROOT}/stb) set(STB_ROOT ${EXTERNAL_ROOT}/stb)
set(SPIRV_ROOT ${EXTERNAL_ROOT}/SPIRV-Cross) set(SPIRV_ROOT ${EXTERNAL_ROOT}/SPIRV-Cross)
set(Boost_DEBUG ON)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS OFF)
set(Boost_LIB_PREFIX lib) set(Boost_LIB_PREFIX lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
@@ -43,13 +44,13 @@ endif()
find_package(Vulkan REQUIRED) find_package(Vulkan REQUIRED)
find_package(Boost REQUIRED COMPONENTS serialization) find_package(Boost REQUIRED COMPONENTS serialization)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(assimp REQUIRED) find_package(Assimp REQUIRED)
find_package(JSON REQUIRED) find_package(JSON REQUIRED)
find_package(GLFW REQUIRED) find_package(GLFW REQUIRED)
#find_package(SPIRV REQUIRED) #find_package(SPIRV REQUIRED)
find_package(GLM REQUIRED) find_package(GLM REQUIRED)
find_package(STB REQUIRED) find_package(STB REQUIRED)
find_package(SLang REQUIRED) find_package(SLANG REQUIRED)
include_directories(${GLM_INCLUDE_DIRS}) include_directories(${GLM_INCLUDE_DIRS})
include_directories(${STB_INCLUDE_DIRS}) include_directories(${STB_INCLUDE_DIRS})
@@ -80,22 +81,23 @@ target_link_libraries(SeeleEngine ${ASSIMP_LIBRARIES})
target_link_libraries(SeeleEngine ${JSON_LIBRARY}) target_link_libraries(SeeleEngine ${JSON_LIBRARY})
#target_link_libraries(SeeleEngine ${SPIRV_LIBRARIES}) #target_link_libraries(SeeleEngine ${SPIRV_LIBRARIES})
#target_precompile_headers(SeeleEngine target_precompile_headers(SeeleEngine
# PRIVATE PRIVATE
# <assert.h> <assert.h>
# <memory> <atomic>
# <atomic> <condition_variable>
# <cstring> <coroutine>
# <iostream> <cstring>
# <string> <filesystem>
# <thread> <functional>
# <functional> <fstream>
# <filesystem> <iostream>
# <fstream> <memory>
# <mutex> <mutex>
# <condition_variable> <string>
# <boost/serialization/serialization.hpp> <thread>
# <boost/crc.hpp>) <boost/serialization/serialization.hpp>
<boost/crc.hpp>)
add_subdirectory(src/) add_subdirectory(src/)
@@ -103,7 +105,7 @@ if(MSVC)
set(_CRT_SECURE_NO_WARNINGS) set(_CRT_SECURE_NO_WARNINGS)
# target_compile_options(SeeleEngine PRIVATE /DEBUG:FASTLINK /Zi) # target_compile_options(SeeleEngine PRIVATE /DEBUG:FASTLINK /Zi)
else() else()
target_compile_options(SeeleEngine PRIVATE -Wall -Wextra -pedantic) target_compile_options(SeeleEngine PRIVATE -Wall -Wextra -Wno-delete-incomplete -pedantic -fcoroutines)
endif() endif()
add_executable(Seele_unit_tests "") add_executable(Seele_unit_tests "")
+4 -3
View File
@@ -48,12 +48,13 @@ else()
/usr/local/include /usr/local/include
/sw/include /sw/include
/opt/local/include /opt/local/include
${ASSIMP_ROOT}/include
DOC "The directory where assimp/scene.h resides") DOC "The directory where assimp/scene.h resides")
# Find library files # Find library files
find_library( find_library(
ASSIMP_LIBRARY ASSIMP_LIBRARY
NAMES assimp NAMES libassimp${CMAKE_DEBUG_POSTFIX}.so
PATHS PATHS
/usr/lib64 /usr/lib64
/usr/lib /usr/lib
@@ -61,12 +62,12 @@ else()
/usr/local/lib /usr/local/lib
/sw/lib /sw/lib
/opt/local/lib /opt/local/lib
${ASSIMP_ROOT}/lib ${ASSIMP_ROOT}/bin
DOC "The Assimp library") DOC "The Assimp library")
endif() endif()
# Handle REQUIRD argument, define *_FOUND variable # Handle REQUIRD argument, define *_FOUND variable
find_package_handle_standard_args(assimp DEFAULT_MSG ASSIMP_INCLUDE_DIR ASSIMP_LIBRARY ASSIMP_BINARY) find_package_handle_standard_args(assimp DEFAULT_MSG ASSIMP_INCLUDE_DIR ASSIMP_LIBRARY)
# Define GLFW_LIBRARIES and GLFW_INCLUDE_DIRS # Define GLFW_LIBRARIES and GLFW_INCLUDE_DIRS
if (ASSIMP_FOUND) if (ASSIMP_FOUND)
+17 -16
View File
@@ -60,7 +60,7 @@ else()
# Find include files # Find include files
find_path( find_path(
GLFW_INCLUDE_DIR GLFW_INCLUDE_DIR
NAMES GLFW/glfw.h NAMES GLFW/glfw3.h
PATHS PATHS
/usr/include /usr/include
/usr/local/include /usr/local/include
@@ -70,22 +70,23 @@ else()
# Find library files # Find library files
# Try to use static libraries # Try to use static libraries
find_library( #find_library(
GLFW_LIBRARY # GLFW_LIBRARY
NAMES glfw3 # NAMES glfw3
PATHS # PATHS
/usr/lib64 # /usr/lib64
/usr/lib # /usr/lib
/usr/local/lib64 # /usr/local/lib64
/usr/local/lib # /usr/local/lib
/sw/lib # /sw/lib
/opt/local/lib # /opt/local/lib
${GLFW_ROOT}/lib # ${GLFW_ROOT}/lib
DOC "The GLFW library") # DOC "The GLFW library")
set(GLFW_LIBRARY "")
find_file( find_file(
GLFW_BINARY GLFW_BINARY
NAMES glfw3.so NAMES libglfw${CMAKE_DEBUG_POSTFIX}.so
PATHS PATHS
/usr/lib64 /usr/lib64
/usr/lib /usr/lib
@@ -93,12 +94,12 @@ else()
/usr/local/lib /usr/local/lib
/sw/lib /sw/lib
/opt/local/lib /opt/local/lib
${GLFW_ROOT}/lib ${GLFW_ROOT}/src
) )
endif() endif()
# Handle REQUIRD argument, define *_FOUND variable # Handle REQUIRD argument, define *_FOUND variable
find_package_handle_standard_args(GLFW DEFAULT_MSG GLFW_INCLUDE_DIR GLFW_LIBRARY GLFW_BINARY) find_package_handle_standard_args(GLFW DEFAULT_MSG GLFW_INCLUDE_DIR GLFW_BINARY)
# Define GLFW_LIBRARIES and GLFW_INCLUDE_DIRS # Define GLFW_LIBRARIES and GLFW_INCLUDE_DIRS
if (GLFW_FOUND) if (GLFW_FOUND)
+2 -1
View File
@@ -32,12 +32,13 @@ else()
# Find include files # Find include files
find_path( find_path(
GLM_INCLUDE_DIR GLM_INCLUDE_DIR
NAMES GLM/glfw.h NAMES glm/glm.hpp
PATHS PATHS
/usr/include /usr/include
/usr/local/include /usr/local/include
/sw/include /sw/include
/opt/local/include /opt/local/include
${GLM_ROOT}
DOC "The directory where GLM/glm.h resides") DOC "The directory where GLM/glm.h resides")
endif() endif()
+10 -7
View File
@@ -49,6 +49,7 @@ if (WIN32)
PATHS PATHS
${SLANG_BINARY_PATH}) ${SLANG_BINARY_PATH})
else() else()
set(SLANG_BINARY_PATH ${SLANG_ROOT}/bin/linux-${CMAKE_PLATFORM}/release/)
# Find include files # Find include files
find_path( find_path(
SLANG_INCLUDE_DIR SLANG_INCLUDE_DIR
@@ -58,13 +59,15 @@ else()
/usr/local/include /usr/local/include
/sw/include /sw/include
/opt/local/include /opt/local/include
${SLANG_ROOT}
DOC "The directory where GL/glfw.h resides") DOC "The directory where GL/glfw.h resides")
# Find library files # Find library files
# Try to use static libraries # Try to use static libraries
set(SLANG_LIBRARY "")
find_library( find_library(
SLANG_LIBRARY SLANG_BINARY
NAMES slang.a NAMES libslang.so
PATHS PATHS
/usr/lib64 /usr/lib64
/usr/lib /usr/lib
@@ -72,12 +75,12 @@ else()
/usr/local/lib /usr/local/lib
/sw/lib /sw/lib
/opt/local/lib /opt/local/lib
${SLANG_ROOT}/lib ${SLANG_BINARY_PATH}
DOC "The SLANG library") DOC "The SLANG library")
find_file( find_file(
SLANG_BINARY SLANG_GLSLANG
NAMES slang.so NAMES libslang-glslang.so
PATHS PATHS
/usr/lib64 /usr/lib64
/usr/lib /usr/lib
@@ -85,12 +88,12 @@ else()
/usr/local/lib /usr/local/lib
/sw/lib /sw/lib
/opt/local/lib /opt/local/lib
${SLANG_ROOT}/lib ${SLANG_BINARY_PATH}
) )
endif() endif()
# Handle REQUIRD argument, define *_FOUND variable # Handle REQUIRD argument, define *_FOUND variable
find_package_handle_standard_args(SLANG DEFAULT_MSG SLANG_INCLUDE_DIR SLANG_LIBRARY SLANG_BINARY SLANG_GLSLANG) find_package_handle_standard_args(SLANG DEFAULT_MSG SLANG_INCLUDE_DIR SLANG_BINARY SLANG_GLSLANG)
# Define SLANG_LIBRARIES and SLANG_INCLUDE_DIRS # Define SLANG_LIBRARIES and SLANG_INCLUDE_DIRS
if (SLANG_FOUND) if (SLANG_FOUND)
+1
View File
@@ -38,6 +38,7 @@ else()
/usr/local/include /usr/local/include
/sw/include /sw/include
/opt/local/include /opt/local/include
${STB_ROOT}
DOC "The directory where STB/stb.h resides") DOC "The directory where STB/stb.h resides")
endif() endif()
+2 -1
View File
@@ -14,6 +14,7 @@ set(BUILD_SHARED_LIBS ON CACHE INTERNAL "")
add_subdirectory(${ASSIMP_ROOT} ${ASSIMP_ROOT}) add_subdirectory(${ASSIMP_ROOT} ${ASSIMP_ROOT})
target_compile_definitions(assimp PRIVATE _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING) target_compile_definitions(assimp PRIVATE _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
target_compile_options(assimp PRIVATE -Wno-error)
#-------------BOOST---------------- #-------------BOOST----------------
list(APPEND DEPENDENCIES boost) list(APPEND DEPENDENCIES boost)
@@ -31,7 +32,7 @@ ExternalProject_Add(boost
INSTALL_COMMAND "") INSTALL_COMMAND "")
list (APPEND EXTRA_CMAKE_ARGS list (APPEND EXTRA_CMAKE_ARGS
-DBoost_NO_SYSTEM_PATHS=ON) -DBoost_NO_SYSTEM_PATHS=OFF)
#--------------------JSON------------------ #--------------------JSON------------------
list(APPEND DEPENDENCIES nlohmann_json) list(APPEND DEPENDENCIES nlohmann_json)
Regular → Executable
View File
-1
View File
@@ -1 +0,0 @@
add_subdirectory(x64/)
+3 -5
View File
@@ -1,7 +1,5 @@
#pragma once #pragma once
#include "MinimalEngine.h" #include "MinimalEngine.h"
#include <filesystem>
#include <fstream>
namespace Seele namespace Seele
{ {
@@ -43,15 +41,15 @@ protected:
std::ifstream& getReadStream(); std::ifstream& getReadStream();
std::ofstream& getWriteStream(); std::ofstream& getWriteStream();
private: private:
Status status;
// Path relative to the project root // Path relative to the project root
std::filesystem::path fullPath; std::filesystem::path fullPath;
std::filesystem::path parentDir;
std::filesystem::path name; std::filesystem::path name;
std::filesystem::path parentDir;
std::filesystem::path extension; std::filesystem::path extension;
Status status;
uint32 byteSize; uint32 byteSize;
std::ifstream inStream; std::ifstream inStream;
std::ofstream outStream; std::ofstream outStream;
}; };
DEFINE_REF(Asset); DEFINE_REF(Asset)
} // namespace Seele } // namespace Seele
+1
View File
@@ -7,6 +7,7 @@
#include "Material/Material.h" #include "Material/Material.h"
#include "Graphics/Graphics.h" #include "Graphics/Graphics.h"
#include "Window/WindowManager.h" #include "Window/WindowManager.h"
#include "MeshAsset.h"
#include <iostream> #include <iostream>
using namespace Seele; using namespace Seele;
+11 -11
View File
@@ -5,13 +5,13 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(TextureLoader); DECLARE_REF(TextureLoader)
DECLARE_REF(MeshLoader); DECLARE_REF(MeshLoader)
DECLARE_REF(MaterialLoader); DECLARE_REF(MaterialLoader)
DECLARE_REF(TextureAsset); DECLARE_REF(TextureAsset)
DECLARE_REF(MeshAsset); DECLARE_REF(MeshAsset)
DECLARE_REF(MaterialAsset); DECLARE_REF(MaterialAsset)
DECLARE_NAME_REF(Gfx, Graphics); DECLARE_NAME_REF(Gfx, Graphics)
class AssetRegistry class AssetRegistry
{ {
public: public:
@@ -26,8 +26,8 @@ public:
static PTextureAsset findTexture(const std::string& filePath); static PTextureAsset findTexture(const std::string& filePath);
static PMaterialAsset findMaterial(const std::string& filePath); static PMaterialAsset findMaterial(const std::string& filePath);
static std::ofstream createWriteStream(const std::string& relativePath, std::ios_base::openmode openmode = 0); static std::ofstream createWriteStream(const std::string& relativePath, std::ios_base::openmode openmode = std::ios::out);
static std::ifstream createReadStream(const std::string& relativePath, std::ios_base::openmode openmode = 0); static std::ifstream createReadStream(const std::string& relativePath, std::ios_base::openmode openmode = std::ios::in);
private: private:
static AssetRegistry& get(); static AssetRegistry& get();
@@ -42,8 +42,8 @@ private:
void registerTexture(PTextureAsset texture); void registerTexture(PTextureAsset texture);
void registerMaterial(PMaterialAsset material); void registerMaterial(PMaterialAsset material);
std::ofstream internalCreateWriteStream(const std::string& relativePath, std::ios_base::openmode openmode = 0); std::ofstream internalCreateWriteStream(const std::string& relativePath, std::ios_base::openmode openmode = std::ios::out);
std::ifstream internalCreateReadStream(const std::string& relaitvePath, std::ios_base::openmode openmode = 0); std::ifstream internalCreateReadStream(const std::string& relaitvePath, std::ios_base::openmode openmode = std::ios::in);
std::filesystem::path rootFolder; std::filesystem::path rootFolder;
Map<std::string, PTextureAsset> textures; Map<std::string, PTextureAsset> textures;
+2 -2
View File
@@ -8,7 +8,7 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(Material) DECLARE_REF(Material)
DECLARE_NAME_REF(Gfx, Graphics); DECLARE_NAME_REF(Gfx, Graphics)
class MaterialLoader class MaterialLoader
{ {
public: public:
@@ -21,5 +21,5 @@ private:
List<std::future<void>> futures; List<std::future<void>> futures;
PMaterial placeholderMaterial; PMaterial placeholderMaterial;
}; };
DEFINE_REF(MaterialLoader); DEFINE_REF(MaterialLoader)
} // namespace Seele } // namespace Seele
+3 -3
View File
@@ -3,8 +3,8 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(Mesh); DECLARE_REF(Mesh)
DECLARE_REF(MaterialAsset); DECLARE_REF(MaterialAsset)
class MeshAsset : public Asset class MeshAsset : public Asset
{ {
public: public:
@@ -20,5 +20,5 @@ private:
Array<PMesh> meshes; Array<PMesh> meshes;
Array<PMaterialAsset> referencedMaterials; Array<PMaterialAsset> referencedMaterials;
}; };
DEFINE_REF(MeshAsset); DEFINE_REF(MeshAsset)
} // namespace Seele } // namespace Seele
+2 -2
View File
@@ -197,7 +197,7 @@ void MeshLoader::convertAssimpARGB(unsigned char* dst, aiTexel* src, uint32 numP
dst[i * 4 + 3] = src[i].a; dst[i * 4 + 3] = src[i].a;
} }
} }
void MeshLoader::loadTextures(const aiScene* scene, Gfx::PGraphics graphics, const std::filesystem::path& meshDirectory) void MeshLoader::loadTextures(const aiScene* scene, const std::filesystem::path& meshDirectory)
{ {
for (uint32 i = 0; i < scene->mNumTextures; ++i) for (uint32 i = 0; i < scene->mNumTextures; ++i)
{ {
@@ -237,7 +237,7 @@ void MeshLoader::import(const std::filesystem::path &path)
const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace); const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace);
Array<PMaterialAsset> globalMaterials(scene->mNumMaterials); Array<PMaterialAsset> globalMaterials(scene->mNumMaterials);
loadTextures(scene, graphics, path.parent_path()); loadTextures(scene, path.parent_path());
loadMaterials(scene, globalMaterials, graphics); loadMaterials(scene, globalMaterials, graphics);
Array<PMesh> globalMeshes(scene->mNumMeshes); Array<PMesh> globalMeshes(scene->mNumMeshes);
+6 -6
View File
@@ -9,10 +9,10 @@ struct aiScene;
struct aiTexel; struct aiTexel;
namespace Seele namespace Seele
{ {
DECLARE_REF(Mesh); DECLARE_REF(Mesh)
DECLARE_REF(MeshAsset); DECLARE_REF(MeshAsset)
DECLARE_REF(MaterialAsset); DECLARE_REF(MaterialAsset)
DECLARE_NAME_REF(Gfx, Graphics); DECLARE_NAME_REF(Gfx, Graphics)
class MeshLoader class MeshLoader
{ {
public: public:
@@ -21,7 +21,7 @@ public:
void importAsset(const std::filesystem::path& filePath); void importAsset(const std::filesystem::path& filePath);
private: private:
void loadMaterials(const aiScene* scene, Array<PMaterialAsset>& globalMaterials, Gfx::PGraphics graphics); void loadMaterials(const aiScene* scene, Array<PMaterialAsset>& globalMaterials, Gfx::PGraphics graphics);
void loadTextures(const aiScene* scene, Gfx::PGraphics graphics, const std::filesystem::path& meshPath); void loadTextures(const aiScene* scene, const std::filesystem::path& meshPath);
void loadGlobalMeshes(const aiScene* scene, Array<PMesh>& globalMeshes, const Array<PMaterialAsset>& materials, Gfx::PGraphics graphics); void loadGlobalMeshes(const aiScene* scene, Array<PMesh>& globalMeshes, const Array<PMaterialAsset>& materials, Gfx::PGraphics graphics);
void convertAssimpARGB(unsigned char* dst, aiTexel* src, uint32 numPixels); void convertAssimpARGB(unsigned char* dst, aiTexel* src, uint32 numPixels);
@@ -29,5 +29,5 @@ private:
List<std::future<void>> futures; List<std::future<void>> futures;
Gfx::PGraphics graphics; Gfx::PGraphics graphics;
}; };
DEFINE_REF(MeshLoader); DEFINE_REF(MeshLoader)
} // namespace Seele } // namespace Seele
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Seele namespace Seele
{ {
DECLARE_NAME_REF(Gfx, Texture); DECLARE_NAME_REF(Gfx, Texture)
class TextureAsset : public Asset class TextureAsset : public Asset
{ {
public: public:
@@ -25,5 +25,5 @@ private:
Gfx::PTexture texture; Gfx::PTexture texture;
friend class TextureLoader; friend class TextureLoader;
}; };
DEFINE_REF(TextureAsset); DEFINE_REF(TextureAsset)
} // namespace Seele } // namespace Seele
+4 -4
View File
@@ -7,9 +7,9 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(TextureAsset); DECLARE_REF(TextureAsset)
DECLARE_NAME_REF(Gfx, Graphics); DECLARE_NAME_REF(Gfx, Graphics)
DECLARE_NAME_REF(Gfx, Texture2D); DECLARE_NAME_REF(Gfx, Texture2D)
class TextureLoader class TextureLoader
{ {
public: public:
@@ -24,5 +24,5 @@ private:
Gfx::PTexture2D placeholderTexture; Gfx::PTexture2D placeholderTexture;
PTextureAsset placeholderAsset; PTextureAsset placeholderAsset;
}; };
DEFINE_REF(TextureLoader); DEFINE_REF(TextureLoader)
} // namespace Seele } // namespace Seele
+1 -2
View File
@@ -5,9 +5,8 @@ target_sources(SeeleEngine
main.cpp) main.cpp)
add_subdirectory(Asset/) add_subdirectory(Asset/)
add_subdirectory(Arch/)
add_subdirectory(Containers/) add_subdirectory(Containers/)
add_subdirectory(Fibers/) #add_subdirectory(Fibers/)
add_subdirectory(Graphics/) add_subdirectory(Graphics/)
add_subdirectory(Material/) add_subdirectory(Material/)
add_subdirectory(Math/) add_subdirectory(Math/)
+42 -26
View File
@@ -17,8 +17,8 @@ namespace Seele
{ {
public: public:
Array() Array()
: allocated(DEFAULT_ALLOC_SIZE) : arraySize(0)
, arraySize(0) , allocated(DEFAULT_ALLOC_SIZE)
{ {
_data = new T[DEFAULT_ALLOC_SIZE]; _data = new T[DEFAULT_ALLOC_SIZE];
assert(_data != nullptr); assert(_data != nullptr);
@@ -26,7 +26,8 @@ namespace Seele
refreshIterators(); refreshIterators();
} }
Array(size_t size, T value = T()) Array(size_t size, T value = T())
: allocated(size), arraySize(size) : arraySize(size)
, allocated(size)
{ {
_data = new T[size]; _data = new T[size];
assert(_data != nullptr); assert(_data != nullptr);
@@ -38,7 +39,8 @@ namespace Seele
refreshIterators(); refreshIterators();
} }
Array(std::initializer_list<T> init) Array(std::initializer_list<T> init)
: allocated(init.size()), arraySize(init.size()) : arraySize(init.size())
, allocated(init.size())
{ {
_data = new T[init.size()]; _data = new T[init.size()];
auto it = init.begin(); auto it = init.begin();
@@ -50,7 +52,8 @@ namespace Seele
refreshIterators(); refreshIterators();
} }
Array(const Array &other) Array(const Array &other)
: allocated(other.allocated), arraySize(other.arraySize) : arraySize(other.arraySize)
, allocated(other.allocated)
{ {
_data = new T[other.allocated]; _data = new T[other.allocated];
assert(_data != nullptr); assert(_data != nullptr);
@@ -58,7 +61,8 @@ namespace Seele
std::copy(other.begin(), other.end(), beginIt); std::copy(other.begin(), other.end(), beginIt);
} }
Array(Array &&other) noexcept Array(Array &&other) noexcept
: allocated(std::move(other.allocated)), arraySize(std::move(other.arraySize)) : arraySize(std::move(other.arraySize))
, allocated(std::move(other.allocated))
{ {
_data = other._data; _data = other._data;
other._data = nullptr; other._data = nullptr;
@@ -110,20 +114,16 @@ namespace Seele
class IteratorBase class IteratorBase
{ {
public: public:
typedef std::forward_iterator_tag iterator_category; using iterator_category = std::random_access_iterator_tag;
typedef X value_type; using value_type = X;
typedef std::ptrdiff_t difference_type; using difference_type = std::ptrdiff_t;
typedef X &reference; using reference = X&;
typedef X *pointer; using pointer = X*;
IteratorBase(X *x = nullptr) IteratorBase(X *x = nullptr)
: p(x) : p(x)
{ {
} }
IteratorBase(const IteratorBase &i)
: p(i.p)
{
}
reference operator*() const reference operator*() const
{ {
return *p; return *p;
@@ -263,7 +263,7 @@ namespace Seele
T &addUnique(const T &item = T()) T &addUnique(const T &item = T())
{ {
Iterator it; Iterator it;
if((it = find(item)) != endIt) if((it = std::move(find(item))) != endIt)
{ {
return *it; return *it;
} }
@@ -297,7 +297,10 @@ namespace Seele
{ {
if (keepOrder) if (keepOrder)
{ {
std::memcpy(&_data[index], &_data[index + 1], sizeof(T) * (arraySize - index)); for(uint32 i = index; i < arraySize-1; ++i)
{
_data[i] = std::move(_data[i+1]);
}
} }
else else
{ {
@@ -324,7 +327,10 @@ namespace Seele
T *newData = new T[newSize]; T *newData = new T[newSize];
assert(newData != nullptr); assert(newData != nullptr);
allocated = newSize; allocated = newSize;
std::memcpy(newData, _data, sizeof(T) * arraySize); for(uint32 i = 0; i < arraySize; ++i)
{
newData[i] = std::move(_data[i]);
}
arraySize = newSize; arraySize = newSize;
delete _data; delete _data;
_data = newData; _data = newData;
@@ -410,8 +416,9 @@ namespace Seele
template<class Archive> template<class Archive>
void serialize(Archive& ar, const unsigned int version) void serialize(Archive& ar, const unsigned int version)
{ {
ar & version;
ar & arraySize; ar & arraySize;
ar & allocated; resize(arraySize);
for(size_t i = 0; i < arraySize; ++i) for(size_t i = 0; i < arraySize; ++i)
ar & _data[i]; ar & _data[i];
refreshIterators(); refreshIterators();
@@ -431,7 +438,7 @@ namespace Seele
class IteratorBase class IteratorBase
{ {
public: public:
using iterator_category = std::forward_iterator_tag; using iterator_category = std::random_access_iterator_tag;
using value_type = X; using value_type = X;
using difference_type = std::ptrdiff_t; using difference_type = std::ptrdiff_t;
using reference = X&; using reference = X&;
@@ -441,10 +448,6 @@ namespace Seele
: p(x) : p(x)
{ {
} }
IteratorBase(const IteratorBase &i)
: p(i.p)
{
}
reference operator*() const reference operator*() const
{ {
return *p; return *p;
@@ -472,6 +475,18 @@ namespace Seele
++*this; ++*this;
return tmp; return tmp;
} }
IteratorBase &operator--()
{
p--;
return *this;
}
IteratorBase operator--(int)
{
IteratorBase tmp(*this);
--*this;
return tmp;
}
private: private:
X *p; X *p;
@@ -522,12 +537,12 @@ namespace Seele
} }
constexpr reference operator[](size_type index) noexcept constexpr reference operator[](size_type index) noexcept
{ {
assert(index >= 0 && index < N); assert(index < N);
return _data[index]; return _data[index];
} }
constexpr const_reference operator[](size_type index) const noexcept constexpr const_reference operator[](size_type index) const noexcept
{ {
assert(index >= 0 && index < N); assert(index < N);
return _data[index]; return _data[index];
} }
iterator begin() iterator begin()
@@ -554,6 +569,7 @@ namespace Seele
template<class Archive> template<class Archive>
void serialize(Archive& ar, const unsigned int version) void serialize(Archive& ar, const unsigned int version)
{ {
ar & version;
ar & N; ar & N;
ar & _data; ar & _data;
} }
+1 -1
View File
@@ -28,9 +28,9 @@ struct Map
private: private:
struct Node struct Node
{ {
Pair<K, V> pair;
Node *leftChild; Node *leftChild;
Node *rightChild; Node *rightChild;
Pair<K, V> pair;
Node() Node()
: leftChild(nullptr), rightChild(nullptr), pair() : leftChild(nullptr), rightChild(nullptr), pair()
{ {
+6 -6
View File
@@ -1,6 +1,6 @@
target_sources(SeeleEngine #target_sources(SeeleEngine
PRIVATE # PRIVATE
Fibers.h # Fibers.h
Fibers.cpp # Fibers.cpp
JobQueue.h # JobQueue.h
JobQueue.cpp) # JobQueue.cpp)
+2 -4
View File
@@ -1,8 +1,6 @@
#pragma once #pragma once
#include "MinimalEngine.h" #include "MinimalEngine.h"
#include "JobQueue.h" #include "JobQueue.h"
#include <atomic>
#include <functional>
namespace Seele namespace Seele
{ {
@@ -67,14 +65,14 @@ public:
private: private:
std::atomic_uint64_t count; std::atomic_uint64_t count;
}; };
DEFINE_REF(Counter); DEFINE_REF(Counter)
struct AwaitCounter struct AwaitCounter
{ {
PCounter counter; PCounter counter;
uint64 target; uint64 target;
JobPriority priority = JobPriority::MEDIUM; JobPriority priority = JobPriority::MEDIUM;
bool await_ready() { return counter->greaterEqual(target); } bool await_ready() { return counter->greaterEqual(target); }
void await_suspend(std::coroutine_handle<> h) { void await_suspend(std::coroutine_handle<>) {
} }
void await_resume() {} void await_resume() {}
}; };
+1 -2
View File
@@ -1,13 +1,12 @@
#pragma once #pragma once
#include "MinimalEngine.h" #include "MinimalEngine.h"
#include "Containers/List.h" #include "Containers/List.h"
#include <coroutine>
namespace Seele namespace Seele
{ {
namespace Fibers namespace Fibers
{ {
class FiberJob; class FiberJob;
DECLARE_REF(Counter); DECLARE_REF(Counter)
enum class JobPriority : size_t enum class JobPriority : size_t
{ {
HIGH = 0, HIGH = 0,
+1 -1
View File
@@ -61,6 +61,6 @@ protected:
PShaderCompiler shaderCompiler; PShaderCompiler shaderCompiler;
friend class Window; friend class Window;
}; };
DEFINE_REF(Graphics); DEFINE_REF(Graphics)
} // namespace Gfx } // namespace Gfx
} // namespace Seele } // namespace Seele
+23 -13
View File
@@ -6,10 +6,9 @@ namespace Seele
struct GraphicsInitializer struct GraphicsInitializer
{ {
const char *windowLayoutFile;
const char *applicationName; const char *applicationName;
const char *engineName; const char *engineName;
void *windowHandle; const char *windowLayoutFile;
/** /**
* layers defines the enabled Vulkan layers used in the instance, * layers defines the enabled Vulkan layers used in the instance,
* if ENABLE_VALIDATION is defined, standard validation is already enabled * if ENABLE_VALIDATION is defined, standard validation is already enabled
@@ -18,12 +17,23 @@ struct GraphicsInitializer
Array<const char *> layers; Array<const char *> layers;
Array<const char *> instanceExtensions; Array<const char *> instanceExtensions;
Array<const char *> deviceExtensions; Array<const char *> deviceExtensions;
void *windowHandle;
GraphicsInitializer() GraphicsInitializer()
: applicationName("SeeleEngine"), engineName("SeeleEngine"), layers{"VK_LAYER_KHRONOS_validation"}, instanceExtensions{}, deviceExtensions{"VK_KHR_swapchain"}, windowHandle(nullptr) : applicationName("SeeleEngine")
, engineName("SeeleEngine")
, layers{"VK_LAYER_KHRONOS_validation"}
, instanceExtensions{}
, deviceExtensions{"VK_KHR_swapchain"}
, windowHandle(nullptr)
{ {
} }
GraphicsInitializer(const GraphicsInitializer &other) GraphicsInitializer(const GraphicsInitializer &other)
: applicationName(other.applicationName), engineName(other.engineName), layers(other.layers), instanceExtensions(other.instanceExtensions), deviceExtensions(other.deviceExtensions) : applicationName(other.applicationName)
, engineName(other.engineName)
, layers(other.layers)
, instanceExtensions(other.instanceExtensions)
, deviceExtensions(other.deviceExtensions)
{ {
} }
}; };
@@ -191,14 +201,14 @@ struct ColorBlendState
float blendConstants[4]; float blendConstants[4];
}; };
} // namespace Gfx } // namespace Gfx
DECLARE_NAME_REF(Gfx, VertexDeclaration); DECLARE_NAME_REF(Gfx, VertexDeclaration)
DECLARE_NAME_REF(Gfx, VertexShader); DECLARE_NAME_REF(Gfx, VertexShader)
DECLARE_NAME_REF(Gfx, ControlShader); DECLARE_NAME_REF(Gfx, ControlShader)
DECLARE_NAME_REF(Gfx, EvaluationShader); DECLARE_NAME_REF(Gfx, EvaluationShader)
DECLARE_NAME_REF(Gfx, GeometryShader); DECLARE_NAME_REF(Gfx, GeometryShader)
DECLARE_NAME_REF(Gfx, FragmentShader); DECLARE_NAME_REF(Gfx, FragmentShader)
DECLARE_NAME_REF(Gfx, PipelineLayout); DECLARE_NAME_REF(Gfx, PipelineLayout)
DECLARE_NAME_REF(Gfx, RenderPass); DECLARE_NAME_REF(Gfx, RenderPass)
struct GraphicsPipelineCreateInfo struct GraphicsPipelineCreateInfo
{ {
Gfx::PVertexDeclaration vertexDeclaration; Gfx::PVertexDeclaration vertexDeclaration;
@@ -216,7 +226,7 @@ struct GraphicsPipelineCreateInfo
Gfx::ColorBlendState colorBlend; Gfx::ColorBlendState colorBlend;
GraphicsPipelineCreateInfo() GraphicsPipelineCreateInfo()
{ {
std::memset(this, 0, sizeof(*this)); std::memset((void*)this, 0, sizeof(*this));
topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
rasterizationState.cullMode = Gfx::SE_CULL_MODE_BACK_BIT; rasterizationState.cullMode = Gfx::SE_CULL_MODE_BACK_BIT;
rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_FILL; rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_FILL;
+40 -12
View File
@@ -43,7 +43,7 @@ ShaderCollection& ShaderMap::createShaders(
RenderPassType renderPass, RenderPassType renderPass,
PMaterial material, PMaterial material,
VertexInputType* vertexInput, VertexInputType* vertexInput,
bool bPositionOnly) bool /*bPositionOnly*/)
{ {
ShaderCollection& collection = shaders.add(); ShaderCollection& collection = shaders.add();
//collection.vertexDeclaration = bPositionOnly ? vertexInput->getPositionDeclaration() : vertexInput->getDeclaration(); //collection.vertexDeclaration = bPositionOnly ? vertexInput->getPositionDeclaration() : vertexInput->getDeclaration();
@@ -139,8 +139,8 @@ void PipelineLayout::addPushConstants(const SePushConstantRange &pushConstant)
} }
QueueOwnedResource::QueueOwnedResource(QueueFamilyMapping mapping, QueueType startQueueType) QueueOwnedResource::QueueOwnedResource(QueueFamilyMapping mapping, QueueType startQueueType)
: mapping(mapping) : currentOwner(startQueueType)
, currentOwner(startQueueType) , mapping(mapping)
{ {
} }
@@ -224,7 +224,9 @@ IndexBuffer::~IndexBuffer()
VertexStream::VertexStream() VertexStream::VertexStream()
{} {}
VertexStream::VertexStream(uint32 stride, uint32 offset, uint8 instanced) VertexStream::VertexStream(uint32 stride, uint32 offset, uint8 instanced)
: stride(stride), instanced(instanced), offset(offset) : stride(stride)
, offset(offset)
, instanced(instanced)
{ {
} }
VertexStream::~VertexStream() VertexStream::~VertexStream()
@@ -294,31 +296,53 @@ RenderCommand::~RenderCommand()
} }
RenderTargetLayout::RenderTargetLayout() RenderTargetLayout::RenderTargetLayout()
: inputAttachments(), colorAttachments(), depthAttachment() : inputAttachments()
, colorAttachments()
, depthAttachment()
{ {
} }
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment depthAttachment) RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment depthAttachment)
: inputAttachments(), colorAttachments(), depthAttachment(depthAttachment), width(depthAttachment->getTexture()->getSizeX()), height(depthAttachment->getTexture()->getSizeY()) : inputAttachments()
, colorAttachments()
, depthAttachment(depthAttachment)
, width(depthAttachment->getTexture()->getSizeX())
, height(depthAttachment->getTexture()->getSizeY())
{ {
} }
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment) RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment)
: inputAttachments(), depthAttachment(depthAttachment), width(depthAttachment->getTexture()->getSizeX()), height(depthAttachment->getTexture()->getSizeY()) : inputAttachments()
, depthAttachment(depthAttachment)
, width(depthAttachment->getTexture()->getSizeX())
, height(depthAttachment->getTexture()->getSizeY())
{ {
colorAttachments.add(colorAttachment); colorAttachments.add(colorAttachment);
} }
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachmet) RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment)
: inputAttachments(), colorAttachments(colorAttachments), depthAttachment(depthAttachment), width(depthAttachment->getTexture()->getSizeX()), height(depthAttachment->getTexture()->getSizeY()) : inputAttachments()
, colorAttachments(colorAttachments)
, depthAttachment(depthAttachment)
, width(depthAttachment->getTexture()->getSizeX())
, height(depthAttachment->getTexture()->getSizeY())
{ {
} }
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment) RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment)
: inputAttachments(inputAttachments), colorAttachments(colorAttachments), depthAttachment(depthAttachment), width(depthAttachment->getTexture()->getSizeX()), height(depthAttachment->getTexture()->getSizeY()) : inputAttachments(inputAttachments)
, colorAttachments(colorAttachments)
, depthAttachment(depthAttachment)
, width(depthAttachment->getTexture()->getSizeX())
, height(depthAttachment->getTexture()->getSizeY())
{ {
} }
Window::Window(const WindowCreateInfo &createInfo) Window::Window(const WindowCreateInfo &createInfo)
: sizeX(createInfo.width), sizeY(createInfo.height), bFullscreen(createInfo.bFullscreen), title(createInfo.title), pixelFormat(createInfo.pixelFormat), samples(createInfo.numSamples) : sizeX(createInfo.width)
, sizeY(createInfo.height)
, bFullscreen(createInfo.bFullscreen)
, title(createInfo.title)
, pixelFormat(createInfo.pixelFormat)
, samples(createInfo.numSamples)
{ {
} }
@@ -327,7 +351,11 @@ Window::~Window()
} }
Viewport::Viewport(PWindow owner, const ViewportCreateInfo &viewportInfo) Viewport::Viewport(PWindow owner, const ViewportCreateInfo &viewportInfo)
: sizeX(viewportInfo.sizeX), sizeY(viewportInfo.sizeY), offsetX(viewportInfo.offsetX), offsetY(viewportInfo.offsetY), owner(owner) : sizeX(viewportInfo.sizeX)
, sizeY(viewportInfo.sizeY)
, offsetX(viewportInfo.offsetX)
, offsetY(viewportInfo.offsetY)
, owner(owner)
{ {
} }
+47 -40
View File
@@ -20,7 +20,7 @@ class VertexInputType;
DECLARE_REF(Material) DECLARE_REF(Material)
namespace Gfx namespace Gfx
{ {
DECLARE_REF(Graphics); DECLARE_REF(Graphics)
class SamplerState class SamplerState
{ {
@@ -29,11 +29,11 @@ public:
{ {
} }
}; };
DEFINE_REF(SamplerState); DEFINE_REF(SamplerState)
class Shader class Shader
{}; {};
DEFINE_REF(Shader); DEFINE_REF(Shader)
class VertexShader class VertexShader
{ {
@@ -41,7 +41,7 @@ public:
VertexShader() {} VertexShader() {}
virtual ~VertexShader() {} virtual ~VertexShader() {}
}; };
DEFINE_REF(VertexShader); DEFINE_REF(VertexShader)
class ControlShader class ControlShader
{ {
public: public:
@@ -52,28 +52,28 @@ public:
protected: protected:
uint32 numPatchPoints; uint32 numPatchPoints;
}; };
DEFINE_REF(ControlShader); DEFINE_REF(ControlShader)
class EvaluationShader class EvaluationShader
{ {
public: public:
EvaluationShader() {} EvaluationShader() {}
virtual ~EvaluationShader() {} virtual ~EvaluationShader() {}
}; };
DEFINE_REF(EvaluationShader); DEFINE_REF(EvaluationShader)
class GeometryShader class GeometryShader
{ {
public: public:
GeometryShader() {} GeometryShader() {}
virtual ~GeometryShader() {} virtual ~GeometryShader() {}
}; };
DEFINE_REF(GeometryShader); DEFINE_REF(GeometryShader)
class FragmentShader class FragmentShader
{ {
public: public:
FragmentShader() {} FragmentShader() {}
virtual ~FragmentShader() {} virtual ~FragmentShader() {}
}; };
DEFINE_REF(FragmentShader); DEFINE_REF(FragmentShader)
//Uniquely identifies a permutation of shaders //Uniquely identifies a permutation of shaders
//using the type parameters used to generate it //using the type parameters used to generate it
@@ -138,7 +138,7 @@ public:
private: private:
Array<ShaderCollection> shaders; Array<ShaderCollection> shaders;
}; };
DEFINE_REF(ShaderMap); DEFINE_REF(ShaderMap)
class ComputeShader class ComputeShader
{ {
@@ -146,7 +146,7 @@ public:
ComputeShader() {} ComputeShader() {}
virtual ~ComputeShader() {} virtual ~ComputeShader() {}
}; };
DEFINE_REF(ComputeShader); DEFINE_REF(ComputeShader)
class DescriptorBinding class DescriptorBinding
{ {
@@ -171,9 +171,9 @@ public:
uint32_t descriptorCount; uint32_t descriptorCount;
SeShaderStageFlags shaderStages; SeShaderStageFlags shaderStages;
}; };
DEFINE_REF(DescriptorBinding); DEFINE_REF(DescriptorBinding)
DECLARE_REF(DescriptorSet); DECLARE_REF(DescriptorSet)
class DescriptorAllocator class DescriptorAllocator
{ {
public: public:
@@ -182,10 +182,10 @@ public:
virtual void allocateDescriptorSet(PDescriptorSet &descriptorSet) = 0; virtual void allocateDescriptorSet(PDescriptorSet &descriptorSet) = 0;
virtual void reset() = 0; virtual void reset() = 0;
}; };
DEFINE_REF(DescriptorAllocator); DEFINE_REF(DescriptorAllocator)
DECLARE_REF(UniformBuffer); DECLARE_REF(UniformBuffer)
DECLARE_REF(StructuredBuffer); DECLARE_REF(StructuredBuffer)
DECLARE_REF(Texture); DECLARE_REF(Texture)
class DescriptorSet class DescriptorSet
{ {
public: public:
@@ -199,7 +199,7 @@ public:
virtual uint32 getSetIndex() const = 0; virtual uint32 getSetIndex() const = 0;
}; };
DEFINE_REF(DescriptorSet); DEFINE_REF(DescriptorSet)
class DescriptorLayout class DescriptorLayout
{ {
@@ -209,10 +209,17 @@ public:
{ {
} }
virtual ~DescriptorLayout() {} virtual ~DescriptorLayout() {}
void operator=(const DescriptorLayout &other) DescriptorLayout& operator=(const DescriptorLayout &other)
{
if(this != &other)
{ {
descriptorBindings.resize(other.descriptorBindings.size()); descriptorBindings.resize(other.descriptorBindings.size());
std::memcpy(descriptorBindings.data(), other.descriptorBindings.data(), sizeof(DescriptorLayout) * descriptorBindings.size()); for(uint32 i = 0; i < descriptorBindings.size(); ++i)
{
descriptorBindings[i] = other.descriptorBindings[i];
}
}
return *this;
} }
virtual void create() = 0; virtual void create() = 0;
virtual void addDescriptorBinding(uint32 binding, SeDescriptorType type, uint32 arrayCount = 1); virtual void addDescriptorBinding(uint32 binding, SeDescriptorType type, uint32 arrayCount = 1);
@@ -228,7 +235,7 @@ protected:
friend class PipelineLayout; friend class PipelineLayout;
friend class DescriptorAllocator; friend class DescriptorAllocator;
}; };
DEFINE_REF(DescriptorLayout); DEFINE_REF(DescriptorLayout)
class PipelineLayout class PipelineLayout
{ {
public: public:
@@ -244,7 +251,7 @@ protected:
Array<PDescriptorLayout> descriptorSetLayouts; Array<PDescriptorLayout> descriptorSetLayouts;
Array<SePushConstantRange> pushConstants; Array<SePushConstantRange> pushConstants;
}; };
DEFINE_REF(PipelineLayout); DEFINE_REF(PipelineLayout)
struct QueueFamilyMapping struct QueueFamilyMapping
{ {
@@ -290,7 +297,7 @@ protected:
Gfx::QueueType currentOwner; Gfx::QueueType currentOwner;
QueueFamilyMapping mapping; QueueFamilyMapping mapping;
}; };
DEFINE_REF(QueueOwnedResource); DEFINE_REF(QueueOwnedResource)
// IMPORTANT!! // IMPORTANT!!
// WHEN DERIVING FROM ANY Gfx:: BASE CLASSES WITH MULTIPLE INHERITANCE // WHEN DERIVING FROM ANY Gfx:: BASE CLASSES WITH MULTIPLE INHERITANCE
@@ -337,7 +344,7 @@ protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(QueueType newOwner) = 0; virtual void executeOwnershipBarrier(QueueType newOwner) = 0;
}; };
DEFINE_REF(UniformBuffer); DEFINE_REF(UniformBuffer)
class VertexBuffer : public Buffer class VertexBuffer : public Buffer
{ {
@@ -360,7 +367,7 @@ protected:
uint32 numVertices; uint32 numVertices;
uint32 vertexSize; uint32 vertexSize;
}; };
DEFINE_REF(VertexBuffer); DEFINE_REF(VertexBuffer)
class IndexBuffer : public Buffer class IndexBuffer : public Buffer
{ {
@@ -382,7 +389,7 @@ protected:
Gfx::SeIndexType indexType; Gfx::SeIndexType indexType;
uint32 numIndices; uint32 numIndices;
}; };
DEFINE_REF(IndexBuffer); DEFINE_REF(IndexBuffer)
class StructuredBuffer : public Buffer class StructuredBuffer : public Buffer
{ {
@@ -393,7 +400,7 @@ protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(QueueType newOwner) = 0; virtual void executeOwnershipBarrier(QueueType newOwner) = 0;
}; };
DEFINE_REF(StructuredBuffer); DEFINE_REF(StructuredBuffer)
class VertexStream class VertexStream
{ {
@@ -410,7 +417,7 @@ public:
Array<VertexElement> vertexDescription; Array<VertexElement> vertexDescription;
uint8 instanced; uint8 instanced;
}; };
DEFINE_REF(VertexStream); DEFINE_REF(VertexStream)
class VertexDeclaration class VertexDeclaration
{ {
public: public:
@@ -420,7 +427,7 @@ public:
static PVertexDeclaration createDeclaration(PGraphics graphics, const Array<VertexElement>& elementList); static PVertexDeclaration createDeclaration(PGraphics graphics, const Array<VertexElement>& elementList);
private: private:
}; };
DEFINE_REF(VertexDeclaration); DEFINE_REF(VertexDeclaration)
class GraphicsPipeline class GraphicsPipeline
{ {
public: public:
@@ -429,10 +436,10 @@ public:
const GraphicsPipelineCreateInfo& getCreateInfo() const {return createInfo;} const GraphicsPipelineCreateInfo& getCreateInfo() const {return createInfo;}
PPipelineLayout getPipelineLayout() const { return layout; } PPipelineLayout getPipelineLayout() const { return layout; }
protected: protected:
PPipelineLayout layout;
GraphicsPipelineCreateInfo createInfo; GraphicsPipelineCreateInfo createInfo;
PPipelineLayout layout;
}; };
DEFINE_REF(GraphicsPipeline); DEFINE_REF(GraphicsPipeline)
// IMPORTANT!! // IMPORTANT!!
// WHEN DERIVING FROM ANY Gfx:: BASE CLASSES WITH MULTIPLE INHERITANCE // WHEN DERIVING FROM ANY Gfx:: BASE CLASSES WITH MULTIPLE INHERITANCE
@@ -455,7 +462,7 @@ protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(QueueType newOwner) = 0; virtual void executeOwnershipBarrier(QueueType newOwner) = 0;
}; };
DEFINE_REF(Texture); DEFINE_REF(Texture)
class Texture2D : public Texture class Texture2D : public Texture
{ {
public: public:
@@ -471,9 +478,9 @@ protected:
//Inherited via QueueOwnedResource //Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(QueueType newOwner) = 0; virtual void executeOwnershipBarrier(QueueType newOwner) = 0;
}; };
DEFINE_REF(Texture2D); DEFINE_REF(Texture2D)
DECLARE_REF(Viewport); DECLARE_REF(Viewport)
class RenderCommand class RenderCommand
{ {
public: public:
@@ -488,7 +495,7 @@ public:
virtual void bindIndexBuffer(Gfx::PIndexBuffer indexBuffer) = 0; virtual void bindIndexBuffer(Gfx::PIndexBuffer indexBuffer) = 0;
virtual void draw(const MeshBatchElement& data) = 0; virtual void draw(const MeshBatchElement& data) = 0;
}; };
DEFINE_REF(RenderCommand); DEFINE_REF(RenderCommand)
class Window class Window
{ {
@@ -521,7 +528,7 @@ protected:
SeFormat pixelFormat; SeFormat pixelFormat;
uint32 samples; uint32 samples;
}; };
DEFINE_REF(Window); DEFINE_REF(Window)
class Viewport class Viewport
{ {
@@ -542,7 +549,7 @@ protected:
uint32 offsetY; uint32 offsetY;
PWindow owner; PWindow owner;
}; };
DEFINE_REF(Viewport); DEFINE_REF(Viewport)
class RenderTargetAttachment class RenderTargetAttachment
{ {
@@ -583,7 +590,7 @@ protected:
SeAttachmentLoadOp stencilLoadOp; SeAttachmentLoadOp stencilLoadOp;
SeAttachmentStoreOp stencilStoreOp; SeAttachmentStoreOp stencilStoreOp;
}; };
DEFINE_REF(RenderTargetAttachment); DEFINE_REF(RenderTargetAttachment)
class SwapchainAttachment : public RenderTargetAttachment class SwapchainAttachment : public RenderTargetAttachment
{ {
@@ -617,7 +624,7 @@ public:
private: private:
PWindow owner; PWindow owner;
}; };
DEFINE_REF(SwapchainAttachment); DEFINE_REF(SwapchainAttachment)
class RenderTargetLayout class RenderTargetLayout
{ {
@@ -633,7 +640,7 @@ public:
uint32 width; uint32 width;
uint32 height; uint32 height;
}; };
DEFINE_REF(RenderTargetLayout); DEFINE_REF(RenderTargetLayout)
class RenderPass class RenderPass
{ {
@@ -645,6 +652,6 @@ public:
protected: protected:
PRenderTargetLayout layout; PRenderTargetLayout layout;
}; };
DEFINE_REF(RenderPass); DEFINE_REF(RenderPass)
} // namespace Gfx } // namespace Gfx
} // namespace Seele } // namespace Seele
+2 -2
View File
@@ -3,8 +3,8 @@
using namespace Seele; using namespace Seele;
Mesh::Mesh(PVertexShaderInput vertexInput, Gfx::PIndexBuffer indexBuffer) Mesh::Mesh(PVertexShaderInput vertexInput, Gfx::PIndexBuffer indexBuffer)
: vertexInput(vertexInput) : indexBuffer(indexBuffer)
, indexBuffer(indexBuffer) , vertexInput(vertexInput)
{ {
} }
+3 -5
View File
@@ -42,7 +42,7 @@ struct MeshDescription
//TODO declaration //TODO declaration
} }
};*/ };*/
DECLARE_REF(MaterialAsset); DECLARE_REF(MaterialAsset)
class Mesh class Mesh
{ {
public: public:
@@ -55,11 +55,9 @@ public:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void serialize(Archive& ar, const unsigned int version) void serialize(Archive&, const unsigned int)
{ {
//ar & referencedMaterial->getFullPath();
//TODO:
} }
}; };
DEFINE_REF(Mesh); DEFINE_REF(Mesh)
} // namespace Seele } // namespace Seele
+8 -8
View File
@@ -2,11 +2,11 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(MaterialAsset); DECLARE_REF(MaterialAsset)
DECLARE_REF(VertexShaderInput); DECLARE_REF(VertexShaderInput)
DECLARE_NAME_REF(Gfx, VertexBuffer); DECLARE_NAME_REF(Gfx, VertexBuffer)
DECLARE_NAME_REF(Gfx, IndexBuffer); DECLARE_NAME_REF(Gfx, IndexBuffer)
DECLARE_NAME_REF(Gfx, UniformBuffer); DECLARE_NAME_REF(Gfx, UniformBuffer)
struct MeshBatchElement struct MeshBatchElement
{ {
public: public:
@@ -32,13 +32,13 @@ public:
MeshBatchElement() MeshBatchElement()
: uniformBuffer(nullptr) : uniformBuffer(nullptr)
, indexBuffer(nullptr) , indexBuffer(nullptr)
, indirectArgsBuffer(nullptr)
, firstIndex(0) , firstIndex(0)
, numPrimitives(0) , numPrimitives(0)
, numInstances(1) , numInstances(1)
, baseVertexIndex(0) , baseVertexIndex(0)
, minVertexIndex(0) , minVertexIndex(0)
, maxVertexIndex(0) , maxVertexIndex(0)
, indirectArgsBuffer(nullptr)
{} {}
}; };
struct MeshBatch struct MeshBatch
@@ -81,13 +81,13 @@ struct MeshBatch
, isBackfaceCullingDisabled(false) , isBackfaceCullingDisabled(false)
, isCastingShadow(true) , isCastingShadow(true)
, useWireframe(false) , useWireframe(false)
, topology(Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
, vertexInput(nullptr) , vertexInput(nullptr)
, material(nullptr) , material(nullptr)
, topology(Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
{ {
} }
}; };
DECLARE_REF(PrimitiveComponent); DECLARE_REF(PrimitiveComponent)
struct StaticMeshBatch : public MeshBatch struct StaticMeshBatch : public MeshBatch
{ {
uint32 index; uint32 index;
+2 -2
View File
@@ -26,10 +26,10 @@ void BasePassMeshProcessor::addMeshBatch(
Gfx::PPipelineLayout pipelineLayout, Gfx::PPipelineLayout pipelineLayout,
Gfx::PDescriptorLayout primitiveLayout, Gfx::PDescriptorLayout primitiveLayout,
Array<Gfx::PDescriptorSet>& descriptorSets, Array<Gfx::PDescriptorSet>& descriptorSets,
int32 staticMeshId) int32 /*staticMeshId*/)
{ {
const PMaterialAsset material = batch.material; const PMaterialAsset material = batch.material;
const Gfx::MaterialShadingModel shadingModel = material->getShadingModel(); //const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
const PVertexShaderInput vertexInput = batch.vertexInput; const PVertexShaderInput vertexInput = batch.vertexInput;
+10 -10
View File
@@ -24,13 +24,13 @@ private:
Array<Gfx::PRenderCommand> renderCommands; Array<Gfx::PRenderCommand> renderCommands;
Array<Gfx::PRenderCommand> cachedCommandBuffers; Array<Gfx::PRenderCommand> cachedCommandBuffers;
Array<Gfx::PDescriptorSet> cachedPrimitiveSets; Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
uint32 cachedPrimitiveIndex;
Gfx::PViewport target; Gfx::PViewport target;
uint8 translucentBasePass; uint8 translucentBasePass;
uint32 cachedPrimitiveIndex;
}; };
DEFINE_REF(BasePassMeshProcessor); DEFINE_REF(BasePassMeshProcessor)
DECLARE_REF(CameraActor); DECLARE_REF(CameraActor)
DECLARE_REF(CameraComponent); DECLARE_REF(CameraComponent)
class BasePass class BasePass
{ {
public: public:
@@ -54,8 +54,12 @@ private:
Gfx::PRenderPass renderPass; Gfx::PRenderPass renderPass;
Gfx::PTexture2D depthBuffer; Gfx::PTexture2D depthBuffer;
const PScene scene;
UPBasePassMeshProcessor processor; UPBasePassMeshProcessor processor;
const PScene scene;
Gfx::PGraphics graphics;
Gfx::PViewport viewport;
Array<Gfx::PDescriptorSet> descriptorSets;
PCameraComponent source;
Gfx::PPipelineLayout basePassLayout; Gfx::PPipelineLayout basePassLayout;
// Set 0: Light environment // Set 0: Light environment
Gfx::PDescriptorLayout lightLayout; Gfx::PDescriptorLayout lightLayout;
@@ -68,10 +72,6 @@ private:
// Set 3: primitive scene data // Set 3: primitive scene data
Gfx::PDescriptorLayout primitiveLayout; Gfx::PDescriptorLayout primitiveLayout;
Gfx::PUniformBuffer primitiveUniformBuffer; Gfx::PUniformBuffer primitiveUniformBuffer;
Array<Gfx::PDescriptorSet> descriptorSets;
Gfx::PGraphics graphics;
PCameraComponent source;
Gfx::PViewport viewport;
}; };
DEFINE_REF(BasePass); DEFINE_REF(BasePass)
} // namespace Seele } // namespace Seele
+3 -3
View File
@@ -3,8 +3,8 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(Material); DECLARE_REF(Material)
DECLARE_NAME_REF(Gfx, Graphics); DECLARE_NAME_REF(Gfx, Graphics)
namespace Gfx namespace Gfx
{ {
class ShaderCompiler class ShaderCompiler
@@ -17,6 +17,6 @@ private:
Array<PMaterial> pendingCompiles; Array<PMaterial> pendingCompiles;
PGraphics graphics; PGraphics graphics;
}; };
DEFINE_REF(ShaderCompiler); DEFINE_REF(ShaderCompiler)
} // namespace Gfx } // namespace Gfx
} // namespace Seele } // namespace Seele
@@ -66,4 +66,4 @@ void StaticMeshVertexInput::setData(StaticMeshDataType&& data)
this->data = std::move(data); this->data = std::move(data);
} }
IMPLEMENT_VERTEX_INPUT_TYPE(StaticMeshVertexInput, "StaticMeshVertexInput"); IMPLEMENT_VERTEX_INPUT_TYPE(StaticMeshVertexInput, "StaticMeshVertexInput")
+2 -2
View File
@@ -16,7 +16,7 @@ struct StaticMeshDataType
}; };
class StaticMeshVertexInput : public VertexShaderInput class StaticMeshVertexInput : public VertexShaderInput
{ {
DECLARE_VERTEX_INPUT_TYPE(StaticMeshVertexInput); DECLARE_VERTEX_INPUT_TYPE(StaticMeshVertexInput)
public: public:
StaticMeshVertexInput(std::string name); StaticMeshVertexInput(std::string name);
virtual ~StaticMeshVertexInput(); virtual ~StaticMeshVertexInput();
@@ -25,5 +25,5 @@ public:
private: private:
StaticMeshDataType data; StaticMeshDataType data;
}; };
DEFINE_REF(StaticMeshVertexInput); DEFINE_REF(StaticMeshVertexInput)
} }
+3 -3
View File
@@ -111,13 +111,13 @@ private:
VertexInputType* inputClass::getType() const { return &staticType; } VertexInputType* inputClass::getType() const { return &staticType; }
struct MeshDescription; struct MeshDescription;
DECLARE_REF(VertexShaderInput); DECLARE_REF(VertexShaderInput)
class VertexShaderInput class VertexShaderInput
{ {
public: public:
VertexShaderInput(std::string name); VertexShaderInput(std::string name);
virtual ~VertexShaderInput(); virtual ~VertexShaderInput();
virtual void init(Gfx::PGraphics graphics) {}; virtual void init(Gfx::PGraphics) {}
void getStreams(VertexInputStreamArray& outVertexStreams) const; void getStreams(VertexInputStreamArray& outVertexStreams) const;
void getPositionOnlyStream(VertexInputStreamArray& outVertexStreams) const; void getPositionOnlyStream(VertexInputStreamArray& outVertexStreams) const;
virtual bool supportsTesselation() { return false; } virtual bool supportsTesselation() { return false; }
@@ -158,5 +158,5 @@ protected:
Gfx::PVertexDeclaration positionDeclaration; Gfx::PVertexDeclaration positionDeclaration;
std::string name; std::string name;
}; };
DEFINE_REF(VertexShaderInput); DEFINE_REF(VertexShaderInput)
} // namespace Seele } // namespace Seele
+13 -3
View File
@@ -5,7 +5,11 @@
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
SubAllocation::SubAllocation(Allocation *owner, VkDeviceSize allocatedOffset, VkDeviceSize size, VkDeviceSize alignedOffset, VkDeviceSize allocatedSize) SubAllocation::SubAllocation(Allocation *owner, VkDeviceSize allocatedOffset, VkDeviceSize size, VkDeviceSize alignedOffset, VkDeviceSize allocatedSize)
: owner(owner), size(size), allocatedOffset(allocatedOffset), alignedOffset(alignedOffset), allocatedSize(allocatedSize) : owner(owner)
, size(size)
, allocatedOffset(allocatedOffset)
, alignedOffset(alignedOffset)
, allocatedSize(allocatedSize)
{ {
} }
@@ -41,7 +45,13 @@ void SubAllocation::invalidateMemory()
Allocation::Allocation(PGraphics graphics, Allocator *allocator, VkDeviceSize size, uint8 memoryTypeIndex, Allocation::Allocation(PGraphics graphics, Allocator *allocator, VkDeviceSize size, uint8 memoryTypeIndex,
VkMemoryPropertyFlags properties, VkMemoryDedicatedAllocateInfo *dedicatedInfo) VkMemoryPropertyFlags properties, VkMemoryDedicatedAllocateInfo *dedicatedInfo)
: device(graphics->getDevice()), allocator(allocator), bytesAllocated(0), bytesUsed(0), readable(properties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT), properties(properties), memoryTypeIndex(memoryTypeIndex) : device(graphics->getDevice())
, allocator(allocator)
, bytesAllocated(0)
, bytesUsed(0)
, readable(properties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
, properties(properties)
, memoryTypeIndex(memoryTypeIndex)
{ {
VkMemoryAllocateInfo allocInfo = VkMemoryAllocateInfo allocInfo =
init::MemoryAllocateInfo(); init::MemoryAllocateInfo();
@@ -224,7 +234,7 @@ PSubAllocation Allocator::allocate(const VkMemoryRequirements2 &memRequirements2
} }
// no suitable allocations found, allocate new block // no suitable allocations found, allocate new block
PAllocation newAllocation = new Allocation(graphics, this, (requirements.size > MemoryBlockSize) ? requirements.size : MemoryBlockSize, memoryTypeIndex, properties, nullptr); PAllocation newAllocation = new Allocation(graphics, this, (requirements.size > MemoryBlockSize) ? requirements.size : (VkDeviceSize)MemoryBlockSize, memoryTypeIndex, properties, nullptr);
heaps[heapIndex].allocations.add(newAllocation); heaps[heapIndex].allocations.add(newAllocation);
return newAllocation->getSuballocation(requirements.size, requirements.alignment); return newAllocation->getSuballocation(requirements.size, requirements.alignment);
} }
+11 -11
View File
@@ -9,7 +9,7 @@ namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(Graphics); DECLARE_REF(Graphics)
class Allocation; class Allocation;
class Allocator; class Allocator;
class SubAllocation class SubAllocation
@@ -33,14 +33,14 @@ public:
private: private:
Allocation *owner; Allocation *owner;
VkDeviceSize allocatedOffset;
VkDeviceSize size; VkDeviceSize size;
VkDeviceSize allocatedOffset;
VkDeviceSize alignedOffset; VkDeviceSize alignedOffset;
VkDeviceSize allocatedSize; VkDeviceSize allocatedSize;
friend class Allocation; friend class Allocation;
friend class Allocator; friend class Allocator;
}; };
DEFINE_REF(SubAllocation); DEFINE_REF(SubAllocation)
class Allocation class Allocation
{ {
public: public:
@@ -94,24 +94,24 @@ public:
} }
private: private:
Allocator *allocator;
VkDevice device; VkDevice device;
VkDeviceMemory allocatedMemory; Allocator *allocator;
VkDeviceSize bytesAllocated; VkDeviceSize bytesAllocated;
VkDeviceSize bytesUsed; VkDeviceSize bytesUsed;
VkMemoryPropertyFlags properties; VkDeviceMemory allocatedMemory;
Map<VkDeviceSize, SubAllocation *> activeAllocations; Map<VkDeviceSize, SubAllocation *> activeAllocations;
Map<VkDeviceSize, PSubAllocation> freeRanges; Map<VkDeviceSize, PSubAllocation> freeRanges;
std::mutex lock; std::mutex lock;
void *mappedPointer; void *mappedPointer;
uint8 memoryTypeIndex;
uint8 isDedicated : 1; uint8 isDedicated : 1;
uint8 canMap : 1; uint8 canMap : 1;
uint8 isMapped : 1; uint8 isMapped : 1;
uint8 readable : 1; uint8 readable : 1;
VkMemoryPropertyFlags properties;
uint8 memoryTypeIndex;
friend class Allocator; friend class Allocator;
}; };
DEFINE_REF(Allocation); DEFINE_REF(Allocation)
class Allocator class Allocator
{ {
@@ -159,7 +159,7 @@ private:
PGraphics graphics; PGraphics graphics;
VkPhysicalDeviceMemoryProperties memProperties; VkPhysicalDeviceMemoryProperties memProperties;
}; };
DEFINE_REF(Allocator); DEFINE_REF(Allocator)
class StagingBuffer class StagingBuffer
{ {
@@ -207,7 +207,7 @@ private:
uint8 bReadable; uint8 bReadable;
friend class StagingManager; friend class StagingManager;
}; };
DEFINE_REF(StagingBuffer); DEFINE_REF(StagingBuffer)
class StagingManager class StagingManager
{ {
@@ -225,6 +225,6 @@ private:
Array<StagingBuffer *> activeBuffers; Array<StagingBuffer *> activeBuffers;
std::mutex lock; std::mutex lock;
}; };
DEFINE_REF(StagingManager); DEFINE_REF(StagingManager)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
+12 -9
View File
@@ -17,7 +17,10 @@ struct PendingBuffer
static Map<ShaderBuffer *, PendingBuffer> pendingBuffers; static Map<ShaderBuffer *, PendingBuffer> pendingBuffers;
ShaderBuffer::ShaderBuffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, Gfx::QueueType queueType) ShaderBuffer::ShaderBuffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, Gfx::QueueType queueType)
: graphics(graphics), currentBuffer(0), size(size), currentOwner(queueType) : graphics(graphics)
, currentBuffer(0)
, size(size)
, currentOwner(queueType)
{ {
if (usage & VK_BUFFER_USAGE_INDEX_BUFFER_BIT || if (usage & VK_BUFFER_USAGE_INDEX_BUFFER_BIT ||
usage & VK_BUFFER_USAGE_VERTEX_BUFFER_BIT || usage & VK_BUFFER_USAGE_VERTEX_BUFFER_BIT ||
@@ -242,8 +245,8 @@ void ShaderBuffer::unlock()
} }
UniformBuffer::UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo &createInfo) UniformBuffer::UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo &createInfo)
: Vulkan::ShaderBuffer(graphics, createInfo.resourceData.size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, createInfo.resourceData.owner) : Gfx::UniformBuffer(graphics->getFamilyMapping(), createInfo.resourceData)
, Gfx::UniformBuffer(graphics->getFamilyMapping(), createInfo.resourceData) , Vulkan::ShaderBuffer(graphics, createInfo.resourceData.size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, createInfo.resourceData.owner)
, dedicatedStagingBuffer(nullptr) , dedicatedStagingBuffer(nullptr)
{ {
if(createInfo.bDynamic) if(createInfo.bDynamic)
@@ -313,8 +316,8 @@ VkAccessFlags UniformBuffer::getDestAccessMask()
} }
StructuredBuffer::StructuredBuffer(PGraphics graphics, const BulkResourceData &resourceData) StructuredBuffer::StructuredBuffer(PGraphics graphics, const BulkResourceData &resourceData)
: Vulkan::ShaderBuffer(graphics, resourceData.size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, resourceData.owner) : Gfx::StructuredBuffer(graphics->getFamilyMapping(), resourceData.owner)
, Gfx::StructuredBuffer(graphics->getFamilyMapping(), resourceData.owner) , Vulkan::ShaderBuffer(graphics, resourceData.size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, resourceData.owner)
{ {
if (resourceData.data != nullptr) if (resourceData.data != nullptr)
{ {
@@ -349,8 +352,8 @@ VkAccessFlags StructuredBuffer::getDestAccessMask()
} }
VertexBuffer::VertexBuffer(PGraphics graphics, const VertexBufferCreateInfo &resourceData) VertexBuffer::VertexBuffer(PGraphics graphics, const VertexBufferCreateInfo &resourceData)
: Vulkan::ShaderBuffer(graphics, resourceData.resourceData.size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, resourceData.resourceData.owner) : Gfx::VertexBuffer(graphics->getFamilyMapping(), resourceData.numVertices, resourceData.vertexSize, resourceData.resourceData.owner)
, Gfx::VertexBuffer(graphics->getFamilyMapping(), resourceData.numVertices, resourceData.vertexSize, resourceData.resourceData.owner) , Vulkan::ShaderBuffer(graphics, resourceData.resourceData.size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, resourceData.resourceData.owner)
{ {
if (resourceData.resourceData.data != nullptr) if (resourceData.resourceData.data != nullptr)
{ {
@@ -385,8 +388,8 @@ VkAccessFlags VertexBuffer::getDestAccessMask()
} }
IndexBuffer::IndexBuffer(PGraphics graphics, const IndexBufferCreateInfo &resourceData) IndexBuffer::IndexBuffer(PGraphics graphics, const IndexBufferCreateInfo &resourceData)
: Vulkan::ShaderBuffer(graphics, resourceData.resourceData.size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, resourceData.resourceData.owner) : Gfx::IndexBuffer(graphics->getFamilyMapping(), resourceData.resourceData.size, resourceData.indexType, resourceData.resourceData.owner)
, Gfx::IndexBuffer(graphics->getFamilyMapping(), resourceData.resourceData.size, resourceData.indexType, resourceData.resourceData.owner) , Vulkan::ShaderBuffer(graphics, resourceData.resourceData.size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, resourceData.resourceData.owner)
{ {
if (resourceData.resourceData.data != nullptr) if (resourceData.resourceData.data != nullptr)
{ {
@@ -23,7 +23,11 @@ CmdBufferBase::~CmdBufferBase()
} }
CmdBuffer::CmdBuffer(PGraphics graphics, VkCommandPool cmdPool, PCommandBufferManager manager) CmdBuffer::CmdBuffer(PGraphics graphics, VkCommandPool cmdPool, PCommandBufferManager manager)
: CmdBufferBase(graphics, cmdPool), renderPass(nullptr), framebuffer(nullptr), subpassIndex(0), manager(manager) : CmdBufferBase(graphics, cmdPool)
, manager(manager)
, renderPass(nullptr)
, framebuffer(nullptr)
, subpassIndex(0)
{ {
VkCommandBufferAllocateInfo allocInfo = VkCommandBufferAllocateInfo allocInfo =
init::CommandBufferAllocateInfo(cmdPool, init::CommandBufferAllocateInfo(cmdPool,
@@ -7,8 +7,8 @@ namespace Seele
struct VertexInputStream; struct VertexInputStream;
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(RenderPass); DECLARE_REF(RenderPass)
DECLARE_REF(Framebuffer); DECLARE_REF(Framebuffer)
class CmdBufferBase class CmdBufferBase
{ {
public: public:
@@ -27,10 +27,10 @@ protected:
VkCommandBuffer handle; VkCommandBuffer handle;
VkCommandPool owner; VkCommandPool owner;
}; };
DEFINE_REF(CmdBufferBase); DEFINE_REF(CmdBufferBase)
DECLARE_REF(SecondaryCmdBuffer); DECLARE_REF(SecondaryCmdBuffer)
DECLARE_REF(CommandBufferManager); DECLARE_REF(CommandBufferManager)
class CmdBuffer : public CmdBufferBase class CmdBuffer : public CmdBufferBase
{ {
public: public:
@@ -68,10 +68,10 @@ private:
friend class CommandBufferManager; friend class CommandBufferManager;
friend class Queue; friend class Queue;
}; };
DEFINE_REF(CmdBuffer); DEFINE_REF(CmdBuffer)
DECLARE_REF(GraphicsPipeline); DECLARE_REF(GraphicsPipeline)
DECLARE_REF(DescriptorSet); DECLARE_REF(DescriptorSet)
class SecondaryCmdBuffer : public Gfx::RenderCommand, public CmdBufferBase class SecondaryCmdBuffer : public Gfx::RenderCommand, public CmdBufferBase
{ {
public: public:
@@ -94,7 +94,7 @@ private:
Array<PDescriptorSet> boundDescriptors; Array<PDescriptorSet> boundDescriptors;
friend class CmdBuffer; friend class CmdBuffer;
}; };
DEFINE_REF(SecondaryCmdBuffer); DEFINE_REF(SecondaryCmdBuffer)
class CommandBufferManager class CommandBufferManager
{ {
@@ -119,6 +119,6 @@ private:
std::mutex allocatedBufferLock; std::mutex allocatedBufferLock;
Array<PCmdBuffer> allocatedBuffers; Array<PCmdBuffer> allocatedBuffers;
}; };
DEFINE_REF(CommandBufferManager); DEFINE_REF(CommandBufferManager)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
@@ -218,7 +218,9 @@ void DescriptorSet::writeChanges()
} }
DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout &layout) DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout &layout)
: layout(layout), graphics(graphics), currentCachedIndex(0) : graphics(graphics)
, layout(layout)
, currentCachedIndex(0)
{ {
std::memset(&cachedHandles, 0, sizeof(cachedHandles)); std::memset(&cachedHandles, 0, sizeof(cachedHandles));
@@ -5,7 +5,7 @@ namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(Graphics); DECLARE_REF(Graphics)
class DescriptorLayout : public Gfx::DescriptorLayout class DescriptorLayout : public Gfx::DescriptorLayout
{ {
public: public:
@@ -24,12 +24,14 @@ private:
VkDescriptorSetLayout layoutHandle; VkDescriptorSetLayout layoutHandle;
friend class DescriptorAllocator; friend class DescriptorAllocator;
}; };
DEFINE_REF(DescriptorLayout); DEFINE_REF(DescriptorLayout)
class PipelineLayout : public Gfx::PipelineLayout class PipelineLayout : public Gfx::PipelineLayout
{ {
public: public:
PipelineLayout(PGraphics graphics) PipelineLayout(PGraphics graphics)
: graphics(graphics), layoutHash(0), layoutHandle(VK_NULL_HANDLE) : graphics(graphics)
, layoutHash(0)
, layoutHandle(VK_NULL_HANDLE)
{ {
} }
virtual ~PipelineLayout(); virtual ~PipelineLayout();
@@ -46,11 +48,11 @@ public:
private: private:
Array<VkDescriptorSetLayout> vulkanDescriptorLayouts; Array<VkDescriptorSetLayout> vulkanDescriptorLayouts;
PGraphics graphics;
uint32 layoutHash; uint32 layoutHash;
VkPipelineLayout layoutHandle; VkPipelineLayout layoutHandle;
PGraphics graphics;
}; };
DEFINE_REF(PipelineLayout); DEFINE_REF(PipelineLayout)
class DescriptorAllocator : public Gfx::DescriptorAllocator class DescriptorAllocator : public Gfx::DescriptorAllocator
{ {
@@ -71,13 +73,13 @@ public:
private: private:
PGraphics graphics; PGraphics graphics;
DescriptorLayout &layout;
uint32 currentCachedIndex;
const static int maxSets = 512; const static int maxSets = 512;
VkDescriptorSet cachedHandles[maxSets]; VkDescriptorSet cachedHandles[maxSets];
uint32 currentCachedIndex;
VkDescriptorPool poolHandle; VkDescriptorPool poolHandle;
DescriptorLayout &layout;
}; };
DEFINE_REF(DescriptorAllocator); DEFINE_REF(DescriptorAllocator)
class DescriptorSet : public Gfx::DescriptorSet class DescriptorSet : public Gfx::DescriptorSet
{ {
@@ -119,12 +121,12 @@ private:
// would not work anyways, so casts should be safe // would not work anyways, so casts should be safe
Array<void*> cachedData[Gfx::numFramesBuffered]; Array<void*> cachedData[Gfx::numFramesBuffered];
VkDescriptorSet setHandle[Gfx::numFramesBuffered]; VkDescriptorSet setHandle[Gfx::numFramesBuffered];
PGraphics graphics;
PDescriptorAllocator owner; PDescriptorAllocator owner;
PCmdBuffer currentlyBound; PCmdBuffer currentlyBound;
PGraphics graphics;
friend class DescriptorAllocator; friend class DescriptorAllocator;
}; };
DEFINE_REF(DescriptorSet); DEFINE_REF(DescriptorSet)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
@@ -5,7 +5,7 @@ namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(RenderPass); DECLARE_REF(RenderPass)
struct FramebufferDescription struct FramebufferDescription
{ {
VkImageView inputAttachments[16]; VkImageView inputAttachments[16];
@@ -35,6 +35,6 @@ private:
Gfx::PRenderTargetLayout layout; Gfx::PRenderTargetLayout layout;
PRenderPass renderPass; PRenderPass renderPass;
}; };
DEFINE_REF(Framebuffer); DEFINE_REF(Framebuffer)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
@@ -10,12 +10,15 @@
#include "VulkanDescriptorSets.h" #include "VulkanDescriptorSets.h"
#include "VulkanShader.h" #include "VulkanShader.h"
#include "Graphics/GraphicsResources.h" #include "Graphics/GraphicsResources.h"
#include <glfw/glfw3.h> #include <GLFW/glfw3.h>
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
Graphics::Graphics() Graphics::Graphics()
: callback(VK_NULL_HANDLE), handle(VK_NULL_HANDLE), instance(VK_NULL_HANDLE), physicalDevice(VK_NULL_HANDLE) : instance(VK_NULL_HANDLE)
, handle(VK_NULL_HANDLE)
, physicalDevice(VK_NULL_HANDLE)
, callback(VK_NULL_HANDLE)
{ {
} }
@@ -161,7 +164,7 @@ Gfx::PGraphicsPipeline Graphics::createGraphicsPipeline(const GraphicsPipelineCr
return pipeline; return pipeline;
} }
Gfx::PSamplerState Graphics::createSamplerState(const SamplerCreateInfo& createInfo) Gfx::PSamplerState Graphics::createSamplerState(const SamplerCreateInfo&)
{ {
PSamplerState sampler = new SamplerState(); // TODO: proper sampler creation PSamplerState sampler = new SamplerState(); // TODO: proper sampler creation
VkSamplerCreateInfo vkInfo = VkSamplerCreateInfo vkInfo =
+9 -9
View File
@@ -6,13 +6,13 @@ namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(Allocator); DECLARE_REF(Allocator)
DECLARE_REF(StagingManager); DECLARE_REF(StagingManager)
DECLARE_REF(CommandBufferManager); DECLARE_REF(CommandBufferManager)
DECLARE_REF(Queue); DECLARE_REF(Queue)
DECLARE_REF(Framebuffer); DECLARE_REF(Framebuffer)
DECLARE_REF(RenderCommand); DECLARE_REF(RenderCommand)
DECLARE_REF(PipelineCache); DECLARE_REF(PipelineCache)
class Graphics : public Gfx::Graphics class Graphics : public Gfx::Graphics
{ {
public: public:
@@ -72,9 +72,9 @@ protected:
void pickPhysicalDevice(); void pickPhysicalDevice();
void createDevice(GraphicsInitializer initInfo); void createDevice(GraphicsInitializer initInfo);
VkInstance instance;
VkDevice handle; VkDevice handle;
VkPhysicalDevice physicalDevice; VkPhysicalDevice physicalDevice;
VkInstance instance;
PQueue graphicsQueue; PQueue graphicsQueue;
PQueue computeQueue; PQueue computeQueue;
@@ -96,6 +96,6 @@ protected:
friend class Window; friend class Window;
}; };
DEFINE_REF(Graphics); DEFINE_REF(Graphics)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
@@ -72,7 +72,8 @@ Semaphore::~Semaphore()
} }
Fence::Fence(PGraphics graphics) Fence::Fence(PGraphics graphics)
: graphics(graphics), signaled(false) : graphics(graphics)
, signaled(false)
{ {
VkFenceCreateInfo info = VkFenceCreateInfo info =
init::FenceCreateInfo(0); init::FenceCreateInfo(0);
@@ -8,11 +8,11 @@ namespace Seele
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(DescriptorAllocator); DECLARE_REF(DescriptorAllocator)
DECLARE_REF(CommandBufferManager); DECLARE_REF(CommandBufferManager)
DECLARE_REF(CmdBuffer); DECLARE_REF(CmdBuffer)
DECLARE_REF(Graphics); DECLARE_REF(Graphics)
DECLARE_REF(SubAllocation); DECLARE_REF(SubAllocation)
class Semaphore class Semaphore
{ {
public: public:
@@ -27,7 +27,7 @@ private:
VkSemaphore handle; VkSemaphore handle;
PGraphics graphics; PGraphics graphics;
}; };
DEFINE_REF(Semaphore); DEFINE_REF(Semaphore)
class Fence class Fence
{ {
@@ -47,11 +47,11 @@ public:
} }
private: private:
PGraphics graphics;
bool signaled; bool signaled;
VkFence fence; VkFence fence;
PGraphics graphics;
}; };
DEFINE_REF(Fence); DEFINE_REF(Fence)
class VertexDeclaration : public Gfx::VertexDeclaration class VertexDeclaration : public Gfx::VertexDeclaration
{ {
@@ -62,7 +62,7 @@ public:
virtual ~VertexDeclaration(); virtual ~VertexDeclaration();
private: private:
}; };
DEFINE_REF(VertexDeclaration); DEFINE_REF(VertexDeclaration)
class QueueOwnedResourceDeletion class QueueOwnedResourceDeletion
{ {
@@ -112,12 +112,12 @@ protected:
VkBuffer buffer; VkBuffer buffer;
PSubAllocation allocation; PSubAllocation allocation;
}; };
BufferAllocation buffers[Gfx::numFramesBuffered]; PGraphics graphics;
uint32 numBuffers;
uint32 currentBuffer; uint32 currentBuffer;
uint32 size; uint32 size;
PGraphics graphics;
Gfx::QueueType currentOwner; Gfx::QueueType currentOwner;
BufferAllocation buffers[Gfx::numFramesBuffered];
uint32 numBuffers;
void executeOwnershipBarrier(Gfx::QueueType newOwner); void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) = 0; virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) = 0;
@@ -125,9 +125,9 @@ protected:
virtual VkAccessFlags getSourceAccessMask() = 0; virtual VkAccessFlags getSourceAccessMask() = 0;
virtual VkAccessFlags getDestAccessMask() = 0; virtual VkAccessFlags getDestAccessMask() = 0;
}; };
DEFINE_REF(ShaderBuffer); DEFINE_REF(ShaderBuffer)
DECLARE_REF(StagingBuffer); DECLARE_REF(StagingBuffer)
class UniformBuffer : public Gfx::UniformBuffer, public ShaderBuffer class UniformBuffer : public Gfx::UniformBuffer, public ShaderBuffer
{ {
public: public:
@@ -147,7 +147,7 @@ protected:
private: private:
PStagingBuffer dedicatedStagingBuffer; PStagingBuffer dedicatedStagingBuffer;
}; };
DEFINE_REF(UniformBuffer); DEFINE_REF(UniformBuffer)
class StructuredBuffer : public Gfx::StructuredBuffer, public ShaderBuffer class StructuredBuffer : public Gfx::StructuredBuffer, public ShaderBuffer
{ {
@@ -163,7 +163,7 @@ protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
}; };
DEFINE_REF(StructuredBuffer); DEFINE_REF(StructuredBuffer)
class VertexBuffer : public Gfx::VertexBuffer, public ShaderBuffer class VertexBuffer : public Gfx::VertexBuffer, public ShaderBuffer
{ {
@@ -179,7 +179,7 @@ protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
}; };
DEFINE_REF(VertexBuffer); DEFINE_REF(VertexBuffer)
class IndexBuffer : public Gfx::IndexBuffer, public ShaderBuffer class IndexBuffer : public Gfx::IndexBuffer, public ShaderBuffer
{ {
@@ -195,7 +195,7 @@ protected:
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
}; };
DEFINE_REF(IndexBuffer); DEFINE_REF(IndexBuffer)
class TextureHandle class TextureHandle
{ {
@@ -303,14 +303,14 @@ protected:
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
}; };
DEFINE_REF(Texture2D); DEFINE_REF(Texture2D)
class SamplerState : public Gfx::SamplerState class SamplerState : public Gfx::SamplerState
{ {
public: public:
VkSampler sampler; VkSampler sampler;
}; };
DEFINE_REF(SamplerState); DEFINE_REF(SamplerState)
class Window : public Gfx::Window class Window : public Gfx::Window
{ {
@@ -347,10 +347,11 @@ protected:
PSemaphore imageAcquiredSemaphore; PSemaphore imageAcquiredSemaphore;
PGraphics graphics; PGraphics graphics;
VkFormat pixelFormat; VkInstance instance;
VkSampleCountFlags numSamples;
VkPresentModeKHR presentMode;
VkSwapchainKHR swapchain; VkSwapchainKHR swapchain;
VkSampleCountFlags numSamples;
VkFormat pixelFormat;
VkPresentModeKHR presentMode;
VkSurfaceKHR surface; VkSurfaceKHR surface;
VkSurfaceFormatKHR surfaceFormat; VkSurfaceFormatKHR surfaceFormat;
void *windowHandle; void *windowHandle;
@@ -358,9 +359,8 @@ protected:
int32 acquiredImageIndex; int32 acquiredImageIndex;
int32 preAcquiredImageIndex; int32 preAcquiredImageIndex;
int32 semaphoreIndex; int32 semaphoreIndex;
VkInstance instance;
}; };
DEFINE_REF(Window); DEFINE_REF(Window)
class Viewport : public Gfx::Viewport class Viewport : public Gfx::Viewport
{ {
@@ -375,6 +375,6 @@ private:
PGraphics graphics; PGraphics graphics;
friend class Graphics; friend class Graphics;
}; };
DECLARE_REF(Viewport); DECLARE_REF(Viewport)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
+4 -4
View File
@@ -5,8 +5,8 @@ namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(PipelineLayout); DECLARE_REF(PipelineLayout)
DECLARE_REF(Graphics); DECLARE_REF(Graphics)
class GraphicsPipeline : public Gfx::GraphicsPipeline class GraphicsPipeline : public Gfx::GraphicsPipeline
{ {
public: public:
@@ -15,9 +15,9 @@ public:
void bind(VkCommandBuffer handle); void bind(VkCommandBuffer handle);
VkPipelineLayout getLayout() const; VkPipelineLayout getLayout() const;
private: private:
VkPipeline pipeline;
PGraphics graphics; PGraphics graphics;
VkPipeline pipeline;
}; };
DEFINE_REF(GraphicsPipeline); DEFINE_REF(GraphicsPipeline)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
@@ -17,6 +17,6 @@ private:
std::string cacheFile; std::string cacheFile;
Map<uint32, VkPipeline> createdPipelines; Map<uint32, VkPipeline> createdPipelines;
}; };
DEFINE_REF(PipelineCache); DEFINE_REF(PipelineCache)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
+3 -1
View File
@@ -9,7 +9,9 @@ using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
Queue::Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex) Queue::Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex)
: familyIndex(familyIndex), graphics(graphics), queueType(queueType) : graphics(graphics)
, familyIndex(familyIndex)
, queueType(queueType)
{ {
vkGetDeviceQueue(graphics->getDevice(), familyIndex, queueIndex, &queue); vkGetDeviceQueue(graphics->getDevice(), familyIndex, queueIndex, &queue);
} }
+2 -2
View File
@@ -5,8 +5,8 @@ namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(CmdBuffer); DECLARE_REF(CmdBuffer)
DECLARE_REF(Graphics); DECLARE_REF(Graphics)
class Queue class Queue
{ {
public: public:
@@ -38,6 +38,6 @@ private:
VkRect2D renderArea; VkRect2D renderArea;
VkSubpassContents subpassContents; VkSubpassContents subpassContents;
}; };
DEFINE_REF(RenderPass); DEFINE_REF(RenderPass)
} // namespace Vulkan } // namespace Vulkan
} // namespace Seele } // namespace Seele
+1 -2
View File
@@ -2,8 +2,7 @@
#include "VulkanGraphics.h" #include "VulkanGraphics.h"
#include "VulkanDescriptorSets.h" #include "VulkanDescriptorSets.h"
#include "slang.h" #include "slang.h"
#include "spirv_cross/spirv_reflect.hpp" //#include "spirv_cross/spirv_reflect.hpp"
#include <fstream>
using namespace slang; using namespace slang;
using namespace Seele; using namespace Seele;
+10 -10
View File
@@ -6,8 +6,8 @@ namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(Graphics); DECLARE_REF(Graphics)
DECLARE_REF(DescriptorLayout); DECLARE_REF(DescriptorLayout)
class Shader class Shader
{ {
public: public:
@@ -31,12 +31,12 @@ private:
PGraphics graphics; PGraphics graphics;
Map<uint32, PDescriptorLayout> descriptorSets; Map<uint32, PDescriptorLayout> descriptorSets;
VkShaderModule module; VkShaderModule module;
VkShaderStageFlags stage;
ShaderType type; ShaderType type;
VkShaderStageFlags stage;
std::string entryPointName; std::string entryPointName;
uint32 hash; uint32 hash;
}; };
DEFINE_REF(Shader); DEFINE_REF(Shader)
template <typename Base, ShaderType shaderType, VkShaderStageFlags stageFlags> template <typename Base, ShaderType shaderType, VkShaderStageFlags stageFlags>
class ShaderBase : public Base, public Shader class ShaderBase : public Base, public Shader
@@ -57,12 +57,12 @@ typedef ShaderBase<Gfx::GeometryShader, ShaderType::GEOMETRY, VK_SHADER_STAGE_GE
typedef ShaderBase<Gfx::FragmentShader, ShaderType::FRAGMENT, VK_SHADER_STAGE_FRAGMENT_BIT> FragmentShader; typedef ShaderBase<Gfx::FragmentShader, ShaderType::FRAGMENT, VK_SHADER_STAGE_FRAGMENT_BIT> FragmentShader;
typedef ShaderBase<Gfx::ComputeShader, ShaderType::COMPUTE, VK_SHADER_STAGE_COMPUTE_BIT> ComputeShader; typedef ShaderBase<Gfx::ComputeShader, ShaderType::COMPUTE, VK_SHADER_STAGE_COMPUTE_BIT> ComputeShader;
DEFINE_REF(VertexShader); DEFINE_REF(VertexShader)
DEFINE_REF(ControlShader); DEFINE_REF(ControlShader)
DEFINE_REF(EvaluationShader); DEFINE_REF(EvaluationShader)
DEFINE_REF(GeometryShader); DEFINE_REF(GeometryShader)
DEFINE_REF(FragmentShader); DEFINE_REF(FragmentShader)
DEFINE_REF(ComputeShader); DEFINE_REF(ComputeShader)
} // namespace Vulkan } // namespace Vulkan
} }
+5 -5
View File
@@ -36,13 +36,13 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType,
, sizeX(createInfo.width) , sizeX(createInfo.width)
, sizeY(createInfo.height) , sizeY(createInfo.height)
, sizeZ(createInfo.depth) , sizeZ(createInfo.depth)
, mipLevels(createInfo.mipLevels)
, format(createInfo.format)
, samples(createInfo.samples)
, usage(createInfo.usage)
, arrayCount(createInfo.bArray ? createInfo.arrayLayers : 1) , arrayCount(createInfo.bArray ? createInfo.arrayLayers : 1)
, aspect(getAspectFromFormat(createInfo.format)) , mipLevels(createInfo.mipLevels)
, samples(createInfo.samples)
, format(createInfo.format)
, usage(createInfo.usage)
, image(existingImage) , image(existingImage)
, aspect(getAspectFromFormat(createInfo.format))
, layout(VK_IMAGE_LAYOUT_UNDEFINED) , layout(VK_IMAGE_LAYOUT_UNDEFINED)
{ {
if (existingImage == VK_NULL_HANDLE) if (existingImage == VK_NULL_HANDLE)
@@ -3,12 +3,12 @@
#include "VulkanInitializer.h" #include "VulkanInitializer.h"
#include "VulkanGraphicsEnums.h" #include "VulkanGraphicsEnums.h"
#include "VulkanCommandBuffer.h" #include "VulkanCommandBuffer.h"
#include <glfw/glfw3.h> #include <GLFW/glfw3.h>
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
void glfwKeyCallback(GLFWwindow* handle, int key, int scancode, int action, int modifier) void glfwKeyCallback(GLFWwindow* handle, int key, int action, int, int modifier)
{ {
Window* window = (Window*)glfwGetWindowUserPointer(handle); Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->keyCallback((KeyCode)key, (InputAction)action, (KeyModifier)modifier); window->keyCallback((KeyCode)key, (InputAction)action, (KeyModifier)modifier);
@@ -39,7 +39,12 @@ void glfwFileCallback(GLFWwindow* handle, int count, const char** paths)
} }
Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo) Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
: Gfx::Window(createInfo), graphics(graphics), instance(graphics->getInstance()), swapchain(VK_NULL_HANDLE), numSamples(createInfo.numSamples), pixelFormat(cast(createInfo.pixelFormat)) : Gfx::Window(createInfo)
, graphics(graphics)
, instance(graphics->getInstance())
, swapchain(VK_NULL_HANDLE)
, numSamples(createInfo.numSamples)
, pixelFormat(cast(createInfo.pixelFormat))
{ {
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow *handle = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr); GLFWwindow *handle = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
@@ -207,6 +212,7 @@ void Window::present()
{ {
presentResult = vkQueuePresentKHR(graphics->getGraphicsCommands()->getQueue()->getHandle(), &info); presentResult = vkQueuePresentKHR(graphics->getGraphicsCommands()->getQueue()->getHandle(), &info);
} }
Gfx::currentFrameIndex = (Gfx::currentFrameIndex + 1)%Gfx::numFramesBuffered;
} }
void Window::createSwapchain() void Window::createSwapchain()
+1 -1
View File
@@ -129,4 +129,4 @@ void BlinnPhong::generateMaterialCode(std::ofstream& codeStream, json codeJson)
codeStream << "}" << std::endl; codeStream << "}" << std::endl;
} }
IMPLEMENT_BRDF(BlinnPhong); IMPLEMENT_BRDF(BlinnPhong)
+1 -1
View File
@@ -29,7 +29,7 @@ protected:
class BlinnPhong : public BRDF class BlinnPhong : public BRDF
{ {
DECLARE_BRDF(BlinnPhong); DECLARE_BRDF(BlinnPhong)
public: public:
virtual void generateMaterialCode(std::ofstream& codeStream, nlohmann::json codeJson); virtual void generateMaterialCode(std::ofstream& codeStream, nlohmann::json codeJson);
protected: protected:
+1 -1
View File
@@ -31,5 +31,5 @@ private:
friend class MaterialLoader; friend class MaterialLoader;
friend class MaterialInstance; friend class MaterialInstance;
}; };
DEFINE_REF(Material); DEFINE_REF(Material)
} // namespace Seele } // namespace Seele
+3 -3
View File
@@ -5,8 +5,8 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(VertexShaderInput); DECLARE_REF(VertexShaderInput)
DECLARE_REF(Material); DECLARE_REF(Material)
class MaterialAsset : public Asset class MaterialAsset : public Asset
{ {
public: public:
@@ -34,5 +34,5 @@ protected:
uint8* uniformData; uint8* uniformData;
int32 uniformBinding; int32 uniformBinding;
}; };
DEFINE_REF(MaterialAsset); DEFINE_REF(MaterialAsset)
} // namespace Seele } // namespace Seele
+3 -3
View File
@@ -3,8 +3,8 @@
namespace Seele namespace Seele
{ {
DECLARE_NAME_REF(Gfx, DescriptorSet); DECLARE_NAME_REF(Gfx, DescriptorSet)
DECLARE_REF(Material); DECLARE_REF(Material)
class MaterialInstance : public MaterialAsset class MaterialInstance : public MaterialAsset
{ {
public: public:
@@ -18,5 +18,5 @@ public:
private: private:
Material* baseMaterial; Material* baseMaterial;
}; };
DEFINE_REF(MaterialInstance); DEFINE_REF(MaterialInstance)
} // namespace Seele } // namespace Seele
+4 -4
View File
@@ -24,7 +24,7 @@ FloatParameter::~FloatParameter()
{ {
} }
void FloatParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) void FloatParameter::updateDescriptorSet(Gfx::PDescriptorSet, uint8* dst)
{ {
std::memcpy(dst + byteOffset, &data, sizeof(float)); std::memcpy(dst + byteOffset, &data, sizeof(float));
} }
@@ -38,7 +38,7 @@ VectorParameter::~VectorParameter()
{ {
} }
void VectorParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) void VectorParameter::updateDescriptorSet(Gfx::PDescriptorSet, uint8* dst)
{ {
std::memcpy(dst + byteOffset, &data, sizeof(Vector)); std::memcpy(dst + byteOffset, &data, sizeof(Vector));
} }
@@ -52,7 +52,7 @@ TextureParameter::~TextureParameter()
{ {
} }
void TextureParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) void TextureParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8*)
{ {
descriptorSet->updateTexture(binding, data->getTexture()); descriptorSet->updateTexture(binding, data->getTexture());
} }
@@ -67,7 +67,7 @@ SamplerParameter::~SamplerParameter()
} }
void SamplerParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) void SamplerParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8*)
{ {
descriptorSet->updateSampler(binding, data); descriptorSet->updateSampler(binding, data);
} }
+8 -8
View File
@@ -14,7 +14,7 @@ struct ExpressionOutput
struct ShaderExpression struct ShaderExpression
{ {
}; };
DECLARE_NAME_REF(Gfx, DescriptorSet); DECLARE_NAME_REF(Gfx, DescriptorSet)
struct ShaderParameter : public ShaderExpression struct ShaderParameter : public ShaderExpression
{ {
std::string name; std::string name;
@@ -25,7 +25,7 @@ struct ShaderParameter : public ShaderExpression
// update a descriptorset, in case of a uniform buffer, copy the data to the dst + byteOffset // update a descriptorset, in case of a uniform buffer, copy the data to the dst + byteOffset
virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) = 0; virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) = 0;
}; };
DEFINE_REF(ShaderParameter); DEFINE_REF(ShaderParameter)
struct FloatParameter : public ShaderParameter struct FloatParameter : public ShaderParameter
{ {
float data; float data;
@@ -33,7 +33,7 @@ struct FloatParameter : public ShaderParameter
virtual ~FloatParameter(); virtual ~FloatParameter();
virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) override; virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) override;
}; };
DEFINE_REF(FloatParameter); DEFINE_REF(FloatParameter)
struct VectorParameter : public ShaderParameter struct VectorParameter : public ShaderParameter
{ {
Vector data; Vector data;
@@ -41,8 +41,8 @@ struct VectorParameter : public ShaderParameter
virtual ~VectorParameter(); virtual ~VectorParameter();
virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) override; virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) override;
}; };
DEFINE_REF(VectorParameter); DEFINE_REF(VectorParameter)
DECLARE_REF(TextureAsset); DECLARE_REF(TextureAsset)
struct TextureParameter : public ShaderParameter struct TextureParameter : public ShaderParameter
{ {
PTextureAsset data; PTextureAsset data;
@@ -50,8 +50,8 @@ struct TextureParameter : public ShaderParameter
virtual ~TextureParameter(); virtual ~TextureParameter();
virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) override; virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) override;
}; };
DEFINE_REF(TextureParameter); DEFINE_REF(TextureParameter)
DECLARE_NAME_REF(Gfx, SamplerState); DECLARE_NAME_REF(Gfx, SamplerState)
struct SamplerParameter : public ShaderParameter struct SamplerParameter : public ShaderParameter
{ {
Gfx::PSamplerState data; Gfx::PSamplerState data;
@@ -59,6 +59,6 @@ struct SamplerParameter : public ShaderParameter
virtual ~SamplerParameter(); virtual ~SamplerParameter();
virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) override; virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) override;
}; };
DEFINE_REF(SamplerParameter); DEFINE_REF(SamplerParameter)
} // namespace Seele } // namespace Seele
-2
View File
@@ -3,9 +3,7 @@
#include <glm/vec3.hpp> #include <glm/vec3.hpp>
#include <glm/vec4.hpp> #include <glm/vec4.hpp>
#pragma warning(disable : 4201)
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
#pragma warning(default : 4201)
namespace Seele namespace Seele
{ {
typedef glm::vec2 Vector2; typedef glm::vec2 Vector2;
+2 -6
View File
@@ -52,10 +52,7 @@ public:
std::scoped_lock lock(registeredObjectsLock); std::scoped_lock lock(registeredObjectsLock);
registeredObjects.erase(handle); registeredObjects.erase(handle);
} }
// we cant always have the definition of every class
#pragma warning(disable : 4150)
delete handle; delete handle;
#pragma warning(default : 4150)
} }
RefObject &operator=(const RefObject &rhs) RefObject &operator=(const RefObject &rhs)
{ {
@@ -105,7 +102,6 @@ public:
{ {
return handle; return handle;
} }
private: private:
T *handle; T *handle;
std::atomic_uint64_t refCount; std::atomic_uint64_t refCount;
@@ -161,7 +157,7 @@ public:
RefPtr(const RefPtr<F> &other) RefPtr(const RefPtr<F> &other)
{ {
F *f = other.getObject()->getHandle(); F *f = other.getObject()->getHandle();
T* t = static_cast<T *>(f); assert(static_cast<T *>(f));
object = (RefObject<T> *)other.getObject(); object = (RefObject<T> *)other.getObject();
object->addRef(); object->addRef();
} }
@@ -267,7 +263,7 @@ private:
RefObject<T> *object; RefObject<T> *object;
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void serialize(Archive& ar, const unsigned int version) void serialize(Archive& ar, const unsigned int)
{ {
ar & *object->getHandle(); ar & *object->getHandle();
} }
+4 -4
View File
@@ -4,9 +4,9 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(Actor); DECLARE_REF(Actor)
DECLARE_REF(Component); DECLARE_REF(Component)
DECLARE_REF(Scene); DECLARE_REF(Scene)
class Actor class Actor
{ {
public: public:
@@ -48,5 +48,5 @@ protected:
Array<PActor> children; Array<PActor> children;
PComponent rootComponent; PComponent rootComponent;
}; };
DEFINE_REF(Actor); DEFINE_REF(Actor)
} // namespace Seele } // namespace Seele
+1 -1
View File
@@ -17,5 +17,5 @@ private:
PCameraComponent cameraComponent; PCameraComponent cameraComponent;
PComponent sceneComponent; // This will be the root, camera will be the child PComponent sceneComponent; // This will be the root, camera will be the child
}; };
DEFINE_REF(CameraActor); DEFINE_REF(CameraActor)
} // namespace Seele } // namespace Seele
@@ -56,5 +56,5 @@ private:
Matrix4 viewMatrix; Matrix4 viewMatrix;
Matrix4 projectionMatrix; Matrix4 projectionMatrix;
}; };
DEFINE_REF(CameraComponent); DEFINE_REF(CameraComponent)
} // namespace Seele } // namespace Seele
+3 -3
View File
@@ -4,9 +4,9 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(Actor); DECLARE_REF(Actor)
DECLARE_REF(Scene); DECLARE_REF(Scene)
DECLARE_REF(Component); DECLARE_REF(Component)
class Component class Component
{ {
public: public:
@@ -7,7 +7,7 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(MeshAsset); DECLARE_REF(MeshAsset)
class PrimitiveComponent : public Component class PrimitiveComponent : public Component
{ {
public: public:
@@ -23,5 +23,5 @@ private:
Gfx::PUniformBuffer uniformBuffer; Gfx::PUniformBuffer uniformBuffer;
friend class Scene; friend class Scene;
}; };
DEFINE_REF(PrimitiveComponent); DEFINE_REF(PrimitiveComponent)
} // namespace Seele } // namespace Seele
+1 -1
View File
@@ -8,7 +8,7 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(Material); DECLARE_REF(Material)
struct DirectionalLight struct DirectionalLight
{ {
+1 -1
View File
@@ -18,5 +18,5 @@ protected:
Gfx::PGraphics graphics; Gfx::PGraphics graphics;
Gfx::PViewport target; Gfx::PViewport target;
}; };
DEFINE_REF(RenderPath); DEFINE_REF(RenderPath)
} // namespace Seele } // namespace Seele
+2 -2
View File
@@ -4,8 +4,8 @@
namespace Seele namespace Seele
{ {
DECLARE_REF(Scene); DECLARE_REF(Scene)
DECLARE_REF(CameraActor); DECLARE_REF(CameraActor)
class SceneRenderPath : public RenderPath class SceneRenderPath : public RenderPath
{ {
public: public:
+4 -4
View File
@@ -26,7 +26,7 @@ void SceneView::beginFrame()
scene->tick(0);//TODO: update in separate thread scene->tick(0);//TODO: update in separate thread
} }
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier) void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier)
{ {
if(action != InputAction::RELEASE) if(action != InputAction::RELEASE)
{ {
@@ -56,7 +56,7 @@ void SceneView::mouseMoveCallback(double xPos, double yPos)
} }
} }
void SceneView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) void SceneView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier)
{ {
if(button == MouseButton::MOUSE_BUTTON_1 && action != InputAction::RELEASE) if(button == MouseButton::MOUSE_BUTTON_1 && action != InputAction::RELEASE)
{ {
@@ -68,12 +68,12 @@ void SceneView::mouseButtonCallback(MouseButton button, InputAction action, KeyM
} }
} }
void SceneView::scrollCallback(double xOffset, double yOffset) void SceneView::scrollCallback(double, double yOffset)
{ {
activeCamera->getCameraComponent()->mouseScroll(yOffset); activeCamera->getCameraComponent()->mouseScroll(yOffset);
} }
void SceneView::fileCallback(int count, const char** paths) void SceneView::fileCallback(int, const char**)
{ {
} }
+3 -3
View File
@@ -2,8 +2,8 @@
#include "View.h" #include "View.h"
namespace Seele namespace Seele
{ {
DECLARE_REF(Scene); DECLARE_REF(Scene)
DECLARE_REF(CameraActor); DECLARE_REF(CameraActor)
class SceneView : public View class SceneView : public View
{ {
public: public:
@@ -20,5 +20,5 @@ private:
virtual void scrollCallback(double xOffset, double yOffset) override; virtual void scrollCallback(double xOffset, double yOffset) override;
virtual void fileCallback(int count, const char** paths) override; virtual void fileCallback(int count, const char** paths) override;
}; };
DEFINE_REF(SceneView); DEFINE_REF(SceneView)
} // namespace Seele } // namespace Seele
+1 -1
View File
@@ -2,7 +2,7 @@
#include "RenderPath.h" #include "RenderPath.h"
namespace Seele namespace Seele
{ {
DECLARE_REF(Window); DECLARE_REF(Window)
// A view is a part of the window, which can be anything from a viewport to an editor // A view is a part of the window, which can be anything from a viewport to an editor
class View class View
{ {
+1 -1
View File
@@ -22,5 +22,5 @@ private:
PView focusedView; PView focusedView;
Gfx::PWindow gfxHandle; Gfx::PWindow gfxHandle;
}; };
DEFINE_REF(Window); DEFINE_REF(Window)
} // namespace Seele } // namespace Seele
+1 -1
View File
@@ -28,5 +28,5 @@ private:
Array<PWindow> windows; Array<PWindow> windows;
static Gfx::PGraphics graphics; static Gfx::PGraphics graphics;
}; };
DEFINE_REF(WindowManager); DEFINE_REF(WindowManager)
} // namespace Seele } // namespace Seele
+1 -1
View File
@@ -5,6 +5,6 @@ target_sources(Seele_unit_tests
EngineTest.cpp) EngineTest.cpp)
target_include_directories(Seele_unit_tests PUBLIC ./) target_include_directories(Seele_unit_tests PUBLIC ./)
add_subdirectory(Containers/) add_subdirectory(Containers/)
add_subdirectory(Fibers/) #add_subdirectory(Fibers/)
add_subdirectory(Graphics/) add_subdirectory(Graphics/)
add_subdirectory(Math/) add_subdirectory(Math/)
+2 -2
View File
@@ -13,11 +13,11 @@ namespace Seele
} }
void setup() void setup()
{ {
Fibers::JobQueue::initJobQueues(); //Fibers::JobQueue::initJobQueues();
} }
void teardown() void teardown()
{ {
Fibers::JobQueue::cleanupJobQueues(); //Fibers::JobQueue::cleanupJobQueues();
} }
}; };
}; };