Skip to content
Draft
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
314 changes: 314 additions & 0 deletions Benchmarks/RENDERING_OPTIMIZATIONS.md

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions Benchmarks/cordon_baseline.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
index;stack;name;time_ms
0;0;Frame;62.280
1;1;CRender_Render;61.532
2;2;SKY_RENDER;0.0430
3;2;phase_scene_prepare;0.0072
4;2;DEFER_PART0_SPLIT;0.3963
5;3;dsgraph_render_static;0.3830
6;3;dsgraph_render_dynamic;0.0133
7;2;DEFER_TEST_LIGHT_VIS;0.0000
8;2;DEFER_PART1_SPLIT;0.2194
9;3;dsgraph_render_lods;0.0000
10;3;DetailManager_Render;0.0819
11;3;copy_zbuffer_scope;0.0229
12;3;dsgraph_render_hud;0.0912
13;3;copy_zbuffer_scope_depth;0.0211
14;2;copy_zbuffer;0.0211
15;2;DEFER_WALLMARKS;0.0040
16;3;dsgraph_render_wmarks;0.0031
17;2;DEFER_RAIN;0.0000
18;2;DEFER_SUN;13.271
19;3;render_sun_flush;13.271
20;4;render_sun_cascade_0;0.6175
21;4;render_sun_cascade_1;0.4690
22;4;render_sun_cascade_2;0.2396
23;3;accum_direct_blend;0.0000
24;2;DEFER_SELF_ILLUM;0.0000
25;2;DEFER_LIGHT;0.5745
26;3;SHADOWED_LIGHTS;0.5100
27;3;SPOT_LIGHTS_ACCUM_VOLUMETRIC;0.0604
28;3;POINT_LIGHTS_ACCUM;0.0041
29;2;DEFER_COMBINE;35.594
30;3;CLOUDS_RENDER;0.0246
31;3;combine_1;18.975
32;3;render_forward;0.1155
33;4;dsgraph_render_graph;0.0205
34;5;dsgraph_render_static;0.0174
35;5;dsgraph_render_dynamic;0.0031
36;4;dsgraph_render_sorted;0.0942
37;3;phase_combine_volumetric;0.0676
38;3;render_distort_objects;0.0010
39;4;dsgraph_render_distort;0.0000
40;3;combine_distort;0.0648
41;3;phase_bloom;0.0206
42;3;combine_tonemap;0.0890
43;3;DLSS;0.3947
44;3;CAS;0.0775
45;3;phase_ss_ss;0.2325
46;4;phase_SS_SS_OGSE;0.2300
47;3;PHASE_BLUR;0.1558
48;3;phase_ssfx_bloom;0.0852
49;3;combine_2;0.2482
50;3;RenderFlares;0.0006
51;3;phase_pp;0.0190
Binary file added Benchmarks/cordon_compare.xlsx
Binary file not shown.
51 changes: 51 additions & 0 deletions Benchmarks/cordon_depth_optimization.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
index;stack;name;time_ms
0;0;Frame;64.133
1;1;CRender_Render;63.365
2;2;SKY_RENDER;0.0451
3;2;phase_scene_prepare;0.0061
4;2;DEFER_PART0_SPLIT;0.3994
5;3;dsgraph_render_static;0.3840
6;3;dsgraph_render_dynamic;0.0154
7;2;DEFER_TEST_LIGHT_VIS;0.0000
8;2;DEFER_PART1_SPLIT;0.4424
9;3;dsgraph_render_lods;0.0010
10;3;DetailManager_Render;0.0850
11;3;dsgraph_render_hud;0.3553
12;2;copy_zbuffer;0.0219
13;2;DEFER_WALLMARKS;0.0041
14;3;dsgraph_render_wmarks;0.0031
15;2;DEFER_RAIN;0.0000
16;2;DEFER_SUN;13.076
17;3;render_sun_flush;13.076
18;4;render_sun_cascade_0;0.6226
19;4;render_sun_cascade_1;0.4444
20;4;render_sun_cascade_2;0.2396
21;3;accum_direct_blend;0.0000
22;2;DEFER_SELF_ILLUM;0.0000
23;2;DEFER_LIGHT;0.5704
24;3;SHADOWED_LIGHTS;0.5048
25;3;SPOT_LIGHTS_ACCUM_VOLUMETRIC;0.0614
26;3;POINT_LIGHTS_ACCUM;0.0041
27;2;DEFER_COMBINE;35.389
28;3;CLOUDS_RENDER;0.0256
29;3;combine_1;19.313
30;3;render_forward;0.0227
31;4;dsgraph_render_graph;0.0215
32;5;dsgraph_render_static;0.0154
33;5;dsgraph_render_dynamic;0.0061
34;4;dsgraph_render_sorted;0.0000
35;3;phase_combine_volumetric;0.0737
36;3;render_distort_objects;0.0020
37;4;dsgraph_render_distort;0.0010
38;3;combine_distort;0.0726
39;3;phase_bloom;0.0210
40;3;combine_tonemap;0.0893
41;3;DLSS;0.3995
42;3;CAS;0.0778
43;3;phase_ss_ss;0.2420
44;4;phase_SS_SS_OGSE;0.2397
45;3;PHASE_BLUR;0.1574
46;3;phase_ssfx_bloom;0.0850
47;3;combine_2;0.2473
48;3;RenderFlares;0.0006
49;3;phase_pp;0.0201
53 changes: 53 additions & 0 deletions Benchmarks/cordon_pingpong.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
index;stack;name;time_ms
0;0;Frame;60.795
1;1;CRender_Render;60.037
2;2;SKY_RENDER;0.0440
3;2;phase_scene_prepare;0.0061
4;2;DEFER_PART0_SPLIT;0.3973
5;3;dsgraph_render_static;0.3809
6;3;dsgraph_render_dynamic;0.0164
7;2;DEFER_TEST_LIGHT_VIS;0.0000
8;2;DEFER_PART1_SPLIT;0.1075
9;3;dsgraph_render_lods;0.0020
10;3;DetailManager_Render;0.0829
11;3;dsgraph_render_hud;0.0225
12;2;copy_zbuffer;0.0221
13;2;DEFER_WALLMARKS;0.0049
14;3;dsgraph_render_wmarks;0.0041
15;2;DEFER_RAIN;0.0000
16;2;DEFER_SUN;13.179
17;3;render_sun_flush;13.179
18;4;render_sun_cascade_0;0.6124
19;4;render_sun_cascade_1;0.4690
20;4;render_sun_cascade_2;0.2355
21;3;accum_direct_blend;0.0000
22;2;DEFER_SELF_ILLUM;0.0000
23;2;DEFER_LIGHT;0.5704
24;3;SHADOWED_LIGHTS;0.5059
25;3;SPOT_LIGHTS_ACCUM_VOLUMETRIC;0.0614
26;3;POINT_LIGHTS_ACCUM;0.0031
27;2;DEFER_COMBINE;35.328
28;3;CLOUDS_RENDER;0.0266
29;3;combine_1;18.801
30;3;render_forward;0.1373
31;4;dsgraph_render_graph;0.0195
32;5;dsgraph_render_static;0.0154
33;5;dsgraph_render_dynamic;0.0041
34;4;dsgraph_render_sorted;0.1167
35;3;phase_combine_volumetric;0.0676
36;3;render_distort_objects;0.0010
37;4;dsgraph_render_distort;0.0000
38;3;combine_distort;0.0664
39;3;phase_bloom;0.0211
40;3;combine_tonemap;0.0892
41;3;DLSS;0.3965
42;3;CAS;0.0635
43;3;phase_ss_ss;0.2393
44;4;phase_SS_SS_OGSE;0.2377
45;5;copy_pp_ssss;0.0261
46;3;PHASE_BLUR;0.1553
47;3;phase_ssfx_bloom;0.0881
48;3;combine_2;0.2482
49;4;copy_pp_combine2;0.0264
50;3;RenderFlares;0.0007
51;3;phase_pp;0.0192
51 changes: 51 additions & 0 deletions Benchmarks/cordon_pingpong2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
index;stack;name;time_ms
0;0;Frame;59.238
1;1;CRender_Render;58.491
2;2;SKY_RENDER;0.0440
3;2;phase_scene_prepare;0.0061
4;2;DEFER_PART0_SPLIT;0.4127
5;3;dsgraph_render_static;0.3779
6;3;dsgraph_render_dynamic;0.0348
7;2;DEFER_TEST_LIGHT_VIS;0.0000
8;2;DEFER_PART1_SPLIT;0.1782
9;3;dsgraph_render_lods;0.0000
10;3;DetailManager_Render;0.0778
11;3;dsgraph_render_hud;0.1004
12;2;copy_zbuffer;0.0222
13;2;DEFER_WALLMARKS;0.0038
14;3;dsgraph_render_wmarks;0.0031
15;2;DEFER_RAIN;0.0000
16;2;DEFER_SUN;13.251
17;3;render_sun_flush;13.251
18;4;render_sun_cascade_0;0.6154
19;4;render_sun_cascade_1;0.4731
20;4;render_sun_cascade_2;0.2355
21;3;accum_direct_blend;0.0000
22;2;DEFER_SELF_ILLUM;0.0000
23;2;DEFER_LIGHT;0.5796
24;3;SHADOWED_LIGHTS;0.5151
25;3;SPOT_LIGHTS_ACCUM_VOLUMETRIC;0.0614
26;3;POINT_LIGHTS_ACCUM;0.0031
27;2;DEFER_COMBINE;32.748
28;3;CLOUDS_RENDER;0.0266
29;3;combine_1;17.848
30;3;render_forward;0.0226
31;4;dsgraph_render_graph;0.0205
32;5;dsgraph_render_static;0.0164
33;5;dsgraph_render_dynamic;0.0041
34;4;dsgraph_render_sorted;0.0010
35;3;phase_combine_volumetric;0.0727
36;3;render_distort_objects;0.0020
37;4;dsgraph_render_distort;0.0010
38;3;combine_distort;0.0722
39;3;phase_bloom;0.0204
40;3;combine_tonemap;0.0889
41;3;DLSS;0.3958
42;3;CAS;0.0625
43;3;phase_ss_ss;0.2130
44;4;phase_SS_SS_OGSE;0.2120
45;3;PHASE_BLUR;0.1567
46;3;phase_ssfx_bloom;0.0881
47;3;combine_2;0.2202
48;3;RenderFlares;0.0000
49;3;phase_pp;0.0174
31 changes: 31 additions & 0 deletions Benchmarks/validate_ao_shaders.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
param(
[string]$Fxc = 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/fxc.exe'
)

