[mupen64plus-video-rice] 73/191: Rewrite highres_memcorruption.patch

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 06:17:19 UTC 2015


This is an automated email from the git hooks/post-receive script.

ecsv-guest pushed a commit to branch armhf_test
in repository mupen64plus-video-rice.

commit 244fbc38605aa9e00f5431470afb6100663641ab
Author: Sven Eckelmann <sven at narfation.org>
Date:   Sun Aug 14 16:57:23 2011 +0200

    Rewrite highres_memcorruption.patch
    
    The highres textures should be created in a buffer with the size calculated
    from the desired native size and the size of the highres texture. The size used
    here should be 2**scaleShift as calculated by FindScaleFactor. This information
    is later used to correctly clamp and mirror textures. Therefore,
    (2**scaleShift)*(Width|Height)ToCreate is the size of the final texture and
    (2**scaleShift)*(Width|Height)ToLoad is the size of the texture information
    which are loaded from the external image. The mirror factor is already part of
    the (Width|Height)ToCreate value and it must not be multiplied by it again to
    get the texture buffer size.
    
    Doing it differently will result in segfaults or corrupted textures.
---
 debian/changelog                                |  8 ++++
 debian/patches/divide_by_zero.patch             |  2 +-
 debian/patches/highres_memcorruption.patch      | 59 ++++++++++++++++++++++---
 debian/patches/png_truecolor_conversation.patch |  2 +-
 debian/patches/undefined_functions.patch        |  2 +-
 5 files changed, 64 insertions(+), 9 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index b076eff..6af72d3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+mupen64plus-video-rice (1.99.4-4) UNRELEASED; urgency=low
+
+  * debian/patches:
+    - Rewrite highres_memcorruption.patch to prevent further crashes and texture
+      corruptions
+
+ -- Sven Eckelmann <sven at narfation.org>  Sun, 14 Aug 2011 16:56:04 +0200
+
 mupen64plus-video-rice (1.99.4-3) unstable; urgency=low
 
   * Upload to unstable
diff --git a/debian/patches/divide_by_zero.patch b/debian/patches/divide_by_zero.patch
index d25c70a..dceb0fe 100644
--- a/debian/patches/divide_by_zero.patch
+++ b/debian/patches/divide_by_zero.patch
@@ -4,7 +4,7 @@ Author: Richard Goedeken <Richard at fascinationsoftware.com>
 
 ---
 diff --git a/src/TextureFilters.cpp b/src/TextureFilters.cpp
-index 7837887a076ffd8b608b51fa11cab51ea95ff062..a8ac0d422b99e8c16e67d5bf6e9f8d87f535bd90 100644
+index 22ae445b3a53079387f418be3f7ca05040c7cfed..9641e1746deab2ee81c0f113915ee32dc192d905 100644
 --- a/src/TextureFilters.cpp
 +++ b/src/TextureFilters.cpp
 @@ -1378,7 +1378,8 @@ int FindScaleFactor(const ExtTxtrInfo &info, TxtrCacheEntry &entry)
diff --git a/debian/patches/highres_memcorruption.patch b/debian/patches/highres_memcorruption.patch
index 8f22074..63f3cdf 100644
--- a/debian/patches/highres_memcorruption.patch
+++ b/debian/patches/highres_memcorruption.patch
@@ -1,9 +1,21 @@
-Description: fix crash in loading Celda 2009 hi-res texture pack for Zelda Ocarina of Time
-Author: Richard Goedeken <Richard at fascinationsoftware.com>
+Description: Scale highres textures by precalculated scaleShift exponent
+ The highres textures should be created in a buffer with the size calculated
+ from the desired native size and the size of the highres texture. The size
+ used here should be 2**scaleShift as calculated by FindScaleFactor. This
+ information is later used to correctly clamp and mirror textures. Therefore,
+ (2**scaleShift)*(Width|Height)ToCreate is the size of the final texture and
+ (2**scaleShift)*(Width|Height)ToLoad is the size of the texture information
+ which are loaded from the external image. The mirror factor is already part of
+ the (Width|Height)ToCreate value and it must not be multiplied by it again to
+ get the texture buffer size.
+ .
+ Doing it differently will result in segfaults or corrupted textures.
+Origin: backport, https://bitbucket.org/richard42/mupen64plus-video-rice/changeset/d1cc49eac47d
+Author: Sven Eckelmann <sven at narfation.org>
 
 ---
 diff --git a/src/TextureFilters.cpp b/src/TextureFilters.cpp
