[Mesa-dev] [PATCH 1/2] i965: Clean up intel_batchbuffer_init().
Iago Toral
itoral at igalia.com
Fri Aug 11 11:26:50 UTC 2017
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
On Thu, 2017-08-10 at 22:52 -0700, Kenneth Graunke wrote:
> Passing screen lets us get the kernel features, devinfo, and bufmgr,
> without needing container_of.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102062
> Cc: Mauro Rossi <issor.oruam at gmail.com>
> Cc: Tapani Pälli <tapani.palli at intel.com>
> ---
> src/mesa/drivers/dri/i965/brw_context.c | 2 +-
> src/mesa/drivers/dri/i965/intel_batchbuffer.c | 16 ++++++++--------
> src/mesa/drivers/dri/i965/intel_batchbuffer.h | 5 ++---
> 3 files changed, 11 insertions(+), 12 deletions(-)
>
> According to the bug report, something about container_of is causing
> things to go haywire. I'm not seeing the problem, but eliminating
> that is easy enough and arguably a bit nicer anyway...
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 60b14571ed0..2d8f34f7efa 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -934,7 +934,7 @@ brwCreateContext(gl_api api,
>
> intel_fbo_init(brw);
>
> - intel_batchbuffer_init(&brw->batch, brw->bufmgr, brw->has_llc);
> + intel_batchbuffer_init(screen, &brw->batch);
>
> if (brw->gen >= 6) {
> /* Create a new hardware context. Using a hardware context
> means that
> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> index 66b9a28129e..59488a2f969 100644
> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> @@ -58,13 +58,13 @@ uint_key_hash(const void *key)
> }
>
> void
> -intel_batchbuffer_init(struct intel_batchbuffer *batch,
> - struct brw_bufmgr *bufmgr,
> - bool has_llc)
> +intel_batchbuffer_init(struct intel_screen *screen,
> + struct intel_batchbuffer *batch)
> {
> - struct brw_context *brw = container_of(batch, brw, batch);
> + struct brw_bufmgr *bufmgr = screen->bufmgr;
> + const struct gen_device_info *devinfo = &screen->devinfo;
>
> - if (!has_llc) {
> + if (!devinfo->has_llc) {
> batch->cpu_map = malloc(BATCH_SZ);
> batch->map = batch->cpu_map;
> batch->map_next = batch->cpu_map;
> @@ -87,14 +87,14 @@ intel_batchbuffer_init(struct intel_batchbuffer
> *batch,
> }
>
> batch->use_batch_first =
> - brw->screen->kernel_features & KERNEL_ALLOWS_EXEC_BATCH_FIRST;
> + screen->kernel_features & KERNEL_ALLOWS_EXEC_BATCH_FIRST;
>
> /* PIPE_CONTROL needs a w/a but only on gen6 */
> batch->valid_reloc_flags = EXEC_OBJECT_WRITE;
> - if (brw->gen == 6)
> + if (devinfo->gen == 6)
> batch->valid_reloc_flags |= EXEC_OBJECT_NEEDS_GTT;
>
> - intel_batchbuffer_reset(batch, bufmgr, has_llc);
> + intel_batchbuffer_reset(batch, bufmgr, devinfo->has_llc);
> }
>
> #define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h
> b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
> index 4661a2a9f66..99d2747f282 100644
> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.h
> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
> @@ -38,9 +38,8 @@ extern "C" {
>
> struct intel_batchbuffer;
>
> -void intel_batchbuffer_init(struct intel_batchbuffer *batch,
> - struct brw_bufmgr *bufmgr,
> - bool has_llc);
> +void intel_batchbuffer_init(struct intel_screen *screen,
> + struct intel_batchbuffer *batch);
> void intel_batchbuffer_free(struct intel_batchbuffer *batch);
> void intel_batchbuffer_save_state(struct brw_context *brw);
> void intel_batchbuffer_reset_to_saved(struct brw_context *brw);
More information about the mesa-dev
mailing list