ilo: require hardware logical context support
authorChia-I Wu <olvaffe@gmail.com>
Mon, 10 Mar 2014 04:31:30 +0000 (12:31 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 10 Mar 2014 08:42:42 +0000 (16:42 +0800)
The code paths are not tested for a while, and have some known issues.

src/gallium/drivers/ilo/ilo_3d.c
src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
src/gallium/drivers/ilo/ilo_common.h
src/gallium/drivers/ilo/ilo_cp.c
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/winsys/intel/drm/intel_drm_winsys.c
src/gallium/winsys/intel/intel_winsys.h

index 1e5ebbcabd8feebfc97e587cc5b0ca7ab608d18b..7615e7c62f86ce12e35e6e79df55941819af1309 100644 (file)
@@ -315,10 +315,6 @@ ilo_3d_cp_flushed(struct ilo_3d *hw3d)
    ilo_3d_pipeline_invalidate(hw3d->pipeline,
          ILO_3D_PIPELINE_INVALIDATE_BATCH_BO |
          ILO_3D_PIPELINE_INVALIDATE_STATE_BO);
-   if (!hw3d->cp->render_ctx) {
-      ilo_3d_pipeline_invalidate(hw3d->pipeline,
-            ILO_3D_PIPELINE_INVALIDATE_HW);
-   }
 
    hw3d->new_batch = true;
 }
index 4263882c4bdb3b5ac04e68d11ba3f655459dad37..953e3e32b549257e7f11d8fa63b9535b80287f0e 100644 (file)
@@ -422,12 +422,6 @@ gen7_pipeline_sol(struct ilo_3d_pipeline *p,
          const int stride = so_info->stride[i] * 4; /* in bytes */
          int base = 0;
 
-         /* reset HW write offsets and offset buffer base */
-         if (!p->cp->render_ctx) {
-            ilo_cp_set_one_off_flags(p->cp, INTEL_EXEC_GEN7_SOL_RESET);
-            base += p->state.so_num_vertices * stride;
-         }
-
          gen7_emit_3DSTATE_SO_BUFFER(p->dev, i, base, stride,
                ilo->so.states[i], p->cp);
       }
index 6a2649b354f8d6f41055b371a58788d2b61f43a2..db7fdc7f1fa97e37e3c5ee9bbbeaba4f73b4e298 100644 (file)
@@ -71,6 +71,7 @@ struct ilo_dev_info {
    int max_batch_size;
    bool has_llc;
    bool has_address_swizzling;
+   bool has_logical_context;
    bool has_timestamp;
    bool has_gen7_sol_reset;
 
index 49dc237d72f0e8c0656849e674987cf027d2bfe6..16871f971ec56529a1dfb85df3be48222183c66e 100644 (file)
@@ -245,8 +245,7 @@ ilo_cp_destroy(struct ilo_cp *cp)
       intel_bo_unreference(cp->bo);
    }
 
-   if (cp->render_ctx)
-      intel_winsys_destroy_context(cp->winsys, cp->render_ctx);
+   intel_winsys_destroy_context(cp->winsys, cp->render_ctx);
 
    FREE(cp->sys);
    FREE(cp);
@@ -266,6 +265,10 @@ ilo_cp_create(struct intel_winsys *winsys, int size, bool direct_map)
 
    cp->winsys = winsys;
    cp->render_ctx = intel_winsys_create_context(winsys);
+   if (!cp->render_ctx) {
+      FREE(cp);
+      return NULL;
+   }
 
    cp->ring = INTEL_RING_RENDER;
    cp->no_implicit_flush = false;
index 8656d18806feacb781deadb7f667fd96baeef113..5d652e4ad73ebfdf87eaaff8d72e9e3fdfe49a3f 100644 (file)
@@ -651,9 +651,15 @@ init_dev(struct ilo_dev_info *dev, const struct intel_winsys_info *info)
    dev->max_batch_size = info->max_batch_size;
    dev->has_llc = info->has_llc;
    dev->has_address_swizzling = info->has_address_swizzling;
+   dev->has_logical_context = info->has_logical_context;
    dev->has_timestamp = info->has_timestamp;
    dev->has_gen7_sol_reset = info->has_gen7_sol_reset;
 
+   if (!dev->has_logical_context) {
+      ilo_err("missing hardware logical context support\n");
+      return false;
+   }
+
    /*
     * From the Sandy Bridge PRM, volume 4 part 2, page 18:
     *
index 5789114b39f9058ecd276cce58f3fec86c27fa4e..dfef9f4a9141f3fd1fadb30bedab34dfb92ec88f 100644 (file)
@@ -53,6 +53,7 @@ struct intel_winsys {
 
    /* these are protected by the mutex */
    pipe_mutex mutex;
+   drm_intel_context *first_gem_ctx;
    struct drm_intel_decode *decode;
 };
 
@@ -145,6 +146,9 @@ probe_winsys(struct intel_winsys *winsys)
    info->has_llc = val;
    info->has_address_swizzling = test_address_swizzling(winsys);
 
+   winsys->first_gem_ctx = drm_intel_gem_context_create(winsys->bufmgr);
+   info->has_logical_context = (winsys->first_gem_ctx != NULL);
+
    /* test TIMESTAMP read */
    info->has_timestamp = test_reg_read(winsys, 0x2358);
 
@@ -210,6 +214,9 @@ intel_winsys_destroy(struct intel_winsys *winsys)
    if (winsys->decode)
       drm_intel_decode_context_free(winsys->decode);
 
+   if (winsys->first_gem_ctx)
+      drm_intel_gem_context_destroy(winsys->first_gem_ctx);
+
    pipe_mutex_destroy(winsys->mutex);
    drm_intel_bufmgr_destroy(winsys->bufmgr);
    FREE(winsys);
@@ -224,8 +231,18 @@ intel_winsys_get_info(const struct intel_winsys *winsys)
 struct intel_context *
 intel_winsys_create_context(struct intel_winsys *winsys)
 {
-   return (struct intel_context *)
-      drm_intel_gem_context_create(winsys->bufmgr);
+   drm_intel_context *gem_ctx;
+
+   /* try the preallocated context first */
+   pipe_mutex_lock(winsys->mutex);
+   gem_ctx = winsys->first_gem_ctx;
+   winsys->first_gem_ctx = NULL;
+   pipe_mutex_unlock(winsys->mutex);
+
+   if (!gem_ctx)
+      gem_ctx = drm_intel_gem_context_create(winsys->bufmgr);
+
+   return (struct intel_context *) gem_ctx;
 }
 
 void
index 8140588dfa2c5cdfc2e1c679200b77ceb2e46ea6..3c9e6f267beaf04253595f650968dec2078c8c76 100644 (file)
@@ -72,6 +72,7 @@ struct intel_winsys_info {
    int max_batch_size;
    bool has_llc;
    bool has_address_swizzling;
+   bool has_logical_context;
 
    /* valid registers for intel_winsys_read_reg() */
    bool has_timestamp;