wined3d: Use WINED3DFMT_FLAG_COMPRESSED instead of checking for specific formats.

Henri Verbeet hverbeet at codeweavers.com
Fri Jun 12 02:46:03 CDT 2009


---
 dlls/wined3d/device.c  |    8 ++------
 dlls/wined3d/surface.c |   17 ++++-------------
 2 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 896f048..2032426 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5975,12 +5975,8 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
     } else { /* Full width, so just write out the whole texture */
         const unsigned char* data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
 
-        if (WINED3DFMT_DXT1 == destFormat ||
-            WINED3DFMT_DXT2 == destFormat ||
-            WINED3DFMT_DXT3 == destFormat ||
-            WINED3DFMT_DXT4 == destFormat ||
-            WINED3DFMT_DXT5 == destFormat) {
-
+        if (dst_format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
+        {
             if (destSurfaceHeight != srcHeight || destSurfaceWidth != srcWidth)
             {
                 /* FIXME: The easy way to do this is to lock the destination, and copy the bits across. */
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index c81dab3..5cf28a1 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -146,9 +146,7 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
 
     ENTER_GL();
 
-    if (format_desc->format == WINED3DFMT_DXT1 || format_desc->format == WINED3DFMT_DXT2
-            || format_desc->format == WINED3DFMT_DXT3 || format_desc->format == WINED3DFMT_DXT4
-            || format_desc->format == WINED3DFMT_DXT5 || format_desc->format == WINED3DFMT_ATI2N)
+    if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
     {
         TRACE("(%p) : Calling glGetCompressedTexImageARB level %d, format %#x, type %#x, data %p.\n",
                 This, This->glDescription.level, format_desc->glFormat, format_desc->glType,
@@ -294,9 +292,7 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsi
 
     if (format_desc->heightscale != 1.0 && format_desc->heightscale != 0.0) height *= format_desc->heightscale;
 
-    if (format_desc->format == WINED3DFMT_DXT1 || format_desc->format == WINED3DFMT_DXT2
-            || format_desc->format == WINED3DFMT_DXT3 || format_desc->format == WINED3DFMT_DXT4
-            || format_desc->format == WINED3DFMT_DXT5 || format_desc->format == WINED3DFMT_ATI2N)
+    if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
     {
         /* glCompressedTexSubImage2D() for uploading and glTexImage2D() for
          * allocating does not work well on some drivers (r200 dri, MacOS ATI
@@ -369,9 +365,7 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal,
             This, This->glDescription.target, This->glDescription.level, debug_d3dformat(format_desc->format),
             internal, width, height, format, type);
 
-    if (format_desc->format == WINED3DFMT_DXT1 || format_desc->format == WINED3DFMT_DXT2
-            || format_desc->format == WINED3DFMT_DXT3 || format_desc->format == WINED3DFMT_DXT4
-            || format_desc->format == WINED3DFMT_DXT5 || format_desc->format == WINED3DFMT_ATI2N)
+    if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
     {
         /* glCompressedTexImage2D does not accept NULL pointers, so we cannot allocate a compressed texture without uploading data */
         TRACE("Not allocating compressed surfaces, surface_upload_data will specify them\n");
@@ -3958,11 +3952,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
     This->pow2Height = pow2Height;
 
     if (pow2Width > This->currentDesc.Width || pow2Height > This->currentDesc.Height) {
-        WINED3DFORMAT Format = This->resource.format_desc->format;
         /** TODO: add support for non power two compressed textures **/
-        if (Format == WINED3DFMT_DXT1 || Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3
-            || Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5
-            || Format == WINED3DFMT_ATI2N)
+        if (This->resource.format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
         {
             FIXME("(%p) Compressed non-power-two textures are not supported w(%d) h(%d)\n",
                   This, This->currentDesc.Width, This->currentDesc.Height);
-- 
1.6.0.6



--------------090302000902030703040805--



More information about the wine-patches mailing list