a minor cleanup in xf registers, an some small bug fixes. please test and give me feedback

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4589 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado 2009-11-19 02:28:41 +00:00
parent 73af91281a
commit fe1a5142a7
6 changed files with 71 additions and 78 deletions

View File

@ -306,7 +306,7 @@ void PixelShaderManager::SetZTextureBias(u32 bias)
}
}
void PixelShaderManager::SetViewport(float* viewport)
void PixelShaderManager::SetViewport(float* viewport,int VIndex)
{
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
// [0] = width/2
@ -316,6 +316,8 @@ void PixelShaderManager::SetViewport(float* viewport)
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
if(VIndex <= 0)
{
if (lastDepthRange[0] != viewport[5] || lastDepthRange[1] != viewport[2])
{
lastDepthRange[0] = viewport[5];
@ -324,24 +326,20 @@ void PixelShaderManager::SetViewport(float* viewport)
s_bDepthRangeChanged = true;
}
}
void PixelShaderManager::SetZScale(float data)
else
{
if (lastDepthRange[0] != data)
if (VIndex == 2 && lastDepthRange[1] != viewport[0])
{
lastDepthRange[0] = data;
lastDepthRange[1] = viewport[0];
s_bDepthRangeChanged = true;
}
}
void PixelShaderManager::SetZOffset(float data)
else if(VIndex == 5 && lastDepthRange[0] != viewport[0])
{
if (lastDepthRange[1] != data)
{
lastDepthRange[1] = data;
lastDepthRange[0] = viewport[0];
s_bDepthRangeChanged = true;
}
}
}
void PixelShaderManager::SetIndTexScaleChanged(u8 stagemask)
{

View File

@ -43,7 +43,7 @@ public:
static void SetTexDims(int texmapid, u32 width, u32 height, u32 wraps, u32 wrapt);
static void SetCustomTexScale(int texmapid, float x, float y);
static void SetZTextureBias(u32 bias);
static void SetViewport(float* viewport);
static void SetViewport(float* viewport,int VIndex = -1);
static void SetIndMatrixChanged(int matrixidx);
static void SetTevKSelChanged(int id);
static void SetZTextureTypeChanged();
@ -54,8 +54,6 @@ public:
static void SetFogParamChanged();
static void SetColorMatrix(const float* pmatrix, const float* pfConstAdd);
static u32 GetTextureMask();
static void SetZScale(float data);
static void SetZOffset(float data);
};

View File

@ -438,27 +438,24 @@ void VertexShaderManager::SetTexMatrixChangedB(u32 Value)
}
}
void VertexShaderManager::SetViewport(float* _Viewport)
void VertexShaderManager::SetViewport(float* _Viewport, int constantIndex)
{
if(constantIndex <= 0)
{
memcpy(xfregs.rawViewport, _Viewport, sizeof(xfregs.rawViewport));
}
else
{
xfregs.rawViewport[constantIndex] = _Viewport[0];
}
/*//Tino: i think this is nod needed so let this commented til confirmed
// Workaround for paper mario, yep this is bizarre.
for (size_t i = 0; i < ARRAYSIZE(xfregs.rawViewport); ++i)
{
if (*(u32*)(_Viewport + i) == 0x7f800000) // invalid fp number
return;
}
memcpy(xfregs.rawViewport, _Viewport, sizeof(xfregs.rawViewport));
bViewportChanged = true;
}
void VertexShaderManager::SetZScale(float data)
{
xfregs.rawViewport[5] = data;
bViewportChanged = true;
}
void VertexShaderManager::SetZOffset(float data)
{
xfregs.rawViewport[2] = data;
memcpy(xfregs.rawViewport, _Viewport, sizeof(xfregs.rawViewport));*/
bViewportChanged = true;
}
@ -468,8 +465,15 @@ void VertexShaderManager::SetViewportChanged()
}
void VertexShaderManager::SetProjection(float* _pProjection, int constantIndex)
{
if(constantIndex <= 0)
{
memcpy(xfregs.rawProjection, _pProjection, sizeof(xfregs.rawProjection));
}
else
{
xfregs.rawProjection[constantIndex] = _pProjection[0];
}
bProjectionChanged = true;
}

