Skip to content

Commit

Permalink
Merge pull request #61 from scallyw4g/jesse/perf/tuning-renderer-text…
Browse files Browse the repository at this point in the history
…ure-sizes

Jesse/perf/tuning renderer texture sizes
  • Loading branch information
scallyw4g authored Mar 28, 2024
2 parents 9bf452e + 721615b commit 86f53d0
Show file tree
Hide file tree
Showing 26 changed files with 339 additions and 60 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
* 1.5.1

- Fog now driven from C++ (and, by extension, the editor)

- Improved UX when opening brush menu for the first time

- Fixed the preview jank when using a layered brush.
The preview should now appear stable in the viewport

- Tuned some gBuffer texture storage resolution, transparency buffer storage resolution, & turned down default shadow quality
This is in an effort to get mid-end cards running at >60fps on 4k

* 1.5.0

- @Shawnecy Chased down a divide by zero in the lighting shader
Expand Down
2 changes: 1 addition & 1 deletion external/bonsai_stdlib
2 changes: 1 addition & 1 deletion generated/block_array_h_texture_688856411.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/texture.h:19:0
// external/bonsai_stdlib/src/texture.h:35:0

struct texture_ptr_block
{
Expand Down
2 changes: 1 addition & 1 deletion generated/block_array_h_texture_688856411_0.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/texture.h:16:0
// external/bonsai_stdlib/src/texture.h:32:0

struct texture_block
{
Expand Down
2 changes: 1 addition & 1 deletion generated/do_editor_ui_for_compound_type_engine_debug.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:413:0
// src/engine/editor.cpp:416:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:434:0
// src/engine/editor.cpp:437:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_resources *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
2 changes: 1 addition & 1 deletion generated/do_editor_ui_for_compound_type_engine_settings.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:431:0
// src/engine/editor.cpp:434:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_settings *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
112 changes: 112 additions & 0 deletions generated/do_editor_ui_for_compound_type_g_buffer_render_group.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// src/engine/editor.cpp:404:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, g_buffer_render_group *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
{
if (Element)
{
// NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to
// support not drawing the toggl-y thing if we just want to dump the members.
b32 DrawChildren = True;
b32 DidToggle = False;
if (Name.Count)
{
if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle g_buffer_render_group", Element), &DefaultUiRenderParams_Generic))
{
DidToggle = True;
PushNewRow(Ui);
}
else
{
DrawChildren = False;
}
}

if (DrawChildren)
{
PushTableStart(Ui);
if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); }
DoEditorUi(Ui,
Window,
&Element->FBO,
CSz("FBO"),
Params
);






DoEditorUi(Ui,
Window,
&Element->Textures,
CSz("Textures"),
Params
);






DoEditorUi(Ui,
Window,
&Element->gBufferShader,
CSz("gBufferShader"),
Params
);






DoEditorUi(Ui,
Window,
&Element->InverseViewMatrix,
CSz("InverseViewMatrix"),
Params
);






DoEditorUi(Ui,
Window,
&Element->InverseProjectionMatrix,
CSz("InverseProjectionMatrix"),
Params
);






DoEditorUi(Ui,
Window,
&Element->ViewProjection,
CSz("ViewProjection"),
Params
);
if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); }
PushTableEnd(Ui);
}
else
{
PushNewRow(Ui);
}

}
else
{
PushColumn(Ui, Name, Params);
PushColumn(Ui, CSz("(null)"), Params);
PushNewRow(Ui);
}

}

2 changes: 1 addition & 1 deletion generated/do_editor_ui_for_compound_type_graphics.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:404:0
// src/engine/editor.cpp:407:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:428:0
// src/engine/editor.cpp:431:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics_settings *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
39 changes: 38 additions & 1 deletion generated/do_editor_ui_for_compound_type_level_editor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:419:0
// src/engine/editor.cpp:422:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, level_editor *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down Expand Up @@ -111,6 +111,43 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, level_editor *Element, cs Nam



DoEditorUi(Ui,
Window,
Cast(b8*,&Element->RootChunkNeedsNewMesh),
CSz("RootChunkNeedsNewMesh"),
&DefaultUiRenderParams_Checkbox
);





PushNewRow(Ui);

DoEditorUi(Ui,
Window,
&Element->MostRecentSelectionRegionMin,
CSz("MostRecentSelectionRegionMin"),
Params
);






DoEditorUi(Ui,
Window,
&Element->NextSelectionRegionMin,
CSz("NextSelectionRegionMin"),
Params
);






