<div dir="ltr"><div>I think Vulkan doesn't need to use legacy GS, because gs_invocations doesn't multiply the max_out_vertices limit in Vulkan, but it does multiply it in GL.<br></div><div><br></div><div>Marek<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 16, 2019 at 10:39 AM Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It should be possible to build it on-demand too but it requires<br>
more work. On GFX10, the GS copy shader is required when tess<br>
is enabled with extreme geometry.<br>
<br>
Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com" target="_blank">samuel.pitoiset@gmail.com</a>><br>
---<br>
 src/amd/vulkan/radv_cmd_buffer.c |  8 ++++----<br>
 src/amd/vulkan/radv_pipeline.c   | 21 ++++++++++++++++++---<br>
 src/amd/vulkan/radv_private.h    |  2 ++<br>
 3 files changed, 24 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c<br>
index 6a0db2b67e9..a6d4e0d0e21 100644<br>
--- a/src/amd/vulkan/radv_cmd_buffer.c<br>
+++ b/src/amd/vulkan/radv_cmd_buffer.c<br>
@@ -929,7 +929,7 @@ radv_emit_prefetch_L2(struct radv_cmd_buffer *cmd_buffer,<br>
        if (mask & RADV_PREFETCH_GS) {<br>
                radv_emit_shader_prefetch(cmd_buffer,<br>
                                          pipeline->shaders[MESA_SHADER_GEOMETRY]);<br>
-               if (pipeline->gs_copy_shader)<br>
+               if (radv_pipeline_has_gs_copy_shader(pipeline))<br>
                        radv_emit_shader_prefetch(cmd_buffer, pipeline->gs_copy_shader);<br>
        }<br>
<br>
@@ -1124,7 +1124,7 @@ radv_emit_graphics_pipeline(struct radv_cmd_buffer *cmd_buffer)<br>
                                   pipeline->shaders[i]->bo);<br>
        }<br>
<br>
-       if (radv_pipeline_has_gs(pipeline) && pipeline->gs_copy_shader)<br>
+       if (radv_pipeline_has_gs_copy_shader(pipeline))<br>
                radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs,<br>
                                   pipeline->gs_copy_shader->bo);<br>
<br>
@@ -2362,7 +2362,7 @@ radv_emit_streamout_buffers(struct radv_cmd_buffer *cmd_buffer, uint64_t va)<br>
                                         base_reg + loc->sgpr_idx * 4, va, false);<br>
        }<br>
<br>
-       if (pipeline->gs_copy_shader) {<br>
+       if (radv_pipeline_has_gs_copy_shader(pipeline)) {<br>
                loc = &pipeline->gs_copy_shader->info.user_sgprs_locs.shader_data[AC_UD_STREAMOUT_BUFFERS];<br>
                if (loc->sgpr_idx != -1) {<br>
                        base_reg = R_00B130_SPI_SHADER_USER_DATA_VS_0;<br>
@@ -4071,7 +4071,7 @@ static void radv_emit_view_index(struct radv_cmd_buffer *cmd_buffer, unsigned in<br>
                radeon_set_sh_reg(cmd_buffer->cs, base_reg + loc->sgpr_idx * 4, index);<br>
<br>
        }<br>
-       if (pipeline->gs_copy_shader) {<br>
+       if (radv_pipeline_has_gs_copy_shader(pipeline)) {<br>
                struct radv_userdata_info *loc = &pipeline->gs_copy_shader->info.user_sgprs_locs.shader_data[AC_UD_VIEW_INDEX];<br>
                if (loc->sgpr_idx != -1) {<br>
                        uint32_t base_reg = R_00B130_SPI_SHADER_USER_DATA_VS_0;<br>
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c<br>
index 31495ec078d..d1eede172dc 100644<br>
--- a/src/amd/vulkan/radv_pipeline.c<br>
+++ b/src/amd/vulkan/radv_pipeline.c<br>
@@ -120,6 +120,22 @@ bool radv_pipeline_has_ngg(const struct radv_pipeline *pipeline)<br>
        return variant->info.is_ngg;<br>
 }<br>
<br>
+bool radv_pipeline_has_gs_copy_shader(const struct radv_pipeline *pipeline)<br>
+{<br>
+       if (!radv_pipeline_has_gs(pipeline))<br>
+               return false;<br>
+<br>
+       /* The GS copy shader is required if the pipeline has GS on GFX6-GFX9.<br>
+        * On GFX10, it might be required in rare cases if it's not possible to<br>
+        * enable NGG.<br>
+        */<br>
+       if (radv_pipeline_has_ngg(pipeline))<br>
+               return false;<br>
+<br>
+       assert(pipeline->gs_copy_shader);<br>
+       return true;<br>
+}<br>
+<br>
 static void<br>
 radv_pipeline_destroy(struct radv_device *device,<br>
                       struct radv_pipeline *pipeline,<br>
@@ -2395,7 +2411,6 @@ void radv_create_shaders(struct radv_pipeline *pipeline,<br>
        struct radv_shader_binary *binaries[MESA_SHADER_STAGES] = {NULL};<br>
        struct radv_shader_variant_key keys[MESA_SHADER_STAGES] = {{{{{0}}}}};<br>
        unsigned char hash[20], gs_copy_hash[20];<br>
-       bool use_ngg = device->physical_device->rad_info.chip_class >= GFX10;<br>
<br>
        radv_start_feedback(pipeline_feedback);<br>
<br>
@@ -2416,7 +2431,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,<br>
        gs_copy_hash[0] ^= 1;<br>
<br>
        bool found_in_application_cache = true;<br>
-       if (modules[MESA_SHADER_GEOMETRY] && !use_ngg) {<br>
+       if (modules[MESA_SHADER_GEOMETRY]) {<br>
                struct radv_shader_variant *variants[MESA_SHADER_STAGES] = {0};<br>
                radv_create_shader_variants_from_pipeline_cache(device, cache, gs_copy_hash, variants,<br>
                                                                &found_in_application_cache);<br>
@@ -2567,7 +2582,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,<br>
                }<br>
        }<br>
<br>
-       if(modules[MESA_SHADER_GEOMETRY] && !use_ngg) {<br>
+       if(modules[MESA_SHADER_GEOMETRY]) {<br>
                struct radv_shader_binary *gs_copy_binary = NULL;<br>
                if (!pipeline->gs_copy_shader) {<br>
                        pipeline->gs_copy_shader = radv_create_gs_copy_shader(<br>
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h<br>
index 08c2abef7ab..b9ac97249d3 100644<br>
--- a/src/amd/vulkan/radv_private.h<br>
+++ b/src/amd/vulkan/radv_private.h<br>
@@ -1512,6 +1512,8 @@ static inline bool radv_pipeline_has_tess(const struct radv_pipeline *pipeline)<br>
<br>
 bool radv_pipeline_has_ngg(const struct radv_pipeline *pipeline);<br>
<br>
+bool radv_pipeline_has_gs_copy_shader(const struct radv_pipeline *pipeline);<br>
+<br>
 struct radv_userdata_info *radv_lookup_user_sgpr(struct radv_pipeline *pipeline,<br>
                                                 gl_shader_stage stage,<br>
                                                 int idx);<br>
-- <br>
2.22.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div></div>