From 538decc0de64e57d00c1a6b4ced431ebfb60de3a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 25 Jan 2018 21:23:45 -0800 Subject: [PATCH] iris: URB configs. --- src/gallium/drivers/iris/iris_context.c | 2 ++ src/gallium/drivers/iris/iris_context.h | 2 ++ src/gallium/drivers/iris/iris_program.c | 4 --- src/gallium/drivers/iris/iris_state.c | 39 ++++++++++++++++++++++++- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c index 4675e2e62c1..f4a912a102f 100644 --- a/src/gallium/drivers/iris/iris_context.c +++ b/src/gallium/drivers/iris/iris_context.c @@ -124,6 +124,8 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags) ctx->flush = iris_flush; ctx->set_debug_callback = iris_set_debug_callback; + ice->shaders.urb_size = devinfo->urb.size; + iris_init_blit_functions(ctx); iris_init_clear_functions(ctx); iris_init_program_functions(ctx); diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 3d16cfedc31..fc1b4c572db 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -119,6 +119,8 @@ struct iris_context { struct u_upload_mgr *uploader; struct hash_table *cache; + + unsigned urb_size; } shaders; /** The main batch for rendering */ diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 82dfd6a5050..e2e92b839ae 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -377,10 +377,6 @@ iris_update_compiled_shaders(struct iris_context *ice) } } } - - if (ice->state.dirty & IRIS_DIRTY_URB) { - // ... back to the state module :/ - } } void diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 10b81859bd3..289bc1c4711 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -40,6 +40,7 @@ #include "util/u_transfer.h" #include "i915_drm.h" #include "intel/compiler/brw_compiler.h" +#include "intel/common/gen_l3_config.h" #include "intel/common/gen_sample_positions.h" #include "iris_batch.h" #include "iris_context.h" @@ -1696,6 +1697,42 @@ iris_set_derived_program_state(const struct gen_device_info *devinfo, } } +static void +iris_upload_urb_config(struct iris_context *ice, struct iris_batch *batch) +{ + const struct gen_device_info *devinfo = &batch->screen->devinfo; + const unsigned push_size_kB = 32; + unsigned entries[4]; + unsigned start[4]; + unsigned size[4]; + + for (int i = MESA_SHADER_VERTEX; i <= MESA_SHADER_GEOMETRY; i++) { + if (!ice->shaders.prog[i]) { + size[i] = 1; + } else { + struct brw_vue_prog_data *vue_prog_data = + (void *) ice->shaders.prog[i]->prog_data; + size[i] = vue_prog_data->urb_entry_size; + } + assert(size[i] != 0); + } + + gen_get_urb_config(devinfo, 1024 * push_size_kB, + 1024 * ice->shaders.urb_size, + ice->shaders.prog[MESA_SHADER_TESS_EVAL] != NULL, + ice->shaders.prog[MESA_SHADER_GEOMETRY] != NULL, + size, entries, start); + + for (int i = MESA_SHADER_VERTEX; i <= MESA_SHADER_GEOMETRY; i++) { + iris_emit_cmd(batch, GENX(3DSTATE_URB_VS), urb) { + urb._3DCommandSubOpcode += i; + urb.VSURBStartingAddress = start[i]; + urb.VSURBEntryAllocationSize = size[i] - 1; + urb.VSNumberofURBEntries = entries[i]; + } + } +} + static void iris_upload_render_state(struct iris_context *ice, struct iris_batch *batch, @@ -1725,7 +1762,7 @@ iris_upload_render_state(struct iris_context *ice, /* XXX: L3 State */ if (dirty & IRIS_DIRTY_URB) { - /* XXX: 3DSTATE_URB */ + iris_upload_urb_config(ice, batch); } if (dirty & IRIS_DIRTY_BLEND_STATE) { -- 2.30.2