Skip to contentSkip to conversation

nv50/exa: add support for more color formats

PATCH Superseded Marcin Slusarz 3 participants 7 messages Dec 28, 2009 – Dec 30, 2009 6 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 nv50/exa: add support for more color formats

---
 src/nv50_exa.c |  155 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 100 insertions(+), 55 deletions(-)
src/nv50_exa.c +100 -55
index 1f5a4ac..54968e8 100644
@@ -79,15 +79,16 @@ NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
 
 	switch (ppix->drawable.depth) {
 	case 8 : *fmt = NV50_2D_SRC_FORMAT_R8_UNORM; break;
-	case 15: *fmt = NV50_2D_SRC_FORMAT_X1R5G5B5_UNORM; break;
-	case 16: *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM; break;
+	case 15:
+	case 16:
+		*fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM;
+		break;
 	case 24: *fmt = NV50_2D_SRC_FORMAT_X8R8G8B8_UNORM; break;
 	case 30: *fmt = NV50_2D_SRC_FORMAT_A2B10G10R10_UNORM; break;
 	case 32: *fmt = NV50_2D_SRC_FORMAT_A8R8G8B8_UNORM; break;
 	default:
 		 NOUVEAU_FALLBACK("Unknown surface format for bpp=%d\n",
 				  ppix->drawable.depth);
-		 return FALSE;
 	}
 
 	return TRUE;
@@ -442,12 +443,17 @@ NV50EXACheckRenderTarget(PicturePtr ppict)
 				 ppict->pDrawable->height);
 
 	switch (ppict->format) {
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
 	case PICT_a8r8g8b8:
 	case PICT_x8r8g8b8:
 	case PICT_r5g6b5:
 	case PICT_a8:
+	case PICT_x1r5g5b5:
+	case PICT_a1r5g5b5:
+	case PICT_x8b8g8r8:
+	case PICT_a2b10g10r10:
+	case PICT_x2b10g10r10:
+	case PICT_a2r10g10b10:
+	case PICT_x2r10g10b10:
 		break;
 	default:
 		NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
@@ -469,14 +475,23 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)
 		NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
 
 	switch (ppict->format) {
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
-		format = NV50TCL_RT_FORMAT_A2B10G10R10_UNORM;
-		break;
 	case PICT_a8r8g8b8: format = NV50TCL_RT_FORMAT_A8R8G8B8_UNORM; break;
 	case PICT_x8r8g8b8: format = NV50TCL_RT_FORMAT_X8R8G8B8_UNORM; break;
 	case PICT_r5g6b5  : format = NV50TCL_RT_FORMAT_R5G6B5_UNORM; break;
 	case PICT_a8      : format = NV50TCL_RT_FORMAT_A8_UNORM; break;
+	case PICT_x1r5g5b5:
+	case PICT_a1r5g5b5:
+		format = NV50TCL_RT_FORMAT_A1R5G5B5_UNORM;
+		break;
+	case PICT_x8b8g8r8: format = NV50TCL_RT_FORMAT_X8B8G8R8_UNORM; break;
+	case PICT_a2b10g10r10:
+	case PICT_x2b10g10r10:
+		format = NV50TCL_RT_FORMAT_A2B10G10R10_UNORM;
+		break;
+	case PICT_a2r10g10b10: 
+	case PICT_x2r10g10b10:
+		format = NV50TCL_RT_FORMAT_A2R10G10B10_UNORM;
+		break;
 	default:
 		NOUVEAU_FALLBACK("invalid picture format\n");
 	}
@@ -510,14 +525,27 @@ NV50EXACheckTexture(PicturePtr ppict, PicturePtr pdpict, int op)
 				 ppict->pDrawable->height);
 
 	switch (ppict->format) {
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
 	case PICT_a8r8g8b8:
 	case PICT_a8b8g8r8:
 	case PICT_x8r8g8b8:
 	case PICT_x8b8g8r8:
 	case PICT_r5g6b5:
 	case PICT_a8:
+	case PICT_x1r5g5b5:
+	case PICT_x1b5g5r5:
+	case PICT_a1r5g5b5:
+	case PICT_a1b5g5r5:
+	case PICT_b5g6r5:
+	case PICT_b8g8r8a8:
+	case PICT_b8g8r8x8:
+	case PICT_a2b10g10r10:
+	case PICT_x2b10g10r10:
+	case PICT_x2r10g10b10:
+	case PICT_a2r10g10b10:
+	case PICT_x4r4g4b4:
+	case PICT_x4b4g4r4:
+	case PICT_a4r4g4b4:
+	case PICT_a4b4g4r4:
 		break;
 	default:
 		NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
@@ -544,6 +572,13 @@ NV50EXACheckTexture(PicturePtr ppict, PicturePtr pdpict, int op)
 	return TRUE;
 }
 
