zzogl-pg: Add in changes from zzogl r218. (I'll still need to go through r214-217 and grab any important changes, though.)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3659 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-08-18 10:52:57 +00:00
parent 9a5e9e24e1
commit 59262101db
4 changed files with 25 additions and 29 deletions

View File

@ -2032,7 +2032,7 @@ void ZeroGS::SetTexClamping(int context, FRAGMENTSHADER* pfragment)
case 3: // region rep x case 3: // region rep x
v.x = 0.9999f; v.x = 0.9999f;
v.z = fw; v.z = (float)fw;
v2.x = (float)GPU_TEXMASKWIDTH / fw; v2.x = (float)GPU_TEXMASKWIDTH / fw;
v2.z = pclamp->maxu / fw; v2.z = pclamp->maxu / fw;
int correctMinu = pclamp->minu & (~pclamp->maxu); // (A && B) || C == (A && (B && !C)) + C 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 case 3: // region rep y
v.y = 0.9999f; v.y = 0.9999f;
v.w = fh; v.w = (float)fh;
v2.y = (float)GPU_TEXMASKWIDTH / fh; v2.y = (float)GPU_TEXMASKWIDTH / fh;
v2.w = pclamp->maxv / fh; v2.w = pclamp->maxv / fh;
int correctMinv = pclamp->minv & (~pclamp->maxv); // (A && B) || C == (A && (B && !C)) + C int correctMinv = pclamp->minv & (~pclamp->maxv); // (A && B) || C == (A && (B && !C)) + C

View File

@ -1,19 +1,4 @@
// Cg Shaders for PS2 GS emulation // 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
//
// divides by z for every pixel, instead of in vertex shader // divides by z for every pixel, instead of in vertex shader
// fixes kh textures // fixes kh textures
@ -92,7 +77,6 @@ float2 ps2memcoord(float2 realtex)
float2 fblock = frac(realtex.xy); float2 fblock = frac(realtex.xy);
off.xy = realtex.xy-fblock.xy; off.xy = realtex.xy-fblock.xy;
//#if 0
#ifdef ACCURATE_DECOMPRESSION #ifdef ACCURATE_DECOMPRESSION
off.zw = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).ar; off.zw = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).ar;
off.x = dot(off.xy, g_fTexOffset.xy); 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)); 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 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 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; return final;
} }
@ -337,7 +321,7 @@ decl_ps2shade_##num(_tex16to32h) \
// nearest // nearest
#define decl_ps2shade_0(bit) \ #define decl_ps2shade_0(bit) \
half4 ps2shade0##bit( TEX_DECL tex) \ float4 ps2shade0##bit( TEX_DECL tex) \
{ \ { \
return tex2DPS##bit( ps2addr(TEX_XY)); \ 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 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; 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; c.w = ( g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y ) * finter;
return c; return c;
} }

View File

@ -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."); if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on generation of bitmask texture.");
vector<u16> data(GPU_TEXMASKWIDTH + 1); vector<u16> data(GPU_TEXMASKWIDTH);
for (u32 i = 0; i < GPU_TEXMASKWIDTH; ++i) for (u32 i = 0; i < GPU_TEXMASKWIDTH; ++i)
{ {
data[i] = (((i << MASKDIVISOR) & bitvalue) << 6); // add the 1/2 offset so that data[i] = (((i << MASKDIVISOR) & bitvalue) << 6); // add the 1/2 offset so that
} }
data[GPU_TEXMASKWIDTH] = 0; // 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.
glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptex); glBindTexture(GL_TEXTURE_RECTANGLE, ptex);
if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on binding bitmask texture."); 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."); 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 // Removing clamping, as it seems lead to numerous troubles at some drivers
// Need to observe, may be clamping is not really needed. // Need to observe, may be clamping is not really needed.
/* setTexRectWrap(GL_REPEAT); /* setRectWrap2(GL_REPEAT);
GLint Error = glGetError(); GLint Error = glGetError();
if( Error != GL_NO_ERROR ) { if( Error != GL_NO_ERROR ) {

View File

@ -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); 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) static __forceinline void TextureRect(GLenum attach, GLuint id = 0)
{ {
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attach, GL_RENDERBUFFER_EXT, id); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attach, GL_RENDERBUFFER_EXT, id);
@ -387,4 +392,10 @@ static __forceinline void setRectWrap(GLint type)
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, 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 #endif