[Mesa-dev] [PATCH 3/3] dri3: Add GLX_EXT_buffer_age support

Adel Gadllah adel.gadllah at gmail.com
Tue Feb 25 03:38:34 PST 2014


Am 24.02.2014 19:37, schrieb Eric Anholt:
> Adel Gadllah <adel.gadllah at gmail.com> writes:
>
>> ---
>>   src/glx/dri2_glx.c      |  1 +
>>   src/glx/dri3_glx.c      | 18 ++++++++++++++++++
>>   src/glx/dri3_priv.h     |  2 ++
>>   src/glx/glx_pbuffer.c   |  8 ++++++++
>>   src/glx/glxclient.h     |  1 +
>>   src/glx/glxextensions.c |  1 +
>>   src/glx/glxextensions.h |  1 +
>>   7 files changed, 32 insertions(+)
>>
>> diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
>> index 67fe9c1..146802a 100644
>> --- a/src/glx/dri2_glx.c
>> +++ b/src/glx/dri2_glx.c
>> @@ -1288,6 +1288,7 @@ dri2CreateScreen(int screen, struct glx_display * priv)
>>      psp->waitForSBC = NULL;
>>      psp->setSwapInterval = NULL;
>>      psp->getSwapInterval = NULL;
>> +   psp->getBufferAge = NULL;
>>   
>>      if (pdp->driMinor >= 2) {
>>         psp->getDrawableMSC = dri2DrawableGetMSC;
>> diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
>> index 70ec057..697d448 100644
>> --- a/src/glx/dri3_glx.c
>> +++ b/src/glx/dri3_glx.c
>> @@ -1345,6 +1345,7 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
>>            target_msc = priv->msc + priv->swap_interval * (priv->send_sbc - priv->recv_sbc);
>>   
>>         priv->buffers[buf_id]->busy = 1;
>> +      priv->buffers[buf_id]->last_swap = priv->swap_count;
>>         xcb_present_pixmap(c,
>>                            priv->base.xDrawable,
>>                            priv->buffers[buf_id]->pixmap,
>> @@ -1379,11 +1380,25 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
>>         xcb_flush(c);
>>         if (priv->stamp)
>>            ++(*priv->stamp);
>> +
>> +      priv->swap_count++;
>>      }
> Can't you just use priv->send_sbc for swap_count?
I could but then would introduce what you describe below.
> It looks like you've
> got the order swapped of the two operations currently:
>
>             "* The current back buffer's age is set to 1.
>              * Any other color buffers' ages are incremented by 1 if
>                their age was previously greater than 0."
>
> As is, when an application gets the buffer from the first swap back, it
> will get a 0 (invalid) age instead of a valid age.
I don't get what you mean by swapped. If you mean increment swap count and then assign to last_swap then no. If I do 
that the age will always be 0.

To avoid the case where last_swap is 0 even though it should be valid ... could simply initialize swap_count to 1.






More information about the mesa-dev mailing list