xwayland/eglstream: Check framebuffer status
The EGLStream backend would sometime generate GL errors trying to draw to the framebuffer, which gives an invalid buffer, which in turn would generate a Wayland error from the compositor which is fatal to the client. Check the framebuffer status and bail out early if it's not complete, to avoid getting into trouble later. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
This commit is contained in:
		
							parent
							
								
									252cbad316
								
							
						
					
					
						commit
						85244d2a20
					
				| 
						 | 
					@ -619,6 +619,7 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
 | 
				
			||||||
        box->x2 - box->x1, box->y2 - box->y1
 | 
					        box->x2 - box->x1, box->y2 - box->y1
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    GLint saved_vao;
 | 
					    GLint saved_vao;
 | 
				
			||||||
 | 
					    int status;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (xwl_pixmap->type != XWL_PIXMAP_EGLSTREAM)
 | 
					    if (xwl_pixmap->type != XWL_PIXMAP_EGLSTREAM)
 | 
				
			||||||
        /* This can happen if a client does X11 rendering on a
 | 
					        /* This can happen if a client does X11 rendering on a
 | 
				
			||||||
| 
						 | 
					@ -652,6 +653,13 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
 | 
				
			||||||
    glUniform1i(xwl_eglstream->blit_is_rgba_pos,
 | 
					    glUniform1i(xwl_eglstream->blit_is_rgba_pos,
 | 
				
			||||||
                pixmap->drawable.depth >= 32);
 | 
					                pixmap->drawable.depth >= 32);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 | 
				
			||||||
 | 
					    if (status != GL_FRAMEBUFFER_COMPLETE) {
 | 
				
			||||||
 | 
					        ErrorF("eglstream: Framebuffer incomplete 0x%X, not posting damage\n", status);
 | 
				
			||||||
 | 
					        status = FALSE;
 | 
				
			||||||
 | 
					        goto out;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Blit rendered image into EGLStream surface */
 | 
					    /* Blit rendered image into EGLStream surface */
 | 
				
			||||||
    glDrawBuffer(GL_BACK);
 | 
					    glDrawBuffer(GL_BACK);
 | 
				
			||||||
    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 | 
					    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 | 
				
			||||||
| 
						 | 
					@ -662,14 +670,16 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        eglSwapBuffers(xwl_screen->egl_display, xwl_pixmap->surface);
 | 
					        eglSwapBuffers(xwl_screen->egl_display, xwl_pixmap->surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* hang onto the pixmap until the compositor has released it */
 | 
				
			||||||
 | 
					    pixmap->refcnt++;
 | 
				
			||||||
 | 
					    status = TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
    /* Restore previous state */
 | 
					    /* Restore previous state */
 | 
				
			||||||
    glBindVertexArray(saved_vao);
 | 
					    glBindVertexArray(saved_vao);
 | 
				
			||||||
    glBindTexture(GL_TEXTURE_2D, 0);
 | 
					    glBindTexture(GL_TEXTURE_2D, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* hang onto the pixmap until the compositor has released it */
 | 
					    return status;
 | 
				
			||||||
    pixmap->refcnt++;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return TRUE;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static Bool
 | 
					static Bool
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue