rend: Add per-strip TR sort option

This commit is contained in:
Flyinghead 2019-05-17 19:48:25 +02:00
parent d38e094ba0
commit 433590b610
5 changed files with 44 additions and 20 deletions

View File

@ -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

View File

@ -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);

View File

@ -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<ListType_Translucent,true>(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<ListType_Translucent,true>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count);
}
}
else
DrawList<ListType_Translucent,false>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count);

View File

@ -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);

View File

@ -638,6 +638,7 @@ struct settings_t
bool Fog;
bool FloatVMUs;
bool Rotate90; // Rotate the screen 90 deg CC
bool PerStripSorting;
} rend;
struct