From 36b192af00650546b9fc8c3b6b77729c8e77d6c4 Mon Sep 17 00:00:00 2001 From: rogerman Date: Thu, 8 Dec 2016 01:18:41 -0800 Subject: [PATCH] SoftRasterizer: Fix bug where texture sampling coordinates were incorrectly calculated when texture upscaling is used with GFX3D_TXTHack enabled. Fixes issue #5. (Related to commit a8c8a86.) --- desmume/src/rasterize.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index f19e8e8cd..9905ff2e0 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -366,18 +366,20 @@ public: { //finally, we can use floor here. but, it is slower than we want. //the best solution is probably to wait until the pipeline is full of fixed point + const float fu = u * (float)this->currentTexture->GetRenderWidth() / (float)this->currentTexture->GetWidth(); + const float fv = v * (float)this->currentTexture->GetRenderHeight() / (float)this->currentTexture->GetHeight(); s32 iu = 0; s32 iv = 0; if (!CommonSettings.GFX3D_TXTHack) { - iu = s32floor(u * (float)this->currentTexture->GetRenderWidth() / (float)this->currentTexture->GetWidth()); - iv = s32floor(v * (float)this->currentTexture->GetRenderHeight() / (float)this->currentTexture->GetHeight()); + iu = s32floor(fu); + iv = s32floor(fv); } else { - iu = round_s(u); - iv = round_s(v); + iu = round_s(fu); + iv = round_s(fv); } const u32 *textureData = this->currentTexture->GetRenderData();