radeonsi: add a gfx11 version of si_decompress_textures, add assertions < GFX11

si_decompress_textures is renamed to gfx6_decompress_textures.
gfx11_decompress_textures is added.

Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22833>
This commit is contained in:
Marek Olšák 2023-05-07 17:03:06 -04:00 committed by Marge Bot
parent dc311f3f61
commit d3f716bdfc
5 changed files with 65 additions and 10 deletions

View file

@ -116,6 +116,8 @@ static unsigned si_blit_dbcb_copy(struct si_context *sctx, struct si_texture *sr
unsigned layer, sample, checked_last_layer, max_layer;
unsigned fully_copied_levels = 0;
assert(sctx->gfx_level < GFX11);
if (planes & PIPE_MASK_Z)
sctx->dbcb_depth_copy_enabled = true;
if (planes & PIPE_MASK_S)
@ -550,6 +552,8 @@ static void si_decompress_color_texture(struct si_context *sctx, struct si_textu
unsigned first_level, unsigned last_level,
bool need_fmask_expand)
{
assert(sctx->gfx_level < GFX11);
/* CMASK or DCC can be discarded and we can still end up here. */
if (!tex->cmask_buffer && !tex->surface.fmask_size &&
!vi_dcc_enabled(tex, first_level))
@ -566,6 +570,8 @@ static void si_decompress_sampler_color_textures(struct si_context *sctx,
unsigned i;
unsigned mask = textures->needs_color_decompress_mask;
assert(sctx->gfx_level < GFX11);
while (mask) {
struct pipe_sampler_view *view;
struct si_texture *tex;
@ -587,6 +593,8 @@ static void si_decompress_image_color_textures(struct si_context *sctx, struct s
unsigned i;
unsigned mask = images->needs_color_decompress_mask;
assert(sctx->gfx_level < GFX11);
while (mask) {
const struct pipe_image_view *view;
struct si_texture *tex;
@ -738,8 +746,10 @@ static void si_check_render_feedback(struct si_context *sctx)
sctx->need_check_render_feedback = false;
}
static void si_decompress_resident_textures(struct si_context *sctx)
static void si_decompress_resident_color_textures(struct si_context *sctx)
{
assert(sctx->gfx_level < GFX11);
util_dynarray_foreach (&sctx->resident_tex_needs_color_decompress, struct si_texture_handle *,
tex_handle) {
struct pipe_sampler_view *view = (*tex_handle)->view;
@ -748,7 +758,10 @@ static void si_decompress_resident_textures(struct si_context *sctx)
si_decompress_color_texture(sctx, tex, view->u.tex.first_level, view->u.tex.last_level,
false);
}
}
static void si_decompress_resident_depth_textures(struct si_context *sctx)
{
util_dynarray_foreach (&sctx->resident_tex_needs_depth_decompress, struct si_texture_handle *,
tex_handle) {
struct pipe_sampler_view *view = (*tex_handle)->view;
@ -763,6 +776,8 @@ static void si_decompress_resident_textures(struct si_context *sctx)
static void si_decompress_resident_images(struct si_context *sctx)
{
assert(sctx->gfx_level < GFX11);
util_dynarray_foreach (&sctx->resident_img_needs_color_decompress, struct si_image_handle *,
img_handle) {
struct pipe_image_view *view = &(*img_handle)->view;
@ -773,7 +788,7 @@ static void si_decompress_resident_images(struct si_context *sctx)
}
}
void si_decompress_textures(struct si_context *sctx, unsigned shader_mask)
void gfx6_decompress_textures(struct si_context *sctx, unsigned shader_mask)
{
unsigned compressed_colortex_counter, mask;
bool need_flush = false;
@ -815,8 +830,10 @@ void si_decompress_textures(struct si_context *sctx, unsigned shader_mask)
}
if (shader_mask & u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS)) {
if (sctx->uses_bindless_samplers)
si_decompress_resident_textures(sctx);
if (sctx->uses_bindless_samplers) {
si_decompress_resident_color_textures(sctx);
si_decompress_resident_depth_textures(sctx);
}
if (sctx->uses_bindless_images)
si_decompress_resident_images(sctx);
@ -828,13 +845,39 @@ void si_decompress_textures(struct si_context *sctx, unsigned shader_mask)
si_check_render_feedback(sctx);
} else if (shader_mask & (1 << PIPE_SHADER_COMPUTE)) {
if (sctx->cs_shader_state.program->sel.info.uses_bindless_samplers)
si_decompress_resident_textures(sctx);
if (sctx->cs_shader_state.program->sel.info.uses_bindless_samplers) {
si_decompress_resident_color_textures(sctx);
si_decompress_resident_depth_textures(sctx);
}
if (sctx->cs_shader_state.program->sel.info.uses_bindless_images)
si_decompress_resident_images(sctx);
}
}
void gfx11_decompress_textures(struct si_context *sctx, unsigned shader_mask)
{
if (sctx->blitter_running)
return;
/* Decompress depth textures if needed. */
unsigned mask = sctx->shader_needs_decompress_mask & shader_mask;
u_foreach_bit(i, mask) {
assert(sctx->samplers[i].needs_depth_decompress_mask);
si_decompress_sampler_depth_textures(sctx, &sctx->samplers[i]);
}
/* Decompress bindless depth textures and disable DCC for render feedback. */
if (shader_mask & u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS)) {
if (sctx->uses_bindless_samplers)
si_decompress_resident_depth_textures(sctx);
si_check_render_feedback(sctx);
} else if (shader_mask & (1 << PIPE_SHADER_COMPUTE)) {
if (sctx->cs_shader_state.program->sel.info.uses_bindless_samplers)
si_decompress_resident_depth_textures(sctx);
}
}
/* Helper for decompressing a portion of a color or depth resource before
* blitting if any decompression is needed.
* The driver doesn't decompress resources automatically while u_blitter is

View file

@ -898,7 +898,10 @@ static void si_launch_grid(struct pipe_context *ctx, const struct pipe_grid_info
sctx->framebuffer.all_DCC_pipe_aligned);
}
si_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE);
if (sctx->gfx_level < GFX11)
gfx6_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE);
else
gfx11_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE);
}
/* Add buffer sizes for memory checking in need_cs_space. */

View file

@ -496,7 +496,9 @@ static void si_set_sampler_view_desc(struct si_context *sctx, struct si_sampler_
static bool color_needs_decompression(struct si_texture *tex)
{
if (tex->is_depth)
struct si_screen *sscreen = (struct si_screen *)tex->buffer.b.b.screen;
if (sscreen->info.gfx_level >= GFX11 || tex->is_depth)
return false;
return tex->surface.fmask_size ||
@ -1640,6 +1642,8 @@ static void si_resident_handles_update_needs_color_decompress(struct si_context
*/
void si_update_needs_color_decompress_masks(struct si_context *sctx)
{
assert(sctx->gfx_level < GFX11);
for (int i = 0; i < SI_NUM_SHADERS; ++i) {
si_samplers_update_needs_color_decompress_mask(&sctx->samplers[i]);
si_images_update_needs_color_decompress_mask(&sctx->images[i]);

View file

@ -1332,7 +1332,8 @@ enum si_blitter_op /* bitmask */
void si_blitter_begin(struct si_context *sctx, enum si_blitter_op op);
void si_blitter_end(struct si_context *sctx);
void si_init_blit_functions(struct si_context *sctx);
void si_decompress_textures(struct si_context *sctx, unsigned shader_mask);
void gfx6_decompress_textures(struct si_context *sctx, unsigned shader_mask);
void gfx11_decompress_textures(struct si_context *sctx, unsigned shader_mask);
void si_decompress_subresource(struct pipe_context *ctx, struct pipe_resource *tex, unsigned planes,
unsigned level, unsigned first_layer, unsigned last_layer,
bool need_fmask_expand);

View file

@ -2154,7 +2154,11 @@ static void si_draw(struct pipe_context *ctx,
si_check_dirty_buffers_textures(sctx);
si_decompress_textures(sctx, u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS));
if (GFX_VERSION < GFX11)
gfx6_decompress_textures(sctx, u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS));
else
gfx11_decompress_textures(sctx, u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS));
si_need_gfx_cs_space(sctx, num_draws);
unsigned instance_count = info->instance_count;