From 433590b610c4775032f7686bc40e6a5ea21ef56e Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 17 May 2019 19:48:25 +0200 Subject: [PATCH] rend: Add per-strip TR sort option --- core/hw/pvr/ta.h | 2 -- core/nullDC.cpp | 3 +++ core/rend/gles/gldraw.cpp | 21 +++++++++++---------- core/rend/gui.cpp | 37 +++++++++++++++++++++++++++++-------- core/types.h | 1 + 5 files changed, 44 insertions(+), 20 deletions(-) diff --git a/core/hw/pvr/ta.h b/core/hw/pvr/ta.h index eb8505bf6..e4e649090 100644 --- a/core/hw/pvr/ta.h +++ b/core/hw/pvr/ta.h @@ -20,5 +20,3 @@ void DYNACALL ta_vtx_data32(void* data); void ta_vtx_data(u32* data, u32 size); bool ta_parse_vdrc(TA_context* ctx); - -#define TRIG_SORT 1 diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 1deeebad7..c31e6d5c4 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -521,6 +521,7 @@ void InitSettings() settings.rend.Fog = true; settings.rend.FloatVMUs = false; settings.rend.Rotate90 = false; + settings.rend.PerStripSorting = false; settings.pvr.ta_skip = 0; settings.pvr.rend = 0; @@ -609,6 +610,7 @@ void LoadSettings(bool game_specific) settings.rend.Fog = cfgLoadBool(config_section, "rend.Fog", settings.rend.Fog); settings.rend.FloatVMUs = cfgLoadBool(config_section, "rend.FloatVMUs", settings.rend.FloatVMUs); settings.rend.Rotate90 = cfgLoadBool(config_section, "rend.Rotate90", settings.rend.Rotate90); + settings.rend.PerStripSorting = cfgLoadBool(config_section, "rend.PerStripSorting", settings.rend.PerStripSorting); settings.pvr.ta_skip = cfgLoadInt(config_section, "ta.skip", settings.pvr.ta_skip); settings.pvr.rend = cfgLoadInt(config_section, "pvr.rend", settings.pvr.rend); @@ -759,6 +761,7 @@ void SaveSettings() cfgSaveBool("config", "rend.Rotate90", settings.rend.Rotate90); cfgSaveInt("config", "ta.skip", settings.pvr.ta_skip); cfgSaveInt("config", "pvr.rend", settings.pvr.rend); + cfgSaveBool("config", "rend.PerStripSorting", settings.rend.PerStripSorting); cfgSaveInt("config", "pvr.MaxThreads", settings.pvr.MaxThreads); cfgSaveBool("config", "pvr.SynchronousRendering", settings.pvr.SynchronousRender); diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index f25369414..8c23dd58b 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -260,11 +260,9 @@ __forceinline glcache.DepthFunc(Zfunction[gp->isp.DepthMode]); } -#if TRIG_SORT - if (SortingEnabled) + if (SortingEnabled && !settings.rend.PerStripSorting) glcache.DepthMask(GL_FALSE); else -#endif glcache.DepthMask(!gp->isp.ZWriteDis); } @@ -1105,13 +1103,16 @@ void DrawStrips() { if (current_pass.autosort) { -#if TRIG_SORT - GenSorted(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); - DrawSorted(render_pass < pvrrc.render_passes.used() - 1); -#else - SortPParams(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); - DrawList(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); -#endif + if (!settings.rend.PerStripSorting) + { + GenSorted(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); + DrawSorted(render_pass < pvrrc.render_passes.used() - 1); + } + else + { + SortPParams(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); + DrawList(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); + } } else DrawList(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 4feec179b..d3cfddad8 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -942,20 +942,41 @@ static void gui_display_settings() if (ImGui::BeginTabItem("Video")) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding); -#if !defined(GLES) && HOST_OS != OS_DARWIN - if (!gl.is_gles && gl.gl_major >= 4 && ImGui::CollapsingHeader("Transparent Sorting", ImGuiTreeNodeFlags_DefaultOpen)) + int renderer = settings.pvr.rend == 3 ? 2 : settings.rend.PerStripSorting ? 1 : 0; + bool has_per_pixel = !gl.is_gles && gl.gl_major >= 4; + if (ImGui::CollapsingHeader("Transparent Sorting", ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::Columns(2, "renderers", false); - ImGui::RadioButton("Per Triangle", (int *)&settings.pvr.rend, 0); + ImGui::Columns(has_per_pixel ? 3 : 2, "renderers", false); + ImGui::RadioButton("Per Triangle", &renderer, 0); ImGui::SameLine(); ShowHelpMarker("Sort transparent polygons per triangle. Fast but may produce graphical glitches"); - ImGui::NextColumn(); - ImGui::RadioButton("Per Pixel", (int *)&settings.pvr.rend, 3); + ImGui::NextColumn(); + ImGui::RadioButton("Per Strip", &renderer, 1); ImGui::SameLine(); - ShowHelpMarker("Sort transparent polygons per pixel. Slower but accurate"); + ShowHelpMarker("Sort transparent polygons per strip. Faster but may produce graphical glitches"); + if (has_per_pixel) + { + ImGui::NextColumn(); + ImGui::RadioButton("Per Pixel", &renderer, 2); + ImGui::SameLine(); + ShowHelpMarker("Sort transparent polygons per pixel. Slower but accurate"); + } ImGui::Columns(1, NULL, false); + switch (renderer) + { + case 0: + settings.pvr.rend = 0; + settings.rend.PerStripSorting = false; + break; + case 1: + settings.pvr.rend = 0; + settings.rend.PerStripSorting = true; + break; + case 2: + settings.pvr.rend = 3; + break; + } } -#endif if (ImGui::CollapsingHeader("Rendering Options", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Checkbox("Synchronous Rendering", &settings.pvr.SynchronousRender); diff --git a/core/types.h b/core/types.h index 8b1a039a8..e73863133 100644 --- a/core/types.h +++ b/core/types.h @@ -638,6 +638,7 @@ struct settings_t bool Fog; bool FloatVMUs; bool Rotate90; // Rotate the screen 90 deg CC + bool PerStripSorting; } rend; struct