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:
parent
b3553eb53c
commit
8e204c659e
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void FramebufferManager::Init(int targetWidth, int targetHeight, int msaaSamples
|
|||
m_efbDepth = glObj[1];
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_efbColor);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, m_targetWidth, m_targetHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, m_targetWidth, m_targetHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_efbDepth);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
|
||||
|
@ -119,7 +119,7 @@ void FramebufferManager::Init(int targetWidth, int targetHeight, int msaaSamples
|
|||
m_resolvedDepthTexture = glObj[1];
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_resolvedColorTexture);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, m_targetWidth, m_targetHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, m_targetWidth, m_targetHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_resolvedDepthTexture);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
|
||||
|
@ -343,7 +343,7 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
|||
// the image will be allocated by glCopyTexImage2D (later).
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfbTexture);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, m_targetWidth, m_targetHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, m_targetWidth, m_targetHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ const XFBSource* FramebufferManager::getRealXFBSource(u32 xfbAddr, u32 fbWidth,
|
|||
glGenTextures(1, &m_realXFBSource.texture);
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_realXFBSource.texture);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, MAX_XFB_WIDTH, MAX_XFB_HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, MAX_XFB_WIDTH, MAX_XFB_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
|
|||
void PixelShaderCache::DisableShader()
|
||||
{
|
||||
CurrentShader = 0;
|
||||
if(ShaderEnabled)
|
||||
//if(ShaderEnabled)
|
||||
{
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, CurrentShader);
|
||||
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
@ -332,7 +332,7 @@ void PixelShaderCache::DisableShader()
|
|||
void PixelShaderCache::SetCurrentShader(GLuint Shader)
|
||||
{
|
||||
//The caching here breakes Super Mario Sunshine i'm still trying to figure out wy
|
||||
if(ShaderEnabled /*&& CurrentShader != Shader*/)
|
||||
//if(ShaderEnabled /*&& CurrentShader != Shader*/)
|
||||
{
|
||||
CurrentShader = Shader;
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, CurrentShader);
|
||||
|
@ -342,13 +342,13 @@ void PixelShaderCache::SetCurrentShader(GLuint Shader)
|
|||
//Enable Fragment program and bind initial program
|
||||
void PixelShaderCache::EnableShader(GLuint Shader)
|
||||
{
|
||||
if(!ShaderEnabled)
|
||||
//if(!ShaderEnabled)
|
||||
{
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
ShaderEnabled = true;
|
||||
CurrentShader = 0;
|
||||
}
|
||||
if(CurrentShader != Shader)
|
||||
//if(CurrentShader != Shader)
|
||||
{
|
||||
CurrentShader = Shader;
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, CurrentShader);
|
||||
|
|
|
@ -1345,13 +1345,7 @@ void UpdateViewport()
|
|||
int GLWidth = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX);
|
||||
int GLHeight = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY);
|
||||
double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
|
||||
double GLFar = xfregs.rawViewport[5] / 16777216.0f;
|
||||
|
||||
if (GLNear < 0.0f) GLNear = 0.0f;
|
||||
if (GLNear > 1.0f) GLNear = 1.0f;
|
||||
if (GLFar > 1.0f) GLFar = 1.0f;
|
||||
if (GLFar < 0.0f) GLFar = 0.0f;
|
||||
|
||||
double GLFar = xfregs.rawViewport[5] / 16777216.0f;
|
||||
// Update the view port
|
||||
glViewport(GLx, GLy, GLWidth, GLHeight);
|
||||
glDepthRange(GLNear, GLFar);
|
||||
|
|
|
@ -269,7 +269,7 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
|||
|
||||
void VertexShaderCache::DisableShader()
|
||||
{
|
||||
if(ShaderEnabled)
|
||||
//if(ShaderEnabled)
|
||||
{
|
||||
CurrentShader = 0;
|
||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, CurrentShader);
|
||||
|
@ -280,7 +280,7 @@ void VertexShaderCache::DisableShader()
|
|||
|
||||
void VertexShaderCache::SetCurrentShader(GLuint Shader)
|
||||
{
|
||||
if(ShaderEnabled && CurrentShader != Shader)
|
||||
//if(ShaderEnabled && CurrentShader != Shader)
|
||||
{
|
||||
CurrentShader = Shader;
|
||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, CurrentShader);
|
||||
|
@ -289,13 +289,13 @@ void VertexShaderCache::SetCurrentShader(GLuint Shader)
|
|||
|
||||
void VertexShaderCache::EnableShader(GLuint Shader)
|
||||
{
|
||||
if(!ShaderEnabled)
|
||||
//if(!ShaderEnabled)
|
||||
{
|
||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
||||
ShaderEnabled= true;
|
||||
CurrentShader = 0;
|
||||
}
|
||||
if(CurrentShader != Shader)
|
||||
//if(CurrentShader != Shader)
|
||||
{
|
||||
CurrentShader = Shader;
|
||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, CurrentShader);
|
||||
|
|
Loading…
Reference in New Issue