radv/gfx10: declare a LDS symbol for the NGG emit space
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 3 Sep 2019 11:01:54 +0000 (13:01 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 10 Sep 2019 07:27:01 +0000 (09:27 +0200)
This fixes some interactions when NGG GS is enabled. It fixes:

- dEQP-VK.clipping.user_defined.clip_cull_distance_dynamic_index.*geom*
- dEQP-VK.tessellation.geometry_interaction.passthrough.*

For some reasons, using the computed ESGS ring size randomly hangs
with CTS. For now, just use the maximum LDS size for ESGS.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_nir_to_llvm.c
src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_shader.c

index 178b0960db145d56b5f5cf3ad3af249880ed61cd..f7249913ec5378c8a000a2b5ceb1968268a8df8c 100644 (file)
@@ -4213,9 +4213,10 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
                                LLVMSetInitializer(ctx.gs_ngg_scratch, LLVMGetUndef(ai32));
                                LLVMSetAlignment(ctx.gs_ngg_scratch, 4);
 
                                LLVMSetInitializer(ctx.gs_ngg_scratch, LLVMGetUndef(ai32));
                                LLVMSetAlignment(ctx.gs_ngg_scratch, 4);
 
-                               ctx.gs_ngg_emit = LLVMBuildIntToPtr(ctx.ac.builder, ctx.ac.i32_0,
-                                       LLVMPointerType(LLVMArrayType(ctx.ac.i32, 0), AC_ADDR_SPACE_LDS),
-                                       "ngg_emit");
+                               ctx.gs_ngg_emit = LLVMAddGlobalInAddressSpace(ctx.ac.module,
+                                       LLVMArrayType(ctx.ac.i32, 0), "ngg_emit", AC_ADDR_SPACE_LDS);
+                               LLVMSetLinkage(ctx.gs_ngg_emit, LLVMExternalLinkage);
+                               LLVMSetAlignment(ctx.gs_ngg_emit, 4);
                        }
 
                        ctx.abi.load_inputs = load_gs_input;
                        }
 
                        ctx.abi.load_inputs = load_gs_input;
index 1bcc165301fb82303f17c336e0a7143494945db0..054f6ac36f85bcddf18b51e768e9b8e7526b4048 100644 (file)
@@ -2338,9 +2338,6 @@ radv_fill_shader_keys(struct radv_device *device,
                 * issues still:
                 *   * GS primitives in pipeline statistic queries do not get
                 *     updates. See dEQP-VK.query_pool.statistics_query.geometry_shader_primitives
                 * issues still:
                 *   * GS primitives in pipeline statistic queries do not get
                 *     updates. See dEQP-VK.query_pool.statistics_query.geometry_shader_primitives
-                *   * dEQP-VK.clipping.user_defined.clip_cull_distance_dynamic_index.*geom* failures
-                *   * Interactions with tessellation failing:
-                *     dEQP-VK.tessellation.geometry_interaction.passthrough.tessellate_isolines_passthrough_geometry_no_change
                 *   * General issues with the last primitive missing/corrupt:
                 *     https://bugs.freedesktop.org/show_bug.cgi?id=111248
                 *
                 *   * General issues with the last primitive missing/corrupt:
                 *     https://bugs.freedesktop.org/show_bug.cgi?id=111248
                 *
index 146d85ade5a02dd73330f43e4d8bcb19d90fbcaf..473b6b0032f950450165d8fe4f956ada084a2346 100644 (file)
@@ -882,44 +882,33 @@ radv_shader_variant_create(struct radv_device *device,
        variant->ref_count = 1;
 
        if (binary->type == RADV_BINARY_TYPE_RTLD) {
        variant->ref_count = 1;
 
        if (binary->type == RADV_BINARY_TYPE_RTLD) {
-               struct ac_rtld_symbol lds_symbols[1];
+               struct ac_rtld_symbol lds_symbols[2];
                unsigned num_lds_symbols = 0;
                const char *elf_data = (const char *)((struct radv_shader_binary_rtld *)binary)->data;
                size_t elf_size = ((struct radv_shader_binary_rtld *)binary)->elf_size;
                unsigned num_lds_symbols = 0;
                const char *elf_data = (const char *)((struct radv_shader_binary_rtld *)binary)->data;
                size_t elf_size = ((struct radv_shader_binary_rtld *)binary)->elf_size;
-               unsigned esgs_ring_size = 0;
 
                if (device->physical_device->rad_info.chip_class >= GFX9 &&
 
                if (device->physical_device->rad_info.chip_class >= GFX9 &&
-                   binary->stage == MESA_SHADER_GEOMETRY && !binary->is_gs_copy_shader) {
-                       /* TODO: Do not hardcode this value */
-                       esgs_ring_size = 32 * 1024;
-               }
-
-               if (binary->info.is_ngg) {
-                       /* GS stores Primitive IDs into LDS at the address
-                        * corresponding to the ES thread of the provoking
-                        * vertex. All ES threads load and export PrimitiveID
-                        * for their thread.
-                        */
-                       if (binary->stage == MESA_SHADER_VERTEX &&
-                           binary->info.vs.export_prim_id) {
-                               /* TODO: Do not harcode this value */
-                               esgs_ring_size = 256 /* max_out_verts */ * 4;
-                       }
-               }
-
-               if (esgs_ring_size) {
+                   (binary->stage == MESA_SHADER_GEOMETRY || binary->info.is_ngg) &&
+                   !binary->is_gs_copy_shader) {
                        /* We add this symbol even on LLVM <= 8 to ensure that
                         * shader->config.lds_size is set correctly below.
                         */
                        /* We add this symbol even on LLVM <= 8 to ensure that
                         * shader->config.lds_size is set correctly below.
                         */
+                       /* TODO: For some reasons, using the computed ESGS ring
+                        * size randomly hangs with CTS. Just use the maximum
+                        * possible LDS size for now.
+                        */
                        struct ac_rtld_symbol *sym = &lds_symbols[num_lds_symbols++];
                        sym->name = "esgs_ring";
                        struct ac_rtld_symbol *sym = &lds_symbols[num_lds_symbols++];
                        sym->name = "esgs_ring";
-                       sym->size = esgs_ring_size;
+                       sym->size = (32 * 1024) - (binary->info.ngg_info.ngg_emit_size * 4) - 32; /* 32 is NGG scratch */
                        sym->align = 64 * 1024;
                        sym->align = 64 * 1024;
+               }
 
 
-                       /* Make sure to have LDS space for NGG scratch. */
-                       /* TODO: Compute this correctly somehow? */
-                       if (binary->info.is_ngg)
-                               sym->size -= 32;
+               if (binary->info.is_ngg &&
+                   binary->stage == MESA_SHADER_GEOMETRY) {
+                       struct ac_rtld_symbol *sym = &lds_symbols[num_lds_symbols++];
+                       sym->name = "ngg_emit";
+                       sym->size = binary->info.ngg_info.ngg_emit_size * 4;
+                       sym->align = 4;
                }
 
                struct ac_rtld_open_info open_info = {
                }
 
                struct ac_rtld_open_info open_info = {