tl;dr: For many types of GL object, we can *NEVER* use the Gen function.
In OpenGL ES (all versions!) and OpenGL compatibility profile,
applications don't have to call Gen functions. The GL spec is very
clear about how you can mix-and-match generated names and non-generated
names: you can use any name you want for a particular object type until
you call the Gen function for that object type.
Here's the problem scenario:
- Application calls a meta function that generates a name. The first
Gen will probably return 1.
- Application decides to use the same name for an object of the same
type without calling Gen. Many demo programs use names 1, 2, 3,
etc. without calling Gen.
- Application calls the meta function again, and the meta function
replaces the data. The application's data is lost, and the app
fails. Have fun debugging that.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92363
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
#include "main/varray.h"
#include "main/uniforms.h"
#include "main/fbobject.h"
+#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/texobj.h"
struct intel_mipmap_tree *mt)
{
struct gl_context *ctx = &brw->ctx;
- GLuint fbo;
struct gl_framebuffer *drawFb;
struct gl_renderbuffer *rb;
struct rect rect;
brw_emit_mi_flush(brw);
- _mesa_meta_begin(ctx, MESA_META_ALL);
-
- _mesa_CreateFramebuffers(1, &fbo);
+ drawFb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
+ if (drawFb == NULL) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "in %s", __func__);
+ return;
+ }
- drawFb = _mesa_lookup_framebuffer(ctx, fbo);
- assert(drawFb != NULL && drawFb->Name == fbo);
+ _mesa_meta_begin(ctx, MESA_META_ALL);
rb = brw_get_rb_for_slice(brw, mt, 0, 0, false);
use_rectlist(brw, false);
_mesa_reference_renderbuffer(&rb, NULL);
- _mesa_DeleteFramebuffers(1, &fbo);
+ _mesa_reference_framebuffer(&drawFb, NULL);
_mesa_meta_end(ctx);
#include "main/blit.h"
#include "main/buffers.h"
#include "main/fbobject.h"
+#include "main/framebuffer.h"
#include "main/uniforms.h"
#include "main/texparam.h"
#include "main/texobj.h"
struct gl_context *ctx = &brw->ctx;
struct blit_dims dims = *orig_dims;
struct fb_tex_blit_state blit;
- GLuint prog, fbo;
- struct gl_framebuffer *drawFb;
- struct gl_renderbuffer *rb;
+ GLuint prog;
+ struct gl_framebuffer *drawFb = NULL;
+ struct gl_renderbuffer *rb = NULL;
GLenum target;
_mesa_meta_fb_tex_blit_begin(ctx, &blit);
assert(ctx->Extensions.ARB_texture_stencil8 == false);
ctx->Extensions.ARB_texture_stencil8 = true;
- _mesa_CreateFramebuffers(1, &fbo);
- drawFb = _mesa_lookup_framebuffer(ctx, fbo);
- assert(drawFb != NULL && drawFb->Name == fbo);
+ drawFb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
+ if (drawFb == NULL) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "in %s", __func__);
+ goto error;
+ }
/* Force the surface to be configured for level zero. */
rb = brw_get_rb_for_slice(brw, dst_mt, 0, dst_layer, true);
_mesa_meta_end(ctx);
_mesa_reference_renderbuffer(&rb, NULL);
- _mesa_DeleteFramebuffers(1, &fbo);
+ _mesa_reference_framebuffer(&drawFb, NULL);
}
void
.dst_x0 = 0, .dst_y0 = 0,
.dst_x1 = dst->logical_width0, .dst_y1 = dst->logical_height0,
.mirror_x = 0, .mirror_y = 0 };
- GLuint fbo;
struct gl_framebuffer *readFb;
struct gl_renderbuffer *rb;
if (dst->stencil_mt)
dst = dst->stencil_mt;
+ readFb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
+ if (readFb == NULL)
+ return;
+
brw_emit_mi_flush(brw);
_mesa_meta_begin(ctx, MESA_META_ALL);
- _mesa_CreateFramebuffers(1, &fbo);
- readFb = _mesa_lookup_framebuffer(ctx, fbo);
- assert(readFb != NULL && readFb->Name == fbo);
-
rb = brw_get_rb_for_slice(brw, src, 0, 0, false);
_mesa_bind_framebuffers(ctx, ctx->DrawBuffer, readFb);
brw_emit_mi_flush(brw);
_mesa_reference_renderbuffer(&rb, NULL);
- _mesa_DeleteFramebuffers(1, &fbo);
+ _mesa_reference_framebuffer(&readFb, NULL);
}
#include "main/buffers.h"
#include "main/enums.h"
#include "main/fbobject.h"
+#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "drivers/common/meta.h"
struct intel_mipmap_tree *dst_mt)
{
struct gl_context *ctx = &brw->ctx;
- GLuint fbos[2];
struct gl_framebuffer *src_fb;
struct gl_framebuffer *dst_fb;
struct gl_renderbuffer *src_rb;
brw_emit_mi_flush(brw);
_mesa_meta_begin(ctx, MESA_META_ALL);
- _mesa_CreateFramebuffers(2, fbos);
src_rb = brw_get_rb_for_slice(brw, src_mt, 0, 0, false);
dst_rb = brw_get_rb_for_slice(brw, dst_mt, 0, 0, false);
- src_fb = _mesa_lookup_framebuffer(ctx, fbos[0]);
- dst_fb = _mesa_lookup_framebuffer(ctx, fbos[1]);
+ src_fb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
+ dst_fb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
- assert(src_fb != NULL && src_fb->Name == fbos[0]);
- assert(dst_fb != NULL && dst_fb->Name == fbos[1]);
+ if (src_fb == NULL || dst_fb == NULL || src_rb == NULL || dst_rb == NULL) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "in %s", __func__);
+ goto error;
+ }
_mesa_bind_framebuffers(ctx, dst_fb, src_fb);
_mesa_framebuffer_renderbuffer(ctx, ctx->ReadBuffer, attachment, src_rb);
dst_mt->logical_width0, dst_mt->logical_height0,
blit_bit, GL_NEAREST);
+error:
_mesa_reference_renderbuffer(&src_rb, NULL);
_mesa_reference_renderbuffer(&dst_rb, NULL);
- _mesa_DeleteFramebuffers(2, fbos);
+ _mesa_reference_framebuffer(&src_fb, NULL);
+ _mesa_reference_framebuffer(&dst_fb, NULL);
_mesa_meta_end(ctx);