From 7053db81ca998d1c0d0e8207cfd868ea25063b2f Mon Sep 17 00:00:00 2001 From: FlayaN Date: Fri, 31 Jan 2025 21:11:17 +0100 Subject: [PATCH] refactor: remove "&" from ptrs --- src/Deferred.cpp | 14 +++++++------- src/Features/CloudShadows.cpp | 6 +++--- src/Features/DynamicCubemaps.cpp | 14 +++++++------- src/Features/GrassCollision.cpp | 2 +- src/Features/ScreenSpaceGI.cpp | 4 ++-- src/Features/ScreenSpaceShadows.cpp | 2 +- src/Features/Skylighting.cpp | 6 +++--- src/Features/SubsurfaceScattering.cpp | 2 +- src/Features/TerrainBlending.cpp | 4 ++-- src/Features/TerrainShadows.cpp | 4 ++-- src/Features/WaterEffects.cpp | 6 +++--- src/Features/WetnessEffects.cpp | 2 +- src/Streamline.cpp | 2 +- src/TruePBR.cpp | 2 +- src/Upscaling.cpp | 4 ++-- src/Utils/D3D.cpp | 2 +- 16 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Deferred.cpp b/src/Deferred.cpp index 66fa025b1..296ca8152 100644 --- a/src/Deferred.cpp +++ b/src/Deferred.cpp @@ -29,7 +29,7 @@ struct BlendStates void SetupRenderTarget(RE::RENDER_TARGET target, D3D11_TEXTURE2D_DESC texDesc, D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc, D3D11_RENDER_TARGET_VIEW_DESC rtvDesc, D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc, DXGI_FORMAT format, uint bindFlags) { auto renderer = globals::game::renderer; - auto& device = globals::d3d::device; + auto device = globals::d3d::device; texDesc.BindFlags = bindFlags; texDesc.Format = format; @@ -106,7 +106,7 @@ void Deferred::SetupResources() } { - auto& device = globals::d3d::device; + auto device = globals::d3d::device; D3D11_SAMPLER_DESC samplerDesc = {}; samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; @@ -182,7 +182,7 @@ void Deferred::CopyShadowData() ZoneScoped; TracyD3D11Zone(globals::state->tracyCtx, "CopyShadowData"); - auto& context = globals::d3d::context; + auto context = globals::d3d::context; ID3D11UnorderedAccessView* uavs[1]{ perShadow->uav.get() }; context->CSSetUnorderedAccessViews(0, 1, uavs, nullptr); @@ -299,7 +299,7 @@ void Deferred::StartDeferred() deferredPass = true; { - auto& context = globals::d3d::context; + auto context = globals::d3d::context; static REL::Relocation perFrame{ REL::RelocationID(524768, 411384) }; ID3D11Buffer* buffers[1] = { *perFrame.get() }; @@ -329,7 +329,7 @@ void Deferred::DeferredPasses() TracyD3D11Zone(globals::state->tracyCtx, "Deferred"); auto renderer = globals::game::renderer; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; { static REL::Relocation perFrame{ REL::RelocationID(524768, 411384) }; @@ -502,7 +502,7 @@ void Deferred::EndDeferred() renderTargets[i] = RE::RENDER_TARGET::kNONE; } - auto& context = globals::d3d::context; + auto context = globals::d3d::context; context->OMSetRenderTargets(0, nullptr, nullptr); // Unbind all bound render targets DeferredPasses(); // Perform deferred passes and composite forward buffers @@ -520,7 +520,7 @@ void Deferred::OverrideBlendStates() static std::once_flag setup; std::call_once(setup, [&]() { - auto& device = globals::d3d::device; + auto device = globals::d3d::device; for (int a = 0; a < 7; a++) { for (int b = 0; b < 2; b++) { diff --git a/src/Features/CloudShadows.cpp b/src/Features/CloudShadows.cpp index d3c957752..21d327ff8 100644 --- a/src/Features/CloudShadows.cpp +++ b/src/Features/CloudShadows.cpp @@ -6,7 +6,7 @@ void CloudShadows::CheckResourcesSide(int side) if (!frame_checker[side].IsNewFrame()) return; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; float black[4] = { 0, 0, 0, 0 }; context->ClearRenderTargetView(cubemapCloudOccRTVs[side], black); @@ -73,7 +73,7 @@ void CloudShadows::EarlyPrepass() !globals::game::sky->currentClimate) return; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; ID3D11ShaderResourceView* srv = texCubemapCloudOcc->srv.get(); context->PSSetShaderResources(25, 1, &srv); @@ -83,7 +83,7 @@ void CloudShadows::EarlyPrepass() void CloudShadows::SetupResources() { auto renderer = globals::game::renderer; - auto& device = globals::d3d::device; + auto device = globals::d3d::device; { auto reflections = renderer->GetRendererData().cubemapRenderTargets[RE::RENDER_TARGET_CUBEMAP::kREFLECTIONS]; diff --git a/src/Features/DynamicCubemaps.cpp b/src/Features/DynamicCubemaps.cpp index c3fc6bcc0..fe5e16113 100644 --- a/src/Features/DynamicCubemaps.cpp +++ b/src/Features/DynamicCubemaps.cpp @@ -51,8 +51,8 @@ void DynamicCubemaps::DrawSettings() ImGui::ColorEdit3("Color", reinterpret_cast(&settings.CubemapColor)); ImGui::SliderFloat("Roughness", &settings.CubemapColor.w, 0.0f, 1.0f, "%.2f"); if (ImGui::Button("Export")) { - auto& device = globals::d3d::device; - auto& context = globals::d3d::context; + auto device = globals::d3d::device; + auto context = globals::d3d::context; D3D11_TEXTURE2D_DESC texDesc{}; texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; @@ -295,7 +295,7 @@ ID3D11ComputeShader* DynamicCubemaps::GetComputeShaderSpecularIrradiance() void DynamicCubemaps::UpdateCubemapCapture(bool a_reflections) { auto renderer = globals::game::renderer; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; auto& depth = renderer->GetDepthStencilData().depthStencils[RE::RENDER_TARGETS_DEPTHSTENCIL::kPOST_ZPREPASS_COPY]; auto& main = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGETS::kMAIN]; @@ -367,7 +367,7 @@ void DynamicCubemaps::UpdateCubemapCapture(bool a_reflections) void DynamicCubemaps::Inferrence(bool a_reflections) { auto renderer = globals::game::renderer; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; // Infer local reflection information ID3D11UnorderedAccessView* uav = envInferredTexture->uav.get(); @@ -404,7 +404,7 @@ void DynamicCubemaps::Inferrence(bool a_reflections) void DynamicCubemaps::Irradiance(bool a_reflections) { - auto& context = globals::d3d::context; + auto context = globals::d3d::context; // Copy cubemap to other resources for (uint face = 0; face < 6; face++) { @@ -503,7 +503,7 @@ void DynamicCubemaps::UpdateCubemap() void DynamicCubemaps::PostDeferred() { - auto& context = globals::d3d::context; + auto context = globals::d3d::context; ID3D11ShaderResourceView* views[2] = { (activeReflections ? envReflectionsTexture : envTexture)->srv.get(), envTexture->srv.get() }; context->PSSetShaderResources(30, 2, views); @@ -518,7 +518,7 @@ void DynamicCubemaps::SetupResources() GetComputeShaderSpecularIrradiance(); auto renderer = globals::game::renderer; - auto& device = globals::d3d::device; + auto device = globals::d3d::device; { D3D11_SAMPLER_DESC samplerDesc = {}; diff --git a/src/Features/GrassCollision.cpp b/src/Features/GrassCollision.cpp index 135673d15..c0ead24ea 100644 --- a/src/Features/GrassCollision.cpp +++ b/src/Features/GrassCollision.cpp @@ -179,7 +179,7 @@ void GrassCollision::Update() updatePerFrame = false; } - auto& context = globals::d3d::context; + auto context = globals::d3d::context; static Util::FrameChecker frameChecker; if (frameChecker.IsNewFrame()) { diff --git a/src/Features/ScreenSpaceGI.cpp b/src/Features/ScreenSpaceGI.cpp index 539523a4d..c4144e124 100644 --- a/src/Features/ScreenSpaceGI.cpp +++ b/src/Features/ScreenSpaceGI.cpp @@ -328,7 +328,7 @@ void ScreenSpaceGI::SaveSettings(json& o_json) void ScreenSpaceGI::SetupResources() { auto renderer = globals::game::renderer; - auto& device = globals::d3d::device; + auto device = globals::d3d::device; logger::debug("Creating buffers..."); { @@ -621,7 +621,7 @@ void ScreenSpaceGI::UpdateSB() void ScreenSpaceGI::DrawSSGI(Texture2D* srcPrevAmbient) { - auto& context = globals::d3d::context; + auto context = globals::d3d::context; if (!(settings.Enabled && ShadersOK())) { FLOAT clr[4] = { 0.f, 0.f, 0.f, 0.f }; diff --git a/src/Features/ScreenSpaceShadows.cpp b/src/Features/ScreenSpaceShadows.cpp index b37ac93ec..d48480f00 100644 --- a/src/Features/ScreenSpaceShadows.cpp +++ b/src/Features/ScreenSpaceShadows.cpp @@ -259,7 +259,7 @@ void ScreenSpaceShadows::SetupResources() raymarchCB = new ConstantBuffer(ConstantBufferDesc()); { - auto& device = globals::d3d::device; + auto device = globals::d3d::device; D3D11_SAMPLER_DESC samplerDesc = {}; samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; diff --git a/src/Features/Skylighting.cpp b/src/Features/Skylighting.cpp index 18e77ac82..ec6408de3 100644 --- a/src/Features/Skylighting.cpp +++ b/src/Features/Skylighting.cpp @@ -30,7 +30,7 @@ void Skylighting::RestoreDefaultSettings() void Skylighting::ResetSkylighting() { - auto& context = globals::d3d::context; + auto context = globals::d3d::context; UINT clr[1] = { 0 }; context->ClearUnorderedAccessViewUint(texAccumFramesArray->uav.get(), clr); queuedResetSkylighting = false; @@ -63,7 +63,7 @@ void Skylighting::DrawSettings() void Skylighting::SetupResources() { auto renderer = globals::game::renderer; - auto& device = globals::d3d::device; + auto device = globals::d3d::device; { auto& precipitationOcclusion = renderer->GetDepthStencilData().depthStencils[RE::RENDER_TARGETS_DEPTHSTENCIL::kPRECIPITATION_OCCLUSION_MAP]; @@ -235,7 +235,7 @@ void Skylighting::Prepass() TracyD3D11Zone(globals::state->tracyCtx, "Skylighting - Update Probes"); - auto& context = globals::d3d::context; + auto context = globals::d3d::context; { std::array srvs = { texOcclusion->srv.get() }; diff --git a/src/Features/SubsurfaceScattering.cpp b/src/Features/SubsurfaceScattering.cpp index 39b5bd1ad..6d39869b9 100644 --- a/src/Features/SubsurfaceScattering.cpp +++ b/src/Features/SubsurfaceScattering.cpp @@ -180,7 +180,7 @@ void SubsurfaceScattering::DrawSSS() } auto renderer = globals::game::renderer; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; { ID3D11Buffer* buffer[1] = { blurCB->CB() }; diff --git a/src/Features/TerrainBlending.cpp b/src/Features/TerrainBlending.cpp index 308cedd0b..4bf4a2ed1 100644 --- a/src/Features/TerrainBlending.cpp +++ b/src/Features/TerrainBlending.cpp @@ -34,7 +34,7 @@ ID3D11ComputeShader* TerrainBlending::GetDepthBlendShader() void TerrainBlending::SetupResources() { auto renderer = globals::game::renderer; - auto& device = globals::d3d::device; + auto device = globals::d3d::device; { auto& mainDepth = renderer->GetDepthStencilData().depthStencils[RE::RENDER_TARGETS_DEPTHSTENCIL::kMAIN]; @@ -144,7 +144,7 @@ void TerrainBlending::ResetTerrainDepth() void TerrainBlending::BlendPrepassDepths() { - auto& context = globals::d3d::context; + auto context = globals::d3d::context; context->OMSetRenderTargets(0, nullptr, nullptr); auto dispatchCount = Util::GetScreenDispatchCount(); diff --git a/src/Features/TerrainShadows.cpp b/src/Features/TerrainShadows.cpp index c2911f8c8..6a5f7c543 100644 --- a/src/Features/TerrainShadows.cpp +++ b/src/Features/TerrainShadows.cpp @@ -209,7 +209,7 @@ void TerrainShadows::LoadHeightmap() if (cachedHeightmap && cachedHeightmap->worldspace == worldspace_name) // already cached return; - auto& device = globals::d3d::device; + auto device = globals::d3d::device; logger::debug("Loading height map..."); { @@ -304,7 +304,7 @@ void TerrainShadows::UpdateShadow() constexpr uint updateLength = 128u; constexpr uint logUpdateLength = std::bit_width(128u) - 1; // integer log2, https://stackoverflow.com/questions/994593/how-to-do-an-integer-log2-in-c - auto& context = globals::d3d::context; + auto context = globals::d3d::context; auto accumulator = RE::BSGraphics::BSShaderAccumulator::GetCurrentAccumulator(); auto sunLight = skyrim_cast(accumulator->GetRuntimeData().activeShadowSceneNode->GetRuntimeData().sunLight->light.get()); if (!sunLight) diff --git a/src/Features/WaterEffects.cpp b/src/Features/WaterEffects.cpp index 99733a8a7..32b80d6cc 100644 --- a/src/Features/WaterEffects.cpp +++ b/src/Features/WaterEffects.cpp @@ -4,15 +4,15 @@ void WaterEffects::SetupResources() { - auto& device = globals::d3d::device; - auto& context = globals::d3d::context; + auto device = globals::d3d::device; + auto context = globals::d3d::context; DirectX::CreateDDSTextureFromFile(device, context, L"Data\\Shaders\\WaterEffects\\watercaustics.dds", nullptr, causticsView.put()); } void WaterEffects::Prepass() { - auto& context = globals::d3d::context; + auto context = globals::d3d::context; auto srv = causticsView.get(); context->PSSetShaderResources(65, 1, &srv); } diff --git a/src/Features/WetnessEffects.cpp b/src/Features/WetnessEffects.cpp index 7acec1317..535f40573 100644 --- a/src/Features/WetnessEffects.cpp +++ b/src/Features/WetnessEffects.cpp @@ -266,7 +266,7 @@ void WetnessEffects::Prepass() static auto renderer = globals::game::renderer; static auto& precipOcclusionTexture = renderer->GetDepthStencilData().depthStencils[RE::RENDER_TARGETS_DEPTHSTENCIL::kPRECIPITATION_OCCLUSION_MAP]; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; context->PSSetShaderResources(70, 1, &precipOcclusionTexture.depthSRV); } diff --git a/src/Streamline.cpp b/src/Streamline.cpp index 6a9c48479..b7e8c96c1 100644 --- a/src/Streamline.cpp +++ b/src/Streamline.cpp @@ -343,7 +343,7 @@ void Streamline::CopyResourcesToSharedBuffers() if (!(featureDLSSG && !REL::Module::IsVR()) || settings.frameGenerationMode == sl::DLSSGMode::eOff) return; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; auto renderer = globals::game::renderer; ID3D11RenderTargetView* backupViews[8]; diff --git a/src/TruePBR.cpp b/src/TruePBR.cpp index 4c6012031..62950ff77 100644 --- a/src/TruePBR.cpp +++ b/src/TruePBR.cpp @@ -1407,7 +1407,7 @@ struct BSGrassShader_SetupMaterial { static void thunk(RE::BSShader* shader, RE::BSLightingShaderMaterialBase const* material) { - const auto& state = globals::state; + const auto state = globals::state; const auto technique = static_cast(state->currentPixelDescriptor & 0b1111); const auto& grassPSConstants = ShaderConstants::GrassPS::Get(); diff --git a/src/Upscaling.cpp b/src/Upscaling.cpp index 469ba7abb..7ad738a17 100644 --- a/src/Upscaling.cpp +++ b/src/Upscaling.cpp @@ -234,7 +234,7 @@ void Upscaling::Upscale() auto state = globals::state; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; ID3D11ShaderResourceView* inputTextureSRV; context->PSGetShaderResources(0, 1, &inputTextureSRV); @@ -345,7 +345,7 @@ void Upscaling::SharpenTAA() CheckResources(); auto state = globals::state; - auto& context = globals::d3d::context; + auto context = globals::d3d::context; ID3D11ShaderResourceView* inputTextureSRV; context->PSGetShaderResources(0, 1, &inputTextureSRV); diff --git a/src/Utils/D3D.cpp b/src/Utils/D3D.cpp index 8c330592c..b449e94c7 100644 --- a/src/Utils/D3D.cpp +++ b/src/Utils/D3D.cpp @@ -124,7 +124,7 @@ namespace Util ID3D11DeviceChild* CompileShader(const wchar_t* FilePath, const std::vector>& Defines, const char* ProgramType, const char* Program) { - auto& device = globals::d3d::device; + auto device = globals::d3d::device; CustomInclude include;