From 53e0a2cb35ca1fd802502a4693c5a36402782ebc Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sun, 15 Jun 2025 16:48:36 -0700 Subject: [PATCH 1/6] chore: trigger cpp validation --- src/XSEPlugin.cpp | 191 ---------------------------------------------- 1 file changed, 191 deletions(-) diff --git a/src/XSEPlugin.cpp b/src/XSEPlugin.cpp index 1484e04e12..e69de29bb2 100644 --- a/src/XSEPlugin.cpp +++ b/src/XSEPlugin.cpp @@ -1,191 +0,0 @@ - -#include "DX12SwapChain.h" -#include "Deferred.h" -#include "FrameAnnotations.h" -#include "Globals.h" -#include "Hooks.h" -#include "Menu.h" -#include "ShaderCache.h" -#include "State.h" -#include "TruePBR.h" -#include "Upscaling.h" - -#include "ENB/ENBSeriesAPI.h" - -#define DLLEXPORT __declspec(dllexport) - -std::list errors; - -bool Load(); - -void InitializeLog([[maybe_unused]] spdlog::level::level_enum a_level = spdlog::level::info) -{ -#ifndef NDEBUG - auto sink = std::make_shared(); -#else - auto path = logger::log_directory(); - if (!path) { - util::report_and_fail("Failed to find standard logging directory"sv); - } - - *path /= std::format("{}.log"sv, Plugin::NAME); - auto sink = std::make_shared(path->string(), true); -#endif - -#ifndef NDEBUG - const auto level = spdlog::level::trace; -#else - const auto level = a_level; -#endif - - auto log = std::make_shared("global log"s, std::move(sink)); - log->set_level(level); - log->flush_on(spdlog::level::info); - - spdlog::set_default_logger(std::move(log)); - spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%l] [%t] [%s:%#] %v"); -} - -extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface* a_skse) -{ -#ifndef NDEBUG - while (!REX::W32::IsDebuggerPresent()) {}; -#endif - InitializeLog(); - logger::info("Loaded {} {}", Plugin::NAME, Plugin::VERSION.string()); - SKSE::Init(a_skse); - return Load(); -} - -extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []() noexcept { - SKSE::PluginVersionData v; - v.PluginName(Plugin::NAME.data()); - v.PluginVersion(Plugin::VERSION); - v.UsesAddressLibrary(); - v.UsesNoStructs(); - return v; -}(); - -extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Query(const SKSE::QueryInterface*, SKSE::PluginInfo* pluginInfo) -{ - pluginInfo->name = SKSEPlugin_Version.pluginName; - pluginInfo->infoVersion = SKSE::PluginInfo::kVersion; - pluginInfo->version = SKSEPlugin_Version.pluginVersion; - return true; -} - -void MessageHandler(SKSE::MessagingInterface::Message* message) -{ - switch (message->type) { - case SKSE::MessagingInterface::kPostPostLoad: - { - if (errors.empty()) { - auto state = globals::state; - state->PostPostLoad(); // state should load first so basic information is populated - Deferred::Hooks::Install(); - globals::truePBR->PostPostLoad(); - Upscaling::InstallHooks(); - Hooks::Install(); - EngineFix::InstallOnPostPostLoadFixes(); - FrameAnnotations::OnPostPostLoad(); - - auto shaderCache = globals::shaderCache; - - shaderCache->ValidateDiskCache(); - - if (shaderCache->UseFileWatcher()) - shaderCache->StartFileWatcher(); - - for (auto* feature : Feature::GetFeatureList()) { - if (feature->loaded) { - feature->PostPostLoad(); - } - } - } - - break; - } - case SKSE::MessagingInterface::kDataLoaded: - { - for (auto it = errors.begin(); it != errors.end(); ++it) { - auto& errorMessage = *it; - RE::DebugMessageBox(std::format("Community Shaders\n{}, will disable all hooks and features", errorMessage).c_str()); - } - - if (errors.empty()) { - globals::OnDataLoaded(); - EngineFix::InstallOnDataLoadedFixes(); - FrameAnnotations::OnDataLoaded(); - - auto shaderCache = globals::shaderCache; - shaderCache->menuLoaded = true; - while (shaderCache->IsCompiling() && !shaderCache->backgroundCompilation) { - std::this_thread::sleep_for(100ms); - } - - if (shaderCache->IsDiskCache()) { - shaderCache->WriteDiskCacheInfo(); - } - - if (!REL::Module::IsVR()) { - RE::GetINISetting("bEnableImprovedSnow:Display")->data.b = false; - RE::GetINISetting("bIBLFEnable:Display")->data.b = false; - } - - globals::truePBR->DataLoaded(); - for (auto* feature : Feature::GetFeatureList()) { - if (feature->loaded) { - feature->DataLoaded(); - } - } - } - - break; - } - } -} - -bool Load() -{ - if (ENB_API::RequestENBAPI()) { - logger::info("ENB detected, disabling all hooks and features"); - return true; - } - - if (REL::Module::IsVR()) { - REL::IDDatabase::get().IsVRAddressLibraryAtLeastVersion("0.178.0", true); - } - - auto privateProfileRedirectorVersion = Util::GetDllVersion(L"Data/SKSE/Plugins/PrivateProfileRedirector.dll"); - if (privateProfileRedirectorVersion.has_value() && privateProfileRedirectorVersion.value().compare(REL::Version(0, 6, 2)) == std::strong_ordering::less) { - stl::report_and_fail("Old version of PrivateProfileRedirector detected, 0.6.2+ required if using it."sv); - } - - auto messaging = SKSE::GetMessagingInterface(); - messaging->RegisterListener("SKSE", MessageHandler); - - globals::OnInit(); - globals::ReInit(); - - auto state = globals::state; - state->Load(); - auto log = spdlog::default_logger(); - log->set_level(state->GetLogLevel()); - - const std::array dlls = { - L"Data/SKSE/Plugins/ShaderTools.dll", - L"Data/SKSE/Plugins/SSEShaderTools.dll" - }; - - for (const auto dll : dlls) { - if (LoadLibrary(dll)) { - auto errorMessage = std::format("Incompatible DLL {} detected", stl::utf16_to_utf8(dll).value_or(""s)); - logger::error("{}", errorMessage); - errors.push_back(errorMessage); - } - } - - if (errors.empty()) - Hooks::InstallD3DHooks(); - return true; -} \ No newline at end of file From ca42871da120b41a67e921d5f92d3ae5374765dc Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sun, 15 Jun 2025 16:58:48 -0700 Subject: [PATCH 2/6] revert: "chore: trigger cpp validation" This reverts commit dafb4b916afb309547603ebc28d6803ba9f5ef54. --- src/XSEPlugin.cpp | 191 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) diff --git a/src/XSEPlugin.cpp b/src/XSEPlugin.cpp index e69de29bb2..1484e04e12 100644 --- a/src/XSEPlugin.cpp +++ b/src/XSEPlugin.cpp @@ -0,0 +1,191 @@ + +#include "DX12SwapChain.h" +#include "Deferred.h" +#include "FrameAnnotations.h" +#include "Globals.h" +#include "Hooks.h" +#include "Menu.h" +#include "ShaderCache.h" +#include "State.h" +#include "TruePBR.h" +#include "Upscaling.h" + +#include "ENB/ENBSeriesAPI.h" + +#define DLLEXPORT __declspec(dllexport) + +std::list errors; + +bool Load(); + +void InitializeLog([[maybe_unused]] spdlog::level::level_enum a_level = spdlog::level::info) +{ +#ifndef NDEBUG + auto sink = std::make_shared(); +#else + auto path = logger::log_directory(); + if (!path) { + util::report_and_fail("Failed to find standard logging directory"sv); + } + + *path /= std::format("{}.log"sv, Plugin::NAME); + auto sink = std::make_shared(path->string(), true); +#endif + +#ifndef NDEBUG + const auto level = spdlog::level::trace; +#else + const auto level = a_level; +#endif + + auto log = std::make_shared("global log"s, std::move(sink)); + log->set_level(level); + log->flush_on(spdlog::level::info); + + spdlog::set_default_logger(std::move(log)); + spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%l] [%t] [%s:%#] %v"); +} + +extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface* a_skse) +{ +#ifndef NDEBUG + while (!REX::W32::IsDebuggerPresent()) {}; +#endif + InitializeLog(); + logger::info("Loaded {} {}", Plugin::NAME, Plugin::VERSION.string()); + SKSE::Init(a_skse); + return Load(); +} + +extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []() noexcept { + SKSE::PluginVersionData v; + v.PluginName(Plugin::NAME.data()); + v.PluginVersion(Plugin::VERSION); + v.UsesAddressLibrary(); + v.UsesNoStructs(); + return v; +}(); + +extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Query(const SKSE::QueryInterface*, SKSE::PluginInfo* pluginInfo) +{ + pluginInfo->name = SKSEPlugin_Version.pluginName; + pluginInfo->infoVersion = SKSE::PluginInfo::kVersion; + pluginInfo->version = SKSEPlugin_Version.pluginVersion; + return true; +} + +void MessageHandler(SKSE::MessagingInterface::Message* message) +{ + switch (message->type) { + case SKSE::MessagingInterface::kPostPostLoad: + { + if (errors.empty()) { + auto state = globals::state; + state->PostPostLoad(); // state should load first so basic information is populated + Deferred::Hooks::Install(); + globals::truePBR->PostPostLoad(); + Upscaling::InstallHooks(); + Hooks::Install(); + EngineFix::InstallOnPostPostLoadFixes(); + FrameAnnotations::OnPostPostLoad(); + + auto shaderCache = globals::shaderCache; + + shaderCache->ValidateDiskCache(); + + if (shaderCache->UseFileWatcher()) + shaderCache->StartFileWatcher(); + + for (auto* feature : Feature::GetFeatureList()) { + if (feature->loaded) { + feature->PostPostLoad(); + } + } + } + + break; + } + case SKSE::MessagingInterface::kDataLoaded: + { + for (auto it = errors.begin(); it != errors.end(); ++it) { + auto& errorMessage = *it; + RE::DebugMessageBox(std::format("Community Shaders\n{}, will disable all hooks and features", errorMessage).c_str()); + } + + if (errors.empty()) { + globals::OnDataLoaded(); + EngineFix::InstallOnDataLoadedFixes(); + FrameAnnotations::OnDataLoaded(); + + auto shaderCache = globals::shaderCache; + shaderCache->menuLoaded = true; + while (shaderCache->IsCompiling() && !shaderCache->backgroundCompilation) { + std::this_thread::sleep_for(100ms); + } + + if (shaderCache->IsDiskCache()) { + shaderCache->WriteDiskCacheInfo(); + } + + if (!REL::Module::IsVR()) { + RE::GetINISetting("bEnableImprovedSnow:Display")->data.b = false; + RE::GetINISetting("bIBLFEnable:Display")->data.b = false; + } + + globals::truePBR->DataLoaded(); + for (auto* feature : Feature::GetFeatureList()) { + if (feature->loaded) { + feature->DataLoaded(); + } + } + } + + break; + } + } +} + +bool Load() +{ + if (ENB_API::RequestENBAPI()) { + logger::info("ENB detected, disabling all hooks and features"); + return true; + } + + if (REL::Module::IsVR()) { + REL::IDDatabase::get().IsVRAddressLibraryAtLeastVersion("0.178.0", true); + } + + auto privateProfileRedirectorVersion = Util::GetDllVersion(L"Data/SKSE/Plugins/PrivateProfileRedirector.dll"); + if (privateProfileRedirectorVersion.has_value() && privateProfileRedirectorVersion.value().compare(REL::Version(0, 6, 2)) == std::strong_ordering::less) { + stl::report_and_fail("Old version of PrivateProfileRedirector detected, 0.6.2+ required if using it."sv); + } + + auto messaging = SKSE::GetMessagingInterface(); + messaging->RegisterListener("SKSE", MessageHandler); + + globals::OnInit(); + globals::ReInit(); + + auto state = globals::state; + state->Load(); + auto log = spdlog::default_logger(); + log->set_level(state->GetLogLevel()); + + const std::array dlls = { + L"Data/SKSE/Plugins/ShaderTools.dll", + L"Data/SKSE/Plugins/SSEShaderTools.dll" + }; + + for (const auto dll : dlls) { + if (LoadLibrary(dll)) { + auto errorMessage = std::format("Incompatible DLL {} detected", stl::utf16_to_utf8(dll).value_or(""s)); + logger::error("{}", errorMessage); + errors.push_back(errorMessage); + } + } + + if (errors.empty()) + Hooks::InstallD3DHooks(); + return true; +} \ No newline at end of file From 2210ac7cffa7754aa970baa8484c776b5dc79244 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sun, 15 Jun 2025 17:11:21 -0700 Subject: [PATCH 3/6] ci: switch to powershell commands --- .github/workflows/build.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e5d889d2d6..6af87caf2d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -160,16 +160,20 @@ jobs: - name: Extract version from CMake id: get_version - shell: bash + shell: pwsh run: | - if [ "${{ steps.check-cpp.outputs.skip }}" == "true" ]; then + if ("${{ steps.check-cpp.outputs.skip }}" -eq "true") { # When skipping build, extract version from CMakeLists.txt - VERSION=$(grep 'project(.*VERSION' CMakeLists.txt | sed -E 's/.*VERSION ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') - else + $content = Get-Content CMakeLists.txt + $versionLine = $content | Select-String -Pattern 'project\(.*VERSION' + $version = $versionLine -replace '.*VERSION ([0-9]+\.[0-9]+\.[0-9]+).*', '$1' + } else { # When building, extract version from CMakeCache.txt - VERSION=$(grep 'CMAKE_PROJECT_VERSION:STATIC' build/ALL/CMakeCache.txt | cut -d= -f2) - fi - echo "version=$VERSION" >> $GITHUB_OUTPUT + $content = Get-Content build/ALL/CMakeCache.txt + $versionLine = $content | Select-String -Pattern 'CMAKE_PROJECT_VERSION:STATIC' + $version = $versionLine -replace '.*=([0-9]+\.[0-9]+\.[0-9]+).*', '$1' + } + echo "version=$version" >> $env:GITHUB_OUTPUT - name: Upload dist artifacts if: success() && steps.check-cpp.outputs.skip != 'true' From 2adaa038c4fcc00f2561ccae3ae4aab1a707cc11 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Sun, 15 Jun 2025 19:42:24 -0700 Subject: [PATCH 4/6] ci: exit early if version not found --- .github/workflows/build.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6af87caf2d..10c6de0a53 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -173,6 +173,9 @@ jobs: $versionLine = $content | Select-String -Pattern 'CMAKE_PROJECT_VERSION:STATIC' $version = $versionLine -replace '.*=([0-9]+\.[0-9]+\.[0-9]+).*', '$1' } + if (-not $version -or $version -eq "") { + Write-Error "Version extraction failed: no version found" -ErrorAction Stop + } echo "version=$version" >> $env:GITHUB_OUTPUT - name: Upload dist artifacts From c12b65a54eb3c01f1ae18b1510ff3805e0169dfb Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Sun, 15 Jun 2025 20:52:59 -0700 Subject: [PATCH 5/6] ci: update regex to pull from CmakeLists.txt --- .github/workflows/build.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 10c6de0a53..c533546c7e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -157,26 +157,32 @@ jobs: with: configurePreset: ALL buildPreset: ALL - - name: Extract version from CMake id: get_version shell: pwsh run: | if ("${{ steps.check-cpp.outputs.skip }}" -eq "true") { # When skipping build, extract version from CMakeLists.txt - $content = Get-Content CMakeLists.txt - $versionLine = $content | Select-String -Pattern 'project\(.*VERSION' - $version = $versionLine -replace '.*VERSION ([0-9]+\.[0-9]+\.[0-9]+).*', '$1' + $content = Get-Content CMakeLists.txt -Raw + if ($content -match 'project\s*\(\s*\w+\s+VERSION\s+([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $matches[1] + } else { + Write-Error "Version extraction failed: VERSION pattern not found in CMakeLists.txt" -ErrorAction Stop + } } else { # When building, extract version from CMakeCache.txt $content = Get-Content build/ALL/CMakeCache.txt $versionLine = $content | Select-String -Pattern 'CMAKE_PROJECT_VERSION:STATIC' - $version = $versionLine -replace '.*=([0-9]+\.[0-9]+\.[0-9]+).*', '$1' + if ($versionLine) { + $version = ($versionLine -replace '.*=([0-9]+\.[0-9]+\.[0-9]+).*', '$1').ToString() + } else { + Write-Error "Version extraction failed: CMAKE_PROJECT_VERSION not found in CMakeCache.txt" -ErrorAction Stop + } } if (-not $version -or $version -eq "") { Write-Error "Version extraction failed: no version found" -ErrorAction Stop } - echo "version=$version" >> $env:GITHUB_OUTPUT + "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - name: Upload dist artifacts if: success() && steps.check-cpp.outputs.skip != 'true' From d4e383751f66f122d58920006a9d394138f3d68c Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Mon, 16 Jun 2025 22:08:52 -0700 Subject: [PATCH 6/6] ci: always build cpp --- .github/workflows/build.yaml | 40 +++++++----------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c533546c7e..00faa26e8c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -120,29 +120,14 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} submodules: recursive - - name: Check if C++ build needed - id: check-cpp - run: | - if [ "${{ needs.check-changes.outputs.should-build }}" != "true" ]; then - echo "No C++ changes detected, skipping build steps" - echo "skip=true" >> $GITHUB_OUTPUT - else - echo "C++ changes detected, proceeding with build" - echo "skip=false" >> $GITHUB_OUTPUT - fi - shell: bash - - uses: ilammy/msvc-dev-cmd@v1.10.0 - if: steps.check-cpp.outputs.skip != 'true' - name: Setup vcpkg - if: steps.check-cpp.outputs.skip != 'true' uses: lukka/run-vcpkg@v11.5 with: vcpkgJsonGlob: vcpkg.json - name: Cache CMake build output - if: steps.check-cpp.outputs.skip != 'true' uses: actions/cache@v4 with: path: build/ALL @@ -152,32 +137,21 @@ jobs: ${{ runner.os }}-cmake- - name: Build using run-cmake - if: steps.check-cpp.outputs.skip != 'true' uses: lukka/run-cmake@v10 with: configurePreset: ALL buildPreset: ALL + - name: Extract version from CMake id: get_version shell: pwsh run: | - if ("${{ steps.check-cpp.outputs.skip }}" -eq "true") { - # When skipping build, extract version from CMakeLists.txt - $content = Get-Content CMakeLists.txt -Raw - if ($content -match 'project\s*\(\s*\w+\s+VERSION\s+([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $matches[1] - } else { - Write-Error "Version extraction failed: VERSION pattern not found in CMakeLists.txt" -ErrorAction Stop - } + $content = Get-Content build/ALL/CMakeCache.txt + $versionLine = $content | Select-String -Pattern 'CMAKE_PROJECT_VERSION:STATIC' + if ($versionLine) { + $version = ($versionLine -replace '.*=([0-9]+\.[0-9]+\.[0-9]+).*', '$1').ToString() } else { - # When building, extract version from CMakeCache.txt - $content = Get-Content build/ALL/CMakeCache.txt - $versionLine = $content | Select-String -Pattern 'CMAKE_PROJECT_VERSION:STATIC' - if ($versionLine) { - $version = ($versionLine -replace '.*=([0-9]+\.[0-9]+\.[0-9]+).*', '$1').ToString() - } else { - Write-Error "Version extraction failed: CMAKE_PROJECT_VERSION not found in CMakeCache.txt" -ErrorAction Stop - } + Write-Error "Version extraction failed: CMAKE_PROJECT_VERSION not found in CMakeCache.txt" -ErrorAction Stop } if (-not $version -or $version -eq "") { Write-Error "Version extraction failed: no version found" -ErrorAction Stop @@ -185,7 +159,7 @@ jobs: "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - name: Upload dist artifacts - if: success() && steps.check-cpp.outputs.skip != 'true' + if: success() uses: actions/upload-artifact@v4 with: name: dist-artifacts