lib: Implement gem_sync() using WAIT

When synchronising to rendering, we only want to wait for it to complete
and avoid the cache-domain side-effects of SET_DOMAIN if possible. This
has the advantage of speeding up a few tests (and thereby making the
actual test more explicit in terms of kernel operations). Of course some
tests may be reliant on the side-effects...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Chris Wilson 2015-04-13 11:54:18 +01:00
parent 9fd6e07369
commit 41fe1d1a44

View File

@ -371,12 +371,22 @@ void gem_set_domain(int fd, uint32_t handle,
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
*
* This is a wrapper around gem_set_domain() which simply blocks for any
* outstanding rendering to complete.
* This functions waits for outstanding rendering to complete.
*/
void gem_sync(int fd, uint32_t handle)
{
gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
struct drm_i915_gem_wait wait;
memset(&wait, 0, sizeof(wait));
wait.bo_handle = handle;
wait.timeout_ns =-1;
if (drmIoctl(fd, DRM_IOCTL_I915_GEM_WAIT, &wait) == 0) {
errno = 0;
return;
}
gem_set_domain(fd, handle,
I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
}
uint32_t __gem_create(int fd, int size)