summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/dri/dri2.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-10-09 18:56:22 +0200
committerMarek Olšák <[email protected]>2017-10-12 19:03:33 +0200
commit255573996cc997cb61be9adad3e8fcaa78db5d1f (patch)
tree5d4d27780c08cc979e62103c227aac3e128314a7 /src/gallium/state_trackers/dri/dri2.c
parent07fdc0a09cd8f7af8231c4bede158588c6649ce4 (diff)
st/dri: implement __DRIimageExtension::validateUsage properly
Reviewed-by: Daniel Stone <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/dri/dri2.c')
-rw-r--r--src/gallium/state_trackers/dri/dri2.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 324e357c358..38e68069f44 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1272,15 +1272,29 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate)
static GLboolean
dri2_validate_usage(__DRIimage *image, unsigned int use)
{
- /*
- * Gallium drivers are bad at adding usages to the resources
- * once opened again in another process, which is the main use
- * case for this, so we have to lie.
+ if (!image || !image->texture)
+ return false;
+
+ struct pipe_screen *screen = image->texture->screen;
+ if (!screen->check_resource_capability)
+ return true;
+
+ /* We don't want to check these:
+ * __DRI_IMAGE_USE_SHARE (all images are shareable)
+ * __DRI_IMAGE_USE_BACKBUFFER (all images support this)
*/
- if (image != NULL)
- return GL_TRUE;
- else
- return GL_FALSE;
+ unsigned bind = 0;
+ if (use & __DRI_IMAGE_USE_SCANOUT)
+ bind |= PIPE_BIND_SCANOUT;
+ if (use & __DRI_IMAGE_USE_LINEAR)
+ bind |= PIPE_BIND_LINEAR;
+ if (use & __DRI_IMAGE_USE_CURSOR)
+ bind |= PIPE_BIND_CURSOR;
+
+ if (!bind)
+ return true;
+
+ return screen->check_resource_capability(screen, image->texture, bind);
}
static __DRIimage *