+#define NV50TIC_0_0_FMT_1_5_5_5                                     0x00000014
+#define NV50TIC_0_0_FMT_4_4_4_4                                     0x00000012
+
+#define _(X1,X2,X3,X4,FMT) (NV50TIC_0_0_TYPER_UNORM | NV50TIC_0_0_TYPEG_UNORM | NV50TIC_0_0_TYPEB_UNORM | NV50TIC_0_0_TYPEA_UNORM | \
+			    NV50TIC_0_0_MAP##X1 | NV50TIC_0_0_MAP##X2 | NV50TIC_0_0_MAP##X3 | NV50TIC_0_0_MAP##X4 | \
+			    NV50TIC_0_0_FMT_##FMT)
+
 static Bool
 NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)
 {
@@ -569,66 +604,76 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)
 	BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
 	OUT_RING  (chan, CB_TIC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
 	BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
+
 	switch (ppict->format) {
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_2_10_10_10);
-		break;
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_2_10_10_10);
-		break;
 	case PICT_a8r8g8b8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8_8_8_8);
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 8_8_8_8));
 		break;
 	case PICT_a8b8g8r8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8_8_8_8);
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 8_8_8_8));
 		break;
 	case PICT_x8r8g8b8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8_8_8_8);
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 8_8_8_8));
 		break;
 	case PICT_x8b8g8r8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8_8_8_8);
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 8_8_8_8));
 		break;
 	case PICT_r5g6b5:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_5_6_5);
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 5_6_5));
 		break;
 	case PICT_a8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8);
+		OUT_RING(chan, _(A_C0, R_ZERO, G_ZERO, B_ZERO, 8));
+		break;
+	case PICT_x1r5g5b5:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 1_5_5_5));
+		break;
+	case PICT_x1b5g5r5:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 1_5_5_5));
+		break;
+	case PICT_a1r5g5b5:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 1_5_5_5));
+		break;
+	case PICT_a1b5g5r5:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 1_5_5_5));
+		break;
+	case PICT_b5g6r5:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 5_6_5));
+		break;
+	case PICT_b8g8r8x8:
+		OUT_RING(chan, _(A_ONE, B_C1, G_C2, R_C3, 8_8_8_8));
+		break;
+	case PICT_b8g8r8a8:
+		OUT_RING(chan, _(A_C0, B_C1, G_C2, R_C3, 8_8_8_8));
+		break;
+	case PICT_a2b10g10r10:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 2_10_10_10));
+		break;
+	case PICT_x2b10g10r10:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 2_10_10_10));
+		break;
+	case PICT_x2r10g10b10:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 2_10_10_10));
+		break;
+	case PICT_a2r10g10b10:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 2_10_10_10));
+		break;
+	case PICT_x4r4g4b4:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 4_4_4_4));
+		break;
+	case PICT_x4b4g4r4:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 4_4_4_4));
+		break;
+	case PICT_a4r4g4b4:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 4_4_4_4));
+		break;
+	case PICT_a4b4g4r4:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 4_4_4_4));
 		break;
 	default:
 		NOUVEAU_FALLBACK("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n");
 	}
+#undef _
+
 	if (OUT_RELOCl(chan, bo, delta, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD))
 		return FALSE;
 	OUT_RING  (chan, 0xd0005000 | (bo->tile_mode << 22));
Signature · 1 line
1.6.6.rc3
#2 lore raw
In reply to a message not in the archive
Quoted 10 lines · Marcin Slusarz

---
 src/nv50_exa.c |  155 ++++++++++++++++++++++++++++++++++++--------------------

 1 files changed, 100 insertions(+), 55 deletions(-)
src/nv50_exa.c +0 -0
index 1f5a4ac..54968e8 100644

src/nv50_exa.c NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt) · line 85

Quoted 9 lines
src/nv50_exa.c +4 -2
@@ -79,15 +79,16 @@ NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
 
        switch (ppix->drawable.depth) {
        case 8 : *fmt = NV50_2D_SRC_FORMAT_R8_UNORM; break;
-       case 15: *fmt = NV50_2D_SRC_FORMAT_X1R5G5B5_UNORM; break;
-       case 16: *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM; break;
+       case 15:
+       case 16:
+               *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM;
+               break;

depth 15 is R5G5B5, why this change?

Quoted 7 lines
src/nv50_exa.c +0 -0
        case 24: *fmt = NV50_2D_SRC_FORMAT_X8R8G8B8_UNORM; break;
        case 30: *fmt = NV50_2D_SRC_FORMAT_A2B10G10R10_UNORM; break;
        case 32: *fmt = NV50_2D_SRC_FORMAT_A8R8G8B8_UNORM; break;

       default:
                NOUVEAU_FALLBACK("Unknown surface format for bpp=%d\n", ppix->drawable.depth);
-                return FALSE;

Why did you remove this?

Quoted 224 lines

       }

       return TRUE;

