summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2015-11-13 17:14:00 -0800
committerIan Romanick <[email protected]>2016-03-01 11:07:20 -0800
commit3ed44fab1811a2112d3b10233640b5aa369b2d21 (patch)
treebadc7cfd5b20140679bd6d7bcf07beac2818f0ba
parentec5757f9c93c6749aee39a10d6edfe4a7389ef5e (diff)
meta/generate_mipmap: Track framebuffer using gl_framebuffer instead of GL API object handle
Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r--src/mesa/drivers/common/meta.h2
-rw-r--r--src/mesa/drivers/common/meta_generate_mipmap.c38
2 files changed, 16 insertions, 24 deletions
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 03d86c8190d..b2c550f89de 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -369,7 +369,7 @@ struct gen_mipmap_state
{
GLuint VAO;
struct gl_buffer_object *buf_obj;
- GLuint FBO;
+ struct gl_framebuffer *fb;
struct gl_sampler_object *samp_obj;
struct blit_shader_table shaders;
diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c
index 3f52698b3a2..ffc26164235 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -35,6 +35,7 @@
#include "main/enums.h"
#include "main/enable.h"
#include "main/fbobject.h"
+#include "main/framebuffer.h"
#include "main/macros.h"
#include "main/mipmap.h"
#include "main/teximage.h"
@@ -56,21 +57,11 @@ static bool
fallback_required(struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj)
{
- const GLuint fboSave = ctx->DrawBuffer->Name;
struct gen_mipmap_state *mipmap = &ctx->Meta->Mipmap;
struct gl_texture_image *baseImage;
GLuint srcLevel;
GLenum status;
- /* GL_DRAW_FRAMEBUFFER does not exist in OpenGL ES 1.x, and since
- * _mesa_meta_begin hasn't been called yet, we have to work-around API
- * difficulties. The whole reason that GL_DRAW_FRAMEBUFFER is used instead
- * of GL_FRAMEBUFFER is that the read framebuffer may be different. This
- * is moot in OpenGL ES 1.x.
- */
- const GLenum fbo_target = ctx->API == API_OPENGLES
- ? GL_FRAMEBUFFER : GL_DRAW_FRAMEBUFFER;
-
/* check for fallbacks */
if (target == GL_TEXTURE_3D) {
_mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH,
@@ -109,17 +100,18 @@ fallback_required(struct gl_context *ctx, GLenum target,
/*
* Test that we can actually render in the texture's format.
*/
- if (!mipmap->FBO)
- _mesa_CreateFramebuffers(1, &mipmap->FBO);
- _mesa_BindFramebuffer(fbo_target, mipmap->FBO);
-
- _mesa_meta_framebuffer_texture_image(ctx, ctx->DrawBuffer,
- GL_COLOR_ATTACHMENT0, baseImage, 0);
+ if (mipmap->fb == NULL) {
+ GLuint FBO;
- status = _mesa_check_framebuffer_status(ctx, ctx->DrawBuffer);
+ _mesa_CreateFramebuffers(1, &FBO);
+ mipmap->fb = _mesa_lookup_framebuffer(ctx, FBO);
+ assert(mipmap->fb != NULL && mipmap->fb->Name == FBO);
+ }
- _mesa_BindFramebuffer(fbo_target, fboSave);
+ _mesa_meta_framebuffer_texture_image(ctx, mipmap->fb,
+ GL_COLOR_ATTACHMENT0, baseImage, 0);
+ status = _mesa_check_framebuffer_status(ctx, mipmap->fb);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
_mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH,
"glGenerateMipmap() got incomplete FBO\n");
@@ -140,9 +132,9 @@ _mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx,
_mesa_reference_buffer_object(ctx, &mipmap->buf_obj, NULL);
_mesa_reference_sampler_object(ctx, &mipmap->samp_obj, NULL);
- if (mipmap->FBO != 0) {
- _mesa_DeleteFramebuffers(1, &mipmap->FBO);
- mipmap->FBO = 0;
+ if (mipmap->fb != NULL) {
+ _mesa_DeleteFramebuffers(1, &mipmap->fb->Name);
+ mipmap->fb = NULL;
}
_mesa_meta_blit_shader_table_cleanup(&mipmap->shaders);
@@ -252,8 +244,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
_mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, mipmap->samp_obj);
- assert(mipmap->FBO != 0);
- _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, mipmap->FBO);
+ assert(mipmap->fb != NULL);
+ _mesa_bind_framebuffers(ctx, mipmap->fb, mipmap->fb);
_mesa_texture_parameteriv(ctx, texObj, GL_GENERATE_MIPMAP, &always_false, false);