Files
jak-project/game/graphics/opengl_renderer/foreground/Generic2.cpp
T
water111 90a049dcc5 [cleanup] memory bugs, memory usage reduction, delete merc1 (#1515)
* [cleanup] remove merc1, fix memory bugs, reduce memory usage

* change compiler log to see actual info from build_level

* save file

* editing text is hard
2022-06-21 21:26:11 -04:00

88 lines
3.1 KiB
C++

#include "Generic2.h"
#include "game/graphics/opengl_renderer/AdgifHandler.h"
#include "third-party/imgui/imgui.h"
Generic2::Generic2(const std::string& name,
BucketId my_id,
u32 num_verts,
u32 num_frags,
u32 num_adgif,
u32 num_buckets)
: BucketRenderer(name, my_id) {
m_verts.resize(num_verts);
m_fragments.resize(num_frags);
m_adgifs.resize(num_adgif);
m_buckets.resize(num_buckets);
m_indices.resize(num_verts * 3);
opengl_setup();
}
Generic2::~Generic2() {
opengl_cleanup();
}
void Generic2::draw_debug_window() {
ImGui::Checkbox("Alpha 1", &m_alpha_draw_enable[0]);
ImGui::Checkbox("Alpha 2", &m_alpha_draw_enable[1]);
ImGui::Checkbox("Alpha 3", &m_alpha_draw_enable[2]);
ImGui::Checkbox("Alpha 4", &m_alpha_draw_enable[3]);
ImGui::Checkbox("Alpha 5", &m_alpha_draw_enable[4]);
ImGui::Checkbox("Alpha 6", &m_alpha_draw_enable[5]);
ImGui::Text("Max Seen:");
ImGui::Text(" frag: %d/%d %.1f%%", m_max_frags_seen, (int)m_fragments.size(),
100.f * m_max_frags_seen / (float)m_fragments.size());
ImGui::Text(" vert: %d/%d %.1f%%", m_max_verts_seen, (int)m_verts.size(),
100.f * m_max_verts_seen / (float)m_verts.size());
ImGui::Text(" adgif: %d/%d %.1f%%", m_max_frags_seen, (int)m_adgifs.size(),
100.f * m_max_adgifs_seen / (float)m_adgifs.size());
ImGui::Text(" idx: %d/%d %.1f%%", m_max_frags_seen, (int)m_indices.size(),
100.f * m_max_indices_seen / (float)m_indices.size());
ImGui::Text(" bucket: %d/%d %.1f%%", m_max_frags_seen, (int)m_fragments.size(),
100.f * m_max_frags_seen / (float)m_fragments.size());
}
/*!
* Main render function for Generic2. This will be passed a DMA "follower" from the main
* OpenGLRenderer that can read a DMA chain, starting at the DMA "bucket" that was filled by the
* generic renderer. This renderer is expected to follow the chain until it reaches "next_bucket"
* and then return.
*/
void Generic2::render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) {
// completely clear out state. These will get populated by the rendering functions, then displayed
// by draw_debug_window() if the user opens that window
m_debug.clear();
m_stats = Stats();
// if the user has asked to disable the renderer, just advance the dma follower to the next
// bucket and return immediately.
if (!m_enabled) {
while (dma.current_tag_offset() != render_state->next_bucket) {
dma.read_and_advance();
}
return;
}
// Generic2 has 3 passes.
{
// our first pass is to go over the DMA chain from the game and extract the data into buffers
auto p = prof.make_scoped_child("dma");
process_dma(dma, render_state->next_bucket);
}
{
// the next pass is to look at all of that data, and figure out the best order to draw it
// using OpenGL
auto p = prof.make_scoped_child("setup");
setup_draws();
}
{
// the final pass is the actual drawing.
auto p = prof.make_scoped_child("drawing");
do_draws(render_state, p);
}
}