[Mesa-dev] [PATCH 05/38] main: Add entry point for NamedFramebufferRenderbuffer.
Fredrik Höglund
fredrik at kde.org
Thu Apr 9 12:42:23 PDT 2015
On Wednesday 04 March 2015, Laura Ekstrand wrote:
> ---
> src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 ++
> src/mesa/main/fbobject.c | 139 +++++++++++++++++--------
> src/mesa/main/fbobject.h | 12 +++
> src/mesa/main/tests/dispatch_sanity.cpp | 1 +
> 4 files changed, 115 insertions(+), 44 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> index 85ef1f6..b954343 100644
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> @@ -118,6 +118,13 @@
> <param name="framebuffers" type="GLuint *" />
> </function>
>
> + <function name="NamedFramebufferRenderbuffer" offset="assign">
> + <param name="framebuffer" type="GLuint" />
> + <param name="attachment" type="GLenum" />
> + <param name="renderbuffertarget" type="GLenum" />
> + <param name="renderbuffer" type="GLuint" />
> + </function>
> +
> <!-- Texture object functions -->
>
> <function name="CreateTextures" offset="assign">
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 948ac91..3895328 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -2748,71 +2748,37 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
> }
>
>
> -void GLAPIENTRY
> -_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
> - GLenum renderbufferTarget,
> - GLuint renderbuffer)
> +void
> +_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
> + struct gl_framebuffer *fb,
> + GLenum attachment,
> + struct gl_renderbuffer *rb,
> + const char *func)
> {
> struct gl_renderbuffer_attachment *att;
> - struct gl_framebuffer *fb;
> - struct gl_renderbuffer *rb;
> - GET_CURRENT_CONTEXT(ctx);
> -
> - fb = get_framebuffer_target(ctx, target);
> - if (!fb) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glFramebufferRenderbuffer(target)");
> - return;
> - }
> -
> - if (renderbufferTarget != GL_RENDERBUFFER_EXT) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glFramebufferRenderbuffer(renderbufferTarget)");
> - return;
> - }
>
> if (_mesa_is_winsys_fbo(fb)) {
> /* Can't attach new renderbuffers to a window system framebuffer */
> - _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbuffer");
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "%s(default framebuffer bound)", func);
> return;
> }
>
> att = get_attachment(ctx, fb, attachment);
> if (att == NULL) {
> _mesa_error(ctx, GL_INVALID_ENUM,
> - "glFramebufferRenderbuffer(invalid attachment %s)",
> + "%s(invalid attachment %s)", func,
> _mesa_lookup_enum_by_nr(attachment));
> return;
> }
>
> - if (renderbuffer) {
> - rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
> - if (!rb) {
> - _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glFramebufferRenderbuffer(non-existant"
> - " renderbuffer %u)", renderbuffer);
> - return;
> - }
> - else if (rb == &DummyRenderbuffer) {
> - _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glFramebufferRenderbuffer(renderbuffer %u)",
> - renderbuffer);
> - return;
> - }
> - }
> - else {
> - /* remove renderbuffer attachment */
> - rb = NULL;
> - }
> -
> if (attachment == GL_DEPTH_STENCIL_ATTACHMENT &&
> rb && rb->Format != MESA_FORMAT_NONE) {
> /* make sure the renderbuffer is a depth/stencil format */
> const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
> if (baseFormat != GL_DEPTH_STENCIL) {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glFramebufferRenderbuffer(renderbuffer"
> - " is not DEPTH_STENCIL format)");
> + "%s(renderbuffer is not DEPTH_STENCIL format)", func);
> return;
> }
> }
> @@ -2828,6 +2794,91 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
> _mesa_update_framebuffer_visual(ctx, fb);
> }
>
> +void GLAPIENTRY
> +_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
> + GLenum renderbuffertarget,
> + GLuint renderbuffer)
> +{
> + struct gl_framebuffer *fb;
> + struct gl_renderbuffer *rb;
> + GET_CURRENT_CONTEXT(ctx);
> +
> + fb = get_framebuffer_target(ctx, target);
> + if (!fb) {
> + _mesa_error(ctx, GL_INVALID_ENUM,
> + "glFramebufferRenderbuffer(invalid target %s)",
> + _mesa_lookup_enum_by_nr(target));
> + return;
> + }
> +
> + if (renderbuffertarget != GL_RENDERBUFFER_EXT) {
> + _mesa_error(ctx, GL_INVALID_ENUM,
> + "glFramebufferRenderbuffer(renderbuffer target is not "
> + "GL_RENDERBUFFER)");
> + return;
> + }
> +
> + if (renderbuffer) {
> + rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer,
> + "glFramebufferRenderbuffer");
> + if (!rb)
> + return;
> + else if (rb == &DummyRenderbuffer) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "glFramebufferRenderbuffer(renderbuffer=%u never bound)",
> + renderbuffer);
> + return;
I think it would make sense to move this test into
_mesa_lookup_renderbuffer_err().
> + }
> + }
> + else {
> + /* remove renderbuffer attachment */
> + rb = NULL;
> + }
> +
> + _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
> + "glFramebufferRenderbuffer");
> +}
> +
> +void GLAPIENTRY
> +_mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
> + GLenum renderbuffertarget,
> + GLuint renderbuffer)
> +{
> + struct gl_framebuffer *fb;
> + struct gl_renderbuffer *rb;
> + GET_CURRENT_CONTEXT(ctx);
> +
> + fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
> + "glNamedFramebufferRenderbuffer");
> +
> + if (renderbuffertarget != GL_RENDERBUFFER_EXT) {
> + _mesa_error(ctx, GL_INVALID_ENUM,
> + "glNamedFramebufferRenderbuffer(renderbuffer target is not "
> + "GL_RENDERBUFFER)");
> + return;
> + }
> +
> + if (renderbuffer) {
> + rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer,
> + "glNamedFramebufferRenderbuffer");
> + if (!rb)
> + return;
> + else if (rb == &DummyRenderbuffer) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "glNamedFramebufferRenderbuffer("
> + "renderbuffer=%u never bound", renderbuffer);
> + return;
> + }
> + }
> + else {
> + /* remove renderbuffer attachment */
> + rb = NULL;
> + }
> +
> + _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
> + "glNamedFramebufferRenderbuffer");
> +}
> +
>
> void GLAPIENTRY
> _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
> diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
> index 10ae242..e25e6d4 100644
> --- a/src/mesa/main/fbobject.h
> +++ b/src/mesa/main/fbobject.h
> @@ -88,6 +88,13 @@ _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
> struct gl_renderbuffer *rb);
>
> extern void
> +_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
> + struct gl_framebuffer *fb,
> + GLenum attachment,
> + struct gl_renderbuffer *rb,
> + const char *func);
> +
> +extern void
> _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
>
> extern GLboolean
> @@ -191,6 +198,11 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
> GLuint renderbuffer);
>
> extern void GLAPIENTRY
> +_mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
> + GLenum renderbuffertarget,
> + GLuint renderbuffer);
> +
> +extern void GLAPIENTRY
> _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
> GLenum pname, GLint *params);
>
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
> index ee8b20f..c370a80 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -971,6 +971,7 @@ const struct function gl_core_functions_possible[] = {
> { "glGetNamedBufferPointerv", 45, -1 },
> { "glGetNamedBufferSubData", 45, -1 },
> { "glCreateFramebuffers", 45, -1 },
> + { "glNamedFramebufferRenderbuffer", 45, -1 },
> { "glCreateTextures", 45, -1 },
> { "glTextureStorage1D", 45, -1 },
> { "glTextureStorage2D", 45, -1 },
>
More information about the mesa-dev
mailing list