zzogl-pg: Use SSE2 by default in the codeblock project. Move the swizzle stuff about a bit. A few changes I had sitting around.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2771 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-03-26 05:17:14 +00:00
parent 60c4ed5fcb
commit 2d754b3ca0
7 changed files with 135 additions and 349 deletions

View File

@ -39,6 +39,7 @@
<Add option="-I/opt/cg/include -L/opt/cg/lib" /> <Add option="-I/opt/cg/include -L/opt/cg/lib" />
<Add option="-msse2" /> <Add option="-msse2" />
<Add option="-fno-regmove" /> <Add option="-fno-regmove" />
<Add option="-DZEROGS_SSE2" />
<Add directory="../../Linux" /> <Add directory="../../Linux" />
<Add directory="../../../opengl" /> <Add directory="../../../opengl" />
<Add directory="../../../../../common/include" /> <Add directory="../../../../../common/include" />
@ -80,6 +81,7 @@
<Unit filename="../zerogs.glade" /> <Unit filename="../zerogs.glade" />
<Unit filename="../../Mem.cpp" /> <Unit filename="../../Mem.cpp" />
<Unit filename="../../Mem.h" /> <Unit filename="../../Mem.h" />
<Unit filename="../../Mem_Swizzle.cpp" />
<Unit filename="../../Mem_Swizzle.h" /> <Unit filename="../../Mem_Swizzle.h" />
<Unit filename="../../Mem_Tables.cpp" /> <Unit filename="../../Mem_Tables.cpp" />
<Unit filename="../../Mem_Transmit.h" /> <Unit filename="../../Mem_Transmit.h" />

View File

