st/nine: Add support for X8L8V8U8
authorAxel Davy <axel.davy@ens.fr>
Mon, 7 Mar 2016 21:30:05 +0000 (22:30 +0100)
committerAxel Davy <axel.davy@ens.fr>
Wed, 18 May 2016 21:37:14 +0000 (23:37 +0200)
X8L8V8U8 support should be common. Some more recent cards
do support this format, but not L6V5U5.

Add fallback for this format to have it alwaus supported.

L6V5U5 conversion rule apparently differs a bit from the normal
spec, and thus the gallium equivalent format leads to slightly
wrong colors. Since some recent cards do not support it, do not
support it either.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/nine_pipe.c
src/gallium/state_trackers/nine/nine_pipe.h

index 27a10d6447348e15908c3dd68cf51a44220ae9c3..461b416d2a26c1f59d8521d6ab4b8801a260f5fa 100644 (file)
@@ -289,8 +289,8 @@ const enum pipe_format nine_d3d9_to_pipe_format_map[120] =
    [D3DFMT_A8L8]          = PIPE_FORMAT_L8A8_UNORM,
    [D3DFMT_A4L4]          = PIPE_FORMAT_L4A4_UNORM,
    [D3DFMT_V8U8]          = PIPE_FORMAT_R8G8_SNORM,
-   [D3DFMT_L6V5U5]        = PIPE_FORMAT_NONE,
-   [D3DFMT_X8L8V8U8]      = PIPE_FORMAT_NONE,
+   [D3DFMT_L6V5U5]        = PIPE_FORMAT_NONE, /* Should be PIPE_FORMAT_R5SG5SB6U_NORM, but interpretation of the data differs a bit. */
+   [D3DFMT_X8L8V8U8]      = PIPE_FORMAT_R8SG8SB8UX8U_NORM,
    [D3DFMT_Q8W8V8U8]      = PIPE_FORMAT_R8G8B8A8_SNORM,
    [D3DFMT_V16U16]        = PIPE_FORMAT_R16G16_SNORM,
    [D3DFMT_A2W10V10U10]   = PIPE_FORMAT_R10SG10SB10SA2U_NORM,
index 1ffce7dc1d72e1679aea9ea5d75dd3f71cead208..9c8e8e6a06250bf5f15264832df44db7dadb9209 100644 (file)
@@ -338,7 +338,8 @@ d3d9_to_pipe_format_checked(struct pipe_screen *screen,
 
     /* bypass_check: Used for D3DPOOL_SCRATCH, which
      * isn't limited to the formats supported by the
-     * device. */
+     * device, and to check we are not using a format
+     * fallback. */
     if (bypass_check || format_check_internal(result))
         return result;
 
@@ -357,6 +358,15 @@ d3d9_to_pipe_format_checked(struct pipe_screen *screen,
         case D3DFMT_D24X8:
             if (format_check_internal(PIPE_FORMAT_Z24X8_UNORM))
                 return PIPE_FORMAT_Z24X8_UNORM;
+        /* Support for X8L8V8U8 bumpenvmap format with lighting bits.
+         * X8L8V8U8 is commonly supported among dx9 cards.
+         * To avoid precision loss, we use PIPE_FORMAT_R32G32B32X32_FLOAT,
+         * however using PIPE_FORMAT_R8G8B8A8_SNORM should be ok */
+        case D3DFMT_X8L8V8U8:
+            if (bindings & PIPE_BIND_RENDER_TARGET)
+                return PIPE_FORMAT_NONE;
+            if (format_check_internal(PIPE_FORMAT_R32G32B32X32_FLOAT))
+                return PIPE_FORMAT_R32G32B32X32_FLOAT;
         default:
             break;
     }