$ErrorActionPreference = 'Stop'
$repoPath = Split-Path -Parent $PSScriptRoot
$shaderPath = Join-Path $repoPath 'Game/Resources_SoC_1.0006/gamedata/shaders/r3'
$outputPath = Join-Path $repoPath 'ogsr_engine/_TEMP/ao_validation'
New-Item -ItemType Directory -Force -Path $outputPath | Out-Null

$compiledCount = 0
foreach ($mode in @('ssdo', 'gtao')) {
foreach ($quality in 0..3) {
foreach ($shader in @('ogsr_ao', 'ogsr_ao_half', 'combine_1', 'combine_1_ao')) {
$shaderArgs = @('/nologo', '/T', 'ps_5_0', '/E', 'main', '/O1', '/Zpr')
if ($quality -gt 0) { $shaderArgs += @('/D', "SSAO_QUALITY=$quality") }
if ($mode -eq 'gtao') { $shaderArgs += @('/D', 'USE_GTAO=1') }
$shaderArgs += @('/Fo', (Join-Path $outputPath "$shader-$mode-$quality.cso"), (Join-Path $shaderPath "$shader.ps"))
$compilerOutput = & $Fxc @shaderArgs 2>&1
if ($LASTEXITCODE -ne 0) {
throw "Failed: $shader, $mode, quality $quality`n$compilerOutput"
}
$compiledCount++
}
}
}

