nvc0: add support for BGRA8 images
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 16 Jul 2016 19:07:21 +0000 (15:07 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Tue, 19 Jul 2016 00:04:17 +0000 (20:04 -0400)
This is useful for pbo downloads, which are now accelerated with images.
BGRA8 is a moderately common format to do that in.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/gallium/drivers/nouveau/codegen/nv50_ir.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir.h
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
src/gallium/drivers/nouveau/nv50/g80_defs.xml.h
src/gallium/drivers/nouveau/nv50/nv50_formats.c
src/gallium/drivers/nouveau/nvc0/nvc0_tex.c

index 2caebe87efe179ae1603692a3fbb51589d3247ce..179ad0b7a97b97c4b5b39e0ee55f2b970e42511f 100644 (file)
@@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] =
    { "RG8_SNORM",    2, {  8,  8,  0,  0 }, SNORM },
    { "R16_SNORM",    1, { 16,  0,  0,  0 }, SNORM },
    { "R8_SNORM",     1, {  8,  0,  0,  0 }, SNORM },
+
+   { "BGRA8",        4, {  8,  8,  8,  8 }, UNORM, true },
 };
 
 void
index 41804b6344dd34aa0d1151f560158cd4f123f146..6d2ee8bce124b45cf19515593b937421a41e4e1e 100644 (file)
@@ -412,6 +412,8 @@ enum ImgFormat
    FMT_R16_SNORM,
    FMT_R8_SNORM,
 
+   FMT_BGRA8,
+
    IMG_FORMAT_COUNT,
 };
 
@@ -967,6 +969,7 @@ public:
       uint8_t components;
       uint8_t bits[4];
       ImgType type;
+      bool bgra;
    };
 
    static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT];
index 61eb7f5c256c48f8407a0895993df769064f63b8..7dff08a5ccc9450d60e1af7d1319cb8ad22d952b 100644 (file)
@@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint format)
    FMT_CASE(R8G8_SNORM, RG8_SNORM);
    FMT_CASE(R16_SNORM, R16_SNORM);
    FMT_CASE(R8_SNORM, R8_SNORM);
+
+   FMT_CASE(B8G8R8A8_UNORM, BGRA8);
    }
 
    assert(!"Unexpected format");
index 18955eb2e183250b3d7297e55a111af51dee197f..92bc0bb0a1f2e4bc15411e9c8bd590a29e5c84cc 100644 (file)
@@ -1940,6 +1940,10 @@ NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su)
          bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]);
       }
    }
+
+   if (format->bgra) {
+      std::swap(typedDst[0], typedDst[2]);
+   }
 }
 
 void
index 5d40624bb9ef241330881e26752f32f8b95735d5..49bf860d3418e3393092464fc34dec752d3db1f9 100644 (file)
@@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define GK104_IMAGE_FORMAT_RG32_FLOAT                          0x0000000d
 #define GK104_IMAGE_FORMAT_RG32_SINT                           0x0000000e
 #define GK104_IMAGE_FORMAT_RG32_UINT                           0x0000000f
+#define GK104_IMAGE_FORMAT_BGRA8_UNORM                         0x00000011
 #define GK104_IMAGE_FORMAT_RGB10_A2_UNORM                      0x00000013
 #define GK104_IMAGE_FORMAT_RGB10_A2_UINT                       0x00000015
 #define GK104_IMAGE_FORMAT_RGBA8_UNORM                         0x00000018
index 34d32d14493669aa2b85932e707ac35e705c223e..07c441986f53a8755b2df90ff6740e32e56b79da 100644 (file)
@@ -50,6 +50,7 @@
 #define U_IB  PIPE_BIND_BLENDABLE | U_IR
 #define U_TD  PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | U_TB
 #define U_TZ  PIPE_BIND_DEPTH_STENCIL | U_T
+#define U_ID  U_TD | U_I
 #if NOUVEAU_DRIVER == 0xc0
 # define U_TC  U_TB
 # define U_IC  U_IB
@@ -122,7 +123,7 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 #endif
 {
-   C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, TD),
+   C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, ID),
    F3(A, B8G8R8X8_UNORM, BGRX8_UNORM, B, G, R, xx, UNORM, A8B8G8R8, TD),
    C4(A, B8G8R8A8_SRGB, BGRA8_SRGB, B, G, R, A, UNORM, A8B8G8R8, TD),
    F3(A, B8G8R8X8_SRGB, BGRX8_SRGB, B, G, R, xx, UNORM, A8B8G8R8, TD),
index 5f7bba83948f274356086ae2cf6eeb3eea1ef2e3..71c1b841460d289fb7bab86eb723484aeb170f40 100644 (file)
@@ -1158,6 +1158,7 @@ static const uint8_t nve4_su_format_map[PIPE_FORMAT_COUNT] =
    [PIPE_FORMAT_R16G16B16A16_SNORM] = GK104_IMAGE_FORMAT_RGBA16_SNORM,
    [PIPE_FORMAT_R16G16B16A16_SINT] = GK104_IMAGE_FORMAT_RGBA16_SINT,
    [PIPE_FORMAT_R16G16B16A16_UINT] = GK104_IMAGE_FORMAT_RGBA16_UINT,
+   [PIPE_FORMAT_B8G8R8A8_UNORM] = GK104_IMAGE_FORMAT_BGRA8_UNORM,
    [PIPE_FORMAT_R8G8B8A8_UNORM] = GK104_IMAGE_FORMAT_RGBA8_UNORM,
    [PIPE_FORMAT_R8G8B8A8_SNORM] = GK104_IMAGE_FORMAT_RGBA8_SNORM,
    [PIPE_FORMAT_R8G8B8A8_SINT] = GK104_IMAGE_FORMAT_RGBA8_SINT,
@@ -1212,6 +1213,7 @@ static const uint16_t nve4_su_format_aux_map[PIPE_FORMAT_COUNT] =
 
    [PIPE_FORMAT_R10G10B10A2_UNORM] = 0x2a24,
    [PIPE_FORMAT_R10G10B10A2_UINT] = 0x2a24,
+   [PIPE_FORMAT_B8G8R8A8_UNORM] = 0x2a24,
    [PIPE_FORMAT_R8G8B8A8_UNORM] = 0x2a24,
    [PIPE_FORMAT_R8G8B8A8_SNORM] = 0x2a24,
    [PIPE_FORMAT_R8G8B8A8_SINT] = 0x2a24,