vc4: Don't consider nr_samples==1 surfaces to be MSAA.
authorEric Anholt <eric@anholt.net>
Mon, 14 Dec 2015 23:22:55 +0000 (15:22 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 15 Dec 2015 20:02:53 +0000 (12:02 -0800)
This is apparently a weirdness of gallium -- nr_samples==1 is occasionally
used and means the same thing as nr_samples==0.  Fixes a bunch of
ARB_framebuffer_srgb blit cases in piglit.

src/gallium/drivers/vc4/vc4_blit.c
src/gallium/drivers/vc4/vc4_context.c
src/gallium/drivers/vc4/vc4_job.c
src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/vc4/vc4_resource.c
src/gallium/drivers/vc4/vc4_state.c

index 16dcece1ea186a0f700a1a90383dbc5000839dee..876c296dc85c32210a44fdddcea631867e896ace 100644 (file)
@@ -54,8 +54,8 @@ vc4_tile_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
         bool old_msaa = vc4->msaa;
         int old_tile_width = vc4->tile_width;
         int old_tile_height = vc4->tile_height;
-        bool msaa = (info->src.resource->nr_samples ||
-                     info->dst.resource->nr_samples);
+        bool msaa = (info->src.resource->nr_samples > 1 ||
+                     info->dst.resource->nr_samples > 1);
         int tile_width = msaa ? 32 : 64;
         int tile_height = msaa ? 32 : 64;
 
@@ -110,9 +110,11 @@ vc4_tile_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
 
         pipe_surface_reference(&vc4->color_read, src_surf);
         pipe_surface_reference(&vc4->color_write,
-                               dst_surf->texture->nr_samples ? NULL : dst_surf);
+                               dst_surf->texture->nr_samples > 1 ?
+                               NULL : dst_surf);
         pipe_surface_reference(&vc4->msaa_color_write,
-                               dst_surf->texture->nr_samples ? dst_surf : NULL);
+                               dst_surf->texture->nr_samples > 1 ?
+                               dst_surf : NULL);
         pipe_surface_reference(&vc4->zs_read, NULL);
         pipe_surface_reference(&vc4->zs_write, NULL);
         pipe_surface_reference(&vc4->msaa_zs_write, NULL);
index 1cd167600b9980e8649da062f9bd2c701cf89625..0f6b97149292869639edd5e4eb4c62984889b211 100644 (file)
@@ -70,11 +70,13 @@ vc4_flush(struct pipe_context *pctx)
         vc4->msaa = false;
         if (cbuf && (vc4->resolve & PIPE_CLEAR_COLOR0)) {
                 pipe_surface_reference(&vc4->color_write,
-                                       cbuf->texture->nr_samples ? NULL : cbuf);
+                                       cbuf->texture->nr_samples > 1 ?
+                                       NULL : cbuf);
                 pipe_surface_reference(&vc4->msaa_color_write,
-                                       cbuf->texture->nr_samples ? cbuf : NULL);
+                                       cbuf->texture->nr_samples > 1 ?
+                                       cbuf : NULL);
 
