diff options
author | Neil Roberts <[email protected]> | 2011-11-30 22:29:21 +0000 |
---|---|---|
committer | Chad Versace <[email protected]> | 2012-01-13 10:06:30 -0800 |
commit | 9462b8447864c754252cd2580c9e1e4d36d5cc63 (patch) | |
tree | a453cf02bd9458bbf66d1bcbb16dbe07b222f5a0 | |
parent | 27915708ed4519cc5606e81fb789e8427501f355 (diff) |
gen6_hiz: Don't bind GL_DRAW_FRAMEBUFFER on GLES
When using Mesa with a GLES API, calling _mesa_FramebufferRenderbuffer
with GL_DRAW_FRAMEBUFFER will report a 'user error' because
get_framebuffer_target validates that this enum from the framebuffer
blit extension is only used on GL. To work around it this patch makes
it use the GL_FRAMEBUFFER enum instead in that case.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=43418
Note: This is a candidate for the 8.0 branch.
Signed-off-by: Chad Versace <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/gen6_hiz.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/i965/gen6_hiz.c b/src/mesa/drivers/dri/i965/gen6_hiz.c index e28251182c9..92b1d61ef44 100644 --- a/src/mesa/drivers/dri/i965/gen6_hiz.c +++ b/src/mesa/drivers/dri/i965/gen6_hiz.c @@ -109,6 +109,24 @@ static const uint32_t gen6_hiz_meta_save = MESA_META_SELECT_FEEDBACK; +static void +gen6_hiz_get_framebuffer_enum(struct gl_context *ctx, + GLenum *bind_enum, + GLenum *get_enum) +{ + /* If the blit framebuffer extension isn't supported then Mesa will + report an error if we try to bind GL_DRAW_FRAMEBUFFER. However in + that case it should be safe to just save and restore + GL_FRAMEBUFFER instead. */ + if (ctx->Extensions.EXT_framebuffer_blit && ctx->API == API_OPENGL) { + *bind_enum = GL_DRAW_FRAMEBUFFER; + *get_enum = GL_DRAW_FRAMEBUFFER_BINDING; + } else { + *bind_enum = GL_FRAMEBUFFER; + *get_enum = GL_FRAMEBUFFER_BINDING; + } +} + /** * Initialize static data needed for HiZ operations. */ @@ -117,10 +135,13 @@ gen6_hiz_init(struct brw_context *brw) { struct gl_context *ctx = &brw->intel.ctx; struct brw_hiz_state *hiz = &brw->hiz; + GLenum fb_bind_enum, fb_get_enum; if (hiz->fbo != 0) return; + gen6_hiz_get_framebuffer_enum(ctx, &fb_bind_enum, &fb_get_enum); + /* Create depthbuffer. * * Until glRenderbufferStorage is called, the renderbuffer hash table @@ -139,8 +160,8 @@ gen6_hiz_init(struct brw_context *brw) /* Setup FBO. */ _mesa_GenFramebuffersEXT(1, &hiz->fbo); - _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, hiz->fbo); - _mesa_FramebufferRenderbufferEXT(GL_DRAW_FRAMEBUFFER, + _mesa_BindFramebufferEXT(fb_bind_enum, hiz->fbo); + _mesa_FramebufferRenderbufferEXT(fb_bind_enum, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, hiz->depth_rb->Name); @@ -241,6 +262,7 @@ gen6_resolve_slice(struct intel_context *intel, struct gl_context *ctx = &intel->ctx; struct brw_context *brw = brw_context(ctx); struct brw_hiz_state *hiz = &brw->hiz; + GLenum fb_bind_enum, fb_get_enum; /* Do not recurse. */ assert(!brw->hiz.op); @@ -250,11 +272,13 @@ gen6_resolve_slice(struct intel_context *intel, assert(level <= mt->last_level); assert(layer < mt->level[level].depth); + gen6_hiz_get_framebuffer_enum(ctx, &fb_bind_enum, &fb_get_enum); + /* Save state. */ GLint save_drawbuffer; GLint save_renderbuffer; _mesa_meta_begin(ctx, gen6_hiz_meta_save); - _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &save_drawbuffer); + _mesa_GetIntegerv(fb_get_enum, &save_drawbuffer); _mesa_GetIntegerv(GL_RENDERBUFFER_BINDING, &save_renderbuffer); /* Initialize context data for HiZ operations. */ @@ -272,7 +296,7 @@ gen6_resolve_slice(struct intel_context *intel, /* Setup FBO. */ gen6_hiz_setup_depth_buffer(brw, mt, level, layer); - _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, hiz->fbo); + _mesa_BindFramebufferEXT(fb_bind_enum, hiz->fbo); /* A rectangle primitive (3DPRIM_RECTLIST) consists of only three vertices. @@ -316,7 +340,7 @@ gen6_resolve_slice(struct intel_context *intel, */ gen6_hiz_teardown_depth_buffer(hiz->depth_rb); _mesa_BindRenderbufferEXT(GL_RENDERBUFFER, save_renderbuffer); - _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, save_drawbuffer); + _mesa_BindFramebufferEXT(fb_bind_enum, save_drawbuffer); _mesa_meta_end(ctx); } |