summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/radeonsi
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>2021-02-12 14:42:10 +0100
committerMarge Bot <eric+marge@anholt.net>2021-02-17 09:11:46 +0000
commita8373b3d3876afa960ead3378adacc43afcec6ed (patch)
treed9b649531e823d777f73ac8b7637668a844d4b6b /src/gallium/drivers/radeonsi
parent47ed0091943871a6370a3ad5a0c5f510da272c45 (diff)
radeonsi: store si_context::xxx_shader members in union
This allows to access them individually (sctx->shader.ps) or using array indexing (sctx->shaders[PIPE_SHADER_FRAGMENT]). Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8869>
Diffstat (limited to 'src/gallium/drivers/radeonsi')
-rw-r--r--src/gallium/drivers/radeonsi/si_blit.c10
-rw-r--r--src/gallium/drivers/radeonsi/si_compute_prim_discard.c6
-rw-r--r--src/gallium/drivers/radeonsi/si_debug.c30
-rw-r--r--src/gallium/drivers/radeonsi/si_descriptors.c24
-rw-r--r--src/gallium/drivers/radeonsi/si_pipe.h31
-rw-r--r--src/gallium/drivers/radeonsi/si_state.c10
-rw-r--r--src/gallium/drivers/radeonsi/si_state_draw.cpp32
-rw-r--r--src/gallium/drivers/radeonsi/si_state_shaders.c243
8 files changed, 189 insertions, 197 deletions
diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index eba077d8b35..1051ff465ad 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -43,10 +43,10 @@ enum
void si_blitter_begin(struct si_context *sctx, enum si_blitter_op op)
{
- util_blitter_save_vertex_shader(sctx->blitter, sctx->vs_shader.cso);
- util_blitter_save_tessctrl_shader(sctx->blitter, sctx->tcs_shader.cso);
- util_blitter_save_tesseval_shader(sctx->blitter, sctx->tes_shader.cso);
- util_blitter_save_geometry_shader(sctx->blitter, sctx->gs_shader.cso);
+ util_blitter_save_vertex_shader(sctx->blitter, sctx->shader.vs.cso);
+ util_blitter_save_tessctrl_shader(sctx->blitter, sctx->shader.tcs.cso);
+ util_blitter_save_tesseval_shader(sctx->blitter, sctx->shader.tes.cso);
+ util_blitter_save_geometry_shader(sctx->blitter, sctx->shader.gs.cso);
util_blitter_save_so_targets(sctx->blitter, sctx->streamout.num_targets,
(struct pipe_stream_output_target **)sctx->streamout.targets);
util_blitter_save_rasterizer(sctx->blitter, sctx->queued.named.rasterizer);
@@ -55,7 +55,7 @@ void si_blitter_begin(struct si_context *sctx, enum si_blitter_op op)
util_blitter_save_blend(sctx->blitter, sctx->queued.named.blend);
util_blitter_save_depth_stencil_alpha(sctx->blitter, sctx->queued.named.dsa);
util_blitter_save_stencil_ref(sctx->blitter, &sctx->stencil_ref.state);
- util_blitter_save_fragment_shader(sctx->blitter, sctx->ps_shader.cso);
+ util_blitter_save_fragment_shader(sctx->blitter, sctx->shader.ps.cso);
util_blitter_save_sample_mask(sctx->blitter, sctx->sample_mask);
util_blitter_save_scissor(sctx->blitter, &sctx->scissors[0]);
util_blitter_save_window_rectangles(sctx->blitter, sctx->window_rectangles_include,
diff --git a/src/gallium/drivers/radeonsi/si_compute_prim_discard.c b/src/gallium/drivers/radeonsi/si_compute_prim_discard.c
index 4b4bfe7f7cd..1cf79929e0c 100644
--- a/src/gallium/drivers/radeonsi/si_compute_prim_discard.c
+++ b/src/gallium/drivers/radeonsi/si_compute_prim_discard.c
@@ -846,7 +846,7 @@ static bool si_shader_select_prim_discard_cs(struct si_context *sctx,
assert(!primitive_restart || info->instance_count == 1);
memset(&key, 0, sizeof(key));
- si_shader_selector_key_vs(sctx, sctx->vs_shader.cso, &key, &key.part.vs.prolog);
+ si_shader_selector_key_vs(sctx, sctx->shader.vs.cso, &key, &key.part.vs.prolog);
assert(!key.part.vs.prolog.instance_divisor_is_fetched);
key.part.vs.prolog.unpack_instance_id_from_vertex_id = 0;
@@ -861,7 +861,7 @@ static bool si_shader_select_prim_discard_cs(struct si_context *sctx,
* orientation for cases where front and back primitive orientation matters.
*/
if (primitive_restart) {
- struct si_shader_selector *ps = sctx->ps_shader.cso;
+ struct si_shader_selector *ps = sctx->shader.ps.cso;
key.opt.cs_need_correct_orientation = rs->cull_front != rs->cull_back ||
ps->info.uses_frontface ||
@@ -883,7 +883,7 @@ static bool si_shader_select_prim_discard_cs(struct si_context *sctx,
key.opt.cs_halfz_clip_space = rs->clip_halfz;
}
- sctx->cs_prim_discard_state.cso = sctx->vs_shader.cso;
+ sctx->cs_prim_discard_state.cso = sctx->shader.vs.cso;
sctx->cs_prim_discard_state.current = NULL;
if (!sctx->compiler.passes)
diff --git a/src/gallium/drivers/radeonsi/si_debug.c b/src/gallium/drivers/radeonsi/si_debug.c
index f1e9db55a2d..241ad8977e7 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -1012,11 +1012,11 @@ static void si_dump_annotated_shaders(struct si_context *sctx, FILE *f)
fprintf(f, COLOR_CYAN "The number of active waves = %u" COLOR_RESET "\n\n", num_waves);
- si_print_annotated_shader(sctx->vs_shader.current, waves, num_waves, f);
- si_print_annotated_shader(sctx->tcs_shader.current, waves, num_waves, f);
- si_print_annotated_shader(sctx->tes_shader.current, waves, num_waves, f);
- si_print_annotated_shader(sctx->gs_shader.current, waves, num_waves, f);
- si_print_annotated_shader(sctx->ps_shader.current, waves, num_waves, f);
+ si_print_annotated_shader(sctx->shader.vs.current, waves, num_waves, f);
+ si_print_annotated_shader(sctx->shader.tcs.current, waves, num_waves, f);
+ si_print_annotated_shader(sctx->shader.tes.current, waves, num_waves, f);
+ si_print_annotated_shader(sctx->shader.gs.current, waves, num_waves, f);
+ si_print_annotated_shader(sctx->shader.ps.current, waves, num_waves, f);
/* Print waves executing shaders that are not currently bound. */
unsigned i;
@@ -1077,26 +1077,26 @@ void si_log_draw_state(struct si_context *sctx, struct u_log_context *log)
if (!log)
return;
- tcs_shader = &sctx->tcs_shader;
- if (sctx->tes_shader.cso && !sctx->tcs_shader.cso)
+ tcs_shader = &sctx->shader.tcs;
+ if (sctx->shader.tes.cso && !sctx->shader.tcs.cso)
tcs_shader = &sctx->fixed_func_tcs_shader;
si_dump_framebuffer(sctx, log);
- si_dump_gfx_shader(sctx, &sctx->vs_shader, log);
+ si_dump_gfx_shader(sctx, &sctx->shader.vs, log);
si_dump_gfx_shader(sctx, tcs_shader, log);
- si_dump_gfx_shader(sctx, &sctx->tes_shader, log);
- si_dump_gfx_shader(sctx, &sctx->gs_shader, log);
- si_dump_gfx_shader(sctx, &sctx->ps_shader, log);
+ si_dump_gfx_shader(sctx, &sctx->shader.tes, log);
+ si_dump_gfx_shader(sctx, &sctx->shader.gs, log);
+ si_dump_gfx_shader(sctx, &sctx->shader.ps, log);
si_dump_descriptor_list(sctx->screen, &sctx->descriptors[SI_DESCS_INTERNAL], "", "RW buffers",
4, sctx->descriptors[SI_DESCS_INTERNAL].num_active_slots, si_identity,
log);
- si_dump_gfx_descriptors(sctx, &sctx->vs_shader, log);
+ si_dump_gfx_descriptors(sctx, &sctx->shader.vs, log);
si_dump_gfx_descriptors(sctx, tcs_shader, log);
- si_dump_gfx_descriptors(sctx, &sctx->tes_shader, log);
- si_dump_gfx_descriptors(sctx, &sctx->gs_shader, log);
- si_dump_gfx_descriptors(sctx, &sctx->ps_shader, log);
+ si_dump_gfx_descriptors(sctx, &sctx->shader.tes, log);
+ si_dump_gfx_descriptors(sctx, &sctx->shader.gs, log);
+ si_dump_gfx_descriptors(sctx, &sctx->shader.ps, log);
}
void si_log_compute_state(struct si_context *sctx, struct u_log_context *log)
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index fb1813020ab..8c8ce9e7d38 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -869,7 +869,7 @@ void si_update_ps_colorbuf0_slot(struct si_context *sctx)
return;
/* See whether FBFETCH is used and color buffer 0 is set. */
- if (sctx->ps_shader.cso && sctx->ps_shader.cso->info.base.fs.uses_fbfetch_output &&
+ if (sctx->shader.ps.cso && sctx->shader.ps.cso->info.base.fs.uses_fbfetch_output &&
sctx->framebuffer.state.nr_cbufs && sctx->framebuffer.state.cbufs[0])
surf = sctx->framebuffer.state.cbufs[0];
@@ -1934,15 +1934,15 @@ void si_shader_change_notify(struct si_context *sctx)
{
si_set_user_data_base(sctx, PIPE_SHADER_VERTEX,
si_get_user_data_base(sctx->chip_class,
- sctx->tes_shader.cso ? TESS_ON : TESS_OFF,
- sctx->gs_shader.cso ? GS_ON : GS_OFF,
+ sctx->shader.tes.cso ? TESS_ON : TESS_OFF,
+ sctx->shader.gs.cso ? GS_ON : GS_OFF,
sctx->ngg ? NGG_ON : NGG_OFF,
PIPE_SHADER_VERTEX));
si_set_user_data_base(sctx, PIPE_SHADER_TESS_EVAL,
si_get_user_data_base(sctx->chip_class,
- sctx->tes_shader.cso ? TESS_ON : TESS_OFF,
- sctx->gs_shader.cso ? GS_ON : GS_OFF,
+ sctx->shader.tes.cso ? TESS_ON : TESS_OFF,
+ sctx->shader.gs.cso ? GS_ON : GS_OFF,
sctx->ngg ? NGG_ON : NGG_OFF,
PIPE_SHADER_TESS_EVAL));
}
@@ -2651,25 +2651,19 @@ void si_release_all_descriptors(struct si_context *sctx)
bool si_gfx_resources_check_encrypted(struct si_context *sctx)
{
bool use_encrypted_bo = false;
- struct si_shader_ctx_state *current_shader[SI_NUM_SHADERS] = {
- [PIPE_SHADER_VERTEX] = &sctx->vs_shader,
- [PIPE_SHADER_TESS_CTRL] = &sctx->tcs_shader,
- [PIPE_SHADER_TESS_EVAL] = &sctx->tes_shader,
- [PIPE_SHADER_GEOMETRY] = &sctx->gs_shader,
- [PIPE_SHADER_FRAGMENT] = &sctx->ps_shader,
- };
for (unsigned i = 0; i < SI_NUM_GRAPHICS_SHADERS && !use_encrypted_bo; i++) {
- if (!current_shader[i]->cso)
+ struct si_shader_ctx_state *current_shader = &sctx->shaders[i];
+ if (!current_shader->cso)
continue;
use_encrypted_bo |=
si_buffer_resources_check_encrypted(sctx, &sctx->const_and_shader_buffers[i]);
use_encrypted_bo |=
si_sampler_views_check_encrypted(sctx, &sctx->samplers[i],
- current_shader[i]->cso->info.base.textures_used);
+ current_shader->cso->info.base.textures_used);
use_encrypted_bo |= si_image_views_check_encrypted(sctx, &sctx->images[i],
- u_bit_consecutive(0, current_shader[i]->cso->info.base.num_images));
+ u_bit_consecutive(0, current_shader->cso->info.base.num_images));
}
use_encrypted_bo |= si_buffer_resources_check_encrypted(sctx, &sctx->internal_bindings);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index d725a5b17a4..27da51eaff8 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -1042,11 +1042,16 @@ struct si_context {
struct si_pm4_state *vgt_shader_config[SI_NUM_VGT_STAGES_STATES];
/* shaders */
- struct si_shader_ctx_state ps_shader;
- struct si_shader_ctx_state gs_shader;
- struct si_shader_ctx_state vs_shader;
- struct si_shader_ctx_state tcs_shader;
- struct si_shader_ctx_state tes_shader;
+ union {
+ struct {
+ struct si_shader_ctx_state vs;
+ struct si_shader_ctx_state ps;
+ struct si_shader_ctx_state gs;
+ struct si_shader_ctx_state tcs;
+ struct si_shader_ctx_state tes;
+ } shader;
+ struct si_shader_ctx_state shaders[SI_NUM_GRAPHICS_SHADERS];
+ };
struct si_shader_ctx_state cs_prim_discard_state;
struct si_cs_shader_state cs_shader_state;
@@ -1684,17 +1689,17 @@ static ALWAYS_INLINE struct si_shader_ctx_state *
si_get_vs_inline(struct si_context *sctx, enum si_has_tess has_tess, enum si_has_gs has_gs)
{
if (has_gs)
- return &sctx->gs_shader;
+ return &sctx->shader.gs;
if (has_tess)
- return &sctx->tes_shader;
+ return &sctx->shader.tes;
- return &sctx->vs_shader;
+ return &sctx->shader.vs;
}
static inline struct si_shader_ctx_state *si_get_vs(struct si_context *sctx)
{
- return si_get_vs_inline(sctx, sctx->tes_shader.cso ? TESS_ON : TESS_OFF,
- sctx->gs_shader.cso ? GS_ON : GS_OFF);
+ return si_get_vs_inline(sctx, sctx->shader.tes.cso ? TESS_ON : TESS_OFF,
+ sctx->shader.gs.cso ? GS_ON : GS_OFF);
}
static inline struct si_shader_info *si_get_vs_info(struct si_context *sctx)
@@ -1819,7 +1824,7 @@ static inline unsigned si_get_total_colormask(struct si_context *sctx)
if (sctx->queued.named.rasterizer->rasterizer_discard)
return 0;
- struct si_shader_selector *ps = sctx->ps_shader.cso;
+ struct si_shader_selector *ps = sctx->shader.ps.cso;
if (!ps)
return 0;
@@ -1962,8 +1967,8 @@ static inline unsigned si_get_shader_wave_size(struct si_shader *shader)
static inline void si_select_draw_vbo(struct si_context *sctx)
{
sctx->b.draw_vbo = sctx->draw_vbo[sctx->chip_class - GFX6]
- [!!sctx->tes_shader.cso]
- [!!sctx->gs_shader.cso]
+ [!!sctx->shader.tes.cso]
+ [!!sctx->shader.gs.cso]
[sctx->ngg]
[si_compute_prim_discard_enabled(sctx)];
assert(sctx->b.draw_vbo);
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 57b3c940ea7..fb90fc80511 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -81,8 +81,8 @@ static void si_emit_cb_render_state(struct si_context *sctx)
*
* Reproducible with Unigine Heaven 4.0 and drirc missing.
*/
- if (blend->dual_src_blend && sctx->ps_shader.cso &&
- (sctx->ps_shader.cso->info.colors_written & 0x3) != 0x3)
+ if (blend->dual_src_blend && sctx->shader.ps.cso &&
+ (sctx->shader.ps.cso->info.colors_written & 0x3) != 0x3)
cb_target_mask = 0;
/* GFX9: Flush DFSM when CB_TARGET_MASK changes.
@@ -121,7 +121,7 @@ static void si_emit_cb_render_state(struct si_context *sctx)
/* RB+ register settings. */
if (sctx->screen->info.rbplus_allowed) {
unsigned spi_shader_col_format =
- sctx->ps_shader.cso ? sctx->ps_shader.current->key.part.ps.epilog.spi_shader_col_format
+ sctx->shader.ps.cso ? sctx->shader.ps.current->key.part.ps.epilog.spi_shader_col_format
: 0;
unsigned sx_ps_downconvert = 0;
unsigned sx_blend_opt_epsilon = 0;
@@ -3387,8 +3387,8 @@ static bool si_out_of_order_rasterization(struct si_context *sctx)
/* The set of PS invocations is always order invariant,
* except when early Z/S tests are requested. */
- if (sctx->ps_shader.cso && sctx->ps_shader.cso->info.base.writes_memory &&
- sctx->ps_shader.cso->info.base.fs.early_fragment_tests &&
+ if (sctx->shader.ps.cso && sctx->shader.ps.cso->info.base.writes_memory &&
+ sctx->shader.ps.cso->info.base.fs.early_fragment_tests &&
!dsa_order_invariant.pass_set)
return false;
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.cpp b/src/gallium/drivers/radeonsi/si_state_draw.cpp
index 0259620ce69..a7aa9612e6c 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.cpp
+++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp
@@ -188,22 +188,22 @@ static void si_emit_derived_tess_state(struct si_context *sctx,
/* The TES pointer will only be used for sctx->last_tcs.
* It would be wrong to think that TCS = TES. */
struct si_shader_selector *tcs =
- sctx->tcs_shader.cso ? sctx->tcs_shader.cso : sctx->tes_shader.cso;
+ sctx->shader.tcs.cso ? sctx->shader.tcs.cso : sctx->shader.tes.cso;
unsigned tess_uses_primid = sctx->ia_multi_vgt_param_key.u.tess_uses_prim_id;
bool has_primid_instancing_bug = sctx->chip_class == GFX6 && sctx->screen->info.max_se == 1;
unsigned tes_sh_base = sctx->shader_pointers.sh_base[PIPE_SHADER_TESS_EVAL];
/* Since GFX9 has merged LS-HS in the TCS state, set LS = TCS. */
if (sctx->chip_class >= GFX9) {
- if (sctx->tcs_shader.cso)
- ls_current = sctx->tcs_shader.current;
+ if (sctx->shader.tcs.cso)
+ ls_current = sctx->shader.tcs.current;
else
ls_current = sctx->fixed_func_tcs_shader.current;
ls = ls_current->key.part.tcs.ls;
} else {
- ls_current = sctx->vs_shader.current;
- ls = sctx->vs_shader.cso;
+ ls_current = sctx->shader.vs.current;
+ ls = sctx->shader.vs.cso;
}
if (sctx->last_ls == ls_current && sctx->last_tcs == tcs &&
@@ -224,7 +224,7 @@ static void si_emit_derived_tess_state(struct si_context *sctx,
unsigned num_tcs_inputs = util_last_bit64(ls->outputs_written);
unsigned num_tcs_output_cp, num_tcs_outputs, num_tcs_patch_outputs;
- if (sctx->tcs_shader.cso) {
+ if (sctx->shader.tcs.cso) {
num_tcs_outputs = util_last_bit64(tcs->outputs_written);
num_tcs_output_cp = tcs->info.base.tess.tcs_vertices_out;
num_tcs_patch_outputs = util_last_bit64(tcs->patch_outputs_written);
@@ -777,7 +777,7 @@ static void si_emit_vs_state(struct si_context *sctx, unsigned index_size)
return;
}
- if (sctx->vs_shader.cso->info.uses_base_vertex) {
+ if (sctx->shader.vs.cso->info.uses_base_vertex) {
sctx->current_vs_state &= C_VS_STATE_INDEXED;
sctx->current_vs_state |= S_VS_STATE_INDEXED(!!index_size);
}
@@ -879,7 +879,7 @@ static void gfx10_emit_ge_cntl(struct si_context *sctx, unsigned num_patches)
primgroup_size = num_patches; /* must be a multiple of NUM_PATCHES */
vertgroup_size = 0;
} else if (HAS_GS) {
- unsigned vgt_gs_onchip_cntl = sctx->gs_shader.current->ctx_reg.gs.vgt_gs_onchip_cntl;
+ unsigned vgt_gs_onchip_cntl = sctx->shader.gs.current->ctx_reg.gs.vgt_gs_onchip_cntl;
primgroup_size = G_028A44_GS_PRIMS_PER_SUBGRP(vgt_gs_onchip_cntl);
vertgroup_size = G_028A44_ES_VERTS_PER_SUBGRP(vgt_gs_onchip_cntl);
} else {
@@ -1115,7 +1115,7 @@ static void si_emit_draw_packets(struct si_context *sctx, const struct pipe_draw
radeon_emit(cs, (sh_base_reg + SI_SGPR_BASE_VERTEX * 4 - SI_SH_REG_OFFSET) >> 2);
radeon_emit(cs, (sh_base_reg + SI_SGPR_START_INSTANCE * 4 - SI_SH_REG_OFFSET) >> 2);
radeon_emit(cs, ((sh_base_reg + SI_SGPR_DRAWID * 4 - SI_SH_REG_OFFSET) >> 2) |
- S_2C3_DRAW_INDEX_ENABLE(sctx->vs_shader.cso->info.uses_drawid) |
+ S_2C3_DRAW_INDEX_ENABLE(sctx->shader.vs.cso->info.uses_drawid) |
S_2C3_COUNT_INDIRECT_ENABLE(!!indirect->indirect_draw_count));
radeon_emit(cs, indirect->draw_count);
radeon_emit(cs, count_va);
@@ -1580,7 +1580,7 @@ static bool si_all_vs_resources_read_only(struct si_context *sctx, struct pipe_r
struct radeon_cmdbuf *cs = &sctx->gfx_cs;
struct si_descriptors *buffers =
&sctx->descriptors[si_const_and_shader_buffer_descriptors_idx(PIPE_SHADER_VERTEX)];
- struct si_shader_selector *vs = sctx->vs_shader.cso;
+ struct si_shader_selector *vs = sctx->shader.vs.cso;
struct si_vertex_elements *velems = sctx->vertex_elements;
unsigned num_velems = velems->count;
unsigned num_images = vs->info.base.num_images;
@@ -1712,7 +1712,7 @@ static void si_draw_vbo(struct pipe_context *ctx,
}
if (HAS_TESS) {
- struct si_shader_selector *tcs = sctx->tcs_shader.cso;
+ struct si_shader_selector *tcs = sctx->shader.tcs.cso;
/* The rarely occuring tcs == NULL case is not optimized. */
bool same_patch_vertices =
@@ -1752,9 +1752,9 @@ static void si_draw_vbo(struct pipe_context *ctx,
if (GFX_VERSION <= GFX7 && unlikely(!indirect && !instance_count))
return;
- struct si_shader_selector *vs = sctx->vs_shader.cso;
+ struct si_shader_selector *vs = sctx->shader.vs.cso;
if (unlikely(!vs || sctx->num_vertex_elements < vs->num_vs_inputs ||
- !sctx->ps_shader.cso || (HAS_TESS != (prim == PIPE_PRIM_PATCHES)))) {
+ !sctx->shader.ps.cso || (HAS_TESS != (prim == PIPE_PRIM_PATCHES)))) {
assert(0);
return;
}
@@ -1888,7 +1888,7 @@ static void si_draw_vbo(struct pipe_context *ctx,
(instance_count <= USHRT_MAX && index_size && index_size <= 2) ||
pd_msg("instance_count too large or index_size == 4 or DrawArraysInstanced"))) &&
((info->drawid == 0 && (num_draws == 1 || !info->increment_draw_id)) ||
- !sctx->vs_shader.cso->info.uses_drawid || pd_msg("draw_id > 0")) &&
+ !sctx->shader.vs.cso->info.uses_drawid || pd_msg("draw_id > 0")) &&
(!sctx->render_cond || pd_msg("render condition")) &&
/* Forced enablement ignores pipeline statistics queries. */
(sctx->screen->debug_flags & (DBG(PD) | DBG(ALWAYS_PD)) ||
@@ -1897,7 +1897,7 @@ static void si_draw_vbo(struct pipe_context *ctx,
(!sctx->vertex_elements->instance_divisor_is_fetched || pd_msg("loads instance divisors")) &&
(!HAS_TESS || pd_msg("uses tess")) &&
(!HAS_GS || pd_msg("uses GS")) &&
- (!sctx->ps_shader.cso->info.uses_primid || pd_msg("PS uses PrimID")) &&
+ (!sctx->shader.ps.cso->info.uses_primid || pd_msg("PS uses PrimID")) &&
!rs->polygon_mode_enabled &&
#if SI_PRIM_DISCARD_DEBUG /* same as cso->prim_discard_cs_allowed */
(!sctx->vs_shader.cso->info.uses_bindless_images || pd_msg("uses bindless images")) &&
@@ -1907,7 +1907,7 @@ static void si_draw_vbo(struct pipe_context *ctx,
!sctx->vs_shader.cso->info.base.vs.window_space_position &&
!sctx->vs_shader.cso->so.num_outputs &&
#else
- (sctx->vs_shader.cso->prim_discard_cs_allowed ||
+ (sctx->shader.vs.cso->prim_discard_cs_allowed ||
pd_msg("VS shader uses unsupported features")) &&
#endif
/* Check that all buffers are used for read only, because compute
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 34434094dcb..b8f054e8304 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1777,7 +1777,7 @@ void si_shader_selector_key_vs(struct si_context *sctx, struct si_shader_selecto
static void si_shader_selector_key_hw_vs(struct si_context *sctx, struct si_shader_selector *vs,
struct si_shader_key *key)
{
- struct si_shader_selector *ps = sctx->ps_shader.cso;
+ struct si_shader_selector *ps = sctx->shader.ps.cso;
key->opt.kill_clip_distances = vs->clipdist_mask & ~sctx->queued.named.rasterizer->clip_plane_enable;
@@ -1814,7 +1814,7 @@ static void si_shader_selector_key_hw_vs(struct si_context *sctx, struct si_shad
if (vs->info.stage != MESA_SHADER_GEOMETRY) {
key->opt.ngg_culling = sctx->ngg_culling;
- if (sctx->ps_shader.cso && sctx->ps_shader.cso->info.uses_primid)
+ if (sctx->shader.ps.cso && sctx->shader.ps.cso->info.uses_primid)
key->mono.u.vs_export_prim_id = 1;
}
@@ -1848,9 +1848,9 @@ static inline void si_shader_selector_key(struct pipe_context *ctx, struct si_sh
case MESA_SHADER_VERTEX:
si_shader_selector_key_vs(sctx, sel, key, &key->part.vs.prolog);
- if (sctx->tes_shader.cso)
+ if (sctx->shader.tes.cso)
key->as_ls = 1;
- else if (sctx->gs_shader.cso) {
+ else if (sctx->shader.gs.cso) {
key->as_es = 1;
key->as_ngg = stages_key.u.ngg;
} else {
@@ -1860,8 +1860,8 @@ static inline void si_shader_selector_key(struct pipe_context *ctx, struct si_sh
break;
case MESA_SHADER_TESS_CTRL:
if (sctx->chip_class >= GFX9) {
- si_shader_selector_key_vs(sctx, sctx->vs_shader.cso, key, &key->part.tcs.ls_prolog);
- key->part.tcs.ls = sctx->vs_shader.cso;
+ si_shader_selector_key_vs(sctx, sctx->shader.vs.cso, key, &key->part.tcs.ls_prolog);
+ key->part.tcs.ls = sctx->shader.vs.cso;
/* When the LS VGPR fix is needed, monolithic shaders
* can:
@@ -1880,18 +1880,18 @@ static inline void si_shader_selector_key(struct pipe_context *ctx, struct si_sh
}
key->part.tcs.epilog.prim_mode =
- sctx->tes_shader.cso->info.base.tess.primitive_mode;
+ sctx->shader.tes.cso->info.base.tess.primitive_mode;
key->part.tcs.epilog.invoc0_tess_factors_are_def =
sel->info.tessfactors_are_def_in_all_invocs;
- key->part.tcs.epilog.tes_reads_tess_factors = sctx->tes_shader.cso->info.reads_tess_factors;
+ key->part.tcs.epilog.tes_reads_tess_factors = sctx->shader.tes.cso->info.reads_tess_factors;
if (sel == sctx->fixed_func_tcs_shader.cso)
- key->mono.u.ff_tcs_inputs_to_copy = sctx->vs_shader.cso->outputs_written;
+ key->mono.u.ff_tcs_inputs_to_copy = sctx->shader.vs.cso->outputs_written;
break;
case MESA_SHADER_TESS_EVAL:
key->as_ngg = stages_key.u.ngg;
- if (sctx->gs_shader.cso)
+ if (sctx->shader.gs.cso)
key->as_es = 1;
else {
si_shader_selector_key_hw_vs(sctx, sel, key);
@@ -1899,11 +1899,11 @@ static inline void si_shader_selector_key(struct pipe_context *ctx, struct si_sh
break;
case MESA_SHADER_GEOMETRY:
if (sctx->chip_class >= GFX9) {
- if (sctx->tes_shader.cso) {
- key->part.gs.es = sctx->tes_shader.cso;
+ if (sctx->shader.tes.cso) {
+ key->part.gs.es = sctx->shader.tes.cso;
} else {
- si_shader_selector_key_vs(sctx, sctx->vs_shader.cso, key, &key->part.gs.vs_prolog);
- key->part.gs.es = sctx->vs_shader.cso;
+ si_shader_selector_key_vs(sctx, sctx->shader.vs.cso, key, &key->part.gs.vs_prolog);
+ key->part.gs.es = sctx->shader.vs.cso;
}
key->as_ngg = stages_key.u.ngg;
@@ -2956,12 +2956,12 @@ static void si_update_rasterized_prim(struct si_context *sctx)
{
enum pipe_prim_type rast_prim;
- if (sctx->gs_shader.cso) {
+ if (sctx->shader.gs.cso) {
/* Only possibilities: POINTS, LINE_STRIP, TRIANGLES */
- rast_prim = sctx->gs_shader.cso->rast_prim;
- } else if (sctx->tes_shader.cso) {
+ rast_prim = sctx->shader.gs.cso->rast_prim;
+ } else if (sctx->shader.tes.cso) {
/* Only possibilities: POINTS, LINE_STRIP, TRIANGLES */
- rast_prim = sctx->tes_shader.cso->rast_prim;
+ rast_prim = sctx->shader.tes.cso->rast_prim;
} else {
/* Determined by draw calls. */
return;
@@ -2981,16 +2981,16 @@ static void si_update_common_shader_state(struct si_context *sctx, struct si_sha
{
si_set_active_descriptors_for_shader(sctx, sel);
- 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->uses_bindless_samplers = si_shader_uses_bindless_samplers(sctx->shader.vs.cso) ||
+ si_shader_uses_bindless_samplers(sctx->shader.gs.cso) ||
+ si_shader_uses_bindless_samplers(sctx->shader.ps.cso) ||
+ si_shader_uses_bindless_samplers(sctx->shader.tcs.cso) ||
+ si_shader_uses_bindless_samplers(sctx->shader.tes.cso);
+ sctx->uses_bindless_images = si_shader_uses_bindless_images(sctx->shader.vs.cso) ||
+ si_shader_uses_bindless_images(sctx->shader.gs.cso) ||
+ si_shader_uses_bindless_images(sctx->shader.ps.cso) ||
+ si_shader_uses_bindless_images(sctx->shader.tcs.cso) ||
+ si_shader_uses_bindless_images(sctx->shader.tes.cso);
/* Invalidate inlinable uniforms. */
sctx->inlinable_uniforms_valid_mask &= ~(1 << type);
@@ -3005,11 +3005,11 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
struct si_shader *old_hw_vs_variant = si_get_vs(sctx)->current;
struct si_shader_selector *sel = state;
- if (sctx->vs_shader.cso == sel)
+ if (sctx->shader.vs.cso == sel)
return;
- sctx->vs_shader.cso = sel;
- sctx->vs_shader.current = sel ? sel->first_variant : NULL;
+ sctx->shader.vs.cso = sel;
+ sctx->shader.vs.current = sel ? sel->first_variant : NULL;
sctx->num_vs_blit_sgprs = sel ? sel->info.base.vs.blit_sgprs_amd : 0;
sctx->vs_uses_draw_id = sel ? sel->info.uses_drawid : false;
@@ -3028,10 +3028,10 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
static void si_update_tess_uses_prim_id(struct si_context *sctx)
{
sctx->ia_multi_vgt_param_key.u.tess_uses_prim_id =
- (sctx->tes_shader.cso && sctx->tes_shader.cso->info.uses_primid) ||
- (sctx->tcs_shader.cso && sctx->tcs_shader.cso->info.uses_primid) ||
- (sctx->gs_shader.cso && sctx->gs_shader.cso->info.uses_primid) ||
- (sctx->ps_shader.cso && !sctx->gs_shader.cso && sctx->ps_shader.cso->info.uses_primid);
+ (sctx->shader.tes.cso && sctx->shader.tes.cso->info.uses_primid) ||
+ (sctx->shader.tcs.cso && sctx->shader.tcs.cso->info.uses_primid) ||
+ (sctx->shader.gs.cso && sctx->shader.gs.cso->info.uses_primid) ||
+ (sctx->shader.ps.cso && !sctx->shader.gs.cso && sctx->shader.ps.cso->info.uses_primid);
}
bool si_update_ngg(struct si_context *sctx)
@@ -3043,7 +3043,7 @@ bool si_update_ngg(struct si_context *sctx)
bool new_ngg = true;
- if (sctx->gs_shader.cso && sctx->tes_shader.cso && sctx->gs_shader.cso->tess_turns_off_ngg) {
+ if (sctx->shader.gs.cso && sctx->shader.tes.cso && sctx->shader.gs.cso->tess_turns_off_ngg) {
new_ngg = false;
} else if (!sctx->screen->use_ngg_streamout) {
struct si_shader_selector *last = si_get_vs(sctx)->cso;
@@ -3079,14 +3079,14 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
struct si_shader_selector *old_hw_vs = si_get_vs(sctx)->cso;
struct si_shader *old_hw_vs_variant = si_get_vs(sctx)->current;
struct si_shader_selector *sel = state;
- bool enable_changed = !!sctx->gs_shader.cso != !!sel;
+ bool enable_changed = !!sctx->shader.gs.cso != !!sel;
bool ngg_changed;
- if (sctx->gs_shader.cso == sel)
+ if (sctx->shader.gs.cso == sel)
return;
- sctx->gs_shader.cso = sel;
- sctx->gs_shader.current = sel ? sel->first_variant : NULL;
+ sctx->shader.gs.cso = sel;
+ sctx->shader.gs.current = sel ? sel->first_variant : NULL;
sctx->ia_multi_vgt_param_key.u.uses_gs = sel != NULL;
si_update_common_shader_state(sctx, sel, PIPE_SHADER_GEOMETRY);
@@ -3111,13 +3111,13 @@ static void si_bind_tcs_shader(struct pipe_context *ctx, void *state)
{
struct si_context *sctx = (struct si_context *)ctx;
struct si_shader_selector *sel = state;
- bool enable_changed = !!sctx->tcs_shader.cso != !!sel;
+ bool enable_changed = !!sctx->shader.tcs.cso != !!sel;
- if (sctx->tcs_shader.cso == sel)
+ if (sctx->shader.tcs.cso == sel)
return;
- sctx->tcs_shader.cso = sel;
- sctx->tcs_shader.current = sel ? sel->first_variant : NULL;
+ sctx->shader.tcs.cso = sel;
+ sctx->shader.tcs.current = sel ? sel->first_variant : NULL;
si_update_tess_uses_prim_id(sctx);
si_update_common_shader_state(sctx, sel, PIPE_SHADER_TESS_CTRL);
@@ -3132,13 +3132,13 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state)
struct si_shader_selector *old_hw_vs = si_get_vs(sctx)->cso;
struct si_shader *old_hw_vs_variant = si_get_vs(sctx)->current;
struct si_shader_selector *sel = state;
- bool enable_changed = !!sctx->tes_shader.cso != !!sel;
+ bool enable_changed = !!sctx->shader.tes.cso != !!sel;
- if (sctx->tes_shader.cso == sel)
+ if (sctx->shader.tes.cso == sel)
return;
- sctx->tes_shader.cso = sel;
- sctx->tes_shader.current = sel ? sel->first_variant : NULL;
+ sctx->shader.tes.cso = sel;
+ sctx->shader.tes.current = sel ? sel->first_variant : NULL;
sctx->ia_multi_vgt_param_key.u.uses_tess = sel != NULL;
si_update_tess_uses_prim_id(sctx);
@@ -3161,15 +3161,15 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state)
static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
{
struct si_context *sctx = (struct si_context *)ctx;
- struct si_shader_selector *old_sel = sctx->ps_shader.cso;
+ struct si_shader_selector *old_sel = sctx->shader.ps.cso;
struct si_shader_selector *sel = state;
/* skip if supplied shader is one already in use */
if (old_sel == sel)
return;
- sctx->ps_shader.cso = sel;
- sctx->ps_shader.current = sel ? sel->first_variant : NULL;
+ sctx->shader.ps.cso = sel;
+ sctx->shader.ps.current = sel ? sel->first_variant : NULL;
si_update_common_shader_state(sctx, sel, PIPE_SHADER_FRAGMENT);
if (sel) {
@@ -3252,19 +3252,12 @@ static void si_destroy_shader_selector(struct pipe_context *ctx, void *cso)
struct si_context *sctx = (struct si_context *)ctx;
struct si_shader_selector *sel = (struct si_shader_selector *)cso;
struct si_shader *p = sel->first_variant, *c;
- struct si_shader_ctx_state *current_shader[SI_NUM_SHADERS] = {
- [MESA_SHADER_VERTEX] = &sctx->vs_shader,
- [MESA_SHADER_TESS_CTRL] = &sctx->tcs_shader,
- [MESA_SHADER_TESS_EVAL] = &sctx->tes_shader,
- [MESA_SHADER_GEOMETRY] = &sctx->gs_shader,
- [MESA_SHADER_FRAGMENT] = &sctx->ps_shader,
- };
util_queue_drop_job(&sctx->screen->shader_compiler_queue, &sel->ready);
- if (current_shader[sel->info.stage]->cso == sel) {
- current_shader[sel->info.stage]->cso = NULL;
- current_shader[sel->info.stage]->current = NULL;
+ if (sctx->shaders[sel->info.stage].cso == sel) {
+ sctx->shaders[sel->info.stage].cso = NULL;
+ sctx->shaders[sel->info.stage].current = NULL;
}
while (p) {
@@ -3357,7 +3350,7 @@ static unsigned si_get_ps_input_cntl(struct si_context *sctx, struct si_shader *
static void si_emit_spi_map(struct si_context *sctx)
{
- struct si_shader *ps = sctx->ps_shader.current;
+ struct si_shader *ps = sctx->shader.ps.current;
struct si_shader *vs;
struct si_shader_info *psinfo = ps ? &ps->selector->info : NULL;
unsigned i, num_interp, num_written = 0;
@@ -3367,8 +3360,8 @@ static void si_emit_spi_map(struct si_context *sctx)
return;
/* With legacy GS, only the GS copy shader contains information about param exports. */
- if (sctx->gs_shader.cso && !sctx->ngg)
- vs = sctx->gs_shader.cso->gs_copy_shader;
+ if (sctx->shader.gs.cso && !sctx->ngg)
+ vs = sctx->shader.gs.cso->gs_copy_shader;
else
vs = si_get_vs(sctx)->current;
@@ -3445,8 +3438,8 @@ static void si_emit_vgt_flush(struct radeon_cmdbuf *cs)
static bool si_update_gs_ring_buffers(struct si_context *sctx)
{
struct si_shader_selector *es =
- sctx->tes_shader.cso ? sctx->tes_shader.cso : sctx->vs_shader.cso;
- struct si_shader_selector *gs = sctx->gs_shader.cso;
+ sctx->shader.tes.cso ? sctx->shader.tes.cso : sctx->shader.vs.cso;
+ struct si_shader_selector *gs = sctx->shader.gs.cso;
struct si_pm4_state *pm4;
/* Chip constants. */
@@ -3652,10 +3645,10 @@ static unsigned si_get_scratch_buffer_bytes_per_wave(struct si_shader *shader)
static struct si_shader *si_get_tcs_current(struct si_context *sctx)
{
- if (!sctx->tes_shader.cso)
+ if (!sctx->shader.tes.cso)
return NULL; /* tessellation disabled */
- return sctx->tcs_shader.cso ? sctx->tcs_shader.current : sctx->fixed_func_tcs_shader.current;
+ return sctx->shader.tcs.cso ? sctx->shader.tcs.current : sctx->fixed_func_tcs_shader.current;
}
static bool si_update_scratch_relocs(struct si_context *sctx)
@@ -3668,17 +3661,17 @@ static bool si_update_scratch_relocs(struct si_context *sctx)
* last used, so we still need to try to update them, even if they
* require scratch buffers smaller than the current size.
*/
- r = si_update_scratch_buffer(sctx, sctx->ps_shader.current);
+ r = si_update_scratch_buffer(sctx, sctx->shader.ps.current);
if (r < 0)
return false;
if (r == 1)
- si_pm4_bind_state(sctx, ps, sctx->ps_shader.current->pm4);
+ si_pm4_bind_state(sctx, ps, sctx->shader.ps.current->pm4);
- r = si_update_scratch_buffer(sctx, sctx->gs_shader.current);
+ r = si_update_scratch_buffer(sctx, sctx->shader.gs.current);
if (r < 0)
return false;
if (r == 1)
- si_pm4_bind_state(sctx, gs, sctx->gs_shader.current->pm4);
+ si_pm4_bind_state(sctx, gs, sctx->shader.gs.current->pm4);
r = si_update_scratch_buffer(sctx, tcs);
if (r < 0)
@@ -3687,31 +3680,31 @@ static bool si_update_scratch_relocs(struct si_context *sctx)
si_pm4_bind_state(sctx, hs, tcs->pm4);
/* VS can be bound as LS, ES, or VS. */
- r = si_update_scratch_buffer(sctx, sctx->vs_shader.current);
+ r = si_update_scratch_buffer(sctx, sctx->shader.vs.current);
if (r < 0)
return false;
if (r == 1) {
- if (sctx->vs_shader.current->key.as_ls)
- si_pm4_bind_state(sctx, ls, sctx->vs_shader.current->pm4);
- else if (sctx->vs_shader.current->key.as_es)
- si_pm4_bind_state(sctx, es, sctx->vs_shader.current->pm4);
- else if (sctx->vs_shader.current->key.as_ngg)
- si_pm4_bind_state(sctx, gs, sctx->vs_shader.current->pm4);
+ if (sctx->shader.vs.current->key.as_ls)
+ si_pm4_bind_state(sctx, ls, sctx->shader.vs.current->pm4);
+ else if (sctx->shader.vs.current->key.as_es)
+ si_pm4_bind_state(sctx, es, sctx->shader.vs.current->pm4);
+ else if (sctx->shader.vs.current->key.as_ngg)
+ si_pm4_bind_state(sctx, gs, sctx->shader.vs.current->pm4);
else
- si_pm4_bind_state(sctx, vs, sctx->vs_shader.current->pm4);
+ si_pm4_bind_state(sctx, vs, sctx->shader.vs.current->pm4);
}
/* TES can be bound as ES or VS. */
- r = si_update_scratch_buffer(sctx, sctx->tes_shader.current);
+ r = si_update_scratch_buffer(sctx, sctx->shader.tes.current);
if (r < 0)
return false;
if (r == 1) {
- if (sctx->tes_shader.current->key.as_es)
- si_pm4_bind_state(sctx, es, sctx->tes_shader.current->pm4);
- else if (sctx->tes_shader.current->key.as_ngg)
- si_pm4_bind_state(sctx, gs, sctx->tes_shader.current->pm4);
+ if (sctx->shader.tes.current->key.as_es)
+ si_pm4_bind_state(sctx, es, sctx->shader.tes.current->pm4);
+ else if (sctx->shader.tes.current->key.as_ngg)
+ si_pm4_bind_state(sctx, gs, sctx->shader.tes.current->pm4);
else
- si_pm4_bind_state(sctx, vs, sctx->tes_shader.current->pm4);
+ si_pm4_bind_state(sctx, vs, sctx->shader.tes.current->pm4);
}
return true;
@@ -3734,12 +3727,12 @@ static bool si_update_spi_tmpring_size(struct si_context *sctx)
*/
unsigned bytes = 0;
- bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->ps_shader.current));
- bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->gs_shader.current));
- bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->vs_shader.current));
+ bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->shader.ps.current));
+ bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->shader.gs.current));
+ bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->shader.vs.current));
- if (sctx->tes_shader.cso) {
- bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->tes_shader.current));
+ if (sctx->shader.tes.cso) {
+ bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->shader.tes.current));
bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(si_get_tcs_current(sctx)));
}
@@ -3943,7 +3936,7 @@ bool si_update_shaders(struct si_context *sctx)
struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
struct si_shader *old_vs = si_get_vs(sctx)->current;
unsigned old_kill_clip_distances = old_vs ? old_vs->key.opt.kill_clip_distances : 0;
- struct si_shader *old_ps = sctx->ps_shader.current;
+ struct si_shader *old_ps = sctx->shader.ps.current;
union si_vgt_stages_key key;
unsigned old_spi_shader_col_format =
old_ps ? old_ps->key.part.ps.epilog.spi_shader_col_format : 0;
@@ -3958,9 +3951,9 @@ bool si_update_shaders(struct si_context *sctx)
key.index = 0;
- if (sctx->tes_shader.cso)
+ if (sctx->shader.tes.cso)
key.u.tess = 1;
- if (sctx->gs_shader.cso)
+ if (sctx->shader.gs.cso)
key.u.gs = 1;
if (sctx->ngg) {
@@ -3969,18 +3962,18 @@ bool si_update_shaders(struct si_context *sctx)
}
/* Update TCS and TES. */
- if (sctx->tes_shader.cso) {
+ if (sctx->shader.tes.cso) {
if (!sctx->tess_rings) {
si_init_tess_factor_ring(sctx);
if (!sctx->tess_rings)
return false;
}
- if (sctx->tcs_shader.cso) {
- r = si_shader_select(ctx, &sctx->tcs_shader, key, &compiler_state);
+ if (sctx->shader.tcs.cso) {
+ r = si_shader_select(ctx, &sctx->shader.tcs, key, &compiler_state);
if (r)
return false;
- si_pm4_bind_state(sctx, hs, sctx->tcs_shader.current->pm4);
+ si_pm4_bind_state(sctx, hs, sctx->shader.tcs.current->pm4);
} else {
if (!sctx->fixed_func_tcs_shader.cso) {
sctx->fixed_func_tcs_shader.cso = si_create_fixed_func_tcs(sctx);
@@ -3994,19 +3987,19 @@ bool si_update_shaders(struct si_context *sctx)
si_pm4_bind_state(sctx, hs, sctx->fixed_func_tcs_shader.current->pm4);
}
- if (!sctx->gs_shader.cso || sctx->chip_class <= GFX8) {
- r = si_shader_select(ctx, &sctx->tes_shader, key, &compiler_state);
+ if (!sctx->shader.gs.cso || sctx->chip_class <= GFX8) {
+ r = si_shader_select(ctx, &sctx->shader.tes, key, &compiler_state);
if (r)
return false;
- if (sctx->gs_shader.cso) {
+ if (sctx->shader.gs.cso) {
/* TES as ES */
assert(sctx->chip_class <= GFX8);
- si_pm4_bind_state(sctx, es, sctx->tes_shader.current->pm4);
+ si_pm4_bind_state(sctx, es, sctx->shader.tes.current->pm4);
} else if (key.u.ngg) {
- si_pm4_bind_state(sctx, gs, sctx->tes_shader.current->pm4);
+ si_pm4_bind_state(sctx, gs, sctx->shader.tes.current->pm4);
} else {
- si_pm4_bind_state(sctx, vs, sctx->tes_shader.current->pm4);
+ si_pm4_bind_state(sctx, vs, sctx->shader.tes.current->pm4);
}
}
} else {
@@ -4016,13 +4009,13 @@ bool si_update_shaders(struct si_context *sctx)
}
/* Update GS. */
- if (sctx->gs_shader.cso) {
- r = si_shader_select(ctx, &sctx->gs_shader, key, &compiler_state);
+ if (sctx->shader.gs.cso) {
+ r = si_shader_select(ctx, &sctx->shader.gs, key, &compiler_state);
if (r)
return false;
- si_pm4_bind_state(sctx, gs, sctx->gs_shader.current->pm4);
+ si_pm4_bind_state(sctx, gs, sctx->shader.gs.current->pm4);
if (!key.u.ngg) {
- si_pm4_bind_state(sctx, vs, sctx->gs_shader.cso->gs_copy_shader->pm4);
+ si_pm4_bind_state(sctx, vs, sctx->shader.gs.cso->gs_copy_shader->pm4);
if (!si_update_gs_ring_buffers(sctx))
return false;
@@ -4039,22 +4032,22 @@ bool si_update_shaders(struct si_context *sctx)
/* Update VS. */
if ((!key.u.tess && !key.u.gs) || sctx->chip_class <= GFX8) {
- r = si_shader_select(ctx, &sctx->vs_shader, key, &compiler_state);
+ r = si_shader_select(ctx, &sctx->shader.vs, key, &compiler_state);
if (r)
return false;
if (!key.u.tess && !key.u.gs) {
if (key.u.ngg) {
- si_pm4_bind_state(sctx, gs, sctx->vs_shader.current->pm4);
+ si_pm4_bind_state(sctx, gs, sctx->shader.vs.current->pm4);
si_pm4_bind_state(sctx, vs, NULL);
} else {
- si_pm4_bind_state(sctx, vs, sctx->vs_shader.current->pm4);
+ si_pm4_bind_state(sctx, vs, sctx->shader.vs.current->pm4);
}
- } else if (sctx->tes_shader.cso) {
- si_pm4_bind_state(sctx, ls, sctx->vs_shader.current->pm4);
+ } else if (sctx->shader.tes.cso) {
+ si_pm4_bind_state(sctx, ls, sctx->shader.vs.current->pm4);
} else {
- assert(sctx->gs_shader.cso);
- si_pm4_bind_state(sctx, es, sctx->vs_shader.current->pm4);
+ assert(sctx->shader.gs.cso);
+ si_pm4_bind_state(sctx, es, sctx->shader.vs.current->pm4);
}
}
@@ -4067,24 +4060,24 @@ bool si_update_shaders(struct si_context *sctx)
}
sctx->vs_uses_base_instance =
- sctx->vs_shader.current ? sctx->vs_shader.current->uses_base_instance :
+ sctx->shader.vs.current ? sctx->shader.vs.current->uses_base_instance :
sctx->queued.named.hs ? sctx->queued.named.hs->shader->uses_base_instance :
- sctx->gs_shader.current->uses_base_instance;
+ sctx->shader.gs.current->uses_base_instance;
si_update_vgt_shader_config(sctx, key);
if (old_kill_clip_distances != si_get_vs(sctx)->current->key.opt.kill_clip_distances)
si_mark_atom_dirty(sctx, &sctx->atoms.s.clip_regs);
- if (sctx->ps_shader.cso) {
+ if (sctx->shader.ps.cso) {
unsigned db_shader_control;
- r = si_shader_select(ctx, &sctx->ps_shader, key, &compiler_state);
+ r = si_shader_select(ctx, &sctx->shader.ps, key, &compiler_state);
if (r)
return false;
- si_pm4_bind_state(sctx, ps, sctx->ps_shader.current->pm4);
+ si_pm4_bind_state(sctx, ps, sctx->shader.ps.current->pm4);
- db_shader_control = sctx->ps_shader.cso->db_shader_control |
+ db_shader_control = sctx->shader.ps.cso->db_shader_control |
S_02880C_KILL_ENABLE(si_get_alpha_test_func(sctx) != PIPE_FUNC_ALWAYS);
if (si_pm4_state_changed(sctx, ps) || si_pm4_state_changed(sctx, vs) ||
@@ -4098,7 +4091,7 @@ bool si_update_shaders(struct si_context *sctx)
if (sctx->screen->info.rbplus_allowed && si_pm4_state_changed(sctx, ps) &&
(!old_ps || old_spi_shader_col_format !=
- sctx->ps_shader.current->key.part.ps.epilog.spi_shader_col_format))
+ sctx->shader.ps.current->key.part.ps.epilog.spi_shader_col_format))
si_mark_atom_dirty(sctx, &sctx->atoms.s.cb_render_state);
if (sctx->ps_db_shader_control != db_shader_control) {
@@ -4109,8 +4102,8 @@ bool si_update_shaders(struct si_context *sctx)
}
if (sctx->smoothing_enabled !=
- sctx->ps_shader.current->key.part.ps.epilog.poly_line_smoothing) {
- sctx->smoothing_enabled = sctx->ps_shader.current->key.part.ps.epilog.poly_line_smoothing;
+ sctx->shader.ps.current->key.part.ps.epilog.poly_line_smoothing) {
+ sctx->smoothing_enabled = sctx->shader.ps.current->key.part.ps.epilog.poly_line_smoothing;
si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_config);
/* NGG cull state uses smoothing_enabled. */
@@ -4125,7 +4118,7 @@ bool si_update_shaders(struct si_context *sctx)
}
if (sctx->chip_class >= GFX10_3) {
- struct si_shader_info *info = &sctx->ps_shader.cso->info;
+ struct si_shader_info *info = &sctx->shader.ps.cso->info;
bool allow_flat_shading = info->allow_flat_shading;
if (allow_flat_shading &&