[Mesa-dev] [PATCH v6 4/5] loader/dri3: Enable adaptive_sync via _VARIABLE_REFRESH property
Kazlauskas, Nicholas
Nicholas.Kazlauskas at amd.com
Fri Oct 19 16:52:17 UTC 2018
On 10/19/2018 12:49 PM, Michel Dänzer wrote:
> On 2018-10-19 6:41 p.m., Nicholas Kazlauskas wrote:
>> The DDX driver can be notified of adaptive sync suitability by
>> flagging the application's window with the _VARIABLE_REFRESH property.
>>
>> This property is set on the first swap the application performs
>> when adaptive_sync is set to true in the drirc.
>>
>> It's performed here instead of when the loader is initialized for
>> two reasons:
>>
>> (1) The window's drawable can be missing during loader init.
>> This can be observed during the Unigine Superposition benchmark.
>>
>> (2) Adaptive sync will only be enabled closer to when the application
>> actually begins rendering.
>>
>> If adaptive_sync is false then the _VARIABLE_REFRESH property
>> is deleted on loader init.
>>
>> The property is only managed on the glx DRI3 backend for now. This
>> should cover most common applications and games on modern hardware.
>>
>> Vulkan support can be implemented in a similar manner but would likely
>> require splitting the function out into a common helper function.
>>
>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
>>
>> [...]
>>
>> @@ -318,6 +344,7 @@ loader_dri3_drawable_init(xcb_connection_t *conn,
>> xcb_get_geometry_reply_t *reply;
>> xcb_generic_error_t *error;
>> GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
>> + unsigned char adaptive_sync;
>> int swap_interval;
>>
>> draw->conn = conn;
>> @@ -331,16 +358,28 @@ loader_dri3_drawable_init(xcb_connection_t *conn,
>> draw->have_back = 0;
>> draw->have_fake_front = 0;
>> draw->first_init = true;
>> + draw->adaptive_sync = false;
>> + draw->adaptive_sync_active = false;
>>
>> draw->cur_blit_source = -1;
>> draw->back_format = __DRI_IMAGE_FORMAT_NONE;
>> mtx_init(&draw->mtx, mtx_plain);
>> cnd_init(&draw->event_cnd);
>>
>> - if (draw->ext->config)
>> + if (draw->ext->config) {
>> draw->ext->config->configQueryi(draw->dri_screen,
>> "vblank_mode", &vblank_mode);
>>
>> + draw->ext->config->configQueryb(draw->dri_screen,
>> + "adaptive_sync",
>> + &adaptive_sync);
>> +
>> + draw->adaptive_sync = adaptive_sync;
>> + }
>> +
>> + if (!adaptive_sync)
>> + set_adaptive_sync_property(conn, draw->drawable, false);
>
> If !draw->ext->config, the local variable adaptive_sync is uninitialized
> here. There are multiple ways to solve this, but I think the cleanest
> might be to move its definition inside the block, and test
> draw->adaptive_sync outside of it.
>
>
Not sure how I missed this. Guess it got lost with the other warnings
when building.
Thanks.
Nicholas Kazlauskas
More information about the mesa-dev
mailing list