This is a "Try to fix" commit, reverted all the changes made by my first commit that could affect texturing, so please everyone with texture problems please test this, also in opengl let the viewport calculations the way they where, opengl can handle any values in the viewport.

in direct3d this is different, the only valid values are between 0.0 an 1.0 so fix this and let the shader handle the rest.
please test all this and let me know the results.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4494 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado
2009-11-02 21:09:48 +00:00
parent b3553eb53c
commit 8e204c659e
5 changed files with 17 additions and 29 deletions

View File

@ -588,6 +588,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
// mtx.m[0][3] = pMatrix[1]; // -0.5f/s_target_width; <-- fix d3d pixel center?
// mtx.m[1][3] = pMatrix[3]; // +0.5f/s_target_height; <-- fix d3d pixel center?
// Called from VertexShaderManager
// Called from VertexShaderManager
void UpdateViewport()
{
@ -604,16 +605,9 @@ void UpdateViewport()
vp.Y = (int)(ceil(xfregs.rawViewport[4] + xfregs.rawViewport[1] - (scissorYOff)) * MValueY);
vp.Width = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX);
vp.Height = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY);
//new depth equation , don't know if is correct but...
vp.MinZ = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
vp.MaxZ = xfregs.rawViewport[5] / 16777216.0f;
// This seems to happen a lot - the above calc is probably wrong.
if (vp.MinZ < 0.0f) vp.MinZ = 0.0f;
if (vp.MinZ > 1.0f) vp.MinZ = 1.0f;
if (vp.MaxZ > 1.0f) vp.MaxZ = 1.0f;
if (vp.MaxZ < 0.0f) vp.MaxZ = 0.0f;
//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;
D3D::dev->SetViewport(&vp);
}