Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/Skylighting/Shaders/Features/Skylighting.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Info]
Version = 1-2-4
Version = 1-3-0

[Nexus]
nexusmodid = 139352
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Info]
Version = 1-0-2
Version = 1-1-0

[Nexus]
nexusmodid = 157076
Expand Down
12 changes: 3 additions & 9 deletions src/Deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ void Deferred::ReflectionsPrepasses()

globals::game::stateUpdateFlags->set(RE::BSGraphics::ShaderFlags::DIRTY_RENDERTARGET); // Run OMSetRenderTargets again

Feature::ForEachLoadedFeature("ReflectionsPrepass", [](Feature* feature) {
feature->ReflectionsPrepass();
});
Feature::ForEachLoadedFeature("ReflectionsPrepass", [](Feature* feature) { feature->ReflectionsPrepass(); }, true);
}

void Deferred::EarlyPrepasses()
Expand All @@ -236,9 +234,7 @@ void Deferred::EarlyPrepasses()
// Shadow maps have just been rendered — upload BSShadowDirectionalLight data to t98.
CopyShadowLightData();

Feature::ForEachLoadedFeature("EarlyPrepass", [](Feature* feature) {
feature->EarlyPrepass();
});
Feature::ForEachLoadedFeature("EarlyPrepass", [](Feature* feature) { feature->EarlyPrepass(); }, true);
}

void Deferred::PrepassPasses()
Expand All @@ -255,9 +251,7 @@ void Deferred::PrepassPasses()
context->OMSetRenderTargets(0, nullptr, nullptr); // Unbind all bound render targets

globals::truePBR->PrePass();
Feature::ForEachLoadedFeature("Prepass", [](Feature* feature) {
feature->Prepass();
});
Feature::ForEachLoadedFeature("Prepass", [](Feature* feature) { feature->Prepass(); }, true);
}

void Deferred::StartDeferred()
Expand Down
20 changes: 15 additions & 5 deletions src/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "FeatureVersions.h"
#ifdef TRACY_ENABLE
# include <Tracy/Tracy.hpp>
# include <Tracy/TracyD3D11.hpp>
#endif

struct Feature
Expand Down Expand Up @@ -213,19 +214,28 @@ struct Feature
* @param methodName Name of the method being called (used for Tracy zone naming)
* @param callback Callable that receives (Feature*) and performs the operation
*/
// Called once from State after TracyD3D11Context is created so ForEachLoadedFeature
// can emit GPU timer zones without pulling in State headers here.
#ifdef TRACY_ENABLE
inline static TracyD3D11Ctx s_tracyCtx = nullptr;
static void SetTracyCtx(TracyD3D11Ctx ctx) noexcept { s_tracyCtx = ctx; }
#endif