$compilerOutput = & $Fxc /nologo /T ps_5_0 /E main /O1 /Zpr /Fo (Join-Path $outputPath 'ogsr_ao_resolve.cso') (Join-Path $shaderPath 'ogsr_ao_resolve.ps') 2>&1
if ($LASTEXITCODE -ne 0) { throw "Failed: AO resolve`n$compilerOutput" }
$compiledCount++
Write-Output "PASS: $compiledCount shader variants (SSDO/GTAO, off/low/medium/high, legacy/separate/half and resolve)."
40 changes: 40 additions & 0 deletions Benchmarks/validate_xegtao_shaders.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
param(
[string]$Fxc = 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/fxc.exe'
)

# Optional, user-run compilation check. This does not build the engine or run GPU tests.
$ErrorActionPreference = 'Stop'
$repoPath = Split-Path -Parent $PSScriptRoot
$shaderPath = Join-Path $repoPath 'Game/Resources_SoC_1.0006/gamedata/shaders/r3'

# FXC accepts slash-separated paths that OGSR's VFS cannot resolve. Check the
# runtime convention too, including nested vendor headers, before compiling.
$includeFiles = @(Get-ChildItem -LiteralPath $shaderPath -File -Filter 'ogsr_xegtao*') +
@(Get-ChildItem -LiteralPath (Join-Path $shaderPath 'xegtao') -File | Where-Object Extension -In @('.h', '.hlsli'))
foreach ($includeFile in $includeFiles) {
$includeText = Get-Content -LiteralPath $includeFile.FullName -Raw
foreach ($includeMatch in [regex]::Matches($includeText, '#include\s+"([^"]+)"')) {
if ($includeMatch.Groups[1].Value.Contains('/')) {
throw "OGSR requires backslashes in shader includes: $($includeFile.Name): $($includeMatch.Groups[1].Value)"
}
}
}