-                if (cbuf->texture->nr_samples)
+                if (cbuf->texture->nr_samples > 1)
                         vc4->msaa = true;
 
                 if (!(vc4->cleared & PIPE_CLEAR_COLOR0)) {
@@ -92,13 +94,13 @@ vc4_flush(struct pipe_context *pctx)
         if (vc4->framebuffer.zsbuf &&
             (vc4->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
                 pipe_surface_reference(&vc4->zs_write,
-                                       zsbuf->texture->nr_samples ?
+                                       zsbuf->texture->nr_samples > 1 ?
                                        NULL : zsbuf);
                 pipe_surface_reference(&vc4->msaa_zs_write,
-                                       zsbuf->texture->nr_samples ?
+                                       zsbuf->texture->nr_samples > 1 ?
                                        zsbuf : NULL);
 
-                if (zsbuf->texture->nr_samples)
+                if (zsbuf->texture->nr_samples > 1)
                         vc4->msaa = true;
 
                 if (!(vc4->cleared & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
index 78a66cc23181864f7c7191af3d7f86c9670a8a19..5d071ec862f6c5a1e6cd540ab5370319363ce1b0 100644 (file)
@@ -89,7 +89,7 @@ vc4_submit_setup_rcl_surface(struct vc4_context *vc4,
         submit_surf->hindex = vc4_gem_hindex(vc4, rsc->bo);
         submit_surf->offset = surf->offset;
 
-        if (psurf->texture->nr_samples == 0) {
+        if (psurf->texture->nr_samples <= 1) {
                 if (is_depth) {
                         submit_surf->bits =
                                 VC4_SET_FIELD(VC4_LOADSTORE_TILE_BUFFER_ZS,
@@ -132,7 +132,7 @@ vc4_submit_setup_rcl_render_config_surface(struct vc4_context *vc4,
         submit_surf->hindex = vc4_gem_hindex(vc4, rsc->bo);
         submit_surf->offset = surf->offset;
 
-        if (psurf->texture->nr_samples == 0) {
+        if (psurf->texture->nr_samples <= 1) {
                 submit_surf->bits =
                         VC4_SET_FIELD(vc4_rt_format_is_565(surf->base.format) ?
                                       VC4_RENDER_CONFIG_FORMAT_BGR565 :
index caad05cb9f792edef657c661621734c250782f61..26bdc9951afc1e67dec921d8f9a79abf1a3785b5 100644 (file)
@@ -2043,7 +2043,7 @@ vc4_setup_shared_key(struct vc4_context *vc4, struct vc4_key *key,
                 key->tex[i].swizzle[2] = sampler->swizzle_b;
                 key->tex[i].swizzle[3] = sampler->swizzle_a;
 
-                if (sampler->texture->nr_samples) {
+                if (sampler->texture->nr_samples > 1) {
                         key->tex[i].msaa_width = sampler->texture->width0;
                         key->tex[i].msaa_height = sampler->texture->height0;
                 } else if (sampler){
index e7069a4e9ff364712ba95ad740a7162a39447b77..9e6678a0625be2b8bfbfb32b479afb735cd51bf2 100644 (file)
@@ -207,7 +207,7 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
         /* If the resource is multisampled, we need to resolve to single
          * sample.  This seems like it should be handled at a higher layer.
          */
-        if (prsc->nr_samples) {
+        if (prsc->nr_samples > 1) {
                 trans->ss_resource = vc4_get_temp_resource(pctx, prsc, box);
                 if (!trans->ss_resource)
                         goto fail;
@@ -377,7 +377,7 @@ vc4_setup_slices(struct vc4_resource *rsc)
 
                 if (!rsc->tiled) {
                         slice->tiling = VC4_TILING_FORMAT_LINEAR;
-                        if (prsc->nr_samples) {
+                        if (prsc->nr_samples > 1) {
                                 /* MSAA (4x) surfaces are stored as raw tile buffer contents. */
                                 level_width = align(level_width, 32);
                                 level_height = align(level_height, 32);
@@ -458,7 +458,7 @@ vc4_resource_setup(struct pipe_screen *pscreen,
         prsc->screen = pscreen;
 
         rsc->base.vtbl = &vc4_resource_vtbl;
-        if (prsc->nr_samples == 0)
+        if (prsc->nr_samples <= 1)
                 rsc->cpp = util_format_get_blocksize(tmpl->format);
         else
                 rsc->cpp = sizeof(uint32_t);
@@ -475,7 +475,7 @@ get_resource_texture_format(struct pipe_resource *prsc)
         uint8_t format = vc4_get_tex_format(prsc->format);
 
         if (!rsc->tiled) {
-                if (prsc->nr_samples) {
+                if (prsc->nr_samples > 1) {
                         return ~0;
                 } else {
                         assert(format == VC4_TEXTURE_TYPE_RGBA8888);
@@ -497,7 +497,7 @@ vc4_resource_create(struct pipe_screen *pscreen,
          * communicate metadata about tiling currently.
          */
         if (tmpl->target == PIPE_BUFFER ||
-            tmpl->nr_samples ||
+            tmpl->nr_samples > 1 ||
             (tmpl->bind & (PIPE_BIND_SCANOUT |
                            PIPE_BIND_LINEAR |
                            PIPE_BIND_SHARED |
@@ -832,7 +832,7 @@ vc4_dump_surface(struct pipe_surface *psurf)
         if (!psurf)
                 return;
 
-        if (psurf->texture->nr_samples)
+        if (psurf->texture->nr_samples > 1)
                 vc4_dump_surface_msaa(psurf);
         else
                 vc4_dump_surface_non_msaa(psurf);
index d9c0f55b23db3dcbf85760ef955caf4f51e2cb01..7e0ada7d0fa36593c45bfbc54aa2dea9896998f3 100644 (file)
@@ -462,9 +462,9 @@ vc4_set_framebuffer_state(struct pipe_context *pctx,
 
         vc4->msaa = false;
         if (cso->cbufs[0])
-                vc4->msaa = cso->cbufs[0]->texture->nr_samples != 0;
+                vc4->msaa = cso->cbufs[0]->texture->nr_samples > 1;
         else if (cso->zsbuf)
-                vc4->msaa = cso->zsbuf->texture->nr_samples != 0;
+                vc4->msaa = cso->zsbuf->texture->nr_samples > 1;
 
         if (vc4->msaa) {
                 vc4->tile_width = 32;