iris: Use different shader uploaders for precompile vs. draw time

When we enable u_threaded_context, the pipe->create_*_state hooks
(precompile variants) are going to be called from one thread, while
iris_update_compiled_shaders (on-the-fly variants) are going to be
called from a driver thread.  BLORP shaders also happen from
clear, blit, and so on in the driver thread.

u_upload_mgr isn't thread-safe, so use an uploader for each purpose.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8964>
This commit is contained in:
Kenneth Graunke 2021-02-08 17:00:36 -08:00
parent ec0d61c14c
commit 3358c7125a
3 changed files with 23 additions and 16 deletions

View File

@ -638,7 +638,10 @@ struct iris_context {
bool constrained;
} urb;
struct u_upload_mgr *uploader;
/** Uploader for shader assembly from the driver thread */
struct u_upload_mgr *uploader_driver;
/** Uploader for shader assembly from the threaded context */
struct u_upload_mgr *uploader_unsync;
struct hash_table *cache;
/** Is a GS or TES outputting points or lines? */

View File

@ -1238,7 +1238,7 @@ iris_update_compiled_vs(struct iris_context *ice)
{
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_VERTEX];
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_driver;
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_VERTEX];
@ -1431,7 +1431,7 @@ iris_update_compiled_tcs(struct iris_context *ice)
struct iris_uncompiled_shader *tcs =
ice->shaders.uncompiled[MESA_SHADER_TESS_CTRL];
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_driver;
const struct brw_compiler *compiler = screen->compiler;
const struct gen_device_info *devinfo = &screen->devinfo;
@ -1564,7 +1564,7 @@ static void
iris_update_compiled_tes(struct iris_context *ice)
{
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_driver;
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_TESS_EVAL];
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_TESS_EVAL];
@ -1690,7 +1690,7 @@ static void
iris_update_compiled_gs(struct iris_context *ice)
{
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_GEOMETRY];
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_driver;
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_GEOMETRY];
struct iris_compiled_shader *old = ice->shaders.prog[IRIS_CACHE_GS];
@ -1810,7 +1810,7 @@ static void
iris_update_compiled_fs(struct iris_context *ice)
{
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_FRAGMENT];
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_driver;
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_FRAGMENT];
struct iris_fs_prog_key key = { KEY_ID(base) };
@ -2068,7 +2068,7 @@ static void
iris_update_compiled_cs(struct iris_context *ice)
{
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_COMPUTE];
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_driver;
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_COMPUTE];
@ -2281,7 +2281,7 @@ iris_create_vs_state(struct pipe_context *ctx,
{
struct iris_context *ice = (void *) ctx;
struct iris_screen *screen = (void *) ctx->screen;
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_unsync;
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
/* User clip planes */
@ -2305,7 +2305,7 @@ iris_create_tcs_state(struct pipe_context *ctx,
struct iris_context *ice = (void *) ctx;
struct iris_screen *screen = (void *) ctx->screen;
const struct brw_compiler *compiler = screen->compiler;
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_unsync;
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
struct shader_info *info = &ish->nir->info;
@ -2342,7 +2342,7 @@ iris_create_tes_state(struct pipe_context *ctx,
{
struct iris_context *ice = (void *) ctx;
struct iris_screen *screen = (void *) ctx->screen;
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_unsync;
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
struct shader_info *info = &ish->nir->info;
@ -2371,7 +2371,7 @@ iris_create_gs_state(struct pipe_context *ctx,
{
struct iris_context *ice = (void *) ctx;
struct iris_screen *screen = (void *) ctx->screen;
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_unsync;
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
/* User clip planes */
@ -2394,7 +2394,7 @@ iris_create_fs_state(struct pipe_context *ctx,
{
struct iris_context *ice = (void *) ctx;
struct iris_screen *screen = (void *) ctx->screen;
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_unsync;
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
struct shader_info *info = &ish->nir->info;
@ -2440,7 +2440,7 @@ iris_create_compute_state(struct pipe_context *ctx,
{
struct iris_context *ice = (void *) ctx;
struct iris_screen *screen = (void *) ctx->screen;
struct u_upload_mgr *uploader = ice->shaders.uploader;
struct u_upload_mgr *uploader = ice->shaders.uploader_unsync;
const nir_shader_compiler_options *options =
screen->compiler->glsl_compiler_options[MESA_SHADER_COMPUTE].NirOptions;

View File

@ -250,7 +250,7 @@ iris_blorp_upload_shader(struct blorp_batch *blorp_batch, uint32_t stage,
struct iris_compiled_shader *shader =
iris_upload_shader(screen, NULL, ice->shaders.cache,
ice->shaders.uploader,
ice->shaders.uploader_driver,
IRIS_CACHE_BLORP, key_size, key, kernel,
prog_data, NULL, NULL, 0, 0, 0, &bt);
@ -270,7 +270,10 @@ iris_init_program_cache(struct iris_context *ice)
ice->shaders.cache =
_mesa_hash_table_create(ice, keybox_hash, keybox_equals);
ice->shaders.uploader =
ice->shaders.uploader_driver =
u_upload_create(&ice->ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
IRIS_RESOURCE_FLAG_SHADER_MEMZONE);
ice->shaders.uploader_unsync =
u_upload_create(&ice->ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
IRIS_RESOURCE_FLAG_SHADER_MEMZONE);
}
@ -288,7 +291,8 @@ iris_destroy_program_cache(struct iris_context *ice)
iris_delete_shader_variant(shader);
}
u_upload_destroy(ice->shaders.uploader);
u_upload_destroy(ice->shaders.uploader_driver);
u_upload_destroy(ice->shaders.uploader_unsync);
ralloc_free(ice->shaders.cache);
}