DoEditorUi(Ui,
Window,
&Element->EditorPreviewRegionMin,
Expand Down
2 changes: 1 addition & 1 deletion generated/do_editor_ui_for_compound_type_render_debug.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:407:0
// src/engine/editor.cpp:410:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, render_debug *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
2 changes: 1 addition & 1 deletion generated/do_editor_ui_for_compound_type_ui_debug.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:410:0
// src/engine/editor.cpp:413:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_debug *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
2 changes: 1 addition & 1 deletion generated/do_editor_ui_for_enum_engine_debug_view_mode.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:416:0
// src/engine/editor.cpp:419:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
2 changes: 1 addition & 1 deletion generated/do_editor_ui_for_enum_resolution_setting.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:422:0
// src/engine/editor.cpp:425:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, resolution_setting *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
2 changes: 1 addition & 1 deletion generated/do_editor_ui_for_enum_shader_language_setting.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/editor.cpp:425:0
// src/engine/editor.cpp:428:0

link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_language_setting *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic)
Expand Down
22 changes: 22 additions & 0 deletions generated/do_editor_ui_for_vector_type_688873645.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,26 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, Quaternion *Value, cs Name, u

PushNewRow(Ui);
}
link_internal void
DoEditorUi(renderer_2d *Ui, window_layout *Window, m4 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS)
{
/* PushTableStart(Ui); */
if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); }

if (Value)
{
u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank);
PushTableStart(Ui);
DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES );
DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES );
DoEditorUi(Ui, Window, &Value->E[2], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES );
DoEditorUi(Ui, Window, &Value->E[3], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES );
PushTableEnd(Ui);
/* PushNewRow(Ui); */
EndColumn(Ui, Start);
}
/* PushTableEnd(Ui); */

PushNewRow(Ui);
}

18 changes: 9 additions & 9 deletions jesse.make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

OPT="-O2"

# ./make.sh RunPoof
# [ $? -ne 0 ] && exit 1
./make.sh RunPoof
[ $? -ne 0 ] && exit 1

# ./make.sh $OPT BuildAll
./make.sh $OPT BuildAll

./make.sh $OPT \
BuildSingleExample examples/blank_project \
BuildSingleExample examples/project_and_level_picker \
BuildSingleExample examples/terrain_gen \
BuildExecutables \
BuildDebugSystem \
# ./make.sh $OPT \
# BuildSingleExample examples/blank_project \
# BuildSingleExample examples/project_and_level_picker \
# BuildSingleExample examples/terrain_gen \
# BuildExecutables \
# BuildDebugSystem \
# BuildSingleExample examples/turn_based \
# BuildSingleExample examples/tools/voxel_synthesis_rule_baker \
# BuildSingleExample examples/the_wanderer \
Expand Down
24 changes: 19 additions & 5 deletions shaders/Ao.fragmentshader
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ in vec2 UV;
out float Output;

/* uniform sampler2D gColor; */
uniform sampler2D gPosition;
/* uniform sampler2D gPosition; */
uniform sampler2D gNormal;
uniform sampler2D gDepth;

uniform sampler2D SsaoNoiseTexture;
uniform vec3 SsaoNoiseTile;
Expand All @@ -12,6 +13,8 @@ uniform vec3 SsaoNoiseTile;
const int SSAO_KERNEL_SIZE = 32;
uniform vec3 SsaoKernel[SSAO_KERNEL_SIZE];

uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform mat4 ViewProjection;

// Tuning
Expand All @@ -22,8 +25,18 @@ uniform mat4 ViewProjection;
void main()
{
vec3 FragNormal = texture(gNormal, UV).rgb; // modelspace
vec3 FragPosition = texture(gPosition, UV).rgb; // worldspace
float FragDepth = texture(gPosition, UV).w; // Linear
/* vec3 FragPosition = texture(gPosition, UV).rgb; // worldspace */

float FragDepthNonlinear = texture(gDepth, UV).r;
v3 FragPosition = WorldPositionFromNonlinearDepth(FragDepthNonlinear, UV, InverseProjectionMatrix, InverseViewMatrix);



float FragDepth = Linearize(FragDepthNonlinear, 5000.f, 0.1f);

/* Output = FragPosition.y; */
/* Output = FragDepth; */
/* return; */

vec3 Noise = texture(SsaoNoiseTexture, UV*SsaoNoiseTile.xy).xyz;

Expand Down Expand Up @@ -59,10 +72,11 @@ void main()
vec2 SampleUV = Projected.xy / Projected.w;

// NDC to screen space [-1, 1] -> [0, 1]
SampleUV = (SampleUV.xy * 0.5) + 0.5;
SampleUV = (SampleUV.xy * 0.5f) + 0.5f;

// get Sample depth:
float SampleDepth = texture(gPosition, SampleUV).w;
float SampleDepth = Linearize(texture(gDepth, SampleUV).r, 5000.f, 0.1f);
/* float SampleDepth = texture(gPosition, SampleUV).w; */
float DepthDelta = (BiasedFragDepth - SampleDepth);

#if 0
Expand Down
Loading

0 comments on commit 86f53d0

Please sign in to comment.