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
4 changes: 2 additions & 2 deletions D3D11Engine/D3D11DeferredRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void D3D11DeferredRenderer::AddGeometryPasses( RenderGraph& graph,
builder.Write( backBufferHandle );

pass.m_executeCallback = [&engine, colorResource, normalsResource, specularResource, reactiveMaskResource, velocityBufferHandle]( const RenderGraph& graph ) -> void {
ZoneScopedN( "DR GBuffer" );
TracyD3D11ZoneCGX( "D3D11DeferredRenderer::G-Buffer Pass" );
const auto& context = engine.GetContext();
context->VSSetShaderResources( 0, 8, s_nullSRVs );
context->PSSetShaderResources( 0, 8, s_nullSRVs );
Expand Down Expand Up @@ -106,7 +106,7 @@ void D3D11DeferredRenderer::AddLightingPasses( RenderGraph& graph,
builder.Write( backBufferHandle );

pass.m_executeCallback = [&engine, &frameLights, colorResource, normalsResource, specularResource]( const RenderGraph& graph ) -> void {
ZoneScopedN( "DR Draw Lighting" );
TracyD3D11ZoneCGX( "D3D11DeferredRenderer::Draw Lighting" );
auto colorTexture = graph.GetPhysicalTexture( colorResource );
auto normalsTexture = graph.GetPhysicalTexture( normalsResource );
auto specularTexture = graph.GetPhysicalTexture( specularResource );
Expand Down
8 changes: 5 additions & 3 deletions D3D11Engine/D3D11ForwardPlusRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void D3D11ForwardPlusRenderer::AddGeometryPasses(
builder.Write( backBufferHandle );

pass.m_executeCallback = [&engine]( const RenderGraph& ) -> void {
ZoneScopedN( "FR Depth Prepass" );
TracyD3D11ZoneCGX( "D3D11ForwardPlusRenderer::Depth Prepass" );
auto& context = engine.GetContext();

// Clear all SRVs to avoid resource hazards
Expand Down Expand Up @@ -78,7 +78,7 @@ void D3D11ForwardPlusRenderer::AddGeometryPasses(
builder.Write( backBufferHandle );

pass.m_executeCallback = [&engine]( const RenderGraph& ) -> void {
ZoneScopedN( "FR Light Culling" );
TracyD3D11ZoneCGX( "D3D11ForwardPlusRenderer::Light Culling" );
// CopyDepthStencil so depth can be read as SRV
engine.CopyDepthStencil();

Expand All @@ -95,7 +95,7 @@ void D3D11ForwardPlusRenderer::AddGeometryPasses(
builder.Write( backBufferHandle );

pass.m_executeCallback = [&engine]( const RenderGraph& ) -> void {
ZoneScopedN( "FR Shadow Maps" );
TracyD3D11ZoneCGX( "D3D11ForwardPlusRenderer::Shadow Maps" );
auto* shadowMaps = engine.GetShadowMaps();
engine.SetDefaultStates();
const auto& settings = Engine::GAPI->GetRendererState().RendererSettings;
Expand Down Expand Up @@ -126,6 +126,7 @@ void D3D11ForwardPlusRenderer::AddGeometryPasses(
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, &engine, shadowMaskResource]( const RenderGraph& graph ) -> void {
TracyD3D11ZoneCGX( "D3D11ForwardPlusRenderer::ShadowMask" );
auto& context = engine.GetContext();
auto* shadowMaps = engine.GetShadowMaps();

Expand Down Expand Up @@ -196,6 +197,7 @@ void D3D11ForwardPlusRenderer::AddGeometryPasses(
}

pass.m_executeCallback = [this, &engine, colorResource, normalsResource, specularResource, reactiveMaskResource, velocityBufferHandle, shadowMaskResource, useScreenSpaceShadowMask]( const RenderGraph& graph ) -> void {
TracyD3D11ZoneCGX( "D3D11ForwardPlusRenderer::Lit Geometry" );
auto& context = engine.GetContext();
auto* shadowMaps = engine.GetShadowMaps();

Expand Down
38 changes: 37 additions & 1 deletion D3D11Engine/D3D11GraphicsEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ XRESULT D3D11GraphicsEngine::OnResize( INT2 newSize ) {
wrl::ComPtr<IDXGISwapChain2> swapChain2;
if ( m_lowlatency && SUCCEEDED( SwapChain.As( &swapChain2 ) ) ) {
frameLatencyWaitableObject = swapChain2->GetFrameLatencyWaitableObject();
ZoneScopedN( "OnResize::frameLatencyWaitableObject" );
WaitForSingleObjectEx( frameLatencyWaitableObject, INFINITE, true );
}
} else {
Expand Down Expand Up @@ -1715,6 +1716,7 @@ void RenderVelocity(D3D11GraphicsEngine* engine,

/** Presents the current frame to the screen */
XRESULT D3D11GraphicsEngine::Present() {
ZoneScoped;
const auto& settings = Engine::GAPI->GetRendererState().RendererSettings;

SetViewport( ViewportInfo( 0, 0, GetBackbufferResolution() ) );
Expand Down Expand Up @@ -1818,6 +1820,7 @@ XRESULT D3D11GraphicsEngine::Present() {
LogWarnBox() << "Device Removed! (Unknown reason)";
}
} else if ( hr == S_OK && frameLatencyWaitableObject ) {
ZoneScopedN( "Present::frameLatencyWaitableObject" );
WaitForSingleObjectEx( frameLatencyWaitableObject, INFINITE, true );
}

Expand Down Expand Up @@ -3837,6 +3840,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( colorResource );

pass.m_executeCallback = [this, colorResource](const RenderGraph& graph)->void {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw Sky" );
// Draw back of the sky if outdoor
GetContext()->OMSetRenderTargets( 1, graph.GetPhysicalTexture( colorResource )->GetRenderTargetView().GetAddressOf(), nullptr );

Expand All @@ -3862,6 +3866,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
if ( !Engine::GAPI->GetRendererState().RendererSettings.DrawParticleEffects ) {
return;
}
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw ParticleFX #1" );
std::vector<zCVob*> decals;
zCCamera::GetCamera()->Activate();
// Camera->Activate breaks viewport
Expand All @@ -3884,6 +3889,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&)-> void {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw Frame AlphaMeshes" );
DrawFrameAlphaMeshes();
};
}
Expand All @@ -3904,6 +3910,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, normalsResource, backBufferHandle](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw HBAO+" );
auto normalsTexture = graph.GetPhysicalTexture(normalsResource);
auto backBuffer = graph.GetPhysicalTexture(backBufferHandle);

Expand All @@ -3920,6 +3927,8 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, normalsResource, backBufferHandle]( const RenderGraph& graph ) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw ASSAO" );

auto normalsTexture = graph.GetPhysicalTexture( normalsResource );
auto backBuffer = graph.GetPhysicalTexture( backBufferHandle );

Expand All @@ -3936,6 +3945,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Read( normalsResource );

pass.m_executeCallback = [this, normalsResource](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw SAO (Compute)" );
auto normalsTexture = graph.GetPhysicalTexture(normalsResource);

PfxRenderer->RenderSAOCompute(
Expand All @@ -3961,6 +3971,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw FrameTransparencyMeshes" );

SetDefaultStates();

Expand All @@ -3978,6 +3989,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw ForestPortals" );

SetDefaultStates();

Expand All @@ -3995,6 +4007,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw FrameTransparencyMeshesWaterfall" );

SetDefaultStates();

Expand All @@ -4011,6 +4024,8 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw Ghosts" );

D3D11ENGINE_RENDER_STAGE oldStage = RenderingStage;
SetRenderingStage( DES_GHOST );
Engine::GAPI->DrawTransparencyVobs();
Expand All @@ -4033,6 +4048,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw Heightfog" );
PfxRenderer->RenderHeightfog();
};
});
Expand All @@ -4045,6 +4061,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw Rain" );
Effects->DrawRain();
};
});
Expand All @@ -4054,6 +4071,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw Rain (CS)" );
Effects->DrawRain_CS();
};
});
Expand All @@ -4079,6 +4097,8 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw ParticleFX #2" );

// Draw unlit decals
// TODO: Only get them once!
std::vector<zCVob*> decals;
Expand All @@ -4104,6 +4124,8 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Read( backBufferHandle );

pass.m_executeCallback = [this, backBufferHandle, &compositionGodRaysSRV](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw GodRays (Compute)" );

Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv;
GetContext()->PSSetShaderResources( 5, 1, srv.GetAddressOf() );

Expand All @@ -4123,6 +4145,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, backBufferHandle, normalsResource](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw GodRays" );
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv;
GetContext()->PSSetShaderResources( 5, 1, srv.GetAddressOf() );

Expand All @@ -4144,6 +4167,8 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {

pass.m_executeCallback = [this, backBufferHandle, compositionSAO, compositionHeightFog,
&compositionGodRaysSRV](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::PostFX Composition" );

auto backBuffer = graph.GetPhysicalTexture(backBufferHandle);

// Copy backbuffer to a temp texture — we need to read it as SRV while writing to RTV
Expand Down Expand Up @@ -4172,6 +4197,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, backBufferHandle](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw DepthOfField" );
auto backbufferResource = graph.GetPhysicalTexture(backBufferHandle);
PfxRenderer->RenderDepthOfField(backbufferResource->GetShaderResView().Get());
};
Expand All @@ -4191,6 +4217,8 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [particleColorHandle, particleDistortionHandle](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw ParticlesSimple" );

Engine::GAPI->ResetRenderStates();
Engine::GAPI->DrawParticlesSimple(
graph.GetPhysicalTexture( particleColorHandle ),
Expand All @@ -4204,6 +4232,8 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw PolyStrips" );

// Calc weapon/effect trail mesh data
Engine::GAPI->CalcPolyStripMeshes();
// Calc lightning flashes mesh data
Expand All @@ -4222,6 +4252,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw Debug Lines" );
LineRenderer->Flush();
LineRenderer->FlushScreenSpace();
};
Expand All @@ -4245,6 +4276,8 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, &rendererState, velocityBufferHandle](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Render TAA" );

auto velocityBufferTex = graph.GetPhysicalTexture( velocityBufferHandle );
PfxRenderer->RenderTAA( rendererState.RendererSettings.DebugSettings.TAA.DepthMotionVectors
? nullptr
Expand All @@ -4260,6 +4293,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, backBufferHandle](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Render HDR" );
auto backbufferTex = graph.GetPhysicalTexture( backBufferHandle );
PfxRenderer->RenderHDR( backbufferTex->GetRenderTargetView().Get(), backbufferTex->GetShaderResView().Get() );
};
Expand All @@ -4274,6 +4308,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, backBufferHandle](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Render SMAA" );
auto backbufferTex = graph.GetPhysicalTexture( backBufferHandle );
PfxRenderer->RenderSMAA(backbufferTex->GetShaderResView().Get());
GetContext()->PSSetSamplers( 0, 1, DefaultSamplerState.GetAddressOf() );
Expand All @@ -4297,6 +4332,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this](const RenderGraph&) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Draw UnderwaterFX" );
DrawUnderwaterEffects();
};
} );
Expand Down Expand Up @@ -4336,6 +4372,7 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
builder.Write( backBufferHandle );

pass.m_executeCallback = [this, &rendererState, backBufferHandle](const RenderGraph& graph) {
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::Sharpen" );
GetContext()->PSSetSamplers( 0, 1, LinearSamplerState.GetAddressOf() );

auto backbufferTex = graph.GetPhysicalTexture( backBufferHandle );
Expand Down Expand Up @@ -8703,7 +8740,6 @@ void D3D11GraphicsEngine::UpdateOcclusion() {
return;
auto _ = RecordGraphicsEvent( GE_NAME( "D3D11GraphicsEngine::UpdateOcclusion" ) );
TracyD3D11ZoneCGX( "D3D11GraphicsEngine::UpdateOcclusion" );
ZoneScopedN( "D3D11GraphicsEngine::UpdateOcclusion" );

// Set up states
Engine::GAPI->GetRendererState().RasterizerState.SetDefault();
Expand Down
1 change: 1 addition & 0 deletions D3D11Engine/D3D11ShadowMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ XRESULT D3D11ShadowMap::DrawWorldLights()
{
auto graphicsEngine = reinterpret_cast<D3D11GraphicsEngine*>(Engine::GraphicsEngine);
auto _ = graphicsEngine->RecordGraphicsEvent( GE_NAME( "DrawWorldLights" ) );
TracyD3D11ZoneCGX( "D3D11ShadowMap::DrawWorldLights");
auto& settings = Engine::GAPI->GetRendererState().RendererSettings;

Engine::GAPI->GetRendererState().BlendState.SetAdditiveBlending();
Expand Down
1 change: 1 addition & 0 deletions D3D11Engine/fpslimiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct FpsLimiter {
if (!m_enabled) {
return;
}
ZoneScopedN("FpsLimiter::Wait");

auto timeNow = GetCounter();
auto frameDuration = timeNow - m_timeStart;
Expand Down
14 changes: 9 additions & 5 deletions D3D11Engine/zCModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,18 @@ class zCModel : public zCVisual {
if ( !nodeList )
return;

transforms->reserve( transforms->size() + nodeList->NumInArray );
for ( int i = 0; i < nodeList->NumInArray; i++ ) {
zCModelNodeInst* node = nodeList->Array[i];
zCModelNodeInst* parent = node->ParentNode;
const auto num = nodeList->NumInArray;
const auto array = nodeList->Array;

transforms->reserve( transforms->size() + num );

for ( int i = 0; i < num; i++ ) {
zCModelNodeInst* node = array[i];
const zCModelNodeInst* parent = node->ParentNode;

// Calculate transform for this node
if ( parent ) {
XMStoreFloat4x4( &node->TrafoObjToCam, XMLoadFloat4x4( &parent->TrafoObjToCam ) * XMLoadFloat4x4( &node->Trafo ) );
XMStoreFloat4x4( &node->TrafoObjToCam, XMMatrixMultiply(XMLoadFloat4x4( &parent->TrafoObjToCam ) , XMLoadFloat4x4( &node->Trafo ) ) );
} else {
node->TrafoObjToCam = node->Trafo;
}
Expand Down
Loading