[Mesa-dev] [v3 PATCH 03/10] mesa: Complete implementation for ARB_framebuffer_no_attachments in Mesa core

Ilia Mirkin imirkin at alum.mit.edu
Thu May 21 14:49:40 PDT 2015


On Thu, May 21, 2015 at 5:30 PM,  <kevin.rogovin at intel.com> wrote:
> From: Kevin Rogovin <kevin.rogovin at intel.com>

If you set your email name to that, you won't get this funny mail, and
your name will appear properly in the actual email sent.

This is what I have in my .gitconfig:

[user]
        email = imirkin at alum.mit.edu
        name = Ilia Mirkin

Adjust to taste :)

>
> Implement GL_ARB_framebuffer_no_attachments in Mesa core
>  - changes to conditions for framebuffer completenss
>  - implement set/get functions for framebuffers for
>    new functions in GL_ARB_framebuffer_no_attachments
>
> v1 -> v2
>  Spacing and exceed 80 characters per line fixes.
>
> v2 -> v3
>  Implement DSA functions of extension.
>
>
> Signed-off-by: Kevin Rogovin <kevin.rogovin at intel.com>
> ---
>  src/mesa/main/fbobject.c | 217 ++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 184 insertions(+), 33 deletions(-)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 4ac3f20..18def71 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -1156,14 +1156,49 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
>        } else if (att_layer_count > max_layer_count) {
>           max_layer_count = att_layer_count;
>        }
> +
> +      /**
> +       * The extension GL_ARB_framebuffer_no_attachments places the additional
> +       * requirement on each attachment that
> +       *
> +       * "The width and height of image are greater than zero and less than or
> +       *  equal to the values of the implementation-dependent limits
> +       *  MAX_FRAMEBUFFER_WIDTH and MAX_FRAMEBUFFER_HEIGHT, respectively. "
> +       *
> +       * "If <image> is a three-dimensional texture or a one- or two-dimensional
> +       *  array texture and the attachment is layered, the depth or layer count
> +       *  of the texture is less than or equal to the implementation-dependent
> +       *  limit MAX_FRAMEBUFFER_LAYERS."
> +       *
> +       * "If image has multiple samples, its sample count is less than or equal
> +       *  to the value of the implementation-dependent limit MAX_FRAMEBUFFER_-
> +       *  SAMPLES ."
> +       *
> +       * The same requirements are also in place for GL 4.5,
> +       * Section 9.4.1 "Framebuffer Attachment Completeness", pg 310-311
> +       *
> +       * However, this is a tighter restriction than previous version of GL.
> +       * In interest of better compatibility, we will not enforce these
> +       * restrictions.
> +       */
>     }
>
>     fb->MaxNumLayers = max_layer_count;
>
>     if (numImages == 0) {
> -      fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
> -      fbo_incomplete(ctx, "no attachments", -1);
> -      return;
> +      fb->_HasAttachments = GL_FALSE;
> +
> +      if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
> +         fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
> +         fbo_incomplete(ctx, "no attachments", -1);
> +         return;
> +      }
> +
> +      if (fb->DefaultGeometry.Width == 0 || fb->DefaultGeometry.Height == 0) {
> +         fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
> +         fbo_incomplete(ctx, "no attachments and default width or height is 0", -1);
> +         return;
> +      }
>     }
>
>     if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
> @@ -1228,8 +1263,10 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
>         * renderbuffers/textures are different sizes, the framebuffer
>         * width/height will be set to the smallest width/height.
>         */
> -      fb->Width = minWidth;
> -      fb->Height = minHeight;
> +      if (numImages != 0) {
> +         fb->Width = minWidth;
> +         fb->Height = minHeight;
> +      }
>
>        /* finally, update the visual info for the framebuffer */
>        _mesa_update_framebuffer_visual(ctx, fb);
> @@ -1335,32 +1372,127 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
>     bind_renderbuffer(target, renderbuffer, true);
>  }
>
> -extern void GLAPIENTRY
> +static void
> +framebuffer_parameteri(struct gl_context *ctx, struct gl_framebuffer *fb,
> +                       GLenum pname, GLint param, const char *func)
> +{
> +   switch (pname) {
> +   case GL_FRAMEBUFFER_DEFAULT_WIDTH:
> +      if (param < 0 || param > ctx->Const.MaxFramebufferWidth)
> +        _mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
> +      else
> +         fb->DefaultGeometry.Width = param;
> +      break;
> +   case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
> +      if (param < 0 || param > ctx->Const.MaxFramebufferHeight)
> +        _mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
> +      else
> +         fb->DefaultGeometry.Height = param;
> +      break;
> +   case GL_FRAMEBUFFER_DEFAULT_LAYERS:
> +      if (param < 0 || param > ctx->Const.MaxFramebufferLayers)
> +        _mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
> +      else
> +         fb->DefaultGeometry.Layers = param;
> +      break;
> +   case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
> +      if (param < 0 || param > ctx->Const.MaxFramebufferSamples)
> +        _mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
> +      else
> +        fb->DefaultGeometry.NumSamples = param;
> +      break;
> +   case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
> +      fb->DefaultGeometry.FixedSampleLocations = param;
> +      break;
> +   default:
> +      _mesa_error(ctx, GL_INVALID_ENUM,
> +                  "%s(pname=0x%x)", func, pname);
> +   }
> +}
> +
> +void GLAPIENTRY
>  _mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param)
>  {
>     GET_CURRENT_CONTEXT(ctx);
> +   struct gl_framebuffer *fb;
>
> -   (void) target;
> -   (void) pname;
> -   (void) param;
> +   if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "glFramebufferParameteriv not supported "
> +                  "(ARB_framebuffer_no_attachments not implemented)");
> +   }
>
> -   _mesa_error(ctx, GL_INVALID_OPERATION,
> -               "glFramebufferParameteri not supported "
> -               "(ARB_framebuffer_no_attachments not implemented)");
> +   fb = get_framebuffer_target(ctx, target);
> +   if (!fb) {
> +      _mesa_error(ctx, GL_INVALID_ENUM,
> +                  "glFramebufferParameteri(target=0x%x)", target);
> +      return;
> +   }
> +
> +   /* check framebuffer binding */
> +   if (_mesa_is_winsys_fbo(fb)) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "glFramebufferParameteri");
> +      return;
> +   }
> +
> +   framebuffer_parameteri(ctx, fb, pname, param, "glFramebufferParameteri");
> +}
> +
> +static void
> +get_framebuffer_parameteriv(struct gl_context *ctx, struct gl_framebuffer *fb,
> +                            GLenum pname, GLint *params, const char *func)
> +{
> +  switch (pname) {

2-space indent, should be 3

> +  case GL_FRAMEBUFFER_DEFAULT_WIDTH:
> +     *params = fb->DefaultGeometry.Width;
> +     break;
> +  case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
> +     *params = fb->DefaultGeometry.Height;
> +     break;
> +  case GL_FRAMEBUFFER_DEFAULT_LAYERS:
> +     *params = fb->DefaultGeometry.Layers;
> +     break;
> +  case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
> +     *params = fb->DefaultGeometry.NumSamples;
> +     break;
> +  case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
> +     *params = fb->DefaultGeometry.FixedSampleLocations;
> +     break;
> +  default:
> +     _mesa_error(ctx, GL_INVALID_ENUM,
> +                 "%s(pname=0x%x)", func, pname);
> +  }
>  }
>
> -extern void GLAPIENTRY
> +void GLAPIENTRY
>  _mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
>  {
>     GET_CURRENT_CONTEXT(ctx);
> +   struct gl_framebuffer *fb;
>
> -   (void) target;
> -   (void) pname;
> -   (void) param;
> +   if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "glGetFramebufferParameteriv not supported "
> +                  "(ARB_framebuffer_no_attachments not implemented)");