View File

@ -31,15 +31,13 @@ public:
// constant management
static void SetConstants();
static void SetViewport(float* _Viewport);
static void SetViewport(float* _Viewport, int constantIndex = -1);
static void SetViewportChanged();
static void SetProjection(float* _pProjection, int constantIndex = -1);
static void InvalidateXFRange(int start, int end);
static void SetTexMatrixChangedA(u32 Value);
static void SetTexMatrixChangedB(u32 Value);
static void SetMaterialColor(int index, u32 data);
static void SetZScale(float data);
static void SetZOffset(float data);
static void TranslateView(float x, float y);
static void RotateView(float x, float y);

View File

@ -94,6 +94,13 @@
#define XFMEM_SETZSCALE 0x101c
#define XFMEM_SETZOFFSET 0x101f
#define XFMEM_SETPROJECTION 0x1020
/*#define XFMEM_SETPROJECTIONB 0x1021
#define XFMEM_SETPROJECTIONC 0x1022
#define XFMEM_SETPROJECTIOND 0x1023
#define XFMEM_SETPROJECTIONE 0x1024
#define XFMEM_SETPROJECTIONF 0x1025
#define XFMEM_SETPROJECTIONORTHO1 0x1026
#define XFMEM_SETPROJECTIONORTHO2 0x1027*/
#define XFMEM_SETNUMTEXGENS 0x103f
#define XFMEM_SETTEXMTXINFO 0x1040
#define XFMEM_SETPOSMTXINFO 0x1050

View File

@ -49,6 +49,28 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
{
xfregs.texcoords[address - XFMEM_SETPOSMTXINFO].postmtxinfo.hex = pData[i];
}
else if (address >= XFMEM_SETVIEWPORT && address <= XFMEM_SETVIEWPORT+5)
{
VertexManager::Flush();
u32 Index = address - XFMEM_SETVIEWPORT;
VertexShaderManager::SetViewport((float*)&pData[i],Index);
PixelShaderManager::SetViewport((float*)&pData[i],Index);
if(Index == 0)
{
i += 5;
}
}
else if (address >= XFMEM_SETPROJECTION && address <= XFMEM_SETPROJECTION+7)
{
VertexManager::Flush();
u32 Index = address - XFMEM_SETPROJECTION;
VertexShaderManager::SetProjection((float*)&pData[i],Index);
if(Index == 0)
{
i += 7;
}
}
else if (address < 0x2000)
{
u32 data = pData[i];
@ -147,20 +169,6 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
//_assert_msg_(GX_XF, 0, "XF matrixindex1");
VertexShaderManager::SetTexMatrixChangedB(data); // ?
break;
case XFMEM_SETVIEWPORT:
VertexManager::Flush();
VertexShaderManager::SetViewport((float*)&pData[i]);
PixelShaderManager::SetViewport((float*)&pData[i]);
i += 6;
break;
case XFMEM_SETPROJECTION:
VertexManager::Flush();
VertexShaderManager::SetProjection((float*)&pData[i]);
i += 7;
break;
case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens
if ((u32)xfregs.numTexGens != data)
{
@ -169,26 +177,6 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
}
break;
// GXSetZScaleOffset ?
// Actually everything i tried didn't seem to change anything x)
// paper mario writes 16777216.0f, 1677721.75
// Killer 7 writes 16777216.0f here
case XFMEM_SETZSCALE:
VertexManager::Flush();
VertexShaderManager::SetZScale(*(float*)&data);
PixelShaderManager::SetZScale(*(float*)&data);
INFO_LOG(VIDEO, "Set ZScale : %x=%x\n", address, data);
break;
// paper mario writes 16777216.0f, 5033165.0f
// Killer 7 alterns this between 16777216.0f and 16710107.0f
case XFMEM_SETZOFFSET:
VertexManager::Flush();
VertexShaderManager::SetZOffset(*(float*)&data);
PixelShaderManager::SetZOffset(*(float*)&data);
INFO_LOG(VIDEO, "Set ZOffset : %x=%x\n", address, data);
break;
// --------------
// Unknown Regs
// --------------