@ -20,175 +20,32 @@
#define MEM_SWIZZLE_H_INCLUDED #define MEM_SWIZZLE_H_INCLUDED
#include "GS.h" #include "GS.h"
#include "Mem.h" #include "Mem.h"
#include "x86.h"
extern __forceinline void SwizzleBlock32(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void SwizzleBlock16(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void SwizzleBlock8(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void SwizzleBlock4(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void SwizzleBlock32u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void SwizzleBlock16u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void SwizzleBlock8u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void SwizzleBlock4u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void __fastcall SwizzleBlock32_c(u8* dst, u8* src, int srcpitch, u32 WriteMask = 0xffffffff);
extern __forceinline void __fastcall SwizzleBlock24_c(u8* dst, u8* src, int srcpitch, u32 WriteMask = 0xffffffff);
extern __forceinline void __fastcall SwizzleBlock16_c(u8* dst, u8* src, int srcpitch, u32 WriteMask = 0xffffffff);
extern __forceinline void __fastcall SwizzleBlock8_c(u8* dst, u8* src, int srcpitch, u32 WriteMask = 0xffffffff);
extern __forceinline void __fastcall SwizzleBlock4_c(u8* dst, u8* src, int srcpitch, u32 WriteMask = 0xffffffff);
// special swizzle macros - which I converted to functions. // special swizzle macros - which I converted to functions.
#ifdef ZEROGS_SSE2 extern __forceinline void SwizzleBlock24(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
extern __forceinline void SwizzleBlock8H(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
static __forceinline void SwizzleBlock32(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff) extern __forceinline void SwizzleBlock4HH(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
{ extern __forceinline void SwizzleBlock4HL(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff);
SwizzleBlock32_sse2(dst, src, pitch, WriteMask); #define SwizzleBlock24u SwizzleBlock24
} #define SwizzleBlock8Hu SwizzleBlock8H
#define SwizzleBlock4HHu SwizzleBlock4HH
static __forceinline void SwizzleBlock16(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock16_sse2(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock8(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock8_sse2(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock4(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock4_sse2(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock32u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock32u_sse2(dst, src, pitch, WriteMask);
}
static __forceinline void SwizzleBlock16u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock16u_sse2(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock8u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock8u_sse2(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock4u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock4u_sse2(dst, src, pitch/*, WriteMask*/);
}
#else
static __forceinline void SwizzleBlock32(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock32_c(dst, src, pitch, WriteMask);
}
static __forceinline void SwizzleBlock16(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock16_c(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock8(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock8_c(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock4(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock4_c(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock32u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock32_c(dst, src, pitch, WriteMask);
}
static __forceinline void SwizzleBlock16u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock16_c(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock8u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock8_c(dst, src, pitch/*, WriteMask*/);
}
static __forceinline void SwizzleBlock4u(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
SwizzleBlock4_c(dst, src, pitch/*, WriteMask*/);
}
#endif
static __forceinline void SwizzleBlock24(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
u8* pnewsrc = src;
u32* pblock = tempblock;
for(int by = 0; by < 7; ++by, pblock += 8, pnewsrc += pitch-24)
{
for(int bx = 0; bx < 8; ++bx, pnewsrc += 3)
{
pblock[bx] = *(u32*)pnewsrc;
}
}
for(int bx = 0; bx < 7; ++bx, pnewsrc += 3)
{
/* might be 1 byte out of bounds of GS memory */
pblock[bx] = *(u32*)pnewsrc;
}
/* do 3 bytes for the last copy */
*((u8*)pblock+28) = pnewsrc[0];
*((u8*)pblock+29) = pnewsrc[1];
*((u8*)pblock+30) = pnewsrc[2];
SwizzleBlock32((u8*)dst, (u8*)tempblock, 32, 0x00ffffff);
}
#define SwizzleBlock24u SwizzleBlock24
static __forceinline void SwizzleBlock8H(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
u8* pnewsrc = src;
u32* pblock = tempblock;
for(int by = 0; by < 8; ++by, pblock += 8, pnewsrc += pitch)
{
u32 u = *(u32*)pnewsrc;
pblock[0] = u<<24;
pblock[1] = u<<16;
pblock[2] = u<<8;
pblock[3] = u;
u = *(u32*)(pnewsrc+4);
pblock[4] = u<<24;
pblock[5] = u<<16;
pblock[6] = u<<8;
pblock[7] = u;
}
SwizzleBlock32((u8*)dst, (u8*)tempblock, 32, 0xff000000);
}
#define SwizzleBlock8Hu SwizzleBlock8H
static __forceinline void SwizzleBlock4HH(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
u8* pnewsrc = src;
u32* pblock = tempblock;
for(int by = 0; by < 8; ++by, pblock += 8, pnewsrc += pitch)
{
u32 u = *(u32*)pnewsrc;
pblock[0] = u<<28;
pblock[1] = u<<24;
pblock[2] = u<<20;
pblock[3] = u<<16;
pblock[4] = u<<12;
pblock[5] = u<<8;
pblock[6] = u<<4;
pblock[7] = u;
}
SwizzleBlock32((u8*)dst, (u8*)tempblock, 32, 0xf0000000);
}
#define SwizzleBlock4HHu SwizzleBlock4HH
static __forceinline void SwizzleBlock4HL(u8 *dst, u8 *src, int pitch, u32 WriteMask = 0xffffffff)
{
u8* pnewsrc = src;
u32* pblock = tempblock;
for(int by = 0; by < 8; ++by, pblock += 8, pnewsrc += pitch)
{
u32 u = *(u32*)pnewsrc;
pblock[0] = u<<24;
pblock[1] = u<<20;
pblock[2] = u<<16;
pblock[3] = u<<12;
pblock[4] = u<<8;
pblock[5] = u<<4;
pblock[6] = u;
pblock[7] = u>>4;
}
SwizzleBlock32((u8*)dst, (u8*)tempblock, 32, 0x0f000000);
}
#define SwizzleBlock4HLu SwizzleBlock4HL #define SwizzleBlock4HLu SwizzleBlock4HL
#endif // MEM_SWIZZLE_H_INCLUDED #endif // MEM_SWIZZLE_H_INCLUDED

View File

@ -327,6 +327,10 @@
RelativePath="..\Mem_Tables.cpp" RelativePath="..\Mem_Tables.cpp"
> >
</File> </File>
<File
RelativePath="..\Mem_Swizzle.cpp"
>
</File>
<File <File
RelativePath="..\memcpy_amd.cpp" RelativePath="..\memcpy_amd.cpp"
> >

View File

@ -50,126 +50,58 @@ void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
DEBUG_LOG(" last listing: %s\n", listing); DEBUG_LOG(" last listing: %s\n", listing);
} }
// This is helper of cgGLSetParameter4fv, made for debug purpose. // This is a helper of cgGLSetParameter4fv, made for debugging purposes.
// Name could be any string. We must use it on compilation time, because erroneus handler does not // The name could be any string. We must use it on compilation time, because the erronious handler does not
// return name // return it.
void ZZcgSetParameter4fv(CGparameter param, const float* v, const char* name) { void ZZcgSetParameter4fv(CGparameter param, const float* v, const char* name)
{
ShaderHandleName = name; ShaderHandleName = name;
cgGLSetParameter4fv(param, v); cgGLSetParameter4fv(param, v);
} }
#define SET_UNIFORMPARAM(var, name) { \
p = cgGetNamedParameter(pf->prog, name); \
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) \
pf->var = p; \
} \
void SetupFragmentProgramParameters(FRAGMENTSHADER* pf, int context, int type) void SetupFragmentProgramParameters(FRAGMENTSHADER* pf, int context, int type)
{ {
// uniform parameters // uniform parameters
CGparameter p; pf->connect(g_fparamFogColor, "g_fFogColor");
p = cgGetNamedParameter(pf->prog, "g_fFogColor"); pf->set_uniform_param(pf->sOneColor, "g_fOneColor");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) { pf->set_uniform_param(pf->sBitBltZ, "g_fBitBltZ");
cgConnectParameter(g_fparamFogColor, p); pf->set_uniform_param(pf->sInvTexDims, "g_fInvTexDims");
} pf->set_uniform_param(pf->fTexAlpha2, "fTexAlpha2");
pf->set_uniform_param(pf->fTexOffset, "g_fTexOffset");
SET_UNIFORMPARAM(sOneColor, "g_fOneColor"); pf->set_uniform_param(pf->fTexDims, "g_fTexDims");
SET_UNIFORMPARAM(sBitBltZ, "g_fBitBltZ"); pf->set_uniform_param(pf->fTexBlock, "g_fTexBlock");
SET_UNIFORMPARAM(sInvTexDims, "g_fInvTexDims"); pf->set_uniform_param(pf->fClampExts, "g_fClampExts");
SET_UNIFORMPARAM(fTexAlpha2, "fTexAlpha2"); pf->set_uniform_param(pf->fTexWrapMode, "TexWrapMode");
SET_UNIFORMPARAM(fTexOffset, "g_fTexOffset"); pf->set_uniform_param(pf->fRealTexDims, "g_fRealTexDims");
SET_UNIFORMPARAM(fTexDims, "g_fTexDims"); pf->set_uniform_param(pf->fTestBlack, "g_fTestBlack");
SET_UNIFORMPARAM(fTexBlock, "g_fTexBlock"); pf->set_uniform_param(pf->fPageOffset, "g_fPageOffset");
SET_UNIFORMPARAM(fClampExts, "g_fClampExts"); pf->set_uniform_param(pf->fTexAlpha, "fTexAlpha");
SET_UNIFORMPARAM(fTexWrapMode, "TexWrapMode");
SET_UNIFORMPARAM(fRealTexDims, "g_fRealTexDims");
SET_UNIFORMPARAM(fTestBlack, "g_fTestBlack");
SET_UNIFORMPARAM(fPageOffset, "g_fPageOffset");
SET_UNIFORMPARAM(fTexAlpha, "fTexAlpha");
// textures // textures
p = cgGetNamedParameter(pf->prog, "g_sBlocks"); pf->set_texture(ptexBlocks, "g_sBlocks");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) {
cgGLSetTextureParameter(p, ptexBlocks);
cgGLEnableTextureParameter(p);
}
// cg parameter usage is wrong, so do it manually // cg parameter usage is wrong, so do it manually
if( type == 3 ) { switch(type)
p = cgGetNamedParameter(pf->prog, "g_sConv16to32"); {
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) { case 3: pf->set_texture(ptexConv16to32, "g_sConv16to32"); break;
cgGLSetTextureParameter(p, ptexConv16to32); case 4: pf->set_texture(ptexConv32to16, "g_sConv32to16"); break;
cgGLEnableTextureParameter(p); default: pf->set_texture(ptexBilinearBlocks, "g_sBilinearBlocks"); break;
}
}
else if( type == 4 ) {
p = cgGetNamedParameter(pf->prog, "g_sConv32to16");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) {
cgGLSetTextureParameter(p, ptexConv32to16);
cgGLEnableTextureParameter(p);
}
}
else {
p = cgGetNamedParameter(pf->prog, "g_sBilinearBlocks");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) {
cgGLSetTextureParameter(p, ptexBilinearBlocks);
cgGLEnableTextureParameter(p);
}
} }
p = cgGetNamedParameter(pf->prog, "g_sMemory"); pf->set_texture(pf->sMemory, "g_sMemory");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) { pf->set_texture(pf->sFinal, "g_sSrcFinal");
//cgGLEnableTextureParameter(p); pf->set_texture(pf->sBitwiseANDX, "g_sBitwiseANDX");
pf->sMemory = p; pf->set_texture(pf->sBitwiseANDY, "g_sBitwiseANDY");
} pf->set_texture(pf->sCLUT, "g_sCLUT");
p = cgGetNamedParameter(pf->prog, "g_sSrcFinal"); pf->set_texture(pf->sInterlace, "g_sInterlace");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) {
//cgGLEnableTextureParameter(p);
pf->sFinal = p;
}
p = cgGetNamedParameter(pf->prog, "g_sBitwiseANDX");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) {
//cgGLEnableTextureParameter(p);
pf->sBitwiseANDX = p;
}
p = cgGetNamedParameter(pf->prog, "g_sBitwiseANDY");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) {
//cgGLEnableTextureParameter(p);
pf->sBitwiseANDY = p;
}
p = cgGetNamedParameter(pf->prog, "g_sCLUT");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) {
//cgGLEnableTextureParameter(p);
pf->sCLUT = p;
}
p = cgGetNamedParameter(pf->prog, "g_sInterlace");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) {
//cgGLEnableTextureParameter(p);
pf->sInterlace = p;
}
// set global shader constants // set global shader constants
p = cgGetNamedParameter(pf->prog, "g_fExactColor"); pf->set_shader_const(Vector(0.5f, (g_GameSettings&GAME_EXACTCOLOR)?0.9f/256.0f:0.5f/256.0f, 0,1/255.0f), "g_fExactColor");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE ) { pf->set_shader_const(Vector(-0.2f, -0.65f, 0.9f, 1.0f / 32767.0f ), "g_fBilinear");
cgGLSetParameter4fv(p, Vector(0.5f, (g_GameSettings&GAME_EXACTCOLOR)?0.9f/256.0f:0.5f/256.0f, 0,1/255.0f)); pf->set_shader_const(Vector(1.0f/256.0f, 1.0004f, 1, 0.5f), "g_fZBias");
} pf->set_shader_const(Vector(0,1, 0.001f, 0.5f), "g_fc0");
pf->set_shader_const(Vector(1/1024.0f, 0.2f/1024.0f, 1/128.0f, 1/512.0f), "g_fMult");
p = cgGetNamedParameter(pf->prog, "g_fBilinear");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE )
cgGLSetParameter4fv(p, Vector(-0.2f, -0.65f, 0.9f, 1.0f / 32767.0f ));
p = cgGetNamedParameter(pf->prog, "g_fZBias");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE )
cgGLSetParameter4fv(p, Vector(1.0f/256.0f, 1.0004f, 1, 0.5f));
p = cgGetNamedParameter(pf->prog, "g_fc0");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE )
cgGLSetParameter4fv(p, Vector(0,1, 0.001f, 0.5f));
p = cgGetNamedParameter(pf->prog, "g_fMult");
if( p != NULL && cgIsParameterUsed(p, pf->prog) == CG_TRUE )
cgGLSetParameter4fv(p, Vector(1/1024.0f, 0.2f/1024.0f, 1/128.0f, 1/512.0f));
} }
void SetupVertexProgramParameters(CGprogram prog, int context) void SetupVertexProgramParameters(CGprogram prog, int context)
@ -181,11 +113,13 @@ void SetupVertexProgramParameters(CGprogram prog, int context)
cgConnectParameter(g_vparamPosXY[context], p); cgConnectParameter(g_vparamPosXY[context], p);
// Set Z-test, log or no log; // Set Z-test, log or no log;
if (g_GameSettings&GAME_NOLOGZ) { if (g_GameSettings&GAME_NOLOGZ)
g_vdepth = Vector( 255.0 /256.0f, 255.0/65536.0f, 255.0f/(65535.0f*256.0f), 1.0f/(65536.0f*65536.0f)); {
g_vdepth = Vector( 255.0 /256.0f, 255.0/65536.0f, 255.0f/(65535.0f*256.0f), 1.0f/(65536.0f*65536.0f));
vlogz = Vector( 1.0f, 0.0f, 0.0f, 0.0f); vlogz = Vector( 1.0f, 0.0f, 0.0f, 0.0f);
} }
else { else
{
g_vdepth = Vector( 256.0f*65536.0f, 65536.0f, 256.0f, 65536.0f*65536.0f); g_vdepth = Vector( 256.0f*65536.0f, 65536.0f, 256.0f, 65536.0f*65536.0f);
vlogz = Vector( 0.0f, 1.0f, 0.0f, 0.0f); vlogz = Vector( 0.0f, 1.0f, 0.0f, 0.0f);
} }

