mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
mesa/st: rework thread scheduler handling + add dispatch tracking
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36715>
This commit is contained in:
parent
b8cd48e8e8
commit
f967a85f64
5 changed files with 39 additions and 29 deletions
|
|
@ -296,6 +296,7 @@ prepare_compute(struct gl_context *ctx)
|
|||
_mesa_update_state(ctx);
|
||||
|
||||
st_validate_state(st, ST_PIPELINE_COMPUTE_STATE_MASK);
|
||||
st_context_add_work(st);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ void _mesa_glthread_enable(struct gl_context *ctx)
|
|||
ctx->GLApi = ctx->MarshalExec;
|
||||
|
||||
/* glthread takes over all thread scheduling. */
|
||||
ctx->st->pin_thread_counter = ST_THREAD_SCHEDULER_DISABLED;
|
||||
ctx->st->thread_scheduler_disabled = true;
|
||||
|
||||
/* Update the dispatch only if the dispatch is current. */
|
||||
if (GET_DISPATCH() == ctx->Dispatch.Current) {
|
||||
|
|
@ -319,7 +319,7 @@ void _mesa_glthread_disable(struct gl_context *ctx)
|
|||
|
||||
/* Re-enable thread scheduling in st/mesa when glthread is disabled. */
|
||||
if (ctx->pipe->set_context_param && util_thread_scheduler_enabled())
|
||||
ctx->st->pin_thread_counter = 0;
|
||||
ctx->st->thread_scheduler_disabled = false;
|
||||
|
||||
/* Update the dispatch only if the dispatch is current. */
|
||||
if (GET_DISPATCH() == ctx->MarshalExec) {
|
||||
|
|
|
|||
|
|
@ -717,7 +717,7 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
|
|||
st->shader_has_one_variant[MESA_SHADER_COMPUTE] = st->has_shareable_shaders;
|
||||
|
||||
if (!st->pipe->set_context_param || !util_thread_scheduler_enabled())
|
||||
st->pin_thread_counter = ST_THREAD_SCHEDULER_DISABLED;
|
||||
st->thread_scheduler_disabled = true;
|
||||
|
||||
st->bitmap.cache.empty = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "vbo/vbo.h"
|
||||
#include "util/list.h"
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
#include "util/u_cpu_detect.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -53,8 +53,6 @@ struct st_context;
|
|||
struct st_program;
|
||||
struct u_upload_mgr;
|
||||
|
||||
#define ST_THREAD_SCHEDULER_DISABLED 0xffffffff
|
||||
|
||||
struct st_bitmap_cache
|
||||
{
|
||||
/** Window pos to render the cached image */
|
||||
|
|
@ -141,10 +139,11 @@ struct st_context
|
|||
struct draw_stage *selection_stage; /**< For GL_SELECT rendermode */
|
||||
struct draw_stage *rastpos_stage; /**< For glRasterPos */
|
||||
|
||||
unsigned pin_thread_counter; /* for L3 thread pinning on AMD Zen */
|
||||
unsigned work_counter; /* for L3 thread pinning on AMD Zen and resource pruning */
|
||||
|
||||
GLboolean clamp_frag_color_in_shader;
|
||||
GLboolean clamp_vert_color_in_shader;
|
||||
bool thread_scheduler_disabled;
|
||||
bool has_stencil_export; /**< can do shader stencil export? */
|
||||
bool has_time_elapsed;
|
||||
bool has_etc1;
|
||||
|
|
@ -517,6 +516,37 @@ st_api_destroy_drawable(struct pipe_frontend_drawable *drawable);
|
|||
void
|
||||
st_screen_destroy(struct pipe_frontend_screen *fscreen);
|
||||
|
||||
static inline void
|
||||
st_context_apply_scheduler_policy(struct st_context *st)
|
||||
{
|
||||
int cpu = util_get_current_cpu();
|
||||
if (cpu >= 0) {
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
uint16_t L3_cache = util_get_cpu_caps()->cpu_to_L3[cpu];
|
||||
|
||||
if (L3_cache != U_CPU_INVALID_L3) {
|
||||
pipe->set_context_param(pipe,
|
||||
PIPE_CONTEXT_PARAM_UPDATE_THREAD_SCHEDULING,
|
||||
cpu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
st_context_add_work(struct st_context *st)
|
||||
{
|
||||
|
||||
/* Apply our thread scheduling policy for better multithreading
|
||||
* performance.
|
||||
*/
|
||||
if (unlikely(++st->work_counter % 512 == 0)) {
|
||||
st->work_counter = 0;
|
||||
if (!st->thread_scheduler_disabled)
|
||||
st_context_apply_scheduler_policy(st);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@
|
|||
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "util/u_cpu_detect.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/u_prim.h"
|
||||
|
|
@ -87,27 +86,7 @@ st_prepare_draw(struct gl_context *ctx, uint64_t state_mask)
|
|||
|
||||
/* Validate state. */
|
||||
st_validate_state(st, state_mask);
|
||||
|
||||
/* Apply our thread scheduling policy for better multithreading
|
||||
* performance.
|
||||
*/
|
||||
if (unlikely(st->pin_thread_counter != ST_THREAD_SCHEDULER_DISABLED &&
|
||||
/* do it occasionally */
|
||||
++st->pin_thread_counter % 512 == 0)) {
|
||||
st->pin_thread_counter = 0;
|
||||
|
||||
int cpu = util_get_current_cpu();
|
||||
if (cpu >= 0) {
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
uint16_t L3_cache = util_get_cpu_caps()->cpu_to_L3[cpu];
|
||||
|
||||
if (L3_cache != U_CPU_INVALID_L3) {
|
||||
pipe->set_context_param(pipe,
|
||||
PIPE_CONTEXT_PARAM_UPDATE_THREAD_SCHEDULING,
|
||||
cpu);
|
||||
}
|
||||
}
|
||||
}
|
||||
st_context_add_work(st);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue