diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 1f4390b7c0..c230bec669 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -380,27 +380,31 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture, const RECT *rSource, int SourceWidth, int SourceHeight, + int DestWidth, + int DestHeight, IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader) { float sw = 1.0f /(float) SourceWidth; float sh = 1.0f /(float) SourceHeight; - float u1=((float)rSource->left + 0.5f) * sw; - float u2=((float)rSource->right + 0.5f) * sw; - float v1=((float)rSource->top + 0.5f) * sh; - float v2=((float)rSource->bottom + 0.5f) * sh; + float dw = 1.0f /(float) DestWidth; + float dh = 1.0f /(float) DestHeight; + float u1=((float)rSource->left) * sw; + float u2=((float)rSource->right) * sw; + float v1=((float)rSource->top) * sh; + float v2=((float)rSource->bottom) * sh; struct Q2DVertex { float x,y,z,rhw,u,v,w,h,L,T,R,B; } coords[4] = { - {-1.0f, 1.0f, 0.0f,1.0f, u1, v1, sw, sh,u1,v1,u2,v2}, - { 1.0f, 1.0f, 0.0f,1.0f, u2, v1, sw, sh,u1,v1,u2,v2}, - { 1.0f,-1.0f, 0.0f,1.0f, u2, v2, sw, sh,u1,v1,u2,v2}, - {-1.0f,-1.0f, 0.0f,1.0f, u1, v2, sw, sh,u1,v1,u2,v2} + {-1.0f - dw,-1.0f + dh, 0.0f,1.0f, u1, v2, sw, sh,u1,v1,u2,v2}, + {-1.0f - dw, 1.0f + dh, 0.0f,1.0f, u1, v1, sw, sh,u1,v1,u2,v2}, + { 1.0f - dw,-1.0f + dh, 0.0f,1.0f, u2, v2, sw, sh,u1,v1,u2,v2}, + { 1.0f - dw, 1.0f + dh, 0.0f,1.0f, u2, v1, sw, sh,u1,v1,u2,v2} }; dev->SetVertexShader(Vshader); dev->SetPixelShader(PShader); D3D::SetTexture(0, texture); dev->SetFVF(D3DFVF_XYZW | D3DFVF_TEX3 | D3DFVF_TEXCOORDSIZE4(2)); - dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex)); + dev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, coords, sizeof(Q2DVertex)); RestoreShaders(); } @@ -409,27 +413,31 @@ void drawShadedTexSubQuad(IDirect3DTexture9 *texture, int SourceWidth, int SourceHeight, const MathUtil::Rectangle *rDest, + int DestWidth, + int DestHeight, IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader) { float sw = 1.0f /(float) SourceWidth; float sh = 1.0f /(float) SourceHeight; - float u1= (rSource->left + 0.5f) * sw; - float u2= (rSource->right + 0.5f) * sw; - float v1= (rSource->top + 0.5f) * sh; - float v2= (rSource->bottom + 0.5f) * sh; + float dw = 1.0f /(float) DestWidth; + float dh = 1.0f /(float) DestHeight; + float u1= rSource->left * sw; + float u2= rSource->right * sw; + float v1= rSource->top * sh; + float v2= rSource->bottom * sh; struct Q2DVertex { float x,y,z,rhw,u,v,w,h,L,T,R,B; } coords[4] = { - { rDest->left , rDest->bottom, 0.0f,1.0f, u1, v1, sw, sh,u1,v1,u2,v2}, - { rDest->right, rDest->bottom, 0.0f,1.0f, u2, v1, sw, sh,u1,v1,u2,v2}, - { rDest->right, rDest->top , 0.0f,1.0f, u2, v2, sw, sh,u1,v1,u2,v2}, - { rDest->left , rDest->top , 0.0f,1.0f, u1, v2, sw, sh,u1,v1,u2,v2} + { rDest->left - dw , rDest->top + dh, 1.0f,1.0f, u1, v2, sw, sh,u1,v1,u2,v2}, + { rDest->left - dw , rDest->bottom + dh, 1.0f,1.0f, u1, v1, sw, sh,u1,v1,u2,v2}, + { rDest->right - dw , rDest->top + dh, 1.0f,1.0f, u2, v2, sw, sh,u1,v1,u2,v2}, + { rDest->right - dw , rDest->bottom + dh, 1.0f,1.0f, u2, v1, sw, sh,u1,v1,u2,v2} }; dev->SetVertexShader(Vshader); dev->SetPixelShader(PShader); D3D::SetTexture(0, texture); dev->SetFVF(D3DFVF_XYZW | D3DFVF_TEX3 | D3DFVF_TEXCOORDSIZE4(2)); - dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex)); + dev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, coords, sizeof(Q2DVertex)); RestoreShaders(); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h index 15810ddefd..4d535aa55d 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h @@ -64,6 +64,8 @@ namespace D3D const RECT *rSource, int SourceWidth, int SourceHeight, + int DestWidth, + int DestHeight, IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader); void drawShadedTexSubQuad(IDirect3DTexture9 *texture, @@ -71,6 +73,8 @@ namespace D3D int SourceWidth, int SourceHeight, const MathUtil::Rectangle *rDest, + int DestWidth, + int DestHeight, IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader); void drawClearQuad(u32 Color,float z,IDirect3DPixelShader9 *PShader,IDirect3DVertexShader9 *Vshader); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp index 7c5b4555dd..bace776f7b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp @@ -451,6 +451,8 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight &sourcerect, Renderer::GetFullTargetWidth() , Renderer::GetFullTargetHeight(), + target_width, + target_height, PixelShaderCache::GetColorCopyProgram(SSAAMode), (SSAAMode != 0)? VertexShaderCache::GetFSAAVertexShader() : VertexShaderCache::GetSimpleVertexShader()); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 5bcb2061ea..013d3ea9b0 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -759,6 +759,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) &RectToLock, Renderer::GetFullTargetWidth() , Renderer::GetFullTargetHeight(), + 4,4, (BufferFormat == FOURCC_RAWZ)?PixelShaderCache::GetColorMatrixProgram(0):PixelShaderCache::GetDepthMatrixProgram(0), VertexShaderCache::GetSimpleVertexShader()); @@ -1095,7 +1096,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) drawRc.top = 1.0f - 2.0f * ((hOffset + xfbHeight) / (float)fbHeight); drawRc.left = -(xfbWidth / (float)fbWidth); drawRc.right = (xfbWidth / (float)fbWidth); - + if (!g_ActiveConfig.bAutoScale) { @@ -1117,7 +1118,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) drawRc.right = 1; } - D3D::drawShadedTexSubQuad(xfbSource->texture,&sourceRc,xfbSource->texWidth,xfbSource->texHeight,&drawRc,PixelShaderCache::GetColorCopyProgram(0),VertexShaderCache::GetSimpleVertexShader()); + D3D::drawShadedTexSubQuad(xfbSource->texture,&sourceRc,xfbSource->texWidth,xfbSource->texHeight,&drawRc,Width,Height,PixelShaderCache::GetColorCopyProgram(0),VertexShaderCache::GetSimpleVertexShader()); } D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp index db5507c8f6..894293bcd2 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp @@ -582,6 +582,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo &sourcerect, Renderer::GetFullTargetWidth() , Renderer::GetFullTargetHeight(), + Scaledtex_w, + Scaledtex_h, ((bformat != FOURCC_RAWZ && bformat != D3DFMT_D24X8) && bFromZBuffer)? PixelShaderCache::GetDepthMatrixProgram(SSAAMode): PixelShaderCache::GetColorMatrixProgram(SSAAMode), (SSAAMode != 0)? VertexShaderCache::GetFSAAVertexShader() : VertexShaderCache::GetSimpleVertexShader()); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp index 57951d63bf..23796a1a50 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp @@ -271,7 +271,7 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr // Draw... - D3D::drawShadedTexQuad(srcTexture,&SrcRect,1,1,shader,VertexShaderCache::GetSimpleVertexShader()); + D3D::drawShadedTexQuad(srcTexture,&SrcRect,1,1,dstWidth,dstHeight,shader,VertexShaderCache::GetSimpleVertexShader()); hr = D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface()); hr = D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface()); Renderer::RestoreAPIState(); @@ -442,9 +442,9 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE RECT sourcerect; sourcerect.bottom = srcHeight; - sourcerect.left = -1; + sourcerect.left = 0; sourcerect.right = srcFmtWidth; - sourcerect.top = -1; + sourcerect.top = 0; D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); @@ -463,6 +463,8 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE &sourcerect, 1 , 1, + srcWidth, + srcHeight, s_yuyvToRgbProgram, VertexShaderCache::GetSimpleVertexShader());