Mesa (master): nouveau: add framebuffer validation callback

Francisco Jerez currojerez at kemper.freedesktop.org
Wed Jan 15 11:27:32 UTC 2014


Module: Mesa
Branch: master
Commit: 716b512dcf1d28eb9cafb31773aec68c4fd58122
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=716b512dcf1d28eb9cafb31773aec68c4fd58122

Author: Ilia Mirkin <imirkin at alum.mit.edu>
Date:   Tue Jan 14 19:50:33 2014 -0500

nouveau: add framebuffer validation callback

Fixes assertions when trying to attach textures to fbs with formats not
supported by the render engines.

See https://bugs.freedesktop.org/show_bug.cgi?id=73459

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-by: Francisco Jerez <currojerez at riseup.net>

---

 src/mesa/drivers/dri/nouveau/nouveau_context.c |    1 +
 src/mesa/drivers/dri/nouveau/nouveau_fbo.c     |   51 ++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index 181c9d0..ec474d4 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -187,6 +187,7 @@ nouveau_context_init(struct gl_context *ctx, struct nouveau_screen *screen,
 	ctx->Extensions.EXT_framebuffer_blit = true;
 	ctx->Extensions.EXT_texture_filter_anisotropic = true;
 	ctx->Extensions.NV_texture_env_combine4 = true;
+	ctx->Const.MaxColorAttachments = 1;
 
 	return GL_TRUE;
 }
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index 25543e4..81e7d62 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -268,6 +268,56 @@ nouveau_finish_render_texture(struct gl_context *ctx,
 	texture_dirty(rb->TexImage->TexObject);
 }
 
+static int
+validate_format_bpp(gl_format format)
+{
+	switch (format) {
+	case MESA_FORMAT_XRGB8888:
+	case MESA_FORMAT_ARGB8888:
+	case MESA_FORMAT_Z24_S8:
+		return 32;
+	case MESA_FORMAT_RGB565:
+	case MESA_FORMAT_Z16:
+		return 16;
+	default:
+		return 0;
+	}
+}
+
+static void
+nouveau_check_framebuffer_complete(struct gl_context *ctx,
+				   struct gl_framebuffer *fb)
+{
+	struct gl_renderbuffer_attachment *color =
+		&fb->Attachment[BUFFER_COLOR0];
+	struct gl_renderbuffer_attachment *depth =
+		&fb->Attachment[BUFFER_DEPTH];
+	int color_bpp = 0, zeta_bpp;
+
+	if (color->Type == GL_TEXTURE) {
+		color_bpp = validate_format_bpp(
+				color->Renderbuffer->TexImage->TexFormat);
+		if (!color_bpp)
+			goto err;
+	}
+
+	if (depth->Type == GL_TEXTURE) {
+		zeta_bpp = validate_format_bpp(
+				depth->Renderbuffer->TexImage->TexFormat);
+		if (!zeta_bpp)
+			goto err;
+		/* NV04/NV05 requires same bpp-ness for color/zeta */
+		if (context_chipset(ctx) < 0x10 &&
+		    color_bpp && color_bpp != zeta_bpp)
+			goto err;
+	}
+
+	return;
+err:
+	fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+	return;
+}
+
 void
 nouveau_fbo_functions_init(struct dd_function_table *functions)
 {
@@ -279,4 +329,5 @@ nouveau_fbo_functions_init(struct dd_function_table *functions)
 	functions->FramebufferRenderbuffer = nouveau_framebuffer_renderbuffer;
 	functions->RenderTexture = nouveau_render_texture;
 	functions->FinishRenderTexture = nouveau_finish_render_texture;
+	functions->ValidateFramebuffer = nouveau_check_framebuffer_complete;
 }




More information about the mesa-commit mailing list