]> git.cworth.org Git - apitrace/commitdiff
Fix compressed texture size computation.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 2 May 2012 12:13:48 +0000 (13:13 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 2 May 2012 12:13:48 +0000 (13:13 +0100)
dispatch/d3d9imports.hpp
helpers/d3dsize.hpp
specs/d3d9types.py
wrappers/d3d9trace.py

index 0d64f757d104332194cc4c5752bea8a5d3318a1b..1ecf293fed6b4a358aff6bcb497269a05ed58216 100644 (file)
 #define D3DFMT_A2B10G10R10_XR_BIAS 119
 #endif
 
-#ifndef D3DFMT_ATI1
-#define D3DFMT_ATI1 ((D3DFORMAT)MAKEFOURCC('A','T','I','1'))
+#ifndef D3DFMT_ATI1N
+#define D3DFMT_ATI1N ((D3DFORMAT)MAKEFOURCC('A','T','I','1'))
 #endif
 
-#ifndef D3DFMT_ATI2
-#define D3DFMT_ATI2 ((D3DFORMAT)MAKEFOURCC('A','T','I','2'))
+#ifndef D3DFMT_ATI2N
+#define D3DFMT_ATI2N ((D3DFORMAT)MAKEFOURCC('A','T','I','2'))
 #endif
 
 #ifndef D3DFMT_AYUV
index 31fcd740a95c55d2bc645e6d58191f984821c891..9f662971f21cc82a7745bd3cc96770383da23e04 100644 (file)
@@ -139,17 +139,24 @@ _getLockSize(D3DFORMAT Format, UINT Width, UINT Height, INT RowPitch, UINT Depth
     case D3DFMT_DXT3:
     case D3DFMT_DXT4:
     case D3DFMT_DXT5:
-    case D3DFMT_ATI1:
-    case D3DFMT_ATI2:
-        Width /= 4;
-        Height /= 4;
+        Width  = (Width  + 3) / 4;
+        Height = (Height + 3) / 4;
+        break;
+
+    case D3DFMT_ATI1N:
+    case D3DFMT_ATI2N:
+        /*
+         * Because these are unsupported formats, RowPitch is not set to the
+         * number of bytes between row of blocks, but instead in such way that
+         * Height * RowPitch will match the expected size.
+         */
         break;
 
     case D3DFMT_UYVY:
     case D3DFMT_R8G8_B8G8:
     case D3DFMT_YUY2:
     case D3DFMT_G8R8_G8B8:
-        Width /= 2;
+        Width = (Width + 1) / 2;
         break;
 
     case D3DFMT_NV12:
index 6622e73df9397fd09ff2b81d076e85c88d34bd1e..47bed8651d02e0856889319cf40bd29870776457 100644 (file)
@@ -729,8 +729,8 @@ D3DFORMAT = Enum("D3DFORMAT", [
     "D3DFMT_BINARYBUFFER",
 
     # Unofficial formats
-    "D3DFMT_ATI1",
-    "D3DFMT_ATI2",
+    "D3DFMT_ATI1N",
+    "D3DFMT_ATI2N",
     "D3DFMT_AYUV",
     "D3DFMT_DF16",
     "D3DFMT_DF24",
index 9185f038e6a63e5d8a6cd96f7881ffd7c4878805..d3f2e024a0330146d35f79a2de80fd05148fbcf2 100644 (file)
@@ -53,7 +53,7 @@ class D3D9Tracer(DllTracer):
 
     def implementWrapperInterfaceMethodBody(self, interface, base, method):
         if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'):
-            print '    if (m_pbData) {'
+            print '    if (_LockedSize && m_pbData) {'
             self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', '_LockedSize')
             print '    }'