little fix for issue 3976.

some optimization for vertex color loading, please test  for any change in game color, this is a optimization so nothing should change :)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6908 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado 2011-01-24 21:26:39 +00:00
parent d2544158df
commit 470ed118f5
3 changed files with 32 additions and 40 deletions

View File

@ -26,7 +26,7 @@
// shader cache for every revision, graphics-related or not, which is simply annoying.
enum
{
LINEAR_DISKCACHE_VER = 6792
LINEAR_DISKCACHE_VER = 6908
};
// On disk format:

View File

@ -567,7 +567,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
if (!Pretest)
{
// alpha test will always fail, so restart the shader and just make it an empty function
WRITE(p, "ocol0 = 0;\n");
WRITE(p, "ocol0 = float4(0.0f,0.0f,0.0f,0.0f);\n");
if(DepthTextureEnable)
WRITE(p, "depth = 1.f;\n");
WRITE(p, "discard;\n");
@ -798,7 +798,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
{
// alpha test will always fail, so restart the shader and just make it an empty function
p = pmainstart;
WRITE(p, "ocol0 = 0;\n");
WRITE(p, "ocol0 = float4(0.0f,0.0f,0.0f,0.0f);\n");
if(DepthTextureEnable)
WRITE(p, "depth = 1.f;\n");
WRITE(p, "discard;\n");
@ -1305,7 +1305,7 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType)
compindex = bpmem.alphaFunc.comp1 % 8;
WRITE(p, tevAlphaFuncsTable[compindex],alphaRef[1]);//lookup the second component from the alpha function table
WRITE(p, ")){ocol0 = 0;%sdiscard;%s}\n",DepthTextureEnable ? "depth = 1.f;" : "",(ApiType != API_D3D11)? "return;" : "");
WRITE(p, ")){ocol0 = float4(0.0f,0.0f,0.0f,0.0f);%sdiscard;%s}\n",DepthTextureEnable ? "depth = 1.f;" : "",(ApiType != API_D3D11)? "return;" : "");
return true;
}

View File

@ -29,6 +29,7 @@
#define GSHIFT 8
#define BSHIFT 16
#define ASHIFT 24
#define AMASK (0xFF << ASHIFT)
extern int colIndex;
extern int colElements[2];
@ -40,12 +41,13 @@ __forceinline void _SetCol(u32 val)
colIndex++;
}
//Read 4444 directly from unswaped val so intead or RGBA yo get BARG
__forceinline void _SetCol4444(u16 val)
{
u32 col = Convert4To8(val & 0xF) << ASHIFT;
col |= Convert4To8((val >> 12) & 0xF) << RSHIFT;
col |= Convert4To8((val >> 8) & 0xF) << GSHIFT;
col |= Convert4To8((val >> 4) & 0xF) << BSHIFT;
u32 col = Convert4To8(val & 0xF) << GSHIFT;
col |= Convert4To8((val >> 12) & 0xF) << BSHIFT;
col |= Convert4To8((val >> 8) & 0xF) << ASHIFT;
col |= Convert4To8((val >> 4) & 0xF) << RSHIFT;
_SetCol(col);
}
@ -63,13 +65,12 @@ __forceinline void _SetCol565(u16 val)
u32 col = Convert5To8((val >> 11) & 0x1F) << RSHIFT;
col |= Convert6To8((val >> 5) & 0x3F) << GSHIFT;
col |= Convert5To8(val & 0x1F) << BSHIFT;
_SetCol(col | (0xFF << ASHIFT));
_SetCol(col | AMASK);
}
__forceinline u32 _Read24(const u8 *addr)
{
return addr[0] | (addr[1] << 8) | (addr[2] << 16) | 0xFF000000;
return Common::swap32(addr) | AMASK;
}
__forceinline u32 _Read32(const u8 *addr)
@ -77,38 +78,33 @@ __forceinline u32 _Read32(const u8 *addr)
return *(const u32 *)addr;
}
void LOADERDECL Color_ReadDirect_24b_888()
{
u32 col = DataReadU8() << RSHIFT;
col |= DataReadU8() << GSHIFT;
col |= DataReadU8() << BSHIFT;
_SetCol(col | (0xFF << ASHIFT));
_SetCol(_Read24(DataGetPosition()));
DataSkip(3);
}
void LOADERDECL Color_ReadDirect_32b_888x(){
u32 col = DataReadU8() << RSHIFT;
col |= DataReadU8() << GSHIFT;
col |= DataReadU8() << BSHIFT;
_SetCol(col | (0xFF << ASHIFT));
DataReadU8();
void LOADERDECL Color_ReadDirect_32b_888x()
{
_SetCol(_Read24(DataGetPosition()));
DataSkip(4);
}
void LOADERDECL Color_ReadDirect_16b_565()
{
_SetCol565(DataReadU16());
}
void LOADERDECL Color_ReadDirect_16b_4444()
{
_SetCol4444(DataReadU16());
_SetCol4444(((const u16*)DataGetPosition())[0]);
DataSkip(2);
}
void LOADERDECL Color_ReadDirect_24b_6666()
{
u32 val = DataReadU8() << 16;
val |= DataReadU8() << 8;
val |= DataReadU8();
_SetCol6666(val);
_SetCol6666(((const u32*)(DataGetPosition() - 1))[0]);
DataSkip(3);
}
// F|RES: i am not 100 percent sure, but the colElements seems to be important for rendering only
@ -125,7 +121,7 @@ void LOADERDECL Color_ReadDirect_32b_8888()
// "kill" the alpha
if (!colElements[colIndex])
col |= 0xFF << ASHIFT;
col |= AMASK;
_SetCol(col);
}
@ -153,15 +149,14 @@ void LOADERDECL Color_ReadIndex8_32b_888x()
void LOADERDECL Color_ReadIndex8_16b_4444()
{
u8 Index = DataReadU8();
u16 val = Common::swap16(*(const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])));
u16 val = ((const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])))[0];
_SetCol4444(val);
}
void LOADERDECL Color_ReadIndex8_24b_6666()
{
u8 Index = DataReadU8();
const u8* pData = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u32 val = pData[2] | (pData[1] << 8) | (pData[0] << 16);
_SetCol6666(val);
const u32* pData = (const u32*)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]) - 1);
_SetCol6666(pData[0]);
}
void LOADERDECL Color_ReadIndex8_32b_8888()
{
@ -170,8 +165,6 @@ void LOADERDECL Color_ReadIndex8_32b_8888()
_SetCol(_Read32(iAddress));
}
void LOADERDECL Color_ReadIndex16_16b_565()
{
u16 Index = DataReadU16();
@ -193,15 +186,14 @@ void LOADERDECL Color_ReadIndex16_32b_888x()
void LOADERDECL Color_ReadIndex16_16b_4444()
{
u16 Index = DataReadU16();
u16 val = Common::swap16(*(const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])));
u16 val = ((const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])))[0];
_SetCol4444(val);
}
void LOADERDECL Color_ReadIndex16_24b_6666()
{
u16 Index = DataReadU16();
const u8 *pData = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u32 val = pData[2] | (pData[1] << 8) | (pData[0] << 16);
_SetCol6666(val);
const u32* pData = (const u32*)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]) - 1);
_SetCol6666(pData[0]);
}
void LOADERDECL Color_ReadIndex16_32b_8888()
{