broadcom/vc5: Set up MSAA texture type according to the internal format.
authorEric Anholt <eric@anholt.net>
Wed, 25 Oct 2017 20:00:44 +0000 (13:00 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 30 Oct 2017 20:31:28 +0000 (13:31 -0700)
It gets most of EXT_framebuffer_multisample-formats passing, but doesn't
really work for texture views.

src/gallium/drivers/vc5/vc5_resource.c
src/gallium/drivers/vc5/vc5_state.c

index 29623d9ba2cecde3bfbc0eefae68cd4624e90ef7..9b951d9341e93f2d958b7d52c3a3ae66e5e168f6 100644 (file)
@@ -371,7 +371,7 @@ vc5_setup_slices(struct vc5_resource *rsc, const char *caller)
         /* MSAA textures/renderbuffers are always laid out as single-level
          * UIF.
          */
-        bool uif_top = prsc->nr_samples > 1;
+        bool uif_top = msaa;
 
         for (int i = prsc->last_level; i >= 0; i--) {
                 struct vc5_resource_slice *slice = &rsc->slices[i];
index 1f05576c18ba3987255784cdd1083ceeb7e53d97..fc0e28742733817d9a9214c5d6d8fcd5aa3cb055 100644 (file)
@@ -571,13 +571,50 @@ vc5_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
                 .image_height = prsc->height0 * msaa_scale,
                 .image_depth = prsc->depth0,
 
-                .texture_type = vc5_get_tex_format(cso->format),
                 .srgb = util_format_is_srgb(cso->format),
 
                 .base_level = cso->u.tex.first_level,
                 .array_stride_64_byte_aligned = rsc->cube_map_stride / 64,
         };
 
+        if (prsc->nr_samples > 1) {
+                /* Using texture views to reinterpret formats on our MSAA
+                 * textures won't work, because we don't lay out the bits in
+                 * memory as it's expected -- for example, RGBA8 and RGB10_A2
+                 * are compatible in the ARB_texture_view spec, but in HW we
+                 * lay them out as 32bpp RGBA8 and 64bpp RGBA16F.  Just assert
+                 * for now to catch failures.
+                 */
+                assert(util_format_linear(cso->format) ==
+                       util_format_linear(prsc->format));
+                uint32_t output_image_format = vc5_get_rt_format(cso->format);
+                uint32_t internal_type;
+                uint32_t internal_bpp;
+                vc5_get_internal_type_bpp_for_output_format(output_image_format,
+                                                            &internal_type,
+                                                            &internal_bpp);
+
+                switch (internal_type) {
+                case INTERNAL_TYPE_8:
+                        state_unpacked.texture_type = TEXTURE_DATA_FORMAT_RGBA8;
+                        break;
+                case INTERNAL_TYPE_16F:
+                        state_unpacked.texture_type = TEXTURE_DATA_FORMAT_RGBA16F;
+                        break;
+                default:
+                        unreachable("Bad MSAA texture type");
+                }
+
+                /* sRGB was stored in the tile buffer as linear and would have
+                 * been encoded to sRGB on resolved tile buffer store.  Note
+                 * that this means we would need shader code if we wanted to
+                 * read an MSAA sRGB texture without sRGB decode.
+                 */
+                state_unpacked.srgb = false;
+        } else {
+                state_unpacked.texture_type = vc5_get_tex_format(cso->format);
+        }
+
         /* Note: Contrary to the docs, the swizzle still applies even
          * if the return size is 32.  It's just that you probably want
          * to swizzle in the shader, because you need the Y/Z/W