Add a "force no texture filter" option, useful for some 2D games (like Mega Man 10) and people who like their pixelated graphics.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7431 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
smelenchuk 2011-04-01 01:35:07 +00:00
parent 783c89f108
commit 15c51c37f3
7 changed files with 24 additions and 3 deletions

View File

@ -248,6 +248,7 @@ wxString scaled_efb_copy_tooltip = wxTRANSLATE("Uses the high-resolution render
wxString pixel_lighting_tooltip = wxTRANSLATE("Calculates lighting of 3D graphics on a per-pixel basis rather than per vertex.\nThis is the more accurate behavior but reduces performance."); wxString pixel_lighting_tooltip = wxTRANSLATE("Calculates lighting of 3D graphics on a per-pixel basis rather than per vertex.\nThis is the more accurate behavior but reduces performance.");
wxString pixel_depth_tooltip = wxT(""); wxString pixel_depth_tooltip = wxT("");
wxString force_filtering_tooltip = wxTRANSLATE("Forces bilinear texture filtering even if the game explicitly disabled it.\nImproves texture quality (especially when using a high internal resolution) but causes glitches in some games."); wxString force_filtering_tooltip = wxTRANSLATE("Forces bilinear texture filtering even if the game explicitly disabled it.\nImproves texture quality (especially when using a high internal resolution) but causes glitches in some games.");
wxString force_no_filtering_tooltip = wxTRANSLATE("Forces no texture filtering even if the game explicitly enabled it.\nGood for some 2D games.");
wxString _3d_vision_tooltip = wxT(""); wxString _3d_vision_tooltip = wxT("");
wxString internal_res_tooltip = wxTRANSLATE("Specifies the resolution used to render at. A high resolution will improve visual quality but is also quite heavy on performance and might cause glitches in certain games.\nFractional: Uses your display resolution directly instead of the native resolution. The quality scales with your display/window size, as does the performance impact.\nIntegral: This is like Fractional, but rounds up to an integer multiple of the native resolution. Should give a more accurate look but is usually slower.\nThe other options are fixed resolutions for choosing a visual quality independent of your display size."); wxString internal_res_tooltip = wxTRANSLATE("Specifies the resolution used to render at. A high resolution will improve visual quality but is also quite heavy on performance and might cause glitches in certain games.\nFractional: Uses your display resolution directly instead of the native resolution. The quality scales with your display/window size, as does the performance impact.\nIntegral: This is like Fractional, but rounds up to an integer multiple of the native resolution. Should give a more accurate look but is usually slower.\nThe other options are fixed resolutions for choosing a visual quality independent of your display size.");
wxString efb_access_tooltip = wxTRANSLATE("Allows the CPU to read or write to the EFB (render buffer).\nThis is needed for certain gameplay functionality (e.g. star pointer in Super Mario Galaxy) as well as for certain visual effects (e.g. Monster Hunter Tri),\nbut enabling this option can also have a huge negative impact on performance if the game uses this functionality heavily."); wxString efb_access_tooltip = wxTRANSLATE("Allows the CPU to read or write to the EFB (render buffer).\nThis is needed for certain gameplay functionality (e.g. star pointer in Super Mario Galaxy) as well as for certain visual effects (e.g. Monster Hunter Tri),\nbut enabling this option can also have a huge negative impact on performance if the game uses this functionality heavily.");
@ -441,6 +442,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
szr_enh->Add(pixel_lighting = new SettingCheckBox(page_general, _("Pixel Lighting"), wxGetTranslation(pixel_lighting_tooltip), SET_PARAMS(bEnablePixelLighting), false, cb_style)); szr_enh->Add(pixel_lighting = new SettingCheckBox(page_general, _("Pixel Lighting"), wxGetTranslation(pixel_lighting_tooltip), SET_PARAMS(bEnablePixelLighting), false, cb_style));
szr_enh->Add(pixel_depth = new SettingCheckBox(page_general, _("Pixel Depth"), wxGetTranslation(pixel_depth_tooltip), SET_PARAMS(bEnablePerPixelDepth), false, cb_style)); szr_enh->Add(pixel_depth = new SettingCheckBox(page_general, _("Pixel Depth"), wxGetTranslation(pixel_depth_tooltip), SET_PARAMS(bEnablePerPixelDepth), false, cb_style));
szr_enh->Add(force_filtering = new SettingCheckBox(page_general, _("Force Bi/Trilinear Filtering"), wxGetTranslation(force_filtering_tooltip), SET_PARAMS(bForceFiltering), false, cb_style)); szr_enh->Add(force_filtering = new SettingCheckBox(page_general, _("Force Bi/Trilinear Filtering"), wxGetTranslation(force_filtering_tooltip), SET_PARAMS(bForceFiltering), false, cb_style));
szr_enh->Add(force_no_filtering = new SettingCheckBox(page_general, _("Force No Filtering"), wxGetTranslation(force_no_filtering_tooltip), SET_PARAMS(bForceNoFiltering), false, cb_style));
_3d_vision = new SettingCheckBox(page_general, _("3D Vision (Requires Fullscreen)"), wxGetTranslation(_3d_vision_tooltip), SET_PARAMS(b3DVision), false, cb_style); _3d_vision = new SettingCheckBox(page_general, _("3D Vision (Requires Fullscreen)"), wxGetTranslation(_3d_vision_tooltip), SET_PARAMS(b3DVision), false, cb_style);
szr_enh->Add(_3d_vision); szr_enh->Add(_3d_vision);
@ -712,6 +714,7 @@ void VideoConfigDiag::ChangeStyle()
CHANGE_DATAREF(pixel_lighting, bEnablePixelLighting); CHANGE_DATAREF(pixel_lighting, bEnablePixelLighting);
CHANGE_DATAREF(pixel_depth, bEnablePerPixelDepth); CHANGE_DATAREF(pixel_depth, bEnablePerPixelDepth);
CHANGE_DATAREF(force_filtering, bForceFiltering); CHANGE_DATAREF(force_filtering, bForceFiltering);
CHANGE_DATAREF(force_no_filtering, bForceNoFiltering);
CHANGE_DATAREF(_3d_vision, b3DVision); CHANGE_DATAREF(_3d_vision, b3DVision);
if (cur_profile == 0) choice_efbscale->Delete(0); if (cur_profile == 0) choice_efbscale->Delete(0);
@ -938,6 +941,7 @@ void VideoConfigDiag::SetUIValuesFromConfig()
SET_CHOICE(pixel_lighting, bEnablePixelLighting); SET_CHOICE(pixel_lighting, bEnablePixelLighting);
SET_CHOICE(pixel_depth, bEnablePerPixelDepth); SET_CHOICE(pixel_depth, bEnablePerPixelDepth);
SET_CHOICE(force_filtering, bForceFiltering); SET_CHOICE(force_filtering, bForceFiltering);
SET_CHOICE(force_no_filtering, bForceNoFiltering);
SET_CHOICE(_3d_vision, b3DVision); SET_CHOICE(_3d_vision, b3DVision);
SET_CHOICE(choice_efbscale, iEFBScale); SET_CHOICE(choice_efbscale, iEFBScale);

View File

@ -261,6 +261,7 @@ protected:
SettingCheckBox* pixel_lighting; SettingCheckBox* pixel_lighting;
SettingCheckBox* pixel_depth; SettingCheckBox* pixel_depth;
SettingCheckBox* force_filtering; SettingCheckBox* force_filtering;
SettingCheckBox* force_no_filtering;
SettingCheckBox* _3d_vision; SettingCheckBox* _3d_vision;
SettingChoice* choice_efbscale; SettingChoice* choice_efbscale;

View File

@ -102,6 +102,7 @@ void VideoConfig::Load(const char *main_ini_file, bool filecheck_passed, const c
#endif #endif
SET_STATE(iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, false), bForceFiltering); SET_STATE(iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, false), bForceFiltering);
SET_STATE(iniFile.Get("Enhancements", "ForceNoFiltering", &bForceNoFiltering, false), bForceNoFiltering);
SET_STATE(iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 0), iMaxAnisotropy); // NOTE - this is x in (1 << x) SET_STATE(iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 0), iMaxAnisotropy); // NOTE - this is x in (1 << x)
iniFile.Get("Enhancements", "PostProcessingShader", &sPostProcessingShader, ""); iniFile.Get("Enhancements", "PostProcessingShader", &sPostProcessingShader, "");
SET_STATE(iniFile.Get("Enhancements", "Enable3dVision", &b3DVision, false), b3DVision); SET_STATE(iniFile.Get("Enhancements", "Enable3dVision", &b3DVision, false), b3DVision);
@ -195,6 +196,7 @@ void VideoConfig::GameIniLoad(const char *ini_file)
SET_UISTATE(iniFile.GetIfExists("Video_Settings", "OMPDecoder", &bOMPDecoder), bOMPDecoder); SET_UISTATE(iniFile.GetIfExists("Video_Settings", "OMPDecoder", &bOMPDecoder), bOMPDecoder);
#endif #endif
SET_UISTATE(iniFile.GetIfExists("Video_Enhancements", "ForceFiltering", &bForceFiltering), bForceFiltering); SET_UISTATE(iniFile.GetIfExists("Video_Enhancements", "ForceFiltering", &bForceFiltering), bForceFiltering);
SET_UISTATE(iniFile.GetIfExists("Video_Enhancements", "ForceNoFiltering", &bForceNoFiltering), bForceNoFiltering);
SET_UISTATE(iniFile.GetIfExists("Video_Enhancements", "MaxAnisotropy", &iMaxAnisotropy), iMaxAnisotropy); // NOTE - this is x in (1 << x) SET_UISTATE(iniFile.GetIfExists("Video_Enhancements", "MaxAnisotropy", &iMaxAnisotropy), iMaxAnisotropy); // NOTE - this is x in (1 << x)
iniFile.GetIfExists("Video_Enhancements", "PostProcessingShader", &sPostProcessingShader); iniFile.GetIfExists("Video_Enhancements", "PostProcessingShader", &sPostProcessingShader);
@ -294,6 +296,7 @@ void VideoConfig::Save(const char *ini_file)
#endif #endif
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering); iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "ForceNoFiltering", bForceNoFiltering);
iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy); iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy);
iniFile.Set("Enhancements", "PostProcessingShader", sPostProcessingShader); iniFile.Set("Enhancements", "PostProcessingShader", sPostProcessingShader);
iniFile.Set("Enhancements", "Enable3dVision", b3DVision); iniFile.Set("Enhancements", "Enable3dVision", b3DVision);
@ -377,6 +380,7 @@ void VideoConfig::GameIniSave(const char* default_ini, const char* game_ini)
#endif #endif
CHECK_UISTATE("Video_Enhancements", "ForceFiltering", bForceFiltering); CHECK_UISTATE("Video_Enhancements", "ForceFiltering", bForceFiltering);
CHECK_UISTATE("Video_Enhancements", "ForceNoFiltering", bForceNoFiltering);
CHECK_UISTATE("Video_Enhancements", "MaxAnisotropy", iMaxAnisotropy); // NOTE - this is x in (1 << x) CHECK_UISTATE("Video_Enhancements", "MaxAnisotropy", iMaxAnisotropy); // NOTE - this is x in (1 << x)
iniFile.Set("Video_Enhancements", "PostProcessingShader", sPostProcessingShader); iniFile.Set("Video_Enhancements", "PostProcessingShader", sPostProcessingShader);
CHECK_UISTATE("Video_Enhancements", "Enable3dVision", b3DVision); CHECK_UISTATE("Video_Enhancements", "Enable3dVision", b3DVision);

