From 4f4f5325f6d355785741a1bd9a26b692c41cc177 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Mon, 13 Dec 2010 18:51:08 +0000 Subject: [PATCH] DX9: Added another comment to further elaborate what drawShadedTexQuad is doing. This comment should give a great speed increase, numerous games (SMG, NSMBW, DKCR, ...) which I tested are at least 20% faster now! git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6574 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 4be3858988..253c105be8 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -374,6 +374,9 @@ void quad2d(float x1, float y1, float x2, float y2, u32 color, float u1, float v So generally speaking the correct coordinate range is [-1-0.5/(w/2);1-0.5/(w/2)] which can be simplified to [-1-1/w;1-1/w]. + Note that while for D3DFVF_XYZRHW the y coordinate of the bottom of the screen is positive, + it's negative for D3DFVF_XYZW. This is why we need to _add_ 1/h for the second position component instead of subtracting it. + For a detailed explanation of this read the MSDN article "Directly Mapping Texels to Pixels (Direct3D 9)". */ void drawShadedTexQuad(IDirect3DTexture9 *texture, @@ -394,7 +397,6 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture, float v1=((float)rSource->top) * sh; float v2=((float)rSource->bottom) * sh; - // TODO: Why do we ADD dh here? struct Q2DVertex { float x,y,z,rhw,u,v,w,h,L,T,R,B; } coords[4] = { {-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},