radv: calculate the GSVS vertex size in the shader info pass
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 3 Sep 2019 16:16:33 +0000 (18:16 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 6 Sep 2019 13:52:22 +0000 (15:52 +0200)
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_shader_info.c

index e0503908ee3e43fedc4781d142daf85d6ff8166d..0ba81322ac0fc16853c6e9dd0ab42206ec2e71bc 100644 (file)
@@ -108,8 +108,6 @@ struct radv_shader_context {
 
        uint32_t tcs_num_inputs;
        uint32_t tcs_num_patches;
-       uint32_t max_gsvs_emit_size;
-       uint32_t gsvs_vertex_size;
 
        LLVMValueRef vertexptr; /* GFX10 only */
 };
@@ -3605,7 +3603,7 @@ static void gfx10_ngg_gs_emit_vertex(struct radv_shader_context *ctx,
                        LLVMBuildStore(builder, out_val, ptr);
                }
        }
-       assert(out_idx * 4 <= ctx->gsvs_vertex_size);
+       assert(out_idx * 4 <= ctx->shader_info->gs.gsvs_vertex_size);
 
        /* Determine and store whether this vertex completed a primitive. */
        const LLVMValueRef curverts = LLVMBuildLoad(builder, ctx->gs_curprim_verts[stream], "");
@@ -4282,14 +4280,6 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
                nir_foreach_variable(variable, &shaders[i]->outputs)
                        scan_shader_output_decl(&ctx, variable, shaders[i], shaders[i]->info.stage);
 
-               if (shaders[i]->info.stage == MESA_SHADER_GEOMETRY) {
-                       unsigned addclip = shaders[i]->info.clip_distance_array_size +
-                                       shaders[i]->info.cull_distance_array_size > 4;
-                       ctx.gsvs_vertex_size = (util_bitcount64(ctx.output_mask) + addclip) * 16;
-                       ctx.max_gsvs_emit_size = ctx.gsvs_vertex_size *
-                               shaders[i]->info.gs.vertices_out;
-               }
-
                ac_setup_rings(&ctx);
 
                LLVMBasicBlockRef merge_block;
@@ -4332,10 +4322,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
                        gfx10_ngg_gs_emit_epilogue_2(&ctx);
                }
 
-               if (shaders[i]->info.stage == MESA_SHADER_GEOMETRY) {
-                       shader_info->gs.gsvs_vertex_size = ctx.gsvs_vertex_size;
-                       shader_info->gs.max_gsvs_emit_size = ctx.max_gsvs_emit_size;
-               } else if (shaders[i]->info.stage == MESA_SHADER_TESS_CTRL) {
+               if (shaders[i]->info.stage == MESA_SHADER_TESS_CTRL) {
                        shader_info->tcs.num_patches = ctx.tcs_num_patches;
                        shader_info->tcs.lds_size = calculate_tess_lds_size(&ctx);
                }
index 7f2d9752948f9b008f5daab49ec7d9305ef3cdce..065cec3e0e71d26221bab2b06c90750bebf3a35f 100644 (file)
@@ -744,4 +744,13 @@ radv_nir_shader_info_pass(const struct nir_shader *nir,
         default:
                 break;
         }
+
+       if (nir->info.stage == MESA_SHADER_GEOMETRY) {
+               unsigned add_clip = nir->info.clip_distance_array_size +
+                                   nir->info.cull_distance_array_size > 4;
+               info->gs.gsvs_vertex_size =
+                       (util_bitcount64(nir->info.outputs_written) + add_clip) * 16;
+               info->gs.max_gsvs_emit_size =
+                       info->gs.gsvs_vertex_size * nir->info.gs.vertices_out;
+       }
 }