tfrag improvements (#970)

* tfrag improvements

* cleanup

* one last fix

* clang
This commit is contained in:
water111
2021-11-15 20:07:10 -05:00
committed by GitHub
parent dcbd90a3f3
commit 7292cb5765
25 changed files with 1396 additions and 50 deletions
@@ -71,6 +71,8 @@ void DirectRenderer::draw_debug_window() {
ImGui::Checkbox("red", &m_debug_state.red);
ImGui::SameLine();
ImGui::Checkbox("always", &m_debug_state.always_draw);
ImGui::SameLine();
ImGui::Checkbox("no mip", &m_debug_state.disable_mipmap);
if (m_mode == Mode::SPRITE_CPU) {
ImGui::Checkbox("draw1", &m_sprite_mode.do_first_draw);
@@ -128,6 +130,7 @@ void DirectRenderer::flush_pending(SharedRenderState* render_state, ScopedProfil
m_test_state_needs_gl_update = false;
}
// I think it's important that this comes last.
if (m_texture_state.needs_gl_update) {
update_gl_texture(render_state);
m_texture_state.needs_gl_update = false;
@@ -218,7 +221,10 @@ void DirectRenderer::flush_pending(SharedRenderState* render_state, ScopedProfil
render_state->shaders[ShaderId::SPRITE_CPU_AFAIL].activate();
glDepthMask(GL_FALSE);
glDrawArrays(GL_TRIANGLES, 0, m_prim_buffer.vert_count);
glDepthMask(GL_TRUE);
if (m_test_state.depth_writes) {
glDepthMask(GL_TRUE);
}
m_prim_gl_state_needs_gl_update = true;
m_blend_state_needs_gl_update = true;
draw_count++;
@@ -349,7 +355,8 @@ void DirectRenderer::update_gl_texture(SharedRenderState* render_state) {
}
if (m_texture_state.enable_tex_filt) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
m_debug_state.disable_mipmap ? GL_LINEAR : GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -391,8 +398,9 @@ void DirectRenderer::update_gl_blend() {
void DirectRenderer::update_gl_test() {
const auto& state = m_test_state;
glEnable(GL_DEPTH_TEST);
if (state.zte) {
glEnable(GL_DEPTH_TEST);
switch (state.ztst) {
case GsTest::ZTest::NEVER:
glDepthFunc(GL_NEVER);
@@ -769,13 +777,14 @@ void DirectRenderer::handle_zbuf1(u64 val,
assert(x.psm() == TextureFormat::PSMZ24);
assert(x.zbp() == 448);
bool write = x.zmsk();
bool write = !x.zmsk();
// assert(write);
if (write != m_test_state.depth_writes) {
m_stats.flush_from_zbuf++;
flush_pending(render_state, prof);
m_test_state_needs_gl_update = true;
m_prim_gl_state_needs_gl_update = true;
m_test_state.depth_writes = write;
}
}
@@ -1042,9 +1051,7 @@ void DirectRenderer::TestState::from_register(GsTest reg) {
}
zte = reg.zte();
if (zte) {
ztst = reg.ztest();
}
ztst = reg.ztest();
}
void DirectRenderer::BlendState::from_register(GsAlpha reg) {