[Mesa-dev] [PATCH 5/5] dri3: Use SwapBuffer flips for back- and fake front
Thomas Hellstrom
thellstrom at vmware.com
Wed Jun 28 18:40:16 UTC 2017
On 06/28/2017 07:36 PM, Axel Davy wrote:
> Hi,
>
> To my knowledge, this is invalid to switch the front fake buffer with
> the back buffer.
>
> The front buffer is supposed to take into account what the app draws
> with the xserver commands, etc.
SwapBuffers should bring the contents of the back buffer to the front
(and fake front if applicable) buffer, and the backbuffer contents
become undefined, or tagged with a certain age. None of this is violated
here. The old back buffer will become the new fake front and
appropriately synced with X rendering as needed.
Is there a specific scenario you are concerned with?
>
> Plus, if there is draw->width and back->width, I guess they can be
> different size, thus switching may be incorrect relative to buffer
> size too.
Fake front and back are resized at the same time with dri3 AFAICT. This
means that with respect to dimensions, the new code should be equivalent
to the old one.
>
> Yours,
>
> Axel Davy
Thanks,
Thomas
>
> On 22/06/2017 12:42, Thomas Hellstrom wrote:
>> Use flips for back- and fake front buffers.
>> This might lead to fake front and real front being shared if the
>> hardware
>> is page-flip capable.
>>
>> In any case it will save a full-drawable copy and also the subsequent
>> wait for
>> the X server to submit that copy to hardware if front-buffer reading or
>> rendering is enabled.
>>
>> Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
>> ---
>> src/loader/loader_dri3_helper.c | 26 ++++++++------------------
>> 1 file changed, 8 insertions(+), 18 deletions(-)
>>
>> diff --git a/src/loader/loader_dri3_helper.c
>> b/src/loader/loader_dri3_helper.c
>> index f012e55..041bfc4 100644
>> --- a/src/loader/loader_dri3_helper.c
>> +++ b/src/loader/loader_dri3_helper.c
>> @@ -652,14 +652,14 @@ loader_dri3_swap_buffers_msc(struct
>> loader_dri3_drawable *draw,
>> back->height,
>> 0, 0, back->width,
>> back->height, __BLIT_FLAG_FLUSH);
>> - /* Update the fake front */
>> - if (draw->have_fake_front)
>> - draw->ext->image->blitImage(dri_context,
>> - draw->buffers[LOADER_DRI3_FRONT_ID]->image,
>> - back->image,
>> - 0, 0, draw->width, draw->height,
>> - 0, 0, draw->width, draw->height,
>> - __BLIT_FLAG_FLUSH);
>> + }
>> +
>> + if (back && draw->have_fake_front) {
>> + struct loader_dri3_buffer *tmp;
>> +
>> + tmp = dri3_fake_front_buffer(draw);
>> + draw->buffers[LOADER_DRI3_FRONT_ID] = back;
>> + draw->buffers[LOADER_DRI3_BACK_ID(draw->cur_back)] = tmp;
>> }
>> dri3_flush_present_events(draw);
>> @@ -727,16 +727,6 @@ loader_dri3_swap_buffers_msc(struct
>> loader_dri3_drawable *draw,
>> * to reset the fence and make future users block until
>> * the X server is done copying the bits
>> */
>> - if (draw->have_fake_front && !draw->is_different_gpu) {
>> - dri3_fence_reset(draw->conn,
>> draw->buffers[LOADER_DRI3_FRONT_ID]);
>> - dri3_copy_area(draw->conn,
>> - back->pixmap,
>> - draw->buffers[LOADER_DRI3_FRONT_ID]->pixmap,
>> - dri3_drawable_gc(draw),
>> - 0, 0, 0, 0,
>> - draw->width, draw->height);
>> - dri3_fence_trigger(draw->conn,
>> draw->buffers[LOADER_DRI3_FRONT_ID]);
>> - }
>> xcb_flush(draw->conn);
>> if (draw->stamp)
>> ++(*draw->stamp);
>
>
More information about the mesa-dev
mailing list