Skip to content

Commit

Permalink
video: test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fzurita committed Mar 8, 2016
1 parent 2e3754f commit ec7da6e
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 30 deletions.
98 changes: 71 additions & 27 deletions jni/mupen64plus-video-gliden64/src/OGL3X/GLSLCombiner_ogl3x.cpp
Expand Up @@ -285,16 +285,55 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
char strCombiner[1024];
m_nInputs = compileCombiner(_color, _alpha, strCombiner);

if (usesTexture()) {
strFragmentShader.assign(fragment_shader_header_common_variables);
strFragmentShader.append(fragment_shader_header_common_functions);
}
else {
strFragmentShader.assign(fragment_shader_header_common_variables_notex);
strFragmentShader.append(fragment_shader_header_common_functions_notex);
}
const bool bUseLod = usesLOD();
const bool bUseHWLight = config.generalEmulation.enableHWLighting != 0 && GBI.isHWLSupported() && usesShadeColor();

if (usesTexture ())
{
strFragmentShader.assign (fragment_shader_header_common_variables);
strFragmentShader.append (fragment_shader_header_noise);
strFragmentShader.append (fragment_shader_header_noise_dither);

if (bUseLod)
{
strFragmentShader.append (fragment_shader_header_mipmap);
}
else
{
strFragmentShader.append (fragment_shader_header_readTex);
#ifdef GL_MULTISAMPLING_SUPPORT
if (config.video.multisampling > 0)
strFragmentShader.append(fragment_shader_header_readTexMS);
#endif
}
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (video().getRender().isImageTexturesSupported() && config.frameBufferEmulation.N64DepthCompare != 0)
strFragmentShader.append(fragment_shader_header_depth_compare);
#endif

if (bUseHWLight)
{
strFragmentShader.append (fragment_shader_header_calc_light);
}
}
else
{
strFragmentShader.assign (fragment_shader_header_common_variables_notex);
strFragmentShader.append (fragment_shader_header_noise);
strFragmentShader.append (fragment_shader_header_noise_dither);

#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (video().getRender().isImageTexturesSupported() && config.frameBufferEmulation.N64DepthCompare != 0)
strFragmentShader.append(fragment_shader_header_depth_compare);
#endif

if (bUseHWLight)
{
strFragmentShader.append (fragment_shader_header_calc_light);
}
}

strFragmentShader.append(fragment_shader_header_main);
const bool bUseLod = usesLOD();
if (bUseLod) {
strFragmentShader.append(" lowp vec4 readtex0, readtex1; \n");
strFragmentShader.append(" lowp float lod_frac = mipmap(readtex0, readtex1); \n");
Expand Down Expand Up @@ -323,7 +362,6 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
strFragmentShader.append(" lowp vec4 readtex1 = readTex(uTex1, vTexCoord1, uFbMonochrome[1], uFbFixedAlpha[1] != 0); \n");
#endif // GL_MULTISAMPLING_SUPPORT
}
const bool bUseHWLight = config.generalEmulation.enableHWLighting != 0 && GBI.isHWLSupported() && usesShadeColor();
if (bUseHWLight)
strFragmentShader.append(" calc_light(vNumLights, vShadeColor.rgb, input_color); \n");
else
Expand Down Expand Up @@ -392,23 +430,29 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
glCompileShader(fragmentShader);
if (!checkShaderCompileStatus(fragmentShader))
{
int pos = 0;
int max = 800;
LOG(LOG_ERROR, "Error in fragment shader");

while(pos < strFragmentShader.length() )
{
if(strFragmentShader.length() - pos < max)
{
LOG(LOG_ERROR, "%s", strFragmentShader.substr(pos).data());
}
else
{
LOG(LOG_ERROR, "%s", strFragmentShader.substr(pos, max).data());
}

pos += max;
}
LOG(LOG_ERROR, "Error in fragment shader");

int pos = 0;
int max = 800;

while(pos < strFragmentShader.length() )
{
if(strFragmentShader.length() - pos < max)
{
LOG(LOG_ERROR, "%s", strFragmentShader.substr(pos).data());
}
else
{
LOG(LOG_ERROR, "%s", strFragmentShader.substr(pos, max).data());
}

pos += max;
}
}
else
{
LOG(LOG_ERROR, "NO Error in fragment shader");

}

m_program = glCreateProgram();
Expand Down
30 changes: 27 additions & 3 deletions jni/mupen64plus-video-gliden64/src/OGL3X/Shaders_ogl3x.h
Expand Up @@ -216,6 +216,30 @@ MAIN_SHADER_VERSION
"out lowp vec4 fragColor; \n"
;

static const char* fragment_shader_header_noise =
"lowp float snoise();\n";
static const char* fragment_shader_header_calc_light =
"void calc_light(in lowp float fLights, in lowp vec3 input_color, out lowp vec3 output_color);\n";
static const char* fragment_shader_header_mipmap =
"mediump float mipmap(out lowp vec4 readtex0, out lowp vec4 readtex1);\n";
static const char* fragment_shader_header_readTex =
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha);\n";
#ifdef GL_MULTISAMPLING_SUPPORT
static const char* fragment_shader_header_readTexMS =
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha);\n";
#endif // GL_MULTISAMPLING_SUPPORT
#ifdef GL_IMAGE_TEXTURES_SUPPORT
static const char* fragment_shader_header_depth_compare =
"bool depth_compare();\n";
#endif // GL_IMAGE_TEXTURES_SUPPORT
static const char* fragment_shader_header_noise_dither =
"void colorNoiseDither(in lowp float _noise, inout lowp vec3 _color);\n"
"void alphaNoiseDither(in lowp float _noise, inout lowp float _alpha);\n";
#ifdef USE_TOONIFY
static const char* fragment_shader_header_alpha_noise_toonify =
"void toonify(in mediump float intensity);\n"
#endif
/*
static const char* fragment_shader_header_common_functions =
" \n"
"lowp float snoise(); \n"
Expand All @@ -226,8 +250,8 @@ static const char* fragment_shader_header_common_functions =
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in mediump vec2 texCoord, in lowp int fbMonochrome, in bool fbFixedAlpha); \n"
#endif // GL_MULTISAMPLING_SUPPORT
#ifdef GL_IMAGE_TEXTURES_SUPPORT
"bool depth_compare(); "
#endif // GL_IMAGE_TEXTURES_SUPPORT \n"
"bool depth_compare(); \n"
#endif // GL_IMAGE_TEXTURES_SUPPORT
"void colorNoiseDither(in lowp float _noise, inout lowp vec3 _color); \n"
"void alphaNoiseDither(in lowp float _noise, inout lowp float _alpha);\n"
#ifdef USE_TOONIFY
Expand All @@ -245,7 +269,7 @@ static const char* fragment_shader_header_common_functions_notex =
"void colorNoiseDither(in lowp float _noise, inout lowp vec3 _color); \n"
"void alphaNoiseDither(in lowp float _noise, inout lowp float _alpha);\n"
;

*/
static const char* fragment_shader_calc_light =
AUXILIARY_SHADER_VERSION
"layout (std140) uniform LightBlock { \n"
Expand Down

0 comments on commit ec7da6e

Please sign in to comment.