<div dir="ltr"><div>FYI, the environment variable will only have effect on amdgpu.<br><br></div>Marek<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 2, 2018 at 12:13 AM, Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
<br>
This is for testing and experiments.<br>
---<br>
 src/gallium/drivers/radeonsi/<wbr>si_pipe.c    | 22 ++++++++++++++++<br>
 src/gallium/drivers/radeonsi/<wbr>si_pipe.h    |  3 +++<br>
 src/gallium/drivers/radeonsi/<wbr>si_state.c   |  5 ++++<br>
 src/gallium/drivers/radeonsi/<wbr>si_texture.c | 31 +++++++++++++++++++----<br>
 4 files changed, 56 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/<wbr>radeonsi/si_pipe.c b/src/gallium/drivers/<wbr>radeonsi/si_pipe.c<br>
index 1ca38ed55cb..35c2c200e57 100644<br>
--- a/src/gallium/drivers/<wbr>radeonsi/si_pipe.c<br>
+++ b/src/gallium/drivers/<wbr>radeonsi/si_pipe.c<br>
@@ -1065,20 +1065,42 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,<br>
        sscreen->barrier_flags.cp_to_<wbr>L2 = SI_CONTEXT_INV_SMEM_L1 |<br>
                                            SI_CONTEXT_INV_VMEM_L1;<br>
        if (sscreen->info.chip_class <= VI) {<br>
                sscreen->barrier_flags.cp_to_<wbr>L2 |= SI_CONTEXT_INV_GLOBAL_L2;<br>
                sscreen->barrier_flags.L2_to_<wbr>cp |= SI_CONTEXT_WRITEBACK_GLOBAL_<wbr>L2;<br>
        }<br>
<br>
        if (debug_get_bool_option("<wbr>RADEON_DUMP_SHADERS", false))<br>
                sscreen->debug_flags |= DBG_ALL_SHADERS;<br>
<br>
+       /* Syntax:<br>
+        *     EQAA=s,z,c<br>
+        * Example:<br>
+        *     EQAA=8,4,2<br>
+<br>
+        * That means 8 coverage samples, 4 Z/S samples, and 2 color samples.<br>
+        * Constraints:<br>
+        *     s >= z >= c (ignoring this only wastes memory)<br>
+        *     s = [2..16]<br>
+        *     z = [2..8]<br>
+        *     c = [2..8]<br>
+        *<br>
+        * Only MSAA color and depth buffers are overriden.<br>
+        */<br>
+       const char *eqaa = debug_get_option("EQAA", NULL);<br>
+       unsigned s,z,f;<br>
+       if (eqaa && sscanf(eqaa, "%u,%u,%u", &s, &z, &f) == 3 && s && z && f) {<br>
+               sscreen->eqaa_force_coverage_<wbr>samples = s;<br>
+               sscreen->eqaa_force_z_samples = z;<br>
+               sscreen->eqaa_force_color_<wbr>samples = f;<br>
+       }<br>
+<br>
        for (i = 0; i < num_comp_hi_threads; i++)<br>
                si_init_compiler(sscreen, &sscreen->compiler[i]);<br>
        for (i = 0; i < num_comp_lo_threads; i++)<br>
                si_init_compiler(sscreen, &sscreen->compiler_lowp[i]);<br>
<br>
        /* Create the auxiliary context. This must be done last. */<br>
        sscreen->aux_context = si_create_context(&sscreen->b, 0);<br>
<br>
        if (sscreen->debug_flags & DBG(TEST_DMA))<br>
                si_test_dma(sscreen);<br>
