gallium/u_threaded: implement set_context_param for thread pinning (v2)
authorMarek Olšák <marek.olsak@amd.com>
Thu, 6 Sep 2018 03:12:27 +0000 (23:12 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 7 Sep 2018 20:03:36 +0000 (16:03 -0400)
v2: - use set_context_param
    - set set_context_param even if the driver doesn't implement it

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/util/u_threaded_context.c
src/gallium/auxiliary/util/u_threaded_context_calls.h

index fc7eb1388353f8918a0de21a5f87de153d2c5344..8e3bceae18d0b983e20cb2dd62587b3fdd6a2c10 100644 (file)
@@ -1899,6 +1899,44 @@ tc_create_video_buffer(UNUSED struct pipe_context *_pipe,
    return NULL;
 }
 
+struct tc_context_param {
+   enum pipe_context_param param;
+   unsigned value;
+};
+
+static void
+tc_call_set_context_param(struct pipe_context *pipe,
+                          union tc_payload *payload)
+{
+   struct tc_context_param *p = (struct tc_context_param*)payload;
+
+   if (pipe->set_context_param)
+      pipe->set_context_param(pipe, p->param, p->value);
+}
+
+static void
+tc_set_context_param(struct pipe_context *_pipe,
+                           enum pipe_context_param param,
+                           unsigned value)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+
+   if (tc->pipe->set_context_param) {
+      struct tc_context_param *payload =
+         tc_add_struct_typed_call(tc, TC_CALL_set_context_param,
+                                  tc_context_param);
+
+      payload->param = param;
+      payload->value = value;
+   }
+
+   if (param == PIPE_CONTEXT_PARAM_PIN_THREADS_TO_L3_CACHE) {
+      /* Pin the gallium thread as requested. */
+      util_pin_thread_to_L3(tc->queue.threads[0], value,
+                            util_cpu_caps.cores_per_L3);
+   }
+}
+
 
 /********************************************************************
  * draw, launch, clear, blit, copy, flush
@@ -2580,6 +2618,8 @@ threaded_context_create(struct pipe_context *pipe,
 
    slab_create_child(&tc->pool_transfers, parent_transfer_pool);
 
+   tc->base.set_context_param = tc_set_context_param; /* always set this */
+
 #define CTX_INIT(_member) \
    tc->base._member = tc->pipe->_member ? tc_##_member : NULL
 
index 921b86a67f0e5d157c978f0b0a8211e720c2dad3..e6ea1b5747c3c0362f858be96ca8a97d88368638 100644 (file)
@@ -49,6 +49,7 @@ CALL(delete_texture_handle)
 CALL(make_texture_handle_resident)
 CALL(delete_image_handle)
 CALL(make_image_handle_resident)
+CALL(set_context_param)
 
 CALL(bind_blend_state)
 CALL(bind_rasterizer_state)