From: Sagar Ghuge Date: Fri, 24 Jan 2020 06:24:37 +0000 (-0800) Subject: intel/compiler: Track patch count threshold X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1a5ac646cefaa183ee09b149ea31931d122c0f51;p=mesa.git intel/compiler: Track patch count threshold Return the number of patches to accumulate before an 8_PATCH mode thread is launched. v2: (Kenneth Graunke) - Track patch count threshold instead of input control points. Signed-off-by: Sagar Ghuge Reviewed-by: Kenneth Graunke Part-of: --- diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h index 181f7e5f67c..2048cfaafcc 100644 --- a/src/intel/compiler/brw_compiler.h +++ b/src/intel/compiler/brw_compiler.h @@ -1136,6 +1136,9 @@ struct brw_tcs_prog_data /** Number vertices in output patch */ int instances; + + /** Track patch count threshold */ + int patch_count_threshold; }; diff --git a/src/intel/compiler/brw_vec4_tcs.cpp b/src/intel/compiler/brw_vec4_tcs.cpp index 1cba9a9a4f8..fcefe395f2d 100644 --- a/src/intel/compiler/brw_vec4_tcs.cpp +++ b/src/intel/compiler/brw_vec4_tcs.cpp @@ -323,6 +323,34 @@ vec4_tcs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr) } } +/** + * Return the number of patches to accumulate before an 8_PATCH mode thread is + * launched. In cases with a large number of input control points and a large + * amount of VS outputs, the VS URB space needed to store an entire 8 patches + * worth of data can be prohibitive, so it can be beneficial to launch threads + * early. + * + * See the 3DSTATE_HS::Patch Count Threshold documentation for the recommended + * values. Note that 0 means to "disable" early dispatch, meaning to wait for + * a full 8 patches as normal. + */ +static int +get_patch_count_threshold(int input_control_points) +{ + if (input_control_points <= 4) + return 0; + else if (input_control_points <= 6) + return 5; + else if (input_control_points <= 8) + return 4; + else if (input_control_points <= 10) + return 3; + else if (input_control_points <= 14) + return 2; + + /* Return patch count 1 for PATCHLIST_15 - PATCHLIST_32 */ + return 1; +} extern "C" const unsigned * brw_compile_tcs(const struct brw_compiler *compiler, @@ -362,6 +390,8 @@ brw_compile_tcs(const struct brw_compiler *compiler, bool has_primitive_id = nir->info.system_values_read & (1 << SYSTEM_VALUE_PRIMITIVE_ID); + prog_data->patch_count_threshold = get_patch_count_threshold(key->input_vertices); + if (compiler->use_tcs_8_patch && nir->info.tess.tcs_vertices_out <= (devinfo->gen >= 12 ? 32 : 16) && 2 + has_primitive_id + key->input_vertices <= 31) {