Present: add PresentCapabilitySyncobj and PresentPixmapSynced

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/967>
This commit is contained in:
Erik Kurzinger
2024-03-18 11:33:15 -07:00
committed by Olivier Fourdan
parent 0a7b09a041
commit ac0bc0b3b6
11 changed files with 332 additions and 41 deletions

View File

@@ -79,79 +79,123 @@ proc_present_query_version(ClientPtr client)
} while (0)
static int
proc_present_pixmap(ClientPtr client)
proc_present_pixmap_common(ClientPtr client,
Window req_window,
Pixmap req_pixmap,
CARD32 req_serial,
CARD32 req_valid,
CARD32 req_update,
INT16 req_x_off,
INT16 req_y_off,
CARD32 req_target_crtc,
XSyncFence req_wait_fence,
XSyncFence req_idle_fence,
#ifdef DRI3
struct dri3_syncobj *acquire_syncobj,
struct dri3_syncobj *release_syncobj,
CARD64 req_acquire_point,
CARD64 req_release_point,
#endif /* DRI3 */
CARD32 req_options,
CARD64 req_target_msc,
CARD64 req_divisor,
CARD64 req_remainder,
size_t base_req_size,
xPresentNotify *req_notifies)
{
REQUEST(xPresentPixmapReq);
WindowPtr window;
PixmapPtr pixmap;
RegionPtr valid = NULL;
RegionPtr update = NULL;
SyncFence *wait_fence;
SyncFence *idle_fence;
RRCrtcPtr target_crtc;
int ret;
int nnotifies;
present_notify_ptr notifies = NULL;
WindowPtr window;
PixmapPtr pixmap;
RegionPtr valid = NULL;
RegionPtr update = NULL;
RRCrtcPtr target_crtc;
SyncFence *wait_fence;
SyncFence *idle_fence;
int nnotifies;
present_notify_ptr notifies = NULL;
int ret;
REQUEST_AT_LEAST_SIZE(xPresentPixmapReq);
ret = dixLookupWindow(&window, stuff->window, client, DixWriteAccess);
ret = dixLookupWindow(&window, req_window, client, DixWriteAccess);
if (ret != Success)
return ret;
ret = dixLookupResourceByType((void **) &pixmap, stuff->pixmap, RT_PIXMAP, client, DixReadAccess);
ret = dixLookupResourceByType((void **) &pixmap, req_pixmap, RT_PIXMAP, client, DixReadAccess);
if (ret != Success)
return ret;
if (window->drawable.depth != pixmap->drawable.depth)
return BadMatch;
VERIFY_REGION_OR_NONE(valid, stuff->valid, client, DixReadAccess);
VERIFY_REGION_OR_NONE(update, stuff->update, client, DixReadAccess);
VERIFY_REGION_OR_NONE(valid, req_valid, client, DixReadAccess);
VERIFY_REGION_OR_NONE(update, req_update, client, DixReadAccess);
VERIFY_CRTC_OR_NONE(target_crtc, stuff->target_crtc, client, DixReadAccess);
VERIFY_CRTC_OR_NONE(target_crtc, req_target_crtc, client, DixReadAccess);
VERIFY_FENCE_OR_NONE(wait_fence, stuff->wait_fence, client, DixReadAccess);
VERIFY_FENCE_OR_NONE(idle_fence, stuff->idle_fence, client, DixWriteAccess);
VERIFY_FENCE_OR_NONE(wait_fence, req_wait_fence, client, DixReadAccess);
VERIFY_FENCE_OR_NONE(idle_fence, req_idle_fence, client, DixWriteAccess);
if (stuff->options & ~(PresentAllOptions)) {
client->errorValue = stuff->options;
if (req_options & ~(PresentAllOptions)) {
client->errorValue = req_options;
return BadValue;
}
/*
* Check to see if remainder is sane
*/
if (stuff->divisor == 0) {
if (stuff->remainder != 0) {
client->errorValue = (CARD32) stuff->remainder;
if (req_divisor == 0) {
if (req_remainder != 0) {
client->errorValue = (CARD32)req_remainder;
return BadValue;
}
} else {
if (stuff->remainder >= stuff->divisor) {
client->errorValue = (CARD32) stuff->remainder;
if (req_remainder >= req_divisor) {
client->errorValue = (CARD32)req_remainder;
return BadValue;
}
}
nnotifies = (client->req_len << 2) - sizeof (xPresentPixmapReq);
nnotifies = (client->req_len << 2) - base_req_size;
if (nnotifies % sizeof (xPresentNotify))
return BadLength;
nnotifies /= sizeof (xPresentNotify);
if (nnotifies) {
ret = present_create_notifies(client, nnotifies, (xPresentNotify *) (stuff + 1), &notifies);
ret = present_create_notifies(client, nnotifies, req_notifies, &notifies);
if (ret != Success)
return ret;
}
ret = present_pixmap(window, pixmap, stuff->serial, valid, update,
stuff->x_off, stuff->y_off, target_crtc,
wait_fence, idle_fence, stuff->options,
stuff->target_msc, stuff->divisor, stuff->remainder, notifies, nnotifies);
ret = present_pixmap(window, pixmap, req_serial,
valid, update, req_x_off, req_y_off, target_crtc,
wait_fence, idle_fence,
#ifdef DRI3
acquire_syncobj, release_syncobj,
req_acquire_point, req_release_point,
#endif /* DRI3 */
req_options, req_target_msc, req_divisor, req_remainder,
notifies, nnotifies);
if (ret != Success)
present_destroy_notifies(notifies, nnotifies);
return ret;
}
static int
proc_present_pixmap(ClientPtr client)
{
REQUEST(xPresentPixmapReq);
REQUEST_AT_LEAST_SIZE(xPresentPixmapReq);
return proc_present_pixmap_common(client, stuff->window, stuff->pixmap, stuff->serial,
stuff->valid, stuff->update, stuff->x_off, stuff->y_off,
stuff->target_crtc,
stuff->wait_fence, stuff->idle_fence,
#ifdef DRI3
None, None, 0, 0,
#endif /* DRI3 */
stuff->options, stuff->target_msc,
stuff->divisor, stuff->remainder,
sizeof (xPresentPixmapReq),
(xPresentNotify *)(stuff + 1));
}
static int
proc_present_notify_msc(ClientPtr client)
{
@@ -240,12 +284,45 @@ proc_present_query_capabilities (ClientPtr client)
return Success;
}
#ifdef DRI3
static int
proc_present_pixmap_synced (ClientPtr client)
{
REQUEST(xPresentPixmapSyncedReq);
struct dri3_syncobj *acquire_syncobj;
struct dri3_syncobj *release_syncobj;
REQUEST_AT_LEAST_SIZE(xPresentPixmapSyncedReq);
VERIFY_DRI3_SYNCOBJ(stuff->acquire_syncobj, acquire_syncobj, DixWriteAccess);
VERIFY_DRI3_SYNCOBJ(stuff->release_syncobj, release_syncobj, DixWriteAccess);
if (stuff->acquire_point == 0 || stuff->release_point == 0 ||
(stuff->acquire_syncobj == stuff->release_syncobj &&
stuff->acquire_point >= stuff->release_point))
return BadValue;
return proc_present_pixmap_common(client, stuff->window, stuff->pixmap, stuff->serial,
stuff->valid, stuff->update, stuff->x_off, stuff->y_off,
stuff->target_crtc,
None, None,
acquire_syncobj, release_syncobj,
stuff->acquire_point, stuff->release_point,
stuff->options, stuff->target_msc,
stuff->divisor, stuff->remainder,
sizeof (xPresentPixmapSyncedReq),
(xPresentNotify *)(stuff + 1));
}
#endif /* DRI3 */
static int (*proc_present_vector[PresentNumberRequests]) (ClientPtr) = {
proc_present_query_version, /* 0 */
proc_present_pixmap, /* 1 */
proc_present_notify_msc, /* 2 */
proc_present_select_input, /* 3 */
proc_present_query_capabilities, /* 4 */
#ifdef DRI3
proc_present_pixmap_synced, /* 5 */
#endif /* DRI3 */
};
int
@@ -325,12 +402,51 @@ sproc_present_query_capabilities (ClientPtr client)
return (*proc_present_vector[stuff->presentReqType]) (client);
}
#ifdef DRI3
static int _X_COLD
sproc_present_pixmap_synced(ClientPtr client)
{
REQUEST(xPresentPixmapSyncedReq);
REQUEST_AT_LEAST_SIZE(xPresentPixmapSyncedReq);
swaps(&stuff->length);
swapl(&stuff->window);
swapl(&stuff->pixmap);
swapl(&stuff->serial);
swapl(&stuff->valid);
swapl(&stuff->update);
swaps(&stuff->x_off);
swaps(&stuff->y_off);
swapl(&stuff->target_crtc);
swapl(&stuff->acquire_syncobj);
swapl(&stuff->release_syncobj);
swapll(&stuff->acquire_point);
swapll(&stuff->release_point);
swapl(&stuff->options);
swapll(&stuff->target_msc);
swapll(&stuff->divisor);
swapll(&stuff->remainder);
return (*proc_present_vector[stuff->presentReqType]) (client);
}
#endif /* DRI3 */
static int (*sproc_present_vector[PresentNumberRequests]) (ClientPtr) = {
sproc_present_query_version, /* 0 */
sproc_present_pixmap, /* 1 */
sproc_present_notify_msc, /* 2 */
sproc_present_select_input, /* 3 */
sproc_present_query_capabilities, /* 4 */
#ifdef DRI3
sproc_present_pixmap_synced, /* 5 */
#endif /* DRI3 */
};
int _X_COLD