[Mesa-dev] [PATCH 3/9] mesa: Complete implementation for GL_ARB_framebuffer_no_attachments in Mesa core

Ian Romanick idr at freedesktop.org
Tue May 5 23:47:51 PDT 2015


On 04/29/2015 01:56 AM, kevin.rogovin at intel.com wrote:
> From: Kevin Rogovin <kevin.rogovin at intel.com>
> 
> 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
> 
> ---
>  src/mesa/main/fbobject.c | 154 ++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 145 insertions(+), 9 deletions(-)
> 
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 5c78c40..402537b 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -1113,14 +1113,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) {
> @@ -1185,8 +1220,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);
> @@ -1292,16 +1329,115 @@ _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)

For both this and get_framebuffer_parameteriv below, I don't see the
value in splitting the implementations.  Also, these functions need to
check that the extension is enabled and generate GL_INVALID_OPERATION if
it is not.

> +{
> +   switch (pname) {
> +   case GL_FRAMEBUFFER_DEFAULT_WIDTH:
> +      if (param < 0 || param > ctx->Const.MaxFramebufferWidth)
> +        _mesa_error(ctx, GL_INVALID_VALUE, "%s", func);

It looks like your indention is off by one here and elsewhere in the switch.

> +      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)
>  {
> -  /* to be implemented */
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_framebuffer *fb;
> +
> +   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) {
> +  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)
>  {
> -  /* to be implemented */
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_framebuffer *fb;
> +
> +   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");
>  }
>  
>  
> 



More information about the mesa-dev mailing list