mirror of
https://github.com/open-goal/jak-project
synced 2026-09-10 20:29:51 -04:00
fix some zero size draws, check all draw call sizes
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "game/graphics/pipelines/opengl.h"
|
||||
#include "third-party/imgui/imgui.h"
|
||||
#include "common/util/Assert.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
|
||||
DirectRenderer::DirectRenderer(const std::string& name, BucketId my_id, int batch_size)
|
||||
: BucketRenderer(name, my_id), m_prim_buffer(batch_size) {
|
||||
@@ -214,14 +215,14 @@ void DirectRenderer::flush_pending(SharedRenderState* render_state, ScopedProfil
|
||||
m_prim_buffer.vertices.data(), GL_STREAM_DRAW);
|
||||
|
||||
int draw_count = 0;
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_prim_buffer.vert_count);
|
||||
DrawCall::draw_arrays(GL_TRIANGLES, 0, m_prim_buffer.vert_count);
|
||||
draw_count++;
|
||||
|
||||
if (m_debug_state.wireframe) {
|
||||
render_state->shaders[ShaderId::DEBUG_RED].activate();
|
||||
glDisable(GL_BLEND);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_prim_buffer.vert_count);
|
||||
DrawCall::draw_arrays(GL_TRIANGLES, 0, m_prim_buffer.vert_count);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
m_blend_state_needs_gl_update = true;
|
||||
m_prim_gl_state_needs_gl_update = true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "DirectRenderer2.h"
|
||||
#include "third-party/imgui/imgui.h"
|
||||
#include "common/log/log.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
#include <immintrin.h>
|
||||
|
||||
DirectRenderer2::DirectRenderer2(u32 max_verts,
|
||||
@@ -160,14 +161,14 @@ void DirectRenderer2::draw_call_loop_simple(SharedRenderState* render_state,
|
||||
setup_opengl_for_draw_mode(draw, render_state);
|
||||
setup_opengl_tex(0, draw.tbp, draw.mode.get_filt_enable(), draw.mode.get_clamp_s_enable(),
|
||||
draw.mode.get_clamp_t_enable(), render_state);
|
||||
void* offset = (void*)(draw.start_index * sizeof(u32));
|
||||
u32 offset = draw.start_index * sizeof(u32);
|
||||
int end_idx;
|
||||
if (draw_idx == m_next_free_draw - 1) {
|
||||
end_idx = m_vertices.next_index;
|
||||
} else {
|
||||
end_idx = m_draw_buffer[draw_idx + 1].start_index;
|
||||
}
|
||||
glDrawElements(GL_TRIANGLE_STRIP, end_idx - draw.start_index, GL_UNSIGNED_INT, (void*)offset);
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, end_idx - draw.start_index, GL_UNSIGNED_INT, offset);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri((end_idx - draw.start_index) - 2);
|
||||
}
|
||||
@@ -210,11 +211,11 @@ void DirectRenderer2::draw_call_loop_grouped(SharedRenderState* render_state,
|
||||
} else {
|
||||
end_idx = m_draw_buffer[end_of_draw_group + 1].start_index;
|
||||
}
|
||||
void* offset = (void*)(draw.start_index * sizeof(u32));
|
||||
u32 offset = (draw.start_index * sizeof(u32));
|
||||
// fmt::print("drawing {:4d} with abe {} tex {} {}", end_idx - draw.start_index,
|
||||
// (int)draw.mode.get_ab_enable(), end_of_draw_group - draw_idx, draw.to_single_line_string() );
|
||||
// fmt::print("{}\n", draw.mode.to_string());
|
||||
glDrawElements(GL_TRIANGLE_STRIP, end_idx - draw.start_index, GL_UNSIGNED_INT, (void*)offset);
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, end_idx - draw.start_index, GL_UNSIGNED_INT, offset);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri((end_idx - draw.start_index) / 3);
|
||||
draw_idx = end_of_draw_group + 1;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "EyeRenderer.h"
|
||||
#include "game/graphics/opengl_renderer/AdgifHandler.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
|
||||
#include "common/util/FileUtil.h"
|
||||
#include "third-party/imgui/imgui.h"
|
||||
@@ -588,7 +589,7 @@ void EyeRenderer::run_gpu(const std::vector<SingleEyeDraws>& draws,
|
||||
// set texture
|
||||
glDisable(GL_BLEND);
|
||||
glBindTexture(GL_TEXTURE_2D, draw.iris_gl_tex);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, buffer_idx / 4, 4);
|
||||
DrawCall::draw_arrays(GL_TRIANGLE_STRIP, buffer_idx / 4, 4);
|
||||
}
|
||||
buffer_idx += 4 * 4;
|
||||
|
||||
@@ -597,14 +598,14 @@ void EyeRenderer::run_gpu(const std::vector<SingleEyeDraws>& draws,
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBindTexture(GL_TEXTURE_2D, draw.pupil_gl_tex);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, buffer_idx / 4, 4);
|
||||
DrawCall::draw_arrays(GL_TRIANGLE_STRIP, buffer_idx / 4, 4);
|
||||
}
|
||||
buffer_idx += 4 * 4;
|
||||
|
||||
if (draw.lid_tex) {
|
||||
glDisable(GL_BLEND);
|
||||
glBindTexture(GL_TEXTURE_2D, draw.lid_gl_tex);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, buffer_idx / 4, 4);
|
||||
DrawCall::draw_arrays(GL_TRIANGLE_STRIP, buffer_idx / 4, 4);
|
||||
}
|
||||
buffer_idx += 4 * 4;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ShadowRenderer.h"
|
||||
#include "third-party/imgui/imgui.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
@@ -368,14 +369,14 @@ void ShadowRenderer::draw(SharedRenderState* render_state, ScopedProfilerNode& p
|
||||
}
|
||||
glStencilFunc(GL_ALWAYS, 0, 0); // always pass stencil
|
||||
glStencilOp(GL_KEEP, GL_INCR, GL_KEEP); // increment on depth fail.
|
||||
glDrawElements(GL_TRIANGLES, m_next_back_index, GL_UNSIGNED_INT, nullptr);
|
||||
DrawCall::draw_elements(GL_TRIANGLES, m_next_back_index, GL_UNSIGNED_INT, 0);
|
||||
|
||||
if (m_debug_draw_volume) {
|
||||
glDisable(GL_BLEND);
|
||||
glUniform4f(glGetUniformLocation(render_state->shaders[ShaderId::SHADOW].id(), "color_uniform"),
|
||||
0., 0.0, 0., 0.5);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glDrawElements(GL_TRIANGLES, m_next_back_index, GL_UNSIGNED_INT, nullptr);
|
||||
DrawCall::draw_elements(GL_TRIANGLES, m_next_back_index, GL_UNSIGNED_INT, 0);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
@@ -390,13 +391,13 @@ void ShadowRenderer::draw(SharedRenderState* render_state, ScopedProfilerNode& p
|
||||
// Second pass.
|
||||
// same settings, but decrement.
|
||||
glStencilOp(GL_KEEP, GL_DECR, GL_KEEP); // decrement on depth fail.
|
||||
glDrawElements(GL_TRIANGLES, (m_next_front_index - 6), GL_UNSIGNED_INT, nullptr);
|
||||
DrawCall::draw_elements(GL_TRIANGLES, (m_next_front_index - 6), GL_UNSIGNED_INT, 0);
|
||||
if (m_debug_draw_volume) {
|
||||
glDisable(GL_BLEND);
|
||||
glUniform4f(glGetUniformLocation(render_state->shaders[ShaderId::SHADOW].id(), "color_uniform"),
|
||||
0., 0.0, 0., 0.5);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glDrawElements(GL_TRIANGLES, (m_next_front_index - 6), GL_UNSIGNED_INT, nullptr);
|
||||
DrawCall::draw_elements(GL_TRIANGLES, (m_next_front_index - 6), GL_UNSIGNED_INT, 0);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
@@ -416,7 +417,7 @@ void ShadowRenderer::draw(SharedRenderState* render_state, ScopedProfilerNode& p
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
|
||||
glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ONE, GL_ZERO);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, (void*)(sizeof(u32) * (m_next_front_index - 6)));
|
||||
DrawCall::draw_elements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, sizeof(u32) * (m_next_front_index - 6));
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(2);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "SkyBlendGPU.h"
|
||||
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
#include "common/log/log.h"
|
||||
#include "game/graphics/opengl_renderer/AdgifHandler.h"
|
||||
|
||||
@@ -174,7 +174,7 @@ SkyBlendStats SkyBlendGPU::do_sky_blends(DmaFollower& dma,
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
// Draw a sqaure
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
DrawCall::draw_arrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
// 1 draw, 2 triangles
|
||||
prof.add_draw_call(1);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
|
||||
#include "Sprite3.h"
|
||||
|
||||
#include "third-party/fmt/core.h"
|
||||
#include "third-party/imgui/imgui.h"
|
||||
#include "game/graphics/opengl_renderer/dma_helpers.h"
|
||||
#include "game/graphics/opengl_renderer/background/background_common.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -498,8 +497,8 @@ void Sprite3::flush_sprites(SharedRenderState* render_state,
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(2 * (bucket->ids.size() / 5));
|
||||
|
||||
glDrawElements(GL_TRIANGLE_STRIP, bucket->ids.size(), GL_UNSIGNED_INT,
|
||||
(void*)(bucket->offset_in_idx_buffer * sizeof(u32)));
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, bucket->ids.size(), GL_UNSIGNED_INT,
|
||||
bucket->offset_in_idx_buffer * sizeof(u32));
|
||||
|
||||
if (double_draw) {
|
||||
switch (settings.kind) {
|
||||
@@ -515,8 +514,8 @@ void Sprite3::flush_sprites(SharedRenderState* render_state,
|
||||
glGetUniformLocation(render_state->shaders[ShaderId::SPRITE3].id(), "alpha_max"),
|
||||
settings.aref_second);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, bucket->ids.size(), GL_UNSIGNED_INT,
|
||||
(void*)(bucket->offset_in_idx_buffer * sizeof(u32)));
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, bucket->ids.size(), GL_UNSIGNED_INT,
|
||||
bucket->offset_in_idx_buffer * sizeof(u32));
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "SpriteRenderer.h"
|
||||
#include "game/graphics/opengl_renderer/dma_helpers.h"
|
||||
#include "game/graphics/opengl_renderer/background/background_common.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -458,7 +459,7 @@ void SpriteRenderer::flush_sprites(SharedRenderState* render_state, ScopedProfil
|
||||
glBufferData(GL_ARRAY_BUFFER, m_sprite_offset * sizeof(SpriteVertex3D) * 6, m_vertices_3d.data(),
|
||||
GL_STREAM_DRAW);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_sprite_offset * 6);
|
||||
DrawCall::draw_arrays(GL_TRIANGLES, 0, m_sprite_offset * 6);
|
||||
|
||||
glBindVertexArray(0);
|
||||
int n_tris = m_sprite_offset * 6 / 3;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Shrub.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
|
||||
Shrub::Shrub(const std::string& name, BucketId my_id) : BucketRenderer(name, my_id) {
|
||||
m_color_result.resize(TIME_OF_DAY_COLOR_COUNT);
|
||||
@@ -270,9 +271,9 @@ void Shrub::render_tree(int idx,
|
||||
tree.perf.draws++;
|
||||
tree.perf.verts += draw_size;
|
||||
|
||||
glMultiDrawElements(GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first],
|
||||
GL_UNSIGNED_INT, &m_cache.multidraw_index_offset_buffer[indices.first],
|
||||
indices.second);
|
||||
DrawCall::multi_draw_elements(
|
||||
GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first], GL_UNSIGNED_INT,
|
||||
&m_cache.multidraw_index_offset_buffer[indices.first], indices.second);
|
||||
|
||||
switch (double_draw.kind) {
|
||||
case DoubleDrawKind::NONE:
|
||||
@@ -287,9 +288,9 @@ void Shrub::render_tree(int idx,
|
||||
glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SHRUB].id(), "alpha_max"),
|
||||
double_draw.aref_second);
|
||||
glDepthMask(GL_FALSE);
|
||||
glMultiDrawElements(GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first],
|
||||
GL_UNSIGNED_INT, &m_cache.multidraw_index_offset_buffer[indices.first],
|
||||
indices.second);
|
||||
DrawCall::multi_draw_elements(
|
||||
GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first], GL_UNSIGNED_INT,
|
||||
&m_cache.multidraw_index_offset_buffer[indices.first], indices.second);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
@@ -297,6 +298,8 @@ void Shrub::render_tree(int idx,
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
tree.perf.draw_time.add(draw_timer.getSeconds());
|
||||
tree.perf.tree_time.add(tree_timer.getSeconds());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Tfrag3.h"
|
||||
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
#include "third-party/imgui/imgui.h"
|
||||
|
||||
Tfrag3::Tfrag3() {
|
||||
@@ -225,9 +225,9 @@ void Tfrag3::render_tree(int geom,
|
||||
|
||||
prof.add_draw_call();
|
||||
|
||||
glMultiDrawElements(GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first],
|
||||
GL_UNSIGNED_INT, &m_cache.multidraw_index_offset_buffer[indices.first],
|
||||
indices.second);
|
||||
DrawCall::multi_draw_elements(
|
||||
GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first], GL_UNSIGNED_INT,
|
||||
&m_cache.multidraw_index_offset_buffer[indices.first], indices.second);
|
||||
|
||||
switch (double_draw.kind) {
|
||||
case DoubleDrawKind::NONE:
|
||||
@@ -240,15 +240,17 @@ void Tfrag3::render_tree(int geom,
|
||||
glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::TFRAG3].id(), "alpha_max"),
|
||||
double_draw.aref_second);
|
||||
glDepthMask(GL_FALSE);
|
||||
glMultiDrawElements(GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first],
|
||||
GL_UNSIGNED_INT, &m_cache.multidraw_index_offset_buffer[indices.first],
|
||||
indices.second);
|
||||
DrawCall::multi_draw_elements(
|
||||
GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first], GL_UNSIGNED_INT,
|
||||
&m_cache.multidraw_index_offset_buffer[indices.first], indices.second);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
}
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -471,7 +473,7 @@ void Tfrag3::render_tree_cull_debug(const TfragRenderSettings& settings,
|
||||
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, to_do * sizeof(DebugVertex),
|
||||
m_debug_vert_data.data() + start);
|
||||
glDrawArrays(GL_TRIANGLES, 0, to_do);
|
||||
DrawCall::draw_arrays(GL_TRIANGLES, 0, to_do);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(to_do / 3);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Tie3.h"
|
||||
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
#include "third-party/imgui/imgui.h"
|
||||
|
||||
Tie3::Tie3(const std::string& name, BucketId my_id, int level_id)
|
||||
@@ -467,8 +467,8 @@ void Tie3::render_tree_wind(int idx,
|
||||
tree.perf.wind_draws++;
|
||||
tree.perf.verts += grp.num;
|
||||
|
||||
glDrawElements(GL_TRIANGLE_STRIP, grp.num, GL_UNSIGNED_INT,
|
||||
(void*)((off + tree.wind_vertex_index_offsets.at(draw_idx)) * sizeof(u32)));
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, grp.num, GL_UNSIGNED_INT,
|
||||
(off + tree.wind_vertex_index_offsets.at(draw_idx)) * sizeof(u32));
|
||||
off += grp.num;
|
||||
|
||||
switch (double_draw.kind) {
|
||||
@@ -487,8 +487,8 @@ void Tie3::render_tree_wind(int idx,
|
||||
glGetUniformLocation(render_state->shaders[ShaderId::TFRAG3].id(), "alpha_max"),
|
||||
double_draw.aref_second);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, draw.vertex_index_stream.size(), GL_UNSIGNED_INT,
|
||||
(void*)0);
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, draw.vertex_index_stream.size(),
|
||||
GL_UNSIGNED_INT, 0);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
@@ -589,9 +589,9 @@ void Tie3::render_tree(int idx,
|
||||
tree.perf.draws++;
|
||||
tree.perf.verts += draw_size;
|
||||
|
||||
glMultiDrawElements(GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first],
|
||||
GL_UNSIGNED_INT, &m_cache.multidraw_index_offset_buffer[indices.first],
|
||||
indices.second);
|
||||
DrawCall::multi_draw_elements(
|
||||
GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first], GL_UNSIGNED_INT,
|
||||
&m_cache.multidraw_index_offset_buffer[indices.first], indices.second);
|
||||
|
||||
switch (double_draw.kind) {
|
||||
case DoubleDrawKind::NONE:
|
||||
@@ -606,9 +606,9 @@ void Tie3::render_tree(int idx,
|
||||
glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::TFRAG3].id(), "alpha_max"),
|
||||
double_draw.aref_second);
|
||||
glDepthMask(GL_FALSE);
|
||||
glMultiDrawElements(GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first],
|
||||
GL_UNSIGNED_INT, &m_cache.multidraw_index_offset_buffer[indices.first],
|
||||
indices.second);
|
||||
DrawCall::multi_draw_elements(
|
||||
GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first], GL_UNSIGNED_INT,
|
||||
&m_cache.multidraw_index_offset_buffer[indices.first], indices.second);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
@@ -628,9 +628,9 @@ void Tie3::render_tree(int idx,
|
||||
settings.fog.x());
|
||||
glDisable(GL_BLEND);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glMultiDrawElements(GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first],
|
||||
GL_UNSIGNED_INT, &m_cache.multidraw_index_offset_buffer[indices.first],
|
||||
indices.second);
|
||||
DrawCall::multi_draw_elements(
|
||||
GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[indices.first], GL_UNSIGNED_INT,
|
||||
&m_cache.multidraw_index_offset_buffer[indices.first], indices.second);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(draw_size);
|
||||
@@ -644,6 +644,8 @@ void Tie3::render_tree(int idx,
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
tree.perf.draw_time.add(draw_timer.getSeconds());
|
||||
tree.perf.tree_time.add(tree_timer.getSeconds());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Generic2.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
|
||||
void Generic2::opengl_setup() {
|
||||
// create OpenGL objects
|
||||
@@ -258,8 +259,8 @@ void Generic2::do_draws_for_alpha(SharedRenderState* render_state,
|
||||
setup_opengl_for_draw_mode(first.mode, first.fix, render_state);
|
||||
setup_opengl_tex(0, first.tbp, first.mode.get_filt_enable(), first.mode.get_clamp_s_enable(),
|
||||
first.mode.get_clamp_t_enable(), render_state);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, bucket.idx_count, GL_UNSIGNED_INT,
|
||||
(void*)(sizeof(u32) * bucket.idx_idx));
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, bucket.idx_count, GL_UNSIGNED_INT,
|
||||
sizeof(u32) * bucket.idx_idx);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(bucket.tri_count);
|
||||
}
|
||||
@@ -274,8 +275,8 @@ void Generic2::do_hud_draws(SharedRenderState* render_state, ScopedProfilerNode&
|
||||
setup_opengl_for_draw_mode(first.mode, first.fix, render_state);
|
||||
setup_opengl_tex(0, first.tbp, first.mode.get_filt_enable(), first.mode.get_clamp_s_enable(),
|
||||
first.mode.get_clamp_t_enable(), render_state);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, bucket.idx_count, GL_UNSIGNED_INT,
|
||||
(void*)(sizeof(u32) * bucket.idx_idx));
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, bucket.idx_count, GL_UNSIGNED_INT,
|
||||
sizeof(u32) * bucket.idx_idx);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(bucket.tri_count);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "CommonOceanRenderer.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
|
||||
CommonOceanRenderer::CommonOceanRenderer() {
|
||||
m_vertices.resize(4096 * 10); // todo decrease
|
||||
@@ -284,6 +285,9 @@ void CommonOceanRenderer::flush_near(SharedRenderState* render_state, ScopedProf
|
||||
glDepthFunc(GL_GEQUAL);
|
||||
|
||||
for (int bucket = 0; bucket < 3; bucket++) {
|
||||
if (m_next_free_index[bucket] == 0) {
|
||||
continue;
|
||||
}
|
||||
switch (bucket) {
|
||||
case 0: {
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
@@ -330,7 +334,7 @@ void CommonOceanRenderer::flush_near(SharedRenderState* render_state, ScopedProf
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ogl.index_buffer[bucket]);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_next_free_index[bucket] * sizeof(u32),
|
||||
m_indices[bucket].data(), GL_STREAM_DRAW);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, m_next_free_index[bucket], GL_UNSIGNED_INT, nullptr);
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, m_next_free_index[bucket], GL_UNSIGNED_INT, 0);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(m_next_free_index[bucket]);
|
||||
}
|
||||
@@ -517,7 +521,7 @@ void CommonOceanRenderer::flush_mid(SharedRenderState* render_state, ScopedProfi
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ogl.index_buffer[bucket]);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_next_free_index[bucket] * sizeof(u32),
|
||||
m_indices[bucket].data(), GL_STREAM_DRAW);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, m_next_free_index[bucket], GL_UNSIGNED_INT, nullptr);
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, m_next_free_index[bucket], GL_UNSIGNED_INT, 0);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(m_next_free_index[bucket]);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "OceanTexture.h"
|
||||
#include "game/graphics/opengl_renderer/AdgifHandler.h"
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
#include "third-party/imgui/imgui.h"
|
||||
|
||||
constexpr int OCEAN_TEX_TBP = 8160; // todo
|
||||
@@ -255,7 +256,7 @@ void OceanTexture::make_texture_with_mipmaps(SharedRenderState* render_state,
|
||||
glUniform1f(
|
||||
glGetUniformLocation(render_state->shaders[ShaderId::OCEAN_TEXTURE_MIPMAP].id(), "scale"),
|
||||
1.f / (1 << i));
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
DrawCall::draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(2);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "OceanTexture.h"
|
||||
|
||||
#include "game/graphics/opengl_renderer/opengl_utils.h"
|
||||
void OceanTexture::run_L1_PC() {
|
||||
// L1:
|
||||
// lq.xyzw vf14_startx, 988(vi00) | maxw.xyzw vf01_ones, vf00, vf00
|
||||
@@ -428,7 +428,7 @@ void OceanTexture::flush(SharedRenderState* render_state, ScopedProfilerNode& pr
|
||||
// glDrawArrays(GL_TRIANGLE_STRIP, 0, NUM_VERTS);
|
||||
glEnable(GL_PRIMITIVE_RESTART);
|
||||
glPrimitiveRestartIndex(UINT32_MAX);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, m_pc.index_buffer.size(), GL_UNSIGNED_INT, (void*)0);
|
||||
DrawCall::draw_elements(GL_TRIANGLE_STRIP, m_pc.index_buffer.size(), GL_UNSIGNED_INT, 0);
|
||||
prof.add_draw_call();
|
||||
prof.add_tri(NUM_STRIPS * NUM_STRIPS * 2);
|
||||
|
||||
|
||||
@@ -143,5 +143,30 @@ void FullScreenDraw::draw(const math::Vector4f& color,
|
||||
color[3]);
|
||||
prof.add_tri(2);
|
||||
prof.add_draw_call();
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
DrawCall::draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
namespace DrawCall {
|
||||
void draw_arrays(u32 kind, u32 offset, u32 count) {
|
||||
ASSERT(count > 0);
|
||||
glDrawArrays(kind, offset, count);
|
||||
}
|
||||
|
||||
void draw_elements(u32 kind, u32 count, u32 index_kind, u32 offset) {
|
||||
ASSERT(count > 0);
|
||||
glDrawElements(kind, count, index_kind, (void*)offset);
|
||||
}
|
||||
|
||||
void multi_draw_elements(u32 kind,
|
||||
GLsizei* counts,
|
||||
u32 index_kind,
|
||||
void** index_offsets,
|
||||
u32 draw_count) {
|
||||
ASSERT(draw_count > 0);
|
||||
for (u32 i = 0; i < draw_count; i++) {
|
||||
ASSERT(counts[i] > 0);
|
||||
}
|
||||
glMultiDrawElements(kind, counts, index_kind, index_offsets, draw_count);
|
||||
}
|
||||
|
||||
} // namespace DrawCall
|
||||
@@ -55,4 +55,14 @@ class FullScreenDraw {
|
||||
private:
|
||||
GLuint m_vao;
|
||||
GLuint m_vertex_buffer;
|
||||
};
|
||||
};
|
||||
|
||||
namespace DrawCall {
|
||||
void draw_arrays(u32 kind, u32 offset, u32 count);
|
||||
void draw_elements(u32 kind, u32 count, u32 index_kind, u32 offset);
|
||||
void multi_draw_elements(u32 kind,
|
||||
GLsizei* counts,
|
||||
u32 index_kind,
|
||||
void** index_offsets,
|
||||
u32 draw_count);
|
||||
} // namespace DrawCall
|
||||
Reference in New Issue
Block a user