17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-07 06:28:08 +01:00

Let the instances drawn from the GPU hide one another, in two phases

This commit is contained in:
2026-10-17 21:50:23 +02:00
parent 918c056b83
commit 5a5c67aaaf
14 changed files with 367 additions and 129 deletions

View File

@@ -351,12 +351,17 @@ class opengl46_renderer : public gfx_renderer {
// pyramid of the occlusion test, runs the culling, walks the submodel trees of the groups once per lod band to record
// the draws (m_indirectdraws, m_indirectcommands), has their instances filled in, then draws them with indirect draws,
// their depth first (Global.gfx_depthprepass). inside the depth pass of the whole scene only their depth is drawn, their
// colour waits for the colour pass (Render_Instances_Indirect_Colour())
// colour waits for the colour pass (Render_Instances_Indirect_Colour()). in two phases
// (Global.gfx_gpucull_occlusion_instances) the instances seen in the previous frame are drawn first (their depth, or
// their colour without the prepass), the pyramid is made again and the other instances are culled against it
void Render_Instances_Indirect();
// the recorded draws of the instances: their depth with the programs of the depth prepass, with the state of the prepass
// already set (returns the number of draws), and their colour. the command buffer and the instances are bound by the caller
std::uint32_t Render_Instances_Indirect_Depth();
void Render_Instances_Indirect_Colour();
// the recorded draws of the instances, with the commands of the given set: their depth with the programs of the depth
// prepass, with the state of the prepass already set (returns the number of draws), the same with the state set for it
// and the time measured outside the depth pass of the whole scene, and their colour. the command buffer and the
// instances are bound by the caller
std::uint32_t Render_Instances_Indirect_Depth( opengl46_instance_cull::command_set const Set );
std::uint32_t Render_Instances_Indirect_Prepass( opengl46_instance_cull::command_set const Set, gl::gpu_timer &Timer );
void Render_Instances_Indirect_Colour( opengl46_instance_cull::command_set const Set );
// how the depth prepass treats the material: 0 left out, 1 drawn without alpha test, 2 with the alpha test of the diffuse texture
int Prepass_Class( material_handle const Material );
// depth of the whole opaque scene of the colour pass, before its colour (Global.gfx_depthprepass_scene): the colour pass
@@ -552,11 +557,13 @@ class opengl46_renderer : public gfx_renderer {
std::unique_ptr<gl::program> m_prepass_alpha_shader;
std::unordered_map<gl::program const *, int> m_prepassclasses;
gl::gpu_timer m_prepasstimer;
gl::gpu_timer m_prepassfirsttimer; // of the instances drawn first, in two phases
// depth pass of the whole scene (Render_Scene_Depth())
bool m_scenedepthpass { false }; // inside it: Bind_Material() and draw() work for the depth
bool m_scenedepthskip { true }; // the material bound last isn't drawn in it
bool m_scenedepthdrawn { false }; // it was drawn for the colour pass under way, which skips what was done in it already
bool m_indirectcolourpending { false }; // the instances were culled in it, the colour pass draws them from the recorded draws
opengl46_instance_cull::command_set m_indirectcolourset { opengl46_instance_cull::command_set::first }; // with these commands
debug_stats m_scenedepthstats; // of its last run
double m_scenedepthcputime { 0.0 }; // ms
gl::gpu_timer m_scenedepthtimer;