template <typename Func>
static inline void ForEachLoadedFeature(std::string_view methodName, Func&& callback)
static inline void ForEachLoadedFeature(std::string_view methodName, Func&& callback, bool emitGpuZone = false)
{
for (auto* feature : GetFeatureList()) {
if (feature->loaded) {
#ifdef TRACY_ENABLE
{
// ZoneTransientN allocates the source location dynamically so the
// runtime string becomes the zone's actual name in Tracy, not just
// a per-instance annotation on a static "ForEachLoadedFeature" zone.
const auto zoneName = std::format("{}::{}", feature->GetShortName(), methodName);
ZoneTransientN(___tracy_feature_zone, zoneName.c_str(), true);
callback(feature);
if (emitGpuZone) {
TracyD3D11ZoneTransientS(s_tracyCtx, ___tracy_d3d11_feature_zone, zoneName.c_str(), 0, s_tracyCtx != nullptr);
callback(feature);
} else {
callback(feature);
}
}
#else
callback(feature);
Expand Down
6 changes: 0 additions & 6 deletions src/Features/IBL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,10 @@ void IBL::ReflectionsPrepass()

void IBL::Prepass()
{
ZoneScoped;
TracyD3D11Zone(globals::state->tracyCtx, "IBL");

if (settings.DisableInInteriors && Util::IsInterior())
return;

auto context = globals::d3d::context;
auto state = globals::state;

auto& dynamicCubemaps = globals::features::dynamicCubemaps;

Expand All @@ -218,7 +214,6 @@ void IBL::Prepass()
context->PSSetShaderResources(76, 2, views);
}

state->BeginPerfEvent("IBL");
std::array<ID3D11ShaderResourceView*, 1> srvs = { (dynamicCubemaps.loaded && envTexture) ? envTexture->srv.get() : nullptr };
std::array<ID3D11UnorderedAccessView*, 1> uavs = { envIBLTexture->uav.get() };
std::array<ID3D11SamplerState*, 1> samplers = { Deferred::GetSingleton()->linearSampler };
Expand Down Expand Up @@ -261,7 +256,6 @@ void IBL::Prepass()
context->CSSetUnorderedAccessViews(0, (uint)uavs.size(), uavs.data(), nullptr);
context->CSSetShader(nullptr, nullptr, 0);
}
state->EndPerfEvent();

// Set PS shader resource
{
Expand Down
2 changes: 1 addition & 1 deletion src/Features/ScreenSpaceShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ ID3D11ComputeShader* ScreenSpaceShadows::GetComputeRaymarchRight()

void ScreenSpaceShadows::DrawShadows()
{
ZoneScoped;
ZoneScopedS(8);
auto state = globals::state;
TracyD3D11Zone(state->tracyCtx, "Screen Space Shadows");

Expand Down
13 changes: 10 additions & 3 deletions src/Features/Skylighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ void Skylighting::SetViewFrustumVR::thunk(RE::NiCamera* a_camera, RE::NiFrustum*

void Skylighting::RenderOcclusion()
{
ZoneScopedS(8);
auto shaderCache = globals::shaderCache;
auto state = globals::state;
auto renderer = globals::game::renderer;
Expand Down Expand Up @@ -574,8 +575,11 @@ void Skylighting::RenderOcclusion()
PrecipitationShaderDirection = { PrecipitationShaderDirectionF.x, PrecipitationShaderDirectionF.y, PrecipitationShaderDirectionF.z };

static REL::Relocation<void(RE::Precipitation*, RE::NiPointer<RE::NiCamera>)> _computeProjection{ REL::RelocationID(25643, 26185) };
_computeProjection(precip, precip->occlusionData.camera);
precip->SetupMask();
{
ZoneScopedN("Skylighting - Setup Projection");
_computeProjection(precip, precip->occlusionData.camera);
precip->SetupMask();
}

BSParticleShaderRainEmitter* rain = new BSParticleShaderRainEmitter;
{
Expand All @@ -596,7 +600,10 @@ void Skylighting::RenderOcclusion()

precipitation = precipitationCopy;

_computeProjection(precip, precip->occlusionData.camera);
{
ZoneScopedN("Skylighting - Restore Projection");
_computeProjection(precip, precip->occlusionData.camera);
}

state->EndPerfEvent();
}
Expand Down
12 changes: 9 additions & 3 deletions src/Features/TerrainBlending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ void TerrainBlending::ClearShaderCache()

void TerrainBlending::Hooks::Main_RenderDepth::thunk(bool a1, bool a2)
{
ZoneScoped;
ZoneScopedS(8);

auto& singleton = globals::features::terrainBlending;
auto shaderCache = globals::shaderCache;
Expand Down Expand Up @@ -859,7 +859,10 @@ void TerrainBlending::Hooks::Main_RenderDepth::thunk(bool a1, bool a2)
singleton.renderDepth = true;
singleton.ResetDepth();

func(a1, a2);
{
ZoneScopedN("Terrain Depth - Game Render");
func(a1, a2);
}

singleton.renderDepth = false;

Expand All @@ -873,7 +876,10 @@ void TerrainBlending::Hooks::Main_RenderDepth::thunk(bool a1, bool a2)
mainDepth.depthSRV = singleton.depthSRVBackup;
zPrepassCopy.depthSRV = singleton.prepassSRVBackup;

func(a1, a2);
{
ZoneScopedN("Terrain Depth - Game Render");
func(a1, a2);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ void State::SetupResources()
featureLevel = globals::d3d::device->GetFeatureLevel();

tracyCtx = TracyD3D11Context(globals::d3d::device, globals::d3d::context);
#ifdef TRACY_ENABLE
Feature::SetTracyCtx(tracyCtx);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
#endif
}

void State::ModifyShaderLookup(const RE::BSShader& a_shader, uint& a_vertexDescriptor, uint& a_pixelDescriptor, bool a_forceDeferred)
Expand Down
Loading