From: ptitSeb Date: Mon, 3 Mar 2014 13:57:21 +0000 (+0100) Subject: GLES2RICE: Update from upstream X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea03ad213a7c83970cdf11e64c769918274ebda2;p=mupen64plus-pandora.git GLES2RICE: Update from upstream --- diff --git a/source/gles2rice/src/Config.cpp b/source/gles2rice/src/Config.cpp index da18f8e..7ac7295 100755 --- a/source/gles2rice/src/Config.cpp +++ b/source/gles2rice/src/Config.cpp @@ -476,7 +476,7 @@ static void ReadConfiguration(void) options.mipmapping = ConfigGetParamInt(l_ConfigVideoRice, "Mipmapping"); //*SEB* Force to 0 has other setting crash on the Pandora - options.mipmapping = 0; + options.mipmapping = TEXTURE_NO_MIPMAP; options.fogMethod = ConfigGetParamInt(l_ConfigVideoRice, "FogMethod"); options.forceTextureFilter = ConfigGetParamInt(l_ConfigVideoRice, "ForceTextureFilter"); options.textureEnhancement = ConfigGetParamInt(l_ConfigVideoRice, "TextureEnhancement"); diff --git a/source/gles2rice/src/OGLES2FragmentShaders.cpp b/source/gles2rice/src/OGLES2FragmentShaders.cpp index 29b8e97..d43fcae 100755 --- a/source/gles2rice/src/OGLES2FragmentShaders.cpp +++ b/source/gles2rice/src/OGLES2FragmentShaders.cpp @@ -35,6 +35,7 @@ const char *vertexShader = "attribute lowp vec2 aTexCoord0; \n"\ "attribute lowp vec2 aTexCoord1; \n"\ "attribute lowp vec2 aAtlasTransform; \n"\ +"attribute mediump float aFogCoord; \n"\ " \n"\ "varying lowp float vFactor; \n"\ "varying lowp vec4 vShadeColor; \n"\ @@ -48,6 +49,7 @@ const char *vertexShader = "vShadeColor = aColor; \n"\ "vTexCoord0 = aTexCoord0; \n"\ "vTexCoord1 = aTexCoord1; \n"\ +"vFog = clamp((FogMinMax[1] - aFogCoord)/(FogMinMax[1]-FogMinMax[0]),0.0,1.0); \n"\ " \n"\ "} \n"\ " \n"; @@ -71,7 +73,6 @@ const char *fragmentHeader = "uniform vec4 FogColor; \n"\ "uniform vec2 FogMinMax; \n"\ " \n"\ -"varying lowp float vFactor; \n"\ "varying lowp vec4 vShadeColor; \n"\ "varying mediump vec2 vTexCoord0; \n"\ "varying lowp vec2 vTexCoord1; \n"\ @@ -80,7 +81,7 @@ const char *fragmentHeader = "{ \n"\ "vec4 comb,comb2; \n"\ " \n"\ -"#ifdef NEED_TEX0 \n"\ +"#ifdef NEED_TEX0 \n"\ "vec4 t0 = texture2D(uTex0,vTexCoord0); \n"\ "#endif \n"\ " \n"\ @@ -91,19 +92,15 @@ const char *fragmentHeader = const char *fragmentFooter = " \n"\ "#ifdef FOG \n"\ -" float z = gl_FragCoord.z * 2.0 - 1.0; \n"\ -" float FogFactor = (FogMinMax[1] - z) / (FogMinMax[1] - FogMinMax[0]); \n"\ -" FogFactor = clamp(FogFactor, 0.0, 1.0); \n"\ -" \n"\ -" gl_FragColor.rgb = mix(FogColor.rgb, comb.rgb, FogFactor ); \n"\ -" gl_FragColor.a = comb.a; \n"\ -"#else \n"\ -" gl_FragColor = comb; \n"\ -"#endif \n"\ -" \n"\ -"#ifdef ALPHA_TEST \n"\ +"gl_FragColor.rgb = mix(FogColor.rgb,comb.rgb,vFog); \n"\ +"gl_FragColor.a = comb.a; \n"\ +"#else \n"\ +"gl_FragColor = comb; \n"\ +"#endif \n"\ +" \n"\ +"#ifdef ALPHA_TEST \n"\ ALPHA_TEST -"#endif \n"\ +"#endif \n"\ "} \n"; //Fragment shader for InitCycleCopy @@ -194,10 +191,10 @@ COGL_FragmentProgramCombiner::COGL_FragmentProgramCombiner(CRender *pRender) m_pDecodedMux = new DecodedMuxForPixelShader; m_bFragmentProgramIsSupported = true; m_AlphaRef = 0.0f; - bAlphaTestState = DISABLE; - bAlphaTestPreviousState = DISABLE; - bFogState = DISABLE; - bFogPreviousState = DISABLE; + bAlphaTestState = false; + bAlphaTestPreviousState = false; + bFogState = false; + bFogPreviousState = false; //Create shaders for fill and copy GLint success; @@ -328,6 +325,8 @@ void COGL_FragmentProgramCombiner::InitCombinerCycleCopy(void) OPENGL_CHECK_ERRORS; glDisableVertexAttribArray(VS_TEXCOORD1); OPENGL_CHECK_ERRORS; + glDisableVertexAttribArray(VS_FOG); + OPENGL_CHECK_ERRORS; COGLTexture* pTexture = g_textures[gRSP.curTile].m_pCOGLTexture; if( pTexture ) { @@ -573,6 +572,8 @@ int COGL_FragmentProgramCombiner::ParseDecodedMux() OPENGL_CHECK_ERRORS; glBindAttribLocation(res.programID,VS_POSITION,"aPosition"); OPENGL_CHECK_ERRORS; + glBindAttribLocation(res.programID,VS_FOG,"aFogCoord"); + OPENGL_CHECK_ERRORS; glLinkProgram(res.programID); OPENGL_CHECK_ERRORS; @@ -650,6 +651,11 @@ void COGL_FragmentProgramCombiner::GenerateCombinerSetting(int index) OPENGL_CHECK_ERRORS; glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) ); OPENGL_CHECK_ERRORS; + + glEnableVertexAttribArray(VS_FOG); + OPENGL_CHECK_ERRORS; + glVertexAttribPointer(VS_FOG,1,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][4])); + OPENGL_CHECK_ERRORS; } void COGL_FragmentProgramCombiner::GenerateCombinerSettingConstants(int index) diff --git a/source/gles2rice/src/OGLGraphicsContext.cpp b/source/gles2rice/src/OGLGraphicsContext.cpp index 6c1f4e8..09acac0 100755 --- a/source/gles2rice/src/OGLGraphicsContext.cpp +++ b/source/gles2rice/src/OGLGraphicsContext.cpp @@ -310,7 +310,7 @@ void COGLGraphicsContext::InitOGLExtension(void) m_bSupportAnisotropicFiltering = IsExtensionSupported("GL_EXT_texture_filter_anisotropic"); #else m_bSupportMultiTexture = true; - m_bSupportFogCoord = false; + m_bSupportFogCoord = true; m_bSupportAnisotropicFiltering = true; #endif // Compute maxAnisotropicFiltering diff --git a/source/gles2rice/src/OGLRender.cpp b/source/gles2rice/src/OGLRender.cpp index 5f25f16..f11798e 100755 --- a/source/gles2rice/src/OGLRender.cpp +++ b/source/gles2rice/src/OGLRender.cpp @@ -198,7 +198,13 @@ void OGLRender::Initialize(void) glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u)); OPENGL_CHECK_ERRORS; } - + + if (m_bSupportFogCoordExt) + { + glVertexAttribPointer(VS_FOG,1,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][4])); + OPENGL_CHECK_ERRORS; + } + glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) ); OPENGL_CHECK_ERRORS; #endif diff --git a/source/gles2rice/src/osal_opengl.h b/source/gles2rice/src/osal_opengl.h index 5fd341c..dd77e67 100755 --- a/source/gles2rice/src/osal_opengl.h +++ b/source/gles2rice/src/osal_opengl.h @@ -51,6 +51,7 @@ #define VS_COLOR 1 #define VS_TEXCOORD0 2 #define VS_TEXCOORD1 3 +#define VS_FOG 4 // Constant substitutions #define GL_CLAMP GL_CLAMP_TO_EDGE