diff options
author | Daniel Stone <[email protected]> | 2019-08-12 12:07:07 +0200 |
---|---|---|
committer | Boris Brezillon <[email protected]> | 2019-08-13 14:40:45 +0200 |
commit | 492ffbed63a2a62759224b1c7d45aa7923d8f542 (patch) | |
tree | a51864e171abb882032fa318262fe39f6e22469a /src/gallium/state_trackers | |
parent | a4a8ebe156bcb690afecdaa44efd6dcf8f0c1de2 (diff) |
st/dri2: Implement DRI2bufferDamageExtension
Add a pipe_screen->set_damage_region() hook to propagate
set-damage-region requests to the driver, it's then up to the driver to
decide what to do with this piece of information.
If the hook is left unassigned, the buffer-damage extension is
considered unsupported.
Signed-off-by: Daniel Stone <[email protected]>
Signed-off-by: Boris Brezillon <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Qiang Yu <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/dri/dri2.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 45fbd0340f5..2b43de9df5d 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -1848,6 +1848,36 @@ static const __DRI2interopExtension dri2InteropExtension = { }; /** + * \brief the DRI2bufferDamageExtension set_damage_region method + */ +static void +dri2_set_damage_region(__DRIdrawable *dPriv, unsigned int nrects, int *rects) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + struct pipe_resource *resource = drawable->textures[ST_ATTACHMENT_BACK_LEFT]; + struct pipe_screen *screen = resource->screen; + struct pipe_box *boxes = NULL; + + if (nrects) { + boxes = CALLOC(nrects, sizeof(*boxes)); + assert(boxes); + + for (unsigned int i = 0; i < nrects; i++) { + int *rect = &rects[i * 4]; + + u_box_2d(rect[0], rect[1], rect[2], rect[3], &boxes[i]); + } + } + + screen->set_damage_region(screen, resource, nrects, boxes); + FREE(boxes); +} + +static __DRI2bufferDamageExtension dri2BufferDamageExtension = { + .base = { __DRI2_BUFFER_DAMAGE, 1 }, +}; + +/** * \brief the DRI2ConfigQueryExtension configQueryb method */ static int @@ -1948,6 +1978,7 @@ static const __DRIextension *dri_screen_extensions[] = { &dri2GalliumConfigQueryExtension.base, &dri2ThrottleExtension.base, &dri2FenceExtension.base, + &dri2BufferDamageExtension.base, &dri2InteropExtension.base, &dri2NoErrorExtension.base, &driBlobExtension.base, @@ -1963,6 +1994,7 @@ static const __DRIextension *dri_robust_screen_extensions[] = { &dri2ThrottleExtension.base, &dri2FenceExtension.base, &dri2InteropExtension.base, + &dri2BufferDamageExtension.base, &dri2Robustness.base, &dri2NoErrorExtension.base, &driBlobExtension.base, @@ -2025,6 +2057,9 @@ dri2_init_screen(__DRIscreen * sPriv) } } + if (pscreen->set_damage_region) + dri2BufferDamageExtension.set_damage_region = dri2_set_damage_region; + if (pscreen->get_param(pscreen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) { sPriv->extensions = dri_robust_screen_extensions; screen->has_reset_status_query = true; |