$outputPath = Join-Path $repoPath 'ogsr_engine/_TEMP/ao_validation'
New-Item -ItemType Directory -Force -Path $outputPath | Out-Null

$compiledCount = 0
foreach ($quality in 1..3) {
foreach ($shader in @('ogsr_xegtao_prefilter.cs', 'ogsr_xegtao_main.cs', 'ogsr_xegtao_denoise.cs', 'ogsr_xegtao_export.ps', 'combine_1_ao.ps')) {
$target = if ($shader.EndsWith('.cs')) { 'cs_5_0' } else { 'ps_5_0' }
$shaderArgs = @('/nologo', '/T', $target, '/E', 'main', '/O1', '/Zpr', '/I', $shaderPath,
'/D', "SSAO_QUALITY=$quality", '/Fo', (Join-Path $outputPath "$shader-xegtao-$quality.cso"),
(Join-Path $shaderPath $shader))
$compilerOutput = & $Fxc @shaderArgs 2>&1
if ($LASTEXITCODE -ne 0) {
throw "Failed: $shader, quality $quality`n$compilerOutput"
}
$compiledCount++
}
}
Write-Output "PASS: $compiledCount XeGTAO shader variants (three quality levels, compute passes, export and composition)."
35 changes: 35 additions & 0 deletions Build_ReleaseTracy.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@echo off
setlocal

cd /d "%~dp0"

set "CONFIGURATION_GA=ReleaseTracyProfiler"

set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" (
echo vswhere.exe not found. Install VS 2022 with the Desktop C++ workload.
exit /b 1
)

for /f "usebackq delims=" %%i in (`"%VSWHERE%" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do set "MSBUILD=%%i"
if not defined MSBUILD (
echo MSBuild.exe not found.
exit /b 1
)

echo Building Engine.sln Release^|x64 with CONFIGURATION_GA=%CONFIGURATION_GA%
echo Using "%MSBUILD%"
echo.

"%MSBUILD%" Engine.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 /m
set "ERR=%ERRORLEVEL%"

echo.
if %ERR% neq 0 (
echo Build failed. Errorlevel %ERR%.
exit /b %ERR%
)

echo Build succeeded. Output: "%cd%\bin_x64"
echo CONFIGURATION_GA was only set for this script.
exit /b 0
13 changes: 11 additions & 2 deletions Game/Resources_SoC_1.0006/gamedata/shaders/r3/combine.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function element_0(shader, t_base, t_second, t_detail)
shader:begin("stub_screen_space", "combine_1")
local function setup_combine(shader, pixel_shader)
shader:begin("stub_screen_space", pixel_shader)
:fog(false)
:zb(false, false)
:blend(true, blend.invsrcalpha,blend.srcalpha)
Expand All @@ -8,6 +8,7 @@ function element_0(shader, t_base, t_second, t_detail)
shader:dx10texture("s_position", "$user$position")
shader:dx10texture("s_diffuse", "$user$albedo")
shader:dx10texture("s_accumulator", "$user$accum")
shader:dx10texture("s_ao", "$user$ao")
shader:dx10texture("env_s0", "$user$env_s0")
shader:dx10texture("env_s1", "$user$env_s1")
shader:dx10texture("sky_s0", "$user$sky0")
Expand All @@ -21,6 +22,14 @@ function element_0(shader, t_base, t_second, t_detail)
shader:dx10sampler("smp_rtlinear")
end

function element_0(shader, t_base, t_second, t_detail)
setup_combine(shader, "combine_1")
end

function element_4(shader, t_base, t_second, t_detail)
setup_combine(shader, "combine_1_ao")
end

function element_1(shader, t_base, t_second, t_detail)
shader:begin("stub_screen_space", "combine_distort")
:fog(false)
Expand Down
Binary file modified Game/Resources_SoC_1.0006/gamedata/shaders/r3/combine_1.ps
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ function element_0(shader, t_base, t_second, t_detail)
shader:dx10texture("t_current", "$user$postprocess0")
shader:dx10sampler("SamplerLinearClamp")
end

-- Samples $user$generic_combine (DLSS/FSR output) instead of postprocess0.
function element_1(shader, t_base, t_second, t_detail)
shader:begin("stub_screen_space", "postprocess_cas")
:fog(false)
:zb(false, false)
shader:dx10texture("t_current", "$user$generic_combine")
shader:dx10sampler("SamplerLinearClamp")
end
Loading