-index e6adc5e115ac8b368544f974d2ca598366caa04c..20f904d8be25a2073b9527202342b0848c72a4d4 100644
+index e6adc5e115ac8b368544f974d2ca598366caa04c..3b728c78c463d4bae8965689189c57fbab5b4c1c 100644
 --- a/src/TextureFilters.cpp
 +++ b/src/TextureFilters.cpp
 @@ -1288,6 +1288,7 @@ void FindAllHiResTextures(void)
@@ -14,14 +26,49 @@ index e6adc5e115ac8b368544f974d2ca598366caa04c..20f904d8be25a2073b9527202342b084
          return;
      }
      else
-@@ -1849,8 +1850,8 @@ void LoadHiresTexture( TxtrCacheEntry &entry )
+@@ -1849,15 +1850,14 @@ void LoadHiresTexture( TxtrCacheEntry &entry )
      }
  
      // calculate the texture size magnification by comparing the N64 texture size and the hi-res texture size
 -    int scalex = width / (int)entry.ti.WidthToCreate;
 -    int scaley = height / (int)entry.ti.HeightToCreate;
-+    int scalex = width / (int)entry.ti.WidthToLoad;
-+    int scaley = height / (int)entry.ti.HeightToLoad;
++    int scale = 1 << scaleShift;
      int mirrorx = 1;
      int mirrory = 1;
      if (entry.ti.WidthToCreate/entry.ti.WidthToLoad == 2) mirrorx = 2;
