[Mesa-dev] [PATCH] mesa/program: split reference program into hot/cold paths.

Dave Airlie airlied at gmail.com
Wed Jul 13 11:04:35 PDT 2011


On Wed, Jul 13, 2011 at 4:53 PM, Brian Paul <brian.e.paul at gmail.com> wrote:
> On Fri, Jun 24, 2011 at 7:20 AM, Brian Paul <brianp at vmware.com> wrote:
>> On 06/23/2011 11:22 PM, Dave Airlie wrote:
>>>
>>> From: Dave Airlie<airlied at redhat.com>
>>>
>>> inline the hotpath of the reference remaining the same, this shouldn't
>>> penalise the slow path at all but improve the hot path so we don't have
>>> to jump to the function.
>>>
>>> It also moves some assert checks under an #ifndef NDEBUG.
>>>
>>> Signed-off-by: Dave Airlie<airlied at redhat.com>
>>> ---
>>>  src/mesa/program/program.c |    8 ++++----
>>>  src/mesa/program/program.h |   12 +++++++++++-
>>>  2 files changed, 15 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
>>> index 78efca9..b419058 100644
>>> --- a/src/mesa/program/program.c
>>> +++ b/src/mesa/program/program.c
>>> @@ -423,10 +423,11 @@ _mesa_lookup_program(struct gl_context *ctx, GLuint
>>> id)
>>>   * Reference counting for vertex/fragment programs
>>>   */
>>>  void
>>> -_mesa_reference_program(struct gl_context *ctx,
>>> +__mesa_reference_program(struct gl_context *ctx,
>>>                          struct gl_program **ptr,
>>>                          struct gl_program *prog)
>>>  {
>>> +#ifndef NDEBUG
>>>     assert(ptr);
>>>     if (*ptr&&  prog) {
>>>        /* sanity check */
>>> @@ -438,9 +439,8 @@ _mesa_reference_program(struct gl_context *ctx,
>>>        else if ((*ptr)->Target == MESA_GEOMETRY_PROGRAM)
>>>           ASSERT(prog->Target == MESA_GEOMETRY_PROGRAM);
>>>     }
>>> -   if (*ptr == prog) {
>>> -      return;  /* no change */
>>> -   }
>>> +#endif
>>> +
>>>     if (*ptr) {
>>>        GLboolean deleteFlag;
>>>
>>> diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
>>> index ce37b95..c093afa 100644
>>> --- a/src/mesa/program/program.h
>>> +++ b/src/mesa/program/program.h
>>> @@ -89,11 +89,21 @@ extern struct gl_program *
>>>  _mesa_lookup_program(struct gl_context *ctx, GLuint id);
>>>
>>>  extern void
>>> -_mesa_reference_program(struct gl_context *ctx,
>>> +__mesa_reference_program(struct gl_context *ctx,
>>>                          struct gl_program **ptr,
>>>                          struct gl_program *prog);
>>>
>>>  static INLINE void
>>> +_mesa_reference_program(struct gl_context *ctx,
>>> +                        struct gl_program **ptr,
>>> +                        struct gl_program *prog)
>>> +{
>>> +   if (*ptr == prog)
>>> +     return;
>>> +   __mesa_reference_program(ctx, ptr, prog);
>>> +}
>>
>> How about:
>>
>> if (*ptr != prog)
>>   __mesa_reference_program(ctx, ptr, prog);
>>
>>
>> Otherwise, Reviewed-by: Brian Paul <brianp at vmware.com>
>
> Dave, were you going to commit this patch?
>

I'm on holidays/moving around the world, so its sitting on my laptop
here, probably get to it once I start back to work.

Dave.


More information about the mesa-dev mailing list