View File

@ -96,6 +96,7 @@ public:
int iMultisampleMode; int iMultisampleMode;
int iEFBScale; int iEFBScale;
bool bForceFiltering; bool bForceFiltering;
bool bForceNoFiltering;
int iMaxAnisotropy; int iMaxAnisotropy;
std::string sPostProcessingShader; std::string sPostProcessingShader;
@ -172,6 +173,7 @@ public:
bool iMultisampleMode; bool iMultisampleMode;
bool iEFBScale; bool iEFBScale;
bool bForceFiltering; bool bForceFiltering;
bool bForceNoFiltering;
bool iMaxAnisotropy; bool iMaxAnisotropy;
bool bShowFPS; bool bShowFPS;
bool bShowInputDisplay; bool bShowInputDisplay;

View File

@ -1346,6 +1346,10 @@ void Renderer::SetSamplerState(int stage, int texindex)
{ {
gx_state.sampdc[stage].Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; gx_state.sampdc[stage].Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
} }
else if (g_ActiveConfig.bForceNoFiltering)
{
gx_state.sampdc[stage].Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
}
else if (tm0.min_filter & 4) // linear min filter else if (tm0.min_filter & 4) // linear min filter
{ {
if (tm0.mag_filter) // linear mag filter if (tm0.mag_filter) // linear mag filter
@ -1390,4 +1394,4 @@ void Renderer::SetInterlacingMode()
// TODO // TODO
} }
} // namespace DX11 } // namespace DX11

