nv50,nvc0: reject R8G8B8A8/X8_UNORM for multisample surfaces
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 27 Aug 2011 15:31:04 +0000 (17:31 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Tue, 30 Aug 2011 11:55:07 +0000 (13:55 +0200)
The window system buffer will be BGRA and applications will try to
directly resolve to it, which would trigger an INVALID_OPERATION in
BlitFramebuffer if the multisample renderbuffer is RGBA.

src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nvc0/nvc0_screen.c

index 581aad196273a6c9b113e2b93d0420870bd5d357..985a55c32239f2bece86266f7611f785aa44f239 100644 (file)
@@ -43,7 +43,7 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
                                 unsigned sample_count,
                                 unsigned bindings)
 {
-   if (sample_count > 2 && sample_count != 4 && sample_count != 8)
+   if (!(0x117 & (1 << sample_count))) /* 0, 1, 2, 4 or 8 */
       return FALSE;
    if (sample_count == 8 && util_format_get_blocksizebits(format) >= 128)
       return FALSE;
@@ -56,6 +56,11 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
       if (nv50_screen(pscreen)->tesla->grclass < NVA0_3D)
          return FALSE;
       break;
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
+   case PIPE_FORMAT_R8G8B8X8_UNORM:
+      /* HACK: GL requires equal formats for MS resolve and window is BGRA */
+      if (sample_count > 1)
+         return FALSE;
    default:
       break;
    }
index c79256a6ba2af3ff04738bc31db8bbb3953bfe97..204887d2e8bc6992951627443c0c90fc7fa1b0b5 100644 (file)
@@ -40,12 +40,22 @@ nvc0_screen_is_format_supported(struct pipe_screen *pscreen,
                                 unsigned sample_count,
                                 unsigned bindings)
 {
-   if (sample_count > 2 && sample_count != 4 && sample_count != 8)
+   if (!(0x117 & (1 << sample_count))) /* 0, 1, 2, 4 or 8 */
       return FALSE;
 
    if (!util_format_is_supported(format, bindings))
       return FALSE;
 
+   switch (format) {
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
+   case PIPE_FORMAT_R8G8B8X8_UNORM:
+      /* HACK: GL requires equal formats for MS resolve and window is BGRA */
+      if (sample_count > 1)
+         return FALSE;
+   default:
+      break;
+   }
+
    /* transfers & shared are always supported */
    bindings &= ~(PIPE_BIND_TRANSFER_READ |
                  PIPE_BIND_TRANSFER_WRITE |