+     if (entry.ti.HeightToCreate/entry.ti.HeightToLoad == 2) mirrory = 2;
+-    entry.pEnhancedTexture = CDeviceBuilder::GetBuilder()->CreateTexture(entry.ti.WidthToCreate*scalex*mirrorx, entry.ti.HeightToCreate*scaley*mirrory);
++    entry.pEnhancedTexture = CDeviceBuilder::GetBuilder()->CreateTexture(entry.ti.WidthToCreate*scale, entry.ti.HeightToCreate*scale);
+     DrawInfo info;
+-
++    
+     if( entry.pEnhancedTexture && entry.pEnhancedTexture->StartUpdate(&info) )
+     {
+ 
+@@ -1913,22 +1913,22 @@ void LoadHiresTexture( TxtrCacheEntry &entry )
+ 
+         if (mirrorx == 2)
+         {
+-            //printf("Mirror: ToCreate: (%d,%d) ToLoad: (%d,%d) Scale: (%i,%i) Mirror: (%i,%i) Size: (%i,%i) Mask: %i\n", entry.ti.WidthToCreate, entry.ti.HeightToCreate, entry.ti.WidthToLoad, entry.ti.HeightToLoad, scalex, scaley, mirrorx, mirrory, width, height, entry.ti.maskS+scaleShift);
++            //printf("Mirror: ToCreate: (%d,%d) ToLoad: (%d,%d) Scale: (%i,%i) Mirror: (%i,%i) Size: (%i,%i) Mask: %i\n", entry.ti.WidthToCreate, entry.ti.HeightToCreate, entry.ti.WidthToLoad, entry.ti.HeightToLoad, scale, scale, mirrorx, mirrory, width, height, entry.ti.maskS+scaleShift);
+             gTextureManager.Mirror(info.lpSurface, width, entry.ti.maskS+scaleShift, width*2, width*2, height, S_FLAG, 4 );
+         }
+ 
+         if (mirrory == 2)
+         {
+-            //printf("Mirror: ToCreate: (%d,%d) ToLoad: (%d,%d) Scale: (%i,%i) Mirror: (%i,%i) Size: (%i,%i) Mask: %i\n", entry.ti.WidthToCreate, entry.ti.HeightToCreate, entry.ti.WidthToLoad, entry.ti.HeightToLoad, scalex, scaley, mirrorx, mirrory, width, height, entry.ti.maskT+scaleShift);
++            //printf("Mirror: ToCreate: (%d,%d) ToLoad: (%d,%d) Scale: (%i,%i) Mirror: (%i,%i) Size: (%i,%i) Mask: %i\n", entry.ti.WidthToCreate, entry.ti.HeightToCreate, entry.ti.WidthToLoad, entry.ti.HeightToLoad, scale, scale, mirrorx, mirrory, width, height, entry.ti.maskT+scaleShift);
+             gTextureManager.Mirror(info.lpSurface, height, entry.ti.maskT+scaleShift, height*2, entry.pEnhancedTexture->m_dwCreatedTextureWidth, height, T_FLAG, 4 );
+         }
+ 
+-        if( entry.ti.WidthToCreate*scalex*mirrorx < entry.pEnhancedTexture->m_dwCreatedTextureWidth )
++        if( entry.ti.WidthToCreate*scale < entry.pEnhancedTexture->m_dwCreatedTextureWidth )
+         {
+             // Clamp
+             gTextureManager.Clamp(info.lpSurface, width, entry.pEnhancedTexture->m_dwCreatedTextureWidth, entry.pEnhancedTexture->m_dwCreatedTextureWidth, height, S_FLAG, 4 );
+         }
+-        if( entry.ti.HeightToCreate*scaley*mirrory < entry.pEnhancedTexture->m_dwCreatedTextureHeight )
++        if( entry.ti.HeightToCreate*scale < entry.pEnhancedTexture->m_dwCreatedTextureHeight )
+         {
+             // Clamp
+             gTextureManager.Clamp(info.lpSurface, height, entry.pEnhancedTexture->m_dwCreatedTextureHeight, entry.pEnhancedTexture->m_dwCreatedTextureWidth, height, T_FLAG, 4 );
diff --git a/debian/patches/png_truecolor_conversation.patch b/debian/patches/png_truecolor_conversation.patch
index c3f1ec1..cdd8bf8 100644
--- a/debian/patches/png_truecolor_conversation.patch
+++ b/debian/patches/png_truecolor_conversation.patch
@@ -6,7 +6,7 @@ Author: Richard Goedeken <Richard at fascinationsoftware.com>
 
 ---
 diff --git a/src/TextureFilters.cpp b/src/TextureFilters.cpp
-index 20f904d8be25a2073b9527202342b0848c72a4d4..7837887a076ffd8b608b51fa11cab51ea95ff062 100644
+index 3b728c78c463d4bae8965689189c57fbab5b4c1c..22ae445b3a53079387f418be3f7ca05040c7cfed 100644
 --- a/src/TextureFilters.cpp
 +++ b/src/TextureFilters.cpp
 @@ -1565,9 +1565,28 @@ bool LoadRGBBufferFromPNGFile(char *filename, unsigned char **pbuf, int &width,
diff --git a/debian/patches/undefined_functions.patch b/debian/patches/undefined_functions.patch
index bd4c5cc..2b5c77a 100644
--- a/debian/patches/undefined_functions.patch
+++ b/debian/patches/undefined_functions.patch
@@ -86,7 +86,7 @@ index 07164aab58c88907cffaf1228c6b411a768b3bac..f044ec950e29bfbad79d729ea438537d
      WindowSettingStruct &w = windowSetting;
      w.clipping.left = (uint32)(gRSP.real_clip_scissor_left*windowSetting.fMultX);
 diff --git a/src/TextureFilters.cpp b/src/TextureFilters.cpp
-index a8ac0d422b99e8c16e67d5bf6e9f8d87f535bd90..37c46d95bb0fe246f80bba609161374d0efb0885 100644
+index 9641e1746deab2ee81c0f113915ee32dc192d905..869adfc97d0c968e38d4c0084c1476388f4de87d 100644
 --- a/src/TextureFilters.cpp
 +++ b/src/TextureFilters.cpp
 @@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-video-rice.git



More information about the Pkg-games-commits mailing list