From 5d2673ba7e3d1fecdc959ce5a2eb8c89b9592ab8 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 7 Apr 2018 06:35:51 -0700 Subject: [PATCH] iris: set sampler views --- src/gallium/drivers/iris/iris_context.h | 4 ++- src/gallium/drivers/iris/iris_state.c | 37 ++++++++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 21e81d37477..81eef52a7a6 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -186,7 +186,9 @@ struct iris_context { struct pipe_resource *sampler_table_resource[MESA_SHADER_STAGES]; uint32_t sampler_table_offset[MESA_SHADER_STAGES]; struct iris_sampler_state *samplers[MESA_SHADER_STAGES][IRIS_MAX_TEXTURE_SAMPLERS]; - unsigned num_samplers; + struct iris_sampler_view *textures[MESA_SHADER_STAGES][IRIS_MAX_TEXTURE_SAMPLERS]; + unsigned num_samplers[MESA_SHADER_STAGES]; + unsigned num_textures[MESA_SHADER_STAGES]; struct iris_binder binder; struct u_upload_mgr *surface_uploader; diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 7b4b66bd7cf..38310cfd6c8 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -890,7 +890,7 @@ iris_bind_sampler_states(struct pipe_context *ctx, map += GENX(SAMPLER_STATE_length); } - ice->state.num_samplers = count; + ice->state.num_samplers[stage] = count; ice->state.dirty |= IRIS_DIRTY_SAMPLER_STATES_VS << stage; } @@ -1055,10 +1055,22 @@ iris_create_surface(struct pipe_context *ctx, static void iris_set_sampler_views(struct pipe_context *ctx, - enum pipe_shader_type shader, + enum pipe_shader_type p_stage, unsigned start, unsigned count, struct pipe_sampler_view **views) { + struct iris_context *ice = (struct iris_context *) ctx; + gl_shader_stage stage = stage_from_pipe(p_stage); + + unsigned i; + for (i = 0; i < count; i++) + pipe_sampler_view_reference(&ice->state.textures[stage][i], views[i]); + for (; i < ice->state.num_textures[stage]; i++) + pipe_sampler_view_reference(&ice->state.textures[stage][i], NULL); + + ice->state.num_textures[stage] = count; + + // XXX: ice->state.dirty |= (IRIS_DIRTY_BINDING_TABLE_VS << stage); } static void @@ -1923,7 +1935,7 @@ use_surface(struct iris_batch *batch, bool writeable) { struct iris_surface *surf = (void *) p_surf; - struct iris_resource *res = (void *) surf->pipe.texture; + struct iris_resource *res = (void *) p_surf->texture; struct iris_resource *state_res = (void *) surf->surface_state_resource; iris_use_pinned_bo(batch, res->bo, writeable); iris_use_pinned_bo(batch, state_res->bo, false); @@ -1931,6 +1943,17 @@ use_surface(struct iris_batch *batch, return surf->surface_state_offset; } +static uint32_t +use_sampler_view(struct iris_batch *batch, struct iris_sampler_view *isv) +{ + struct iris_resource *res = (void *) isv->pipe.texture; + struct iris_resource *state_res = (void *) isv->surface_state_resource; + iris_use_pinned_bo(batch, res->bo, false); + iris_use_pinned_bo(batch, state_res->bo, false); + + return isv->surface_state_offset; +} + static void iris_upload_render_state(struct iris_context *ice, struct iris_batch *batch, @@ -2085,12 +2108,12 @@ iris_upload_render_state(struct iris_context *ice, } } -#if 0 - for (int i = 0; i < ice->state.num_samplers; i++) { - struct iris_sampler_view *view = SOMEWHERE; + for (int i = 0; i < ice->state.num_textures[stage]; i++) { + struct iris_sampler_view *view = ice->state.textures[stage][i]; struct iris_resource *res = (void *) view->pipe.texture; - *bt_map++ = use_surface(batch, isv, true); + *bt_map++ = use_sampler_view(batch, view); } +#if 0 // XXX: not implemented yet assert(prog_data->binding_table.pull_constants_start == 0xd0d0d0d0); -- 2.30.2