radeonsi: fold si_create_function into si_llvm_create_func
[mesa.git] / src / gallium / drivers / radeonsi / si_blit.c
index 68ed4cc5002e2744a01bccd48852d80e4e561e0e..70ad55d8a41b6e470bea641ad2848ce05a4f0751 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "si_pipe.h"
 #include "si_compute.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
 #include "util/u_log.h"
 #include "util/u_surface.h"
 
@@ -99,6 +99,7 @@ void si_blitter_end(struct si_context *sctx)
         * non-global VS user SGPRs. */
        sctx->shader_pointers_dirty |= SI_DESCS_SHADER_MASK(VERTEX);
        sctx->vertex_buffer_pointer_dirty = sctx->vb_descriptors_buffer != NULL;
+       sctx->vertex_buffer_user_sgprs_dirty = sctx->num_vertex_elements > 0;
        si_mark_atom_dirty(sctx, &sctx->atoms.s.shader_pointers);
 }
 
@@ -432,7 +433,8 @@ static void si_blit_decompress_color(struct si_context *sctx,
                                     struct si_texture *tex,
                                     unsigned first_level, unsigned last_level,
                                     unsigned first_layer, unsigned last_layer,
-                                    bool need_dcc_decompress)
+                                    bool need_dcc_decompress,
+                                    bool need_fmask_expand)
 {
        void* custom_blend;
        unsigned layer, checked_last_layer, max_layer;
@@ -453,7 +455,7 @@ static void si_blit_decompress_color(struct si_context *sctx,
        if (need_dcc_decompress) {
                custom_blend = sctx->custom_blend_dcc_decompress;
 
-               assert(tex->dcc_offset);
+               assert(tex->surface.dcc_offset);
 
                /* disable levels without DCC */
                for (int i = first_level; i <= last_level; i++) {
@@ -512,19 +514,25 @@ static void si_blit_decompress_color(struct si_context *sctx,
        si_make_CB_shader_coherent(sctx, tex->buffer.b.b.nr_samples,
                                   vi_dcc_enabled(tex, first_level),
                                   tex->surface.u.gfx9.dcc.pipe_aligned);
+
+       if (need_fmask_expand && tex->surface.fmask_offset && tex->fmask_is_not_identity) {
+               si_compute_expand_fmask(&sctx->b, &tex->buffer.b.b);
+               tex->fmask_is_not_identity = false;
+       }
 }
 
 static void
 si_decompress_color_texture(struct si_context *sctx, struct si_texture *tex,
-                           unsigned first_level, unsigned last_level)
+                           unsigned first_level, unsigned last_level,
+                           bool need_fmask_expand)
 {
        /* CMASK or DCC can be discarded and we can still end up here. */
-       if (!tex->cmask_buffer && !tex->surface.fmask_size && !tex->dcc_offset)
+       if (!tex->cmask_buffer && !tex->surface.fmask_size && !tex->surface.dcc_offset)
                return;
 
        si_blit_decompress_color(sctx, tex, first_level, last_level, 0,
                                 util_max_layer(&tex->buffer.b.b, first_level),
-                                false);
+                                false, need_fmask_expand);
 }
 
 static void
@@ -546,7 +554,7 @@ si_decompress_sampler_color_textures(struct si_context *sctx,
                tex = (struct si_texture *)view->texture;
 
                si_decompress_color_texture(sctx, tex, view->u.tex.first_level,
-                                           view->u.tex.last_level);
+                                           view->u.tex.last_level, false);
        }
 }
 
@@ -569,7 +577,8 @@ si_decompress_image_color_textures(struct si_context *sctx,
                tex = (struct si_texture *)view->resource;
 
                si_decompress_color_texture(sctx, tex, view->u.tex.level,
-                                           view->u.tex.level);
+                                           view->u.tex.level,
+                                           view->access & PIPE_IMAGE_ACCESS_WRITE);
        }
 }
 
@@ -582,7 +591,7 @@ static void si_check_render_feedback_texture(struct si_context *sctx,
 {
        bool render_feedback = false;
 
-       if (!tex->dcc_offset)
+       if (!tex->surface.dcc_offset)
                return;
 
        for (unsigned j = 0; j < sctx->framebuffer.state.nr_cbufs; ++j) {
@@ -729,7 +738,7 @@ static void si_decompress_resident_textures(struct si_context *sctx)
                struct si_texture *tex = (struct si_texture *)view->texture;
 
                si_decompress_color_texture(sctx, tex, view->u.tex.first_level,
-                                           view->u.tex.last_level);
+                                           view->u.tex.last_level, false);
        }
 
        util_dynarray_foreach(&sctx->resident_tex_needs_depth_decompress,
@@ -753,7 +762,8 @@ static void si_decompress_resident_images(struct si_context *sctx)
                struct si_texture *tex = (struct si_texture *)view->resource;
 
                si_decompress_color_texture(sctx, tex, view->u.tex.level,
-                                           view->u.tex.level);
+                                           view->u.tex.level,
+                                           view->access & PIPE_IMAGE_ACCESS_WRITE);
        }
 }
 
