diff options
author | Kenneth Graunke <[email protected]> | 2018-04-21 23:27:15 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-02-21 10:26:06 -0800 |
commit | e2ba98ba398011f3b4f2c62c446053ed1303ebdc (patch) | |
tree | e33ef8493d8bc88d1754c9d420fe60c8130c19e4 /src | |
parent | 1bba60a4bf7e0a29c90c2fea77746e64d837123f (diff) |
iris: more blorp
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/iris/iris_blorp.c | 22 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_context.h | 17 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_program_cache.c | 156 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_state.c | 5 |
4 files changed, 150 insertions, 50 deletions
diff --git a/src/gallium/drivers/iris/iris_blorp.c b/src/gallium/drivers/iris/iris_blorp.c index 7995325239e..c61fb1b483e 100644 --- a/src/gallium/drivers/iris/iris_blorp.c +++ b/src/gallium/drivers/iris/iris_blorp.c @@ -35,17 +35,20 @@ stream_state(struct iris_batch *batch, unsigned size, unsigned alignment, uint32_t *out_offset, - struct iris_bo **out_bo) + struct iris_bo **out_bo, + bool relative_to_base) { struct pipe_resource *res = NULL; void *ptr = NULL; u_upload_alloc(uploader, 0, size, alignment, out_offset, &res, &ptr); - *out_bo = iris_resource_bo(res); - iris_use_pinned_bo(batch, *out_bo, false); + struct iris_bo *bo = iris_resource_bo(res); + iris_use_pinned_bo(batch, bo, false); - *out_offset += iris_bo_offset_from_base_address(*out_bo); + *out_bo = bo; + *out_offset += relative_to_base ? iris_bo_offset_from_base_address(bo) + : bo->gtt_offset; pipe_resource_reference(&res, NULL); @@ -110,7 +113,7 @@ blorp_alloc_dynamic_state(struct blorp_batch *blorp_batch, struct iris_bo *bo; return stream_state(batch, ice->state.dynamic_uploader, - size, alignment, offset, &bo); + size, alignment, offset, &bo, true); } static void @@ -133,7 +136,7 @@ blorp_alloc_binding_table(struct blorp_batch *blorp_batch, for (unsigned i = 0; i < num_entries; i++) { surface_maps[i] = stream_state(batch, ice->state.surface_uploader, state_size, state_alignment, - &surface_offsets[i], &bo); + &surface_offsets[i], &bo, true); bt_map[i] = surface_offsets[i]; } } @@ -149,7 +152,7 @@ blorp_alloc_vertex_buffer(struct blorp_batch *blorp_batch, uint32_t offset; void *map = stream_state(batch, ice->ctx.stream_uploader, size, 64, - &offset, &bo); + &offset, &bo, false); *addr = (struct blorp_address) { .buffer = bo, @@ -323,6 +326,7 @@ genX(init_blorp)(struct iris_context *ice) blorp_init(&ice->blorp, ice, &screen->isl_dev); ice->blorp.compiler = screen->compiler; - - ice->vtbl.blorp_exec = iris_blorp_exec; + ice->blorp.lookup_shader = iris_blorp_lookup_shader; + ice->blorp.upload_shader = iris_blorp_upload_shader; + ice->blorp.exec = iris_blorp_exec; } diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 1e7e60cc3a3..0be4a313258 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -118,7 +118,7 @@ enum iris_program_cache_id { IRIS_CACHE_GS = MESA_SHADER_GEOMETRY, IRIS_CACHE_FS = MESA_SHADER_FRAGMENT, IRIS_CACHE_CS = MESA_SHADER_COMPUTE, - IRIS_CACHE_BLORP_BLIT, + IRIS_CACHE_BLORP, }; /** @{ @@ -211,8 +211,6 @@ struct iris_vtable { void (*emit_raw_pipe_control)(struct iris_batch *batch, uint32_t flags, struct iris_bo *bo, uint32_t offset, uint64_t imm); - void (*blorp_exec)(struct blorp_batch *blorp_batch, - const struct blorp_params *params); unsigned (*derived_program_state_size)(enum iris_program_cache_id id); void (*set_derived_program_state)(const struct gen_device_info *devinfo, @@ -361,4 +359,17 @@ void iris_upload_and_bind_shader(struct iris_context *ice, const void *iris_find_previous_compile(const struct iris_context *ice, enum iris_program_cache_id cache_id, unsigned program_string_id); +bool iris_blorp_lookup_shader(struct blorp_batch *blorp_batch, + const void *key, + uint32_t key_size, + uint32_t *kernel_out, + void *prog_data_out); +bool iris_blorp_upload_shader(struct blorp_batch *blorp_batch, + const void *key, uint32_t key_size, + const void *kernel, uint32_t kernel_size, + const struct brw_stage_prog_data *prog_data, + uint32_t prog_data_size, + uint32_t *kernel_out, + void *prog_data_out); + #endif diff --git a/src/gallium/drivers/iris/iris_program_cache.c b/src/gallium/drivers/iris/iris_program_cache.c index e1fc21a08c1..6c286fd6640 100644 --- a/src/gallium/drivers/iris/iris_program_cache.c +++ b/src/gallium/drivers/iris/iris_program_cache.c @@ -34,6 +34,7 @@ #include "intel/compiler/brw_eu.h" #include "intel/compiler/brw_nir.h" #include "iris_context.h" +#include "iris_resource.h" struct keybox { uint8_t size; @@ -41,10 +42,8 @@ struct keybox { uint8_t data[0]; }; -static struct keybox * -make_keybox(void *mem_ctx, - enum iris_program_cache_id cache_id, - const void *key) +static uint32_t +key_size_for_cache(enum iris_program_cache_id cache_id) { static const unsigned key_sizes[] = { [IRIS_CACHE_VS] = sizeof(struct brw_vs_prog_key), @@ -53,15 +52,26 @@ make_keybox(void *mem_ctx, [IRIS_CACHE_GS] = sizeof(struct brw_gs_prog_key), [IRIS_CACHE_FS] = sizeof(struct brw_wm_prog_key), [IRIS_CACHE_CS] = sizeof(struct brw_cs_prog_key), - //[IRIS_CACHE_BLORP_BLIT] = sizeof(struct brw_blorp_blit_prog_key), }; + /* BLORP keys aren't all the same size. */ + assert(cache_id != IRIS_CACHE_BLORP); + + return key_sizes[cache_id]; +} + +static struct keybox * +make_keybox(void *mem_ctx, + enum iris_program_cache_id cache_id, + const void *key, + uint32_t key_size) +{ struct keybox *keybox = - ralloc_size(mem_ctx, sizeof(struct keybox) + key_sizes[cache_id]); + ralloc_size(mem_ctx, sizeof(struct keybox) + key_size); keybox->cache_id = cache_id; - keybox->size = key_sizes[cache_id]; - memcpy(keybox->data, key, key_sizes[cache_id]); + keybox->size = key_size; + memcpy(keybox->data, key, key_size); return keybox; } @@ -111,6 +121,20 @@ get_program_string_id(enum iris_program_cache_id cache_id, const void *key) } } +static struct iris_compiled_shader * +iris_find_cached_shader(struct iris_context *ice, + enum iris_program_cache_id cache_id, + const void *key, + uint32_t key_size) +{ + struct keybox *keybox = + make_keybox(ice->shaders.cache, cache_id, key, key_size); + struct hash_entry *entry = + _mesa_hash_table_search(ice->shaders.cache, keybox); + + return entry ? entry->data : NULL; +} + /** * Looks for a program in the cache and binds it. * @@ -121,17 +145,14 @@ iris_bind_cached_shader(struct iris_context *ice, enum iris_program_cache_id cache_id, const void *key) { - struct keybox *keybox = make_keybox(ice->shaders.cache, cache_id, key); - struct hash_entry *entry = - _mesa_hash_table_search(ice->shaders.cache, keybox); + unsigned key_size = key_size_for_cache(cache_id); + struct iris_compiled_shader *shader = + iris_find_cached_shader(ice, cache_id, key, key_size); - if (!entry) + if (!shader) return false; - struct iris_compiled_shader *shader = entry->data; - - if (cache_id <= MESA_SHADER_STAGES && - memcmp(shader, ice->shaders.prog[cache_id], sizeof(*shader)) != 0) { + if (memcmp(shader, ice->shaders.prog[cache_id], sizeof(*shader)) != 0) { ice->shaders.prog[cache_id] = shader; ice->state.dirty |= dirty_flag_for_cache(cache_id); } @@ -176,17 +197,13 @@ find_existing_assembly(struct hash_table *cache, return NULL; } -/** - * Upload a new shader to the program cache, and bind it for use. - * - * \param prog_data must be ralloc'd and will be stolen. - */ -void -iris_upload_and_bind_shader(struct iris_context *ice, - enum iris_program_cache_id cache_id, - const void *key, - const void *assembly, - struct brw_stage_prog_data *prog_data) +static struct iris_compiled_shader * +iris_upload_shader(struct iris_context *ice, + enum iris_program_cache_id cache_id, + uint32_t key_size, + const void *key, + const void *assembly, + const struct brw_stage_prog_data *prog_data) { struct iris_screen *screen = (void *) ice->ctx.screen; struct gen_device_info *devinfo = &screen->devinfo; @@ -214,20 +231,87 @@ iris_upload_and_bind_shader(struct iris_context *ice, shader->prog_data = prog_data; + /* Store the 3DSTATE shader packets and other derived state. */ + ice->vtbl.set_derived_program_state(devinfo, cache_id, shader); + + struct keybox *keybox = make_keybox(cache, cache_id, key, key_size); + _mesa_hash_table_insert(ice->shaders.cache, keybox, shader); + + return shader; +} + +/** + * Upload a new shader to the program cache, and bind it for use. + * + * \param prog_data must be ralloc'd and will be stolen. + */ +void +iris_upload_and_bind_shader(struct iris_context *ice, + enum iris_program_cache_id cache_id, + const void *key, + const void *assembly, + struct brw_stage_prog_data *prog_data) +{ + assert(cache_id != IRIS_CACHE_BLORP); + + struct iris_compiled_shader *shader = + iris_upload_shader(ice, cache_id, key_size_for_cache(cache_id), key, + assembly, prog_data); + ralloc_steal(shader, shader->prog_data); ralloc_steal(shader->prog_data, prog_data->param); ralloc_steal(shader->prog_data, prog_data->pull_param); - /* Store the 3DSTATE shader packets and other derived state. */ - ice->vtbl.set_derived_program_state(devinfo, cache_id, shader); + ice->shaders.prog[cache_id] = shader; + ice->state.dirty |= dirty_flag_for_cache(cache_id); +} - struct keybox *keybox = make_keybox(cache, cache_id, key); - _mesa_hash_table_insert(ice->shaders.cache, keybox, shader); +bool +iris_blorp_lookup_shader(struct blorp_batch *blorp_batch, + const void *key, uint32_t key_size, + uint32_t *kernel_out, void *prog_data_out) +{ + struct blorp_context *blorp = blorp_batch->blorp; + struct iris_context *ice = blorp->driver_ctx; + struct iris_batch *batch = blorp_batch->driver_batch; + struct iris_compiled_shader *shader = + iris_find_cached_shader(ice, IRIS_CACHE_BLORP, key, key_size); - if (cache_id <= MESA_SHADER_STAGES) { - ice->shaders.prog[cache_id] = shader; - ice->state.dirty |= dirty_flag_for_cache(cache_id); - } + if (!shader) + return false; + + struct iris_bo *bo = iris_resource_bo(shader->buffer); + *kernel_out = iris_bo_offset_from_base_address(bo) + shader->offset; + *((void **) prog_data_out) = shader->prog_data; + + iris_use_pinned_bo(batch, bo, false); + + return true; +} + +bool +iris_blorp_upload_shader(struct blorp_batch *blorp_batch, + const void *key, uint32_t key_size, + const void *kernel, UNUSED uint32_t kernel_size, + const struct brw_stage_prog_data *prog_data, + UNUSED uint32_t prog_data_size, + uint32_t *kernel_out, void *prog_data_out) +{ + struct blorp_context *blorp = blorp_batch->blorp; + struct iris_context *ice = blorp->driver_ctx; + struct iris_batch *batch = blorp_batch->driver_batch; + + struct iris_compiled_shader *shader = + iris_upload_shader(ice, IRIS_CACHE_BLORP, key_size, key, kernel, + prog_data); + + struct iris_bo *bo = iris_resource_bo(shader->buffer); + *kernel_out = iris_bo_offset_from_base_address(bo) + shader->offset; + *((void **) prog_data_out) = shader->prog_data; + + iris_use_pinned_bo(batch, bo, false); + + return true; } void @@ -256,7 +340,7 @@ iris_destroy_program_cache(struct iris_context *ice) static const char * cache_name(enum iris_program_cache_id cache_id) { - if (cache_id == IRIS_CACHE_BLORP_BLIT) + if (cache_id == IRIS_CACHE_BLORP) return "BLORP"; return _mesa_shader_stage_to_string(cache_id); diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index a3ebf3d0399..c1d523d3925 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -1900,7 +1900,7 @@ iris_set_fs_state(const struct gen_device_info *devinfo, static unsigned iris_derived_program_state_size(enum iris_program_cache_id cache_id) { - assert(cache_id <= IRIS_CACHE_CS); + assert(cache_id <= IRIS_CACHE_BLORP); static const unsigned dwords[] = { [IRIS_CACHE_VS] = GENX(3DSTATE_VS_length), @@ -1910,7 +1910,7 @@ iris_derived_program_state_size(enum iris_program_cache_id cache_id) [IRIS_CACHE_FS] = GENX(3DSTATE_PS_length) + GENX(3DSTATE_PS_EXTRA_length), [IRIS_CACHE_CS] = 0, - [IRIS_CACHE_BLORP_BLIT] = 0, + [IRIS_CACHE_BLORP] = 0, }; return sizeof(uint32_t) * dwords[cache_id]; @@ -1938,6 +1938,7 @@ iris_set_derived_program_state(const struct gen_device_info *devinfo, iris_set_fs_state(devinfo, shader); break; case IRIS_CACHE_CS: + case IRIS_CACHE_BLORP: break; default: break; |