diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 0000000000..945c9b46d6 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/src/Features/Upscaling.cpp b/src/Features/Upscaling.cpp index 6a37d71a81..9de7e51104 100644 --- a/src/Features/Upscaling.cpp +++ b/src/Features/Upscaling.cpp @@ -12,6 +12,27 @@ #include #include +// Extended structure definition for BSImagespaceShaderISTemporalAA +// TODO: Contribute this structure extension to alandtse/CommonLibVR +// This extends RE::ImageSpaceManager::UNK_BSImagespaceShaderISTemporalAA with additional members +namespace +{ + struct ExtendedTemporalAAStruct + { + RE::BSImagespaceShaderISTemporalAA* shader; // 00 - Main TAA shader + RE::BSImagespaceShader* BSImagespaceShaderISTemporalAA_UI; // 08 - TAA for UI elements + RE::BSImagespaceShader* BSImagespaceShaderISTemporalAA_Water; // 10 - TAA for water + bool taaEnabled; // 18 - Global TAA enable flag + std::uint8_t pad19[7]; // 19 - Padding for alignment + std::uint64_t unk20; // 20 - Unknown (needs further RE) + std::uint64_t unk28; // 28 - Unknown (needs further RE) + std::uint64_t unk30; // 30 - Unknown (needs further RE) + bool enableWaterTAA; // 38 - Water TAA enable flag + std::uint8_t pad39[7]; // 39 - Padding to 0x40 + }; + static_assert(sizeof(ExtendedTemporalAAStruct) == 0x40, "ExtendedTemporalAAStruct must be 0x40 bytes"); +} + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( Upscaling::Settings, upscaleMethod, @@ -701,12 +722,15 @@ void Upscaling::ConfigureTAA() auto imageSpaceManager = RE::ImageSpaceManager::GetSingleton(); GET_INSTANCE_MEMBER(BSImagespaceShaderISTemporalAA, imageSpaceManager); + // Cast to extended structure to access enableWaterTAA + // This structure extension should be contributed to CommonLibVR upstream + auto* extendedStruct = reinterpret_cast(BSImagespaceShaderISTemporalAA); + // Disable water TAA when upscaling is enabled - bool* enableWaterTAA = reinterpret_cast(reinterpret_cast(BSImagespaceShaderISTemporalAA) + 0x38LL); - *enableWaterTAA = upscaleMethod == UpscaleMethod::kNONE || upscaleMethod == UpscaleMethod::kTAA; + extendedStruct->enableWaterTAA = upscaleMethod == UpscaleMethod::kNONE || upscaleMethod == UpscaleMethod::kTAA; // Force enable TAA if needed - BSImagespaceShaderISTemporalAA->taaEnabled = upscaleMethod != UpscaleMethod::kNONE; + extendedStruct->taaEnabled = upscaleMethod != UpscaleMethod::kNONE; } void Upscaling::ConfigureUpscaling(RE::BSGraphics::State* a_viewport) @@ -1474,11 +1498,14 @@ void Upscaling::Main_PostProcessing::thunk(RE::ImageSpaceManager* a_this, uint32 auto imageSpaceManager = RE::ImageSpaceManager::GetSingleton(); GET_INSTANCE_MEMBER(BSImagespaceShaderISTemporalAA, imageSpaceManager); - BSImagespaceShaderISTemporalAA->taaEnabled = upscaleMethod == UpscaleMethod::kTAA; + // Cast to extended structure for consistent access pattern + auto* extendedStruct = reinterpret_cast(BSImagespaceShaderISTemporalAA); + + extendedStruct->taaEnabled = upscaleMethod == UpscaleMethod::kTAA; func(a_this, a3, a_target, a_4, a_5); - BSImagespaceShaderISTemporalAA->taaEnabled = false; + extendedStruct->taaEnabled = false; } void Upscaling::SetScissorRect::thunk(RE::BSGraphics::Renderer* This, int a_left, int a_top, int a_right, int a_bottom)