@@ -798,7 +808,7 @@ void si_decompress_textures(struct si_context *sctx, unsigned shader_mask)
                        si_decompress_color_texture(sctx,
                                                    (struct si_texture*)cb0->texture,
                                                    cb0->u.tex.first_layer,
-                                                   cb0->u.tex.last_layer);
+                                                   cb0->u.tex.last_layer, false);
                }
 
                si_check_render_feedback(sctx);
@@ -840,7 +850,7 @@ static void si_decompress_subresource(struct pipe_context *ctx,
                si_decompress_depth(sctx, stex, planes,
                                    level, level,
                                    first_layer, last_layer);
-       } else if (stex->surface.fmask_size || stex->cmask_buffer || stex->dcc_offset) {
+       } else if (stex->surface.fmask_size || stex->cmask_buffer || stex->surface.dcc_offset) {
                /* If we've rendered into the framebuffer and it's a blitting
                 * source, make sure the decompression pass is invoked
                 * by dirtying the framebuffer.
@@ -855,7 +865,7 @@ static void si_decompress_subresource(struct pipe_context *ctx,
                }
 
                si_blit_decompress_color(sctx, stex, level, level,
-                                        first_layer, last_layer, false);
+                                        first_layer, last_layer, false, false);
        }
 }
 
@@ -896,7 +906,7 @@ void si_resource_copy_region(struct pipe_context *ctx,
            !util_format_is_compressed(dst->format) &&
            !util_format_is_depth_or_stencil(src->format) &&
            src->nr_samples <= 1 &&
-           !sdst->dcc_offset &&
+           !sdst->surface.dcc_offset &&
            !(dst->target != src->target &&
              (src->target == PIPE_TEXTURE_1D_ARRAY || dst->target == PIPE_TEXTURE_1D_ARRAY))) {
                si_compute_copy_image(sctx, dst, dst_level, src, src_level, dstx, dsty, dstz, src_box);
@@ -1153,10 +1163,13 @@ resolve_to_temp:
        templ.array_size = 1;
        templ.usage = PIPE_USAGE_DEFAULT;
        templ.flags = SI_RESOURCE_FLAG_FORCE_MSAA_TILING |
+                     SI_RESOURCE_FLAG_FORCE_MICRO_TILE_MODE |
+                     SI_RESOURCE_FLAG_MICRO_TILE_MODE_SET(src->surface.micro_tile_mode) |
                      SI_RESOURCE_FLAG_DISABLE_DCC;
 
        /* The src and dst microtile modes must be the same. */
-       if (src->surface.micro_tile_mode == RADEON_MICRO_MODE_DISPLAY)
+       if (sctx->chip_class <= GFX8 &&
+           src->surface.micro_tile_mode == RADEON_MICRO_MODE_DISPLAY)
                templ.bind = PIPE_BIND_SCANOUT;
        else
                templ.bind = 0;
@@ -1203,7 +1216,6 @@ static void si_blit(struct pipe_context *ctx,
         * on failure (recursion).
         */
        if (dst->surface.is_linear &&
-           sctx->dma_copy &&
            util_can_blit_via_copy_region(info, false)) {
                sctx->dma_copy(ctx, info->dst.resource, info->dst.level,
                                 info->dst.box.x, info->dst.box.y,
@@ -1228,7 +1240,7 @@ static void si_blit(struct pipe_context *ctx,
                                  info->src.box.z,
                                  info->src.box.z + info->src.box.depth - 1);
 
-       if (sctx->screen->debug_flags & DBG(FORCE_DMA) &&
+       if (sctx->screen->debug_flags & DBG(FORCE_SDMA) &&
            util_try_blit_via_copy_region(ctx, info))
                return;
 
@@ -1288,13 +1300,15 @@ static void si_flush_resource(struct pipe_context *ctx,
        if (tex->dcc_separate_buffer && !tex->separate_dcc_dirty)
                return;
 
-       if (!tex->is_depth && (tex->cmask_buffer || tex->dcc_offset)) {
+       if (!tex->is_depth && (tex->cmask_buffer || tex->surface.dcc_offset)) {
                si_blit_decompress_color(sctx, tex, 0, res->last_level,
                                         0, util_max_layer(res, 0),
-                                        tex->dcc_separate_buffer != NULL);
+                                        tex->dcc_separate_buffer != NULL, false);
 
-               if (tex->display_dcc_offset)
+               if (tex->surface.display_dcc_offset && tex->displayable_dcc_dirty) {
                        si_retile_dcc(sctx, tex);
+                       tex->displayable_dcc_dirty = false;
+               }
        }
 
        /* Always do the analysis even if DCC is disabled at the moment. */
@@ -1333,12 +1347,12 @@ void si_decompress_dcc(struct si_context *sctx, struct si_texture *tex)
        /* If graphics is disabled, we can't decompress DCC, but it shouldn't
         * be compressed either. The caller should simply discard it.
         */
-       if (!tex->dcc_offset || !sctx->has_graphics)
+       if (!tex->surface.dcc_offset || !sctx->has_graphics)
                return;
 
        si_blit_decompress_color(sctx, tex, 0, tex->buffer.b.b.last_level,
                                 0, util_max_layer(&tex->buffer.b.b, 0),
-                                true);
+                                true, false);
 }
 
 void si_init_blit_functions(struct si_context *sctx)