return;

> +   }
>
> -   _mesa_error(ctx, GL_INVALID_OPERATION,
> -               "glGetNamedFramebufferParameteriv not supported "
> -               "(ARB_framebuffer_no_attachments not implemented)");
> +   fb = get_framebuffer_target(ctx, target);
> +   if (!fb) {
> +      _mesa_error(ctx, GL_INVALID_ENUM,
> +                  "glGetFramebufferParameteriv(target=0x%x)", target);
> +      return;
> +   }
> +
> +   /* check framebuffer binding */
> +   if (_mesa_is_winsys_fbo(fb)) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "glGetFramebufferParameteriv");
> +      return;
> +   }
> +
> +   get_framebuffer_parameteriv(ctx, fb, pname, params,
> +                               "glGetFramebufferParameteriv");
>  }
>
>
> @@ -3757,10 +3889,7 @@ _mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
>                                   GLint param)
>  {
>     GET_CURRENT_CONTEXT(ctx);
> -
> -   (void) framebuffer;
> -   (void) pname;
> -   (void) param;
> +   struct gl_framebuffer *fb = NULL;
>
>     if (!ctx->Extensions.ARB_direct_state_access) {
>        _mesa_error(ctx, GL_INVALID_OPERATION,
> @@ -3769,9 +3898,19 @@ _mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
>        return;
>     }
>
> -   _mesa_error(ctx, GL_INVALID_OPERATION,
> -               "glNamedFramebufferParameteri not supported "
> -               "(ARB_framebuffer_no_attachments not implemented)");
> +   if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "glNamedFramebufferParameteri not supported "
> +                  "(ARB_framebuffer_no_attachments not implemented)");

return;

> +   }
> +
> +   fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
> +                                     "glNamedFramebufferParameteri");
> +
> +   if (fb) {
> +      framebuffer_parameteri(ctx, fb, pname, param,
> +                             "glNamedFramebufferParameteriv");
> +   }
>  }
>
>
> @@ -3780,10 +3919,7 @@ _mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
>                                       GLint *param)
>  {
>     GET_CURRENT_CONTEXT(ctx);
> -
> -   (void) framebuffer;
> -   (void) pname;
> -   (void) param;
> +   struct gl_framebuffer *fb;
>
>     if (!ctx->Extensions.ARB_direct_state_access) {
>        _mesa_error(ctx, GL_INVALID_OPERATION,
> @@ -3792,9 +3928,24 @@ _mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
>        return;
>     }
>
> -   _mesa_error(ctx, GL_INVALID_OPERATION,
> -               "glGetNamedFramebufferParameteriv not supported "
> -               "(ARB_framebuffer_no_attachments not implemented)");
> +   if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "glGetNamedFramebufferParameteriv not supported "
> +                  "(ARB_framebuffer_no_attachments not implemented)");

return;

> +   }
> +
> +   if (framebuffer) {
> +      fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
> +                                        "glGetNamedFramebufferParameteriv");
> +   }
> +   else {
> +      fb = ctx->WinSysDrawBuffer;
> +   }
> +
> +   if (fb) {
> +      get_framebuffer_parameteriv(ctx, fb, pname, param,
> +                                  "glGetNamedFramebufferParameteriv");
> +   }
>  }
>
>
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list