gallium/radeon: add an assertion checking the validity of PIPE_BIND_SCANOUT
authorMarek Olšák <marek.olsak@amd.com>
Mon, 6 Jun 2016 09:28:16 +0000 (11:28 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 7 Jun 2016 22:22:45 +0000 (00:22 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/drivers/radeon/r600_texture.c

index 0f72a6d64aff4d02d4b4d64abf765b8faf0b1938..ca91c37ae17f39a23ff4b2c478ba2725620f5780 100644 (file)
@@ -266,9 +266,6 @@ static int r600_init_surface(struct r600_common_screen *rscreen,
        default:
                return -EINVAL;
        }
-       if (ptex->bind & PIPE_BIND_SCANOUT) {
-               surface->flags |= RADEON_SURF_SCANOUT;
-       }
 
        if (!is_flushed_depth && is_depth) {
                surface->flags |= RADEON_SURF_ZBUFFER;
@@ -286,6 +283,16 @@ static int r600_init_surface(struct r600_common_screen *rscreen,
            ptex->format == PIPE_FORMAT_R9G9B9E5_FLOAT)
                surface->flags |= RADEON_SURF_DISABLE_DCC;
 
+       if (ptex->bind & PIPE_BIND_SCANOUT) {
+               /* This should catch bugs in gallium users setting incorrect flags. */
+               assert(surface->nsamples == 1 &&
+                      surface->array_size == 1 &&
+                      surface->npix_z == 1 &&
+                      surface->last_level == 0 &&
+                      !(surface->flags & RADEON_SURF_Z_OR_SBUFFER));
+
+               surface->flags |= RADEON_SURF_SCANOUT;
+       }
        return 0;
 }