src/nv50_exa.c +0 -2
@@ -442,12 +443,17 @@ NV50EXACheckRenderTarget(PicturePtr ppict)
                                 ppict->pDrawable->height);
 
        switch (ppict->format) {
-       case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-       case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):

       case PICT_a8r8g8b8:
       case PICT_x8r8g8b8:
       case PICT_r5g6b5:
       case PICT_a8:
+       case PICT_x1r5g5b5:
+       case PICT_a1r5g5b5:
+       case PICT_x8b8g8r8:
+       case PICT_a2b10g10r10:
+       case PICT_x2b10g10r10:
+       case PICT_a2r10g10b10:
+       case PICT_x2r10g10b10:
               break;
       default:
               NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);

src/nv50_exa.c +13 -4
@@ -469,14 +475,23 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)
                NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
 
        switch (ppict->format) {
-       case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-       case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
-               format = NV50TCL_RT_FORMAT_A2B10G10R10_UNORM;
-               break;
        case PICT_a8r8g8b8: format = NV50TCL_RT_FORMAT_A8R8G8B8_UNORM; break;
        case PICT_x8r8g8b8: format = NV50TCL_RT_FORMAT_X8R8G8B8_UNORM; break;
        case PICT_r5g6b5  : format = NV50TCL_RT_FORMAT_R5G6B5_UNORM; break;
        case PICT_a8      : format = NV50TCL_RT_FORMAT_A8_UNORM; break;
+       case PICT_x1r5g5b5:
+       case PICT_a1r5g5b5:
+               format = NV50TCL_RT_FORMAT_A1R5G5B5_UNORM;
+               break;
+       case PICT_x8b8g8r8: format = NV50TCL_RT_FORMAT_X8B8G8R8_UNORM; break;
+       case PICT_a2b10g10r10:
+       case PICT_x2b10g10r10:
+               format = NV50TCL_RT_FORMAT_A2B10G10R10_UNORM;
+               break;
+       case PICT_a2r10g10b10:
+       case PICT_x2r10g10b10:
+               format = NV50TCL_RT_FORMAT_A2R10G10B10_UNORM;
+               break;

       default:
               NOUVEAU_FALLBACK("invalid picture format\n"); }

src/nv50_exa.c +0 -2
@@ -510,14 +525,27 @@ NV50EXACheckTexture(PicturePtr ppict, PicturePtr pdpict, int op)
                                 ppict->pDrawable->height);
 
        switch (ppict->format) {
-       case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-       case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):

       case PICT_a8r8g8b8:
       case PICT_a8b8g8r8:
       case PICT_x8r8g8b8:
       case PICT_x8b8g8r8:
       case PICT_r5g6b5:
       case PICT_a8:
+       case PICT_x1r5g5b5:
+       case PICT_x1b5g5r5:
+       case PICT_a1r5g5b5:
+       case PICT_a1b5g5r5:
+       case PICT_b5g6r5:
+       case PICT_b8g8r8a8:
+       case PICT_b8g8r8x8:
+       case PICT_a2b10g10r10:
+       case PICT_x2b10g10r10:
+       case PICT_x2r10g10b10:
+       case PICT_a2r10g10b10:
+       case PICT_x4r4g4b4:
+       case PICT_x4b4g4r4:
+       case PICT_a4r4g4b4:
+       case PICT_a4b4g4r4:
               break;
       default:
               NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);

src/nv50_exa.c +7 -0
@@ -544,6 +572,13 @@ NV50EXACheckTexture(PicturePtr ppict, PicturePtr pdpict, int op)
        return TRUE;
  }
 
+#define NV50TIC_0_0_FMT_1_5_5_5                                     0x00000014
+#define NV50TIC_0_0_FMT_4_4_4_4                                     0x00000012
+
+#define _(X1,X2,X3,X4,FMT) (NV50TIC_0_0_TYPER_UNORM | NV50TIC_0_0_TYPEG_UNORM | NV50TIC_0_0_TYPEB_UNORM | NV50TIC_0_0_TYPEA_UNORM | \
+                           NV50TIC_0_0_MAP##X1 | NV50TIC_0_0_MAP##X2 | NV50TIC_0_0_MAP##X3 | NV50TIC_0_0_MAP##X4 | \
+                           NV50TIC_0_0_FMT_##FMT)
+

 static Bool
 NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit) {

src/nv50_exa.c +1 -14
@@ -569,66 +604,76 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)
        BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
        OUT_RING  (chan, CB_TIC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
        BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
+
        switch (ppict->format) {
-       case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-               OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-                        NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                        NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-                        NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-                        NV50TIC_0_0_FMT_2_10_10_10);
-               break;
-       case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
-               OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-                        NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                        NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-                        NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-                        NV50TIC_0_0_FMT_2_10_10_10);
-               break;

       case PICT_a8r8g8b8:
-               OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |

-                        NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                        NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-                        NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |

-                        NV50TIC_0_0_FMT_8_8_8_8);
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 8_8_8_8)); break;
       case PICT_a8b8g8r8:
-               OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |

-                        NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                        NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-                        NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |

-                        NV50TIC_0_0_FMT_8_8_8_8);
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 8_8_8_8)); break;
       case PICT_x8r8g8b8:
-               OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |

-                        NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                        NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-                        NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |

-                        NV50TIC_0_0_FMT_8_8_8_8);
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 8_8_8_8)); break;
       case PICT_x8b8g8r8:
-               OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |

-                        NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-                        NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-                        NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |

-                        NV50TIC_0_0_FMT_8_8_8_8);
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 8_8_8_8)); break;
       case PICT_r5g6b5:
-               OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |

-                        NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-                        NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-                        NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |

-                        NV50TIC_0_0_FMT_5_6_5);
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 5_6_5)); break;
       case PICT_a8:
-               OUT_RING  (chan, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |

-                        NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM |
-                        NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEB_UNORM |
-                        NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEG_UNORM |

-                        NV50TIC_0_0_FMT_8);
+               OUT_RING(chan, _(A_C0, R_ZERO, G_ZERO, B_ZERO, 8));
+               break;
+       case PICT_x1r5g5b5:
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 1_5_5_5));
+               break;
+       case PICT_x1b5g5r5:
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 1_5_5_5));
+               break;
+       case PICT_a1r5g5b5:
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 1_5_5_5));
+               break;
+       case PICT_a1b5g5r5:
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 1_5_5_5));
+               break;
+       case PICT_b5g6r5:
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 5_6_5));
+               break;
+       case PICT_b8g8r8x8:
+               OUT_RING(chan, _(A_ONE, B_C1, G_C2, R_C3, 8_8_8_8));
+               break;
+       case PICT_b8g8r8a8:
+               OUT_RING(chan, _(A_C0, B_C1, G_C2, R_C3, 8_8_8_8));
+               break;
+       case PICT_a2b10g10r10:
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 2_10_10_10));
+               break;
+       case PICT_x2b10g10r10:
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 2_10_10_10));
+               break;
+       case PICT_x2r10g10b10:
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 2_10_10_10));
+               break;
+       case PICT_a2r10g10b10:
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 2_10_10_10));
+               break;
+       case PICT_x4r4g4b4:
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 4_4_4_4));
+               break;
+       case PICT_x4b4g4r4:
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 4_4_4_4));
+               break;
+       case PICT_a4r4g4b4:
+               OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 4_4_4_4));
+               break;
+       case PICT_a4b4g4r4:
+               OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 4_4_4_4));
               break;
       default:
               NOUVEAU_FALLBACK("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n"); }

src/nv50_exa.c +2 -0
+#undef _
+

       if (OUT_RELOCl(chan, bo, delta, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD)) return FALSE;
       OUT_RING  (chan, 0xd0005000 | (bo->tile_mode << 22)); --
1.6.6.rc3

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#4 lore raw
In reply to a message not in the archive
Quoted 13 lines · Maarten Maathuis
Quoted 11 lines · Marcin Slusarz

---
 src/nv50_exa.c |  155 ++++++++++++++++++++++++++++++++++++--------------------

 1 files changed, 100 insertions(+), 55 deletions(-)
src/nv50_exa.c +0 -0
index 1f5a4ac..54968e8 100644
@@ -79,15 +79,16 @@ NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
 
Quoted 10 lines

src/nv50_exa.c NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt) · line 85

