Stefan Dösinger : wined3d: Emulate D3DFMT_L6V5U5.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Sep 12 07:50:39 CDT 2007


Module: wine
Branch: master
Commit: 0ed81b20afa640466b0f88335a4a35c3403cca7f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0ed81b20afa640466b0f88335a4a35c3403cca7f

Author: Stefan Dösinger <stefandoesinger at gmx.at>
Date:   Fri Aug 31 20:41:03 2007 +0200

wined3d: Emulate D3DFMT_L6V5U5.

---

 dlls/wined3d/surface.c         |   54 ++++++++++++++++++++++++++++++++++++++++
 dlls/wined3d/utils.c           |    2 +-
 dlls/wined3d/wined3d_private.h |    1 +
 3 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 4904f24..c41e2eb 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1576,6 +1576,20 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
             *target_bpp = 3;
             break;
 
+        case WINED3DFMT_L6V5U5:
+            *convert = CONVERT_L6V5U5;
+            if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
+                *target_bpp = 3;
+                /* Use format and types from table */
+            } else {
+                /* Load it into unsigned R5G6B5, swap L and V channels, and revert that in the shader */
+                *target_bpp = 2;
+                *format = GL_RGB;
+                *internal = GL_RGB5;
+                *type = GL_UNSIGNED_SHORT_5_6_5;
+            }
+            break;
+
         case WINED3DFMT_X8L8V8U8:
             *convert = CONVERT_X8L8V8U8;
             *target_bpp = 4;
@@ -1838,6 +1852,46 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
             break;
         }
 
+        case CONVERT_L6V5U5:
+        {
+            unsigned int x, y;
+            WORD *Source;
+            unsigned char *Dest;
+
+            if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
+                /* This makes the gl surface bigger(24 bit instead of 16), but it works with
+                 * fixed function and shaders without further conversion once the surface is
+                 * loaded
+                 */
+                for(y = 0; y < height; y++) {
+                    Source = (WORD *) (src + y * pitch);
+                    Dest = (unsigned char *) (dst + y * outpitch);
+                    for (x = 0; x < width; x++ ) {
+                        short color = (*Source++);
+                        unsigned char l = ((color >> 10) & 0xfc);
+                                  char v = ((color >>  5) & 0x3e);
+                                  char u = ((color      ) & 0x1f);
+
+                        /* 8 bits destination, 6 bits source, 8th bit is the sign. gl ignores the sign
+                         * and doubles the positive range. Thus shift left only once, gl does the 2nd
+                         * shift. GL reads a signed value and converts it into an unsigned value.
+                         */
+                        /* M */ Dest[2] = l << 1;
+
+                        /* Those are read as signed, but kept signed. Just left-shift 3 times to scale
+                         * from 5 bit values to 8 bit values.
+                         */
+                        /* V */ Dest[1] = v << 3;
+                        /* U */ Dest[0] = u << 3;
+                        Dest += 3;
+                    }
+                }
+            } else {
+                FIXME("Add D3DFMT_L6V5U5 emulation using standard unsigned RGB and shaders\n");
+            }
+            break;
+        }
+
         case CONVERT_X8L8V8U8:
         {
             unsigned int x, y;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 472907f..d5131e1 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -169,7 +169,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = {
     {WINED3DFMT_A4L4           ,GL_LUMINANCE4_ALPHA4             ,GL_LUMINANCE4_ALPHA4                   ,GL_LUMINANCE_ALPHA        ,GL_UNSIGNED_BYTE               },
     /* Bump mapping stuff */
     {WINED3DFMT_V8U8           ,GL_DSDT8_NV                      ,GL_DSDT8_NV                            ,GL_DSDT_NV                ,GL_BYTE                        },
-    {WINED3DFMT_L6V5U5         ,GL_COLOR_INDEX8_EXT              ,GL_COLOR_INDEX8_EXT                    ,GL_COLOR_INDEX            ,GL_UNSIGNED_SHORT_5_5_5_1      },
+    {WINED3DFMT_L6V5U5         ,GL_DSDT8_MAG8_NV                 ,GL_DSDT8_MAG8_NV                       ,GL_DSDT_MAG_NV            ,GL_BYTE                        },
     {WINED3DFMT_X8L8V8U8       ,GL_DSDT8_MAG8_INTENSITY8_NV      ,GL_DSDT8_MAG8_INTENSITY8_NV            ,GL_DSDT_MAG_VIB_NV       ,GL_UNSIGNED_INT_8_8_S8_S8_REV_NV},
     {WINED3DFMT_Q8W8V8U8       ,GL_SIGNED_RGBA8_NV               ,GL_SIGNED_RGBA8_NV                     ,GL_RGBA                   ,GL_BYTE                        },
     {WINED3DFMT_V16U16         ,GL_SIGNED_HILO16_NV              ,GL_SIGNED_HILO16_NV                    ,GL_HILO_NV                ,GL_SHORT                       },
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 27ef553..b8cbbe7 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1231,6 +1231,7 @@ typedef enum {
     CONVERT_CK_8888_ARGB,
     CONVERT_RGB32_888,
     CONVERT_V8U8,
+    CONVERT_L6V5U5,
     CONVERT_X8L8V8U8,
     CONVERT_Q8W8V8U8,
     CONVERT_V16U16,




More information about the wine-cvs mailing list