diff --git a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp index e4338b555a..446eebaf25 100644 --- a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp @@ -2032,7 +2032,7 @@ void ZeroGS::SetTexClamping(int context, FRAGMENTSHADER* pfragment) case 3: // region rep x v.x = 0.9999f; - v.z = fw; + v.z = (float)fw; v2.x = (float)GPU_TEXMASKWIDTH / fw; v2.z = pclamp->maxu / fw; int correctMinu = pclamp->minu & (~pclamp->maxu); // (A && B) || C == (A && (B && !C)) + C @@ -2067,7 +2067,7 @@ void ZeroGS::SetTexClamping(int context, FRAGMENTSHADER* pfragment) case 3: // region rep y v.y = 0.9999f; - v.w = fh; + v.w = (float)fh; v2.y = (float)GPU_TEXMASKWIDTH / fh; v2.w = pclamp->maxv / fh; int correctMinv = pclamp->minv & (~pclamp->maxv); // (A && B) || C == (A && (B && !C)) + C diff --git a/plugins/zzogl-pg/opengl/ps2hw.fx b/plugins/zzogl-pg/opengl/ps2hw.fx index 1d372be9bd..c76252ba26 100644 --- a/plugins/zzogl-pg/opengl/ps2hw.fx +++ b/plugins/zzogl-pg/opengl/ps2hw.fx @@ -1,19 +1,4 @@ -// Cg Shaders for PS2 GS emulation -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// Cg Shaders for PS2 GS emulation // divides by z for every pixel, instead of in vertex shader // fixes kh textures @@ -92,7 +77,6 @@ float2 ps2memcoord(float2 realtex) float2 fblock = frac(realtex.xy); off.xy = realtex.xy-fblock.xy; -//#if 0 #ifdef ACCURATE_DECOMPRESSION off.zw = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).ar; off.x = dot(off.xy, g_fTexOffset.xy); @@ -216,9 +200,9 @@ float2 ps2addr(float2 coord) float2 final = frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw)); if( TexWrapMode.x > g_fBilinear.z ) // region repeat mode for x (umsk&x)|ufix - final.x = texRECT(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.zz).x * g_fClampExts.x + g_fClampExts.z; + final.x = texRECT(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.zx).x * g_fClampExts.x + g_fClampExts.z; if( TexWrapMode.y > g_fBilinear.z ) // region repeat mode for x (vmsk&x)|vfix - final.y = texRECT(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.ww).x * g_fClampExts.y + g_fClampExts.w; + final.y = texRECT(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.wy).x * g_fClampExts.y + g_fClampExts.w; return final; } @@ -337,7 +321,7 @@ decl_ps2shade_##num(_tex16to32h) \ // nearest #define decl_ps2shade_0(bit) \ -half4 ps2shade0##bit( TEX_DECL tex) \ +float4 ps2shade0##bit( TEX_DECL tex) \ { \ return tex2DPS##bit( ps2addr(TEX_XY)); \ } \ @@ -745,7 +729,7 @@ half4 BilinearFloat16(float2 tex0) half4 CRTCTargInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR { float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w; - half4 c = BilinearFloat16(tex0); + float4 c = BilinearFloat16(tex0); c.w = ( g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y ) * finter; return c; } diff --git a/plugins/zzogl-pg/opengl/targets.cpp b/plugins/zzogl-pg/opengl/targets.cpp index b27e35be86..74b0cd593b 100644 --- a/plugins/zzogl-pg/opengl/targets.cpp +++ b/plugins/zzogl-pg/opengl/targets.cpp @@ -2543,24 +2543,25 @@ u32 ZeroGS::CBitwiseTextureMngr::GetTexInt(u32 bitvalue, u32 ptexDoNotDelete) if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on generation of bitmask texture."); - vector data(GPU_TEXMASKWIDTH + 1); + vector data(GPU_TEXMASKWIDTH); for (u32 i = 0; i < GPU_TEXMASKWIDTH; ++i) { data[i] = (((i << MASKDIVISOR) & bitvalue) << 6); // add the 1/2 offset so that } + + // data[GPU_TEXMASKWIDTH] = 0; // I remove GPU_TEXMASKWIDTH+1 element of this texture, because it was a reason of FFC crush + // Probably, some sort of PoT incompability in drivers. - data[GPU_TEXMASKWIDTH] = 0; - - glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptex); + glBindTexture(GL_TEXTURE_RECTANGLE, ptex); if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on binding bitmask texture."); - TextureRect(GL_LUMINANCE16, GPU_TEXMASKWIDTH + 1, 1, GL_LUMINANCE, GL_UNSIGNED_SHORT, &data[0]); + TextureRect2(GL_LUMINANCE16, GPU_TEXMASKWIDTH, 1, GL_LUMINANCE, GL_UNSIGNED_SHORT, &data[0]); if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on applying bitmask texture."); // Removing clamping, as it seems lead to numerous troubles at some drivers // Need to observe, may be clamping is not really needed. - /* setTexRectWrap(GL_REPEAT); + /* setRectWrap2(GL_REPEAT); GLint Error = glGetError(); if( Error != GL_NO_ERROR ) { diff --git a/plugins/zzogl-pg/opengl/targets.h b/plugins/zzogl-pg/opengl/targets.h index c055012781..de2061076d 100644 --- a/plugins/zzogl-pg/opengl/targets.h +++ b/plugins/zzogl-pg/opengl/targets.h @@ -345,6 +345,11 @@ static __forceinline void TextureRect(GLint iFormat, GLint width, GLint height, glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, iFormat, width, height, 0, format, type, pixels); } +static __forceinline void TextureRect2(GLint iFormat, GLint width, GLint height, GLenum format, GLenum type, const GLvoid* pixels) +{ + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, iFormat, width, height, 0, format, type, pixels); +} + static __forceinline void TextureRect(GLenum attach, GLuint id = 0) { glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attach, GL_RENDERBUFFER_EXT, id); @@ -386,5 +391,11 @@ static __forceinline void setRectWrap(GLint type) glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, type); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, type); } + +static __forceinline void setRectWrap2(GLint type) +{ + glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, type); + glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, type); +} #endif