[Mesa-dev] [PATCH 2/2] mesa: make _mesa_accum() static

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed May 3 09:31:40 UTC 2017



On 05/03/2017 11:30 AM, Timothy Arceri wrote:
> On 03/05/17 17:27, Samuel Pitoiset wrote:
>> Why don't inline _mesa_acum()?
> 
> inline is only meaningful if the function is in the header. Just marking 
> it as static will do the same thing in a c file. i.e leave it up to the 
> compiler as to whether it should be inlined or not. At least that's how 
> I understand it.
> 
>> Usually, we remove the '_' for static mesa functions right?
> 
> Right I will remove the mesa also. So its just accum()

Yeah sure, I was just a bit curious. :)

With the '_' removed, this patch is:

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

> 
>>
>> On 05/03/2017 05:38 AM, Timothy Arceri wrote:
>>> ---
>>>   src/mesa/main/accum.c | 104 
>>> +++++++++++++++++++++++++-------------------------
>>>   src/mesa/main/accum.h |   3 --
>>>   2 files changed, 52 insertions(+), 55 deletions(-)
>>>
>>> diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
>>> index ef74468..919c441 100644
>>> --- a/src/mesa/main/accum.c
>>> +++ b/src/mesa/main/accum.c
>>> @@ -46,71 +46,20 @@ _mesa_ClearAccum( GLfloat red, GLfloat green, 
>>> GLfloat blue, GLfloat alpha )
>>>      tmp[2] = CLAMP( blue,  -1.0F, 1.0F );
>>>      tmp[3] = CLAMP( alpha, -1.0F, 1.0F );
>>>      if (TEST_EQ_4V(tmp, ctx->Accum.ClearColor))
>>>         return;
>>>      COPY_4FV( ctx->Accum.ClearColor, tmp );
>>>   }
>>> -void GLAPIENTRY
>>> -_mesa_Accum( GLenum op, GLfloat value )
>>> -{
>>> -   GET_CURRENT_CONTEXT(ctx);
>>> -   FLUSH_VERTICES(ctx, 0);
>>> -
>>> -   switch (op) {
>>> -   case GL_ADD:
>>> -   case GL_MULT:
>>> -   case GL_ACCUM:
>>> -   case GL_LOAD:
>>> -   case GL_RETURN:
>>> -      /* OK */
>>> -      break;
>>> -   default:
>>> -      _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)");
>>> -      return;
>>> -   }
>>> -
>>> -   if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) {
>>> -      _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum 
>>> buffer)");
>>> -      return;
>>> -   }
>>> -
>>> -   if (ctx->DrawBuffer != ctx->ReadBuffer) {
>>> -      /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read,
>>> -       * or GL_EXT_framebuffer_blit.
>>> -       */
>>> -      _mesa_error(ctx, GL_INVALID_OPERATION,
>>> -                  "glAccum(different read/draw buffers)");
>>> -      return;
>>> -   }
>>> -
>>> -   if (ctx->NewState)
>>> -      _mesa_update_state(ctx);
>>> -
>>> -   if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
>>> -      _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
>>> -                  "glAccum(incomplete framebuffer)");
>>> -      return;
>>> -   }
>>> -
>>> -   if (ctx->RasterDiscard)
>>> -      return;
>>> -
>>> -   if (ctx->RenderMode == GL_RENDER) {
>>> -      _mesa_accum(ctx, op, value);
>>> -   }
>>> -}
>>> -
>>> -
>>>   /**
>>>    * Clear the accumulation buffer by mapping the renderbuffer and
>>>    * writing the clear color to it.  Called by the driver's 
>>> implementation
>>>    * of the glClear function.
>>>    */
>>>   void
>>>   _mesa_clear_accum_buffer(struct gl_context *ctx)
>>>   {
>>>      GLuint x, y, width, height;
>>>      GLubyte *accMap;
>>> @@ -429,21 +378,21 @@ accum_return(struct gl_context *ctx, GLfloat 
>>> value,
>>>      ctx->Driver.UnmapRenderbuffer(ctx, accRb);
>>>   }
>>>   /**
>>>    * Software fallback for glAccum.  A hardware driver that supports
>>>    * signed 16-bit color channels could implement hardware accumulation
>>>    * operations, but no driver does so at this time.
>>>    */
>>> -void
>>> +static void
>>>   _mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value)
>>>   {
>>>      GLint xpos, ypos, width, height;
>>>      if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) {
>>>         _mesa_warning(ctx, "Calling glAccum() without an accumulation 
>>> buffer");
>>>         return;
>>>      }
>>>      if (!_mesa_check_conditional_render(ctx))
>>> @@ -482,10 +431,61 @@ _mesa_accum(struct gl_context *ctx, GLenum op, 
>>> GLfloat value)
>>>      }
>>>   }
>>>   void
>>>   _mesa_init_accum( struct gl_context *ctx )
>>>   {
>>>      /* Accumulate buffer group */
>>>      ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 );
>>>   }
>>> +
>>> +
>>> +void GLAPIENTRY
>>> +_mesa_Accum( GLenum op, GLfloat value )
>>> +{
>>> +   GET_CURRENT_CONTEXT(ctx);
>>> +   FLUSH_VERTICES(ctx, 0);
>>> +
>>> +   switch (op) {
>>> +   case GL_ADD:
>>> +   case GL_MULT:
>>> +   case GL_ACCUM:
>>> +   case GL_LOAD:
>>> +   case GL_RETURN:
>>> +      /* OK */
>>> +      break;
>>> +   default:
>>> +      _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)");
>>> +      return;
>>> +   }
>>> +
>>> +   if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) {
>>> +      _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum 
>>> buffer)");
>>> +      return;
>>> +   }
>>> +
>>> +   if (ctx->DrawBuffer != ctx->ReadBuffer) {
>>> +      /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read,
>>> +       * or GL_EXT_framebuffer_blit.
>>> +       */
>>> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>>> +                  "glAccum(different read/draw buffers)");
>>> +      return;
>>> +   }
>>> +
>>> +   if (ctx->NewState)
>>> +      _mesa_update_state(ctx);
>>> +
>>> +   if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
>>> +      _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
>>> +                  "glAccum(incomplete framebuffer)");
>>> +      return;
>>> +   }
>>> +
>>> +   if (ctx->RasterDiscard)
>>> +      return;
>>> +
>>> +   if (ctx->RenderMode == GL_RENDER) {
>>> +      _mesa_accum(ctx, op, value);
>>> +   }
>>> +}
>>> diff --git a/src/mesa/main/accum.h b/src/mesa/main/accum.h
>>> index ede2ecc..fe253a2 100644
>>> --- a/src/mesa/main/accum.h
>>> +++ b/src/mesa/main/accum.h
>>> @@ -40,19 +40,16 @@
>>>   #include "main/glheader.h"
>>>   struct gl_context;
>>>   extern void GLAPIENTRY
>>>   _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat 
>>> alpha );
>>>   void GLAPIENTRY
>>>   _mesa_Accum( GLenum op, GLfloat value );
>>>   extern void
>>> -_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value);
>>> -
>>> -extern void
>>>   _mesa_clear_accum_buffer(struct gl_context *ctx);
>>>   extern void
>>>   _mesa_init_accum( struct gl_context *ctx );
>>>   #endif /* ACCUM_H */
>>>


More information about the mesa-dev mailing list