From: Marek Olšák Date: Mon, 2 Oct 2017 15:07:52 +0000 (+0200) Subject: radeonsi: inline struct si_sampler_views X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=15d918e46faf08be018394747f019b082871dccf;p=mesa.git radeonsi: inline struct si_sampler_views Reviewed-by: Samuel Pitoiset Reviewed-by: Nicolai Hähnle --- diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c index 957254be66c..67972a24ffb 100644 --- a/src/gallium/drivers/radeonsi/si_blit.c +++ b/src/gallium/drivers/radeonsi/si_blit.c @@ -80,10 +80,10 @@ static void si_blitter_begin(struct pipe_context *ctx, enum si_blitter_op op) if (op & SI_SAVE_TEXTURES) { util_blitter_save_fragment_sampler_states( sctx->blitter, 2, - (void**)sctx->samplers[PIPE_SHADER_FRAGMENT].views.sampler_states); + (void**)sctx->samplers[PIPE_SHADER_FRAGMENT].sampler_states); util_blitter_save_fragment_sampler_views(sctx->blitter, 2, - sctx->samplers[PIPE_SHADER_FRAGMENT].views.views); + sctx->samplers[PIPE_SHADER_FRAGMENT].views); } if (op & SI_DISABLE_RENDER_COND) @@ -433,7 +433,7 @@ si_decompress_sampler_depth_textures(struct si_context *sctx, i = u_bit_scan(&mask); - view = textures->views.views[i]; + view = textures->views[i]; assert(view); sview = (struct si_sampler_view*)view; @@ -559,7 +559,7 @@ si_decompress_sampler_color_textures(struct si_context *sctx, i = u_bit_scan(&mask); - view = textures->views.views[i]; + view = textures->views[i]; assert(view); tex = (struct r600_texture *)view->texture; @@ -629,7 +629,7 @@ static void si_check_render_feedback_texture(struct si_context *sctx, static void si_check_render_feedback_textures(struct si_context *sctx, struct si_samplers *textures) { - uint32_t mask = textures->views.enabled_mask; + uint32_t mask = textures->enabled_mask; while (mask) { const struct pipe_sampler_view *view; @@ -637,7 +637,7 @@ static void si_check_render_feedback_textures(struct si_context *sctx, unsigned i = u_bit_scan(&mask); - view = textures->views.views[i]; + view = textures->views[i]; if(view->texture->target == PIPE_BUFFER) continue; diff --git a/src/gallium/drivers/radeonsi/si_debug.c b/src/gallium/drivers/radeonsi/si_debug.c index 5075ccd26dd..ddf65d6d7e2 100644 --- a/src/gallium/drivers/radeonsi/si_debug.c +++ b/src/gallium/drivers/radeonsi/si_debug.c @@ -736,7 +736,7 @@ static void si_dump_descriptors(struct si_context *sctx, u_bit_consecutive(0, SI_NUM_SHADER_BUFFERS); enabled_shaderbuf = util_bitreverse(enabled_shaderbuf) >> (32 - SI_NUM_SHADER_BUFFERS); - enabled_samplers = sctx->samplers[processor].views.enabled_mask; + enabled_samplers = sctx->samplers[processor].enabled_mask; enabled_images = sctx->images[processor].enabled_mask; } diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 788e7c35f66..dee8e7138ff 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -194,12 +194,12 @@ si_sampler_and_image_descriptors(struct si_context *sctx, unsigned shader) return &sctx->descriptors[si_sampler_and_image_descriptors_idx(shader)]; } -static void si_release_sampler_views(struct si_sampler_views *views) +static void si_release_sampler_views(struct si_samplers *samplers) { int i; - for (i = 0; i < ARRAY_SIZE(views->views); i++) { - pipe_sampler_view_reference(&views->views[i], NULL); + for (i = 0; i < ARRAY_SIZE(samplers->views); i++) { + pipe_sampler_view_reference(&samplers->views[i], NULL); } } @@ -243,14 +243,14 @@ static void si_sampler_view_add_buffer(struct si_context *sctx, } static void si_sampler_views_begin_new_cs(struct si_context *sctx, - struct si_sampler_views *views) + struct si_samplers *samplers) { - unsigned mask = views->enabled_mask; + unsigned mask = samplers->enabled_mask; /* Add buffers to the CS. */ while (mask) { int i = u_bit_scan(&mask); - struct si_sampler_view *sview = (struct si_sampler_view *)views->views[i]; + struct si_sampler_view *sview = (struct si_sampler_view *)samplers->views[i]; si_sampler_view_add_buffer(sctx, sview->base.texture, RADEON_USAGE_READ, @@ -466,20 +466,19 @@ static void si_set_sampler_view(struct si_context *sctx, bool disallow_early_out) { struct si_samplers *samplers = &sctx->samplers[shader]; - struct si_sampler_views *views = &samplers->views; struct si_sampler_view *rview = (struct si_sampler_view*)view; struct si_descriptors *descs = si_sampler_and_image_descriptors(sctx, shader); unsigned desc_slot = si_get_sampler_slot(slot); uint32_t *desc = descs->list + desc_slot * 16; - if (views->views[slot] == view && !disallow_early_out) + if (samplers->views[slot] == view && !disallow_early_out) return; if (view) { struct r600_texture *rtex = (struct r600_texture *)view->texture; si_set_sampler_view_desc(sctx, rview, - views->sampler_states[slot], desc); + samplers->sampler_states[slot], desc); if (rtex->resource.b.b.target == PIPE_BUFFER) { rtex->resource.bind_history |= PIPE_BIND_SAMPLER_VIEW; @@ -502,8 +501,8 @@ static void si_set_sampler_view(struct si_context *sctx, sctx->need_check_render_feedback = true; } - pipe_sampler_view_reference(&views->views[slot], view); - views->enabled_mask |= 1u << slot; + pipe_sampler_view_reference(&samplers->views[slot], view); + samplers->enabled_mask |= 1u << slot; /* Since this can flush, it must be done after enabled_mask is * updated. */ @@ -511,16 +510,16 @@ static void si_set_sampler_view(struct si_context *sctx, RADEON_USAGE_READ, rview->is_stencil_sampler, true); } else { - pipe_sampler_view_reference(&views->views[slot], NULL); + pipe_sampler_view_reference(&samplers->views[slot], NULL); memcpy(desc, null_texture_descriptor, 8*4); /* Only clear the lower dwords of FMASK. */ memcpy(desc + 8, null_texture_descriptor, 4*4); /* Re-set the sampler state if we are transitioning from FMASK. */ - if (views->sampler_states[slot]) - si_set_sampler_state_desc(views->sampler_states[slot], NULL, NULL, + if (samplers->sampler_states[slot]) + si_set_sampler_state_desc(samplers->sampler_states[slot], NULL, NULL, desc + 12); - views->enabled_mask &= ~(1u << slot); + samplers->enabled_mask &= ~(1u << slot); samplers->needs_depth_decompress_mask &= ~(1u << slot); samplers->needs_color_decompress_mask &= ~(1u << slot); } @@ -567,11 +566,11 @@ static void si_set_sampler_views(struct pipe_context *ctx, static void si_samplers_update_needs_color_decompress_mask(struct si_samplers *samplers) { - unsigned mask = samplers->views.enabled_mask; + unsigned mask = samplers->enabled_mask; while (mask) { int i = u_bit_scan(&mask); - struct pipe_resource *res = samplers->views.views[i]->texture; + struct pipe_resource *res = samplers->views[i]->texture; if (res && res->target != PIPE_BUFFER) { struct r600_texture *rtex = (struct r600_texture *)res; @@ -842,19 +841,19 @@ static void si_bind_sampler_states(struct pipe_context *ctx, unsigned desc_slot = si_get_sampler_slot(slot); if (!sstates[i] || - sstates[i] == samplers->views.sampler_states[slot]) + sstates[i] == samplers->sampler_states[slot]) continue; #ifdef DEBUG assert(sstates[i]->magic == SI_SAMPLER_STATE_MAGIC); #endif - samplers->views.sampler_states[slot] = sstates[i]; + samplers->sampler_states[slot] = sstates[i]; /* If FMASK is bound, don't overwrite it. * The sampler state will be set after FMASK is unbound. */ struct si_sampler_view *sview = - (struct si_sampler_view *)samplers->views.views[slot]; + (struct si_sampler_view *)samplers->views[slot]; struct r600_texture *tex = NULL; @@ -1683,14 +1682,14 @@ static void si_rebind_buffer(struct pipe_context *ctx, struct pipe_resource *buf if (rbuffer->bind_history & PIPE_BIND_SAMPLER_VIEW) { /* Texture buffers - update bindings. */ for (shader = 0; shader < SI_NUM_SHADERS; shader++) { - struct si_sampler_views *views = &sctx->samplers[shader].views; + struct si_samplers *samplers = &sctx->samplers[shader]; struct si_descriptors *descs = si_sampler_and_image_descriptors(sctx, shader); - unsigned mask = views->enabled_mask; + unsigned mask = samplers->enabled_mask; while (mask) { unsigned i = u_bit_scan(&mask); - if (views->views[i]->texture == buf) { + if (samplers->views[i]->texture == buf) { unsigned desc_slot = si_get_sampler_slot(i); si_desc_reset_buffer_offset(ctx, @@ -1948,7 +1947,7 @@ void si_update_all_texture_descriptors(struct si_context *sctx) unsigned shader; for (shader = 0; shader < SI_NUM_SHADERS; shader++) { - struct si_sampler_views *samplers = &sctx->samplers[shader].views; + struct si_samplers *samplers = &sctx->samplers[shader]; struct si_images *images = &sctx->images[shader]; unsigned mask; @@ -2771,7 +2770,7 @@ void si_release_all_descriptors(struct si_context *sctx) for (i = 0; i < SI_NUM_SHADERS; i++) { si_release_buffer_resources(&sctx->const_and_shader_buffers[i], si_const_and_shader_buffer_descriptors(sctx, i)); - si_release_sampler_views(&sctx->samplers[i].views); + si_release_sampler_views(&sctx->samplers[i]); si_release_image_views(&sctx->images[i]); } si_release_buffer_resources(&sctx->rw_buffers, @@ -2793,7 +2792,7 @@ void si_all_descriptors_begin_new_cs(struct si_context *sctx) for (i = 0; i < SI_NUM_SHADERS; i++) { si_buffer_resources_begin_new_cs(sctx, &sctx->const_and_shader_buffers[i]); - si_sampler_views_begin_new_cs(sctx, &sctx->samplers[i].views); + si_sampler_views_begin_new_cs(sctx, &sctx->samplers[i]); si_image_views_begin_new_cs(sctx, &sctx->images[i]); } si_buffer_resources_begin_new_cs(sctx, &sctx->rw_buffers); diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 212d163686c..b96bf9d2fe1 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -182,7 +182,11 @@ struct si_cs_shader_state { }; struct si_samplers { - struct si_sampler_views views; + struct pipe_sampler_view *views[SI_NUM_SAMPLERS]; + struct si_sampler_state *sampler_states[SI_NUM_SAMPLERS]; + + /* The i-th bit is set if that element is enabled (non-NULL resource). */ + unsigned enabled_mask; uint32_t needs_depth_decompress_mask; uint32_t needs_color_decompress_mask; }; diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 8e414a0817c..3277926ba3c 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -276,14 +276,6 @@ struct si_descriptors { ubyte shader_userdata_offset; }; -struct si_sampler_views { - struct pipe_sampler_view *views[SI_NUM_SAMPLERS]; - struct si_sampler_state *sampler_states[SI_NUM_SAMPLERS]; - - /* The i-th bit is set if that element is enabled (non-NULL resource). */ - unsigned enabled_mask; -}; - struct si_buffer_resources { struct pipe_resource **buffers; /* this has num_buffers elements */