diff --git a/.gitmodules b/.gitmodules index 018c0a8c..36ad4fbf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,39 +1,3 @@ -[submodule "3rdparty/googletest"] - path = 3rdparty/googletest - url = https://github.com/google/googletest.git -[submodule "3rdparty/glm"] - path = 3rdparty/glm - url = https://github.com/g-truc/glm.git -[submodule "3rdparty/profiler"] - path = 3rdparty/profiler - url = https://github.com/NovaMods/profiler.git -[submodule "3rdparty/json"] - path = 3rdparty/json - url = https://github.com/nlohmann/json.git -[submodule "3rdparty/VulkanMemoryAllocator"] - path = 3rdparty/VulkanMemoryAllocator - url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git -[submodule "3rdparty/SPIRV-Headers"] - path = 3rdparty/SPIRV-Headers - url = https://github.com/KhronosGroup/SPIRV-Headers.git -[submodule "3rdparty/SPIRV-Tools"] - path = 3rdparty/SPIRV-Tools - url = https://github.com/KhronosGroup/SPIRV-Tools.git -[submodule "3rdparty/SPIRV-Cross"] - path = 3rdparty/SPIRV-Cross - url = https://github.com/KhronosGroup/SPIRV-Cross.git -[submodule "3rdparty/glslang"] - path = 3rdparty/glslang - url = https://github.com/KhronosGroup/glslang.git -[submodule "3rdparty/miniz"] - path = 3rdparty/miniz - url = https://github.com/richgel999/miniz.git -[submodule "3rdparty/minitrace"] - path = 3rdparty/minitrace - url = https://github.com/hrydgard/minitrace.git [submodule "3rdparty/run-clang-tidy"] path = 3rdparty/run-clang-tidy url = https://github.com/cwfitzgerald/run-clang-tidy.git -[submodule "3rdparty/fmtlib"] - path = 3rdparty/fmtlib - url = https://github.com/fmtlib/fmt.git diff --git a/3rdparty/3rdparty.cmake b/3rdparty/3rdparty.cmake index 60dc5c01..7a0c4865 100644 --- a/3rdparty/3rdparty.cmake +++ b/3rdparty/3rdparty.cmake @@ -23,115 +23,28 @@ else() set(VULKAN_INCLUDE "") endif() -######################### -# Header only libraries # -######################### - -include_target(glm::glm "${CMAKE_CURRENT_LIST_DIR}/glm") -set_target_properties(glm::glm PROPERTIES INTERFACE_COMPILE_DEFINITIONS "GLM_ENABLE_EXPERIMENTAL") - -include_target(nlohmann::json "${CMAKE_CURRENT_LIST_DIR}/json/single_include") -include_target(spirv::headers "${CMAKE_CURRENT_LIST_DIR}/SPIRV-Headers") -include_target(vma::vma "${3RD_PARTY_DIR}/VulkanMemoryAllocator/src") include_target(vulkan::sdk "${VULKAN_INCLUDE}") +find_package(glm CONFIG REQUIRED) +find_package(nlohmann_json CONFIG REQUIRED) +find_package(unofficial-vulkan-memory-allocator CONFIG REQUIRED) +find_package(minitrace CONFIG REQUIRED) +find_package(fmt CONFIG REQUIRED) +find_package(miniz CONFIG REQUIRED) +find_package(glslang CONFIG REQUIRED) +find_package(spirv_cross_core CONFIG REQUIRED) +find_package(spirv_cross_glsl CONFIG REQUIRED) +find_package(spirv_cross_cpp CONFIG REQUIRED) +find_package(spirv_cross_hlsl CONFIG REQUIRED) +find_package(spirv_cross_msl CONFIG REQUIRED) +find_package(spirv_cross_reflect CONFIG REQUIRED) +find_package(spirv_cross_util CONFIG REQUIRED) +find_package(SPIRV-Tools CONFIG REQUIRED) + ##################### -# Setup google test # +# Test dependencies # ##################### if(NOVA_TEST) - set(INSTALL_GTEST OFF) - set(gtest_force_shared_crt ON CACHE BOOL "Use shared (DLL) run-time lib even when Google Test is built as static lib." FORCE) - set(BUILD_GMOCK OFF CACHE BOOL "Build GMOCK shared library" FORCE) - add_subdirectory(3rdparty/googletest) - include(GoogleTest) -endif() - -####################### -# Submodule libraries # -####################### - -add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/fmtlib) -add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glslang) -add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/profiler) - -set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/SPIRV-Headers) -set(SPIRV_SKIP_TESTS ON CACHE BOOL "Disable SPIRV-Tools tests" FORCE) -set(SPIRV_WERROR OFF CACHE BOOL "Enable error on warning SPIRV-Tools" FORCE) -add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/SPIRV-Tools) - -set(ENABLE_EXPORTS ON CACHE BOOL "Enable linking SPIRV_Cross" FORCE) -add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/SPIRV-Cross) - -target_includes_system(fmt) -target_includes_system(glslang) -if(NOVA_TEST) - target_includes_system(gtest) - target_includes_system(gtest_main) + find_package(GTest MODULE REQUIRED) endif() -target_includes_system(nova-profiler) -target_includes_system(SPIRV) -target_includes_system(spirv-cross-core) -target_includes_system(spirv-cross-glsl) -target_includes_system(spirv-cross-hlsl) -target_includes_system(spirv-cross-reflect) -target_includes_system(spirv-cross-util) - -############################ -# Manually built libraries # -############################ - -include(miniz) -include(minitrace) -include(glslang) - -##################################### -# Hide unnecessary targets from all # -##################################### - -set_property(TARGET glslang PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET glslang-default-resource-limits PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET OGLCompiler PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET OSDependent PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET SPIRV PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET SPVRemapper PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET HLSL PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET glslangValidator PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-remap PROPERTY EXCLUDE_FROM_ALL True) - -set_property(TARGET spirv-tools-build-version PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-tools-debuginfo PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-tools-header-DebugInfo PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-tools-spv-amd-gcn-shader PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-tools-spv-amd-shader-ballot PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-tools-spv-amd-shader-explicit-vertex-parameter PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-tools-spv-amd-shader-trinary-minmax PROPERTY EXCLUDE_FROM_ALL True) - -set_property(TARGET spirv-tools-cpp-example PROPERTY EXCLUDE_FROM_ALL True) - -set_property(TARGET spirv-as PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cfg PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-dis PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-link PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-opt PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-reduce PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-stats PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-val PROPERTY EXCLUDE_FROM_ALL True) - -set_property(TARGET SPIRV-Tools PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET SPIRV-Tools-link PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET SPIRV-Tools-opt PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET SPIRV-Tools-reduce PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET SPIRV-Tools-shared PROPERTY EXCLUDE_FROM_ALL True) - -set_property(TARGET spirv-tools-vimsyntax PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-tools-pkg-config PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-tools-shared-pkg-config PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cross PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cross-core PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cross-cpp PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cross-glsl PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cross-hlsl PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cross-msl PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cross-reflect PROPERTY EXCLUDE_FROM_ALL True) -set_property(TARGET spirv-cross-util PROPERTY EXCLUDE_FROM_ALL True) diff --git a/3rdparty/SPIRV-Cross b/3rdparty/SPIRV-Cross deleted file mode 160000 index 236df436..00000000 --- a/3rdparty/SPIRV-Cross +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 236df43689aec12644de4a88edc002ca16d58f37 diff --git a/3rdparty/SPIRV-Headers b/3rdparty/SPIRV-Headers deleted file mode 160000 index 17da9f82..00000000 --- a/3rdparty/SPIRV-Headers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 17da9f8231f78cf519b4958c2229463a63ead9e2 diff --git a/3rdparty/SPIRV-Tools b/3rdparty/SPIRV-Tools deleted file mode 160000 index 24328a05..00000000 --- a/3rdparty/SPIRV-Tools +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 24328a0554654d9e205b532288044d6d203c3f2c diff --git a/3rdparty/VulkanMemoryAllocator b/3rdparty/VulkanMemoryAllocator deleted file mode 160000 index 3a7249f3..00000000 --- a/3rdparty/VulkanMemoryAllocator +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3a7249f313b047417fbb1d36a3fbe6c3bf1505b5 diff --git a/3rdparty/fmtlib b/3rdparty/fmtlib deleted file mode 160000 index d231d68a..00000000 --- a/3rdparty/fmtlib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d231d68a8bb1129e8c5a6f1fe657175f74507907 diff --git a/3rdparty/glm b/3rdparty/glm deleted file mode 160000 index 437a131a..00000000 --- a/3rdparty/glm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 437a131adb3205b20abb5432eb705b36abb8b51f diff --git a/3rdparty/glslang b/3rdparty/glslang deleted file mode 160000 index 9ed38739..00000000 --- a/3rdparty/glslang +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9ed38739b974f9d6585e8c5f11184409b11d3817 diff --git a/3rdparty/glslang.cmake b/3rdparty/glslang.cmake deleted file mode 100644 index 3b986f0a..00000000 --- a/3rdparty/glslang.cmake +++ /dev/null @@ -1,2 +0,0 @@ -add_library(glsl-standalone STATIC ${CMAKE_CURRENT_LIST_DIR}/glslang/StandAlone/ResourceLimits.cpp) -target_include_directories(glsl-standalone PRIVATE ${CMAKE_CURRENT_LIST_DIR}/glslang) diff --git a/3rdparty/googletest b/3rdparty/googletest deleted file mode 160000 index 9ab640ce..00000000 --- a/3rdparty/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9ab640ce5e5120021c5972d7e60f258bfca64d71 diff --git a/3rdparty/json b/3rdparty/json deleted file mode 160000 index 4f270e38..00000000 --- a/3rdparty/json +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4f270e38ccaa2677b8347e063759101579cd6a50 diff --git a/3rdparty/minitrace b/3rdparty/minitrace deleted file mode 160000 index a48215c4..00000000 --- a/3rdparty/minitrace +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a48215c409dd848fa0a76c5eb4dfaba4ca3bca39 diff --git a/3rdparty/miniz b/3rdparty/miniz deleted file mode 160000 index 3a884afa..00000000 --- a/3rdparty/miniz +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3a884afaa7a9eefb4eb80041aee6e7995a2f5215 diff --git a/3rdparty/miniz.cmake b/3rdparty/miniz.cmake deleted file mode 100644 index 08ab8b32..00000000 --- a/3rdparty/miniz.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# Miniz's cmake sucks, so doing it here -set(MINIZ_SOURCE ${CMAKE_CURRENT_LIST_DIR}/miniz/miniz.c - ${CMAKE_CURRENT_LIST_DIR}/miniz/miniz_zip.c - ${CMAKE_CURRENT_LIST_DIR}/miniz/miniz_tinfl.c - ${CMAKE_CURRENT_LIST_DIR}/miniz/miniz_tdef.c) -add_library(miniz ${MINIZ_SOURCE}) -target_include_directories(miniz SYSTEM PUBLIC ${CMAKE_CURRENT_LIST_DIR}/miniz) diff --git a/3rdparty/profiler b/3rdparty/profiler deleted file mode 160000 index 2f3576f2..00000000 --- a/3rdparty/profiler +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2f3576f2aa4ec9508beb9f2a54086b1f13643cdf diff --git a/CMakeLists.txt b/CMakeLists.txt index 98bea77b..32cb6796 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ project(nova-renderer) ################################################################ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) set(NOVA_IN_SUBMODULE False) + else() set(NOVA_IN_SUBMODULE True) endif() @@ -255,23 +256,25 @@ add_coverage(nova-renderer) ######################### set(COMMON_LINK_LIBS ${CMAKE_DL_LIBS} fmt::fmt - glm::glm - glsl-standalone - glslang - minitrace - miniz - nlohmann::json - nova-profiler - SPIRV + glm + glslang::glslang + glslang::OGLCompiler + glslang::OSDependent + glslang::SPIRV + minitrace::minitrace + miniz::miniz + nlohmann_json + nlohmann_json::nlohmann_json + spirv-tools::SPIRV-Tools spirv-cross-core + spirv-cross-cpp spirv-cross-glsl - spirv-cross-hlsl spirv-cross-reflect + spirv-cross-msl spirv-cross-util - spirv::headers - vma::vma - vulkan::sdk - ${Vulkan_LIBRARIES}) + unofficial::vulkan-memory-allocator::vulkan-memory-allocator + Vulkan::Vulkan + vulkan::sdk) ############################## # Find C++ filesystem header # @@ -299,7 +302,7 @@ if(WIN32) add_compile_options_if_supported(/Zc:twoPhase- /permissive) set_target_properties(nova-renderer PROPERTIES PREFIX "") - set(COMMON_LINK_LIBS ${COMMON_LINK_LIBS} d3d12 dxgi d3dcompiler) + set(COMMON_LINK_LIBS ${COMMON_LINK_LIBS} d3d12 dxgi d3dcompiler glslang::HLSL spirv-cross-hlsl) target_include_directories(nova-renderer PRIVATE ${WinSDK_DIRS}) target_compile_definitions(nova-renderer PUBLIC _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING NOMINMAX) diff --git a/appveyor.yml b/appveyor.yml index 993346fc..070c530f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,12 +22,16 @@ install: - cmd: git submodule update --init --recursive - cmd: curl --silent --show-error --output VulkanSDK.exe https://cwfitz.com/s/19028-082433-VulkanSDK-1.1.97.0-Installer.exe - cmd: .\VulkanSDK.exe /S + - cmd: cd C:\Tools\vcpkg + - cmd: git pull + - cmd: cd %APPVEYOR_BUILD_FOLDER% + - ps: .\setup-windows.ps1 before_build: - cmd: cd C:\projects\nova-renderer - cmd: md build - cmd: cd build - - cmd: cmake .. -G "Visual Studio 15 2017 Win64" -DNOVA_TEST=On -DNOVA_TREAT_WARNINGS_AS_ERRORS=On -Thost=x64 + - cmd: cmake .. -G "Visual Studio 15 2017 Win64" -DNOVA_TEST=On -DNOVA_TREAT_WARNINGS_AS_ERRORS=On -Thost=x64 -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake build: project: C:\projects\nova-renderer\build\nova-renderer.sln @@ -38,6 +42,10 @@ test_script: - cmd: dir C:\projects\nova-renderer\build\%CONFIGURATION%\ - cmd: C:\projects\nova-renderer\build\%CONFIGURATION%\nova-test-unit.exe +cache: + - c:\tools\vcpkg\packages\ -> appveyor.yml + - c:\tools\vcpkg\installed\ -> setup-windows.ps1 + on_success: - ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1 - ps: ./send.ps1 success $env:WEBHOOK_URL diff --git a/cmake/ClangFormat.cmake b/cmake/ClangFormat.cmake index e0641840..15f73bea 100644 --- a/cmake/ClangFormat.cmake +++ b/cmake/ClangFormat.cmake @@ -31,9 +31,11 @@ message(STATUS "Found clang-format at ${CLANG_FORMAT_PROGRAM}") if(NOT TARGET format) add_custom_target(format VERBATIM) + set_target_properties(format PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True) endif() if(NOT TARGET reformat) add_custom_target(reformat VERBATIM) + set_target_properties(reformat PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True) endif() file(GLOB_RECURSE CLANG_FORMAT_PATHS CONFIGURE_DEPENDS "*.clang-format") @@ -77,6 +79,8 @@ function(format TARGET) COMMAND "${CMAKE_COMMAND}" -E remove ${TOUCH_PATHS} COMMENT "Clearing format dependencies" ) + set_target_properties(${TARGET}-format PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True FOLDER CMakePredefinedTargets/format) + set_target_properties(${TARGET}-reformat PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True FOLDER CMakePredefinedTargets/reformat) add_dependencies(format ${TARGET}-format) add_dependencies(reformat ${TARGET}-reformat) diff --git a/jenkins.sh b/jenkins.sh index 6038d7e6..bcd3729a 100755 --- a/jenkins.sh +++ b/jenkins.sh @@ -13,6 +13,7 @@ cd build-clang cmake ..\ -DNOVA_TEST=ON\ -DCMAKE_BUILD_TYPE=Debug\ + -DCMAKE_TOOLCHAIN_FILE=${VCPKG_CMAKE}\ -DCMAKE_EXPORT_COMPILE_COMMANDS=On\ -DNOVA_TREAT_WARNINGS_AS_ERRORS=On\ -DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_COMPILER=clang++-8\ @@ -32,6 +33,7 @@ cd build-gcc cmake ..\ -DNOVA_TEST=On\ -DCMAKE_BUILD_TYPE=Debug\ + -DCMAKE_TOOLCHAIN_FILE=${VCPKG_CMAKE}\ -DNOVA_TREAT_WARNINGS_AS_ERRORS=On\ -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7\ -DCMAKE_{C,CXX}_COMPILER_LAUNCHER=ccache\ diff --git a/readme.md b/readme.md index a76f89f6..a1ef2444 100644 --- a/readme.md +++ b/readme.md @@ -17,6 +17,25 @@ The Nova Renderer is currently early in development, so early that I don't think If you want to see what we have planned, or what has already been done, check out [the GitHub projects page](https://github.com/NovaMods/nova-renderer/projects). +## Developer setup + +Nova uses [vcpkg](https://github.com/Microsoft/vcpkg) for dependency management. You need to install it on your system PATH. Once `vcpkg` is on your path, run the appropriate setup script for your platform - run `setup-windows.ps1` from Powershell on Windows, run `setup-linux.sh` from Bash on Linux. This will install almost all of Nova's dependencies + +Install the LunarG Vulkan SDK. Use the latest SDK for Vulkan 1.1 + +Generate your compiler's build files from the CMake project. We recommend creating your build files in a `build` directory in the root of your local Nova Renderer repository. Be sure to pass CMake the `vcpkg` toolchain file, or your CMake will be very sad. An example: + +```powershell +cd $PATH_TO_NOVA +mkdir build +cd build +cmake -DCMAKE_TOOLCHAIN_FILE=C:/Users/DethRaid/Documents/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 15 2017 Win64" -Thost=x64 .. +``` + +This will generate project files for Visual Studio 2017 to compile for a 64-bit machine, and it will use the `vcpkg` toolchain file in my local `vcpkg` repo + +That's it! + ## End Goal Everything from here on out describes what the Nova Renderer will look like during version 1.0. This doesn't necessarily reflect the current status of the project. Check [the GitHub projects page](https://github.com/NovaMods/nova-renderer/projects) to see the current status of the Nova Renderer. diff --git a/setup-linux.sh b/setup-linux.sh new file mode 100644 index 00000000..7ed30f3b --- /dev/null +++ b/setup-linux.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +vcpkg update +vcpkg upgrade --no-dry-run +vcpkg install --recurse miniz:x64-linux fmt:x64-linux glm:x64-linux glslang:x64-linux gtest:x64-linux nlohmann-json:x64-linux spirv-cross:x64-linux spirv-tools:x64-linux vulkan-memory-allocator:x64-linux vulkan:x64-linux spirv-tools:x64-linux minitrace:x64-linux diff --git a/setup-windows.ps1 b/setup-windows.ps1 new file mode 100644 index 00000000..81b65a52 --- /dev/null +++ b/setup-windows.ps1 @@ -0,0 +1,3 @@ +vcpkg update +vcpkg upgrade --no-dry-run +vcpkg install --recurse miniz:x64-windows fmt:x64-windows glm:x64-windows glslang:x64-windows gtest:x64-windows nlohmann-json:x64-windows spirv-cross:x64-windows spirv-tools:x64-windows vulkan-memory-allocator:x64-windows vulkan:x64-windows spirv-tools:x64-windows minitrace:x64-windows diff --git a/src/loading/shaderpack/render_graph_builder.cpp b/src/loading/shaderpack/render_graph_builder.cpp index e18d80f0..b331f084 100644 --- a/src/loading/shaderpack/render_graph_builder.cpp +++ b/src/loading/shaderpack/render_graph_builder.cpp @@ -4,9 +4,9 @@ */ #include "render_graph_builder.hpp" +#include #include #include "../../util/logger.hpp" -#include "nova/profiler.h" namespace nova::renderer { /*! @@ -77,8 +77,8 @@ namespace nova::renderer { } std::vector order_passes(const std::unordered_map& passes) { - // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) - NOVA_PROFILER_SCOPE; + MTR_SCOPE("Renderpass", "order_passes"); + NOVA_LOG(DEBUG) << "Executing Pass Scheduler"; std::vector ordered_passes; diff --git a/src/loading/shaderpack/shaderpack_data.cpp b/src/loading/shaderpack/shaderpack_data.cpp index 9d217c44..8583565e 100644 --- a/src/loading/shaderpack/shaderpack_data.cpp +++ b/src/loading/shaderpack/shaderpack_data.cpp @@ -5,7 +5,6 @@ #include "../../util/vma_usage.hpp" -#include #include "../json_utils.hpp" #include "shaderpack_data.hpp" diff --git a/src/loading/shaderpack/shaderpack_loading.cpp b/src/loading/shaderpack/shaderpack_loading.cpp index 24dea07b..0b6d0e1e 100644 --- a/src/loading/shaderpack/shaderpack_loading.cpp +++ b/src/loading/shaderpack/shaderpack_loading.cpp @@ -4,7 +4,7 @@ */ #include "shaderpack_loading.hpp" -#include +#include #include #include "../folder_accessor.hpp" #include "../json_utils.hpp" @@ -19,6 +19,104 @@ #include "../../tasks/task_scheduler.hpp" namespace nova::renderer { + // Removed from the GLSLang version we're using + const TBuiltInResource default_built_in_resource = { + /* .MaxLights = */ 32, + /* .MaxClipPlanes = */ 6, + /* .MaxTextureUnits = */ 32, + /* .MaxTextureCoords = */ 32, + /* .MaxVertexAttribs = */ 64, + /* .MaxVertexUniformComponents = */ 4096, + /* .MaxVaryingFloats = */ 64, + /* .MaxVertexTextureImageUnits = */ 32, + /* .MaxCombinedTextureImageUnits = */ 80, + /* .MaxTextureImageUnits = */ 32, + /* .MaxFragmentUniformComponents = */ 4096, + /* .MaxDrawBuffers = */ 32, + /* .MaxVertexUniformVectors = */ 128, + /* .MaxVaryingVectors = */ 8, + /* .MaxFragmentUniformVectors = */ 16, + /* .MaxVertexOutputVectors = */ 16, + /* .MaxFragmentInputVectors = */ 15, + /* .MinProgramTexelOffset = */ -8, + /* .MaxProgramTexelOffset = */ 7, + /* .MaxClipDistances = */ 8, + /* .MaxComputeWorkGroupCountX = */ 65535, + /* .MaxComputeWorkGroupCountY = */ 65535, + /* .MaxComputeWorkGroupCountZ = */ 65535, + /* .MaxComputeWorkGroupSizeX = */ 1024, + /* .MaxComputeWorkGroupSizeY = */ 1024, + /* .MaxComputeWorkGroupSizeZ = */ 64, + /* .MaxComputeUniformComponents = */ 1024, + /* .MaxComputeTextureImageUnits = */ 16, + /* .MaxComputeImageUniforms = */ 8, + /* .MaxComputeAtomicCounters = */ 8, + /* .MaxComputeAtomicCounterBuffers = */ 1, + /* .MaxVaryingComponents = */ 60, + /* .MaxVertexOutputComponents = */ 64, + /* .MaxGeometryInputComponents = */ 64, + /* .MaxGeometryOutputComponents = */ 128, + /* .MaxFragmentInputComponents = */ 128, + /* .MaxImageUnits = */ 8, + /* .MaxCombinedImageUnitsAndFragmentOutputs = */ 8, + /* .MaxCombinedShaderOutputResources = */ 8, + /* .MaxImageSamples = */ 0, + /* .MaxVertexImageUniforms = */ 0, + /* .MaxTessControlImageUniforms = */ 0, + /* .MaxTessEvaluationImageUniforms = */ 0, + /* .MaxGeometryImageUniforms = */ 0, + /* .MaxFragmentImageUniforms = */ 8, + /* .MaxCombinedImageUniforms = */ 8, + /* .MaxGeometryTextureImageUnits = */ 16, + /* .MaxGeometryOutputVertices = */ 256, + /* .MaxGeometryTotalOutputComponents = */ 1024, + /* .MaxGeometryUniformComponents = */ 1024, + /* .MaxGeometryVaryingComponents = */ 64, + /* .MaxTessControlInputComponents = */ 128, + /* .MaxTessControlOutputComponents = */ 128, + /* .MaxTessControlTextureImageUnits = */ 16, + /* .MaxTessControlUniformComponents = */ 1024, + /* .MaxTessControlTotalOutputComponents = */ 4096, + /* .MaxTessEvaluationInputComponents = */ 128, + /* .MaxTessEvaluationOutputComponents = */ 128, + /* .MaxTessEvaluationTextureImageUnits = */ 16, + /* .MaxTessEvaluationUniformComponents = */ 1024, + /* .MaxTessPatchComponents = */ 120, + /* .MaxPatchVertices = */ 32, + /* .MaxTessGenLevel = */ 64, + /* .MaxViewports = */ 16, + /* .MaxVertexAtomicCounters = */ 0, + /* .MaxTessControlAtomicCounters = */ 0, + /* .MaxTessEvaluationAtomicCounters = */ 0, + /* .MaxGeometryAtomicCounters = */ 0, + /* .MaxFragmentAtomicCounters = */ 8, + /* .MaxCombinedAtomicCounters = */ 8, + /* .MaxAtomicCounterBindings = */ 1, + /* .MaxVertexAtomicCounterBuffers = */ 0, + /* .MaxTessControlAtomicCounterBuffers = */ 0, + /* .MaxTessEvaluationAtomicCounterBuffers = */ 0, + /* .MaxGeometryAtomicCounterBuffers = */ 0, + /* .MaxFragmentAtomicCounterBuffers = */ 1, + /* .MaxCombinedAtomicCounterBuffers = */ 1, + /* .MaxAtomicCounterBufferSize = */ 16384, + /* .MaxTransformFeedbackBuffers = */ 4, + /* .MaxTransformFeedbackInterleavedComponents = */ 64, + /* .MaxCullDistances = */ 8, + /* .MaxCombinedClipAndCullDistances = */ 8, + /* .MaxSamples = */ 4, + /* .limits = */ + { + /* .nonInductiveForLoops = */ true, + /* .whileLoops = */ true, + /* .doWhileLoops = */ true, + /* .generalUniformIndexing = */ true, + /* .generalAttributeMatrixVectorIndexing = */ true, + /* .generalVaryingIndexing = */ true, + /* .generalSamplerIndexing = */ true, + /* .generalVariableIndexing = */ true, + /* .generalConstantMatrixVectorIndexing = */ true, + }}; + std::shared_ptr get_shaderpack_accessor(const fs::path& shaderpack_name); shaderpack_resources_data load_dynamic_resources_file(const std::shared_ptr& folder_access); @@ -344,7 +442,7 @@ namespace nova::renderer { auto* shader_source_data = shader_source.data(); shader.setStrings(&shader_source_data, 1); - const bool shader_compiled = shader.parse(&glslang::DefaultTBuiltInResource, + const bool shader_compiled = shader.parse(&default_built_in_resource, 450, ECoreProfile, false, diff --git a/src/loading/zip_folder_accessor.hpp b/src/loading/zip_folder_accessor.hpp index 448cbcf6..b0e083a7 100644 --- a/src/loading/zip_folder_accessor.hpp +++ b/src/loading/zip_folder_accessor.hpp @@ -6,7 +6,7 @@ #ifndef NOVA_RENDERER_ZIP_FOLDER_ACCESSOR_H #define NOVA_RENDERER_ZIP_FOLDER_ACCESSOR_H -#include +#include #include "folder_accessor.hpp" namespace nova::renderer { diff --git a/src/nova_renderer.cpp b/src/nova_renderer.cpp index 86fc7872..2fe39946 100644 --- a/src/nova_renderer.cpp +++ b/src/nova_renderer.cpp @@ -3,13 +3,13 @@ * \date 03-Sep-18. */ +#include #include #include "nova_renderer.hpp" #include "glslang/MachineIndependent/Initialize.h" #include "loading/shaderpack/shaderpack_loading.hpp" -#include "util/logger.hpp" #if defined(NOVA_WINDOWS) #include "render_engine/dx12/dx12_render_engine.hpp" @@ -18,7 +18,7 @@ #include "debugging/renderdoc.hpp" #include "render_engine/vulkan/vulkan_render_engine.hpp" -#include "minitrace.h" +#include namespace nova::renderer { std::unique_ptr nova_renderer::instance; @@ -40,8 +40,8 @@ namespace nova::renderer { if(render_doc != nullptr) { render_doc->SetCaptureFilePathTemplate(settings.debug.renderdoc.capture_path.c_str()); - RENDERDOC_InputButton captureKey = eRENDERDOC_Key_PrtScrn; - render_doc->SetCaptureKeys(&captureKey, 1); + std::array capture_key = {eRENDERDOC_Key_F12, eRENDERDOC_Key_PrtScrn}; + render_doc->SetCaptureKeys(capture_key.data(), 1); render_doc->SetCaptureOptionU32(eRENDERDOC_Option_AllowFullscreen, 1U); render_doc->SetCaptureOptionU32(eRENDERDOC_Option_AllowVSync, 1U); @@ -58,6 +58,9 @@ namespace nova::renderer { MTR_SCOPE("Init", "InitDirectX12RenderEngine"); engine = std::make_unique(render_settings, &task_scheduler); } break; +#else + NOVA_LOG(WARN) << "You selected the DX12 graphics API, but your system doesn't support it. Defaulting to Vulkan"; + [[fallthrough]]; #endif case graphics_api::vulkan: MTR_SCOPE("Init", "InitVulkanRenderEngine"); diff --git a/src/render_engine/dx12/dx12_render_engine.cpp b/src/render_engine/dx12/dx12_render_engine.cpp index 19028d58..be1bdf45 100644 --- a/src/render_engine/dx12/dx12_render_engine.cpp +++ b/src/render_engine/dx12/dx12_render_engine.cpp @@ -8,10 +8,9 @@ #include #include -#include #include "dx12_render_engine.hpp" -#include "../../../3rdparty/SPIRV-Cross/spirv_cross.hpp" +#include #include "../../loading/shaderpack/render_graph_builder.hpp" #include "../../loading/shaderpack/shaderpack_loading.hpp" #include "../../nova_renderer.hpp" diff --git a/src/render_engine/dx12/dx12_render_engine.hpp b/src/render_engine/dx12/dx12_render_engine.hpp index a9022a6e..a2318377 100644 --- a/src/render_engine/dx12/dx12_render_engine.hpp +++ b/src/render_engine/dx12/dx12_render_engine.hpp @@ -16,9 +16,9 @@ #include #include +#include #include #include -#include "../../../3rdparty/SPIRV-Cross/spirv_hlsl.hpp" #include "../../loading/shaderpack/render_graph_builder.hpp" #include "dx12_texture.hpp" diff --git a/src/render_engine/vulkan/uniform_buffer.hpp b/src/render_engine/vulkan/uniform_buffer.hpp index 9d485192..ab418be8 100644 --- a/src/render_engine/vulkan/uniform_buffer.hpp +++ b/src/render_engine/vulkan/uniform_buffer.hpp @@ -7,7 +7,7 @@ #define RENDERER_GL_UNIFORM_BUFFER_H #include -#include +#include "../../util/vma_usage.hpp" namespace nova::renderer { /*! diff --git a/src/render_engine/vulkan/vulkan_render_engine.cpp b/src/render_engine/vulkan/vulkan_render_engine.cpp index d62e6ee0..7788e339 100644 --- a/src/render_engine/vulkan/vulkan_render_engine.cpp +++ b/src/render_engine/vulkan/vulkan_render_engine.cpp @@ -3,7 +3,7 @@ // #include "vulkan_render_engine.hpp" -#include +#include #include #include "../../loading/shaderpack/render_graph_builder.hpp" #include "../../loading/shaderpack/shaderpack_loading.hpp" diff --git a/src/render_engine/vulkan/vulkan_render_engine.hpp b/src/render_engine/vulkan/vulkan_render_engine.hpp index af6c7b99..5ad43052 100644 --- a/src/render_engine/vulkan/vulkan_render_engine.hpp +++ b/src/render_engine/vulkan/vulkan_render_engine.hpp @@ -24,9 +24,9 @@ #include #include -#include +#include +#include "../../util/vma_usage.hpp" #include "compacting_block_allocator.hpp" -#include "spirv_glsl.hpp" #include #include "../../render_objects/render_object.hpp" diff --git a/src/render_engine/vulkan/vulkan_render_engine_render_frame.cpp b/src/render_engine/vulkan/vulkan_render_engine_render_frame.cpp index dd9803cb..1b013836 100644 --- a/src/render_engine/vulkan/vulkan_render_engine_render_frame.cpp +++ b/src/render_engine/vulkan/vulkan_render_engine_render_frame.cpp @@ -446,6 +446,32 @@ namespace nova::renderer { const std::unordered_map>& renderables_by_buffer = renderables_by_material.at(pass.name); + /* + * For the compute shader that generates draw commands: + * + * + * ZerfYesterday at 11:52 PM + * so in that case, do something like this + * curr_index = 0 + * for each modeltype + * start_index = curr_index + * for each instance of modeltype + * if ( is_culled ) { + * continue + * } + * matrix_indices[curr_index] = matrix_index; + * ++curr_index + * } + * if ( curr_index != start_index ) { + * write render_indirect data + * instanceCount = curr_index - start_index + * firstInstance = start_index + * } + * then in your shader, you can get the offset into matrix_indices by using gl_InstanceIndex + * and if you need the current instance, you can calculate it by using + * int curr_instance = gl_InstanceIndex - gl_BaseInstance + */ + for(const auto& [buffer, renderables] : renderables_by_buffer) { VkBufferCreateInfo buffer_create_info = {}; buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; diff --git a/src/render_engine/vulkan/x11_window.cpp b/src/render_engine/vulkan/x11_window.cpp index a4d22993..99d34af7 100644 --- a/src/render_engine/vulkan/x11_window.cpp +++ b/src/render_engine/vulkan/x11_window.cpp @@ -9,7 +9,7 @@ #include "x11_window.hpp" namespace nova::renderer { - x11_window::x11_window(uint32_t width, uint32_t height, const std::string &title) { + x11_window::x11_window(uint32_t width, uint32_t height, const std::string& title) { display = XOpenDisplay(nullptr); if(display == nullptr) { throw window_creation_error("Failed to open XDisplay"); diff --git a/src/render_engine/vulkan/x11_window.hpp b/src/render_engine/vulkan/x11_window.hpp index 283abfb4..3af71c95 100644 --- a/src/render_engine/vulkan/x11_window.hpp +++ b/src/render_engine/vulkan/x11_window.hpp @@ -21,7 +21,7 @@ namespace nova::renderer { Atom wm_delete_window; public: - explicit x11_window(uint32_t width, uint32_t height, const std::string &title); + explicit x11_window(uint32_t width, uint32_t height, const std::string& title); x11_window(x11_window&& other) noexcept = delete; x11_window& operator=(x11_window&& other) noexcept = delete; diff --git a/src/util/vma_usage.hpp b/src/util/vma_usage.hpp index e559fe96..e9a3a2bf 100644 --- a/src/util/vma_usage.hpp +++ b/src/util/vma_usage.hpp @@ -3,4 +3,5 @@ #undef NOMINMAX #undef WIN32_LEAN_AND_MEAN #undef VK_USE_PLATFORM_WIN32_KHR -#include + +#include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3dad1043..0583435b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,7 +23,7 @@ nova_format(nova-test-end-to-end) set(NOVA_UNIT_TEST_SOURCES unit_tests/loading/filesystem_test.cpp src/general_test_setup.hpp unit_tests/loading/shaderpack/shaderpack_validator_tests.cpp) add_executable(nova-test-unit ${NOVA_UNIT_TEST_SOURCES}) target_compile_definitions(nova-test-unit PRIVATE CMAKE_DEFINED_RESOURCES_PREFIX="${CMAKE_CURRENT_LIST_DIR}/resources/") -target_link_libraries(nova-test-unit nova-renderer gtest_main Threads::Threads) +target_link_libraries(nova-test-unit nova-renderer GTest::Main Threads::Threads) target_compile_options_if_supported(nova-test-unit PRIVATE -Wno-unknown-pragmas) remove_permissive(nova-test-unit) nova_format(nova-test-unit)