View File

@ -1381,6 +1381,10 @@ void Renderer::SetSamplerState(int stage, int texindex)
{ {
min = mag = mip = D3DTEXF_LINEAR; min = mag = mip = D3DTEXF_LINEAR;
} }
else if (g_ActiveConfig.bForceNoFiltering)
{
min = mag = mip = D3DTEXF_POINT;
}
else else
{ {
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT; min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;

View File

@ -348,13 +348,15 @@ void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, co
//mode1 = newmode1; //mode1 = newmode1;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
(newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST); ((newmode.mag_filter && !g_Config.bForceNoFiltering) || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST);
if (bHaveMipMaps) if (bHaveMipMaps)
{ {
// TODO: not used anywhere // TODO: not used anywhere
if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4) if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4)
mode.min_filter += 4; // take equivalent forced linear mode.min_filter += 4; // take equivalent forced linear
else if (g_ActiveConfig.bForceNoFiltering && newmode.min_filter >= 4)
mode.min_filter -= 4;
int filt = newmode.min_filter; int filt = newmode.min_filter;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt & 7]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt & 7]);
@ -364,7 +366,7 @@ void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, co
} }
else else
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
(g_ActiveConfig.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST); (g_ActiveConfig.bForceFiltering || (newmode.min_filter >= 4 && !g_ActiveConfig.bForceNoFiltering)) ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, c_WrapSettings[newmode.wrap_s]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, c_WrapSettings[newmode.wrap_s]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, c_WrapSettings[newmode.wrap_t]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, c_WrapSettings[newmode.wrap_t]);