From c4c809f6b1bd40f945ab12e7b5adbb4b4e0998fc Mon Sep 17 00:00:00 2001 From: Rodolfo Osvaldo Bogado Date: Tue, 19 Jan 2010 15:00:45 +0000 Subject: [PATCH] Small fixes: in opengl correct an error introduced by mi in efb to ram alignment, it's seems to fix SMS but it missalign a lot of other games, so revert to the default. must solve truncated coins in NSMB. revert alpha testing values to the values in rev 4812 as they fix some games. in d3d dynamized the Render target size so it will change at runtime when viewport exceed it size, in the worse case it will cause a missing frame when resizing but in the games I tested is not noticeable at all This must solve all the remaining viewports problems in nvidia cards, in ati this is not needed. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4888 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/LinearDiskCache.cpp | 2 +- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 12 ++-- .../Src/TextureConversionShader.cpp | 2 +- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 61 ++++++++++++------- 4 files changed, 48 insertions(+), 29 deletions(-) diff --git a/Source/Core/Common/Src/LinearDiskCache.cpp b/Source/Core/Common/Src/LinearDiskCache.cpp index 820450bef4..ca467ca48d 100644 --- a/Source/Core/Common/Src/LinearDiskCache.cpp +++ b/Source/Core/Common/Src/LinearDiskCache.cpp @@ -18,7 +18,7 @@ #include "LinearDiskCache.h" static const char ID[4] = {'D', 'C', 'A', 'C'}; -const int version = 1; // TODO: Get from SVN_REV +const int version = 4888; // TODO: Get from SVN_REV LinearDiskCache::LinearDiskCache() : file_(NULL), num_entries_(0) { diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 54a433d71c..97eff04756 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -871,12 +871,12 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con static const char *tevAlphaFuncsTable[] = { "(false)", //ALPHACMP_NEVER 0 - "(prev.a <= %s - (0.5f/255.0f))", //ALPHACMP_LESS 1 - "(abs( prev.a - %s ) < (1.0f/255.0f))", //ALPHACMP_EQUAL 2 - "(prev.a < %s + (0.5f/255.0f))", //ALPHACMP_LEQUAL 3 - "(prev.a >= %s + (0.5f/255.0f))", //ALPHACMP_GREATER 4 - "(abs( prev.a - %s ) >= (1.0f/255.0f))", //ALPHACMP_NEQUAL 5 - "(prev.a > %s - (0.5f/255.0f))", //ALPHACMP_GEQUAL 6 + "(prev.a <= %s - (0.25f/255.0f))", //ALPHACMP_LESS 1 + "(abs( prev.a - %s ) < (0.5f/255.0f))", //ALPHACMP_EQUAL 2 + "(prev.a < %s + (0.25f/255.0f))", //ALPHACMP_LEQUAL 3 + "(prev.a >= %s + (0.25f/255.0f))", //ALPHACMP_GREATER 4 + "(abs( prev.a - %s ) >= (0.5f/255.0f))", //ALPHACMP_NEQUAL 5 + "(prev.a > %s - (0.25f/255.0f))", //ALPHACMP_GEQUAL 6 "(true)" //ALPHACMP_ALWAYS 7 }; diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index eb6b83e234..8c8a75b403 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -116,7 +116,7 @@ void WriteSwizzler(char*& p, u32 format,bool HLSL) } else { - WRITE(p, " sampleUv = sampleUv + float2(1.0f,-1.0f);\n"); + WRITE(p, " sampleUv = sampleUv;\n"); } } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index d2863ce2df..88a1f1de8a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -58,8 +58,7 @@ static int s_backbuffer_height; static float xScale; static float yScale; -static int FULL_EFB_WIDTH = EFB_WIDTH; -static int FULL_EFB_HEIGHT = EFB_HEIGHT; +static bool AUTO_ADJUST_RENDERTARGET_SIZE = false; static int s_recordWidth; static int s_recordHeight; @@ -272,21 +271,11 @@ bool Renderer::Init() xScale = (float)s_target_width / (float)EFB_WIDTH; yScale = (float)s_target_height / (float)EFB_HEIGHT; - if (!D3D::IsATIDevice()) - { - FULL_EFB_WIDTH = 2 * EFB_WIDTH; - FULL_EFB_HEIGHT = 2 * EFB_HEIGHT; - s_Fulltarget_width = FULL_EFB_WIDTH * xScale; - s_Fulltarget_height = FULL_EFB_HEIGHT * yScale; - } - else - { - s_Fulltarget_width = s_target_width; - s_Fulltarget_height = s_target_height; - } - + s_Fulltarget_width = s_backbuffer_width; + s_Fulltarget_height = s_backbuffer_height; + //apply automatic resizing only is not an ati card, ati can handle large viewports :) + AUTO_ADJUST_RENDERTARGET_SIZE = true;//!D3D::IsATIDevice(); - s_LastFrameDumped = false; s_AVIDumping = false; @@ -843,10 +832,6 @@ 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() { @@ -883,7 +868,41 @@ void UpdateViewport() Y += Height; Height *= -1; } - + if(AUTO_ADJUST_RENDERTARGET_SIZE) + { + bool sizeChanged = false; + if(X < 0) + { + s_Fulltarget_width -= 2 * X; + X = 0; + sizeChanged=true; + } + if(Y < 0) + { + s_Fulltarget_height -= 2 * Y; + Y = 0; + sizeChanged=true; + } + if(X + Width > s_Fulltarget_width) + { + s_Fulltarget_width += (X + Width - s_Fulltarget_width) * 2; + sizeChanged=true; + } + if(Y + Height > s_Fulltarget_height) + { + s_Fulltarget_height += (Y + Height - s_Fulltarget_height) * 2; + sizeChanged=true; + } + if(sizeChanged) + { + D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface()); + D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface()); + FBManager::Destroy(); + FBManager::Create(); + D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface()); + D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface()); + } + } vp.X = X; vp.Y = Y; vp.Width = Width;