Quoted 8 lines
src/nv50_exa.c +4 -2
        switch (ppix->drawable.depth) {
        case 8 : *fmt = NV50_2D_SRC_FORMAT_R8_UNORM; break;
-       case 15: *fmt = NV50_2D_SRC_FORMAT_X1R5G5B5_UNORM; break;
-       case 16: *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM; break;
+       case 15:
+       case 16:
+               *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM;
+               break;

depth 15 is R5G5B5, why this change?

it's the only value which passes rendercheck tests (rendercheck -t blend -o Src -f x1r5g5b5,r5g5b5)

Quoted 9 lines
Quoted 7 lines
src/nv50_exa.c +0 -0
        case 24: *fmt = NV50_2D_SRC_FORMAT_X8R8G8B8_UNORM; break;
        case 30: *fmt = NV50_2D_SRC_FORMAT_A2B10G10R10_UNORM; break;
        case 32: *fmt = NV50_2D_SRC_FORMAT_A8R8G8B8_UNORM; break;

       default:
                NOUVEAU_FALLBACK("Unknown surface format for bpp=%d\n", ppix->drawable.depth);
-                return FALSE;

Why did you remove this?

because it's unreachable, NOUVEAU_FALLBACK returns FALSE

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#6 lore raw

ddx/nv50: use drawable.bitsPerPixel to decide format

In reply to a message not in the archive
Quoted 25 lines · Marcin Slusarz
Quoted 13 lines · Maarten Maathuis
Quoted 11 lines · Marcin Slusarz
---
 src/nv50_exa.c |  155 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 100 insertions(+), 55 deletions(-)
src/nv50_exa.c +0 -0
index 1f5a4ac..54968e8 100644
@@ -79,15 +79,16 @@ NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
 
Quoted 10 lines

src/nv50_exa.c NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt) · line 85

Quoted 8 lines
src/nv50_exa.c +4 -2
       switch (ppix->drawable.depth) {
       case 8 : *fmt = NV50_2D_SRC_FORMAT_R8_UNORM; break;
-       case 15: *fmt = NV50_2D_SRC_FORMAT_X1R5G5B5_UNORM; break;
-       case 16: *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM; break;
+       case 15:
+       case 16:
+               *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM;
+               break;

depth 15 is R5G5B5, why this change?

Quoted 3 lines

it's the only value which passes rendercheck tests (rendercheck -t blend -o Src -f x1r5g5b5,r5g5b5)

This is as far as I can tell because x1r5g5b5 (XRender direct format as queries by rendercheck) has depth set to 16, and therefore uses case 16 here.
If you use the same for depth 15, the rendercheck test check succeeds, but doing this is wrong.
If you check bitsPerPixel instead, this will be 15 for both x1r5g5b5 and r5g5b5, and all looks fine then.

See the attached patch. I'm not sure if I should have changed the xv stuff also.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
src/nv50_exa.c +0 -1
       case 24: *fmt = NV50_2D_SRC_FORMAT_X8R8G8B8_UNORM; break;
       case 30: *fmt = NV50_2D_SRC_FORMAT_A2B10G10R10_UNORM; break;
       case 32: *fmt = NV50_2D_SRC_FORMAT_A8R8G8B8_UNORM; break;
       default:
                NOUVEAU_FALLBACK("Unknown surface format for bpp=%d\n",
                                 ppix->drawable.depth);
-                return FALSE;
Quoted 8 lines
Quoted 1 line

Why did you remove this?

because it's unreachable, NOUVEAU_FALLBACK returns FALSE

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

From c1de285273004f90937e909187db654d789617b7 Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Wed, 30 Dec 2009 18:28:25 +0100
Subject: [PATCH] nv50: check drawable.bitsPerPixel instead of depth to get format

---
 src/nv50_exa.c |    6 +++---
 src/nv50_xv.c  |    6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)
src/nv50_exa.c +3 -3
index 1f5a4ac..bddc463 100644
@@ -77,7 +77,7 @@ NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
 {
 	NV50EXA_LOCALS(ppix);
 
-	switch (ppix->drawable.depth) {
+	switch (ppix->drawable.bitsPerPixel) {
 	case 8 : *fmt = NV50_2D_SRC_FORMAT_R8_UNORM; break;
 	case 15: *fmt = NV50_2D_SRC_FORMAT_X1R5G5B5_UNORM; break;
 	case 16: *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM; break;
@@ -86,7 +86,7 @@ NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
 	case 32: *fmt = NV50_2D_SRC_FORMAT_A8R8G8B8_UNORM; break;
 	default:
 		 NOUVEAU_FALLBACK("Unknown surface format for bpp=%d\n",
-				  ppix->drawable.depth);
+				  ppix->drawable.bitsPerPixel);
 		 return FALSE;
 	}
 
@@ -179,7 +179,7 @@ NV50EXASetROP(PixmapPtr pdpix, int alu, Pixel planemask)
 	}
 
 	BEGIN_RING(chan, eng2d, NV50_2D_PATTERN_FORMAT, 2);
