Module: Mesa
Branch: staging/23.1
Commit: 1d0991caa812bbbbd94d3beef08072734e92b61d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d0991caa812bbbbd94d3beef08072734e92b61d

Author: Italo Nicola <[email protected]>
Date:   Fri May 14 11:25:42 2021 +0000

mesa/main: account for RTT samples when updating framebuffer

For EXT_multisampled_render_to_texture, we store the number of samples
in Attachment->NumSamples instead of Renderbuffer->NumSamples. This
meant that the previous code ignored that the framebuffer was
multisampled. Because of this, pipe_rasterizer_state::multisample is set
incorrectly, leading to visual artifacts on drivers that support MS-RTT
extension, such as panfrost.

Signed-off-by: Italo Nicola <[email protected]>
Reviewed-by: Rob Clark <[email protected]>
Reviewed-by: Emma Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10747>
(cherry picked from commit 4d1a07c1a0ba6d308bed3ebbf77f24bb2ed03afc)

---

 .pick_status.json           |  2 +-
 src/mesa/main/framebuffer.c | 27 ++++++++++++++++++++++++---
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index f2b432d47ca..f7134e02f88 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -571,7 +571,7 @@
         "description": "mesa/main: account for RTT samples when updating 
framebuffer",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index f2d4a603f13..5d2c0044e85 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -423,15 +423,36 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
    /* find first RGB renderbuffer */
    for (unsigned i = 0; i < BUFFER_COUNT; i++) {
       if (fb->Attachment[i].Renderbuffer) {
-         const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
+         const struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+         const struct gl_renderbuffer *rb = att->Renderbuffer;
          const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
          const mesa_format fmt = rb->Format;
 
          /* Grab samples and sampleBuffers from any attachment point (assuming
           * the framebuffer is complete, we'll get the same answer from all
-          * attachments).
+          * attachments). If using EXT_multisampled_render_to_texture, the
+          * number of samples will be on fb->Attachment[i].NumSamples instead
+          * of the usual rb->NumSamples, but it's still guarantted to be the
+          * same for every attachment.
+          *
+          * From EXT_multisampled_render_to_texture:
+          *
+          *    Also, FBOs cannot combine attachments that have associated
+          *    multisample data specified by the mechanisms described in this
+          *    extension with attachments allocated using the core OpenGL ES
+          *    3.1 mechanisms, such as TexStorage2DMultisample. Add to section
+          *    9.4.2 "Whole Framebuffer Completeness":
+          *
+          *    "* If the value of RENDERBUFFER_SAMPLES is non-zero, all or
+          *       none of the attached renderbuffers have been allocated
+          *       using RenderbufferStorage- MultisampleEXT; if the value of
+          *       TEXTURES_SAMPLES is non-zero, all or none of the attached
+          *       textures have been attached using Framebuffer-
+          *       Texture2DMultisampleEXT.
+          *       { GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT }"
           */
-         fb->Visual.samples = rb->NumSamples;
+         fb->Visual.samples =
+            att->NumSamples ? att->NumSamples : rb->NumSamples;
 
          if (_mesa_is_legal_color_format(ctx, baseFormat)) {
             fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS);

Reply via email to