From 4c47fd0d49dbc264384e81b20eda6f01b8e5f9ad Mon Sep 17 00:00:00 2001 From: Rodolfo Osvaldo Bogado Date: Tue, 25 Jan 2011 03:45:44 +0000 Subject: [PATCH] revert my optimizations until i fix some errors and really fix issue 3976 git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6911 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 10 ++- .../VideoCommon/Src/VertexLoader_Color.cpp | 64 +++++++++++-------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 6524f67d91..38d1e64e59 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -567,9 +567,11 @@ 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 = float4(0.0f,0.0f,0.0f,0.0f);\n"); + WRITE(p, "ocol0 = 0;\n"); if(DepthTextureEnable) WRITE(p, "depth = 1.f;\n"); + if(dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) + WRITE(p, "ocol1 = 0;\n"); WRITE(p, "discard;\n"); if(ApiType != API_D3D11) WRITE(p, "return;\n"); @@ -798,9 +800,11 @@ 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 = float4(0.0f,0.0f,0.0f,0.0f);\n"); + WRITE(p, "ocol0 = 0;\n"); if(DepthTextureEnable) WRITE(p, "depth = 1.f;\n"); + if(dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) + WRITE(p, "ocol1 = 0;\n"); WRITE(p, "discard;\n"); if(ApiType != API_D3D11) WRITE(p, "return;\n"); @@ -1305,7 +1309,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 = float4(0.0f,0.0f,0.0f,0.0f);%sdiscard;%s}\n",DepthTextureEnable ? "depth = 1.f;" : "",(ApiType != API_D3D11)? "return;" : ""); + WRITE(p, ")){ocol0 = 0;%s%sdiscard;%s}\n",dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND && ? "ocol1 = 0;" : "",DepthTextureEnable ? "depth = 1.f;" : "",(ApiType != API_D3D11)? "return;" : ""); return true; } diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp index a1bf278192..362a777ffb 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp @@ -29,7 +29,6 @@ #define GSHIFT 8 #define BSHIFT 16 #define ASHIFT 24 -#define AMASK (0xFF << ASHIFT) extern int colIndex; extern int colElements[2]; @@ -41,13 +40,12 @@ __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) << GSHIFT; - col |= Convert4To8((val >> 12) & 0xF) << BSHIFT; - col |= Convert4To8((val >> 8) & 0xF) << ASHIFT; - col |= Convert4To8((val >> 4) & 0xF) << RSHIFT; + u32 col = Convert4To8(val & 0xF) << ASHIFT; + col |= Convert4To8((val >> 12) & 0xF) << RSHIFT; + col |= Convert4To8((val >> 8) & 0xF) << GSHIFT; + col |= Convert4To8((val >> 4) & 0xF) << BSHIFT; _SetCol(col); } @@ -65,12 +63,13 @@ __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 | AMASK); + _SetCol(col | (0xFF << ASHIFT)); } + __forceinline u32 _Read24(const u8 *addr) { - return Common::swap32(addr) | AMASK; + return addr[0] | (addr[1] << 8) | (addr[2] << 16) | 0xFF000000; } __forceinline u32 _Read32(const u8 *addr) @@ -78,33 +77,38 @@ __forceinline u32 _Read32(const u8 *addr) return *(const u32 *)addr; } + + + void LOADERDECL Color_ReadDirect_24b_888() { - _SetCol(_Read24(DataGetPosition())); - DataSkip(3); + u32 col = DataReadU8() << RSHIFT; + col |= DataReadU8() << GSHIFT; + col |= DataReadU8() << BSHIFT; + _SetCol(col | (0xFF << ASHIFT)); } -void LOADERDECL Color_ReadDirect_32b_888x() -{ - _SetCol(_Read24(DataGetPosition())); - DataSkip(4); +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_16b_565() { _SetCol565(DataReadU16()); } - void LOADERDECL Color_ReadDirect_16b_4444() { - _SetCol4444(((const u16*)DataGetPosition())[0]); - DataSkip(2); + _SetCol4444(DataReadU16()); } - void LOADERDECL Color_ReadDirect_24b_6666() { - _SetCol6666(((const u32*)(DataGetPosition() - 1))[0]); - DataSkip(3); + u32 val = DataReadU8() << 16; + val |= DataReadU8() << 8; + val |= DataReadU8(); + _SetCol6666(val); } // F|RES: i am not 100 percent sure, but the colElements seems to be important for rendering only @@ -121,7 +125,7 @@ void LOADERDECL Color_ReadDirect_32b_8888() // "kill" the alpha if (!colElements[colIndex]) - col |= AMASK; + col |= 0xFF << ASHIFT; _SetCol(col); } @@ -149,14 +153,15 @@ void LOADERDECL Color_ReadIndex8_32b_888x() void LOADERDECL Color_ReadIndex8_16b_4444() { u8 Index = DataReadU8(); - u16 val = ((const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])))[0]; + u16 val = Common::swap16(*(const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]))); _SetCol4444(val); } void LOADERDECL Color_ReadIndex8_24b_6666() { u8 Index = DataReadU8(); - const u32* pData = (const u32*)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]) - 1); - _SetCol6666(pData[0]); + 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); } void LOADERDECL Color_ReadIndex8_32b_8888() { @@ -165,6 +170,8 @@ void LOADERDECL Color_ReadIndex8_32b_8888() _SetCol(_Read32(iAddress)); } + + void LOADERDECL Color_ReadIndex16_16b_565() { u16 Index = DataReadU16(); @@ -186,14 +193,15 @@ void LOADERDECL Color_ReadIndex16_32b_888x() void LOADERDECL Color_ReadIndex16_16b_4444() { u16 Index = DataReadU16(); - u16 val = ((const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])))[0]; + u16 val = Common::swap16(*(const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]))); _SetCol4444(val); } void LOADERDECL Color_ReadIndex16_24b_6666() { u16 Index = DataReadU16(); - const u32* pData = (const u32*)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]) - 1); - _SetCol6666(pData[0]); + 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); } void LOADERDECL Color_ReadIndex16_32b_8888() {