Fix an error introduced in r7083. In the pixel shader manager the farZ and zRange of the z bias were flipped. Switched to using the viewport struct rather than a raw float array to hopefully avoid such confusion in the future. Fixes issue 4060.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7446 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
6ca5d7c7c8
commit
77a4a64909
|
@ -148,7 +148,7 @@ void PixelShaderManager::SetConstants()
|
|||
// [5] = 16777215 * farz
|
||||
|
||||
//ERROR_LOG("pixel=%x,%x, bias=%x\n", bpmem.zcontrol.pixel_format, bpmem.ztex2.type, lastZBias);
|
||||
SetPSConstant4f(C_ZBIAS+1, xfregs.rawViewport[2] / 16777216.0f, xfregs.rawViewport[5] / 16777216.0f, 0, (float)(lastZBias)/16777215.0f);
|
||||
SetPSConstant4f(C_ZBIAS+1, xfregs.viewport.farZ / 16777216.0f, xfregs.viewport.zRange / 16777216.0f, 0, (float)(lastZBias)/16777215.0f);
|
||||
s_bZBiasChanged = s_bDepthRangeChanged = false;
|
||||
}
|
||||
|
||||
|
@ -245,14 +245,14 @@ void PixelShaderManager::SetConstants()
|
|||
//bpmem.fogRange.Base.Center : center of the viewport in x axis. observation: bpmem.fogRange.Base.Center = realcenter + 342;
|
||||
int center = ((u32)bpmem.fogRange.Base.Center) - 342;
|
||||
// normalice center to make calculations easy
|
||||
float ScreenSpaceCenter = center / (2.0f * xfregs.rawViewport[0]);
|
||||
float ScreenSpaceCenter = center / (2.0f * xfregs.viewport.wd);
|
||||
ScreenSpaceCenter = (ScreenSpaceCenter * 2.0f) - 1.0f;
|
||||
//bpmem.fogRange.K seems to be a table of precalculated coeficients for the adjust factor
|
||||
//observations: bpmem.fogRange.K[0].LO apears to be the lowest value and bpmem.fogRange.K[4].HI the largest
|
||||
// they always seems to be larger than 256 so my teory is :
|
||||
// they are the coeficients from the center to th e border of the screen
|
||||
// so to simplify i use the hi coeficient as K in the shader taking 256 as the scale
|
||||
SetPSConstant4f(C_FOG + 2, ScreenSpaceCenter, (float)Renderer::EFBToScaledX((int)(2.0f * xfregs.rawViewport[0])), bpmem.fogRange.K[4].HI / 256.0f,0.0f);
|
||||
SetPSConstant4f(C_FOG + 2, ScreenSpaceCenter, (float)Renderer::EFBToScaledX((int)(2.0f * xfregs.viewport.wd)), bpmem.fogRange.K[4].HI / 256.0f,0.0f);
|
||||
}
|
||||
s_bFogRangeAdjustChanged = false;
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ void VertexShaderManager::SetConstants()
|
|||
if (bViewportChanged)
|
||||
{
|
||||
bViewportChanged = false;
|
||||
SetVSConstant4f(C_DEPTHPARAMS,xfregs.rawViewport[5]/ 16777216.0f,xfregs.rawViewport[2]/ 16777216.0f,0.0f,0.0f);
|
||||
SetVSConstant4f(C_DEPTHPARAMS,xfregs.viewport.farZ / 16777216.0f,xfregs.viewport.zRange / 16777216.0f,0.0f,0.0f);
|
||||
// This is so implementation-dependent that we can't have it here.
|
||||
UpdateViewport();
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ struct Viewport
|
|||
{
|
||||
float wd;
|
||||
float ht;
|
||||
float nearZ;
|
||||
float zRange;
|
||||
float xOrig;
|
||||
float yOrig;
|
||||
float farZ;
|
||||
|
@ -259,7 +259,7 @@ struct XFRegisters
|
|||
u32 unk7; // 0x1017
|
||||
u32 MatrixIndexA; // 0x1018
|
||||
u32 MatrixIndexB; // 0x1019
|
||||
float rawViewport[6]; // 0x101a - 0x101f
|
||||
Viewport viewport; // 0x101a - 0x101f
|
||||
float rawProjection[7]; // 0x1020 - 0x1026
|
||||
u32 unk8[24]; // 0x1027 - 0x103e
|
||||
NumTexGen numTexGen; // 0x103f
|
||||
|
|
|
@ -675,10 +675,10 @@ void Renderer::UpdateViewport()
|
|||
|
||||
// TODO: ceil, floor or just cast to int?
|
||||
// TODO: Directly use the floats instead of rounding them?
|
||||
int X = Renderer::EFBToScaledX((int)ceil(xfregs.rawViewport[3] - xfregs.rawViewport[0] - scissorXOff)) + Renderer::TargetStrideX();
|
||||
int Y = Renderer::EFBToScaledY((int)ceil(xfregs.rawViewport[4] + xfregs.rawViewport[1] - scissorYOff)) + Renderer::TargetStrideY();
|
||||
int Width = Renderer::EFBToScaledX((int)ceil(2.0f * xfregs.rawViewport[0]));
|
||||
int Height = Renderer::EFBToScaledY((int)ceil(-2.0f * xfregs.rawViewport[1]));
|
||||
int X = Renderer::EFBToScaledX((int)ceil(xfregs.viewport.xOrig - xfregs.viewport.wd - scissorXOff)) + Renderer::TargetStrideX();
|
||||
int Y = Renderer::EFBToScaledY((int)ceil(xfregs.viewport.yOrig + xfregs.viewport.ht - scissorYOff)) + Renderer::TargetStrideY();
|
||||
int Width = Renderer::EFBToScaledX((int)ceil(2.0f * xfregs.viewport.wd));
|
||||
int Height = Renderer::EFBToScaledY((int)ceil(-2.0f * xfregs.viewport.ht));
|
||||
if (Width < 0)
|
||||
{
|
||||
X += Width;
|
||||
|
@ -741,8 +741,8 @@ void Renderer::UpdateViewport()
|
|||
|
||||
// Some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
|
||||
D3D11_VIEWPORT vp = CD3D11_VIEWPORT(newx, newy, newwidth, newheight,
|
||||
0.f, // (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
|
||||
1.f); // xfregs.rawViewport[5] / 16777216.0f;
|
||||
0.f, // (xfregs.viewport.farZ - xfregs.viewport.zRange) / 16777216.0f;
|
||||
1.f); // xfregs.viewport.farZ / 16777216.0f;
|
||||
D3D::g_context->RSSetViewports(1, &vp);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,8 +133,8 @@ void VertexManager::Draw(UINT stride)
|
|||
{
|
||||
float lineWidth = float(bpmem.lineptwidth.linesize) / 6.f;
|
||||
float texOffset = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.lineoff];
|
||||
float vpWidth = 2.0f * xfregs.rawViewport[0];
|
||||
float vpHeight = -2.0f * xfregs.rawViewport[1];
|
||||
float vpWidth = 2.0f * xfregs.viewport.wd;
|
||||
float vpHeight = -2.0f * xfregs.viewport.ht;
|
||||
|
||||
if (m_lineShader.SetShader(g_nativeVertexFmt->m_components, lineWidth, texOffset, vpWidth, vpHeight))
|
||||
{
|
||||
|
@ -149,8 +149,8 @@ void VertexManager::Draw(UINT stride)
|
|||
{
|
||||
float pointSize = float(bpmem.lineptwidth.pointsize) / 6.f;
|
||||
float texOffset = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.pointoff];
|
||||
float vpWidth = 2.0f * xfregs.rawViewport[0];
|
||||
float vpHeight = -2.0f * xfregs.rawViewport[1];
|
||||
float vpWidth = 2.0f * xfregs.viewport.wd;
|
||||
float vpHeight = -2.0f * xfregs.viewport.ht;
|
||||
|
||||
if (m_pointShader.SetShader(g_nativeVertexFmt->m_components, pointSize, texOffset, vpWidth, vpHeight))
|
||||
{
|
||||
|
|
|
@ -707,10 +707,10 @@ void Renderer::UpdateViewport()
|
|||
int scissorYOff = bpmem.scissorOffset.y << 1;
|
||||
|
||||
// TODO: ceil, floor or just cast to int?
|
||||
int X = EFBToScaledX((int)ceil(xfregs.rawViewport[3] - xfregs.rawViewport[0] - scissorXOff)) + TargetStrideX();
|
||||
int Y = EFBToScaledY((int)ceil(xfregs.rawViewport[4] + xfregs.rawViewport[1] - scissorYOff)) + TargetStrideY();
|
||||
int Width = EFBToScaledX((int)ceil(2.0f * xfregs.rawViewport[0]));
|
||||
int Height = EFBToScaledY((int)ceil(-2.0f * xfregs.rawViewport[1]));
|
||||
int X = EFBToScaledX((int)ceil(xfregs.viewport.xOrig - xfregs.viewport.wd - scissorXOff)) + TargetStrideX();
|
||||
int Y = EFBToScaledY((int)ceil(xfregs.viewport.yOrig + xfregs.viewport.ht - scissorYOff)) + TargetStrideY();
|
||||
int Width = EFBToScaledX((int)ceil(2.0f * xfregs.viewport.wd));
|
||||
int Height = EFBToScaledY((int)ceil(-2.0f * xfregs.viewport.ht));
|
||||
if (Width < 0)
|
||||
{
|
||||
X += Width;
|
||||
|
@ -794,8 +794,8 @@ void Renderer::UpdateViewport()
|
|||
vp.Height = Height;
|
||||
|
||||
// Some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
|
||||
vp.MinZ = 0.0f; // (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
|
||||
vp.MaxZ = 1.0f; // xfregs.rawViewport[5] / 16777216.0f;
|
||||
vp.MinZ = 0.0f; // (xfregs.viewport.farZ - xfregs.viewport.zRange) / 16777216.0f;
|
||||
vp.MaxZ = 1.0f; // xfregs.viewport.farZ / 16777216.0f;
|
||||
D3D::dev->SetViewport(&vp);
|
||||
}
|
||||
|
||||
|
@ -1367,7 +1367,7 @@ void Renderer::SetDitherMode()
|
|||
void Renderer::SetLineWidth()
|
||||
{
|
||||
// We can't change line width in D3D unless we use ID3DXLine
|
||||
float fratio = xfregs.rawViewport[0] != 0 ? Renderer::EFBToScaledXf(1.f) : 1.0f;
|
||||
float fratio = xfregs.viewport.wd != 0 ? Renderer::EFBToScaledXf(1.f) : 1.0f;
|
||||
float psize = bpmem.lineptwidth.linesize * fratio / 6.0f;
|
||||
D3D::SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
|
||||
}
|
||||
|
|
|
@ -830,12 +830,12 @@ void Renderer::UpdateViewport()
|
|||
int scissorYOff = bpmem.scissorOffset.y << 1;
|
||||
|
||||
// TODO: ceil, floor or just cast to int?
|
||||
int X = EFBToScaledX((int)ceil(xfregs.rawViewport[3] - xfregs.rawViewport[0] - (float)scissorXOff));
|
||||
int Y = EFBToScaledY((int)ceil((float)EFB_HEIGHT - xfregs.rawViewport[4] + xfregs.rawViewport[1] + (float)scissorYOff));
|
||||
int Width = EFBToScaledX((int)ceil(2.0f * xfregs.rawViewport[0]));
|
||||
int Height = EFBToScaledY((int)ceil(-2.0f * xfregs.rawViewport[1]));
|
||||
double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
|
||||
double GLFar = xfregs.rawViewport[5] / 16777216.0f;
|
||||
int X = EFBToScaledX((int)ceil(xfregs.viewport.xOrig - xfregs.viewport.wd - (float)scissorXOff));
|
||||
int Y = EFBToScaledY((int)ceil((float)EFB_HEIGHT - xfregs.viewport.yOrig + xfregs.viewport.ht + (float)scissorYOff));
|
||||
int Width = EFBToScaledX((int)ceil(2.0f * xfregs.viewport.wd));
|
||||
int Height = EFBToScaledY((int)ceil(-2.0f * xfregs.viewport.ht));
|
||||
double GLNear = (xfregs.viewport.farZ - xfregs.viewport.zRange) / 16777216.0f;
|
||||
double GLFar = xfregs.viewport.farZ / 16777216.0f;
|
||||
if (Width < 0)
|
||||
{
|
||||
X += Width;
|
||||
|
@ -1482,7 +1482,7 @@ void Renderer::SetDitherMode()
|
|||
|
||||
void Renderer::SetLineWidth()
|
||||
{
|
||||
float fratio = xfregs.rawViewport[0] != 0 ?
|
||||
float fratio = xfregs.viewport.wd != 0 ?
|
||||
((float)Renderer::GetTargetWidth() / EFB_WIDTH) : 1.0f;
|
||||
if (bpmem.lineptwidth.linesize > 0)
|
||||
// scale by ratio of widths
|
||||
|
|
Loading…
Reference in New Issue