diff --git a/src/gallium/drivers/<wbr>radeonsi/si_pipe.h b/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
index 55a135f3870..6917d5e6068 100644<br>
--- a/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
+++ b/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
@@ -409,20 +409,23 @@ struct si_screen {<br>
<br>
        struct radeon_info              info;<br>
        uint64_t                        debug_flags;<br>
        char                            renderer_string[100];<br>
<br>
        unsigned                        gs_table_depth;<br>
        unsigned                        tess_offchip_block_dw_size;<br>
        unsigned                        tess_offchip_ring_size;<br>
        unsigned                        tess_factor_ring_size;<br>
        unsigned                        vgt_hs_offchip_param;<br>
+       unsigned                        eqaa_force_coverage_samples;<br>
+       unsigned                        eqaa_force_z_samples;<br>
+       unsigned                        eqaa_force_color_samples;<br>
        bool                            has_clear_state;<br>
        bool                            has_distributed_tess;<br>
        bool                            has_draw_indirect_multi;<br>
        bool                            has_out_of_order_rast;<br>
        bool                            assume_no_z_fights;<br>
        bool                            commutative_blend_add;<br>
        bool                            clear_db_cache_before_clear;<br>
        bool                            has_msaa_sample_loc_bug;<br>
        bool                            has_ls_vgpr_init_bug;<br>
        bool                            dpbb_allowed;<br>
diff --git a/src/gallium/drivers/<wbr>radeonsi/si_state.c b/src/gallium/drivers/<wbr>radeonsi/si_state.c<br>
index e133bf28589..c7585b285e9 100644<br>
--- a/src/gallium/drivers/<wbr>radeonsi/si_state.c<br>
+++ b/src/gallium/drivers/<wbr>radeonsi/si_state.c<br>
@@ -2112,20 +2112,21 @@ static bool si_is_zs_format_supported(enum pipe_format format)<br>
 {<br>
        return si_translate_dbformat(format) != V_028040_Z_INVALID;<br>
 }<br>
<br>
 static boolean si_is_format_supported(struct pipe_screen *screen,<br>
                                      enum pipe_format format,<br>
                                      enum pipe_texture_target target,<br>
                                      unsigned sample_count,<br>
                                      unsigned usage)<br>
 {<br>
+       struct si_screen *sscreen = (struct si_screen *)screen;<br>
        unsigned retval = 0;<br>
<br>
        if (target >= PIPE_MAX_TEXTURE_TYPES) {<br>
                PRINT_ERR("r600: unsupported texture type %d\n", target);<br>
                return false;<br>
        }<br>
<br>
        if (!util_format_is_supported(<wbr>format, usage))<br>
                return false;<br>
<br>
@@ -2135,20 +2136,24 @@ static boolean si_is_format_supported(struct pipe_screen *screen,<br>
<br>
                if (usage & PIPE_BIND_SHADER_IMAGE)<br>
                        return false;<br>
<br>
                switch (sample_count) {<br>
                case 2:<br>
                case 4:<br>
                case 8:<br>
                        break;<br>
                case 16:<br>
+                       /* Allow resource_copy_region with nr_samples == 16. */<br>
+                       if (sscreen->eqaa_force_coverage_<wbr>samples == 16 &&<br>
+                           !util_format_is_depth_or_<wbr>stencil(format))<br>
+                               return true;<br>
                        if (format == PIPE_FORMAT_NONE)<br>
                                return true;<br>
                        else<br>
                                return false;<br>
                default:<br>
                        return false;<br>
                }<br>
        }<br>
<br>
        if (usage & (PIPE_BIND_SAMPLER_VIEW |<br>
diff --git a/src/gallium/drivers/<wbr>radeonsi/si_texture.c b/src/gallium/drivers/<wbr>radeonsi/si_texture.c<br>
index 52b8b87732f..804708e0516 100644<br>
--- a/src/gallium/drivers/<wbr>radeonsi/si_texture.c<br>
+++ b/src/gallium/drivers/<wbr>radeonsi/si_texture.c<br>
@@ -1380,47 +1380,68 @@ si_choose_tiling(struct si_screen *sscreen,<br>
<br>
        /* Make small textures 1D tiled. */<br>
        if (templ->width0 <= 16 || templ->height0 <= 16 ||<br>
            (sscreen->debug_flags & DBG(NO_2D_TILING)))<br>
                return RADEON_SURF_MODE_1D;<br>
<br>
        /* The allocator will switch to 1D if needed. */<br>
        return RADEON_SURF_MODE_2D;<br>
 }<br>
<br>
-static unsigned si_get_num_color_samples(const struct pipe_resource *templ,<br>
+static unsigned si_get_num_color_samples(<wbr>struct si_screen *sscreen,<br>
+                                        const struct pipe_resource *templ,<br>
                                         bool imported)<br>
 {<br>
+       if (!imported && templ->nr_samples >= 2 &&<br>
+           sscreen->eqaa_force_color_<wbr>samples)<br>
+               return sscreen->eqaa_force_color_<wbr>samples;<br>
+<br>
        return CLAMP(templ->nr_samples, 1, 8);<br>
 }<br>
<br>
 struct pipe_resource *si_texture_create(struct pipe_screen *screen,<br>
                                        const struct pipe_resource *templ)<br>
 {<br>
        struct si_screen *sscreen = (struct si_screen*)screen;<br>
+       bool is_zs = util_format_is_depth_or_<wbr>stencil(templ->format);<br>
+<br>
+       if (templ->nr_samples >= 2) {<br>
+               /* This is hackish (overwriting the const pipe_resource template),<br>
+                * but should be harmless and state trackers can also see<br>
+                * the overriden number of samples in the created pipe_resource.<br>
+                */<br>
+               if (is_zs && sscreen->eqaa_force_z_samples) {<br>
+                       ((struct pipe_resource*)templ)->nr_<wbr>samples =<br>
+                               sscreen->eqaa_force_z_samples;<br>
+               } else if (!is_zs && sscreen->eqaa_force_color_<wbr>samples) {<br>
+                       ((struct pipe_resource*)templ)->nr_<wbr>samples =<br>
+                               sscreen->eqaa_force_coverage_<wbr>samples;<br>
+               }<br>
+       }<br>
+<br>
        struct radeon_surf surface = {0};<br>
        bool is_flushed_depth = templ->flags & SI_RESOURCE_FLAG_FLUSHED_<wbr>DEPTH;<br>
        bool tc_compatible_htile =<br>
                sscreen->info.chip_class >= VI &&<br>
                /* There are issues with TC-compatible HTILE on Tonga (and<br>
                 * Iceland is the same design), and documented bug workarounds<br>
                 * don't help. For example, this fails:<br>
                 *   piglit/bin/tex-miplevel-<wbr>selection 'texture()' 2DShadow -auto<br>
                 */<br>
                sscreen->info.family != CHIP_TONGA &&<br>
                sscreen->info.family != CHIP_ICELAND &&<br>
                (templ->flags & PIPE_RESOURCE_FLAG_TEXTURING_<wbr>MORE_LIKELY) &&<br>
                !(sscreen->debug_flags & DBG(NO_HYPERZ)) &&<br>
                !is_flushed_depth &&<br>
                templ->nr_samples <= 1 && /* TC-compat HTILE is less efficient with MSAA */<br>
-               util_format_is_depth_or_<wbr>stencil(templ->format);<br>
-       unsigned num_color_samples = si_get_num_color_samples(<wbr>templ, false);<br>
+               is_zs;<br>
+       unsigned num_color_samples = si_get_num_color_samples(<wbr>sscreen, templ, false);<br>
        int r;<br>
<br>
        r = si_init_surface(sscreen, &surface, templ, num_color_samples,<br>
                            si_choose_tiling(sscreen, templ, tc_compatible_htile),<br>
                            0, 0, false, false, is_flushed_depth,<br>
                            tc_compatible_htile);<br>
        if (r) {<br>
                return NULL;<br>
        }<br>
<br>
@@ -1450,21 +1471,21 @@ static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen,<br>
                return NULL;<br>
<br>
        buf = sscreen->ws->buffer_from_<wbr>handle(sscreen->ws, whandle, &stride, &offset);<br>
        if (!buf)<br>
                return NULL;<br>
<br>
        sscreen->ws->buffer_get_<wbr>metadata(buf, &metadata);<br>
        si_surface_import_metadata(<wbr>sscreen, &surface, &metadata,<br>
                                     &array_mode, &is_scanout);<br>
<br>
-       unsigned num_color_samples = si_get_num_color_samples(<wbr>templ, true);<br>
+       unsigned num_color_samples = si_get_num_color_samples(<wbr>sscreen, templ, true);<br>
<br>
        r = si_init_surface(sscreen, &surface, templ, num_color_samples,<br>
                            array_mode, stride, offset, true, is_scanout,<br>
                            false, false);<br>
        if (r) {<br>
                return NULL;<br>
        }<br>
<br>
        rtex = si_texture_create_object(<wbr>screen, templ, num_color_samples,<br>
                                        buf, &surface);<br>
@@ -2384,21 +2405,21 @@ si_texture_from_memobj(struct pipe_screen *screen,<br>
                 * implementation simple.<br>
                 *<br>
                 * A possible alternative is to attempt to reconstruct the<br>
                 * tiling information when the TexParameter TEXTURE_TILING_EXT<br>
                 * is set.<br>
                 */<br>
                array_mode = RADEON_SURF_MODE_LINEAR_<wbr>ALIGNED;<br>
                is_scanout = false;<br>
        }<br>
<br>
-       unsigned num_color_samples = si_get_num_color_samples(<wbr>templ, true);<br>
+       unsigned num_color_samples = si_get_num_color_samples(<wbr>sscreen, templ, true);<br>
<br>
        r = si_init_surface(sscreen, &surface, templ, num_color_samples,<br>
                            array_mode, memobj->stride, offset, true,<br>
                            is_scanout, false, false);<br>
        if (r)<br>
                return NULL;<br>
<br>
        rtex = si_texture_create_object(<wbr>screen, templ, num_color_samples,<br>
                                        memobj->buf, &surface);<br>
        if (!rtex)<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.17.0<br>
<br>
</font></span></blockquote></div><br></div>