From 5588ede005a7229e968d09604da21ea308c08713 Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Tue, 30 Jul 2024 16:16:19 +0100 Subject: [PATCH 1/9] feat: add tracy profiler --- CMakeLists.txt | 2 ++ include/PCH.h | 2 ++ src/Deferred.cpp | 13 +++++++++++++ src/Features/DynamicCubemaps.cpp | 2 ++ src/Features/ScreenSpaceGI.cpp | 11 +++++++++++ src/Features/ScreenSpaceShadows.cpp | 7 +++++++ src/Features/Skylighting.cpp | 7 ++++++- src/Features/SubsurfaceScattering.cpp | 7 +++++++ src/Features/TerrainOcclusion.cpp | 3 +++ src/Hooks.cpp | 20 +++++++++++++++++++- src/State.cpp | 2 ++ src/State.h | 11 +++++++++++ vcpkg.json | 3 ++- 13 files changed, 87 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe81cf487..8494224db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ find_package(pystring CONFIG REQUIRED) find_package(cppwinrt CONFIG REQUIRED) find_package(unordered_dense CONFIG REQUIRED) find_package(efsw CONFIG REQUIRED) +find_package(Tracy CONFIG REQUIRED) set(NVAPI_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/extern/nvapi/" CACHE STRING "Path to NVAPI include headers/shaders" ) set(NVAPI_LIBRARY "${CMAKE_SOURCE_DIR}/extern/nvapi/amd64/nvapi64.lib" CACHE STRING "Path to NVAPI .lib file") @@ -68,6 +69,7 @@ target_link_libraries( pystring::pystring unordered_dense::unordered_dense efsw::efsw + Tracy::TracyClient ${NVAPI_LIBRARY} ) diff --git a/include/PCH.h b/include/PCH.h index de9965b2b..856ef5b2d 100644 --- a/include/PCH.h +++ b/include/PCH.h @@ -31,6 +31,8 @@ void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, cons #define WIN32_LEAN_AND_MEAN #include +#define TRACY_ENABLE + using namespace std::literals; namespace stl diff --git a/src/Deferred.cpp b/src/Deferred.cpp index be7627d90..5de844409 100644 --- a/src/Deferred.cpp +++ b/src/Deferred.cpp @@ -170,6 +170,9 @@ void Deferred::SetupResources() void Deferred::CopyShadowData() { + ZoneScoped; + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "CopyShadowData"); + auto& context = State::GetSingleton()->context; ID3D11UnorderedAccessView* uavs[1]{ perShadow->uav.get() }; @@ -239,6 +242,9 @@ void Deferred::UpdateConstantBuffer() void Deferred::PrepassPasses() { + ZoneScoped; + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Prepass"); + auto& shaderCache = SIE::ShaderCache::Instance(); if (!shaderCache.IsEnabled()) @@ -391,6 +397,9 @@ void Deferred::StartDeferred() void Deferred::DeferredPasses() { + ZoneScoped; + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Deferred"); + auto renderer = RE::BSGraphics::Renderer::GetSingleton(); auto& context = State::GetSingleton()->context; @@ -431,6 +440,8 @@ void Deferred::DeferredPasses() // Ambient Composite { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Ambient Composite"); + ID3D11Buffer* buffer = skylighting->loaded ? skylighting->skylightingCB->CB() : nullptr; context->CSSetConstantBuffers(1, 1, &buffer); @@ -469,6 +480,8 @@ void Deferred::DeferredPasses() // Deferred Composite { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Deferred Composite"); + ID3D11Buffer* buffer = skylighting->loaded ? skylighting->skylightingCB->CB() : nullptr; context->CSSetConstantBuffers(1, 1, &buffer); diff --git a/src/Features/DynamicCubemaps.cpp b/src/Features/DynamicCubemaps.cpp index 5056791af..e8f2da9e8 100644 --- a/src/Features/DynamicCubemaps.cpp +++ b/src/Features/DynamicCubemaps.cpp @@ -368,6 +368,8 @@ void DynamicCubemaps::Irradiance(bool a_reflections) void DynamicCubemaps::UpdateCubemap() { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Cubemap Update"); + switch (nextTask) { case NextTask::kInferrence: nextTask = NextTask::kIrradiance; diff --git a/src/Features/ScreenSpaceGI.cpp b/src/Features/ScreenSpaceGI.cpp index 1c71f01b4..e40936dd6 100644 --- a/src/Features/ScreenSpaceGI.cpp +++ b/src/Features/ScreenSpaceGI.cpp @@ -635,6 +635,9 @@ void ScreenSpaceGI::DrawSSGI(Texture2D* srcPrevAmbient) return; } + ZoneScoped; + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSGI"); + static uint lastFrameGITexIdx = 0; static uint lastFrameAccumTexIdx = 0; uint inputGITexIdx = lastFrameGITexIdx; @@ -675,6 +678,8 @@ void ScreenSpaceGI::DrawSSGI(Texture2D* srcPrevAmbient) // prefilter depths { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSGI - Prefilter Depths"); + srvs.at(0) = renderer->GetDepthStencilData().depthStencils[RE::RENDER_TARGETS_DEPTHSTENCIL::kPOST_ZPREPASS_COPY].depthSRV; for (int i = 0; i < 5; ++i) uavs.at(i) = uavWorkingDepth[i].get(); @@ -687,6 +692,8 @@ void ScreenSpaceGI::DrawSSGI(Texture2D* srcPrevAmbient) // fetch radiance and disocclusion { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSGI - Radiance Disocc"); + resetViews(); srvs.at(0) = rts[deferred->forwardRenderTargets[0]].SRV; srvs.at(1) = texGI[inputGITexIdx]->srv.get(); @@ -714,6 +721,8 @@ void ScreenSpaceGI::DrawSSGI(Texture2D* srcPrevAmbient) // GI { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSGI - GI"); + resetViews(); srvs.at(0) = texWorkingDepth->srv.get(); srvs.at(1) = rts[NORMALROUGHNESS].SRV; @@ -738,6 +747,8 @@ void ScreenSpaceGI::DrawSSGI(Texture2D* srcPrevAmbient) // blur if (settings.EnableBlur) { for (uint i = 0; i < settings.BlurPasses; i++) { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSGI - Blur"); + resetViews(); srvs.at(0) = texGI[inputGITexIdx]->srv.get(); srvs.at(1) = texAccumFrames[lastFrameAccumTexIdx]->srv.get(); diff --git a/src/Features/ScreenSpaceShadows.cpp b/src/Features/ScreenSpaceShadows.cpp index 3090434fc..b27e37300 100644 --- a/src/Features/ScreenSpaceShadows.cpp +++ b/src/Features/ScreenSpaceShadows.cpp @@ -87,6 +87,9 @@ ID3D11ComputeShader* ScreenSpaceShadows::GetComputeRaymarchRight() void ScreenSpaceShadows::DrawShadows() { + ZoneScoped; + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Screen Space Shadows"); + auto renderer = RE::BSGraphics::Renderer::GetSingleton(); auto context = State::GetSingleton()->context; @@ -134,6 +137,8 @@ void ScreenSpaceShadows::DrawShadows() float2 dynamicRes = { viewport->GetRuntimeData().dynamicResolutionWidthRatio, viewport->GetRuntimeData().dynamicResolutionHeightRatio }; for (int i = 0; i < dispatchList.DispatchCount; i++) { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSS - Ray March"); + auto dispatchData = dispatchList.Dispatch[i]; RaymarchCB data{}; @@ -174,6 +179,8 @@ void ScreenSpaceShadows::DrawShadows() dispatchList = Bend::BuildDispatchList(lightProjectionRightF, viewportSize, minRenderBounds, maxRenderBounds); for (int i = 0; i < dispatchList.DispatchCount; i++) { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSS - Ray March (VR Right Eye)"); + auto dispatchData = dispatchList.Dispatch[i]; RaymarchCB data{}; diff --git a/src/Features/Skylighting.cpp b/src/Features/Skylighting.cpp index bf0383df4..03ed11fce 100644 --- a/src/Features/Skylighting.cpp +++ b/src/Features/Skylighting.cpp @@ -200,6 +200,8 @@ void Skylighting::CompileComputeShaders() void Skylighting::Prepass() { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Skylighting - Update Probes"); + auto& context = State::GetSingleton()->context; { @@ -649,7 +651,10 @@ void Skylighting::Main_Precipitation_RenderOcclusion::thunk() Precipitation_SetupMask(precip); // Calling setup twice fixes an issue when it is raining BSParticleShaderRainEmitter* rain = new BSParticleShaderRainEmitter; - Precipitation_RenderMask(precip, rain); + { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Skylighting - Render Height Map"); + Precipitation_RenderMask(precip, rain); + } singleton->inOcclusion = false; RE::BSParticleShaderCubeEmitter* cube = (RE::BSParticleShaderCubeEmitter*)rain; diff --git a/src/Features/SubsurfaceScattering.cpp b/src/Features/SubsurfaceScattering.cpp index 85847c3ed..e01017538 100644 --- a/src/Features/SubsurfaceScattering.cpp +++ b/src/Features/SubsurfaceScattering.cpp @@ -163,6 +163,9 @@ void SubsurfaceScattering::DrawSSS() if (!validMaterials) return; + ZoneScoped; + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Subsurface Scattering"); + validMaterials = false; auto dispatchCount = Util::GetScreenDispatchCount(); @@ -204,6 +207,8 @@ void SubsurfaceScattering::DrawSSS() // Horizontal pass to temporary texture { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Subsurface Scattering - Horizontal"); + auto shader = GetComputeShaderHorizontalBlur(); context->CSSetShader(shader, nullptr, 0); @@ -215,6 +220,8 @@ void SubsurfaceScattering::DrawSSS() // Vertical pass to main texture { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Subsurface Scattering - Vertical"); + views[0] = blurHorizontalTemp->srv.get(); context->CSSetShaderResources(0, 1, views); diff --git a/src/Features/TerrainOcclusion.cpp b/src/Features/TerrainOcclusion.cpp index 801414661..82ce98d9a 100644 --- a/src/Features/TerrainOcclusion.cpp +++ b/src/Features/TerrainOcclusion.cpp @@ -432,6 +432,9 @@ void TerrainOcclusion::UpdateShadow() if (!sunLight) return; + ZoneScoped; + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Terrain Occlusion - Update Shadows"); + /* ---- UPDATE CB ---- */ uint width = texNormalisedHeight->desc.Width; uint height = texNormalisedHeight->desc.Height; diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 4486839dc..60745cad0 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -147,7 +147,9 @@ HRESULT WINAPI hk_IDXGISwapChain_Present(IDXGISwapChain* This, UINT SyncInterval { State::GetSingleton()->Reset(); Menu::GetSingleton()->DrawOverlay(); - return (This->*ptr_IDXGISwapChain_Present)(SyncInterval, Flags); + auto retval = (This->*ptr_IDXGISwapChain_Present)(SyncInterval, Flags); + TracyD3D11Collect(State::GetSingleton()->tracyCtx); + return retval; } void hk_BSGraphics_SetDirtyStates(bool isCompute); @@ -443,6 +445,18 @@ namespace Hooks static inline REL::Relocation func; }; +#ifdef TRACY_ENABLE + struct Main_Update + { + static void thunk(RE::Main* a_this, float a2) + { + func(a_this, a2); + FrameMark; + } + static inline REL::Relocation func; + }; +#endif + void Install() { SKSE::AllocTrampoline(14); @@ -482,5 +496,9 @@ namespace Hooks stl::write_thunk_call(REL::RelocationID(100458, 107175).address() + REL::Relocate(0x406, 0x409)); stl::write_thunk_call(REL::RelocationID(100458, 107175).address() + REL::Relocate(0x1245, 0x123B, 0x1917)); stl::write_thunk_call(REL::RelocationID(100458, 107175).address() + REL::Relocate(0xA25, 0xA25, 0xCD2)); + +#ifdef TRACY_ENABLE + stl::write_thunk_call(REL::RelocationID(35551, 36544).address() + REL::Relocate(0x11F, 0x160, 0x0)); // VR unknown +#endif } } \ No newline at end of file diff --git a/src/State.cpp b/src/State.cpp index f7579e222..bee82ae55 100644 --- a/src/State.cpp +++ b/src/State.cpp @@ -361,6 +361,8 @@ void State::SetupResources() context = reinterpret_cast(renderer->GetRuntimeData().context); device = reinterpret_cast(renderer->GetRuntimeData().forwarder); context->QueryInterface(__uuidof(pPerf), reinterpret_cast(&pPerf)); + + tracyCtx = TracyD3D11Context(device, context); } void State::ModifyShaderLookup(const RE::BSShader& a_shader, uint& a_vertexDescriptor, uint& a_pixelDescriptor, bool a_forceDeferred) diff --git a/src/State.h b/src/State.h index a31cb396a..df09bfa2d 100644 --- a/src/State.h +++ b/src/State.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include using json = nlohmann::json; @@ -138,6 +141,14 @@ class State ID3D11DeviceContext* context = nullptr; ID3D11Device* device = nullptr; + TracyD3D11Ctx tracyCtx = nullptr; // Tracy context + + inline ~State() + { + if (tracyCtx) + TracyD3D11Destroy(tracyCtx); + } + private: std::shared_ptr pPerf; bool initialized = false; diff --git a/vcpkg.json b/vcpkg.json index 9eeeb399a..6ef5ad1db 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -25,7 +25,8 @@ "eastl", "clib-util", "unordered-dense", - "efsw" + "efsw", + "tracy" ], "overrides": [ { From 2c512660322e9197d207f2508b793f3bcd30be6b Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Tue, 30 Jul 2024 17:25:19 +0100 Subject: [PATCH 2/9] chore: update VR offset --- src/Hooks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 60745cad0..8dc9c37e5 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -498,7 +498,7 @@ namespace Hooks stl::write_thunk_call(REL::RelocationID(100458, 107175).address() + REL::Relocate(0xA25, 0xA25, 0xCD2)); #ifdef TRACY_ENABLE - stl::write_thunk_call(REL::RelocationID(35551, 36544).address() + REL::Relocate(0x11F, 0x160, 0x0)); // VR unknown + stl::write_thunk_call(REL::RelocationID(35551, 36544).address() + REL::Relocate(0x11F, 0x160)); #endif } } \ No newline at end of file From 43d8b4d4f9d15bf119054567961d59537890c03a Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Wed, 31 Jul 2024 02:53:20 +0100 Subject: [PATCH 3/9] chore: force tracy 0.11.0 --- vcpkg.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vcpkg.json b/vcpkg.json index 6ef5ad1db..e4a1e4dd3 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -26,7 +26,10 @@ "clib-util", "unordered-dense", "efsw", - "tracy" + { + "name": "tracy", + "version>=": "0.11.0" + } ], "overrides": [ { From da62a1eca8ef2dcb390133e68e3c9ea53fea6e19 Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Wed, 31 Jul 2024 13:31:58 +0100 Subject: [PATCH 4/9] chore: add TRACY_ENABLE as cmake option, remove redundant include --- CMakeLists.txt | 2 ++ include/PCH.h | 2 -- src/State.h | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8494224db..d41f0d9ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,9 +15,11 @@ message("Options:") option(AUTO_PLUGIN_DEPLOYMENT "Copy the build output and addons to env:CommunityShadersOutputDir." OFF) option(ZIP_TO_DIST "Zip the base mod and addons to their own 7z file in dist." ON) option(AIO_ZIP_TO_DIST "Zip the base mod and addons to a AIO 7z file in dist." ON) +option(TRACY_ENABLE "Enable support for tracy profiler" ON) message("\tAuto plugin deployment: ${AUTO_PLUGIN_DEPLOYMENT}") message("\tZip to dist: ${ZIP_TO_DIST}") message("\tAIO Zip to dist: ${AIO_ZIP_TO_DIST}") +message("\tTracy profiler: ${TRACY_ENABLE}") # ####################################################################################################################### # # Add CMake features diff --git a/include/PCH.h b/include/PCH.h index 856ef5b2d..de9965b2b 100644 --- a/include/PCH.h +++ b/include/PCH.h @@ -31,8 +31,6 @@ void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, cons #define WIN32_LEAN_AND_MEAN #include -#define TRACY_ENABLE - using namespace std::literals; namespace stl diff --git a/src/State.h b/src/State.h index df09bfa2d..40b38a7c8 100644 --- a/src/State.h +++ b/src/State.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include From cfd833cc2dcd44eb9f300e4bbe3b9aa825770fb1 Mon Sep 17 00:00:00 2001 From: Flayan Date: Wed, 31 Jul 2024 15:56:55 +0200 Subject: [PATCH 5/9] build: add TRACY_SUPPORT cmake option and fix vcpkg baseline --- .github/workflows/build.yaml | 7 ++--- CMakeLists.txt | 12 ++++++--- CMakePresets.json | 17 +++++++----- README.md | 6 ++++- include/PCH.h | 4 +++ src/State.h | 3 +++ vcpkg.json | 51 ++++++++++++++++++++---------------- 7 files changed, 62 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0fbab9138..7137d7043 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,9 +9,6 @@ on: permissions: contents: write -env: - VCPKG_COMMIT_ID: 34742e119fb2aae42f10c03a98e475eb1934f7c9 - jobs: compile: name: build plugin and addons @@ -23,9 +20,9 @@ jobs: - uses: ilammy/msvc-dev-cmd@v1.10.0 - - uses: lukka/run-vcpkg@v11 + - uses: lukka/run-vcpkg@v11.5 with: - vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + vcpkgJsonGlob: vcpkg.json - name: cmake configure run: cmake -S . --preset=ALL --check-stamp-file "build\CMakeFiles\generate.stamp" diff --git a/CMakeLists.txt b/CMakeLists.txt index d41f0d9ef..9372a5593 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,11 +15,11 @@ message("Options:") option(AUTO_PLUGIN_DEPLOYMENT "Copy the build output and addons to env:CommunityShadersOutputDir." OFF) option(ZIP_TO_DIST "Zip the base mod and addons to their own 7z file in dist." ON) option(AIO_ZIP_TO_DIST "Zip the base mod and addons to a AIO 7z file in dist." ON) -option(TRACY_ENABLE "Enable support for tracy profiler" ON) +option(TRACY_SUPPORT "Enable support for tracy profiler" OFF) message("\tAuto plugin deployment: ${AUTO_PLUGIN_DEPLOYMENT}") message("\tZip to dist: ${ZIP_TO_DIST}") message("\tAIO Zip to dist: ${AIO_ZIP_TO_DIST}") -message("\tTracy profiler: ${TRACY_ENABLE}") +message("\tTracy profiler: ${TRACY_SUPPORT}") # ####################################################################################################################### # # Add CMake features @@ -47,6 +47,12 @@ find_package(Tracy CONFIG REQUIRED) set(NVAPI_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/extern/nvapi/" CACHE STRING "Path to NVAPI include headers/shaders" ) set(NVAPI_LIBRARY "${CMAKE_SOURCE_DIR}/extern/nvapi/amd64/nvapi64.lib" CACHE STRING "Path to NVAPI .lib file") +target_compile_definitions( + ${PROJECT_NAME} + PRIVATE + "$<$:TRACY_SUPPORT>" +) + target_include_directories( ${PROJECT_NAME} PRIVATE @@ -72,7 +78,7 @@ target_link_libraries( unordered_dense::unordered_dense efsw::efsw Tracy::TracyClient - ${NVAPI_LIBRARY} + ${NVAPI_LIBRARY} ) # https://gitlab.kitware.com/cmake/cmake/-/issues/24922#note_1371990 diff --git a/CMakePresets.json b/CMakePresets.json index 7469e111f..27998958b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -58,7 +58,8 @@ "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "ON", "ENABLE_SKYRIM_SE": "OFF", - "ENABLE_SKYRIM_VR": "OFF" + "ENABLE_SKYRIM_VR": "OFF", + "BUILD_TESTS": "OFF" }, "inherits": [ "common", @@ -73,7 +74,8 @@ "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "OFF", "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "OFF" + "ENABLE_SKYRIM_VR": "OFF", + "BUILD_TESTS": "OFF" }, "inherits": [ "common", @@ -88,7 +90,8 @@ "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "OFF", "ENABLE_SKYRIM_SE": "OFF", - "ENABLE_SKYRIM_VR": "ON" + "ENABLE_SKYRIM_VR": "ON", + "BUILD_TESTS": "OFF" }, "inherits": [ "common", @@ -103,7 +106,8 @@ "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "ON", "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "ON" + "ENABLE_SKYRIM_VR": "ON", + "BUILD_TESTS": "OFF" }, "inherits": [ "common", @@ -118,7 +122,8 @@ "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "OFF", "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "ON" + "ENABLE_SKYRIM_VR": "ON", + "BUILD_TESTS": "OFF" }, "inherits": [ "common", @@ -134,7 +139,7 @@ "ENABLE_SKYRIM_AE": "ON", "ENABLE_SKYRIM_SE": "ON", "ENABLE_SKYRIM_VR": "OFF", - "Build Tests": "OFF" + "BUILD_TESTS": "OFF" }, "inherits": [ "common", diff --git a/README.md b/README.md index 1aa8118fd..7ad689c93 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,17 @@ If you want an example CMakeUserPreset to start off with you can copy the `CMake * Make sure `"AUTO_PLUGIN_DEPLOYMENT"` is set to `"ON"` in `CMakeUserPresets.json` * Change the `"CommunityShadersOutputDir"` value to match your desired outputs, if you want multiple folders you can separate them by `;` is shown in the template example #### AIO_ZIP_TO_DIST -* This option is default `"OFF"` +* This option is default `"ON"` * Make sure `"AIO_ZIP_TO_DIST"` is set to `"ON"` in `CMakeUserPresets.json` * This will create a `CommunityShaders_AIO.7z` archive in /dist containing all features and base mod #### ZIP_TO_DIST * This option is default `"ON"` * Make sure `"ZIP_TO_DIST"` is set to `"ON"` in `CMakeUserPresets.json` * This will create a zip for each feature and one for the base Community shaders in /dist containing +#### TRACY_SUPPORT +* This option is default `"OFF"` +* This will enable tracy support, might need to delete build folder when this option is changed + When using custom preset you can call BuildRelease.bat with an parameter to specify which preset to configure eg: `.\BuildRelease.bat ALL-WITH-AUTO-DEPLOYMENT` diff --git a/include/PCH.h b/include/PCH.h index de9965b2b..05f058749 100644 --- a/include/PCH.h +++ b/include/PCH.h @@ -31,6 +31,10 @@ void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, cons #define WIN32_LEAN_AND_MEAN #include +#ifndef TRACY_SUPPORT + #undef TRACY_ENABLE +#endif + using namespace std::literals; namespace stl diff --git a/src/State.h b/src/State.h index 40b38a7c8..25924634d 100644 --- a/src/State.h +++ b/src/State.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -144,8 +145,10 @@ class State inline ~State() { +#ifdef TRACY_ENABLE if (tracyCtx) TracyD3D11Destroy(tracyCtx); +#endif } private: diff --git a/vcpkg.json b/vcpkg.json index e4a1e4dd3..9d3314d21 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,41 +1,46 @@ { + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "name": "communityshaders", - "version-semver": "0.7.4", - "description": "", "license": "GPL-3.0", + "features": { + "commonlibsse-ng": { + "description": "Dependencies of clib-ng", + "dependencies": ["fmt", "directxtk", "rapidcsv", "spdlog"] + } + }, + "default-features": ["commonlibsse-ng"], "dependencies": [ "bshoshany-thread-pool", + "clib-util", "cppwinrt", - "fmt", - "directxtk", - "rapidcsv", - "spdlog", - "magic-enum", - "xbyak", - "catch2", - "magic-enum", - "nlohmann-json", - "pystring", "directxtex", + "eastl", + "efsw", { "name": "imgui", - "features": ["dx11-binding", "win32-binding", "docking-experimental"], - "version>=": "1.88" + "features": ["dx11-binding", "win32-binding", "docking-experimental"] }, - "eastl", - "clib-util", + "magic-enum", + "magic-enum", + "nlohmann-json", + "pystring", + "tracy", "unordered-dense", - "efsw", - { - "name": "tracy", - "version>=": "0.11.0" - } + "xbyak" ], "overrides": [ { "name": "bshoshany-thread-pool", - "version-string": "3.5.0" + "version": "3.5.0" + }, + { + "name": "imgui", + "version": "1.90" + }, + { + "name": "tracy", + "version": "0.11.0" } ], - "builtin-baseline": "83972272512ce4ede5fc3b2ba98f6468b179f192" + "builtin-baseline": "1dc5ee30eb1032221d29f281f4a94b73f06b4284" } From 4748912a2a232a9eec40b72f088827ef7ae3129c Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Fri, 2 Aug 2024 13:57:25 +0100 Subject: [PATCH 6/9] chore: update to dev --- src/Features/ScreenSpaceGI.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Features/ScreenSpaceGI.cpp b/src/Features/ScreenSpaceGI.cpp index c3a98787a..4c989d684 100644 --- a/src/Features/ScreenSpaceGI.cpp +++ b/src/Features/ScreenSpaceGI.cpp @@ -797,9 +797,8 @@ void ScreenSpaceGI::DrawSSGI(Texture2D* srcPrevAmbient) // blur if (settings.EnableBlur) { for (uint i = 0; i < settings.BlurPasses; i++) { - TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSGI - Blur"); - if (doSpecular) { + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSGI - Specular Blur"); resetViews(); srvs.at(0) = texGISpecular[inputGITexIdx]->srv.get(); srvs.at(1) = nullptr; @@ -815,6 +814,8 @@ void ScreenSpaceGI::DrawSSGI(Texture2D* srcPrevAmbient) context->Dispatch((internalRes[0] + 7u) >> 3, (internalRes[1] + 7u) >> 3, 1); } + TracyD3D11Zone(State::GetSingleton()->tracyCtx, "SSGI - Diffuse Blur"); + resetViews(); srvs.at(0) = texGI[inputGITexIdx]->srv.get(); srvs.at(1) = texAccumFrames[lastFrameAccumTexIdx]->srv.get(); From 323aa438d8eb08aceff7d901905b683bf09e7414 Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Sun, 4 Aug 2024 21:18:26 +0100 Subject: [PATCH 7/9] Update CMakePresets.json --- CMakePresets.json | 82 ++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 58 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 27998958b..9b960271d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,20 +12,14 @@ "cacheVariables": { "SKSE_SUPPORT_XBYAK": "ON" }, - "binaryDir": "${sourceDir}/build" + "binaryDir": "${sourceDir}/build/${presetName}" }, { "name": "vcpkg", "hidden": true, "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": { - "type": "STRING", - "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - }, - "VCPKG_OVERLAY_PORTS": { - "type": "STRING", - "value": "${sourceDir}/cmake/ports/" - }, + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "VCPKG_OVERLAY_PORTS": "${sourceDir}/cmake/ports/", "VCPKG_TARGET_TRIPLET": "x64-windows-static-md" } }, @@ -53,12 +47,10 @@ } }, { - "name": "AE", + "name": "skyrim", + "hidden": true, "cacheVariables": { "BUILD_SKYRIM": true, - "ENABLE_SKYRIM_AE": "ON", - "ENABLE_SKYRIM_SE": "OFF", - "ENABLE_SKYRIM_VR": "OFF", "BUILD_TESTS": "OFF" }, "inherits": [ @@ -68,85 +60,59 @@ "msvc" ] }, + { + "name": "AE", + "cacheVariables": { + "ENABLE_SKYRIM_AE": "ON", + "ENABLE_SKYRIM_SE": "OFF", + "ENABLE_SKYRIM_VR": "OFF" + }, + "inherits": "skyrim" + }, { "name": "SE", "cacheVariables": { - "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "OFF", "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "OFF", - "BUILD_TESTS": "OFF" + "ENABLE_SKYRIM_VR": "OFF" }, - "inherits": [ - "common", - "vcpkg", - "win64", - "msvc" - ] + "inherits": "skyrim" }, { "name": "VR", "cacheVariables": { - "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "OFF", "ENABLE_SKYRIM_SE": "OFF", - "ENABLE_SKYRIM_VR": "ON", - "BUILD_TESTS": "OFF" + "ENABLE_SKYRIM_VR": "ON" }, - "inherits": [ - "common", - "vcpkg", - "win64", - "msvc" - ] + "inherits": "skyrim" }, { "name": "ALL", "cacheVariables": { - "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "ON", "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "ON", - "BUILD_TESTS": "OFF" + "ENABLE_SKYRIM_VR": "ON" }, - "inherits": [ - "common", - "vcpkg", - "win64", - "msvc" - ] + "inherits": "skyrim" }, { "name": "PRE-AE", "cacheVariables": { - "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "OFF", "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "ON", - "BUILD_TESTS": "OFF" + "ENABLE_SKYRIM_VR": "ON" }, - "inherits": [ - "common", - "vcpkg", - "win64", - "msvc" - ] + "inherits": "skyrim" }, { "name": "FLATRIM", "cacheVariables": { - "BUILD_SKYRIM": true, "ENABLE_SKYRIM_AE": "ON", "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "OFF", - "BUILD_TESTS": "OFF" + "ENABLE_SKYRIM_VR": "OFF" }, - "inherits": [ - "common", - "vcpkg", - "win64", - "msvc" - ] + "inherits": "skyrim" } ] } \ No newline at end of file From 1a3214bca8084f63a0915517a81417690d640274 Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Sun, 4 Aug 2024 21:40:28 +0100 Subject: [PATCH 8/9] build: add `ALL-TRACY` preset Co-Authored-By: Flayan <964655+flayan@users.noreply.github.com> --- CMakePresets.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 9b960271d..81e3af446 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -113,6 +113,13 @@ "ENABLE_SKYRIM_VR": "OFF" }, "inherits": "skyrim" - } + }, + { + "name": "ALL-TRACY", + "cacheVariables": { + "TRACY_SUPPORT": "ON" + }, + "inherits": "ALL" + } ] } \ No newline at end of file From cc709f6a17bd2ca27d283a582e8ad979c0cc7225 Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Sun, 4 Aug 2024 21:53:06 +0100 Subject: [PATCH 9/9] Update CMakePresets.json Co-Authored-By: Flayan <964655+flayan@users.noreply.github.com> --- CMakePresets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 81e3af446..7dd216b00 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -120,6 +120,6 @@ "TRACY_SUPPORT": "ON" }, "inherits": "ALL" - } + } ] } \ No newline at end of file