Module: Mesa
Branch: master
Commit: e5e3b5cdcc38ce1111b134e6fe5bc4d00c8c715f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5e3b5cdcc38ce1111b134e6fe5bc4d00c8c715f

Author: Marek Olšák <[email protected]>
Date:   Wed Sep  5 22:57:19 2018 -0400

gallium: add pipe_context::set_context_param for tuning perf on AMD Zen (v2)

State trackers will not use the new param directly, but will instead use
a helper in MakeCurrent that does the right thing.

v2: rework the interface

Reviewed-by: Brian Paul <[email protected]>

---

 src/gallium/auxiliary/driver_ddebug/dd_context.c | 11 +++++++++++
 src/gallium/auxiliary/driver_noop/noop_pipe.c    |  7 +++++++
 src/gallium/auxiliary/driver_trace/tr_context.c  | 20 ++++++++++++++++++++
 src/gallium/include/pipe/p_context.h             |  7 +++++++
 src/gallium/include/pipe/p_defines.h             | 14 ++++++++++++++
 5 files changed, 59 insertions(+)

diff --git a/src/gallium/auxiliary/driver_ddebug/dd_context.c 
b/src/gallium/auxiliary/driver_ddebug/dd_context.c
index a1b6c971e8..a9ac6ef14a 100644
--- a/src/gallium/auxiliary/driver_ddebug/dd_context.c
+++ b/src/gallium/auxiliary/driver_ddebug/dd_context.c
@@ -759,6 +759,16 @@ dd_context_make_image_handle_resident(struct pipe_context 
*_pipe,
    pipe->make_image_handle_resident(pipe, handle, access, resident);
 }
 
+static void
+dd_context_set_context_param(struct pipe_context *_pipe,
+                             enum pipe_context_param param,
+                             unsigned value)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->set_context_param(pipe, param, value);
+}
+
 struct pipe_context *
 dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
 {
@@ -862,6 +872,7 @@ dd_context_create(struct dd_screen *dscreen, struct 
pipe_context *pipe)
    CTX_INIT(create_image_handle);
    CTX_INIT(delete_image_handle);
    CTX_INIT(make_image_handle_resident);
+   CTX_INIT(set_context_param);
 
    dd_init_draw_functions(dctx);
 
diff --git a/src/gallium/auxiliary/driver_noop/noop_pipe.c 
b/src/gallium/auxiliary/driver_noop/noop_pipe.c
index 7de3e88239..a6497f0767 100644
--- a/src/gallium/auxiliary/driver_noop/noop_pipe.c
+++ b/src/gallium/auxiliary/driver_noop/noop_pipe.c
@@ -312,6 +312,12 @@ static void noop_invalidate_resource(struct pipe_context 
*ctx,
 {
 }
 
+static void noop_set_context_param(struct pipe_context *ctx,
+                                   enum pipe_context_param param,
+                                   unsigned value)
+{
+}
+
 static struct pipe_context *noop_create_context(struct pipe_screen *screen,
                                                 void *priv, unsigned flags)
 {
@@ -351,6 +357,7 @@ static struct pipe_context *noop_create_context(struct 
pipe_screen *screen,
    ctx->buffer_subdata = noop_buffer_subdata;
    ctx->texture_subdata = noop_texture_subdata;
    ctx->invalidate_resource = noop_invalidate_resource;
+   ctx->set_context_param = noop_set_context_param;
    noop_init_state_functions(ctx);
 
    return ctx;
diff --git a/src/gallium/auxiliary/driver_trace/tr_context.c 
b/src/gallium/auxiliary/driver_trace/tr_context.c
index dc091aee2e..7859a3395c 100644
--- a/src/gallium/auxiliary/driver_trace/tr_context.c
+++ b/src/gallium/auxiliary/driver_trace/tr_context.c
@@ -1577,6 +1577,25 @@ trace_context_invalidate_resource(struct pipe_context 
*_context,
 }
 
 static void
+trace_context_set_context_param(struct pipe_context *_context,
+                                enum pipe_context_param param,
+                                unsigned value)
+{
+   struct trace_context *tr_context = trace_context(_context);
+   struct pipe_context *context = tr_context->pipe;
+
+   trace_dump_call_begin("pipe_context", "set_context_param");
+
+   trace_dump_arg(ptr, context);
+   trace_dump_arg(uint, param);
+   trace_dump_arg(uint, value);
+
+   trace_dump_call_end();
+
+   context->set_context_param(context, param, value);
+}
+
+static void
 trace_context_render_condition(struct pipe_context *_context,
                                struct pipe_query *query,
                                boolean condition,
@@ -1948,6 +1967,7 @@ trace_context_create(struct trace_screen *tr_scr,
    TR_CTX_INIT(buffer_subdata);
    TR_CTX_INIT(texture_subdata);
    TR_CTX_INIT(invalidate_resource);
+   TR_CTX_INIT(set_context_param);
 
 #undef TR_CTX_INIT
 
diff --git a/src/gallium/include/pipe/p_context.h 
b/src/gallium/include/pipe/p_context.h
index 7cf037f1ab..dd1f5ed192 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -927,6 +927,13 @@ struct pipe_context {
     */
    void (*callback)(struct pipe_context *ctx, void (*fn)(void *), void *data,
                     bool asap);
+
+   /**
+    * Set a context parameter See enum pipe_context_param for more details.
+    */
+   void (*set_context_param)(struct pipe_context *ctx,
+                             enum pipe_context_param param,
+                             unsigned value);
 };
 
 
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 22515504f6..f605219673 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -953,6 +953,20 @@ enum pipe_compute_cap
 };
 
 /**
+ * Types of parameters for pipe_context::set_context_param.
+ */
+enum pipe_context_param
+{
+   /* A hint for the driver that it should pin its execution threads to
+    * a group of cores sharing a specific L3 cache if the CPU has multiple
+    * L3 caches. This is needed for good multithreading performance on
+    * AMD Zen CPUs. "value" is the L3 cache index. Drivers that don't have
+    * any internal threads or don't run on affected CPUs can ignore this.
+    */
+   PIPE_CONTEXT_PARAM_PIN_THREADS_TO_L3_CACHE,
+};
+
+/**
  * Composite query types
  */
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to