meta/generate_mipmap: Track framebuffer using gl_framebuffer instead of GL API object handle
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
if (mipmap->fb == NULL) {
|
||||
GLuint FBO;
|
||||
|
||||
_mesa_meta_framebuffer_texture_image(ctx, ctx->DrawBuffer,
|
||||
_mesa_CreateFramebuffers(1, &FBO);
|
||||
mipmap->fb = _mesa_lookup_framebuffer(ctx, FBO);
|
||||
assert(mipmap->fb != NULL && mipmap->fb->Name == FBO);
|
||||
}
|
||||
|
||||
_mesa_meta_framebuffer_texture_image(ctx, mipmap->fb,
|
||||
GL_COLOR_ATTACHMENT0, baseImage, 0);
|
||||
|
||||
status = _mesa_check_framebuffer_status(ctx, ctx->DrawBuffer);
|
||||
|
||||
_mesa_BindFramebuffer(fbo_target, fboSave);
|
||||
|
||||
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);
|
||||
|
||||
|
Reference in New Issue
Block a user