Module: Mesa Branch: main Commit: 155eb72771964a5d0005ef6a87e1b76642fda324 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=155eb72771964a5d0005ef6a87e1b76642fda324
Author: Konstantin Seurer <[email protected]> Date: Fri May 26 21:32:25 2023 +0200 treewide: Add a .clang-format file Add a Mesa base style instead of copying the same rules multiple times. This is especially annoying with foreach macros, where every .clang-format file maintains it's own incomplete list of the same macros. Adding a tree wide .clang-format allows other drivers to derive their code style from whatever is considered default Mesa style. Since clang-format doesn't allow us to derive ForEachMacros, driver specific foreach macros have to be added to the common file. Having a tree wide clang format should also help (new) contributers with working oin parts of the tree that don't have their own .clang-format file. (With regards to code formatting) Acked-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23275> --- .gitlab-ci/test-source-dep.yml | 1 + src/.clang-format | 302 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 303 insertions(+) diff --git a/.gitlab-ci/test-source-dep.yml b/.gitlab-ci/test-source-dep.yml index bf50f3088ec..5cd7768e8a3 100644 --- a/.gitlab-ci/test-source-dep.yml +++ b/.gitlab-ci/test-source-dep.yml @@ -997,6 +997,7 @@ - .clang-format - .clang-format-include - .clang-format-ignore + - src/**/.clang-format - src/**/asahi/**/* - src/**/panfrost/**/* when: on_success diff --git a/src/.clang-format b/src/.clang-format new file mode 100644 index 00000000000..9a94417ef08 --- /dev/null +++ b/src/.clang-format @@ -0,0 +1,302 @@ + +AlignAfterOpenBracket: true +AlignConsecutiveMacros: true + +AllowAllArgumentsOnNextLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false + +AlwaysBreakAfterReturnType: TopLevelDefinitions + +BraceWrapping: + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterStruct: false + BeforeElse: false + SplitEmptyFunction: true + +BinPackArguments: true +BinPackParameters: true + +BreakBeforeBraces: Custom + +ColumnLimit: 100 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyExcessCharacter: 100 + +ContinuationIndentWidth: 3 +IndentWidth: 3 +UseTab: Never + +Cpp11BracedListStyle: true + +SpaceAfterCStyleCast: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: false +SpacesInContainerLiterals: false + +PointerAlignment: Right + +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '<[[:alnum:].]+>' + Priority: 1 + - Regex: '.*\/.*' + Priority: 2 + - Regex: '.*' + Priority: 3 + +ForEachMacros: +# util + - u_foreach_bit + - u_foreach_bit64 + + - BITSET_FOREACH_SET + - BITSET_FOREACH_RANGE + + - hash_table_foreach + - hash_table_foreach_remove + + - rb_tree_foreach + - rb_tree_foreach_rev + - rb_tree_foreach_rev_safe + - rb_tree_foreach_safe + + - set_foreach + - set_foreach_remove + + - util_dynarray_foreach + - util_dynarray_foreach_reverse + + - util_idalloc_foreach + + - LIST_FOR_EACH_ENTRY + - LIST_FOR_EACH_ENTRY_FROM + - LIST_FOR_EACH_ENTRY_FROM_REV + - LIST_FOR_EACH_ENTRY_SAFE + - LIST_FOR_EACH_ENTRY_SAFE_REV + - list_for_each_entry + - list_for_each_entry_from + - list_for_each_entry_from_rev + - list_for_each_entry_from_safe + - list_for_each_entry_rev + - list_for_each_entry_rev_safe + - list_for_each_entry_safe + - list_pair_for_each_entry + + - foreach_in_list + - foreach_in_list_reverse + - foreach_in_list_reverse_safe + - foreach_in_list_safe + - foreach_in_list_use_after + - foreach_list_typed + - foreach_list_typed_from + - foreach_list_typed_reverse + - foreach_list_typed_reverse_safe + - foreach_list_typed_safe + - foreach_two_lists + +# nir + - nir_foreach_function_temp_variable + - nir_foreach_function_temp_variable_safe + - nir_foreach_image_variable + - nir_foreach_image_variable_safe + - nir_foreach_shader_in_variable + - nir_foreach_shader_in_variable_safe + - nir_foreach_shader_out_variable + - nir_foreach_shader_out_variable_safe + - nir_foreach_uniform_variable + - nir_foreach_uniform_variable_safe + - nir_foreach_variable + - nir_foreach_variable_in_list + - nir_foreach_variable_in_list_safe + - nir_foreach_variable_in_shader + - nir_foreach_variable_in_shader_safe + - nir_foreach_variable_safe + - nir_foreach_variable_with_modes + - nir_foreach_variable_with_modes_safe + + - nir_foreach_register + - nir_foreach_register_safe + + - nir_foreach_if_use + - nir_foreach_if_use_safe + - nir_foreach_use + - nir_foreach_use_including_if + - nir_foreach_use_including_if_safe + - nir_foreach_use_safe + + - nir_foreach_def + - nir_foreach_def_safe + + - nir_foreach_phi_src + - nir_foreach_phi_src_safe + + - nir_foreach_parallel_copy_entry + + - nir_foreach_instr + - nir_foreach_instr_in_worklist + - nir_foreach_instr_reverse + - nir_foreach_instr_reverse_safe + - nir_foreach_instr_safe + + - nir_foreach_phi + - nir_foreach_phi_safe + + - nir_foreach_function + + - nir_foreach_block_unstructured + - nir_foreach_block_unstructured_safe + + - nir_foreach_block + - nir_foreach_block_in_cf_node + - nir_foreach_block_reverse + - nir_foreach_block_reverse_safe + - nir_foreach_block_safe + + - nir_foreach_src + +# vulkan + - vk_foreach_queue + - vk_foreach_queue_safe + + - vk_foreach_struct + - vk_foreach_struct_const + + - vk_foreach_multi_draw + - vk_foreach_multi_draw_indexed + +# asahi + - foreach_active + - foreach_submitted + - AGX_BATCH_FOREACH_BO_HANDLE + - agx_pack + - agx_usc_pack + - agx_ppp_push + - agx_foreach_block + - agx_foreach_block_from + - agx_foreach_block_from_rev + - agx_foreach_block_rev + - agx_foreach_dest + - agx_foreach_instr_global + - agx_foreach_instr_global_rev + - agx_foreach_instr_global_safe + - agx_foreach_instr_global_safe_rev + - agx_foreach_instr_in_block + - agx_foreach_instr_in_block_from + - agx_foreach_instr_in_block_from_rev + - agx_foreach_instr_in_block_rev + - agx_foreach_instr_in_block_safe + - agx_foreach_instr_in_block_safe_rev + - agx_foreach_non_phi_in_block_rev + - agx_foreach_phi_in_block + - agx_foreach_predecessor + - agx_foreach_src + - agx_foreach_ssa_dest + - agx_foreach_ssa_src + - agx_foreach_successor + +# radv + - PHASE + +# freedreno + - ir2_foreach_instr + - ir2_foreach_live_reg + - ir2_foreach_avail + - ir2_foreach_src + - foreach_two_lists + - foreach_sched_node + - foreach_src + - foreach_src_n + - foreach_dst + - foreach_dst_n + - ra_foreach_dst + - ra_foreach_src + - ra_foreach_src_rev + - foreach_ssa_use + - foreach_ssa_srcp_n + - foreach_ssa_srcp + - foreach_ssa_src_n + - foreach_ssa_src + - foreach_input_n + - foreach_input + - foreach_output_n + - foreach_output + - foreach_instr + - foreach_instr_rev + - foreach_instr_safe + - foreach_instr_from_safe + - foreach_block + - foreach_block_safe + - foreach_block_rev + - foreach_array + - foreach_array_safe + - foreach_name_n + - foreach_name + - foreach_def + - foreach_use + - foreach_interval + - foreach_interval_safe + - foreach_interval_rev + - foreach_interval_rev_safe + - foreach_batch + - foreach_line_in_section + - perf_time + - perf_time_ctx + - foreach_submit + - foreach_submit_safe + +# panfrost + - foreach_batch + - pan_pack + - pan_section_pack + - bi_foreach_block + - bi_foreach_block_from + - bi_foreach_block_from_rev + - bi_foreach_block_rev + - bi_foreach_clause_in_block + - bi_foreach_clause_in_block_from + - bi_foreach_clause_in_block_from_rev + - bi_foreach_clause_in_block_rev + - bi_foreach_clause_in_block_safe + - bi_foreach_dest + - bi_foreach_instr_and_src_in_tuple + - bi_foreach_instr_global + - bi_foreach_instr_global_rev + - bi_foreach_instr_global_rev_safe + - bi_foreach_instr_global_safe + - bi_foreach_instr_in_block + - bi_foreach_instr_in_block_from + - bi_foreach_instr_in_block_from_rev + - bi_foreach_instr_in_block_rev + - bi_foreach_instr_in_block_safe + - bi_foreach_instr_in_block_safe_rev + - bi_foreach_instr_in_clause + - bi_foreach_instr_in_clause_rev + - bi_foreach_instr_in_tuple + - bi_foreach_predecessor + - bi_foreach_src + - bi_foreach_ssa_src + - bi_foreach_successor + - mir_foreach_block + - mir_foreach_block_from + - mir_foreach_bundle_in_block + - mir_foreach_bundle_in_block_rev + - mir_foreach_instr_global + - mir_foreach_instr_global_safe + - mir_foreach_instr_in_block + - mir_foreach_instr_in_block_from + - mir_foreach_instr_in_block_from_rev + - mir_foreach_instr_in_block_rev + - mir_foreach_instr_in_block_safe + - mir_foreach_instr_in_block_safe_rev + - mir_foreach_instr_in_block_scheduled_rev + - mir_foreach_predecessor + - mir_foreach_src + - nodearray_dense_foreach + - nodearray_dense_foreach_64 + - nodearray_sparse_foreach + - pan_foreach_instr_in_block_rev + - pan_foreach_predecessor + - pan_foreach_successor