-	switch (pdpix->drawable.depth) {
+	switch (pdpix->drawable.bitsPerPixel) {
 		case  8: OUT_RING  (chan, 3); break;
 		case 15: OUT_RING  (chan, 1); break;
 		case 16: OUT_RING  (chan, 0); break;
src/nv50_xv.c +4 -2
index b0eccfd..bb9bb43 100644
@@ -41,10 +41,11 @@ extern Atom xvSyncToVBlank, xvSetDefaults;
 static Bool
 nv50_xv_check_image_put(PixmapPtr ppix)
 {
-	switch (ppix->drawable.depth) {
+	switch (ppix->drawable.bitsPerPixel) {
 	case 32:
 	case 24:
 	case 16:
+	case 15:
 		break;
 	default:
 		return FALSE;
@@ -78,10 +79,11 @@ nv50_xv_state_emit(PixmapPtr ppix, int id, struct nouveau_bo *src,
 		MARK_UNDO(chan);
 		return FALSE;
 	}
-	switch (ppix->drawable.depth) {
+	switch (ppix->drawable.bitsPerPixel) {
 	case 32: OUT_RING  (chan, NV50TCL_RT_FORMAT_A8R8G8B8_UNORM); break;
 	case 24: OUT_RING  (chan, NV50TCL_RT_FORMAT_X8R8G8B8_UNORM); break;
 	case 16: OUT_RING  (chan, NV50TCL_RT_FORMAT_R5G6B5_UNORM); break;
+	case 15: OUT_RING  (chan, NV50TCL_RT_FORMAT_X1R5G5B5_UNORM); break;
 	}
 	OUT_RING  (chan, bo->tile_mode << 4);
 	OUT_RING  (chan, 0);
Signature · 1 line
1.6.4.4

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#8 lore raw

Re: ddx/nv50: use drawable.bitsPerPixel to decide format

In reply to a message not in the archive
Quoted 26 lines · Christoph Bumiller
Quoted 25 lines · Marcin Slusarz
Quoted 23 lines · Maarten Maathuis
Quoted 10 lines · Marcin Slusarz
---
 src/nv50_exa.c |  155 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 100 insertions(+), 55 deletions(-)
src/nv50_exa.c +0 -0
index 1f5a4ac..54968e8 100644

src/nv50_exa.c NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt) · line 85

Quoted 9 lines
src/nv50_exa.c +4 -2
@@ -79,15 +79,16 @@ NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
 
       switch (ppix->drawable.depth) {
       case 8 : *fmt = NV50_2D_SRC_FORMAT_R8_UNORM; break;
-       case 15: *fmt = NV50_2D_SRC_FORMAT_X1R5G5B5_UNORM; break;
-       case 16: *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM; break;
+       case 15:
+       case 16:
+               *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM;
+               break;

depth 15 is R5G5B5, why this change?

Quoted 6 lines
Quoted 3 lines

it's the only value which passes rendercheck tests (rendercheck -t blend -o Src -f x1r5g5b5,r5g5b5)

This is as far as I can tell because x1r5g5b5 (XRender direct format as queries by rendercheck) has depth set to 16, and therefore uses case 16 here.

*queried

Quoted 5 lines

If you use the same for depth 15, the rendercheck test check succeeds, but doing this is wrong.
If you check bitsPerPixel instead, this will be 15 for both x1r5g5b5 and r5g5b5, and all looks fine then.

If we e.g. copy from 15bpp to 16bpp though, can the 16th bit be alpha instead of green ? That would be problematic.

Quoted 25 lines

See the attached patch. I'm not sure if I should have changed the xv stuff also.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
src/nv50_exa.c +0 -1
       case 24: *fmt = NV50_2D_SRC_FORMAT_X8R8G8B8_UNORM; break;
       case 30: *fmt = NV50_2D_SRC_FORMAT_A2B10G10R10_UNORM; break;
       case 32: *fmt = NV50_2D_SRC_FORMAT_A8R8G8B8_UNORM; break;
       default:
                NOUVEAU_FALLBACK("Unknown surface format for bpp=%d\n",
                                 ppix->drawable.depth);
-                return FALSE;
Quoted 8 lines
Quoted 1 line

Why did you remove this?

because it's unreachable, NOUVEAU_FALLBACK returns FALSE

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#10 lore raw

Re: ddx/nv50: use drawable.bitsPerPixel to decide format

In reply to a message not in the archive
Quoted 27 lines · Christoph Bumiller
Quoted 26 lines · Christoph Bumiller
Quoted 25 lines · Marcin Slusarz
Quoted 23 lines · Maarten Maathuis
Quoted 10 lines · Marcin Slusarz
---
 src/nv50_exa.c |  155 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 100 insertions(+), 55 deletions(-)
src/nv50_exa.c +0 -0
index 1f5a4ac..54968e8 100644

src/nv50_exa.c NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt) · line 85

Quoted 9 lines
src/nv50_exa.c +4 -2
@@ -79,15 +79,16 @@ NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
 
       switch (ppix->drawable.depth) {
       case 8 : *fmt = NV50_2D_SRC_FORMAT_R8_UNORM; break;
-       case 15: *fmt = NV50_2D_SRC_FORMAT_X1R5G5B5_UNORM; break;
-       case 16: *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM; break;
+       case 15:
+       case 16:
+               *fmt = NV50_2D_SRC_FORMAT_R5G6B5_UNORM;
+               break;

depth 15 is R5G5B5, why this change?

Quoted 11 lines
Quoted 6 lines
Quoted 3 lines

it's the only value which passes rendercheck tests (rendercheck -t blend -o Src -f x1r5g5b5,r5g5b5)

This is as far as I can tell because x1r5g5b5 (XRender direct format as queries by rendercheck) has depth set to 16, and therefore uses case 16 here.

*queried

Quoted 4 lines

If you use the same for depth 15, the rendercheck test check succeeds, but doing this is wrong.
If you check bitsPerPixel instead, this will be 15 for both x1r5g5b5 and r5g5b5, and all looks fine then.

I agree.

Quoted 2 lines

If we e.g. copy from 15bpp to 16bpp though, can the 16th bit be alpha instead of green ? That would be problematic.

xserver advertises a1r5g5b5 as supported too so it's possible, but rendercheck currently omits it, because it can't handle (it uses colors which can't be represented in low-bits color formats, rounds them and the "error" looks huge)
i don't know how to test it...

Quoted 2 lines
Quoted 2 lines

See the attached patch. I'm not sure if I should have changed the xv stuff also.

rendercheck is happy with your patch :)

ps: i'll remove the piece you fixed differently and resend my patch soon

#12 lore raw

PATCH v2 1/2 nv50/exa: add support for more color formats

In reply to a message not in the archive
Quoted 1 line · Marcin Slusarz

ps: i'll remove the piece you fixed differently and resend my patch soon

here we go: (2nd patch applies cleanly, so I won't resend it)

---
From 201601b66386d6fc8e28b863eac405f91edee5ed Mon Sep 17 00:00:00 2001
From: Marcin Slusarz <[email protected]>
Date: Thu, 24 Dec 2009 21:29:10 +0100
Subject: [PATCH 1/2] nv50/exa: add support for more color formats

---
 src/nv50_exa.c |  148 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 96 insertions(+), 52 deletions(-)
src/nv50_exa.c +96 -52
index bddc463..c9d4c06 100644
@@ -442,12 +442,17 @@ NV50EXACheckRenderTarget(PicturePtr ppict)
 				 ppict->pDrawable->height);
 
 	switch (ppict->format) {
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
 	case PICT_a8r8g8b8:
 	case PICT_x8r8g8b8:
 	case PICT_r5g6b5:
 	case PICT_a8:
+	case PICT_x1r5g5b5:
+	case PICT_a1r5g5b5:
+	case PICT_x8b8g8r8:
+	case PICT_a2b10g10r10:
+	case PICT_x2b10g10r10:
+	case PICT_a2r10g10b10:
+	case PICT_x2r10g10b10:
 		break;
 	default:
 		NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
@@ -469,14 +474,23 @@ NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)
 		NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
 
 	switch (ppict->format) {
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
-		format = NV50TCL_RT_FORMAT_A2B10G10R10_UNORM;
-		break;
 	case PICT_a8r8g8b8: format = NV50TCL_RT_FORMAT_A8R8G8B8_UNORM; break;
 	case PICT_x8r8g8b8: format = NV50TCL_RT_FORMAT_X8R8G8B8_UNORM; break;
 	case PICT_r5g6b5  : format = NV50TCL_RT_FORMAT_R5G6B5_UNORM; break;
 	case PICT_a8      : format = NV50TCL_RT_FORMAT_A8_UNORM; break;
+	case PICT_x1r5g5b5:
+	case PICT_a1r5g5b5:
+		format = NV50TCL_RT_FORMAT_A1R5G5B5_UNORM;
+		break;
+	case PICT_x8b8g8r8: format = NV50TCL_RT_FORMAT_X8B8G8R8_UNORM; break;
+	case PICT_a2b10g10r10:
+	case PICT_x2b10g10r10:
+		format = NV50TCL_RT_FORMAT_A2B10G10R10_UNORM;
+		break;
+	case PICT_a2r10g10b10: 
+	case PICT_x2r10g10b10:
+		format = NV50TCL_RT_FORMAT_A2R10G10B10_UNORM;
+		break;
 	default:
 		NOUVEAU_FALLBACK("invalid picture format\n");
 	}
@@ -510,14 +524,27 @@ NV50EXACheckTexture(PicturePtr ppict, PicturePtr pdpict, int op)
 				 ppict->pDrawable->height);
 
 	switch (ppict->format) {
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
 	case PICT_a8r8g8b8:
 	case PICT_a8b8g8r8:
 	case PICT_x8r8g8b8:
 	case PICT_x8b8g8r8:
 	case PICT_r5g6b5:
 	case PICT_a8:
+	case PICT_x1r5g5b5:
+	case PICT_x1b5g5r5:
+	case PICT_a1r5g5b5:
+	case PICT_a1b5g5r5:
+	case PICT_b5g6r5:
+	case PICT_b8g8r8a8:
+	case PICT_b8g8r8x8:
+	case PICT_a2b10g10r10:
+	case PICT_x2b10g10r10:
+	case PICT_x2r10g10b10:
+	case PICT_a2r10g10b10:
+	case PICT_x4r4g4b4:
+	case PICT_x4b4g4r4:
+	case PICT_a4r4g4b4:
+	case PICT_a4b4g4r4:
 		break;
 	default:
 		NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
@@ -544,6 +571,13 @@ NV50EXACheckTexture(PicturePtr ppict, PicturePtr pdpict, int op)
 	return TRUE;
 }
 
+#define NV50TIC_0_0_FMT_1_5_5_5                                     0x00000014
+#define NV50TIC_0_0_FMT_4_4_4_4                                     0x00000012
+
+#define _(X1,X2,X3,X4,FMT) (NV50TIC_0_0_TYPER_UNORM | NV50TIC_0_0_TYPEG_UNORM | NV50TIC_0_0_TYPEB_UNORM | NV50TIC_0_0_TYPEA_UNORM | \
+			    NV50TIC_0_0_MAP##X1 | NV50TIC_0_0_MAP##X2 | NV50TIC_0_0_MAP##X3 | NV50TIC_0_0_MAP##X4 | \
+			    NV50TIC_0_0_FMT_##FMT)
+
 static Bool
 NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)
 {
@@ -569,66 +603,76 @@ NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)
 	BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
 	OUT_RING  (chan, CB_TIC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
 	BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
+
 	switch (ppict->format) {
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 2, 10, 10, 10):
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_2_10_10_10);
-		break;
-	case PICT_FORMAT(32, PICT_TYPE_ABGR, 0, 10, 10, 10):
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_2_10_10_10);
-		break;
 	case PICT_a8r8g8b8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8_8_8_8);
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 8_8_8_8));
 		break;
 	case PICT_a8b8g8r8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8_8_8_8);
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 8_8_8_8));
 		break;
 	case PICT_x8r8g8b8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8_8_8_8);
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 8_8_8_8));
 		break;
 	case PICT_x8b8g8r8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8_8_8_8);
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 8_8_8_8));
 		break;
 	case PICT_r5g6b5:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_5_6_5);
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 5_6_5));
 		break;
 	case PICT_a8:
