From 747627d0456eb14b2fb4c320c5bf0f084f3b2907 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 10 Mar 2014 12:31:30 +0800 Subject: [PATCH] ilo: require hardware logical context support The code paths are not tested for a while, and have some known issues. --- src/gallium/drivers/ilo/ilo_3d.c | 4 ---- .../drivers/ilo/ilo_3d_pipeline_gen7.c | 6 ------ src/gallium/drivers/ilo/ilo_common.h | 1 + src/gallium/drivers/ilo/ilo_cp.c | 7 +++++-- src/gallium/drivers/ilo/ilo_screen.c | 6 ++++++ .../winsys/intel/drm/intel_drm_winsys.c | 21 +++++++++++++++++-- src/gallium/winsys/intel/intel_winsys.h | 1 + 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_3d.c b/src/gallium/drivers/ilo/ilo_3d.c index 1e5ebbcabd8..7615e7c62f8 100644 --- a/src/gallium/drivers/ilo/ilo_3d.c +++ b/src/gallium/drivers/ilo/ilo_3d.c @@ -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; } diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c index 4263882c4bd..953e3e32b54 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c @@ -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); } diff --git a/src/gallium/drivers/ilo/ilo_common.h b/src/gallium/drivers/ilo/ilo_common.h index 6a2649b354f..db7fdc7f1fa 100644 --- a/src/gallium/drivers/ilo/ilo_common.h +++ b/src/gallium/drivers/ilo/ilo_common.h @@ -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; diff --git a/src/gallium/drivers/ilo/ilo_cp.c b/src/gallium/drivers/ilo/ilo_cp.c index 49dc237d72f..16871f971ec 100644 --- a/src/gallium/drivers/ilo/ilo_cp.c +++ b/src/gallium/drivers/ilo/ilo_cp.c @@ -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; diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index 8656d18806f..5d652e4ad73 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -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: * diff --git a/src/gallium/winsys/intel/drm/intel_drm_winsys.c b/src/gallium/winsys/intel/drm/intel_drm_winsys.c index 5789114b39f..dfef9f4a914 100644 --- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c +++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c @@ -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 diff --git a/src/gallium/winsys/intel/intel_winsys.h b/src/gallium/winsys/intel/intel_winsys.h index 8140588dfa2..3c9e6f267be 100644 --- a/src/gallium/winsys/intel/intel_winsys.h +++ b/src/gallium/winsys/intel/intel_winsys.h @@ -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; -- 2.30.2