View File

@ -29,78 +29,6 @@
#endif #endif
// swizzling // swizzling
void __fastcall SwizzleBlock32_c(u8* dst, u8* src, int srcpitch, u32 WriteMask)
{
u32* d = &g_columnTable32[0][0];
if(WriteMask == 0xffffffff)
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = ((u32*)src)[i];
}
else
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = (((u32*)dst)[d[i]] & ~WriteMask) | (((u32*)src)[i] & WriteMask);
}
}
void __fastcall SwizzleBlock24_c(u8* dst, u8* src, int srcpitch, u32 WriteMask)
{
u32* d = &g_columnTable32[0][0];
if(WriteMask == 0x00ffffff)
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = ((u32*)src)[i];
}
else
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = (((u32*)dst)[d[i]] & ~WriteMask) | (((u32*)src)[i] & WriteMask);
}
}
void __fastcall SwizzleBlock16_c(u8* dst, u8* src, int srcpitch, u32 WriteMask)
{
u32* d = &g_columnTable16[0][0];
for(int j = 0; j < 8; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
((u16*)dst)[d[i]] = ((u16*)src)[i];
}
void __fastcall SwizzleBlock8_c(u8* dst, u8* src, int srcpitch, u32 WriteMask)
{
u32* d = &g_columnTable8[0][0];
for(int j = 0; j < 16; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
dst[d[i]] = src[i];
}
void __fastcall SwizzleBlock4_c(u8* dst, u8* src, int srcpitch, u32 WriteMask)
{
u32* d = &g_columnTable4[0][0];
for(int j = 0; j < 16; j++, d += 32, src += srcpitch)
{
for(int i = 0; i < 32; i++)
{
u32 addr = d[i];
u8 c = (src[i>>1] >> ((i&1) << 2)) & 0x0f;
u32 shift = (addr&1) << 2;
dst[addr >> 1] = (dst[addr >> 1] & (0xf0 >> shift)) | (c << shift);
}
}
}
#define _FrameSwizzleBlock(type, transfer, transfer16, incsrc) \ #define _FrameSwizzleBlock(type, transfer, transfer16, incsrc) \
/* FrameSwizzleBlock32 */ \ /* FrameSwizzleBlock32 */ \
void __fastcall FrameSwizzleBlock32##type##c(u32* dst, u32* src, int srcpitch, u32 WriteMask) \ void __fastcall FrameSwizzleBlock32##type##c(u32* dst, u32* src, int srcpitch, u32 WriteMask) \

View File

@ -59,10 +59,10 @@ extern "C" void __fastcall Frame16SwizzleBlock32ZA4_sse2(u32* dst, Vector_16F* s
extern "C" void __fastcall Frame16SwizzleBlock16A4_sse2(u16* dst, Vector_16F* src, int srcpitch, u32 WriteMask); extern "C" void __fastcall Frame16SwizzleBlock16A4_sse2(u16* dst, Vector_16F* src, int srcpitch, u32 WriteMask);
extern "C" void __fastcall Frame16SwizzleBlock16ZA4_sse2(u16* dst, Vector_16F* src, int srcpitch, u32 WriteMask); extern "C" void __fastcall Frame16SwizzleBlock16ZA4_sse2(u16* dst, Vector_16F* src, int srcpitch, u32 WriteMask);
extern void __fastcall SwizzleBlock32_c(u8* dst, u8* src, int srcpitch, u32 WriteMask = 0xffffffff); /*extern void __fastcall SwizzleBlock32_c(u8* dst, u8* src, int srcpitch, u32 WriteMask = 0xffffffff);
extern void __fastcall SwizzleBlock16_c(u8* dst, u8* src, int srcpitch); extern void __fastcall SwizzleBlock16_c(u8* dst, u8* src, int srcpitch);
extern void __fastcall SwizzleBlock8_c(u8* dst, u8* src, int srcpitch); extern void __fastcall SwizzleBlock8_c(u8* dst, u8* src, int srcpitch);
extern void __fastcall SwizzleBlock4_c(u8* dst, u8* src, int srcpitch); extern void __fastcall SwizzleBlock4_c(u8* dst, u8* src, int srcpitch);*/
// no AA // no AA
extern void __fastcall FrameSwizzleBlock32_c(u32* dst, u32* src, int srcpitch, u32 WriteMask); extern void __fastcall FrameSwizzleBlock32_c(u32* dst, u32* src, int srcpitch, u32 WriteMask);

View File

@ -271,6 +271,67 @@ struct FRAGMENTSHADER
#ifdef _DEBUG #ifdef _DEBUG
string filename; string filename;
#endif #endif
void set_uniform_param(CGparameter &var, const char *name)
{
CGparameter p;
p = cgGetNamedParameter(prog, name);
if (p != NULL && cgIsParameterUsed(p, prog) == CG_TRUE) var = p;
}
bool set_texture(GLuint texobj, const char *name)
{
CGparameter p;
p = cgGetNamedParameter(prog, name);
if( p != NULL && cgIsParameterUsed(p, prog) == CG_TRUE )
{
cgGLSetTextureParameter(p, texobj);
cgGLEnableTextureParameter(p);
return true;
}
return false;
}
bool connect(CGparameter &tex, const char *name)
{
CGparameter p;
p = cgGetNamedParameter(prog, name);
if( p != NULL && cgIsParameterUsed(p, prog) == CG_TRUE )
{
cgConnectParameter(tex, p);
return true;
}
return false;
}
bool set_texture(CGparameter &tex, const char *name)
{
CGparameter p;
p = cgGetNamedParameter(prog, name);
if( p != NULL && cgIsParameterUsed(p, prog) == CG_TRUE )
{
//cgGLEnableTextureParameter(p);
tex = p;
return true;
}
return false;
}
bool set_shader_const(Vector v, const char *name)
{
CGparameter p;
p = cgGetNamedParameter(prog, name);
if( p != NULL && cgIsParameterUsed(p, prog) == CG_TRUE )
{
cgGLSetParameter4fv(p, v);
return true;
}
return false;
}
}; };
struct VERTEXSHADER struct VERTEXSHADER