Skip to content

Commit

Permalink
Make the hybrid texture filter optional through configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fzurita authored and gonetz committed Feb 12, 2020
1 parent 0692abe commit 0a5216f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void Config::resetToDefaults()
generalEmulation.enableCustomSettings = 1;
generalEmulation.enableShadersStorage = 1;
generalEmulation.enableLegacyBlending = 0;
generalEmulation.enableHybridFilter = 1;
generalEmulation.hacks = 0;
#if defined(OS_ANDROID) || defined(OS_IOS)
generalEmulation.enableFragmentDepthWrite = 0;
Expand Down
1 change: 1 addition & 0 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct Config
u32 enableCustomSettings;
u32 enableShadersStorage;
u32 enableLegacyBlending;
u32 enableHybridFilter;
u32 enableFragmentDepthWrite;
u32 enableBlitScreenWorkaround;
u32 hacks;
Expand Down
49 changes: 25 additions & 24 deletions src/Graphics/OpenGLContext/GLSL/glsl_SpecialShadersFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <Graphics/ObjectHandle.h>
#include <Graphics/ShaderProgram.h>
#include <Graphics/OpenGLContext/opengl_CachedFunctions.h>
#include <Config.h>
#include "glsl_SpecialShadersFactory.h"
#include "glsl_ShaderPart.h"
#include "glsl_FXAA.h"
Expand Down Expand Up @@ -448,17 +449,7 @@ namespace glsl {
public:
TexrectCopy(const opengl::GLInfo & _glinfo)
{
if (_glinfo.isGLES2) {
m_part =
"IN mediump vec2 vTexCoord0; \n"
"uniform sampler2D uTex0; \n"
"OUT lowp vec4 fragColor; \n"
" \n"
"void main() \n"
"{ \n"
" fragColor = texture2D(uTex0, vTexCoord0); \n"
;
} else {
if (config.generalEmulation.enableHybridFilter) {
m_part = getHybridTextureFilter();
m_part +=
"IN mediump vec2 vTexCoord0; \n"
Expand All @@ -468,6 +459,16 @@ namespace glsl {
"{ \n"
" fragColor = hybridFilter(vTexCoord0); \n"
;
} else {
m_part =
"IN mediump vec2 vTexCoord0; \n"
"uniform sampler2D uTex0; \n"
"OUT lowp vec4 fragColor; \n"
" \n"
"void main() \n"
"{ \n"
" fragColor = texture2D(uTex0, vTexCoord0); \n"
;
}
}
};
Expand All @@ -479,19 +480,7 @@ namespace glsl {
public:
TexrectColorAndDepthCopy(const opengl::GLInfo & _glinfo)
{
if (_glinfo.isGLES2) {
m_part =
"IN mediump vec2 vTexCoord0; \n"
"uniform sampler2D uTex0; \n"
"uniform sampler2D uTex1; \n"
"OUT lowp vec4 fragColor; \n"
" \n"
"void main() \n"
"{ \n"
" fragColor = texture2D(uTex0, vTexCoord0); \n"
" gl_FragDepth = texture2D(uTex1, vTexCoord0).r; \n"
;
} else {
if (config.generalEmulation.enableHybridFilter) {
m_part = getHybridTextureFilter();
m_part +=
"IN mediump vec2 vTexCoord0; \n"
Expand All @@ -503,6 +492,18 @@ namespace glsl {
" fragColor = hybridFilter(vTexCoord0); \n"
" gl_FragDepth = texture2D(uTex1, vTexCoord0).r; \n"
;
} else {
m_part =
"IN mediump vec2 vTexCoord0; \n"
"uniform sampler2D uTex0; \n"
"uniform sampler2D uTex1; \n"
"OUT lowp vec4 fragColor; \n"
" \n"
"void main() \n"
"{ \n"
" fragColor = texture2D(uTex0, vTexCoord0); \n"
" gl_FragDepth = texture2D(uTex1, vTexCoord0).r; \n"
;
}
}
};
Expand Down
4 changes: 3 additions & 1 deletion src/Graphics/OpenGLContext/opengl_GLInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ void GLInfo::init() {

const bool imageTexturesInterlock = imageTextures && (fragment_interlock || fragment_interlockNV || fragment_ordering);

if (isGLES2)
if (isGLES2) {
config.generalEmulation.enableFragmentDepthWrite = 0;
config.generalEmulation.enableHybridFilter = 0;
}

bufferStorage = (!isGLESX && (numericVersion >= 44)) || Utils::isExtensionSupported(*this, "GL_ARB_buffer_storage") ||
Utils::isExtensionSupported(*this, "GL_EXT_buffer_storage");
Expand Down
3 changes: 3 additions & 0 deletions src/mupenplus/Config_mupenplus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ bool Config_SetDefault()
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableLegacyBlending", config.generalEmulation.enableLegacyBlending, "Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableHybridFilter", config.generalEmulation.enableHybridFilter, "Enable hybrid integer scaling filter, this can be slow with low-end GPUs");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableFragmentDepthWrite", config.generalEmulation.enableFragmentDepthWrite, "Enable writing of fragment depth. Some mobile GPUs do not support it, thus it made optional. Leave enabled.");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableCustomSettings", config.generalEmulation.enableCustomSettings, "Use GLideN64 per-game settings.");
Expand Down Expand Up @@ -397,6 +399,7 @@ void Config_LoadConfig()
config.generalEmulation.enableHWLighting = ConfigGetParamBool(g_configVideoGliden64, "EnableHWLighting");
config.generalEmulation.enableShadersStorage = ConfigGetParamBool(g_configVideoGliden64, "EnableShadersStorage");
config.generalEmulation.enableLegacyBlending = ConfigGetParamBool(g_configVideoGliden64, "EnableLegacyBlending");
config.generalEmulation.enableHybridFilter = ConfigGetParamBool(g_configVideoGliden64, "EnableHybridFilter");
config.generalEmulation.enableFragmentDepthWrite = ConfigGetParamBool(g_configVideoGliden64, "EnableFragmentDepthWrite");
config.generalEmulation.enableCustomSettings = ConfigGetParamBool(g_configVideoGliden64, "EnableCustomSettings");
#if defined(OS_ANDROID) || defined(OS_IOS)
Expand Down

0 comments on commit 0a5216f

Please sign in to comment.