diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 3a4b5d0699..cfb74df225 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -434,13 +434,15 @@ void drawShadedTexSubQuad(IDirect3DTexture9 *texture, // Fills a certain area of the current render target with the specified color // Z buffer disabled; destination coordinates normalized to (-1;1) -void drawColorQuad(u32 Color, float x1, float y1, float x2, float y2) +void drawColorQuad(int DestWidth, int DestHeight, u32 Color, float x1, float y1, float x2, float y2) { + float dw = 1.f / (float)DestWidth; + float dh = 1.f / (float)DestHeight; struct CQVertex { float x, y, z, rhw; u32 col; } coords[4] = { - { x1, y2, 0.f, 1.f, Color }, - { x2, y2, 0.f, 1.f, Color }, - { x1, y1, 0.f, 1.f, Color }, - { x2, y1, 0.f, 1.f, Color }, + { x1-dw, y2+dh, 0.f, 1.f, Color }, + { x2-dw, y2+dh, 0.f, 1.f, Color }, + { x1-dw, y1+dh, 0.f, 1.f, Color }, + { x2-dw, y1+dh, 0.f, 1.f, Color }, }; dev->SetVertexShader(VertexShaderCache::GetClearVertexShader()); dev->SetPixelShader(PixelShaderCache::GetClearProgram()); @@ -449,13 +451,15 @@ void drawColorQuad(u32 Color, float x1, float y1, float x2, float y2) RestoreShaders(); } -void drawClearQuad(u32 Color,float z,IDirect3DPixelShader9 *PShader,IDirect3DVertexShader9 *Vshader) +void drawClearQuad(int DestWidth, int DestHeight, u32 Color, float z, IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader) { + float dw = 1.f / (float)DestWidth; + float dh = 1.f / (float)DestHeight; struct Q2DVertex { float x,y,z,rhw;u32 color;} coords[4] = { - {-1.0f, 1.0f, z, 1.0f, Color}, - { 1.0f, 1.0f, z, 1.0f, Color}, - { 1.0f, -1.0f, z, 1.0f, Color}, - {-1.0f, -1.0f, z, 1.0f, Color} + {-1.0f-dw, 1.0f+dh, z, 1.0f, Color}, + { 1.0f-dw, 1.0f+dh, z, 1.0f, Color}, + { 1.0f-dw, -1.0f+dh, z, 1.0f, Color}, + {-1.0f-dw, -1.0f+dh, z, 1.0f, Color} }; dev->SetVertexShader(Vshader); dev->SetPixelShader(PShader); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h index 882f112ece..93e60f938b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h @@ -82,8 +82,8 @@ namespace D3D IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader, float Gamma = 1.0f); - void drawClearQuad(u32 Color, float z, IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader); - void drawColorQuad(u32 Color, float x1, float y1, float x2, float y2); + void drawClearQuad(int DestWidth, int DestHeight, u32 Color, float z, IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader); + void drawColorQuad(int DestWidth, int DestHeight, u32 Color, float x1, float y1, float x2, float y2); void SaveRenderStates(); void RestoreRenderStates(); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index df7fa6c2ee..414f372674 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -691,10 +691,11 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) { // TODO: Speed this up by batching pokes? ResetAPIState(); - D3D::drawColorQuad(poke_data, (float)RectToLock.left * 2.f / (float)Renderer::GetFullTargetWidth() - 1.f, - - (float)RectToLock.top * 2.f / (float)Renderer::GetFullTargetHeight() + 1.f, - (float)RectToLock.right * 2.f / (float)Renderer::GetFullTargetWidth() - 1.f, - - (float)RectToLock.bottom * 2.f / (float)Renderer::GetFullTargetHeight() + 1.f); + D3D::drawColorQuad(GetFullTargetWidth(), GetFullTargetHeight(), poke_data, + (float)RectToLock.left * 2.f / (float)Renderer::GetFullTargetWidth() - 1.f, + - (float)RectToLock.top * 2.f / (float)Renderer::GetFullTargetHeight() + 1.f, + (float)RectToLock.right * 2.f / (float)Renderer::GetFullTargetWidth() - 1.f, + - (float)RectToLock.bottom * 2.f / (float)Renderer::GetFullTargetHeight() + 1.f); RestoreAPIState(); return 0; } @@ -838,7 +839,7 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE vp.MinZ = 0.0; vp.MaxZ = 1.0; D3D::dev->SetViewport(&vp); - D3D::drawClearQuad(color, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader()); + D3D::drawClearQuad(GetFullTargetWidth(), GetFullTargetHeight(), color, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader()); RestoreAPIState(); } @@ -978,7 +979,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons vp.MinZ = 0.0f; vp.MaxZ = 1.0f; D3D::dev->SetViewport(&vp); - D3D::drawClearQuad(0, 1.0, PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader()); + D3D::drawClearQuad(GetFullTargetWidth(), GetFullTargetHeight(), 0, 1.0, PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader()); } else {