radeonsi: track use of bindless samplers/images from tgsi_shader_info

This adds some new helper functions to know if the current draw
call (or dispatch compute) is using bindless samplers/images,
based on TGSI analysis.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Samuel Pitoiset 2017-05-16 12:25:28 +02:00
parent e1813a8635
commit 2c3a7d5840
5 changed files with 46 additions and 5 deletions

View file

@ -108,6 +108,8 @@ static void si_create_compute_state_async(void *job, int thread_index)
program->shader.is_monolithic = true;
program->uses_grid_size = sel.info.uses_grid_size;
program->uses_block_size = sel.info.uses_block_size;
program->uses_bindless_samplers = sel.info.uses_bindless_samplers;
program->uses_bindless_images = sel.info.uses_bindless_images;
if (si_shader_create(program->screen, tm, &program->shader, debug)) {
program->shader.compilation_failed = true;

View file

@ -49,6 +49,8 @@ struct si_compute {
unsigned variable_group_size : 1;
unsigned uses_grid_size:1;
unsigned uses_block_size:1;
unsigned uses_bindless_samplers:1;
unsigned uses_bindless_images:1;
};
#endif /* SI_COMPUTE_H */

View file

@ -428,6 +428,10 @@ struct si_context {
/* Resident bindless handles */
struct util_dynarray resident_tex_handles;
struct util_dynarray resident_img_handles;
/* Bindless state */
bool uses_bindless_samplers;
bool uses_bindless_images;
};
/* cik_sdma.c */

View file

@ -630,4 +630,16 @@ si_get_main_shader_part(struct si_shader_selector *sel,
return &sel->main_shader_part;
}
static inline bool
si_shader_uses_bindless_samplers(struct si_shader_selector *selector)
{
return selector ? selector->info.uses_bindless_samplers : false;
}
static inline bool
si_shader_uses_bindless_images(struct si_shader_selector *selector)
{
return selector ? selector->info.uses_bindless_images : false;
}
#endif

View file

@ -2202,6 +2202,23 @@ static void si_update_clip_regs(struct si_context *sctx,
si_mark_atom_dirty(sctx, &sctx->clip_regs);
}
static void si_update_common_shader_state(struct si_context *sctx)
{
sctx->uses_bindless_samplers =
si_shader_uses_bindless_samplers(sctx->vs_shader.cso) ||
si_shader_uses_bindless_samplers(sctx->gs_shader.cso) ||
si_shader_uses_bindless_samplers(sctx->ps_shader.cso) ||
si_shader_uses_bindless_samplers(sctx->tcs_shader.cso) ||
si_shader_uses_bindless_samplers(sctx->tes_shader.cso);
sctx->uses_bindless_images =
si_shader_uses_bindless_images(sctx->vs_shader.cso) ||
si_shader_uses_bindless_images(sctx->gs_shader.cso) ||
si_shader_uses_bindless_images(sctx->ps_shader.cso) ||
si_shader_uses_bindless_images(sctx->tcs_shader.cso) ||
si_shader_uses_bindless_images(sctx->tes_shader.cso);
sctx->do_update_shaders = true;
}
static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
{
struct si_context *sctx = (struct si_context *)ctx;
@ -2214,7 +2231,8 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
sctx->vs_shader.cso = sel;
sctx->vs_shader.current = sel ? sel->first_variant : NULL;
sctx->do_update_shaders = true;
si_update_common_shader_state(sctx);
r600_update_vs_writes_viewport_index(&sctx->b, si_get_vs_info(sctx));
si_set_active_descriptors_for_shader(sctx, sel);
si_update_streamout_state(sctx);
@ -2249,7 +2267,8 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
sctx->gs_shader.cso = sel;
sctx->gs_shader.current = sel ? sel->first_variant : NULL;
sctx->ia_multi_vgt_param_key.u.uses_gs = sel != NULL;
sctx->do_update_shaders = true;
si_update_common_shader_state(sctx);
sctx->last_rast_prim = -1; /* reset this so that it gets updated */
if (enable_changed) {
@ -2276,7 +2295,8 @@ static void si_bind_tcs_shader(struct pipe_context *ctx, void *state)
sctx->tcs_shader.cso = sel;
sctx->tcs_shader.current = sel ? sel->first_variant : NULL;
si_update_tess_uses_prim_id(sctx);
sctx->do_update_shaders = true;
si_update_common_shader_state(sctx);
if (enable_changed)
sctx->last_tcs = NULL; /* invalidate derived tess state */
@ -2299,7 +2319,8 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state)
sctx->tes_shader.current = sel ? sel->first_variant : NULL;
sctx->ia_multi_vgt_param_key.u.uses_tess = sel != NULL;
si_update_tess_uses_prim_id(sctx);
sctx->do_update_shaders = true;
si_update_common_shader_state(sctx);
sctx->last_rast_prim = -1; /* reset this so that it gets updated */
if (enable_changed) {
@ -2325,8 +2346,8 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
sctx->ps_shader.cso = sel;
sctx->ps_shader.current = sel ? sel->first_variant : NULL;
sctx->do_update_shaders = true;
si_update_common_shader_state(sctx);
if (sel) {
if (sctx->ia_multi_vgt_param_key.u.uses_tess)
si_update_tess_uses_prim_id(sctx);