[Mesa-dev] [RFC] st/mesa: Add both front and back buffers for double-buffer visuals

Boyan Ding boyan.j.ding at gmail.com
Wed Jan 18 01:25:58 UTC 2017


2017-01-18 1:31 GMT+08:00 Brian Paul <brianp at vmware.com>:
> On 01/17/2017 06:44 AM, Boyan Ding wrote:
>>
>> st will only add back buffer attachment to window framebuffer when
>> visual is in double-buffer mode. However, some applications may
>> render to front buffer even if they have chosen a double-buffer visual.
>> In this case, no color buffer will be attached when rendering. i965
>> handles this case correctly, in which it adds both front and back buffer
>> attachments. Do the same thing in st.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99116
>> Signed-off-by: Boyan Ding <boyan.j.ding at gmail.com>
>> ---
>>   src/mesa/state_tracker/st_manager.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/mesa/state_tracker/st_manager.c
>> b/src/mesa/state_tracker/st_manager.c
>> index c3d8286b5a..aa53edfecb 100644
>> --- a/src/mesa/state_tracker/st_manager.c
>> +++ b/src/mesa/state_tracker/st_manager.c
>> @@ -417,7 +417,6 @@ st_framebuffer_create(struct st_context *st,
>>   {
>>      struct st_framebuffer *stfb;
>>      struct gl_config mode;
>> -   gl_buffer_index idx;
>>
>>      if (!stfbi)
>>         return NULL;
>> @@ -466,11 +465,12 @@ st_framebuffer_create(struct st_context *st,
>>      stfb->iface_stamp = p_atomic_read(&stfbi->stamp) - 1;
>>
>>      /* add the color buffer */
>> -   idx = stfb->Base._ColorDrawBufferIndexes[0];
>> -   if (!st_framebuffer_add_renderbuffer(stfb, idx)) {
>> +   if (!st_framebuffer_add_renderbuffer(stfb, BUFFER_FRONT_LEFT)) {
>>         free(stfb);
>>         return NULL;
>>      }
>> +   if (mode.doubleBufferMode)
>> +      st_framebuffer_add_renderbuffer(stfb, BUFFER_BACK_LEFT);
>>
>>      st_framebuffer_add_renderbuffer(stfb, BUFFER_DEPTH);
>>      st_framebuffer_add_renderbuffer(stfb, BUFFER_ACCUM);
>>
>
>
> I believe we have code in the state tracker to allocate the front buffer on
> demand when the app actually tries to draw to it.  Can you look into that?
>
> -Brian
>

Hi,

I don't think I find that. The only place in state tracker where
_mesa_add_renderbuffer is called is st_framebuffer_create and only one
of the front and back buffers is allocated based on the default
behavior. When update_framebuffer_state() in state tracker is called
after draw buffer changes to front, state tracker will find it refers
to a null renderbuffer and remove it afterwards.

So the reasonable way is to allocate the front buffer in
update_framebuffer_state when front buffer is the draw buffer but not
allocated?

Regards,
Boyan Ding


More information about the mesa-dev mailing list