turnip: add r5g5b5a1_unorm/b5g5r5a1_unorm formats
authorJonathan Marek <jonathan@marek.ca>
Thu, 27 Feb 2020 20:35:54 +0000 (15:35 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 28 Feb 2020 12:48:11 +0000 (12:48 +0000)
r5g5b5a1/b5g5r5a1 tiled/ubwc is the same as a1r5g5b5 (in memory), but
linear is read as 1_5_5_5 and written with 5_5_5_1 with swap.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3806>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3806>

src/freedreno/registers/a6xx.xml
src/freedreno/vulkan/tu_formats.c

index 23373b94bdd175e26ad319de99a6bb1d1c84fa5f..94dfb36e9c0c5a7248a8ecad5d77c1e0cc0a2894 100644 (file)
@@ -22,6 +22,7 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 
        <value value="0x08" name="FMT6_4_4_4_4_UNORM"/>
        <value value="0x0a" name="FMT6_5_5_5_1_UNORM"/>
+       <value value="0x0c" name="FMT6_1_5_5_5_UNORM"/> <!-- read only -->
        <value value="0x0e" name="FMT6_5_6_5_UNORM"/>
 
        <value value="0x0f" name="FMT6_8_8_UNORM"/>
index 05dd0e87f026bfed6520051552473bece4fc896e..021618ee8f44b8a57bd46751f28730fd98322c42 100644 (file)
@@ -62,8 +62,8 @@ static const struct tu_native_format tu6_format_table[] = {
    TU6_xTC(B4G4R4A4_UNORM_PACK16,      4_4_4_4_UNORM,     ZYXW), /* 3 */
    TU6_xTC(R5G6B5_UNORM_PACK16,        5_6_5_UNORM,       WXYZ), /* 4 */
    TU6_xTC(B5G6R5_UNORM_PACK16,        5_6_5_UNORM,       WZYX), /* 5 */
-   TU6_xxx(R5G5B5A1_UNORM_PACK16,      1_5_5_5_UNORM,     XYZW), /* 6 */
-   TU6_xxx(B5G5R5A1_UNORM_PACK16,      1_5_5_5_UNORM,     XYZW), /* 7 */
+   TU6_xTC(R5G5B5A1_UNORM_PACK16,      5_5_5_1_UNORM,     XYZW), /* 6 */
+   TU6_xTC(B5G5R5A1_UNORM_PACK16,      5_5_5_1_UNORM,     ZYXW), /* 7 */
    TU6_xTC(A1R5G5B5_UNORM_PACK16,      5_5_5_1_UNORM,     WXYZ), /* 8 */
 
    /* 8-bit R */
@@ -347,8 +347,15 @@ tu6_format_texture(VkFormat format, bool tiled)
    struct tu_native_format fmt = tu6_get_native_format(format);
    assert(fmt.supported & FMT_TEXTURE);
 
-   if (tiled)
+   if (!tiled) {
+      /* different from format table when used as linear src */
+      if (format == VK_FORMAT_R5G5B5A1_UNORM_PACK16)
+         fmt.fmt = FMT6_1_5_5_5_UNORM, fmt.swap = WXYZ;
+      if (format == VK_FORMAT_B5G5R5A1_UNORM_PACK16)
+         fmt.fmt = FMT6_1_5_5_5_UNORM, fmt.swap = WZYX;
+   } else {
       fmt.swap = WZYX;
+   }
 
    return fmt;
 }