-		OUT_RING  (chan, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
-			 NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM |
-			 NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEB_UNORM |
-			 NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEG_UNORM |
-			 NV50TIC_0_0_FMT_8);
+		OUT_RING(chan, _(A_C0, R_ZERO, G_ZERO, B_ZERO, 8));
+		break;
+	case PICT_x1r5g5b5:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 1_5_5_5));
+		break;
+	case PICT_x1b5g5r5:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 1_5_5_5));
+		break;
+	case PICT_a1r5g5b5:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 1_5_5_5));
+		break;
+	case PICT_a1b5g5r5:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 1_5_5_5));
+		break;
+	case PICT_b5g6r5:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 5_6_5));
+		break;
+	case PICT_b8g8r8x8:
+		OUT_RING(chan, _(A_ONE, B_C1, G_C2, R_C3, 8_8_8_8));
+		break;
+	case PICT_b8g8r8a8:
+		OUT_RING(chan, _(A_C0, B_C1, G_C2, R_C3, 8_8_8_8));
+		break;
+	case PICT_a2b10g10r10:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 2_10_10_10));
+		break;
+	case PICT_x2b10g10r10:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 2_10_10_10));
+		break;
+	case PICT_x2r10g10b10:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 2_10_10_10));
+		break;
+	case PICT_a2r10g10b10:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 2_10_10_10));
+		break;
+	case PICT_x4r4g4b4:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_ONE, 4_4_4_4));
+		break;
+	case PICT_x4b4g4r4:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_ONE, 4_4_4_4));
+		break;
+	case PICT_a4r4g4b4:
+		OUT_RING(chan, _(R_C0, G_C1, B_C2, A_C3, 4_4_4_4));
+		break;
+	case PICT_a4b4g4r4:
+		OUT_RING(chan, _(B_C0, G_C1, R_C2, A_C3, 4_4_4_4));
 		break;
 	default:
 		NOUVEAU_FALLBACK("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n");
 	}
+#undef _
+
 	if (OUT_RELOCl(chan, bo, delta, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD))
 		return FALSE;
 	OUT_RING  (chan, 0xd0005000 | (bo->tile_mode << 22));
Signature · 1 line
1.6.6.rc3