From 7711f8288b662c4e264f42e13c8e49be4172b271 Mon Sep 17 00:00:00 2001 From: rogerman Date: Mon, 5 Dec 2016 11:45:40 -0800 Subject: [PATCH] SoftRasterizer: Fix bug where the texture wrap mode would be applied inconsistently under multithreaded rendering. (Regression from 032622e.) --- desmume/src/rasterize.cpp | 20 ++++++-------------- desmume/src/rasterize.h | 4 +--- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index b8bdbe2f8..000bf3dca 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -332,6 +332,7 @@ protected: SoftRasterizerTexture *currentTexture; VERT* verts[MAX_CLIPPED_VERTS]; int polynum; + u8 _textureWrapMode; public: bool _debug_thisPoly; @@ -353,7 +354,8 @@ public: return RENDER3DERROR_NOERR; } - theTexture->SetRenderWrapMode(thePoly.texParam); + this->_textureWrapMode = (thePoly.texParam >> 16) & 0x0F; + theTexture->ResetCacheAge(); theTexture->IncreaseCacheUsageCount(1); @@ -379,7 +381,7 @@ public: } const u32 *textureData = this->currentTexture->GetRenderData(); - this->currentTexture->GetRenderSamplerCoordinates(iu, iv); + this->currentTexture->GetRenderSamplerCoordinates(this->_textureWrapMode, iu, iv); FragmentColor color; color.color = textureData[( iv << this->currentTexture->GetRenderWidthShift() ) + iu]; @@ -1218,19 +1220,9 @@ u32 SoftRasterizerTexture::GetRenderWidthShift() const return this->_renderWidthShift; } -u8 SoftRasterizerTexture::GetRenderWrapMode() const +FORCEINLINE void SoftRasterizerTexture::GetRenderSamplerCoordinates(const u8 wrapMode, s32 &iu, s32 &iv) const { - return this->_renderWrapMode; -} - -void SoftRasterizerTexture::SetRenderWrapMode(u32 texParam) -{ - this->_renderWrapMode = (texParam >> 16) & 0x0F; -} - -FORCEINLINE void SoftRasterizerTexture::GetRenderSamplerCoordinates(s32 &iu, s32 &iv) const -{ - switch (this->_renderWrapMode) + switch (wrapMode) { //flip none case 0x0: _hclamp(iu); _vclamp(iv); break; diff --git a/desmume/src/rasterize.h b/desmume/src/rasterize.h index 18e025b4e..e7ced3fb1 100644 --- a/desmume/src/rasterize.h +++ b/desmume/src/rasterize.h @@ -77,10 +77,8 @@ public: s32 GetRenderWidthMask() const; s32 GetRenderHeightMask() const; u32 GetRenderWidthShift() const; - u8 GetRenderWrapMode() const; - void SetRenderWrapMode(u32 texParam); - void GetRenderSamplerCoordinates(s32 &iu, s32 &iv) const; + void GetRenderSamplerCoordinates(const u8 wrapMode, s32 &iu, s32 &iv) const; void SetUseDeposterize(bool willDeposterize); void SetScalingFactor(size_t scalingFactor);