jak-project/game/graphics/opengl_renderer/foreground/Generic2.cpp
water111 a6fa04a83d
[graphics] port generic VU1 to OpenGL (#1221)
* temp

* name the obvious ones

* un-pipelined the fast case in generic vu1

* generic2 dma

* pass2

* first pass at opengl

* many fixes

* fix hud, strip

* windows fix

* final tweaks

* memcard folder

* add missing include
2022-03-06 19:56:43 -05:00

76 lines
2.3 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]);
}
/*!
* 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);
}
}