intel/context: new execbuf interface for contexts
authorBen Widawsky <ben@bwidawsk.net>
Mon, 19 Mar 2012 01:28:28 +0000 (18:28 -0700)
committerBen Widawsky <ben@bwidawsk.net>
Wed, 27 Jun 2012 16:57:17 +0000 (09:57 -0700)
To support this we extract the common execbuf2 functionality to be
called with, or without contexts.

The context'd execbuf does not support some of the dri1 stuff.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
intel/intel_bufmgr.h
intel/intel_bufmgr_gem.c

index fedffb584abe4b61a3a8709d46d76c1df9c3f375..9b3a483f3c459f3a3ebbf2d0c5227731f28ca9c0 100644 (file)
@@ -187,6 +187,11 @@ int drm_intel_get_aperture_sizes(int fd, size_t *mappable, size_t *total);
 int drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr);
 int drm_intel_gem_bo_wait(drm_intel_bo *bo, int64_t timeout_ns);
 
+drm_intel_context *drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr);
+void drm_intel_gem_context_destroy(drm_intel_context *ctx);
+int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx,
+                                 int used, unsigned int flags);
+
 /* drm_intel_bufmgr_fake.c */
 drm_intel_bufmgr *drm_intel_bufmgr_fake_init(int fd,
                                             unsigned long low_offset,
index e90f8bdbe6097e36b326b999706c2300eada98c0..485308b534fa6b7a30a4feb760bd73e2becd09c0 100644 (file)
@@ -2187,9 +2187,9 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used,
 }
 
 static int
-drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
-                       drm_clip_rect_t *cliprects, int num_cliprects, int DR4,
-                       unsigned int flags)
+do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx,
+        drm_clip_rect_t *cliprects, int num_cliprects, int DR4,
+        unsigned int flags)
 {
        drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
        struct drm_i915_gem_execbuffer2 execbuf;
@@ -2231,7 +2231,10 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
        execbuf.DR1 = 0;
        execbuf.DR4 = DR4;
        execbuf.flags = flags;
-       execbuf.rsvd1 = 0;
+       if (ctx == NULL)
+               i915_execbuffer2_set_context_id(execbuf, 0);
+       else
+               i915_execbuffer2_set_context_id(execbuf, ctx->ctx_id);
        execbuf.rsvd2 = 0;
 
        aub_exec(bo, flags, used);
@@ -2279,9 +2282,24 @@ drm_intel_gem_bo_exec2(drm_intel_bo *bo, int used,
                       drm_clip_rect_t *cliprects, int num_cliprects,
                       int DR4)
 {
-       return drm_intel_gem_bo_mrb_exec2(bo, used,
-                                       cliprects, num_cliprects, DR4,
-                                       I915_EXEC_RENDER);
+       return do_exec2(bo, used, NULL, cliprects, num_cliprects, DR4,
+                       I915_EXEC_RENDER);
+}
+
+static int
+drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
+                       drm_clip_rect_t *cliprects, int num_cliprects, int DR4,
+                       unsigned int flags)
+{
+       return do_exec2(bo, used, NULL, cliprects, num_cliprects, DR4,
+                       flags);
+}
+
+int
+drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx,
+                             int used, unsigned int flags)
+{
+       return do_exec2(bo, used, ctx, NULL, 0, 0, flags);
 }
 
 static int