From: Faith Ekstrand Date: Tue, 8 Aug 2023 17:00:35 +0000 (-0500) Subject: nir: clang-format src/compiler/nir/*.[ch] X-Git-Tag: upstream/23.3.3~3400 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=777d336b1ffe6b1ab4aec16ef32d71b9ad62f51f;p=platform%2Fupstream%2Fmesa.git nir: clang-format src/compiler/nir/*.[ch] Part-of: --- diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 1c54a77..4979527 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -26,15 +26,15 @@ */ #include "nir.h" -#include "nir_builder.h" -#include "nir_control_flow_private.h" -#include "nir_worklist.h" -#include "util/half_float.h" -#include #include +#include #include +#include "util/half_float.h" #include "util/u_math.h" #include "util/u_qsort.h" +#include "nir_builder.h" +#include "nir_control_flow_private.h" +#include "nir_worklist.h" #include "main/menums.h" /* BITFIELD64_MASK */ @@ -496,7 +496,8 @@ src_copy(nir_src *dest, const nir_src *src, gc_ctx *ctx) /* NOTE: if the instruction you are copying a src to is already added * to the IR, use nir_instr_rewrite_src() instead. */ -void nir_src_copy(nir_src *dest, const nir_src *src, nir_instr *instr) +void +nir_src_copy(nir_src *dest, const nir_src *src, nir_instr *instr) { src_copy(dest, src, instr ? gc_get_context(instr) : NULL); } @@ -523,7 +524,6 @@ nir_alu_src_is_trivial_ssa(const nir_alu_instr *alu, unsigned srcn) (memcmp(src->swizzle, trivial_swizzle, num_components) == 0); } - static void cf_init(nir_cf_node *node, nir_cf_node_type type) { @@ -755,8 +755,7 @@ nir_call_instr_create(nir_shader *shader, nir_function *callee) return instr; } -static int8_t default_tg4_offsets[4][2] = -{ +static int8_t default_tg4_offsets[4][2] = { { 0, 1 }, { 1, 1 }, { 1, 0 }, @@ -812,8 +811,8 @@ nir_tex_instr_remove_src(nir_tex_instr *tex, unsigned src_idx) /* Now, move all of the other sources down */ for (unsigned i = src_idx + 1; i < tex->num_srcs; i++) { - tex->src[i-1].src_type = tex->src[i].src_type; - nir_instr_move_src(&tex->instr, &tex->src[i-1].src, &tex->src[i].src); + tex->src[i - 1].src_type = tex->src[i].src_type; + nir_instr_move_src(&tex->instr, &tex->src[i - 1].src, &tex->src[i].src); } tex->num_srcs--; } @@ -1077,7 +1076,7 @@ nir_instr_insert(nir_cursor cursor, nir_instr *instr) /* Inserting instructions after a jump is illegal. */ nir_instr *last = nir_block_last_instr(cursor.block); assert(last == NULL || last->type != nir_instr_type_jump); - (void) last; + (void)last; instr->block = cursor.block; add_defs_uses(instr); @@ -1136,7 +1135,7 @@ src_is_valid(const nir_src *src) static bool remove_use_cb(nir_src *src, void *state) { - (void) state; + (void)state; if (src_is_valid(src)) list_del(&src->use_link); @@ -1150,7 +1149,8 @@ remove_defs_uses(nir_instr *instr) nir_foreach_src(instr, remove_use_cb, instr); } -void nir_instr_remove_v(nir_instr *instr) +void +nir_instr_remove_v(nir_instr *instr) { remove_defs_uses(instr); exec_node_remove(&instr->node); @@ -1161,7 +1161,8 @@ void nir_instr_remove_v(nir_instr *instr) } } -void nir_instr_free(nir_instr *instr) +void +nir_instr_free(nir_instr *instr) { switch (instr->type) { case nir_instr_type_tex: @@ -1192,7 +1193,8 @@ nir_instr_free_list(struct exec_list *list) } } -static bool nir_instr_free_and_dce_live_cb(nir_ssa_def *def, void *state) +static bool +nir_instr_free_and_dce_live_cb(nir_ssa_def *def, void *state) { bool *live = state; @@ -1204,7 +1206,8 @@ static bool nir_instr_free_and_dce_live_cb(nir_ssa_def *def, void *state) } } -static bool nir_instr_free_and_dce_is_live(nir_instr *instr) +static bool +nir_instr_free_and_dce_is_live(nir_instr *instr) { /* Note: don't have to worry about jumps because they don't have dests to * become unused. @@ -1305,7 +1308,7 @@ nir_foreach_ssa_def(nir_instr *instr, nir_foreach_ssa_def_cb cb, void *state) case nir_instr_type_intrinsic: case nir_instr_type_phi: case nir_instr_type_parallel_copy: { - struct foreach_ssa_def_state foreach_state = {cb, state}; + struct foreach_ssa_def_state foreach_state = { cb, state }; return nir_foreach_dest(instr, nir_ssa_def_visitor, &foreach_state); } @@ -1560,7 +1563,7 @@ nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def, void nir_ssa_dest_init(nir_instr *instr, nir_dest *dest, - unsigned num_components, unsigned bit_size) + unsigned num_components, unsigned bit_size) { nir_ssa_def_init(instr, &dest->ssa, num_components, bit_size); } @@ -1798,7 +1801,8 @@ nir_block_cf_tree_prev(nir_block *block) } } -nir_block *nir_cf_node_cf_tree_first(nir_cf_node *node) +nir_block * +nir_cf_node_cf_tree_first(nir_cf_node *node) { switch (node->type) { case nir_cf_node_function: { @@ -1825,7 +1829,8 @@ nir_block *nir_cf_node_cf_tree_first(nir_cf_node *node) } } -nir_block *nir_cf_node_cf_tree_last(nir_cf_node *node) +nir_block * +nir_cf_node_cf_tree_last(nir_cf_node *node) { switch (node->type) { case nir_cf_node_function: { @@ -1855,7 +1860,8 @@ nir_block *nir_cf_node_cf_tree_last(nir_cf_node *node) } } -nir_block *nir_cf_node_cf_tree_next(nir_cf_node *node) +nir_block * +nir_cf_node_cf_tree_next(nir_cf_node *node) { if (node->type == nir_cf_node_block) return nir_block_cf_tree_next(nir_cf_node_as_block(node)); @@ -1902,10 +1908,10 @@ nir_block_get_following_loop(nir_block *block) static int compare_block_index(const void *p1, const void *p2) { - const nir_block *block1 = *((const nir_block **) p1); - const nir_block *block2 = *((const nir_block **) p2); + const nir_block *block1 = *((const nir_block **)p1); + const nir_block *block2 = *((const nir_block **)p2); - return (int) block1->index - (int) block2->index; + return (int)block1->index - (int)block2->index; } nir_block ** @@ -1916,7 +1922,7 @@ nir_block_get_predecessors_sorted(const nir_block *block, void *mem_ctx) unsigned i = 0; set_foreach(block->predecessors, entry) - preds[i++] = (nir_block *) entry->key; + preds[i++] = (nir_block *)entry->key; assert(i == block->predecessors->entries); qsort(preds, block->predecessors->entries, sizeof(nir_block *), @@ -1946,7 +1952,7 @@ nir_index_blocks(nir_function_impl *impl) static bool index_ssa_def_cb(nir_ssa_def *def, void *state) { - unsigned *index = (unsigned *) state; + unsigned *index = (unsigned *)state; def->index = (*index)++; return true; @@ -2166,7 +2172,8 @@ nir_shader_lower_instructions(nir_shader *shader, * Returns true if the shader supports quad-based implicit derivatives on * texture sampling. */ -bool nir_shader_supports_implicit_lod(nir_shader *shader) +bool +nir_shader_supports_implicit_lod(nir_shader *shader) { return (shader->info.stage == MESA_SHADER_FRAGMENT || (shader->info.stage == MESA_SHADER_COMPUTE && @@ -2543,21 +2550,21 @@ nir_rewrite_image_intrinsic(nir_intrinsic_instr *intrin, nir_ssa_def *src, atomic_op = nir_intrinsic_atomic_op(intrin); switch (intrin->intrinsic) { -#define CASE(op) \ - case nir_intrinsic_image_deref_##op: \ +#define CASE(op) \ + case nir_intrinsic_image_deref_##op: \ intrin->intrinsic = bindless ? nir_intrinsic_bindless_image_##op \ - : nir_intrinsic_image_##op; \ + : nir_intrinsic_image_##op; \ break; - CASE(load) - CASE(sparse_load) - CASE(store) - CASE(atomic) - CASE(atomic_swap) - CASE(size) - CASE(samples) - CASE(load_raw_intel) - CASE(store_raw_intel) - CASE(fragment_mask_load_amd) + CASE(load) + CASE(sparse_load) + CASE(store) + CASE(atomic) + CASE(atomic_swap) + CASE(size) + CASE(samples) + CASE(load_raw_intel) + CASE(store_raw_intel) + CASE(fragment_mask_load_amd) #undef CASE default: unreachable("Unhanded image intrinsic"); @@ -2609,9 +2616,10 @@ nir_get_shader_call_payload_src(nir_intrinsic_instr *call) } } -nir_binding nir_chase_binding(nir_src rsrc) +nir_binding +nir_chase_binding(nir_src rsrc) { - nir_binding res = {0}; + nir_binding res = { 0 }; if (rsrc.ssa->parent_instr->type == nir_instr_type_deref) { const struct glsl_type *type = glsl_without_array(nir_src_as_deref(rsrc)->type); bool is_image = glsl_type_is_image(type) || glsl_type_is_sampler(type); @@ -2626,7 +2634,7 @@ nir_binding nir_chase_binding(nir_src rsrc) return res; } else if (deref->deref_type == nir_deref_type_array && is_image) { if (res.num_indices == ARRAY_SIZE(res.indices)) - return (nir_binding){0}; + return (nir_binding){ 0 }; res.indices[res.num_indices++] = deref->arr.index; } @@ -2646,13 +2654,13 @@ nir_binding nir_chase_binding(nir_src rsrc) if (alu && alu->op == nir_op_mov) { for (unsigned i = 0; i < num_components; i++) { if (alu->src[0].swizzle[i] != i) - return (nir_binding){0}; + return (nir_binding){ 0 }; } rsrc = alu->src[0].src; } else if (alu && nir_op_is_vec(alu->op)) { for (unsigned i = 0; i < num_components; i++) { if (alu->src[i].swizzle[0] != i || alu->src[i].src.ssa != alu->src[0].src.ssa) - return (nir_binding){0}; + return (nir_binding){ 0 }; } rsrc = alu->src[0].src; } else if (intrin && intrin->intrinsic == nir_intrinsic_read_first_invocation) { @@ -2681,7 +2689,7 @@ nir_binding nir_chase_binding(nir_src rsrc) nir_intrinsic_instr *intrin = nir_src_as_intrinsic(rsrc); if (!intrin) - return (nir_binding){0}; + return (nir_binding){ 0 }; /* Intel resource, similar to load_vulkan_descriptor after it has been * lowered. @@ -2703,11 +2711,11 @@ nir_binding nir_chase_binding(nir_src rsrc) if (intrin->intrinsic == nir_intrinsic_load_vulkan_descriptor) { intrin = nir_src_as_intrinsic(intrin->src[0]); if (!intrin) - return (nir_binding){0}; + return (nir_binding){ 0 }; } if (intrin->intrinsic != nir_intrinsic_vulkan_resource_index) - return (nir_binding){0}; + return (nir_binding){ 0 }; assert(res.num_indices == 0); res.success = true; @@ -2718,7 +2726,8 @@ nir_binding nir_chase_binding(nir_src rsrc) return res; } -nir_variable *nir_get_binding_variable(nir_shader *shader, nir_binding binding) +nir_variable * +nir_get_binding_variable(nir_shader *shader, nir_binding binding) { nir_variable *binding_var = NULL; unsigned count = 0; @@ -2789,7 +2798,7 @@ nir_get_nir_type_for_glsl_base_type(enum glsl_base_type base_type) case GLSL_TYPE_FLOAT: return nir_type_float32; case GLSL_TYPE_FLOAT16: return nir_type_float16; case GLSL_TYPE_DOUBLE: return nir_type_float64; - /* clang-format on */ + /* clang-format on */ case GLSL_TYPE_SAMPLER: case GLSL_TYPE_TEXTURE: @@ -2897,27 +2906,27 @@ nir_ssa_alu_instr_src_components(const nir_alu_instr *instr, unsigned src) } #define CASE_ALL_SIZES(op) \ - case op: \ - case op ## 8: \ - case op ## 16: \ - case op ## 32: \ + case op: \ + case op##8: \ + case op##16: \ + case op##32: bool nir_alu_instr_is_comparison(const nir_alu_instr *instr) { switch (instr->op) { - CASE_ALL_SIZES(nir_op_flt) - CASE_ALL_SIZES(nir_op_fge) - CASE_ALL_SIZES(nir_op_feq) - CASE_ALL_SIZES(nir_op_fneu) - CASE_ALL_SIZES(nir_op_ilt) - CASE_ALL_SIZES(nir_op_ult) - CASE_ALL_SIZES(nir_op_ige) - CASE_ALL_SIZES(nir_op_uge) - CASE_ALL_SIZES(nir_op_ieq) - CASE_ALL_SIZES(nir_op_ine) - CASE_ALL_SIZES(nir_op_bitz) - CASE_ALL_SIZES(nir_op_bitnz) + CASE_ALL_SIZES(nir_op_flt) + CASE_ALL_SIZES(nir_op_fge) + CASE_ALL_SIZES(nir_op_feq) + CASE_ALL_SIZES(nir_op_fneu) + CASE_ALL_SIZES(nir_op_ilt) + CASE_ALL_SIZES(nir_op_ult) + CASE_ALL_SIZES(nir_op_ige) + CASE_ALL_SIZES(nir_op_uge) + CASE_ALL_SIZES(nir_op_ieq) + CASE_ALL_SIZES(nir_op_ine) + CASE_ALL_SIZES(nir_op_bitz) + CASE_ALL_SIZES(nir_op_bitnz) case nir_op_inot: return true; default: @@ -3038,11 +3047,10 @@ nir_intrinsic_copy_const_indices(nir_intrinsic_instr *dst, nir_intrinsic_instr * assert(dst_info->index_map[i] > 0); dst->const_index[dst_info->index_map[i] - 1] = - src->const_index[src_info->index_map[i] - 1]; + src->const_index[src_info->index_map[i] - 1]; } } - bool nir_tex_instr_need_sampler(const nir_tex_instr *instr) { @@ -3067,23 +3075,23 @@ nir_tex_instr_result_size(const nir_tex_instr *instr) case nir_texop_txs: { unsigned ret; switch (instr->sampler_dim) { - case GLSL_SAMPLER_DIM_1D: - case GLSL_SAMPLER_DIM_BUF: - ret = 1; - break; - case GLSL_SAMPLER_DIM_2D: - case GLSL_SAMPLER_DIM_CUBE: - case GLSL_SAMPLER_DIM_MS: - case GLSL_SAMPLER_DIM_RECT: - case GLSL_SAMPLER_DIM_EXTERNAL: - case GLSL_SAMPLER_DIM_SUBPASS: - ret = 2; - break; - case GLSL_SAMPLER_DIM_3D: - ret = 3; - break; - default: - unreachable("not reached"); + case GLSL_SAMPLER_DIM_1D: + case GLSL_SAMPLER_DIM_BUF: + ret = 1; + break; + case GLSL_SAMPLER_DIM_2D: + case GLSL_SAMPLER_DIM_CUBE: + case GLSL_SAMPLER_DIM_MS: + case GLSL_SAMPLER_DIM_RECT: + case GLSL_SAMPLER_DIM_EXTERNAL: + case GLSL_SAMPLER_DIM_SUBPASS: + ret = 2; + break; + case GLSL_SAMPLER_DIM_3D: + ret = 3; + break; + default: + unreachable("not reached"); } if (instr->is_array) ret++; @@ -3268,15 +3276,13 @@ nir_instr_xfb_write_mask(nir_intrinsic_instr *instr) unsigned mask = 0; if (nir_intrinsic_has_io_xfb(instr)) { - unsigned wr_mask = nir_intrinsic_write_mask(instr) << - nir_intrinsic_component(instr); + unsigned wr_mask = nir_intrinsic_write_mask(instr) << nir_intrinsic_component(instr); assert((wr_mask & ~0xf) == 0); /* only 4 components allowed */ unsigned iter_mask = wr_mask; while (iter_mask) { unsigned i = u_bit_scan(&iter_mask); - nir_io_xfb xfb = i < 2 ? nir_intrinsic_io_xfb(instr) : - nir_intrinsic_io_xfb2(instr); + nir_io_xfb xfb = i < 2 ? nir_intrinsic_io_xfb(instr) : nir_intrinsic_io_xfb2(instr); if (xfb.out[i % 2].num_components) mask |= BITFIELD_RANGE(i, xfb.out[i % 2].num_components) & wr_mask; } @@ -3392,7 +3398,8 @@ nir_remove_varying(nir_intrinsic_instr *intr, gl_shader_stage next_shader) * This marks the output store instruction as not feeding fixed-function * logic. If the instruction has no other use, it's removed. */ -void nir_remove_sysval_output(nir_intrinsic_instr *intr) +void +nir_remove_sysval_output(nir_intrinsic_instr *intr) { nir_io_semantics sem = nir_intrinsic_io_semantics(intr); @@ -3406,7 +3413,8 @@ void nir_remove_sysval_output(nir_intrinsic_instr *intr) } } -void nir_remove_non_entrypoints(nir_shader *nir) +void +nir_remove_non_entrypoints(nir_shader *nir) { nir_foreach_function_safe(func, nir) { if (!func->is_entrypoint) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 6a09216..98a4105 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -28,25 +28,25 @@ #ifndef NIR_H #define NIR_H -#include "util/hash_table.h" #include "compiler/glsl/list.h" -#include "util/list.h" -#include "util/log.h" -#include "util/ralloc.h" -#include "util/set.h" +#include "compiler/nir_types.h" +#include "compiler/shader_enums.h" +#include "compiler/shader_info.h" #include "util/bitscan.h" #include "util/bitset.h" #include "util/compiler.h" #include "util/enum_operators.h" +#include "util/format/u_format.h" +#include "util/hash_table.h" +#include "util/list.h" +#include "util/log.h" #include "util/macros.h" +#include "util/ralloc.h" +#include "util/set.h" #include "util/u_printf.h" -#include "util/format/u_format.h" -#include "compiler/nir_types.h" -#include "compiler/shader_enums.h" -#include "compiler/shader_info.h" #define XXH_INLINE_ALL -#include "util/xxhash.h" #include +#include "util/xxhash.h" #ifndef NDEBUG #include "util/u_debug.h" @@ -62,7 +62,7 @@ extern uint32_t nir_debug; extern bool nir_debug_print_shader[MESA_SHADER_KERNEL + 1]; #ifndef NDEBUG -#define NIR_DEBUG(flag) unlikely(nir_debug & (NIR_DEBUG_ ## flag)) +#define NIR_DEBUG(flag) unlikely(nir_debug &(NIR_DEBUG_##flag)) #else #define NIR_DEBUG(flag) false #endif @@ -91,36 +91,36 @@ extern bool nir_debug_print_shader[MESA_SHADER_KERNEL + 1]; #define NIR_DEBUG_PRINT_INTERNAL (1u << 21) #define NIR_DEBUG_PRINT_PASS_FLAGS (1u << 22) -#define NIR_DEBUG_PRINT (NIR_DEBUG_PRINT_VS | \ +#define NIR_DEBUG_PRINT (NIR_DEBUG_PRINT_VS | \ NIR_DEBUG_PRINT_TCS | \ NIR_DEBUG_PRINT_TES | \ - NIR_DEBUG_PRINT_GS | \ - NIR_DEBUG_PRINT_FS | \ - NIR_DEBUG_PRINT_CS | \ - NIR_DEBUG_PRINT_TS | \ - NIR_DEBUG_PRINT_MS | \ + NIR_DEBUG_PRINT_GS | \ + NIR_DEBUG_PRINT_FS | \ + NIR_DEBUG_PRINT_CS | \ + NIR_DEBUG_PRINT_TS | \ + NIR_DEBUG_PRINT_MS | \ NIR_DEBUG_PRINT_RGS | \ NIR_DEBUG_PRINT_AHS | \ NIR_DEBUG_PRINT_CHS | \ NIR_DEBUG_PRINT_MHS | \ - NIR_DEBUG_PRINT_IS | \ + NIR_DEBUG_PRINT_IS | \ NIR_DEBUG_PRINT_CBS | \ NIR_DEBUG_PRINT_KS) -#define NIR_FALSE 0u -#define NIR_TRUE (~0u) +#define NIR_FALSE 0u +#define NIR_TRUE (~0u) #define NIR_MAX_VEC_COMPONENTS 16 #define NIR_MAX_MATRIX_COLUMNS 4 -#define NIR_STREAM_PACKED (1 << 8) +#define NIR_STREAM_PACKED (1 << 8) typedef uint16_t nir_component_mask_t; static inline bool nir_num_components_valid(unsigned num_components) { - return (num_components >= 1 && + return (num_components >= 1 && num_components <= 5) || - num_components == 8 || - num_components == 16; + num_components == 8 || + num_components == 16; } static inline nir_component_mask_t @@ -149,14 +149,14 @@ nir_component_mask_reinterpret(nir_component_mask_t mask, * Note that you have to be a bit careful as the generated cast function * destroys constness. */ -#define NIR_DEFINE_CAST(name, in_type, out_type, field, \ - type_field, type_value) \ -static inline out_type * \ -name(const in_type *parent) \ -{ \ - assert(parent && parent->type_field == type_value); \ - return exec_node_data(out_type, parent, field); \ -} +#define NIR_DEFINE_CAST(name, in_type, out_type, field, \ + type_field, type_value) \ + static inline out_type * \ + name(const in_type *parent) \ + { \ + assert(parent && parent->type_field == type_value); \ + return exec_node_data(out_type, parent, field); \ + } struct nir_function; struct nir_shader; @@ -164,7 +164,6 @@ struct nir_instr; struct nir_builder; struct nir_xfb_info; - /** * Description of built-in state associated with a uniform * @@ -228,10 +227,10 @@ MESA_DEFINE_CPP_ENUM_BITFIELD_OPERATORS(nir_variable_mode) */ typedef enum { nir_rounding_mode_undef = 0, - nir_rounding_mode_rtne = 1, /* round to nearest even */ - nir_rounding_mode_ru = 2, /* round up */ - nir_rounding_mode_rd = 3, /* round down */ - nir_rounding_mode_rtz = 4, /* round towards zero */ + nir_rounding_mode_rtne = 1, /* round to nearest even */ + nir_rounding_mode_ru = 2, /* round up */ + nir_rounding_mode_rd = 3, /* round down */ + nir_rounding_mode_rtz = 4, /* round towards zero */ } nir_rounding_mode; /** @@ -263,10 +262,10 @@ typedef enum { * Intel resource flags */ typedef enum { - nir_resource_intel_bindless = 1u << 0, - nir_resource_intel_pushable = 1u << 1, - nir_resource_intel_sampler = 1u << 2, - nir_resource_intel_non_uniform = 1u << 3, + nir_resource_intel_bindless = 1u << 0, + nir_resource_intel_pushable = 1u << 1, + nir_resource_intel_sampler = 1u << 2, + nir_resource_intel_non_uniform = 1u << 3, } nir_resource_data_intel; typedef union { @@ -284,10 +283,10 @@ typedef union { } nir_const_value; #define nir_const_value_to_array(arr, c, components, m) \ -do { \ - for (unsigned i = 0; i < components; ++i) \ - arr[i] = c[i].m; \ -} while (false) + do { \ + for (unsigned i = 0; i < components; ++i) \ + arr[i] = c[i].m; \ + } while (false) static inline nir_const_value nir_const_value_for_raw_uint(uint64_t x, unsigned bit_size) @@ -424,11 +423,11 @@ typedef struct nir_constant { * with a layout qualifier. */ typedef enum { - nir_depth_layout_none, /**< No depth layout is specified. */ - nir_depth_layout_any, - nir_depth_layout_greater, - nir_depth_layout_less, - nir_depth_layout_unchanged + nir_depth_layout_none, /**< No depth layout is specified. */ + nir_depth_layout_any, + nir_depth_layout_greater, + nir_depth_layout_less, + nir_depth_layout_unchanged } nir_depth_layout; /** @@ -477,7 +476,7 @@ typedef struct nir_variable { * * \sa nir_variable_mode */ - unsigned mode:16; + unsigned mode : 16; /** * Is the variable read-only? @@ -485,18 +484,18 @@ typedef struct nir_variable { * This is set for variables declared as \c const, shader inputs, * and uniforms. */ - unsigned read_only:1; - unsigned centroid:1; - unsigned sample:1; - unsigned patch:1; - unsigned invariant:1; + unsigned read_only : 1; + unsigned centroid : 1; + unsigned sample : 1; + unsigned patch : 1; + unsigned invariant : 1; /** * Is the variable a ray query? */ - unsigned ray_query:1; + unsigned ray_query : 1; - /** + /** * Precision qualifier. * * In desktop GLSL we do not care about precision qualifiers at all, in @@ -507,7 +506,7 @@ typedef struct nir_variable { * have the same precision value and the checks we add in the compiler * for this field will never break a desktop shader compile. */ - unsigned precision:2; + unsigned precision : 2; /** * Has this variable been statically assigned? @@ -517,7 +516,7 @@ typedef struct nir_variable { * still written after dead code removal, nor is it maintained in * non-ast_to_hir.cpp (GLSL parsing) paths. */ - unsigned assigned:1; + unsigned assigned : 1; /** * Can this variable be coalesced with another? @@ -528,7 +527,7 @@ typedef struct nir_variable { * result in a load/store of the variable with an indirect offset which * the backend may not be able to handle. */ - unsigned cannot_coalesce:1; + unsigned cannot_coalesce : 1; /** * When separate shader programs are enabled, only input/outputs between @@ -538,14 +537,14 @@ typedef struct nir_variable { * This is also used to make sure xfb varyings that are unused by the * fragment shader are not removed. */ - unsigned always_active_io:1; + unsigned always_active_io : 1; /** * Interpolation mode for shader inputs / outputs * * \sa glsl_interp_mode */ - unsigned interpolation:3; + unsigned interpolation : 3; /** * If non-zero, then this variable may be packed along with other variables @@ -554,32 +553,32 @@ typedef struct nir_variable { * component of this variable is actually stored in component y of the * location specified by \c location. */ - unsigned location_frac:2; + unsigned location_frac : 2; /** * If true, this variable represents an array of scalars that should * be tightly packed. In other words, consecutive array elements * should be stored one component apart, rather than one slot apart. */ - unsigned compact:1; + unsigned compact : 1; /** * Whether this is a fragment shader output implicitly initialized with * the previous contents of the specified render target at the * framebuffer location corresponding to this shader invocation. */ - unsigned fb_fetch_output:1; + unsigned fb_fetch_output : 1; /** * Non-zero if this variable is considered bindless as defined by * ARB_bindless_texture. */ - unsigned bindless:1; + unsigned bindless : 1; /** * Was an explicit binding set in the shader? */ - unsigned explicit_binding:1; + unsigned explicit_binding : 1; /** * Was the location explicitly set in the shader? @@ -588,53 +587,53 @@ typedef struct nir_variable { * by the linker or by the API (e.g., calls to \c glBindAttribLocation have * no effect). */ - unsigned explicit_location:1; + unsigned explicit_location : 1; /** * Is this varying used by transform feedback? * * This is used by the linker to decide if it's safe to pack the varying. */ - unsigned is_xfb:1; + unsigned is_xfb : 1; /** * Is this varying used only by transform feedback? * * This is used by the linker to decide if its safe to pack the varying. */ - unsigned is_xfb_only:1; + unsigned is_xfb_only : 1; /** * Was a transfer feedback buffer set in the shader? */ - unsigned explicit_xfb_buffer:1; + unsigned explicit_xfb_buffer : 1; /** * Was a transfer feedback stride set in the shader? */ - unsigned explicit_xfb_stride:1; + unsigned explicit_xfb_stride : 1; /** * Was an explicit offset set in the shader? */ - unsigned explicit_offset:1; + unsigned explicit_offset : 1; /** * Layout of the matrix. Uses glsl_matrix_layout values. */ - unsigned matrix_layout:2; + unsigned matrix_layout : 2; /** * Non-zero if this variable was created by lowering a named interface * block. */ - unsigned from_named_ifc_block:1; + unsigned from_named_ifc_block : 1; /** * Non-zero if the variable must be a shader input. This is useful for * constraints on function parameters. */ - unsigned must_be_shader_input:1; + unsigned must_be_shader_input : 1; /** * How the variable was declared. See nir_var_declaration_type. @@ -642,25 +641,25 @@ typedef struct nir_variable { * This is used to detect variables generated by the compiler, so should * not be visible via the API. */ - unsigned how_declared:2; + unsigned how_declared : 2; /** * Is this variable per-view? If so, we know it must be an array with * size corresponding to the number of views. */ - unsigned per_view:1; + unsigned per_view : 1; /** * Whether the variable is per-primitive. * Can be use by Mesh Shader outputs and corresponding Fragment Shader inputs. */ - unsigned per_primitive:1; + unsigned per_primitive : 1; /** * Whether the variable is declared to indicate that a fragment shader * input will not have interpolated values. */ - unsigned per_vertex:1; + unsigned per_vertex : 1; /** * \brief Layout qualifier for gl_FragDepth. See nir_depth_layout. @@ -668,7 +667,7 @@ typedef struct nir_variable { * This is not equal to \c ir_depth_layout_none if and only if this * variable is \c gl_FragDepth and a layout qualifier is specified. */ - unsigned depth_layout:3; + unsigned depth_layout : 3; /** * Vertex stream output identifier. @@ -676,7 +675,7 @@ typedef struct nir_variable { * For packed outputs, NIR_STREAM_PACKED is set and bits [2*i+1,2*i] * indicate the stream of the i-th component. */ - unsigned stream:9; + unsigned stream : 9; /** * See gl_access_qualifier. @@ -684,12 +683,12 @@ typedef struct nir_variable { * Access flags for memory variables (SSBO/global), image uniforms, and * bindless images in uniforms/inputs/outputs. */ - unsigned access:9; + unsigned access : 9; /** * Descriptor set binding for sampler or UBO. */ - unsigned descriptor_set:5; + unsigned descriptor_set : 5; /** * output index for dual source blending. @@ -759,7 +758,7 @@ typedef struct nir_variable { /** * Transform feedback buffer. */ - uint16_t buffer:2; + uint16_t buffer : 2; /** * Transform feedback stride. @@ -791,7 +790,7 @@ typedef struct nir_variable { */ /*@{*/ uint16_t num_state_slots; /**< Number of state slots used */ - nir_state_slot *state_slots; /**< State descriptors. */ + nir_state_slot *state_slots; /**< State descriptors. */ /*@}*/ /** @@ -851,11 +850,11 @@ _nir_shader_variable_has_mode(nir_variable *var, unsigned modes) nir_foreach_variable_in_list_safe(var, &(shader)->variables) #define nir_foreach_variable_with_modes(var, shader, modes) \ - nir_foreach_variable_in_shader(var, shader) \ + nir_foreach_variable_in_shader(var, shader) \ if (_nir_shader_variable_has_mode(var, modes)) #define nir_foreach_variable_with_modes_safe(var, shader, modes) \ - nir_foreach_variable_in_shader_safe(var, shader) \ + nir_foreach_variable_in_shader_safe(var, shader) \ if (_nir_shader_variable_has_mode(var, modes)) #define nir_foreach_shader_in_variable(var, shader) \ @@ -1014,19 +1013,19 @@ nir_src_init(void) #define nir_foreach_use_including_if_safe(src, reg_or_ssa_def) \ list_for_each_entry_safe(nir_src, src, &(reg_or_ssa_def)->uses, use_link) -#define nir_foreach_use(src, reg_or_ssa_def) \ +#define nir_foreach_use(src, reg_or_ssa_def) \ nir_foreach_use_including_if(src, reg_or_ssa_def) \ if (!src->is_if) -#define nir_foreach_use_safe(src, reg_or_ssa_def) \ +#define nir_foreach_use_safe(src, reg_or_ssa_def) \ nir_foreach_use_including_if_safe(src, reg_or_ssa_def) \ if (!src->is_if) -#define nir_foreach_if_use(src, reg_or_ssa_def) \ +#define nir_foreach_if_use(src, reg_or_ssa_def) \ nir_foreach_use_including_if(src, reg_or_ssa_def) \ if (src->is_if) -#define nir_foreach_if_use_safe(src, reg_or_ssa_def) \ +#define nir_foreach_if_use_safe(src, reg_or_ssa_def) \ nir_foreach_use_including_if_safe(src, reg_or_ssa_def) \ if (src->is_if) @@ -1185,7 +1184,7 @@ typedef enum ENUM_PACKED { } nir_alu_type; /* clang-format on */ -#define NIR_ALU_TYPE_SIZE_MASK 0x79 +#define NIR_ALU_TYPE_SIZE_MASK 0x79 #define NIR_ALU_TYPE_BASE_TYPE_MASK 0x86 static inline unsigned @@ -1277,57 +1276,57 @@ nir_op_is_vec(nir_op op); static inline bool nir_is_float_control_signed_zero_inf_nan_preserve(unsigned execution_mode, unsigned bit_size) { - return (16 == bit_size && execution_mode & FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP16) || - (32 == bit_size && execution_mode & FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP32) || - (64 == bit_size && execution_mode & FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP64); + return (16 == bit_size && execution_mode & FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP16) || + (32 == bit_size && execution_mode & FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP32) || + (64 == bit_size && execution_mode & FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP64); } static inline bool nir_is_denorm_flush_to_zero(unsigned execution_mode, unsigned bit_size) { - return (16 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP16) || - (32 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP32) || - (64 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP64); + return (16 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP16) || + (32 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP32) || + (64 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP64); } static inline bool nir_is_denorm_preserve(unsigned execution_mode, unsigned bit_size) { - return (16 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_PRESERVE_FP16) || - (32 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_PRESERVE_FP32) || - (64 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_PRESERVE_FP64); + return (16 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_PRESERVE_FP16) || + (32 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_PRESERVE_FP32) || + (64 == bit_size && execution_mode & FLOAT_CONTROLS_DENORM_PRESERVE_FP64); } static inline bool nir_is_rounding_mode_rtne(unsigned execution_mode, unsigned bit_size) { - return (16 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP16) || - (32 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP32) || - (64 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP64); + return (16 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP16) || + (32 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP32) || + (64 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP64); } static inline bool nir_is_rounding_mode_rtz(unsigned execution_mode, unsigned bit_size) { - return (16 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP16) || - (32 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP32) || - (64 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP64); + return (16 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP16) || + (32 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP32) || + (64 == bit_size && execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP64); } static inline bool nir_has_any_rounding_mode_rtz(unsigned execution_mode) { - return (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP16) || - (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP32) || - (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP64); + return (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP16) || + (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP32) || + (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP64); } static inline bool nir_has_any_rounding_mode_rtne(unsigned execution_mode) { - return (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP16) || - (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP32) || - (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP64); + return (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP16) || + (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP32) || + (execution_mode & FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP64); } static inline nir_rounding_mode @@ -1459,19 +1458,19 @@ typedef struct nir_alu_instr { * it must ensure that the resulting value is bit-for-bit identical to the * original. */ - bool exact:1; + bool exact : 1; /** * Indicates that this instruction doese not cause signed integer wrapping * to occur, in the form of overflow or underflow. */ - bool no_signed_wrap:1; + bool no_signed_wrap : 1; /** * Indicates that this instruction does not cause unsigned integer wrapping * to occur, in the form of overflow or underflow. */ - bool no_unsigned_wrap:1; + bool no_unsigned_wrap : 1; /** Destination */ nir_alu_dest dest; @@ -1781,13 +1780,13 @@ nir_intrinsic_get_var(const nir_intrinsic_instr *intrin, unsigned i) typedef enum { /* Memory ordering. */ - NIR_MEMORY_ACQUIRE = 1 << 0, - NIR_MEMORY_RELEASE = 1 << 1, - NIR_MEMORY_ACQ_REL = NIR_MEMORY_ACQUIRE | NIR_MEMORY_RELEASE, + NIR_MEMORY_ACQUIRE = 1 << 0, + NIR_MEMORY_RELEASE = 1 << 1, + NIR_MEMORY_ACQ_REL = NIR_MEMORY_ACQUIRE | NIR_MEMORY_RELEASE, /* Memory visibility operations. */ NIR_MEMORY_MAKE_AVAILABLE = 1 << 2, - NIR_MEMORY_MAKE_VISIBLE = 1 << 3, + NIR_MEMORY_MAKE_VISIBLE = 1 << 3, } nir_memory_semantics; /** @@ -1820,15 +1819,15 @@ typedef enum { #define NIR_ALIGN_MUL_MAX 0x40000000 typedef struct nir_io_semantics { - unsigned location:7; /* gl_vert_attrib, gl_varying_slot, or gl_frag_result */ - unsigned num_slots:6; /* max 32, may be pessimistic with const indexing */ - unsigned dual_source_blend_index:1; - unsigned fb_fetch_output:1; /* for GL_KHR_blend_equation_advanced */ - unsigned gs_streams:8; /* xxyyzzww: 2-bit stream index for each component */ - unsigned medium_precision:1; /* GLSL mediump qualifier */ - unsigned per_view:1; - unsigned high_16bits:1; /* whether accessing low or high half of the slot */ - unsigned invariant:1; /* The variable has the invariant flag set */ + unsigned location : 7; /* gl_vert_attrib, gl_varying_slot, or gl_frag_result */ + unsigned num_slots : 6; /* max 32, may be pessimistic with const indexing */ + unsigned dual_source_blend_index : 1; + unsigned fb_fetch_output : 1; /* for GL_KHR_blend_equation_advanced */ + unsigned gs_streams : 8; /* xxyyzzww: 2-bit stream index for each component */ + unsigned medium_precision : 1; /* GLSL mediump qualifier */ + unsigned per_view : 1; + unsigned high_16bits : 1; /* whether accessing low or high half of the slot */ + unsigned invariant : 1; /* The variable has the invariant flag set */ /* CLIP_DISTn, LAYER, VIEWPORT, and TESS_LEVEL_* have up to 3 uses: * - an output consumed by the next stage * - a system value output affecting fixed-func hardware, e.g. the clipper @@ -1836,10 +1835,10 @@ typedef struct nir_io_semantics { * The following fields disable the first two. Transform feedback is disabled * by transform feedback info. */ - unsigned no_varying:1; /* whether this output isn't consumed by the next stage */ - unsigned no_sysval_output:1; /* whether this system value output has no - effect due to current pipeline states */ - unsigned _pad:3; + unsigned no_varying : 1; /* whether this output isn't consumed by the next stage */ + unsigned no_sysval_output : 1; /* whether this system value output has no + effect due to current pipeline states */ + unsigned _pad : 3; } nir_io_semantics; /* Transform feedback info for 2 outputs. nir_intrinsic_store_output contains @@ -1851,10 +1850,10 @@ typedef struct nir_io_xfb { /* start_component is equal to the index of out[]; add 2 for io_xfb2 */ /* start_component is not relative to nir_intrinsic_component */ /* get the stream index from nir_io_semantics */ - uint8_t num_components:4; /* max 4; if this is 0, xfb is disabled */ - uint8_t buffer:4; /* buffer index, max 3 */ - uint8_t offset; /* transform feedback buffer offset in dwords, - max (1K - 4) bytes */ + uint8_t num_components : 4; /* max 4; if this is 0, xfb is disabled */ + uint8_t buffer : 4; /* buffer index, max 3 */ + uint8_t offset; /* transform feedback buffer offset in dwords, + max (1K - 4) bytes */ } out[2]; } nir_io_xfb; @@ -2178,28 +2177,28 @@ typedef struct { /** Texture instruction opcode */ typedef enum { - nir_texop_tex, /**< Regular texture look-up */ - nir_texop_txb, /**< Texture look-up with LOD bias */ - nir_texop_txl, /**< Texture look-up with explicit LOD */ - nir_texop_txd, /**< Texture look-up with partial derivatives */ - nir_texop_txf, /**< Texel fetch with explicit LOD */ - nir_texop_txf_ms, /**< Multisample texture fetch */ - nir_texop_txf_ms_fb, /**< Multisample texture fetch from framebuffer */ - nir_texop_txf_ms_mcs_intel, /**< Multisample compression value fetch */ - nir_texop_txs, /**< Texture size */ - nir_texop_lod, /**< Texture lod query */ - nir_texop_tg4, /**< Texture gather */ - nir_texop_query_levels, /**< Texture levels query */ - nir_texop_texture_samples, /**< Texture samples query */ - nir_texop_samples_identical, /**< Query whether all samples are definitely - * identical. - */ - nir_texop_tex_prefetch, /**< Regular texture look-up, eligible for pre-dispatch */ + nir_texop_tex, /**< Regular texture look-up */ + nir_texop_txb, /**< Texture look-up with LOD bias */ + nir_texop_txl, /**< Texture look-up with explicit LOD */ + nir_texop_txd, /**< Texture look-up with partial derivatives */ + nir_texop_txf, /**< Texel fetch with explicit LOD */ + nir_texop_txf_ms, /**< Multisample texture fetch */ + nir_texop_txf_ms_fb, /**< Multisample texture fetch from framebuffer */ + nir_texop_txf_ms_mcs_intel, /**< Multisample compression value fetch */ + nir_texop_txs, /**< Texture size */ + nir_texop_lod, /**< Texture lod query */ + nir_texop_tg4, /**< Texture gather */ + nir_texop_query_levels, /**< Texture levels query */ + nir_texop_texture_samples, /**< Texture samples query */ + nir_texop_samples_identical, /**< Query whether all samples are definitely + * identical. + */ + nir_texop_tex_prefetch, /**< Regular texture look-up, eligible for pre-dispatch */ nir_texop_fragment_fetch_amd, /**< Multisample fragment color texture fetch */ nir_texop_fragment_mask_fetch_amd, /**< Multisample fragment mask texture fetch */ - nir_texop_descriptor_amd, /**< Returns a buffer or image descriptor. */ - nir_texop_sampler_descriptor_amd, /**< Returns a sampler descriptor. */ - nir_texop_lod_bias_agx, /**< Returns the sampler's LOD bias */ + nir_texop_descriptor_amd, /**< Returns a buffer or image descriptor. */ + nir_texop_sampler_descriptor_amd, /**< Returns a sampler descriptor. */ + nir_texop_lod_bias_agx, /**< Returns the sampler's LOD bias */ } nir_texop; /** Represents a texture instruction */ @@ -2395,7 +2394,7 @@ nir_tex_instr_src_index(const nir_tex_instr *instr, nir_tex_src_type type) { for (unsigned i = 0; i < instr->num_srcs; i++) if (instr->src[i].src_type == type) - return (int) i; + return (int)i; return -1; } @@ -2563,34 +2562,32 @@ NIR_DEFINE_CAST(nir_instr_as_parallel_copy, nir_instr, nir_parallel_copy_instr, instr, type, nir_instr_type_parallel_copy) +#define NIR_DEFINE_SRC_AS_CONST(type, suffix) \ + static inline type \ + nir_src_comp_as_##suffix(nir_src src, unsigned comp) \ + { \ + assert(nir_src_is_const(src)); \ + nir_load_const_instr *load = \ + nir_instr_as_load_const(src.ssa->parent_instr); \ + assert(comp < load->def.num_components); \ + return nir_const_value_as_##suffix(load->value[comp], \ + load->def.bit_size); \ + } \ + \ + static inline type \ + nir_src_as_##suffix(nir_src src) \ + { \ + assert(nir_src_num_components(src) == 1); \ + return nir_src_comp_as_##suffix(src, 0); \ + } -#define NIR_DEFINE_SRC_AS_CONST(type, suffix) \ -static inline type \ -nir_src_comp_as_##suffix(nir_src src, unsigned comp) \ -{ \ - assert(nir_src_is_const(src)); \ - nir_load_const_instr *load = \ - nir_instr_as_load_const(src.ssa->parent_instr); \ - assert(comp < load->def.num_components); \ - return nir_const_value_as_##suffix(load->value[comp], \ - load->def.bit_size); \ -} \ - \ -static inline type \ -nir_src_as_##suffix(nir_src src) \ -{ \ - assert(nir_src_num_components(src) == 1); \ - return nir_src_comp_as_##suffix(src, 0); \ -} - -NIR_DEFINE_SRC_AS_CONST(int64_t, int) -NIR_DEFINE_SRC_AS_CONST(uint64_t, uint) -NIR_DEFINE_SRC_AS_CONST(bool, bool) -NIR_DEFINE_SRC_AS_CONST(double, float) +NIR_DEFINE_SRC_AS_CONST(int64_t, int) +NIR_DEFINE_SRC_AS_CONST(uint64_t, uint) +NIR_DEFINE_SRC_AS_CONST(bool, bool) +NIR_DEFINE_SRC_AS_CONST(double, float) #undef NIR_DEFINE_SRC_AS_CONST - typedef struct { nir_ssa_def *def; unsigned comp; @@ -2616,18 +2613,18 @@ nir_ssa_scalar_as_const_value(nir_ssa_scalar s) return load->value[s.comp]; } -#define NIR_DEFINE_SCALAR_AS_CONST(type, suffix) \ -static inline type \ -nir_ssa_scalar_as_##suffix(nir_ssa_scalar s) \ -{ \ - return nir_const_value_as_##suffix( \ - nir_ssa_scalar_as_const_value(s), s.def->bit_size); \ -} +#define NIR_DEFINE_SCALAR_AS_CONST(type, suffix) \ + static inline type \ + nir_ssa_scalar_as_##suffix(nir_ssa_scalar s) \ + { \ + return nir_const_value_as_##suffix( \ + nir_ssa_scalar_as_const_value(s), s.def->bit_size); \ + } -NIR_DEFINE_SCALAR_AS_CONST(int64_t, int) -NIR_DEFINE_SCALAR_AS_CONST(uint64_t, uint) -NIR_DEFINE_SCALAR_AS_CONST(bool, bool) -NIR_DEFINE_SCALAR_AS_CONST(double, float) +NIR_DEFINE_SCALAR_AS_CONST(int64_t, int) +NIR_DEFINE_SCALAR_AS_CONST(uint64_t, uint) +NIR_DEFINE_SCALAR_AS_CONST(bool, bool) +NIR_DEFINE_SCALAR_AS_CONST(double, float) #undef NIR_DEFINE_SCALAR_AS_CONST @@ -2711,7 +2708,6 @@ typedef struct { nir_binding nir_chase_binding(nir_src rsrc); nir_variable *nir_get_binding_variable(struct nir_shader *shader, nir_binding binding); - /* * Control flow * @@ -2848,7 +2844,7 @@ nir_block_ends_in_break(nir_block *block) nir_instr *instr = nir_block_last_instr(block); return instr->type == nir_instr_type_jump && - nir_instr_as_jump(instr)->type == nir_jump_break; + nir_instr_as_jump(instr)->type == nir_jump_break; } #define nir_foreach_instr(instr, block) \ @@ -2885,14 +2881,14 @@ nir_next_phi(nir_phi_instr *phi) return NULL; } -#define nir_foreach_phi(instr, block) \ - for (nir_phi_instr *instr = nir_first_phi_in_block(block); instr != NULL; \ +#define nir_foreach_phi(instr, block) \ + for (nir_phi_instr *instr = nir_first_phi_in_block(block); instr != NULL; \ instr = nir_next_phi(instr)) -#define nir_foreach_phi_safe(instr, block) \ - for (nir_phi_instr *instr = nir_first_phi_in_block(block), \ - *__next = instr ? nir_next_phi(instr) : NULL; \ - instr != NULL; \ +#define nir_foreach_phi_safe(instr, block) \ + for (nir_phi_instr *instr = nir_first_phi_in_block(block), \ + *__next = instr ? nir_next_phi(instr) : NULL; \ + instr != NULL; \ instr = __next, __next = instr ? nir_next_phi(instr) : NULL) static inline nir_phi_instr * @@ -3023,7 +3019,7 @@ typedef enum { typedef struct { nir_cf_node cf_node; - struct exec_list body; /** < list of nir_cf_node */ + struct exec_list body; /** < list of nir_cf_node */ struct exec_list continue_list; /** < (optional) list of nir_cf_node */ nir_loop_info *info; @@ -3162,13 +3158,13 @@ typedef struct { ATTRIBUTE_RETURNS_NONNULL static inline nir_block * nir_start_block(nir_function_impl *impl) { - return (nir_block *) impl->body.head_sentinel.next; + return (nir_block *)impl->body.head_sentinel.next; } ATTRIBUTE_RETURNS_NONNULL static inline nir_block * nir_impl_last_block(nir_function_impl *impl) { - return (nir_block *) impl->body.tail_sentinel.prev; + return (nir_block *)impl->body.tail_sentinel.prev; } static inline nir_cf_node * @@ -3385,13 +3381,13 @@ typedef enum { } nir_divergence_options; typedef enum { - nir_pack_varying_interp_mode_none = (1 << 0), - nir_pack_varying_interp_mode_smooth = (1 << 1), - nir_pack_varying_interp_mode_flat = (1 << 2), + nir_pack_varying_interp_mode_none = (1 << 0), + nir_pack_varying_interp_mode_smooth = (1 << 1), + nir_pack_varying_interp_mode_flat = (1 << 2), nir_pack_varying_interp_mode_noperspective = (1 << 3), - nir_pack_varying_interp_loc_sample = (1 << 16), - nir_pack_varying_interp_loc_centroid = (1 << 17), - nir_pack_varying_interp_loc_center = (1 << 18), + nir_pack_varying_interp_loc_sample = (1 << 16), + nir_pack_varying_interp_loc_centroid = (1 << 17), + nir_pack_varying_interp_loc_center = (1 << 18), } nir_pack_varying_options; /** An instruction filtering callback @@ -3687,7 +3683,6 @@ typedef struct nir_shader_compiler_options { */ bool use_interpolated_input_intrinsics; - /** * Whether nir_lower_io() will lower interpolateAt functions to * load_interpolated_input intrinsics. @@ -3944,13 +3939,13 @@ nir_foreach_function_with_impl_next(nir_function **it) return NULL; } -#define nir_foreach_function_with_impl(it, impl_it, shader) \ - for (nir_function *it =nir_foreach_function_with_impl_first(shader); \ - it != NULL; \ - it = NULL) \ - \ - for (nir_function_impl *impl_it = it->impl; \ - impl_it != NULL; \ +#define nir_foreach_function_with_impl(it, impl_it, shader) \ + for (nir_function *it = nir_foreach_function_with_impl_first(shader); \ + it != NULL; \ + it = NULL) \ + \ + for (nir_function_impl *impl_it = it->impl; \ + impl_it != NULL; \ impl_it = nir_foreach_function_with_impl_next(&it)) /* Equivalent to @@ -4405,13 +4400,14 @@ bool nir_foreach_phi_src_leaving_block(nir_block *instr, nir_const_value *nir_src_as_const_value(nir_src src); -#define NIR_SRC_AS_(name, c_type, type_enum, cast_macro) \ -static inline c_type * \ -nir_src_as_ ## name (nir_src src) \ -{ \ - return src.ssa->parent_instr->type == type_enum \ - ? cast_macro(src.ssa->parent_instr) : NULL; \ -} +#define NIR_SRC_AS_(name, c_type, type_enum, cast_macro) \ + static inline c_type * \ + nir_src_as_##name(nir_src src) \ + { \ + return src.ssa->parent_instr->type == type_enum \ + ? cast_macro(src.ssa->parent_instr) \ + : NULL; \ + } NIR_SRC_AS_(alu_instr, nir_alu_instr, nir_instr_type_alu, nir_instr_as_alu) NIR_SRC_AS_(intrinsic, nir_intrinsic_instr, @@ -4472,7 +4468,6 @@ nir_ssa_def_is_unused(nir_ssa_def *ssa) return list_is_empty(&ssa->uses); } - /** Returns the next block, disregarding structure * * The ordering is deterministic but has no guarantees beyond that. In @@ -4481,14 +4476,14 @@ nir_ssa_def_is_unused(nir_ssa_def *ssa) nir_block *nir_block_unstructured_next(nir_block *block); nir_block *nir_unstructured_start_block(nir_function_impl *impl); -#define nir_foreach_block_unstructured(block, impl) \ +#define nir_foreach_block_unstructured(block, impl) \ for (nir_block *block = nir_unstructured_start_block(impl); block != NULL; \ block = nir_block_unstructured_next(block)) -#define nir_foreach_block_unstructured_safe(block, impl) \ +#define nir_foreach_block_unstructured_safe(block, impl) \ for (nir_block *block = nir_unstructured_start_block(impl), \ - *next = nir_block_unstructured_next(block); \ - block != NULL; \ + *next = nir_block_unstructured_next(block); \ + block != NULL; \ block = next, next = nir_block_unstructured_next(block)) /* @@ -4516,29 +4511,29 @@ nir_block *nir_cf_node_cf_tree_next(nir_cf_node *node); /* Macros for loops that visit blocks in source-code order */ -#define nir_foreach_block(block, impl) \ +#define nir_foreach_block(block, impl) \ for (nir_block *block = nir_start_block(impl); block != NULL; \ block = nir_block_cf_tree_next(block)) -#define nir_foreach_block_safe(block, impl) \ - for (nir_block *block = nir_start_block(impl), \ - *next = nir_block_cf_tree_next(block); \ - block != NULL; \ +#define nir_foreach_block_safe(block, impl) \ + for (nir_block *block = nir_start_block(impl), \ + *next = nir_block_cf_tree_next(block); \ + block != NULL; \ block = next, next = nir_block_cf_tree_next(block)) -#define nir_foreach_block_reverse(block, impl) \ +#define nir_foreach_block_reverse(block, impl) \ for (nir_block *block = nir_impl_last_block(impl); block != NULL; \ block = nir_block_cf_tree_prev(block)) -#define nir_foreach_block_reverse_safe(block, impl) \ - for (nir_block *block = nir_impl_last_block(impl), \ - *prev = nir_block_cf_tree_prev(block); \ - block != NULL; \ +#define nir_foreach_block_reverse_safe(block, impl) \ + for (nir_block *block = nir_impl_last_block(impl), \ + *prev = nir_block_cf_tree_prev(block); \ + block != NULL; \ block = prev, prev = nir_block_cf_tree_prev(block)) -#define nir_foreach_block_in_cf_node(block, node) \ +#define nir_foreach_block_in_cf_node(block, node) \ for (nir_block *block = nir_cf_node_cf_tree_first(node); \ - block != nir_cf_node_cf_tree_next(node); \ + block != nir_cf_node_cf_tree_next(node); \ block = nir_block_cf_tree_next(block)) /* If the following CF node is an if, this function returns that if. @@ -4565,9 +4560,9 @@ void nir_print_shader_annotated(nir_shader *shader, FILE *fp, struct hash_table void nir_print_instr(const nir_instr *instr, FILE *fp); void nir_print_deref(const nir_deref_instr *deref, FILE *fp); void nir_log_shader_annotated_tagged(enum mesa_log_level level, const char *tag, nir_shader *shader, struct hash_table *annotations); -#define nir_log_shadere(s) nir_log_shader_annotated_tagged(MESA_LOG_ERROR, (MESA_LOG_TAG), (s), NULL) -#define nir_log_shaderw(s) nir_log_shader_annotated_tagged(MESA_LOG_WARN, (MESA_LOG_TAG), (s), NULL) -#define nir_log_shaderi(s) nir_log_shader_annotated_tagged(MESA_LOG_INFO, (MESA_LOG_TAG), (s), NULL) +#define nir_log_shadere(s) nir_log_shader_annotated_tagged(MESA_LOG_ERROR, (MESA_LOG_TAG), (s), NULL) +#define nir_log_shaderw(s) nir_log_shader_annotated_tagged(MESA_LOG_WARN, (MESA_LOG_TAG), (s), NULL) +#define nir_log_shaderi(s) nir_log_shader_annotated_tagged(MESA_LOG_INFO, (MESA_LOG_TAG), (s), NULL) #define nir_log_shader_annotated(s, annotations) nir_log_shader_annotated_tagged(MESA_LOG_ERROR, (MESA_LOG_TAG), (s), annotations) char *nir_shader_as_str(nir_shader *nir, void *mem_ctx); @@ -4628,50 +4623,77 @@ should_print_nir(nir_shader *shader) return unlikely(nir_debug_print_shader[shader->info.stage]); } #else -static inline void nir_validate_shader(nir_shader *shader, const char *when) { (void) shader; (void)when; } -static inline void nir_validate_ssa_dominance(nir_shader *shader, const char *when) { (void) shader; (void)when; } -static inline void nir_metadata_set_validation_flag(nir_shader *shader) { (void) shader; } -static inline void nir_metadata_check_validation_flag(nir_shader *shader) { (void) shader; } -static inline bool should_skip_nir(UNUSED const char *pass_name) { return false; } -static inline bool should_print_nir(UNUSED nir_shader *shader) { return false; } +static inline void +nir_validate_shader(nir_shader *shader, const char *when) +{ + (void)shader; + (void)when; +} +static inline void +nir_validate_ssa_dominance(nir_shader *shader, const char *when) +{ + (void)shader; + (void)when; +} +static inline void +nir_metadata_set_validation_flag(nir_shader *shader) +{ + (void)shader; +} +static inline void +nir_metadata_check_validation_flag(nir_shader *shader) +{ + (void)shader; +} +static inline bool +should_skip_nir(UNUSED const char *pass_name) +{ + return false; +} +static inline bool +should_print_nir(UNUSED nir_shader *shader) +{ + return false; +} #endif /* NDEBUG */ -#define _PASS(pass, nir, do_pass) do { \ - if (should_skip_nir(#pass)) { \ - printf("skipping %s\n", #pass); \ - break; \ - } \ - do_pass \ - if (NIR_DEBUG(CLONE)) { \ - nir_shader *clone = nir_shader_clone(ralloc_parent(nir), nir); \ - nir_shader_replace(nir, clone); \ - } \ - if (NIR_DEBUG(SERIALIZE)) { \ - nir_shader_serialize_deserialize(nir); \ - } \ -} while (0) - -#define NIR_PASS(progress, nir, pass, ...) _PASS(pass, nir, { \ - nir_metadata_set_validation_flag(nir); \ - if (should_print_nir(nir)) \ - printf("%s\n", #pass); \ - if (pass(nir, ##__VA_ARGS__)) { \ - nir_validate_shader(nir, "after " #pass " in " __FILE__); \ - UNUSED bool _; \ - progress = true; \ - if (should_print_nir(nir)) \ - nir_print_shader(nir, stdout); \ - nir_metadata_check_validation_flag(nir); \ - } \ +#define _PASS(pass, nir, do_pass) \ + do { \ + if (should_skip_nir(#pass)) { \ + printf("skipping %s\n", #pass); \ + break; \ + } \ + do_pass if (NIR_DEBUG(CLONE)) \ + { \ + nir_shader *clone = nir_shader_clone(ralloc_parent(nir), nir); \ + nir_shader_replace(nir, clone); \ + } \ + if (NIR_DEBUG(SERIALIZE)) { \ + nir_shader_serialize_deserialize(nir); \ + } \ + } while (0) + +#define NIR_PASS(progress, nir, pass, ...) _PASS(pass, nir, { \ + nir_metadata_set_validation_flag(nir); \ + if (should_print_nir(nir)) \ + printf("%s\n", #pass); \ + if (pass(nir, ##__VA_ARGS__)) { \ + nir_validate_shader(nir, "after " #pass " in " __FILE__); \ + UNUSED bool _; \ + progress = true; \ + if (should_print_nir(nir)) \ + nir_print_shader(nir, stdout); \ + nir_metadata_check_validation_flag(nir); \ + } \ }) -#define NIR_PASS_V(nir, pass, ...) _PASS(pass, nir, { \ - if (should_print_nir(nir)) \ - printf("%s\n", #pass); \ - pass(nir, ##__VA_ARGS__); \ - nir_validate_shader(nir, "after " #pass " in " __FILE__); \ - if (should_print_nir(nir)) \ - nir_print_shader(nir, stdout); \ +#define NIR_PASS_V(nir, pass, ...) _PASS(pass, nir, { \ + if (should_print_nir(nir)) \ + printf("%s\n", #pass); \ + pass(nir, ##__VA_ARGS__); \ + nir_validate_shader(nir, "after " #pass " in " __FILE__); \ + if (should_print_nir(nir)) \ + nir_print_shader(nir, stdout); \ }) #define NIR_SKIP(name) should_skip_nir(#name) @@ -4812,10 +4834,10 @@ void nir_fixup_deref_modes(nir_shader *shader); bool nir_lower_global_vars_to_local(nir_shader *shader); typedef enum { - nir_lower_direct_array_deref_of_vec_load = (1 << 0), - nir_lower_indirect_array_deref_of_vec_load = (1 << 1), - nir_lower_direct_array_deref_of_vec_store = (1 << 2), - nir_lower_indirect_array_deref_of_vec_store = (1 << 3), + nir_lower_direct_array_deref_of_vec_load = (1 << 0), + nir_lower_indirect_array_deref_of_vec_load = (1 << 1), + nir_lower_direct_array_deref_of_vec_store = (1 << 2), + nir_lower_indirect_array_deref_of_vec_store = (1 << 3), } nir_lower_array_deref_of_vec_options; bool nir_lower_array_deref_of_vec(nir_shader *shader, nir_variable_mode modes, @@ -4969,7 +4991,7 @@ typedef enum { * An address format which is a 64-bit value, where the high 32 bits * are a buffer index, and the low 32 bits are an offset. */ - nir_address_format_32bit_index_offset_pack64, + nir_address_format_32bit_index_offset_pack64, /** * An address format which is comprised of a vec3 where the first two @@ -5005,7 +5027,7 @@ typedef enum { /** * An address format which is a simple 32-bit offset cast to 64-bit. */ - nir_address_format_32bit_offset_as_64bit, + nir_address_format_32bit_offset_as_64bit, /** * An address format representing a purely logical addressing model. In @@ -5050,10 +5072,10 @@ nir_ssa_def *nir_build_addr_ieq(struct nir_builder *b, nir_ssa_def *addr0, nir_s nir_ssa_def *nir_build_addr_isub(struct nir_builder *b, nir_ssa_def *addr0, nir_ssa_def *addr1, nir_address_format addr_format); -nir_ssa_def * nir_explicit_io_address_from_deref(struct nir_builder *b, - nir_deref_instr *deref, - nir_ssa_def *base_addr, - nir_address_format addr_format); +nir_ssa_def *nir_explicit_io_address_from_deref(struct nir_builder *b, + nir_deref_instr *deref, + nir_ssa_def *base_addr, + nir_address_format addr_format); bool nir_get_explicit_deref_align(nir_deref_instr *deref, bool default_to_type_align, @@ -5130,7 +5152,6 @@ typedef struct { bool lower_shared; } nir_lower_robust_access_options; - bool nir_lower_robust_access(nir_shader *s, const nir_lower_robust_access_options *opts); @@ -5262,16 +5283,16 @@ bool nir_lower_io_to_scalar(nir_shader *shader, nir_variable_mode mask, nir_inst bool nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask); bool nir_lower_io_to_vector(nir_shader *shader, nir_variable_mode mask); bool nir_vectorize_tess_levels(nir_shader *shader); -nir_shader * nir_create_passthrough_tcs_impl(const nir_shader_compiler_options *options, - unsigned *locations, unsigned num_locations, - uint8_t patch_vertices); -nir_shader * nir_create_passthrough_tcs(const nir_shader_compiler_options *options, - const nir_shader *vs, uint8_t patch_vertices); -nir_shader * nir_create_passthrough_gs(const nir_shader_compiler_options *options, - const nir_shader *prev_stage, - enum mesa_prim primitive_type, - bool emulate_edgeflags, - bool force_line_strip_out); +nir_shader *nir_create_passthrough_tcs_impl(const nir_shader_compiler_options *options, + unsigned *locations, unsigned num_locations, + uint8_t patch_vertices); +nir_shader *nir_create_passthrough_tcs(const nir_shader_compiler_options *options, + const nir_shader *vs, uint8_t patch_vertices); +nir_shader *nir_create_passthrough_gs(const nir_shader_compiler_options *options, + const nir_shader *prev_stage, + enum mesa_prim primitive_type, + bool emulate_edgeflags, + bool force_line_strip_out); bool nir_lower_fragcolor(nir_shader *shader, unsigned max_cbufs); bool nir_lower_fragcoord_wtrans(nir_shader *shader); @@ -5287,21 +5308,21 @@ typedef struct nir_lower_subgroups_options { uint8_t subgroup_size; uint8_t ballot_bit_size; uint8_t ballot_components; - bool lower_to_scalar:1; - bool lower_vote_trivial:1; - bool lower_vote_eq:1; - bool lower_subgroup_masks:1; - bool lower_relative_shuffle:1; - bool lower_shuffle_to_32bit:1; - bool lower_shuffle_to_swizzle_amd:1; - bool lower_shuffle:1; - bool lower_quad:1; - bool lower_quad_broadcast_dynamic:1; - bool lower_quad_broadcast_dynamic_to_const:1; - bool lower_elect:1; - bool lower_read_invocation_to_cond:1; - bool lower_rotate_to_shuffle:1; - bool lower_ballot_bit_count_to_mbcnt_amd:1; + bool lower_to_scalar : 1; + bool lower_vote_trivial : 1; + bool lower_vote_eq : 1; + bool lower_subgroup_masks : 1; + bool lower_relative_shuffle : 1; + bool lower_shuffle_to_32bit : 1; + bool lower_shuffle_to_swizzle_amd : 1; + bool lower_shuffle : 1; + bool lower_quad : 1; + bool lower_quad_broadcast_dynamic : 1; + bool lower_quad_broadcast_dynamic_to_const : 1; + bool lower_elect : 1; + bool lower_read_invocation_to_cond : 1; + bool lower_rotate_to_shuffle : 1; + bool lower_ballot_bit_count_to_mbcnt_amd : 1; } nir_lower_subgroups_options; bool nir_lower_subgroups(nir_shader *shader, @@ -5313,16 +5334,16 @@ nir_ssa_def * nir_build_lowered_load_helper_invocation(struct nir_builder *b); typedef struct nir_lower_compute_system_values_options { - bool has_base_global_invocation_id:1; - bool has_base_workgroup_id:1; - bool shuffle_local_ids_for_quad_derivatives:1; - bool lower_local_invocation_index:1; - bool lower_cs_local_id_to_index:1; - bool lower_workgroup_id_to_index:1; + bool has_base_global_invocation_id : 1; + bool has_base_workgroup_id : 1; + bool shuffle_local_ids_for_quad_derivatives : 1; + bool lower_local_invocation_index : 1; + bool lower_cs_local_id_to_index : 1; + bool lower_workgroup_id_to_index : 1; /* At shader execution time, check if WorkGroupId should be 1D * and compute it quickly. Fall back to slow computation if not. */ - bool shortcut_1d_workgroup_id:1; + bool shortcut_1d_workgroup_id : 1; uint16_t num_workgroups[3]; /* Compile-time-known dispatch sizes, or 0 if unknown. */ } nir_lower_compute_system_values_options; @@ -5330,9 +5351,9 @@ bool nir_lower_compute_system_values(nir_shader *shader, const nir_lower_compute_system_values_options *options); struct nir_lower_sysvals_to_varyings_options { - bool frag_coord:1; - bool front_face:1; - bool point_coord:1; + bool frag_coord : 1; + bool front_face : 1; + bool point_coord : 1; }; bool @@ -5575,12 +5596,11 @@ typedef struct nir_lower_tex_options { bool nir_lower_tex(nir_shader *shader, const nir_lower_tex_options *options); - typedef struct nir_lower_tex_shadow_swizzle { - unsigned swizzle_r:3; - unsigned swizzle_g:3; - unsigned swizzle_b:3; - unsigned swizzle_a:3; + unsigned swizzle_r : 3; + unsigned swizzle_g : 3; + unsigned swizzle_b : 3; + unsigned swizzle_a : 3; } nir_lower_tex_shadow_swizzle; bool @@ -5600,11 +5620,11 @@ typedef struct nir_lower_image_options { */ bool lower_to_fragment_mask_load_amd; - /** - * Lower image_samples to a constant in case the driver doesn't support multisampled - * images. - */ - bool lower_image_samples_to_one; + /** + * Lower image_samples to a constant in case the driver doesn't support multisampled + * images. + */ + bool lower_image_samples_to_one; } nir_lower_image_options; bool nir_lower_image(nir_shader *nir, @@ -5616,11 +5636,11 @@ nir_lower_image_atomics_to_global(nir_shader *s); bool nir_lower_readonly_images_to_tex(nir_shader *shader, bool per_variable); enum nir_lower_non_uniform_access_type { - nir_lower_non_uniform_ubo_access = (1 << 0), - nir_lower_non_uniform_ssbo_access = (1 << 1), + nir_lower_non_uniform_ubo_access = (1 << 0), + nir_lower_non_uniform_ssbo_access = (1 << 1), nir_lower_non_uniform_texture_access = (1 << 2), - nir_lower_non_uniform_image_access = (1 << 3), - nir_lower_non_uniform_get_ssbo_size = (1 << 4), + nir_lower_non_uniform_image_access = (1 << 3), + nir_lower_non_uniform_get_ssbo_size = (1 << 4), }; /* Given the nir_src used for the resource, return the channels which might be non-uniform. */ @@ -5685,10 +5705,10 @@ bool nir_lower_patch_vertices(nir_shader *nir, unsigned static_count, typedef struct nir_lower_wpos_ytransform_options { gl_state_index16 state_tokens[STATE_LENGTH]; - bool fs_coord_origin_upper_left :1; - bool fs_coord_origin_lower_left :1; - bool fs_coord_pixel_center_integer :1; - bool fs_coord_pixel_center_half_integer :1; + bool fs_coord_origin_upper_left : 1; + bool fs_coord_origin_lower_left : 1; + bool fs_coord_pixel_center_integer : 1; + bool fs_coord_pixel_center_half_integer : 1; } nir_lower_wpos_ytransform_options; bool nir_lower_wpos_ytransform(nir_shader *shader, @@ -5708,8 +5728,8 @@ typedef struct nir_lower_drawpixels_options { gl_state_index16 bias_state_tokens[STATE_LENGTH]; unsigned drawpix_sampler; unsigned pixelmap_sampler; - bool pixel_maps :1; - bool scale_and_bias :1; + bool pixel_maps : 1; + bool scale_and_bias : 1; } nir_lower_drawpixels_options; void nir_lower_drawpixels(nir_shader *shader, @@ -5807,9 +5827,9 @@ void nir_lower_texcoord_replace_late(nir_shader *s, unsigned coord_replace, typedef enum { nir_lower_interpolation_at_sample = (1 << 1), nir_lower_interpolation_at_offset = (1 << 2), - nir_lower_interpolation_centroid = (1 << 3), - nir_lower_interpolation_pixel = (1 << 4), - nir_lower_interpolation_sample = (1 << 5), + nir_lower_interpolation_centroid = (1 << 3), + nir_lower_interpolation_pixel = (1 << 4), + nir_lower_interpolation_sample = (1 << 5), } nir_lower_interpolation_options; bool nir_lower_interpolation(nir_shader *shader, @@ -5963,13 +5983,13 @@ bool nir_opt_large_constants(nir_shader *shader, bool nir_opt_loop_unroll(nir_shader *shader); typedef enum { - nir_move_const_undef = (1 << 0), - nir_move_load_ubo = (1 << 1), - nir_move_load_input = (1 << 2), - nir_move_comparisons = (1 << 3), - nir_move_copies = (1 << 4), - nir_move_load_ssbo = (1 << 5), - nir_move_load_uniform = (1 << 6), + nir_move_const_undef = (1 << 0), + nir_move_load_ubo = (1 << 1), + nir_move_load_input = (1 << 2), + nir_move_comparisons = (1 << 3), + nir_move_copies = (1 << 4), + nir_move_load_ssbo = (1 << 5), + nir_move_load_uniform = (1 << 6), } nir_move_options; bool nir_can_move_instr(nir_instr *instr, nir_move_options options); @@ -6060,9 +6080,7 @@ nir_variable_is_in_block(const nir_variable *var) static inline unsigned nir_variable_count_slots(const nir_variable *var, const struct glsl_type *type) { - return var->data.compact ? - DIV_ROUND_UP(var->data.location_frac + glsl_get_length(type), 4) : - glsl_count_attribute_slots(type, false); + return var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(type), 4) : glsl_count_attribute_slots(type, false); } /* See default_ub_config in nir_range_analysis.c for documentation. */ @@ -6177,13 +6195,13 @@ nir_next_decl_reg(nir_intrinsic_instr *prev, nir_function_impl *impl) return NULL; } -#define nir_foreach_reg_decl(reg, impl) \ - for (nir_intrinsic_instr *reg = nir_next_decl_reg(NULL, impl); \ +#define nir_foreach_reg_decl(reg, impl) \ + for (nir_intrinsic_instr *reg = nir_next_decl_reg(NULL, impl); \ reg; reg = nir_next_decl_reg(reg, NULL)) -#define nir_foreach_reg_decl_safe(reg, impl) \ - for (nir_intrinsic_instr *reg = nir_next_decl_reg(NULL, impl), \ - *next_ = nir_next_decl_reg(reg, NULL); \ +#define nir_foreach_reg_decl_safe(reg, impl) \ + for (nir_intrinsic_instr *reg = nir_next_decl_reg(NULL, impl), \ + *next_ = nir_next_decl_reg(reg, NULL); \ reg; reg = next_, next_ = nir_next_decl_reg(next_, NULL)) static inline bool @@ -6200,16 +6218,16 @@ nir_is_store_reg(nir_intrinsic_instr *intr) intr->intrinsic == nir_intrinsic_store_reg_indirect; } -#define nir_foreach_reg_load(load, reg) \ - assert(reg->intrinsic == nir_intrinsic_decl_reg); \ - \ - nir_foreach_use(load, ®->dest.ssa) \ +#define nir_foreach_reg_load(load, reg) \ + assert(reg->intrinsic == nir_intrinsic_decl_reg); \ + \ + nir_foreach_use(load, ®->dest.ssa) \ if (nir_is_load_reg(nir_instr_as_intrinsic(load->parent_instr))) -#define nir_foreach_reg_store(store, reg) \ - assert(reg->intrinsic == nir_intrinsic_decl_reg); \ - \ - nir_foreach_use(store, ®->dest.ssa) \ +#define nir_foreach_reg_store(store, reg) \ + assert(reg->intrinsic == nir_intrinsic_decl_reg); \ + \ + nir_foreach_use(store, ®->dest.ssa) \ if (nir_is_store_reg(nir_instr_as_intrinsic(store->parent_instr))) static inline nir_intrinsic_instr * diff --git a/src/compiler/nir/nir_builder.c b/src/compiler/nir/nir_builder.c index a7f6ae7..0de722e 100644 --- a/src/compiler/nir/nir_builder.c +++ b/src/compiler/nir/nir_builder.c @@ -25,9 +25,9 @@ #include "nir_builder.h" nir_builder MUST_CHECK PRINTFLIKE(3, 4) -nir_builder_init_simple_shader(gl_shader_stage stage, - const nir_shader_compiler_options *options, - const char *name, ...) + nir_builder_init_simple_shader(gl_shader_stage stage, + const nir_shader_compiler_options *options, + const char *name, ...) { nir_builder b; @@ -94,7 +94,7 @@ nir_builder_alu_instr_finish_and_insert(nir_builder *build, nir_alu_instr *instr bit_size = src_bit_size; } else { assert(src_bit_size == - nir_alu_type_get_type_size(op_info->input_types[i])); + nir_alu_type_get_type_size(op_info->input_types[i])); } } } @@ -154,7 +154,7 @@ nir_build_alu1(nir_builder *build, nir_op op, nir_ssa_def *src0) nir_ssa_def * nir_build_alu2(nir_builder *build, nir_op op, nir_ssa_def *src0, - nir_ssa_def *src1) + nir_ssa_def *src1) { nir_alu_instr *instr = nir_alu_instr_create(build->shader, op); if (!instr) @@ -168,7 +168,7 @@ nir_build_alu2(nir_builder *build, nir_op op, nir_ssa_def *src0, nir_ssa_def * nir_build_alu3(nir_builder *build, nir_op op, nir_ssa_def *src0, - nir_ssa_def *src1, nir_ssa_def *src2) + nir_ssa_def *src1, nir_ssa_def *src2) { nir_alu_instr *instr = nir_alu_instr_create(build->shader, op); if (!instr) @@ -183,7 +183,7 @@ nir_build_alu3(nir_builder *build, nir_op op, nir_ssa_def *src0, nir_ssa_def * nir_build_alu4(nir_builder *build, nir_op op, nir_ssa_def *src0, - nir_ssa_def *src1, nir_ssa_def *src2, nir_ssa_def *src3) + nir_ssa_def *src1, nir_ssa_def *src2, nir_ssa_def *src3) { nir_alu_instr *instr = nir_alu_instr_create(build->shader, op); if (!instr) @@ -267,7 +267,7 @@ nir_build_tex_deref_instr(nir_builder *build, nir_texop op, case nir_tex_src_coord: tex->coord_components = nir_src_num_components(extra_srcs[i].src); assert(tex->coord_components == tex->is_array + - glsl_get_sampler_dim_coordinate_components(tex->sampler_dim)); + glsl_get_sampler_dim_coordinate_components(tex->sampler_dim)); break; case nir_tex_src_lod: @@ -553,10 +553,10 @@ nir_type_convert(nir_builder *b, nir_alu_type_get_type_size(src_type) == src->bit_size); const nir_alu_type dst_base = - (nir_alu_type) nir_alu_type_get_base_type(dest_type); + (nir_alu_type)nir_alu_type_get_base_type(dest_type); const nir_alu_type src_base = - (nir_alu_type) nir_alu_type_get_base_type(src_type); + (nir_alu_type)nir_alu_type_get_base_type(src_type); /* b2b uses the regular type conversion path, but i2b and f2b are * implemented as src != 0. @@ -568,21 +568,39 @@ nir_type_convert(nir_builder *b, if (src_base == nir_type_float) { switch (dst_bit_size) { - case 1: opcode = nir_op_fneu; break; - case 8: opcode = nir_op_fneu8; break; - case 16: opcode = nir_op_fneu16; break; - case 32: opcode = nir_op_fneu32; break; - default: unreachable("Invalid Boolean size."); + case 1: + opcode = nir_op_fneu; + break; + case 8: + opcode = nir_op_fneu8; + break; + case 16: + opcode = nir_op_fneu16; + break; + case 32: + opcode = nir_op_fneu32; + break; + default: + unreachable("Invalid Boolean size."); } } else { assert(src_base == nir_type_int || src_base == nir_type_uint); switch (dst_bit_size) { - case 1: opcode = nir_op_ine; break; - case 8: opcode = nir_op_ine8; break; - case 16: opcode = nir_op_ine16; break; - case 32: opcode = nir_op_ine32; break; - default: unreachable("Invalid Boolean size."); + case 1: + opcode = nir_op_ine; + break; + case 8: + opcode = nir_op_ine8; + break; + case 16: + opcode = nir_op_ine16; + break; + case 32: + opcode = nir_op_ine32; + break; + default: + unreachable("Invalid Boolean size."); } } @@ -590,7 +608,7 @@ nir_type_convert(nir_builder *b, nir_imm_zero(b, src->num_components, src->bit_size), NULL, NULL); } else { - src_type = (nir_alu_type) (src_type | src->bit_size); + src_type = (nir_alu_type)(src_type | src->bit_size); nir_op opcode = nir_type_conversion_op(src_type, dest_type, rnd); diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index e098101..b495de8 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -24,9 +24,9 @@ #ifndef NIR_BUILDER_H #define NIR_BUILDER_H -#include "nir_control_flow.h" #include "util/bitscan.h" #include "util/half_float.h" +#include "nir_control_flow.h" #ifdef __cplusplus extern "C" { @@ -71,9 +71,9 @@ nir_builder_at(nir_cursor cursor) } nir_builder MUST_CHECK PRINTFLIKE(3, 4) -nir_builder_init_simple_shader(gl_shader_stage stage, - const nir_shader_compiler_options *options, - const char *name, ...); + nir_builder_init_simple_shader(gl_shader_stage stage, + const nir_shader_compiler_options *options, + const char *name, ...); typedef bool (*nir_instr_pass_cb)(struct nir_builder *, nir_instr *, void *); @@ -400,11 +400,11 @@ nir_type_convert(nir_builder *b, static inline nir_ssa_def * nir_convert_to_bit_size(nir_builder *b, - nir_ssa_def *src, - nir_alu_type type, - unsigned bit_size) + nir_ssa_def *src, + nir_alu_type type, + unsigned bit_size) { - return nir_type_convert(b, src, type, (nir_alu_type) (type | bit_size), + return nir_type_convert(b, src, type, (nir_alu_type)(type | bit_size), nir_rounding_mode_undef); } @@ -442,7 +442,7 @@ static inline nir_ssa_def * nir_b2iN(nir_builder *b, nir_ssa_def *src, uint32_t bit_size) { return nir_type_convert(b, src, nir_type_bool, - (nir_alu_type) (nir_type_int | bit_size), + (nir_alu_type)(nir_type_int | bit_size), nir_rounding_mode_undef); } @@ -450,7 +450,7 @@ static inline nir_ssa_def * nir_b2fN(nir_builder *b, nir_ssa_def *src, uint32_t bit_size) { return nir_type_convert(b, src, nir_type_bool, - (nir_alu_type) (nir_type_float | bit_size), + (nir_alu_type)(nir_type_float | bit_size), nir_rounding_mode_undef); } @@ -458,7 +458,7 @@ static inline nir_ssa_def * nir_i2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) { return nir_type_convert(b, src, nir_type_int, - (nir_alu_type) (nir_type_float | bit_size), + (nir_alu_type)(nir_type_float | bit_size), nir_rounding_mode_undef); } @@ -466,7 +466,7 @@ static inline nir_ssa_def * nir_u2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) { return nir_type_convert(b, src, nir_type_uint, - (nir_alu_type) (nir_type_float | bit_size), + (nir_alu_type)(nir_type_float | bit_size), nir_rounding_mode_undef); } @@ -474,7 +474,7 @@ static inline nir_ssa_def * nir_f2uN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) { return nir_type_convert(b, src, nir_type_float, - (nir_alu_type) (nir_type_uint | bit_size), + (nir_alu_type)(nir_type_uint | bit_size), nir_rounding_mode_undef); } @@ -482,7 +482,7 @@ static inline nir_ssa_def * nir_f2iN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) { return nir_type_convert(b, src, nir_type_float, - (nir_alu_type) (nir_type_int | bit_size), + (nir_alu_type)(nir_type_int | bit_size), nir_rounding_mode_undef); } @@ -548,13 +548,20 @@ nir_fdot(nir_builder *build, nir_ssa_def *src0, nir_ssa_def *src1) { assert(src0->num_components == src1->num_components); switch (src0->num_components) { - case 1: return nir_fmul(build, src0, src1); - case 2: return nir_fdot2(build, src0, src1); - case 3: return nir_fdot3(build, src0, src1); - case 4: return nir_fdot4(build, src0, src1); - case 5: return nir_fdot5(build, src0, src1); - case 8: return nir_fdot8(build, src0, src1); - case 16: return nir_fdot16(build, src0, src1); + case 1: + return nir_fmul(build, src0, src1); + case 2: + return nir_fdot2(build, src0, src1); + case 3: + return nir_fdot3(build, src0, src1); + case 4: + return nir_fdot4(build, src0, src1); + case 5: + return nir_fdot5(build, src0, src1); + case 8: + return nir_fdot8(build, src0, src1); + case 16: + return nir_fdot16(build, src0, src1); default: unreachable("bad component size"); } @@ -566,13 +573,20 @@ static inline nir_ssa_def * nir_ball_iequal(nir_builder *b, nir_ssa_def *src0, nir_ssa_def *src1) { switch (src0->num_components) { - case 1: return nir_ieq(b, src0, src1); - case 2: return nir_ball_iequal2(b, src0, src1); - case 3: return nir_ball_iequal3(b, src0, src1); - case 4: return nir_ball_iequal4(b, src0, src1); - case 5: return nir_ball_iequal5(b, src0, src1); - case 8: return nir_ball_iequal8(b, src0, src1); - case 16: return nir_ball_iequal16(b, src0, src1); + case 1: + return nir_ieq(b, src0, src1); + case 2: + return nir_ball_iequal2(b, src0, src1); + case 3: + return nir_ball_iequal3(b, src0, src1); + case 4: + return nir_ball_iequal4(b, src0, src1); + case 5: + return nir_ball_iequal5(b, src0, src1); + case 8: + return nir_ball_iequal8(b, src0, src1); + case 16: + return nir_ball_iequal16(b, src0, src1); default: unreachable("bad component size"); } @@ -588,13 +602,20 @@ static inline nir_ssa_def * nir_bany_inequal(nir_builder *b, nir_ssa_def *src0, nir_ssa_def *src1) { switch (src0->num_components) { - case 1: return nir_ine(b, src0, src1); - case 2: return nir_bany_inequal2(b, src0, src1); - case 3: return nir_bany_inequal3(b, src0, src1); - case 4: return nir_bany_inequal4(b, src0, src1); - case 5: return nir_bany_inequal5(b, src0, src1); - case 8: return nir_bany_inequal8(b, src0, src1); - case 16: return nir_bany_inequal16(b, src0, src1); + case 1: + return nir_ine(b, src0, src1); + case 2: + return nir_bany_inequal2(b, src0, src1); + case 3: + return nir_bany_inequal3(b, src0, src1); + case 4: + return nir_bany_inequal4(b, src0, src1); + case 5: + return nir_bany_inequal5(b, src0, src1); + case 8: + return nir_bany_inequal8(b, src0, src1); + case 16: + return nir_bany_inequal16(b, src0, src1); default: unreachable("bad component size"); } @@ -727,7 +748,7 @@ nir_replicate(nir_builder *b, nir_ssa_def *scalar, unsigned num_components) assert(scalar->num_components == 1); assert(num_components <= NIR_MAX_VEC_COMPONENTS); - nir_ssa_def *copies[NIR_MAX_VEC_COMPONENTS] = {NULL}; + nir_ssa_def *copies[NIR_MAX_VEC_COMPONENTS] = { NULL }; for (unsigned i = 0; i < num_components; ++i) copies[i] = scalar; @@ -882,7 +903,7 @@ nir_ishl_imm(nir_builder *build, nir_ssa_def *x, uint32_t y) if (y == 0) { return x; } else { - assert (y < x->bit_size); + assert(y < x->bit_size); return nir_ishl(build, x, nir_imm_int(build, y)); } } @@ -987,7 +1008,7 @@ nir_ffma_imm12(nir_builder *build, nir_ssa_def *src0, double src1, double src2) return nir_fadd_imm(build, nir_fmul_imm(build, src0, src1), src2); else return nir_ffma(build, src0, nir_imm_floatN_t(build, src1, src0->bit_size), - nir_imm_floatN_t(build, src2, src0->bit_size)); + nir_imm_floatN_t(build, src2, src0->bit_size)); } static inline nir_ssa_def * @@ -1017,9 +1038,12 @@ nir_pack_bits(nir_builder *b, nir_ssa_def *src, unsigned dest_bit_size) switch (dest_bit_size) { case 64: switch (src->bit_size) { - case 32: return nir_pack_64_2x32(b, src); - case 16: return nir_pack_64_4x16(b, src); - default: break; + case 32: + return nir_pack_64_2x32(b, src); + case 16: + return nir_pack_64_4x16(b, src); + default: + break; } break; @@ -1053,9 +1077,12 @@ nir_unpack_bits(nir_builder *b, nir_ssa_def *src, unsigned dest_bit_size) switch (src->bit_size) { case 64: switch (dest_bit_size) { - case 32: return nir_unpack_64_2x32(b, src); - case 16: return nir_unpack_64_4x16(b, src); - default: break; + case 32: + return nir_unpack_64_2x32(b, src); + case 16: + return nir_unpack_64_4x16(b, src); + default: + break; } break; @@ -1120,7 +1147,7 @@ nir_extract_bits(nir_builder *b, nir_ssa_def **srcs, unsigned num_srcs, const unsigned bit = first_bit + (i * common_bit_size); while (bit >= src_end_bit) { src_idx++; - assert(src_idx < (int) num_srcs); + assert(src_idx < (int)num_srcs); src_start_bit = src_end_bit; src_end_bit += srcs[src_idx]->bit_size * srcs[src_idx]->num_components; @@ -1134,8 +1161,7 @@ nir_extract_bits(nir_builder *b, nir_ssa_def **srcs, unsigned num_srcs, rel_bit / src_bit_size); if (srcs[src_idx]->bit_size > common_bit_size) { nir_ssa_def *unpacked = nir_unpack_bits(b, comp, common_bit_size); - comp = nir_channel(b, unpacked, (rel_bit % src_bit_size) / - common_bit_size); + comp = nir_channel(b, unpacked, (rel_bit % src_bit_size) / common_bit_size); } common_comps[i] = comp; } @@ -1465,7 +1491,7 @@ nir_build_deref_follower(nir_builder *b, nir_deref_instr *parent, if (leader->deref_type == nir_deref_type_array) { nir_ssa_def *index = nir_i2iN(b, leader->arr.index.ssa, - parent->dest.ssa.bit_size); + parent->dest.ssa.bit_size); return nir_build_deref_array(b, parent, index); } else { return nir_build_deref_array_wildcard(b, parent); @@ -1531,8 +1557,8 @@ static inline void nir_copy_deref(nir_builder *build, nir_deref_instr *dest, nir_deref_instr *src) { nir_copy_deref_with_access(build, dest, src, - (enum gl_access_qualifier) 0, - (enum gl_access_qualifier) 0); + (enum gl_access_qualifier)0, + (enum gl_access_qualifier)0); } static inline void @@ -1572,7 +1598,7 @@ static inline void nir_copy_var(nir_builder *build, nir_variable *dest, nir_variable *src) { nir_copy_deref(build, nir_build_deref_var(build, dest), - nir_build_deref_var(build, src)); + nir_build_deref_var(build, src)); } static inline nir_ssa_def * @@ -1635,7 +1661,7 @@ nir_store_global(nir_builder *build, nir_ssa_def *addr, unsigned align, store->src[0] = nir_src_for_ssa(value); store->src[1] = nir_src_for_ssa(addr); nir_intrinsic_set_write_mask(store, - write_mask & BITFIELD_MASK(value->num_components)); + write_mask & BITFIELD_MASK(value->num_components)); nir_intrinsic_set_align(store, align, 0); nir_builder_instr_insert(build, &store->instr); } @@ -1740,7 +1766,7 @@ static inline nir_ssa_def * nir_tex_deref(nir_builder *b, nir_deref_instr *t, nir_deref_instr *s, nir_ssa_def *coord) { - nir_tex_src srcs[] = {nir_tex_src_for_ssa(nir_tex_src_coord, coord)}; + nir_tex_src srcs[] = { nir_tex_src_for_ssa(nir_tex_src_coord, coord) }; return nir_build_tex_deref_instr(b, nir_texop_tex, t, s, ARRAY_SIZE(srcs), srcs); @@ -1832,7 +1858,7 @@ static inline nir_ssa_def * nir_samples_identical_deref(nir_builder *b, nir_deref_instr *t, nir_ssa_def *coord) { - nir_tex_src srcs[] = {nir_tex_src_for_ssa(nir_tex_src_coord, coord)}; + nir_tex_src srcs[] = { nir_tex_src_for_ssa(nir_tex_src_coord, coord) }; return nir_build_tex_deref_instr(b, nir_texop_samples_identical, t, NULL, ARRAY_SIZE(srcs), srcs); @@ -1843,7 +1869,7 @@ static inline nir_ssa_def * nir_mask(nir_builder *b, nir_ssa_def *bits, unsigned dst_bit_size) { return nir_ushr(b, nir_imm_intN_t(b, -1, dst_bit_size), - nir_isub_imm(b, dst_bit_size, nir_u2u32(b, bits))); + nir_isub_imm(b, dst_bit_size, nir_u2u32(b, bits))); } static inline nir_ssa_def * diff --git a/src/compiler/nir/nir_builtin_builder.c b/src/compiler/nir/nir_builtin_builder.c index 48d13cd..9ba8a5c 100644 --- a/src/compiler/nir/nir_builtin_builder.c +++ b/src/compiler/nir/nir_builtin_builder.c @@ -27,37 +27,37 @@ #include "nir.h" #include "nir_builtin_builder.h" -nir_ssa_def* +nir_ssa_def * nir_cross3(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) { unsigned yzx[3] = { 1, 2, 0 }; unsigned zxy[3] = { 2, 0, 1 }; return nir_ffma(b, nir_swizzle(b, x, yzx, 3), - nir_swizzle(b, y, zxy, 3), - nir_fneg(b, nir_fmul(b, nir_swizzle(b, x, zxy, 3), - nir_swizzle(b, y, yzx, 3)))); + nir_swizzle(b, y, zxy, 3), + nir_fneg(b, nir_fmul(b, nir_swizzle(b, x, zxy, 3), + nir_swizzle(b, y, yzx, 3)))); } -nir_ssa_def* +nir_ssa_def * nir_cross4(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) { nir_ssa_def *cross = nir_cross3(b, x, y); return nir_vec4(b, - nir_channel(b, cross, 0), - nir_channel(b, cross, 1), - nir_channel(b, cross, 2), - nir_imm_intN_t(b, 0, cross->bit_size)); + nir_channel(b, cross, 0), + nir_channel(b, cross, 1), + nir_channel(b, cross, 2), + nir_imm_intN_t(b, 0, cross->bit_size)); } -nir_ssa_def* +nir_ssa_def * nir_fast_length(nir_builder *b, nir_ssa_def *vec) { return nir_fsqrt(b, nir_fdot(b, vec, vec)); } -nir_ssa_def* +nir_ssa_def * nir_nextafter(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) { nir_ssa_def *zero = nir_imm_intN_t(b, 0, x->bit_size); @@ -106,7 +106,7 @@ nir_nextafter(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) return nir_nan_check2(b, x, y, nir_bcsel(b, condeq, x, res)); } -nir_ssa_def* +nir_ssa_def * nir_normalize(nir_builder *b, nir_ssa_def *vec) { if (vec->num_components == 1) @@ -128,7 +128,7 @@ nir_normalize(nir_builder *b, nir_ssa_def *vec) return nir_bcsel(b, nir_feq(b, maxc, f0), vec, res); } -nir_ssa_def* +nir_ssa_def * nir_smoothstep(nir_builder *b, nir_ssa_def *edge0, nir_ssa_def *edge1, nir_ssa_def *x) { nir_ssa_def *f2 = nir_imm_floatN_t(b, 2.0, x->bit_size); @@ -137,13 +137,13 @@ nir_smoothstep(nir_builder *b, nir_ssa_def *edge0, nir_ssa_def *edge1, nir_ssa_d /* t = clamp((x - edge0) / (edge1 - edge0), 0, 1) */ nir_ssa_def *t = nir_fsat(b, nir_fdiv(b, nir_fsub(b, x, edge0), - nir_fsub(b, edge1, edge0))); + nir_fsub(b, edge1, edge0))); /* result = t * t * (3 - 2 * t) */ return nir_fmul(b, t, nir_fmul(b, t, nir_a_minus_bc(b, f3, f2, t))); } -nir_ssa_def* +nir_ssa_def * nir_upsample(nir_builder *b, nir_ssa_def *hi, nir_ssa_def *lo) { assert(lo->num_components == hi->num_components); @@ -188,7 +188,7 @@ nir_atan(nir_builder *b, nir_ssa_def *y_over_x) * \ 1.0 / y_over_x otherwise */ nir_ssa_def *x = nir_fdiv(b, nir_fmin(b, abs_y_over_x, one), - nir_fmax(b, abs_y_over_x, one)); + nir_fmax(b, abs_y_over_x, one)); /* * approximate atan by evaluating polynomial: @@ -197,19 +197,19 @@ nir_atan(nir_builder *b, nir_ssa_def *y_over_x) * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 + * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444 */ - nir_ssa_def *x_2 = nir_fmul(b, x, x); - nir_ssa_def *x_3 = nir_fmul(b, x_2, x); - nir_ssa_def *x_5 = nir_fmul(b, x_3, x_2); - nir_ssa_def *x_7 = nir_fmul(b, x_5, x_2); - nir_ssa_def *x_9 = nir_fmul(b, x_7, x_2); + nir_ssa_def *x_2 = nir_fmul(b, x, x); + nir_ssa_def *x_3 = nir_fmul(b, x_2, x); + nir_ssa_def *x_5 = nir_fmul(b, x_3, x_2); + nir_ssa_def *x_7 = nir_fmul(b, x_5, x_2); + nir_ssa_def *x_9 = nir_fmul(b, x_7, x_2); nir_ssa_def *x_11 = nir_fmul(b, x_9, x_2); nir_ssa_def *polynomial_terms[] = { - nir_fmul_imm(b, x, 0.9999793128310355f), - nir_fmul_imm(b, x_3, -0.3326756418091246f), - nir_fmul_imm(b, x_5, 0.1938924977115610f), - nir_fmul_imm(b, x_7, -0.1173503194786851f), - nir_fmul_imm(b, x_9, 0.0536813784310406f), + nir_fmul_imm(b, x, 0.9999793128310355f), + nir_fmul_imm(b, x_3, -0.3326756418091246f), + nir_fmul_imm(b, x_5, 0.1938924977115610f), + nir_fmul_imm(b, x_7, -0.1173503194786851f), + nir_fmul_imm(b, x_9, 0.0536813784310406f), nir_fmul_imm(b, x_11, -0.0121323213173444f), }; diff --git a/src/compiler/nir/nir_builtin_builder.h b/src/compiler/nir/nir_builtin_builder.h index 61f32d0..ff263ee 100644 --- a/src/compiler/nir/nir_builtin_builder.h +++ b/src/compiler/nir/nir_builtin_builder.h @@ -36,16 +36,16 @@ extern "C" { * Definitions for functions in the C file come first. */ -nir_ssa_def* nir_cross3(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y); -nir_ssa_def* nir_cross4(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y); -nir_ssa_def* nir_fast_length(nir_builder *b, nir_ssa_def *vec); -nir_ssa_def* nir_nextafter(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y); -nir_ssa_def* nir_normalize(nir_builder *b, nir_ssa_def *vec); -nir_ssa_def* nir_smoothstep(nir_builder *b, nir_ssa_def *edge0, +nir_ssa_def *nir_cross3(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y); +nir_ssa_def *nir_cross4(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y); +nir_ssa_def *nir_fast_length(nir_builder *b, nir_ssa_def *vec); +nir_ssa_def *nir_nextafter(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y); +nir_ssa_def *nir_normalize(nir_builder *b, nir_ssa_def *vec); +nir_ssa_def *nir_smoothstep(nir_builder *b, nir_ssa_def *edge0, nir_ssa_def *edge1, nir_ssa_def *x); -nir_ssa_def* nir_upsample(nir_builder *b, nir_ssa_def *hi, nir_ssa_def *lo); -nir_ssa_def* nir_atan(nir_builder *b, nir_ssa_def *y_over_x); -nir_ssa_def* nir_atan2(nir_builder *b, nir_ssa_def *y, nir_ssa_def *x); +nir_ssa_def *nir_upsample(nir_builder *b, nir_ssa_def *hi, nir_ssa_def *lo); +nir_ssa_def *nir_atan(nir_builder *b, nir_ssa_def *y_over_x); +nir_ssa_def *nir_atan2(nir_builder *b, nir_ssa_def *y, nir_ssa_def *x); nir_ssa_def * nir_get_texture_lod(nir_builder *b, nir_tex_instr *tex); @@ -171,19 +171,19 @@ nir_fast_distance(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) return nir_fast_length(b, nir_fsub(b, x, y)); } -static inline nir_ssa_def* +static inline nir_ssa_def * nir_fast_normalize(nir_builder *b, nir_ssa_def *vec) { return nir_fdiv(b, vec, nir_fast_length(b, vec)); } -static inline nir_ssa_def* +static inline nir_ssa_def * nir_fmad(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, nir_ssa_def *z) { return nir_fadd(b, nir_fmul(b, x, y), z); } -static inline nir_ssa_def* +static inline nir_ssa_def * nir_maxmag(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) { nir_ssa_def *xabs = nir_fabs(b, x); @@ -195,7 +195,7 @@ nir_maxmag(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) return nir_bcsel(b, condy, y, nir_bcsel(b, condx, x, nir_fmax(b, x, y))); } -static inline nir_ssa_def* +static inline nir_ssa_def * nir_minmag(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) { nir_ssa_def *xabs = nir_fabs(b, x); @@ -207,7 +207,7 @@ nir_minmag(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) return nir_bcsel(b, condy, y, nir_bcsel(b, condx, x, nir_fmin(b, x, y))); } -static inline nir_ssa_def* +static inline nir_ssa_def * nir_nan(nir_builder *b, nir_ssa_def *x) { nir_ssa_def *nan = nir_imm_floatN_t(b, NAN, x->bit_size); diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index 0b03442..b10aba5 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -666,8 +666,8 @@ clone_function(clone_state *state, const nir_function *fxn, nir_shader *ns) nfxn->num_params = fxn->num_params; if (fxn->num_params) { - nfxn->params = ralloc_array(state->ns, nir_parameter, fxn->num_params); - memcpy(nfxn->params, fxn->params, sizeof(nir_parameter) * fxn->num_params); + nfxn->params = ralloc_array(state->ns, nir_parameter, fxn->num_params); + memcpy(nfxn->params, fxn->params, sizeof(nir_parameter) * fxn->num_params); } nfxn->is_entrypoint = fxn->is_entrypoint; nfxn->is_preamble = fxn->is_preamble; diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c index d04026a..6483eb0 100644 --- a/src/compiler/nir/nir_control_flow.c +++ b/src/compiler/nir/nir_control_flow.c @@ -154,7 +154,6 @@ link_block_to_non_block(nir_block *block, nir_cf_node *node) unlink_block_successors(block); link_blocks(block, loop_header_block, NULL); } - } /** @@ -190,7 +189,7 @@ split_block_beginning(nir_block *block) exec_node_insert_node_before(&block->cf_node.node, &new_block->cf_node.node); set_foreach(block->predecessors, entry) { - nir_block *pred = (nir_block *) entry->key; + nir_block *pred = (nir_block *)entry->key; replace_successor(pred, block, new_block); } @@ -440,7 +439,7 @@ nir_loop_add_continue_construct(nir_loop *loop) nir_block *header = nir_loop_first_block(loop); nir_block *preheader = nir_block_cf_tree_prev(header); set_foreach(header->predecessors, entry) { - nir_block *pred = (nir_block *) entry->key; + nir_block *pred = (nir_block *)entry->key; if (pred != preheader) replace_successor(pred, header, cont); } @@ -457,7 +456,7 @@ nir_loop_remove_continue_construct(nir_loop *loop) nir_block *header = nir_loop_first_block(loop); nir_block *cont = nir_loop_first_continue_block(loop); set_foreach(cont->predecessors, entry) { - nir_block *pred = (nir_block*) entry->key; + nir_block *pred = (nir_block *)entry->key; replace_successor(pred, cont, header); } block_remove_pred(header, cont); @@ -611,8 +610,7 @@ stitch_blocks(nir_block *before, nir_block *after) exec_list_append(&before->instr_list, &after->instr_list); exec_node_remove(&after->cf_node.node); - return last_before_instr ? nir_after_instr(last_before_instr) : - nir_before_block(before); + return last_before_instr ? nir_after_instr(last_before_instr) : nir_before_block(before); } } diff --git a/src/compiler/nir/nir_control_flow.h b/src/compiler/nir/nir_control_flow.h index e31cd8e..74e083c 100644 --- a/src/compiler/nir/nir_control_flow.h +++ b/src/compiler/nir/nir_control_flow.h @@ -79,7 +79,6 @@ nir_cf_node_insert_end(struct exec_list *list, nir_cf_node *node) nir_cf_node_insert(nir_after_cf_list(list), node); } - /** Control flow motion. * * These functions let you take a part of a control flow list (basically diff --git a/src/compiler/nir/nir_control_flow_private.h b/src/compiler/nir/nir_control_flow_private.h index 31e6d3c..1d4fd33 100644 --- a/src/compiler/nir/nir_control_flow_private.h +++ b/src/compiler/nir/nir_control_flow_private.h @@ -30,7 +30,6 @@ #include "nir_control_flow.h" - /* Internal control-flow modification functions used when inserting/removing * instructions. */ diff --git a/src/compiler/nir/nir_conversion_builder.h b/src/compiler/nir/nir_conversion_builder.h index e926e8e..a96d65a 100644 --- a/src/compiler/nir/nir_conversion_builder.h +++ b/src/compiler/nir/nir_conversion_builder.h @@ -72,7 +72,7 @@ nir_round_float_to_float(nir_builder *b, nir_ssa_def *src, switch (round) { case nir_rounding_mode_ru: { /* If lower-precision conversion results in a lower value, push it - * up one ULP. */ + * up one ULP. */ nir_ssa_def *lower_prec = nir_build_alu(b, low_conv, src, NULL, NULL, NULL); nir_ssa_def *roundtrip = @@ -83,7 +83,7 @@ nir_round_float_to_float(nir_builder *b, nir_ssa_def *src, } case nir_rounding_mode_rd: { /* If lower-precision conversion results in a higher value, push it - * down one ULP. */ + * down one ULP. */ nir_ssa_def *lower_prec = nir_build_alu(b, low_conv, src, NULL, NULL, NULL); nir_ssa_def *roundtrip = @@ -94,10 +94,10 @@ nir_round_float_to_float(nir_builder *b, nir_ssa_def *src, } case nir_rounding_mode_rtz: return nir_bcsel(b, nir_flt_imm(b, src, 1), - nir_round_float_to_float(b, src, dest_bit_size, - nir_rounding_mode_ru), - nir_round_float_to_float(b, src, dest_bit_size, - nir_rounding_mode_rd)); + nir_round_float_to_float(b, src, dest_bit_size, + nir_rounding_mode_ru), + nir_round_float_to_float(b, src, dest_bit_size, + nir_rounding_mode_rd)); case nir_rounding_mode_rtne: case nir_rounding_mode_undef: break; @@ -125,7 +125,8 @@ nir_round_int_to_float(nir_builder *b, nir_ssa_def *src, case 64: mantissa_bits = 52; break; - default: unreachable("Unsupported bit size"); + default: + unreachable("Unsupported bit size"); } if (src->bit_size < mantissa_bits) @@ -142,7 +143,7 @@ nir_round_int_to_float(nir_builder *b, nir_ssa_def *src, switch (round) { case nir_rounding_mode_rtz: return nir_bcsel(b, sign, nir_ineg(b, positive_rounded), - positive_rounded); + positive_rounded); break; case nir_rounding_mode_ru: return nir_bcsel(b, sign, @@ -175,7 +176,7 @@ nir_round_int_to_float(nir_builder *b, nir_ssa_def *src, break; case nir_rounding_mode_ru: return nir_bcsel(b, nir_ieq(b, src, truncated), - src, nir_uadd_sat(b, truncated, adjust)); + src, nir_uadd_sat(b, truncated, adjust)); case nir_rounding_mode_rtne: case nir_rounding_mode_undef: break; @@ -266,8 +267,7 @@ nir_get_clamp_limits(nir_builder *b, break; } case nir_type_uint: { - uint64_t uhigh = dest_bit_size == 64 ? - ~0ull : (1ull << dest_bit_size) - 1; + uint64_t uhigh = dest_bit_size == 64 ? ~0ull : (1ull << dest_bit_size) - 1; if (src_base_type != nir_type_float) { *low = nir_imm_intN_t(b, 0, src_bit_size); if (src_base_type == nir_type_uint || src_bit_size > dest_bit_size) @@ -314,8 +314,7 @@ nir_get_clamp_limits(nir_builder *b, break; } case nir_type_uint: { - uint64_t src_uhigh = src_bit_size == 64 ? - ~0ull : (1ull << src_bit_size) - 1; + uint64_t src_uhigh = src_bit_size == 64 ? ~0ull : (1ull << src_bit_size) - 1; if (src_uhigh > fhigh) *high = nir_imm_intN_t(b, fhigh, src_bit_size); break; @@ -338,7 +337,7 @@ nir_get_clamp_limits(nir_builder *b, /** * Clamp the value into the widest representatble range of the * destination type with cmp + bcsel. - * + * * val/val_type: The variables used for bcsel * src/src_type: The variables used for comparison * dest_type: The type which determines the range used for comparison @@ -450,7 +449,7 @@ nir_convert_with_rounding(nir_builder *b, /* Try to simplify the conversion if we can */ clamp = clamp && - !nir_alu_type_range_contains_type_range(dest_type, src_type); + !nir_alu_type_range_contains_type_range(dest_type, src_type); round = nir_simplify_conversion_rounding(src_type, dest_type, round); /* For float -> int/uint conversions, we might not be able to represent @@ -458,8 +457,8 @@ nir_convert_with_rounding(nir_builder *b, * do the comparison in float range, but the bcsel in the destination range. */ bool clamp_after_conversion = clamp && - src_base_type == nir_type_float && - dest_base_type != nir_type_float; + src_base_type == nir_type_float && + dest_base_type != nir_type_float; /* * If we don't care about rounding and clamping, we can just use NIR's @@ -473,9 +472,9 @@ nir_convert_with_rounding(nir_builder *b, if (!clamp && round == nir_rounding_mode_undef) { trivial_convert = true; } else if (!clamp && src_type == nir_type_float32 && - dest_type == nir_type_float16 && - (round == nir_rounding_mode_rtne || - round == nir_rounding_mode_rtz)) { + dest_type == nir_type_float16 && + (round == nir_rounding_mode_rtne || + round == nir_rounding_mode_rtz)) { trivial_convert = true; } else { trivial_convert = false; diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c index 216c4f3..92933bb 100644 --- a/src/compiler/nir/nir_deref.c +++ b/src/compiler/nir/nir_deref.c @@ -21,10 +21,10 @@ * IN THE SOFTWARE. */ -#include "nir.h" -#include "nir_builder.h" #include "nir_deref.h" #include "util/hash_table.h" +#include "nir.h" +#include "nir_builder.h" static bool is_trivial_deref_cast(nir_deref_instr *cast) @@ -144,8 +144,8 @@ nir_deref_instr_is_known_out_of_bounds(nir_deref_instr *instr) for (; instr; instr = nir_deref_instr_parent(instr)) { if (instr->deref_type == nir_deref_type_array && nir_src_is_const(instr->arr.index) && - nir_src_as_uint(instr->arr.index) >= - glsl_get_length(nir_deref_instr_parent(instr)->type)) + nir_src_as_uint(instr->arr.index) >= + glsl_get_length(nir_deref_instr_parent(instr)->type)) return true; } @@ -318,13 +318,13 @@ nir_deref_instr_get_const_offset(nir_deref_instr *deref, case nir_deref_type_array: offset += nir_src_as_uint((*p)->arr.index) * type_get_array_stride((*p)->type, size_align); - break; + break; case nir_deref_type_struct: { /* p starts at path[1], so this is safe */ nir_deref_instr *parent = *(p - 1); offset += struct_type_get_field_offset(parent->type, size_align, (*p)->strct.index); - break; + break; } case nir_deref_type_cast: /* A cast doesn't contribute to the offset */ @@ -393,7 +393,7 @@ nir_remove_dead_derefs_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -452,9 +452,10 @@ nir_fixup_deref_modes(nir_shader *shader) { nir_shader_instructions_pass(shader, nir_fixup_deref_modes_instr, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs | - nir_metadata_instr_index, NULL); + nir_metadata_dominance | + nir_metadata_live_ssa_defs | + nir_metadata_instr_index, + NULL); } static bool @@ -717,7 +718,8 @@ nir_compare_derefs(nir_deref_instr *a, nir_deref_instr *b) return result; } -nir_deref_path *nir_get_deref_path(void *mem_ctx, nir_deref_and_path *deref) +nir_deref_path * +nir_get_deref_path(void *mem_ctx, nir_deref_and_path *deref) { if (!deref->_path) { deref->_path = ralloc(mem_ctx, nir_deref_path); @@ -726,9 +728,10 @@ nir_deref_path *nir_get_deref_path(void *mem_ctx, nir_deref_and_path *deref) return deref->_path; } -nir_deref_compare_result nir_compare_derefs_and_paths(void *mem_ctx, - nir_deref_and_path *a, - nir_deref_and_path *b) +nir_deref_compare_result +nir_compare_derefs_and_paths(void *mem_ctx, + nir_deref_and_path *a, + nir_deref_and_path *b) { if (a->instr == b->instr) /* nir_compare_derefs has a fast path if a == b */ return nir_compare_derefs(a->instr, b->instr); @@ -1196,7 +1199,6 @@ opt_deref_cast(nir_builder *b, nir_deref_instr *cast) bool trivial_array_cast = is_trivial_array_deref_cast(cast); - nir_foreach_use_including_if_safe(use_src, &cast->dest.ssa) { assert(!use_src->is_if && "there cannot be if-uses"); @@ -1250,11 +1252,10 @@ opt_deref_ptr_as_array(nir_builder *b, nir_deref_instr *deref) parent->deref_type != nir_deref_type_ptr_as_array) return false; - deref->arr.in_bounds &= parent->arr.in_bounds; nir_ssa_def *new_idx = nir_iadd(b, parent->arr.index.ssa, - deref->arr.index.ssa); + deref->arr.index.ssa); deref->deref_type = parent->deref_type; nir_instr_rewrite_src(&deref->instr, &deref->parent, parent->parent); @@ -1316,7 +1317,9 @@ resize_vector(nir_builder *b, nir_ssa_def *data, unsigned num_components) if (num_components == data->num_components) return data; - unsigned swiz[NIR_MAX_VEC_COMPONENTS] = { 0, }; + unsigned swiz[NIR_MAX_VEC_COMPONENTS] = { + 0, + }; for (unsigned i = 0; i < MIN2(num_components, data->num_components); i++) swiz[i] = i; @@ -1505,7 +1508,7 @@ nir_opt_deref_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_deref.h b/src/compiler/nir/nir_deref.h index a7ada23..087146f 100644 --- a/src/compiler/nir/nir_deref.h +++ b/src/compiler/nir/nir_deref.h @@ -62,9 +62,9 @@ nir_ssa_def *nir_build_deref_offset(nir_builder *b, nir_deref_instr *deref, nir_deref_path *nir_get_deref_path(void *mem_ctx, nir_deref_and_path *deref); typedef enum { - nir_derefs_do_not_alias = 0, - nir_derefs_equal_bit = (1 << 0), - nir_derefs_may_alias_bit = (1 << 1), + nir_derefs_do_not_alias = 0, + nir_derefs_equal_bit = (1 << 0), + nir_derefs_may_alias_bit = (1 << 1), nir_derefs_a_contains_b_bit = (1 << 2), nir_derefs_b_contains_a_bit = (1 << 3), } nir_deref_compare_result; diff --git a/src/compiler/nir/nir_divergence_analysis.c b/src/compiler/nir/nir_divergence_analysis.c index 9c0f2d2..871aa30 100644 --- a/src/compiler/nir/nir_divergence_analysis.c +++ b/src/compiler/nir/nir_divergence_analysis.c @@ -669,7 +669,8 @@ visit_ssa_undef(nir_ssa_undef_instr *instr) } static bool -nir_variable_mode_is_uniform(nir_variable_mode mode) { +nir_variable_mode_is_uniform(nir_variable_mode mode) +{ switch (mode) { case nir_var_uniform: case nir_var_mem_ubo: @@ -869,7 +870,7 @@ visit_loop_header_phi(nir_phi_instr *phi, nir_block *preheader, bool divergent_c if (phi->dest.ssa.divergent) return false; - nir_ssa_def* same = NULL; + nir_ssa_def *same = NULL; nir_foreach_phi_src(src, phi) { /* if any source value is divergent, the resulting value is divergent */ if (src->src.ssa->divergent) { @@ -1058,7 +1059,8 @@ nir_divergence_analysis(nir_shader *shader) visit_cf_list(&nir_shader_get_entrypoint(shader)->body, &state); } -bool nir_update_instr_divergence(nir_shader *shader, nir_instr *instr) +bool +nir_update_instr_divergence(nir_shader *shader, nir_instr *instr) { nir_foreach_ssa_def(instr, set_ssa_def_not_divergent, NULL); @@ -1078,7 +1080,6 @@ bool nir_update_instr_divergence(nir_shader *shader, nir_instr *instr) return true; } - bool nir_has_divergent_loop(nir_shader *shader) { diff --git a/src/compiler/nir/nir_dominance.c b/src/compiler/nir/nir_dominance.c index 0433d4a..14d3e15 100644 --- a/src/compiler/nir/nir_dominance.c +++ b/src/compiler/nir/nir_dominance.c @@ -74,7 +74,7 @@ calc_dominance(nir_block *block) { nir_block *new_idom = NULL; set_foreach(block->predecessors, entry) { - nir_block *pred = (nir_block *) entry->key; + nir_block *pred = (nir_block *)entry->key; if (pred->imm_dom) { if (new_idom) @@ -97,7 +97,7 @@ calc_dom_frontier(nir_block *block) { if (block->predecessors->entries > 1) { set_foreach(block->predecessors, entry) { - nir_block *runner = (nir_block *) entry->key; + nir_block *runner = (nir_block *)entry->key; /* Skip unreachable predecessors */ if (runner->imm_dom == NULL) @@ -125,7 +125,7 @@ calc_dom_frontier(nir_block *block) */ static void -calc_dom_children(nir_function_impl* impl) +calc_dom_children(nir_function_impl *impl) { void *mem_ctx = ralloc_parent(impl); @@ -142,8 +142,7 @@ calc_dom_children(nir_function_impl* impl) nir_foreach_block_unstructured(block, impl) { if (block->imm_dom) { - block->imm_dom->dom_children[block->imm_dom->num_dom_children++] - = block; + block->imm_dom->dom_children[block->imm_dom->num_dom_children++] = block; } } } @@ -170,7 +169,6 @@ nir_calc_dominance_impl(nir_function_impl *impl) nir_metadata_require(impl, nir_metadata_block_index); - nir_foreach_block_unstructured(block, impl) { init_block(block, impl); } @@ -303,7 +301,7 @@ nir_dump_dom_frontier_impl(nir_function_impl *impl, FILE *fp) nir_foreach_block_unstructured(block, impl) { fprintf(fp, "DF(%u) = {", block->index); set_foreach(block->dom_frontier, entry) { - nir_block *df = (nir_block *) entry->key; + nir_block *df = (nir_block *)entry->key; fprintf(fp, "%u, ", df->index); } fprintf(fp, "}\n"); diff --git a/src/compiler/nir/nir_format_convert.h b/src/compiler/nir/nir_format_convert.h index 4ac95df..9b11e9b 100644 --- a/src/compiler/nir/nir_format_convert.h +++ b/src/compiler/nir/nir_format_convert.h @@ -79,15 +79,12 @@ nir_format_sign_extend_ivec(nir_builder *b, nir_ssa_def *src, nir_ssa_def *comps[4]; for (unsigned i = 0; i < src->num_components; i++) { unsigned shift = src->bit_size - bits[i]; - comps[i] = nir_ishr_imm(b, nir_ishl_imm(b, - nir_channel(b, src, i), - shift), - shift); + comps[i] = nir_ishr_imm(b, nir_ishl_imm(b, nir_channel(b, src, i), shift), + shift); } return nir_vec(b, comps, src->num_components); } - static inline nir_ssa_def * nir_format_unpack_int(nir_builder *b, nir_ssa_def *packed, const unsigned *bits, unsigned num_components, @@ -147,8 +144,7 @@ nir_format_pack_uint_unmasked(nir_builder *b, nir_ssa_def *color, nir_ssa_def *packed = nir_imm_int(b, 0); unsigned offset = 0; for (unsigned i = 0; i < num_components; i++) { - packed = nir_ior(b, packed, nir_shift_imm(b, nir_channel(b, color, i), - offset)); + packed = nir_ior(b, packed, nir_shift_imm(b, nir_channel(b, color, i), offset)); offset += bits[i]; } assert(offset <= packed->bit_size); @@ -192,13 +188,13 @@ nir_format_bitcast_uvec_unmasked(nir_builder *b, nir_ssa_def *src, DIV_ROUND_UP(src->num_components * src_bits, dst_bits); assert(dst_components <= 4); - nir_ssa_def *dst_chan[4] = {0}; + nir_ssa_def *dst_chan[4] = { 0 }; if (dst_bits > src_bits) { unsigned shift = 0; unsigned dst_idx = 0; for (unsigned i = 0; i < src->num_components; i++) { nir_ssa_def *shifted = nir_ishl_imm(b, nir_channel(b, src, i), - shift); + shift); if (shift == 0) { dst_chan[dst_idx] = shifted; } else { @@ -263,7 +259,7 @@ nir_format_snorm_to_float(nir_builder *b, nir_ssa_def *s, const unsigned *bits) _nir_format_norm_factor(b, bits, s->num_components, true); return nir_fmax(b, nir_fdiv(b, nir_i2f32(b, s), factor), - nir_imm_float(b, -1.0f)); + nir_imm_float(b, -1.0f)); } static inline nir_ssa_def * @@ -308,12 +304,11 @@ nir_format_linear_to_srgb(nir_builder *b, nir_ssa_def *c) { nir_ssa_def *linear = nir_fmul_imm(b, c, 12.92f); nir_ssa_def *curved = - nir_fadd_imm(b, nir_fmul_imm(b, nir_fpow(b, c, nir_imm_float(b, 1.0 / 2.4)), - 1.055f), - -0.055f); + nir_fadd_imm(b, nir_fmul_imm(b, nir_fpow(b, c, nir_imm_float(b, 1.0 / 2.4)), 1.055f), + -0.055f); return nir_fsat(b, nir_bcsel(b, nir_flt_imm(b, c, 0.0031308f), - linear, curved)); + linear, curved)); } static inline nir_ssa_def * @@ -321,12 +316,11 @@ nir_format_srgb_to_linear(nir_builder *b, nir_ssa_def *c) { nir_ssa_def *linear = nir_fdiv_imm(b, c, 12.92f); nir_ssa_def *curved = - nir_fpow(b, nir_fmul_imm(b, nir_fadd_imm(b, c, 0.055f), - 1.0 / 1.055f), - nir_imm_float(b, 2.4f)); + nir_fpow(b, nir_fmul_imm(b, nir_fadd_imm(b, c, 0.055f), 1.0 / 1.055f), + nir_imm_float(b, 2.4f)); return nir_fsat(b, nir_bcsel(b, nir_fle_imm(b, c, 0.04045f), - linear, curved)); + linear, curved)); } /* Clamps a vector of uints so they don't extend beyond the given number of @@ -392,9 +386,9 @@ nir_format_pack_11f11f10f(nir_builder *b, nir_ssa_def *color) nir_ssa_def *undef = nir_ssa_undef(b, 1, color->bit_size); nir_ssa_def *p1 = nir_pack_half_2x16_split(b, nir_channel(b, clamped, 0), - nir_channel(b, clamped, 1)); + nir_channel(b, clamped, 1)); nir_ssa_def *p2 = nir_pack_half_2x16_split(b, nir_channel(b, clamped, 2), - undef); + undef); /* A 10 or 11-bit float has the same exponent as a 16-bit float but with * fewer mantissa bits and no sign bit. All we have to do is throw away @@ -418,12 +412,12 @@ nir_format_pack_r9g9b9e5(nir_builder *b, nir_ssa_def *color) /* Get rid of negatives and NaN */ clamped = nir_bcsel(b, nir_ugt_imm(b, color, 0x7f800000), - nir_imm_float(b, 0), clamped); + nir_imm_float(b, 0), clamped); /* maxrgb.u = MAX3(rc.u, gc.u, bc.u); */ nir_ssa_def *maxu = nir_umax(b, nir_channel(b, clamped, 0), - nir_umax(b, nir_channel(b, clamped, 1), - nir_channel(b, clamped, 2))); + nir_umax(b, nir_channel(b, clamped, 1), + nir_channel(b, clamped, 2))); /* maxrgb.u += maxrgb.u & (1 << (23-9)); */ maxu = nir_iadd(b, maxu, nir_iand_imm(b, maxu, 1 << 14)); @@ -432,17 +426,15 @@ nir_format_pack_r9g9b9e5(nir_builder *b, nir_ssa_def *color) * 1 + RGB9E5_EXP_BIAS - 127; */ nir_ssa_def *exp_shared = - nir_iadd_imm(b, nir_umax(b, nir_ushr_imm(b, maxu, 23), - nir_imm_int(b, -RGB9E5_EXP_BIAS - 1 + 127)), - 1 + RGB9E5_EXP_BIAS - 127); + nir_iadd_imm(b, nir_umax(b, nir_ushr_imm(b, maxu, 23), nir_imm_int(b, -RGB9E5_EXP_BIAS - 1 + 127)), + 1 + RGB9E5_EXP_BIAS - 127); /* revdenom_biasedexp = 127 - (exp_shared - RGB9E5_EXP_BIAS - * RGB9E5_MANTISSA_BITS) + 1; */ nir_ssa_def *revdenom_biasedexp = - nir_isub_imm(b, 127 + RGB9E5_EXP_BIAS + - RGB9E5_MANTISSA_BITS + 1, - exp_shared); + nir_isub_imm(b, 127 + RGB9E5_EXP_BIAS + RGB9E5_MANTISSA_BITS + 1, + exp_shared); /* revdenom.u = revdenom_biasedexp << 23; */ nir_ssa_def *revdenom = @@ -460,7 +452,7 @@ nir_format_pack_r9g9b9e5(nir_builder *b, nir_ssa_def *color) * bm = (bm & 1) + (bm >> 1); */ mantissa = nir_iadd(b, nir_iand_imm(b, mantissa, 1), - nir_ushr_imm(b, mantissa, 1)); + nir_ushr_imm(b, mantissa, 1)); nir_ssa_def *packed = nir_channel(b, mantissa, 0); packed = nir_mask_shift_or(b, packed, nir_channel(b, mantissa, 1), ~0, 9); diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c index 8e76d4d..1012d79 100644 --- a/src/compiler/nir/nir_from_ssa.c +++ b/src/compiler/nir/nir_from_ssa.c @@ -82,7 +82,8 @@ ssa_def_dominates(nir_ssa_def *a, nir_ssa_def *b) if (a->parent_instr->type == nir_instr_type_ssa_undef) { /* SSA undefs always dominate */ return true; - } if (def_after(a, b)) { + } + if (def_after(a, b)) { return false; } else if (a->parent_instr->block == b->parent_instr->block) { return def_after(b, a); @@ -92,7 +93,6 @@ ssa_def_dominates(nir_ssa_def *a, nir_ssa_def *b) } } - /* The following data structure, which I have named merge_set is a way of * representing a set registers of non-interfering registers. This is * based on the concept of a "dominance forest" presented in "Fast Copy @@ -453,7 +453,7 @@ coalesce_phi_nodes_block(nir_block *block, struct from_ssa_state *state) static void aggressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy, - struct from_ssa_state *state) + struct from_ssa_state *state) { nir_foreach_parallel_copy_entry(entry, pcopy) { assert(!entry->src_is_reg); @@ -551,15 +551,15 @@ nir_rewrite_uses_to_load_reg(nir_builder *b, nir_ssa_def *old, */ nir_ssa_def *load = NULL; if (b->cursor.option == nir_cursor_before_instr) { - nir_instr *prev = nir_instr_prev(b->cursor.instr); - - if (prev != NULL && prev->type == nir_instr_type_intrinsic) { - nir_intrinsic_instr *intr = nir_instr_as_intrinsic(prev); - if (intr->intrinsic == nir_intrinsic_load_reg && - intr->src[0].ssa == reg && - nir_intrinsic_base(intr) == 0) - load = &intr->dest.ssa; - } + nir_instr *prev = nir_instr_prev(b->cursor.instr); + + if (prev != NULL && prev->type == nir_instr_type_intrinsic) { + nir_intrinsic_instr *intr = nir_instr_as_intrinsic(prev); + if (intr->intrinsic == nir_intrinsic_load_reg && + intr->src[0].ssa == reg && + nir_intrinsic_base(intr) == 0) + load = &intr->dest.ssa; + } } if (load == NULL) @@ -968,7 +968,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy, } set_reg_divergent(reg, copy_value_is_divergent(values[b])); - values[num_vals] = (struct copy_value) { + values[num_vals] = (struct copy_value){ .is_reg = true, .ssa = reg, }; @@ -1034,12 +1034,11 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, /* Mark metadata as dirty before we ask for liveness analysis */ nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); nir_metadata_require(impl, nir_metadata_instr_index | - nir_metadata_live_ssa_defs | - nir_metadata_dominance); - + nir_metadata_live_ssa_defs | + nir_metadata_dominance); nir_foreach_block(block, impl) { coalesce_phi_nodes_block(block, &state); @@ -1056,7 +1055,7 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); /* Clean up dead instructions and the hash tables */ nir_instr_free_list(&state.dead_instrs); @@ -1078,13 +1077,12 @@ nir_convert_from_ssa(nir_shader *shader, return progress; } - static void place_phi_read(nir_builder *b, nir_ssa_def *reg, nir_ssa_def *def, nir_block *block, struct set *visited_blocks) { - /* Search already visited blocks to avoid back edges in tree */ - if (_mesa_set_search(visited_blocks, block) == NULL) { + /* Search already visited blocks to avoid back edges in tree */ + if (_mesa_set_search(visited_blocks, block) == NULL) { /* Try to go up the single-successor tree */ bool all_single_successors = true; set_foreach(block->predecessors, entry) { diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index 3edbc06..e302d7a 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -21,9 +21,9 @@ * IN THE SOFTWARE. */ +#include "main/menums.h" #include "nir.h" #include "nir_deref.h" -#include "main/menums.h" #include "util/set.h" @@ -33,7 +33,7 @@ src_is_invocation_id(const nir_src *src) nir_ssa_scalar s = nir_ssa_scalar_resolved(src->ssa, 0); return s.def->parent_instr->type == nir_instr_type_intrinsic && nir_instr_as_intrinsic(s.def->parent_instr)->intrinsic == - nir_intrinsic_load_invocation_id; + nir_intrinsic_load_invocation_id; } static bool @@ -42,7 +42,7 @@ src_is_local_invocation_index(const nir_src *src) nir_ssa_scalar s = nir_ssa_scalar_resolved(src->ssa, 0); return s.def->parent_instr->type == nir_instr_type_intrinsic && nir_instr_as_intrinsic(s.def->parent_instr)->intrinsic == - nir_intrinsic_load_local_invocation_index; + nir_intrinsic_load_local_invocation_index; } static void @@ -109,8 +109,7 @@ set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len, return; bitfield = BITFIELD64_BIT(idx - VARYING_SLOT_PATCH0); - } - else { + } else { /* Varyings might still have temp locations so abort */ if (idx >= VARYING_SLOT_MAX) return; @@ -222,9 +221,7 @@ get_io_offset(nir_deref_instr *deref, nir_variable *var, bool is_arrayed, return 0; } assert(deref->deref_type == nir_deref_type_array); - return nir_src_is_const(deref->arr.index) ? - (nir_src_as_uint(deref->arr.index) + var->data.location_frac) / 4u : - (unsigned)-1; + return nir_src_is_const(deref->arr.index) ? (nir_src_as_uint(deref->arr.index) + var->data.location_frac) / 4u : (unsigned)-1; } unsigned offset = 0; @@ -452,10 +449,10 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, case nir_intrinsic_interp_deref_at_vertex: case nir_intrinsic_load_deref: case nir_intrinsic_store_deref: - case nir_intrinsic_copy_deref:{ + case nir_intrinsic_copy_deref: { nir_deref_instr *deref = nir_src_as_deref(instr->src[0]); if (nir_deref_mode_is_one_of(deref, nir_var_shader_in | - nir_var_shader_out)) { + nir_var_shader_out)) { nir_variable *var = nir_deref_instr_get_variable(deref); bool is_output_read = false; if (var->data.mode == nir_var_shader_out && @@ -582,8 +579,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, case nir_intrinsic_load_color0: case nir_intrinsic_load_color1: shader->info.inputs_read |= - BITFIELD64_BIT(VARYING_SLOT_COL0 << - (instr->intrinsic == nir_intrinsic_load_color1)); + BITFIELD64_BIT(VARYING_SLOT_COL0 << (instr->intrinsic == nir_intrinsic_load_color1)); FALLTHROUGH; case nir_intrinsic_load_subgroup_size: case nir_intrinsic_load_subgroup_invocation: diff --git a/src/compiler/nir/nir_gather_ssa_types.c b/src/compiler/nir/nir_gather_ssa_types.c index fcfac1e..f5e9550 100644 --- a/src/compiler/nir/nir_gather_ssa_types.c +++ b/src/compiler/nir/nir_gather_ssa_types.c @@ -21,8 +21,8 @@ * IN THE SOFTWARE. */ -#include "nir.h" #include "util/bitset.h" +#include "nir.h" static void set_type(unsigned idx, nir_alu_type type, BITSET_WORD *float_types, diff --git a/src/compiler/nir/nir_gather_xfb_info.c b/src/compiler/nir/nir_gather_xfb_info.c index dad009e..bf6ba7c 100644 --- a/src/compiler/nir/nir_gather_xfb_info.c +++ b/src/compiler/nir/nir_gather_xfb_info.c @@ -44,7 +44,6 @@ add_var_xfb_varying(nir_xfb_info *xfb, xfb->buffers[buffer].varying_count++; } - static nir_xfb_info * nir_xfb_info_create(void *mem_ctx, uint16_t output_count) { @@ -231,8 +230,8 @@ nir_gather_xfb_info_with_varyings(nir_shader *shader, * that contains an array. */ bool is_array_block = var->interface_type != NULL && - glsl_type_is_array(var->type) && - glsl_without_array(var->type) == var->interface_type; + glsl_type_is_array(var->type) && + glsl_without_array(var->type) == var->interface_type; if (var->data.explicit_offset && !is_array_block) { unsigned offset = var->data.offset; @@ -275,7 +274,7 @@ nir_gather_xfb_info_with_varyings(nir_shader *shader, #ifndef NDEBUG /* Finally, do a sanity check */ - unsigned max_offset[NIR_MAX_XFB_BUFFERS] = {0}; + unsigned max_offset[NIR_MAX_XFB_BUFFERS] = { 0 }; for (unsigned i = 0; i < xfb->output_count; i++) { assert(xfb->outputs[i].offset >= max_offset[xfb->outputs[i].buffer]); assert(xfb->outputs[i].component_mask != 0); @@ -318,12 +317,12 @@ void nir_gather_xfb_info_from_intrinsics(nir_shader *nir) { nir_function_impl *impl = nir_shader_get_entrypoint(nir); - uint8_t buffer_to_stream[MAX_XFB_BUFFERS] = {0}; + uint8_t buffer_to_stream[MAX_XFB_BUFFERS] = { 0 }; uint8_t buffer_mask = 0; uint8_t stream_mask = 0; /* Gather xfb outputs. */ - struct util_dynarray array = {0}; + struct util_dynarray array = { 0 }; nir_foreach_block(block, impl) { nir_foreach_instr(instr, block) { @@ -338,8 +337,7 @@ nir_gather_xfb_info_from_intrinsics(nir_shader *nir) while (wr_mask) { unsigned i = u_bit_scan(&wr_mask); unsigned index = nir_intrinsic_component(intr) + i; - nir_io_xfb xfb = index < 2 ? nir_intrinsic_io_xfb(intr) : - nir_intrinsic_io_xfb2(intr); + nir_io_xfb xfb = index < 2 ? nir_intrinsic_io_xfb(intr) : nir_intrinsic_io_xfb2(intr); if (xfb.out[index % 2].num_components) { nir_io_semantics sem = nir_intrinsic_io_semantics(intr); @@ -388,10 +386,11 @@ nir_gather_xfb_info_from_intrinsics(nir_shader *nir) j < count && cur->buffer == outputs[j].buffer && cur->location == outputs[j].location && - cur->high_16bits == outputs[j].high_16bits; j++) { + cur->high_16bits == outputs[j].high_16bits; + j++) { if (outputs[j].component_mask && outputs[j].offset - outputs[j].component_offset * 4 == - cur->offset - cur->component_offset * 4) { + cur->offset - cur->component_offset * 4) { unsigned merged_offset = MIN2(cur->component_offset, outputs[j].component_offset); /* component_mask is relative to 0, not component_offset */ diff --git a/src/compiler/nir/nir_group_loads.c b/src/compiler/nir/nir_group_loads.c index e588f38..96f5af3 100644 --- a/src/compiler/nir/nir_group_loads.c +++ b/src/compiler/nir/nir_group_loads.c @@ -164,8 +164,7 @@ get_uniform_inst_resource(nir_instr *instr) return NULL; } -struct check_sources_state -{ +struct check_sources_state { nir_block *block; uint32_t first_index; }; @@ -273,7 +272,7 @@ set_instr_indices(nir_block *block) * instructions. */ if (last && is_pseudo_inst(last) && is_grouped_load(instr)) - counter++; + counter++; /* Set each instruction's index within the block. */ instr->index = counter; @@ -307,7 +306,6 @@ is_barrier(nir_instr *instr) nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); const char *name = nir_intrinsic_infos[intr->intrinsic].name; - if (intr->intrinsic == nir_intrinsic_discard || intr->intrinsic == nir_intrinsic_discard_if || intr->intrinsic == nir_intrinsic_terminate || @@ -320,8 +318,7 @@ is_barrier(nir_instr *instr) return false; } -struct indirection_state -{ +struct indirection_state { nir_block *block; unsigned indirections; }; @@ -376,7 +373,7 @@ process_block(nir_block *block, nir_load_grouping grouping, unsigned max_distance) { int max_indirection = -1; - unsigned num_inst_per_level[256] = {0}; + unsigned num_inst_per_level[256] = { 0 }; /* UINT32_MAX means the instruction has not been visited. Once * an instruction has been visited and its indirection level has been @@ -481,7 +478,7 @@ nir_group_loads(nir_shader *shader, nir_load_grouping grouping, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_loop_analysis); + nir_metadata_dominance | + nir_metadata_loop_analysis); } } diff --git a/src/compiler/nir/nir_gs_count_vertices.c b/src/compiler/nir/nir_gs_count_vertices.c index 98490e1..db2aa98 100644 --- a/src/compiler/nir/nir_gs_count_vertices.c +++ b/src/compiler/nir/nir_gs_count_vertices.c @@ -60,16 +60,16 @@ nir_gs_count_vertices_and_primitives(const nir_shader *shader, { assert(num_streams); - int vtxcnt_arr[4] = {-1, -1, -1, -1}; - int prmcnt_arr[4] = {-1, -1, -1, -1}; - bool cnt_found[4] = {false, false, false, false}; + int vtxcnt_arr[4] = { -1, -1, -1, -1 }; + int prmcnt_arr[4] = { -1, -1, -1, -1 }; + bool cnt_found[4] = { false, false, false, false }; nir_foreach_function_impl(impl, shader) { /* set_vertex_and_primitive_count intrinsics only appear in predecessors of the * end block. So we don't need to walk all of them. */ set_foreach(impl->end_block->predecessors, entry) { - nir_block *block = (nir_block *) entry->key; + nir_block *block = (nir_block *)entry->key; nir_foreach_instr_reverse(instr, block) { nir_intrinsic_instr *intrin = as_set_vertex_and_primitive_count(instr); diff --git a/src/compiler/nir/nir_inline_functions.c b/src/compiler/nir/nir_inline_functions.c index 0fe2263..5286166 100644 --- a/src/compiler/nir/nir_inline_functions.c +++ b/src/compiler/nir/nir_inline_functions.c @@ -26,16 +26,18 @@ #include "nir_control_flow.h" #include "nir_vla.h" -static bool function_ends_in_jump(nir_function_impl *impl) +static bool +function_ends_in_jump(nir_function_impl *impl) { nir_block *last_block = nir_impl_last_block(impl); return nir_block_ends_in_jump(last_block); } -void nir_inline_function_impl(struct nir_builder *b, - const nir_function_impl *impl, - nir_ssa_def **params, - struct hash_table *shader_var_remap) +void +nir_inline_function_impl(struct nir_builder *b, + const nir_function_impl *impl, + nir_ssa_def **params, + struct hash_table *shader_var_remap) { nir_function_impl *copy = nir_function_impl_clone(b->shader, impl); diff --git a/src/compiler/nir/nir_inline_uniforms.c b/src/compiler/nir/nir_inline_uniforms.c index ef1e4a0..c20537c 100644 --- a/src/compiler/nir/nir_inline_uniforms.c +++ b/src/compiler/nir/nir_inline_uniforms.c @@ -110,7 +110,7 @@ nir_collect_src_uniforms(const nir_src *src, int component, if (!nir_collect_src_uniforms(&alu_src->src, alu_src->swizzle[j], uni_offsets, num_offsets, max_num_bo, max_offset)) - return false; + return false; } } } @@ -228,7 +228,7 @@ nir_add_inlinable_uniforms(const nir_src *cond, nir_loop_info *info, /* Allow induction variable which means a loop terminator. */ if (info) { - nir_ssa_scalar cond_scalar = {cond->ssa, 0}; + nir_ssa_scalar cond_scalar = { cond->ssa, 0 }; /* Limit terminator condition to loop unroll support case which is a simple * comparison (ie. "i < count" is supported, but "i + 1 < count" is not). @@ -419,7 +419,7 @@ nir_inline_uniforms(nir_shader *shader, unsigned num_uniforms, * found component load with constant load. */ uint32_t max_offset = offset + num_components; - nir_ssa_def *components[NIR_MAX_VEC_COMPONENTS] = {0}; + nir_ssa_def *components[NIR_MAX_VEC_COMPONENTS] = { 0 }; bool found = false; b.cursor = nir_before_instr(&intr->instr); @@ -461,7 +461,7 @@ nir_inline_uniforms(nir_shader *shader, unsigned num_uniforms, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } } } diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index 5d2d106..cad4a59 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -22,8 +22,8 @@ */ #include "nir_instr_set.h" -#include "nir_vla.h" #include "util/half_float.h" +#include "nir_vla.h" /* This function determines if uses of an instruction can safely be rewritten * to use another identical instruction instead. Note that this function must @@ -55,7 +55,6 @@ instr_can_rewrite(const nir_instr *instr) return false; } - #define HASH(hash, data) XXH32(&(data), sizeof(data), hash) static uint32_t @@ -312,7 +311,8 @@ get_neg_instr(nir_src s) nir_alu_instr *alu = nir_src_as_alu_instr(s); return alu != NULL && (alu->op == nir_op_fneg || alu->op == nir_op_ineg) - ? alu : NULL; + ? alu + : NULL; } bool @@ -428,7 +428,7 @@ nir_alu_srcs_negative_equal(const nir_alu_instr *alu1, return true; } - uint8_t alu1_swizzle[NIR_MAX_VEC_COMPONENTS] = {0}; + uint8_t alu1_swizzle[NIR_MAX_VEC_COMPONENTS] = { 0 }; nir_src alu1_actual_src; nir_alu_instr *neg1 = get_neg_instr(alu1->src[src1].src); @@ -445,7 +445,7 @@ nir_alu_srcs_negative_equal(const nir_alu_instr *alu1, alu1_swizzle[i] = i; } - uint8_t alu2_swizzle[NIR_MAX_VEC_COMPONENTS] = {0}; + uint8_t alu2_swizzle[NIR_MAX_VEC_COMPONENTS] = { 0 }; nir_src alu2_actual_src; nir_alu_instr *neg2 = get_neg_instr(alu2->src[src2].src); @@ -609,9 +609,9 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2) tex1->is_shadow != tex2->is_shadow || tex1->is_new_style_shadow != tex2->is_new_style_shadow || tex1->component != tex2->component || - tex1->texture_index != tex2->texture_index || - tex1->sampler_index != tex2->sampler_index || - tex1->backend_flags != tex2->backend_flags) { + tex1->texture_index != tex2->texture_index || + tex1->sampler_index != tex2->sampler_index || + tex1->backend_flags != tex2->backend_flags) { return false; } @@ -682,11 +682,11 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2) return false; if (info->has_dest && intrinsic1->dest.ssa.num_components != - intrinsic2->dest.ssa.num_components) + intrinsic2->dest.ssa.num_components) return false; if (info->has_dest && intrinsic1->dest.ssa.bit_size != - intrinsic2->dest.ssa.bit_size) + intrinsic2->dest.ssa.bit_size) return false; for (unsigned i = 0; i < info->num_srcs; i++) { @@ -753,14 +753,14 @@ nir_instr_set_destroy(struct set *instr_set) bool nir_instr_set_add_or_rewrite(struct set *instr_set, nir_instr *instr, - bool (*cond_function) (const nir_instr *a, - const nir_instr *b)) + bool (*cond_function)(const nir_instr *a, + const nir_instr *b)) { if (!instr_can_rewrite(instr)) return false; struct set_entry *e = _mesa_set_search_or_add(instr_set, instr, NULL); - nir_instr *match = (nir_instr *) e->key; + nir_instr *match = (nir_instr *)e->key; if (match == instr) return false; @@ -799,4 +799,3 @@ nir_instr_set_remove(struct set *instr_set, nir_instr *instr) if (entry) _mesa_set_remove(instr_set, entry); } - diff --git a/src/compiler/nir/nir_legacy.c b/src/compiler/nir/nir_legacy.c index a646408..650cf27 100644 --- a/src/compiler/nir/nir_legacy.c +++ b/src/compiler/nir/nir_legacy.c @@ -4,9 +4,9 @@ * SPDX-License-Identifier: MIT */ +#include "nir_legacy.h" #include "nir.h" #include "nir_builder.h" -#include "nir_legacy.h" bool nir_legacy_float_mod_folds(nir_alu_instr *mod) @@ -47,18 +47,17 @@ chase_alu_src_helper(const nir_src *src) if (load) { bool indirect = (load->intrinsic == nir_intrinsic_load_reg_indirect); - return (nir_legacy_alu_src) { + return (nir_legacy_alu_src){ .src.is_ssa = false, .src.reg = { .handle = load->src[0].ssa, .base_offset = nir_intrinsic_base(load), - .indirect = indirect ? load->src[1].ssa : NULL - }, + .indirect = indirect ? load->src[1].ssa : NULL }, .fabs = nir_intrinsic_legacy_fabs(load), .fneg = nir_intrinsic_legacy_fneg(load), }; } else { - return (nir_legacy_alu_src) { + return (nir_legacy_alu_src){ .src.is_ssa = true, .src.ssa = src->ssa, }; @@ -130,18 +129,17 @@ chase_alu_dest_helper(nir_dest *dest) if (store) { bool indirect = (store->intrinsic == nir_intrinsic_store_reg_indirect); - return (nir_legacy_alu_dest) { + return (nir_legacy_alu_dest){ .dest.is_ssa = false, .dest.reg = { .handle = store->src[1].ssa, .base_offset = nir_intrinsic_base(store), - .indirect = indirect ? store->src[2].ssa : NULL - }, + .indirect = indirect ? store->src[2].ssa : NULL }, .fsat = nir_intrinsic_legacy_fsat(store), .write_mask = nir_intrinsic_write_mask(store), }; } else { - return (nir_legacy_alu_dest) { + return (nir_legacy_alu_dest){ .dest.is_ssa = true, .dest.ssa = &dest->ssa, .write_mask = nir_component_mask(dest->ssa.num_components), @@ -226,7 +224,7 @@ nir_legacy_chase_alu_dest(nir_dest *dest) /* Try SSA fsat. No users support 64-bit modifiers. */ if (chase_fsat(&def)) { - return (nir_legacy_alu_dest) { + return (nir_legacy_alu_dest){ .dest.is_ssa = true, .dest.ssa = def, .fsat = true, @@ -333,8 +331,9 @@ nir_legacy_trivialize(nir_shader *s, bool fuse_fabs) * chase registers recursively, allowing registers to be trivialized easier. */ if (nir_shader_instructions_pass(s, fuse_mods_with_registers, - nir_metadata_block_index | - nir_metadata_dominance, &fuse_fabs)) { + nir_metadata_block_index | + nir_metadata_dominance, + &fuse_fabs)) { /* If we made progress, we likely left dead loads. Clean them up. */ NIR_PASS_V(s, nir_opt_dce); } diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c index f9ba20a..5fe8177 100644 --- a/src/compiler/nir/nir_linking_helpers.c +++ b/src/compiler/nir/nir_linking_helpers.c @@ -21,10 +21,10 @@ * IN THE SOFTWARE. */ +#include "util/hash_table.h" +#include "util/set.h" #include "nir.h" #include "nir_builder.h" -#include "util/set.h" -#include "util/hash_table.h" /* This file contains various little helpers for doing simple linking in * NIR. Eventually, we'll probably want a full-blown varying packing @@ -41,8 +41,7 @@ get_variable_io_mask(nir_variable *var, gl_shader_stage stage) if (var->data.location < 0) return 0; - unsigned location = var->data.patch ? - var->data.location - VARYING_SLOT_PATCH0 : var->data.location; + unsigned location = var->data.patch ? var->data.location - VARYING_SLOT_PATCH0 : var->data.location; assert(var->data.mode == nir_var_shader_in || var->data.mode == nir_var_shader_out); @@ -159,7 +158,7 @@ nir_remove_unused_io_vars(nir_shader *shader, if (!(other_stage & get_variable_io_mask(var, shader->info.stage))) { /* This one is invalid, make it a global variable instead */ if (shader->info.stage == MESA_SHADER_MESH && - (shader->info.outputs_read & BITFIELD64_BIT(var->data.location))) + (shader->info.outputs_read & BITFIELD64_BIT(var->data.location))) var->data.mode = nir_var_mem_shared; else var->data.mode = nir_var_shader_temp; @@ -172,7 +171,7 @@ nir_remove_unused_io_vars(nir_shader *shader, nir_function_impl *impl = nir_shader_get_entrypoint(shader); if (progress) { nir_metadata_preserve(impl, nir_metadata_dominance | - nir_metadata_block_index); + nir_metadata_block_index); nir_fixup_deref_modes(shader); } else { nir_metadata_preserve(impl, nir_metadata_all); @@ -232,7 +231,8 @@ nir_remove_unused_varyings(nir_shader *producer, nir_shader *consumer) patches_read); progress = nir_remove_unused_io_vars(consumer, nir_var_shader_in, written, - patches_written) || progress; + patches_written) || + progress; return progress; } @@ -253,9 +253,9 @@ get_interp_type(nir_variable *var, const struct glsl_type *type, return INTERP_MODE_NONE; } -#define INTERPOLATE_LOC_SAMPLE 0 +#define INTERPOLATE_LOC_SAMPLE 0 #define INTERPOLATE_LOC_CENTROID 1 -#define INTERPOLATE_LOC_CENTER 2 +#define INTERPOLATE_LOC_CENTER 2 static uint8_t get_interp_loc(nir_variable *var) @@ -280,8 +280,7 @@ is_packing_supported_for_type(const struct glsl_type *type) return glsl_type_is_scalar(type) && glsl_type_is_32bit(type); } -struct assigned_comps -{ +struct assigned_comps { uint8_t comps; uint8_t interp_type; uint8_t interp_loc; @@ -324,8 +323,7 @@ get_unmoveable_components_masks(nir_shader *shader, unsigned location = var->data.location - VARYING_SLOT_VAR0; unsigned elements = - glsl_type_is_vector_or_scalar(glsl_without_array(type)) ? - glsl_get_vector_elements(glsl_without_array(type)) : 4; + glsl_type_is_vector_or_scalar(glsl_without_array(type)) ? glsl_get_vector_elements(glsl_without_array(type)) : 4; bool dual_slot = glsl_type_is_dual_slot(glsl_without_array(type)); unsigned slots = glsl_count_attribute_slots(type, false); @@ -366,8 +364,7 @@ get_unmoveable_components_masks(nir_shader *shader, } } -struct varying_loc -{ +struct varying_loc { uint8_t component; uint32_t location; }; @@ -379,7 +376,7 @@ mark_all_used_slots(nir_variable *var, uint64_t *slots_used, unsigned loc_offset = var->data.patch ? VARYING_SLOT_PATCH0 : 0; slots_used[var->data.patch ? 1 : 0] |= slots_used_mask & - BITFIELD64_RANGE(var->data.location - loc_offset, num_slots); + BITFIELD64_RANGE(var->data.location - loc_offset, num_slots); } static void @@ -396,10 +393,10 @@ remap_slots_and_components(nir_shader *shader, nir_variable_mode mode, struct varying_loc (*remap)[4], uint64_t *slots_used, uint64_t *out_slots_read, uint32_t *p_slots_used, uint32_t *p_out_slots_read) - { +{ const gl_shader_stage stage = shader->info.stage; - uint64_t out_slots_read_tmp[2] = {0}; - uint64_t slots_used_tmp[2] = {0}; + uint64_t out_slots_read_tmp[2] = { 0 }; + uint64_t slots_used_tmp[2] = { 0 }; /* We don't touch builtins so just copy the bitmask */ slots_used_tmp[0] = *slots_used & BITFIELD64_RANGE(0, VARYING_SLOT_VAR0); @@ -488,8 +485,8 @@ struct varying_component { static int cmp_varying_component(const void *comp1_v, const void *comp2_v) { - struct varying_component *comp1 = (struct varying_component *) comp1_v; - struct varying_component *comp2 = (struct varying_component *) comp2_v; + struct varying_component *comp1 = (struct varying_component *)comp1_v; + struct varying_component *comp2 = (struct varying_component *)comp2_v; /* We want patches to be order at the end of the array */ if (comp1->is_patch != comp2->is_patch) @@ -535,7 +532,7 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer, unsigned *varying_comp_info_size, bool default_to_smooth_interp) { - unsigned store_varying_info_idx[MAX_VARYINGS_INCL_PATCH][4] = {{0}}; + unsigned store_varying_info_idx[MAX_VARYINGS_INCL_PATCH][4] = { { 0 } }; unsigned num_of_comps_to_pack = 0; /* Count the number of varying that can be packed and create a mapping @@ -611,7 +608,7 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer, continue; struct varying_component *vc_info = - &(*varying_comp_info)[var_info_idx-1]; + &(*varying_comp_info)[var_info_idx - 1]; if (!vc_info->initialised) { const struct glsl_type *type = in_var->type; @@ -629,8 +626,8 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer, vc_info->is_patch = in_var->data.patch; vc_info->is_per_primitive = in_var->data.per_primitive; vc_info->is_mediump = !producer->options->linker_ignore_precision && - (in_var->data.precision == GLSL_PRECISION_MEDIUM || - in_var->data.precision == GLSL_PRECISION_LOW); + (in_var->data.precision == GLSL_PRECISION_MEDIUM || + in_var->data.precision == GLSL_PRECISION_LOW); vc_info->is_intra_stage_only = false; vc_info->initialised = true; } @@ -678,7 +675,7 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer, } struct varying_component *vc_info = - &(*varying_comp_info)[var_info_idx-1]; + &(*varying_comp_info)[var_info_idx - 1]; if (!vc_info->initialised) { const struct glsl_type *type = out_var->type; @@ -695,8 +692,8 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer, vc_info->is_patch = out_var->data.patch; vc_info->is_per_primitive = out_var->data.per_primitive; vc_info->is_mediump = !producer->options->linker_ignore_precision && - (out_var->data.precision == GLSL_PRECISION_MEDIUM || - out_var->data.precision == GLSL_PRECISION_LOW); + (out_var->data.precision == GLSL_PRECISION_MEDIUM || + out_var->data.precision == GLSL_PRECISION_LOW); vc_info->is_intra_stage_only = true; vc_info->initialised = true; } @@ -704,7 +701,7 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer, } } - for (unsigned i = 0; i < *varying_comp_info_size; i++ ) { + for (unsigned i = 0; i < *varying_comp_info_size; i++) { struct varying_component *vc_info = &(*varying_comp_info)[i]; if (!vc_info->initialised) { /* Something went wrong, the shader interfaces didn't match, so @@ -765,12 +762,12 @@ allow_pack_interp_loc(nir_pack_varying_options options, int loc) } static void -assign_remap_locations(struct varying_loc (*remap)[4], - struct assigned_comps *assigned_comps, - struct varying_component *info, - unsigned *cursor, unsigned *comp, - unsigned max_location, - nir_pack_varying_options options) + assign_remap_locations(struct varying_loc (*remap)[4], + struct assigned_comps *assigned_comps, + struct varying_component *info, + unsigned *cursor, unsigned *comp, + unsigned max_location, + nir_pack_varying_options options) { unsigned tmp_cursor = *cursor; unsigned tmp_comp = *comp; @@ -860,7 +857,7 @@ compact_components(nir_shader *producer, nir_shader *consumer, struct assigned_comps *assigned_comps, bool default_to_smooth_interp) { - struct varying_loc remap[MAX_VARYINGS_INCL_PATCH][4] = {{{0}, {0}}}; + struct varying_loc remap[MAX_VARYINGS_INCL_PATCH][4] = { { { 0 }, { 0 } } }; struct varying_component *varying_comp_info; unsigned varying_comp_info_size; @@ -879,7 +876,7 @@ compact_components(nir_shader *producer, nir_shader *consumer, unsigned comp = 0; /* Set the remap array based on the sorted components */ - for (unsigned i = 0; i < varying_comp_info_size; i++ ) { + for (unsigned i = 0; i < varying_comp_info_size; i++) { struct varying_component *info = &varying_comp_info[i]; assert(info->is_patch || cursor < MAX_VARYING); @@ -949,7 +946,7 @@ nir_compact_varyings(nir_shader *producer, nir_shader *consumer, assert(producer->info.stage != MESA_SHADER_FRAGMENT); assert(consumer->info.stage != MESA_SHADER_VERTEX); - struct assigned_comps assigned_comps[MAX_VARYINGS_INCL_PATCH] = {{0}}; + struct assigned_comps assigned_comps[MAX_VARYINGS_INCL_PATCH] = { { 0 } }; get_unmoveable_components_masks(producer, nir_var_shader_out, assigned_comps, @@ -1091,7 +1088,7 @@ replace_varying_input_by_constant_load(nir_shader *shader, static bool replace_duplicate_input(nir_shader *shader, nir_variable *input_var, - nir_intrinsic_instr *dup_store_intr) + nir_intrinsic_instr *dup_store_intr) { assert(input_var); @@ -1195,7 +1192,7 @@ static nir_deref_instr * clone_deref_instr(nir_builder *b, nir_variable *var, nir_deref_instr *deref) { if (deref->deref_type == nir_deref_type_var) - return nir_build_deref_var(b, var); + return nir_build_deref_var(b, var); nir_deref_instr *parent_deref = nir_deref_instr_parent(deref); nir_deref_instr *parent = clone_deref_instr(b, var, parent_deref); @@ -1267,7 +1264,7 @@ replace_varying_input_by_uniform_load(nir_shader *shader, /* Add a vector to scalar move if uniform is a vector. */ if (uni_def->num_components > 1) { - nir_alu_src src = {0}; + nir_alu_src src = { 0 }; src.src = nir_src_for_ssa(uni_def); src.swizzle[0] = scalar->comp; uni_def = nir_mov_alu(&b, src, 1); @@ -1344,7 +1341,7 @@ nir_link_varying_precision(nir_shader *producer, nir_shader *consumer) continue; nir_variable *consumer_var = find_consumer_variable(consumer, - producer_var); + producer_var); /* Skip if the variable will be eliminated */ if (!consumer_var) @@ -1424,7 +1421,7 @@ nir_link_opt_varyings(nir_shader *producer, nir_shader *consumer) struct hash_entry *entry = _mesa_hash_table_search(varying_values, ssa); if (entry) { progress |= replace_duplicate_input(consumer, - (nir_variable *) entry->data, + (nir_variable *)entry->data, intr); } else { nir_variable *in_var = get_matching_input_var(consumer, out_var); @@ -1482,7 +1479,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode, { unsigned location = 0; unsigned assigned_locations[VARYING_SLOT_TESS_MAX]; - uint64_t processed_locs[2] = {0}; + uint64_t processed_locs[2] = { 0 }; struct exec_list io_vars; sort_varyings(shader, mode, &io_vars); diff --git a/src/compiler/nir/nir_liveness.c b/src/compiler/nir/nir_liveness.c index b5e999a..e485c9b 100644 --- a/src/compiler/nir/nir_liveness.c +++ b/src/compiler/nir/nir_liveness.c @@ -22,8 +22,8 @@ */ #include "nir.h" -#include "nir_worklist.h" #include "nir_vla.h" +#include "nir_worklist.h" /* * Basic liveness analysis. This works only in SSA form. @@ -72,7 +72,7 @@ set_src_live(nir_src *src, void *void_live) BITSET_WORD *live = void_live; if (nir_src_is_undef(*src)) - return true; /* undefined variables are never live */ + return true; /* undefined variables are never live */ BITSET_SET(live, src->ssa->index); @@ -137,7 +137,7 @@ nir_live_ssa_defs_impl(nir_function_impl *impl) /* Number the instructions so we can do cheap interference tests using the * instruction index. */ - nir_metadata_require(impl, nir_metadata_instr_index); + nir_metadata_require(impl, nir_metadata_instr_index); nir_block_worklist_init(&state.worklist, impl->num_blocks, NULL); @@ -148,7 +148,6 @@ nir_live_ssa_defs_impl(nir_function_impl *impl) init_liveness_block(block, &state); } - /* We're now ready to work through the worklist and update the liveness * sets of each of the blocks. By the time we get to this point, every * block in the function implementation has been pushed onto the diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c index e191356..6ff65d2 100644 --- a/src/compiler/nir/nir_loop_analyze.c +++ b/src/compiler/nir/nir_loop_analyze.c @@ -21,10 +21,10 @@ * IN THE SOFTWARE. */ -#include "nir.h" -#include "nir_constant_expressions.h" #include "nir_loop_analyze.h" #include "util/bitset.h" +#include "nir.h" +#include "nir_constant_expressions.h" typedef enum { undefined, @@ -158,7 +158,7 @@ instr_cost(loop_info_state *state, nir_instr *instr, unsigned cost = 1; if (nir_op_is_selection(alu->op)) { - nir_ssa_scalar cond_scalar = {alu->src[0].src.ssa, 0}; + nir_ssa_scalar cond_scalar = { alu->src[0].src.ssa, 0 }; if (nir_is_terminator_condition_with_two_inputs(cond_scalar)) { nir_instr *sel_cond = alu->src[0].src.ssa->parent_instr; nir_alu_instr *sel_alu = nir_instr_as_alu(sel_cond); @@ -174,7 +174,7 @@ instr_cost(loop_info_state *state, nir_instr *instr, if ((nir_src_is_const(sel_alu->src[0].src) && get_loop_var(rhs.def, state)->type == basic_induction) || (nir_src_is_const(sel_alu->src[1].src) && - get_loop_var(lhs.def, state)->type == basic_induction) ) { + get_loop_var(lhs.def, state)->type == basic_induction)) { /* Also if the selects condition is only used by the select then * remove that alu instructons cost from the cost total also. */ @@ -204,7 +204,7 @@ instr_cost(loop_info_state *state, nir_instr *instr, return cost; bool is_fp64 = nir_dest_bit_size(alu->dest.dest) == 64 && - nir_alu_type_get_base_type(info->output_type) == nir_type_float; + nir_alu_type_get_base_type(info->output_type) == nir_type_float; for (unsigned i = 0; i < info->num_inputs; i++) { if (nir_src_bit_size(alu->src[i].src) == 64 && nir_alu_type_get_base_type(info->input_types[i]) == nir_type_float) @@ -245,9 +245,9 @@ static bool init_loop_block(nir_block *block, loop_info_state *state, bool in_if_branch, bool in_nested_loop) { - init_loop_state init_state = {.in_if_branch = in_if_branch, - .in_nested_loop = in_nested_loop, - .state = state }; + init_loop_state init_state = { .in_if_branch = in_if_branch, + .in_nested_loop = in_nested_loop, + .state = state }; nir_foreach_instr(instr, block) { nir_foreach_ssa_def(instr, init_loop_def, &init_state); @@ -374,7 +374,7 @@ is_only_uniform_src(nir_src *src) nir_alu_instr *alu = nir_instr_as_alu(instr); for (unsigned i = 0; i < nir_op_infos[alu->op].num_inputs; i++) { if (!is_only_uniform_src(&alu->src[i].src)) - return false; + return false; } return true; } @@ -460,7 +460,7 @@ compute_induction_information(loop_info_state *state) /* Is one of the operands const or uniform, and the other the phi. * The phi source can't be swizzled in any way. */ - if (alu->src[1-i].src.ssa == &phi->dest.ssa && + if (alu->src[1 - i].src.ssa == &phi->dest.ssa && alu_src_has_identity_swizzle(alu, 1 - i)) { if (is_only_uniform_src(&alu->src[i].src)) var->update_src = alu->src + i; @@ -508,9 +508,9 @@ compute_induction_information(loop_info_state *state) if (var->type == basic_induction) { nir_loop_induction_variable *ivar = &info->induction_vars[info->num_induction_vars++]; - ivar->def = var->def; - ivar->init_src = var->init_src; - ivar->update_src = var->update_src; + ivar->def = var->def; + ivar->init_src = var->init_src; + ivar->update_src = var->update_src; } } /* don't overflow */ @@ -1379,9 +1379,9 @@ force_unroll_array_access(loop_info_state *state, nir_deref_instr *deref, if (array_size) { if ((array_size == state->loop->info->max_trip_count) && nir_deref_mode_must_be(deref, nir_var_shader_in | - nir_var_shader_out | - nir_var_shader_temp | - nir_var_function_temp)) + nir_var_shader_out | + nir_var_shader_temp | + nir_var_function_temp)) return true; if (nir_deref_mode_must_be(deref, state->indirect_mask)) @@ -1404,7 +1404,6 @@ force_unroll_heuristics(loop_info_state *state, nir_block *block) nir_tex_instr_src_index(tex_instr, nir_tex_src_sampler_deref); - if (sampler_idx >= 0) { nir_deref_instr *deref = nir_instr_as_deref(tex_instr->src[sampler_idx].src.ssa->parent_instr); @@ -1413,7 +1412,6 @@ force_unroll_heuristics(loop_info_state *state, nir_block *block) } } - if (instr->type != nir_instr_type_intrinsic) continue; @@ -1526,7 +1524,7 @@ initialize_loop_info_state(nir_loop *loop, void *mem_ctx, list_inithead(&state->process_list); if (loop->info) - ralloc_free(loop->info); + ralloc_free(loop->info); loop->info = rzalloc(loop, nir_loop_info); diff --git a/src/compiler/nir/nir_lower_alpha_test.c b/src/compiler/nir/nir_lower_alpha_test.c index 27e8b25..2ce8dd0 100644 --- a/src/compiler/nir/nir_lower_alpha_test.c +++ b/src/compiler/nir/nir_lower_alpha_test.c @@ -107,6 +107,6 @@ nir_lower_alpha_test(nir_shader *shader, enum compare_func func, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } } diff --git a/src/compiler/nir/nir_lower_alu.c b/src/compiler/nir/nir_lower_alu.c index 03852d5..a0d4bee 100644 --- a/src/compiler/nir/nir_lower_alu.c +++ b/src/compiler/nir/nir_lower_alu.c @@ -230,6 +230,6 @@ nir_lower_alu(nir_shader *shader) return nir_shader_instructions_pass(shader, lower_alu_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_alu_width.c b/src/compiler/nir/nir_lower_alu_width.c index 46a479f..60bf4a6 100644 --- a/src/compiler/nir/nir_lower_alu_width.c +++ b/src/compiler/nir/nir_lower_alu_width.c @@ -199,12 +199,12 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data) } #define LOWER_REDUCTION(name, chan, merge) \ - case name##2: \ - case name##3: \ - case name##4: \ - case name##8: \ - case name##16: \ - return lower_reduction(alu, chan, merge, b, true); \ + case name##2: \ + case name##3: \ + case name##4: \ + case name##8: \ + case name##16: \ + return lower_reduction(alu, chan, merge, b, true); switch (alu->op) { case nir_op_vec16: @@ -225,7 +225,7 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data) nir_ssa_def *src_vec2 = nir_ssa_for_alu_src(b, alu, 0); return nir_pack_half_2x16_split(b, nir_channel(b, src_vec2, 0), - nir_channel(b, src_vec2, 1)); + nir_channel(b, src_vec2, 1)); } case nir_op_unpack_unorm_4x8: @@ -244,15 +244,15 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data) nir_ssa_def *packed = nir_ssa_for_alu_src(b, alu, 0); if (alu->op == nir_op_unpack_half_2x16_flush_to_zero) { - return nir_vec2(b, - nir_unpack_half_2x16_split_x_flush_to_zero(b, - packed), - nir_unpack_half_2x16_split_y_flush_to_zero(b, - packed)); + return nir_vec2(b, + nir_unpack_half_2x16_split_x_flush_to_zero(b, + packed), + nir_unpack_half_2x16_split_y_flush_to_zero(b, + packed)); } else { - return nir_vec2(b, - nir_unpack_half_2x16_split_x(b, packed), - nir_unpack_half_2x16_split_y(b, packed)); + return nir_vec2(b, + nir_unpack_half_2x16_split_x(b, packed), + nir_unpack_half_2x16_split_y(b, packed)); } } @@ -261,10 +261,9 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data) b->shader->options->lower_pack_unorm_2x16); nir_ssa_def *word = nir_extract_u16(b, nir_ssa_for_alu_src(b, alu, 0), - nir_imm_int(b, 0)); - return nir_ior(b, nir_ishl(b, nir_channel(b, word, 1), - nir_imm_int(b, 16)), - nir_channel(b, word, 0)); + nir_imm_int(b, 0)); + return nir_ior(b, nir_ishl(b, nir_channel(b, word, 1), nir_imm_int(b, 16)), + nir_channel(b, word, 0)); } case nir_op_pack_uvec4_to_uint: { @@ -272,14 +271,10 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data) b->shader->options->lower_pack_unorm_4x8); nir_ssa_def *byte = nir_extract_u8(b, nir_ssa_for_alu_src(b, alu, 0), - nir_imm_int(b, 0)); - return nir_ior(b, nir_ior(b, nir_ishl(b, nir_channel(b, byte, 3), - nir_imm_int(b, 24)), - nir_ishl(b, nir_channel(b, byte, 2), - nir_imm_int(b, 16))), - nir_ior(b, nir_ishl(b, nir_channel(b, byte, 1), - nir_imm_int(b, 8)), - nir_channel(b, byte, 0))); + nir_imm_int(b, 0)); + return nir_ior(b, nir_ior(b, nir_ishl(b, nir_channel(b, byte, 3), nir_imm_int(b, 24)), nir_ishl(b, nir_channel(b, byte, 2), nir_imm_int(b, 16))), + nir_ior(b, nir_ishl(b, nir_channel(b, byte, 1), nir_imm_int(b, 8)), + nir_channel(b, byte, 0))); } case nir_op_fdph: { @@ -293,7 +288,7 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data) for (unsigned i = 0; i < 3; i++) { int dest = reverse_order ? 3 - i : i; sum[dest] = nir_fmul(b, nir_channel(b, src0_vec, i), - nir_channel(b, src1_vec, i)); + nir_channel(b, src1_vec, i)); } sum[reverse_order ? 0 : 3] = nir_channel(b, src1_vec, 3); @@ -325,9 +320,9 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data) nir_ssa_def *src_vec4 = nir_ssa_for_alu_src(b, alu, 0); nir_ssa_def *xy = nir_pack_32_2x16_split(b, nir_channel(b, src_vec4, 0), - nir_channel(b, src_vec4, 1)); + nir_channel(b, src_vec4, 1)); nir_ssa_def *zw = nir_pack_32_2x16_split(b, nir_channel(b, src_vec4, 2), - nir_channel(b, src_vec4, 3)); + nir_channel(b, src_vec4, 3)); return nir_pack_64_2x32_split(b, xy, zw); } @@ -459,4 +454,3 @@ nir_lower_alu_to_scalar(nir_shader *shader, nir_instr_filter_cb cb, const void * return nir_lower_alu_width(shader, cb ? scalar_cb : NULL, &data); } - diff --git a/src/compiler/nir/nir_lower_amul.c b/src/compiler/nir/nir_lower_amul.c index 16d56e5..42b656e 100644 --- a/src/compiler/nir/nir_lower_amul.c +++ b/src/compiler/nir/nir_lower_amul.c @@ -123,19 +123,19 @@ lower_intrinsic(lower_state *state, nir_intrinsic_instr *intr) { switch (intr->intrinsic) { case nir_intrinsic_load_ubo: - //# src[] = { buffer_index, offset }. + // # src[] = { buffer_index, offset }. if (large_ubo(state, intr->src[0])) lower_large_src(&intr->src[1], state); return; case nir_intrinsic_load_ssbo: - //# src[] = { buffer_index, offset }. + // # src[] = { buffer_index, offset }. if (large_ssbo(state, intr->src[0])) lower_large_src(&intr->src[1], state); return; case nir_intrinsic_store_ssbo: - //# src[] = { value, block_index, offset } + // # src[] = { value, block_index, offset } if (large_ssbo(state, intr->src[1])) lower_large_src(&intr->src[2], state); return; @@ -215,7 +215,7 @@ nir_lower_amul(nir_shader *shader, /* Figure out which UBOs or SSBOs are large enough to be * disqualified from imul24: */ - nir_foreach_variable_in_shader (var, shader) { + nir_foreach_variable_in_shader(var, shader) { if (var->data.mode == nir_var_mem_ubo) { if (is_large(&state, var)) { state.has_large_ubo = true; @@ -270,8 +270,7 @@ nir_lower_amul(nir_shader *shader, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); - + nir_metadata_dominance); } return state.progress; diff --git a/src/compiler/nir/nir_lower_array_deref_of_vec.c b/src/compiler/nir/nir_lower_array_deref_of_vec.c index 2587cd9..7317105 100644 --- a/src/compiler/nir/nir_lower_array_deref_of_vec.c +++ b/src/compiler/nir/nir_lower_array_deref_of_vec.c @@ -163,7 +163,7 @@ nir_lower_array_deref_of_vec_impl(nir_function_impl *impl, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_atomics_to_ssbo.c b/src/compiler/nir/nir_lower_atomics_to_ssbo.c index 0d32d4f..b9632d3 100644 --- a/src/compiler/nir/nir_lower_atomics_to_ssbo.c +++ b/src/compiler/nir/nir_lower_atomics_to_ssbo.c @@ -35,7 +35,7 @@ static nir_deref_instr * deref_offset_var(nir_builder *b, unsigned binding, unsigned offset_align_state) { - gl_state_index16 tokens[STATE_LENGTH] = {offset_align_state, binding}; + gl_state_index16 tokens[STATE_LENGTH] = { offset_align_state, binding }; nir_variable *var = nir_find_state_variable(b->shader, tokens); if (!var) { var = nir_state_variable_create(b->shader, glsl_uint_type(), "offset", tokens); @@ -100,7 +100,7 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b, un offset_load = nir_load_deref(b, deref_offset); } nir_intrinsic_instr *new_instr = - nir_intrinsic_instr_create(b->shader, op); + nir_intrinsic_instr_create(b->shader, op); if (nir_intrinsic_has_atomic_op(new_instr)) nir_intrinsic_set_atomic_op(new_instr, atomic_op); @@ -197,7 +197,7 @@ nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned offset_align_state) } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } if (progress) { @@ -237,14 +237,14 @@ nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned offset_align_state) ssbo->data.binding + 1); struct glsl_struct_field field = { - .type = type, - .name = "counters", - .location = -1, + .type = type, + .name = "counters", + .location = -1, }; ssbo->interface_type = - glsl_interface_type(&field, 1, GLSL_INTERFACE_PACKING_STD430, - false, "counters"); + glsl_interface_type(&field, 1, GLSL_INTERFACE_PACKING_STD430, + false, "counters"); replaced |= (1 << var->data.binding); } @@ -255,4 +255,3 @@ nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned offset_align_state) return progress; } - diff --git a/src/compiler/nir/nir_lower_bit_size.c b/src/compiler/nir/nir_lower_bit_size.c index 57c447e..467a3cb 100644 --- a/src/compiler/nir/nir_lower_bit_size.c +++ b/src/compiler/nir/nir_lower_bit_size.c @@ -30,8 +30,9 @@ * the original bit-size. */ -static nir_ssa_def *convert_to_bit_size(nir_builder *bld, nir_ssa_def *src, - nir_alu_type type, unsigned bit_size) +static nir_ssa_def * +convert_to_bit_size(nir_builder *bld, nir_ssa_def *src, + nir_alu_type type, unsigned bit_size) { assert(src->bit_size < bit_size); @@ -114,7 +115,6 @@ lower_alu_instr(nir_builder *bld, nir_alu_instr *alu, unsigned bit_size) lowered_dst = nir_build_alu_src_arr(bld, op, srcs); } - /* Convert result back to the original bit-size */ if (nir_alu_type_get_type_size(nir_op_infos[op].output_type) == 0 && dst_bit_size != bit_size) { @@ -278,7 +278,7 @@ lower_impl(nir_function_impl *impl, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -357,6 +357,6 @@ nir_lower_64bit_phis(nir_shader *shader) { return nir_shader_instructions_pass(shader, lower_64bit_phi_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_bitmap.c b/src/compiler/nir/nir_lower_bitmap.c index 9599986..12c3b0b 100644 --- a/src/compiler/nir/nir_lower_bitmap.c +++ b/src/compiler/nir/nir_lower_bitmap.c @@ -90,8 +90,7 @@ lower_bitmap(nir_shader *shader, nir_builder *b, nir_builder_instr_insert(b, &tex->instr); /* kill if tex != 0.0.. take .x or .w channel according to format: */ - cond = nir_fneu_imm(b, nir_channel(b, &tex->dest.ssa, - options->swizzle_xxxx ? 0 : 3), + cond = nir_fneu_imm(b, nir_channel(b, &tex->dest.ssa, options->swizzle_xxxx ? 0 : 3), 0.0); nir_discard_if(b, cond); @@ -108,7 +107,7 @@ lower_bitmap_impl(nir_function_impl *impl, lower_bitmap(impl->function->shader, &b, options); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } void diff --git a/src/compiler/nir/nir_lower_blend.c b/src/compiler/nir/nir_lower_blend.c index e7ad8be..71ad9da 100644 --- a/src/compiler/nir/nir_lower_blend.c +++ b/src/compiler/nir/nir_lower_blend.c @@ -31,11 +31,11 @@ * fixed-function blending in part or in full. */ +#include "nir_lower_blend.h" #include "compiler/nir/nir.h" #include "compiler/nir/nir_builder.h" #include "compiler/nir/nir_format_convert.h" #include "util/blend.h" -#include "nir_lower_blend.h" struct ctx { const nir_lower_blend_options *options; @@ -136,7 +136,7 @@ static nir_ssa_def * nir_fsat_signed(nir_builder *b, nir_ssa_def *x) { return nir_fclamp(b, x, nir_imm_floatN_t(b, -1.0, x->bit_size), - nir_imm_floatN_t(b, +1.0, x->bit_size)); + nir_imm_floatN_t(b, +1.0, x->bit_size)); } static nir_ssa_def * @@ -189,7 +189,6 @@ should_clamp_factor(enum pipe_blendfactor factor, bool snorm) default: unreachable("invalid blend factor"); } - } static bool @@ -246,10 +245,10 @@ nir_color_mask( nir_ssa_def *dst) { return nir_vec4(b, - nir_channel(b, (mask & (1 << 0)) ? src : dst, 0), - nir_channel(b, (mask & (1 << 1)) ? src : dst, 1), - nir_channel(b, (mask & (1 << 2)) ? src : dst, 2), - nir_channel(b, (mask & (1 << 3)) ? src : dst, 3)); + nir_channel(b, (mask & (1 << 0)) ? src : dst, 0), + nir_channel(b, (mask & (1 << 1)) ? src : dst, 1), + nir_channel(b, (mask & (1 << 2)) ? src : dst, 2), + nir_channel(b, (mask & (1 << 3)) ? src : dst, 3)); } static nir_ssa_def * @@ -330,7 +329,7 @@ nir_blend_logicop( unsigned bits[4]; for (int i = 0; i < 4; ++i) - bits[i] = format_desc->channel[i].size; + bits[i] = format_desc->channel[i].size; if (util_format_is_unorm(format)) { src = nir_format_float_to_unorm(b, src, bits); @@ -435,10 +434,10 @@ nir_blend( nir_ssa_def *one = nir_imm_floatN_t(b, 1.0, dst->bit_size); dst = nir_vec4(b, - channel_exists(desc, 0) ? nir_channel(b, dst, 0) : zero, - channel_exists(desc, 1) ? nir_channel(b, dst, 1) : zero, - channel_exists(desc, 2) ? nir_channel(b, dst, 2) : zero, - channel_exists(desc, 3) ? nir_channel(b, dst, 3) : one); + channel_exists(desc, 0) ? nir_channel(b, dst, 0) : zero, + channel_exists(desc, 1) ? nir_channel(b, dst, 1) : zero, + channel_exists(desc, 2) ? nir_channel(b, dst, 2) : zero, + channel_exists(desc, 3) ? nir_channel(b, dst, 3) : one); /* We blend per channel and recombine later */ nir_ssa_def *channels[4]; @@ -453,14 +452,14 @@ nir_blend( if (nir_blend_factored(chan.func)) { psrc = nir_blend_factor( - b, psrc, - src, src1, dst, bconst, c, - chan.src_factor, format); + b, psrc, + src, src1, dst, bconst, c, + chan.src_factor, format); pdst = nir_blend_factor( - b, pdst, - src, src1, dst, bconst, c, - chan.dst_factor, format); + b, pdst, + src, src1, dst, bconst, c, + chan.dst_factor, format); } channels[c] = nir_blend_func(b, chan.func, psrc, pdst); @@ -595,7 +594,7 @@ nir_lower_blend_instr(nir_builder *b, nir_instr *instr, void *data) /* Grow or shrink the store destination as needed */ store->num_components = num_components; nir_intrinsic_set_write_mask(store, nir_intrinsic_write_mask(store) & - nir_component_mask(num_components)); + nir_component_mask(num_components)); /* Write out the final color instead of the input */ nir_instr_rewrite_src_ssa(instr, &store->src[0], blended); @@ -649,14 +648,14 @@ nir_lower_blend(nir_shader *shader, const nir_lower_blend_options *options) { assert(shader->info.stage == MESA_SHADER_FRAGMENT); - struct ctx ctx = {.options = options}; + struct ctx ctx = { .options = options }; nir_shader_instructions_pass(shader, consume_dual_stores, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, ctx.src1); nir_shader_instructions_pass(shader, nir_lower_blend_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &ctx); } diff --git a/src/compiler/nir/nir_lower_blend.h b/src/compiler/nir/nir_lower_blend.h index a04e3af..f2c4a0b 100644 --- a/src/compiler/nir/nir_lower_blend.h +++ b/src/compiler/nir/nir_lower_blend.h @@ -26,8 +26,8 @@ #define NIR_BLEND_H #include "compiler/nir/nir.h" -#include "util/format/u_formats.h" #include "util/blend.h" +#include "util/format/u_formats.h" /* These structs encapsulates the blend state such that it can be lowered * cleanly diff --git a/src/compiler/nir/nir_lower_bool_to_bitsize.c b/src/compiler/nir/nir_lower_bool_to_bitsize.c index 9328d32..ef47200 100644 --- a/src/compiler/nir/nir_lower_bool_to_bitsize.c +++ b/src/compiler/nir/nir_lower_bool_to_bitsize.c @@ -46,9 +46,12 @@ static uint32_t get_bool_convert_opcode(uint32_t dst_bit_size) { switch (dst_bit_size) { - case 32: return nir_op_i2i32; - case 16: return nir_op_i2i16; - case 8: return nir_op_i2i8; + case 32: + return nir_op_i2i32; + case 16: + return nir_op_i2i16; + case 8: + return nir_op_i2i8; default: unreachable("invalid boolean bit-size"); } @@ -173,130 +176,118 @@ lower_alu_instr(nir_builder *b, nir_alu_instr *alu) break; case nir_op_flt: - opcode = bit_size == 8 ? nir_op_flt8 : - bit_size == 16 ? nir_op_flt16 : nir_op_flt32; + opcode = bit_size == 8 ? nir_op_flt8 : bit_size == 16 ? nir_op_flt16 + : nir_op_flt32; break; case nir_op_fge: - opcode = bit_size == 8 ? nir_op_fge8 : - bit_size == 16 ? nir_op_fge16 : nir_op_fge32; + opcode = bit_size == 8 ? nir_op_fge8 : bit_size == 16 ? nir_op_fge16 + : nir_op_fge32; break; case nir_op_feq: - opcode = bit_size == 8 ? nir_op_feq8 : - bit_size == 16 ? nir_op_feq16 : nir_op_feq32; + opcode = bit_size == 8 ? nir_op_feq8 : bit_size == 16 ? nir_op_feq16 + : nir_op_feq32; break; case nir_op_fneu: - opcode = bit_size == 8 ? nir_op_fneu8 : - bit_size == 16 ? nir_op_fneu16 : nir_op_fneu32; + opcode = bit_size == 8 ? nir_op_fneu8 : bit_size == 16 ? nir_op_fneu16 + : nir_op_fneu32; break; case nir_op_ilt: - opcode = bit_size == 8 ? nir_op_ilt8 : - bit_size == 16 ? nir_op_ilt16 : nir_op_ilt32; + opcode = bit_size == 8 ? nir_op_ilt8 : bit_size == 16 ? nir_op_ilt16 + : nir_op_ilt32; break; case nir_op_ige: - opcode = bit_size == 8 ? nir_op_ige8 : - bit_size == 16 ? nir_op_ige16 : nir_op_ige32; + opcode = bit_size == 8 ? nir_op_ige8 : bit_size == 16 ? nir_op_ige16 + : nir_op_ige32; break; case nir_op_ieq: - opcode = bit_size == 8 ? nir_op_ieq8 : - bit_size == 16 ? nir_op_ieq16 : nir_op_ieq32; + opcode = bit_size == 8 ? nir_op_ieq8 : bit_size == 16 ? nir_op_ieq16 + : nir_op_ieq32; break; case nir_op_ine: - opcode = bit_size == 8 ? nir_op_ine8 : - bit_size == 16 ? nir_op_ine16 : nir_op_ine32; + opcode = bit_size == 8 ? nir_op_ine8 : bit_size == 16 ? nir_op_ine16 + : nir_op_ine32; break; case nir_op_ult: - opcode = bit_size == 8 ? nir_op_ult8 : - bit_size == 16 ? nir_op_ult16 : nir_op_ult32; + opcode = bit_size == 8 ? nir_op_ult8 : bit_size == 16 ? nir_op_ult16 + : nir_op_ult32; break; case nir_op_uge: - opcode = bit_size == 8 ? nir_op_uge8 : - bit_size == 16 ? nir_op_uge16 : nir_op_uge32; + opcode = bit_size == 8 ? nir_op_uge8 : bit_size == 16 ? nir_op_uge16 + : nir_op_uge32; break; case nir_op_ball_fequal2: - opcode = bit_size == 8 ? nir_op_b8all_fequal2 : - bit_size == 16 ? nir_op_b16all_fequal2 : - nir_op_b32all_fequal2; + opcode = bit_size == 8 ? nir_op_b8all_fequal2 : bit_size == 16 ? nir_op_b16all_fequal2 + : nir_op_b32all_fequal2; break; case nir_op_ball_fequal3: - opcode = bit_size == 8 ? nir_op_b8all_fequal3 : - bit_size == 16 ? nir_op_b16all_fequal3 : - nir_op_b32all_fequal3; + opcode = bit_size == 8 ? nir_op_b8all_fequal3 : bit_size == 16 ? nir_op_b16all_fequal3 + : nir_op_b32all_fequal3; break; case nir_op_ball_fequal4: - opcode = bit_size == 8 ? nir_op_b8all_fequal4 : - bit_size == 16 ? nir_op_b16all_fequal4 : - nir_op_b32all_fequal4; + opcode = bit_size == 8 ? nir_op_b8all_fequal4 : bit_size == 16 ? nir_op_b16all_fequal4 + : nir_op_b32all_fequal4; break; case nir_op_bany_fnequal2: - opcode = bit_size == 8 ? nir_op_b8any_fnequal2 : - bit_size == 16 ? nir_op_b16any_fnequal2 : - nir_op_b32any_fnequal2; + opcode = bit_size == 8 ? nir_op_b8any_fnequal2 : bit_size == 16 ? nir_op_b16any_fnequal2 + : nir_op_b32any_fnequal2; break; case nir_op_bany_fnequal3: - opcode = bit_size == 8 ? nir_op_b8any_fnequal3 : - bit_size == 16 ? nir_op_b16any_fnequal3 : - nir_op_b32any_fnequal3; + opcode = bit_size == 8 ? nir_op_b8any_fnequal3 : bit_size == 16 ? nir_op_b16any_fnequal3 + : nir_op_b32any_fnequal3; break; case nir_op_bany_fnequal4: - opcode = bit_size == 8 ? nir_op_b8any_fnequal4 : - bit_size == 16 ? nir_op_b16any_fnequal4 : - nir_op_b32any_fnequal4; + opcode = bit_size == 8 ? nir_op_b8any_fnequal4 : bit_size == 16 ? nir_op_b16any_fnequal4 + : nir_op_b32any_fnequal4; break; case nir_op_ball_iequal2: - opcode = bit_size == 8 ? nir_op_b8all_iequal2 : - bit_size == 16 ? nir_op_b16all_iequal2 : - nir_op_b32all_iequal2; + opcode = bit_size == 8 ? nir_op_b8all_iequal2 : bit_size == 16 ? nir_op_b16all_iequal2 + : nir_op_b32all_iequal2; break; case nir_op_ball_iequal3: - opcode = bit_size == 8 ? nir_op_b8all_iequal3 : - bit_size == 16 ? nir_op_b16all_iequal3 : - nir_op_b32all_iequal3; + opcode = bit_size == 8 ? nir_op_b8all_iequal3 : bit_size == 16 ? nir_op_b16all_iequal3 + : nir_op_b32all_iequal3; break; case nir_op_ball_iequal4: - opcode = bit_size == 8 ? nir_op_b8all_iequal4 : - bit_size == 16 ? nir_op_b16all_iequal4 : - nir_op_b32all_iequal4; + opcode = bit_size == 8 ? nir_op_b8all_iequal4 : bit_size == 16 ? nir_op_b16all_iequal4 + : nir_op_b32all_iequal4; break; case nir_op_bany_inequal2: - opcode = bit_size == 8 ? nir_op_b8any_inequal2 : - bit_size == 16 ? nir_op_b16any_inequal2 : - nir_op_b32any_inequal2; + opcode = bit_size == 8 ? nir_op_b8any_inequal2 : bit_size == 16 ? nir_op_b16any_inequal2 + : nir_op_b32any_inequal2; break; case nir_op_bany_inequal3: - opcode = bit_size == 8 ? nir_op_b8any_inequal3 : - bit_size == 16 ? nir_op_b16any_inequal3 : - nir_op_b32any_inequal3; + opcode = bit_size == 8 ? nir_op_b8any_inequal3 : bit_size == 16 ? nir_op_b16any_inequal3 + : nir_op_b32any_inequal3; break; case nir_op_bany_inequal4: - opcode = bit_size == 8 ? nir_op_b8any_inequal4 : - bit_size == 16 ? nir_op_b16any_inequal4 : - nir_op_b32any_inequal4; + opcode = bit_size == 8 ? nir_op_b8any_inequal4 : bit_size == 16 ? nir_op_b16any_inequal4 + : nir_op_b32any_inequal4; break; case nir_op_bcsel: - opcode = bit_size == 8 ? nir_op_b8csel : - bit_size == 16 ? nir_op_b16csel : nir_op_b32csel; + opcode = bit_size == 8 ? nir_op_b8csel : bit_size == 16 ? nir_op_b16csel + : nir_op_b32csel; /* The destination of the selection may have a different bit-size from * the bcsel condition. @@ -425,6 +416,6 @@ nir_lower_bool_to_bitsize(nir_shader *shader) { return nir_shader_instructions_pass(shader, nir_lower_bool_to_bitsize_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_bool_to_float.c b/src/compiler/nir/nir_lower_bool_to_float.c index 2d672f9..2ca9ddb 100644 --- a/src/compiler/nir/nir_lower_bool_to_float.c +++ b/src/compiler/nir/nir_lower_bool_to_float.c @@ -65,33 +65,83 @@ lower_alu_instr(nir_builder *b, nir_alu_instr *alu, bool has_fcsel_ne, /* These we expect to have booleans but the opcode doesn't change */ break; - case nir_op_b2f32: alu->op = nir_op_mov; break; - case nir_op_b2i32: alu->op = nir_op_mov; break; - case nir_op_b2b1: alu->op = nir_op_mov; break; - - case nir_op_flt: alu->op = nir_op_slt; break; - case nir_op_fge: alu->op = nir_op_sge; break; - case nir_op_feq: alu->op = nir_op_seq; break; - case nir_op_fneu: alu->op = nir_op_sne; break; - case nir_op_ilt: alu->op = nir_op_slt; break; - case nir_op_ige: alu->op = nir_op_sge; break; - case nir_op_ieq: alu->op = nir_op_seq; break; - case nir_op_ine: alu->op = nir_op_sne; break; - case nir_op_ult: alu->op = nir_op_slt; break; - case nir_op_uge: alu->op = nir_op_sge; break; - - case nir_op_ball_fequal2: alu->op = nir_op_fall_equal2; break; - case nir_op_ball_fequal3: alu->op = nir_op_fall_equal3; break; - case nir_op_ball_fequal4: alu->op = nir_op_fall_equal4; break; - case nir_op_bany_fnequal2: alu->op = nir_op_fany_nequal2; break; - case nir_op_bany_fnequal3: alu->op = nir_op_fany_nequal3; break; - case nir_op_bany_fnequal4: alu->op = nir_op_fany_nequal4; break; - case nir_op_ball_iequal2: alu->op = nir_op_fall_equal2; break; - case nir_op_ball_iequal3: alu->op = nir_op_fall_equal3; break; - case nir_op_ball_iequal4: alu->op = nir_op_fall_equal4; break; - case nir_op_bany_inequal2: alu->op = nir_op_fany_nequal2; break; - case nir_op_bany_inequal3: alu->op = nir_op_fany_nequal3; break; - case nir_op_bany_inequal4: alu->op = nir_op_fany_nequal4; break; + case nir_op_b2f32: + alu->op = nir_op_mov; + break; + case nir_op_b2i32: + alu->op = nir_op_mov; + break; + case nir_op_b2b1: + alu->op = nir_op_mov; + break; + + case nir_op_flt: + alu->op = nir_op_slt; + break; + case nir_op_fge: + alu->op = nir_op_sge; + break; + case nir_op_feq: + alu->op = nir_op_seq; + break; + case nir_op_fneu: + alu->op = nir_op_sne; + break; + case nir_op_ilt: + alu->op = nir_op_slt; + break; + case nir_op_ige: + alu->op = nir_op_sge; + break; + case nir_op_ieq: + alu->op = nir_op_seq; + break; + case nir_op_ine: + alu->op = nir_op_sne; + break; + case nir_op_ult: + alu->op = nir_op_slt; + break; + case nir_op_uge: + alu->op = nir_op_sge; + break; + + case nir_op_ball_fequal2: + alu->op = nir_op_fall_equal2; + break; + case nir_op_ball_fequal3: + alu->op = nir_op_fall_equal3; + break; + case nir_op_ball_fequal4: + alu->op = nir_op_fall_equal4; + break; + case nir_op_bany_fnequal2: + alu->op = nir_op_fany_nequal2; + break; + case nir_op_bany_fnequal3: + alu->op = nir_op_fany_nequal3; + break; + case nir_op_bany_fnequal4: + alu->op = nir_op_fany_nequal4; + break; + case nir_op_ball_iequal2: + alu->op = nir_op_fall_equal2; + break; + case nir_op_ball_iequal3: + alu->op = nir_op_fall_equal3; + break; + case nir_op_ball_iequal4: + alu->op = nir_op_fall_equal4; + break; + case nir_op_bany_inequal2: + alu->op = nir_op_fany_nequal2; + break; + case nir_op_bany_inequal3: + alu->op = nir_op_fany_nequal3; + break; + case nir_op_bany_inequal4: + alu->op = nir_op_fany_nequal4; + break; case nir_op_bcsel: if (has_fcsel_gt) @@ -110,13 +160,19 @@ lower_alu_instr(nir_builder *b, nir_alu_instr *alu, bool has_fcsel_ne, break; - case nir_op_iand: alu->op = nir_op_fmul; break; - case nir_op_ixor: alu->op = nir_op_sne; break; - case nir_op_ior: alu->op = nir_op_fmax; break; + case nir_op_iand: + alu->op = nir_op_fmul; + break; + case nir_op_ixor: + alu->op = nir_op_sne; + break; + case nir_op_ior: + alu->op = nir_op_fmax; + break; case nir_op_inot: rep = nir_seq(b, nir_ssa_for_alu_src(b, alu, 0), - nir_imm_float(b, 0)); + nir_imm_float(b, 0)); break; default: @@ -206,6 +262,6 @@ nir_lower_bool_to_float(nir_shader *shader, bool has_fcsel_ne) return nir_shader_instructions_pass(shader, nir_lower_bool_to_float_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &data); } diff --git a/src/compiler/nir/nir_lower_bool_to_int32.c b/src/compiler/nir/nir_lower_bool_to_int32.c index f9e2884..2f719f1 100644 --- a/src/compiler/nir/nir_lower_bool_to_int32.c +++ b/src/compiler/nir/nir_lower_bool_to_int32.c @@ -73,33 +73,81 @@ lower_alu_instr(nir_alu_instr *alu) alu->op = nir_op_mov; break; - case nir_op_flt: alu->op = nir_op_flt32; break; - case nir_op_fge: alu->op = nir_op_fge32; break; - case nir_op_feq: alu->op = nir_op_feq32; break; - case nir_op_fneu: alu->op = nir_op_fneu32; break; - case nir_op_ilt: alu->op = nir_op_ilt32; break; - case nir_op_ige: alu->op = nir_op_ige32; break; - case nir_op_ieq: alu->op = nir_op_ieq32; break; - case nir_op_ine: alu->op = nir_op_ine32; break; - case nir_op_ult: alu->op = nir_op_ult32; break; - case nir_op_uge: alu->op = nir_op_uge32; break; - - case nir_op_ball_fequal2: alu->op = nir_op_b32all_fequal2; break; - case nir_op_ball_fequal3: alu->op = nir_op_b32all_fequal3; break; - case nir_op_ball_fequal4: alu->op = nir_op_b32all_fequal4; break; - case nir_op_bany_fnequal2: alu->op = nir_op_b32any_fnequal2; break; - case nir_op_bany_fnequal3: alu->op = nir_op_b32any_fnequal3; break; - case nir_op_bany_fnequal4: alu->op = nir_op_b32any_fnequal4; break; - case nir_op_ball_iequal2: alu->op = nir_op_b32all_iequal2; break; - case nir_op_ball_iequal3: alu->op = nir_op_b32all_iequal3; break; - case nir_op_ball_iequal4: alu->op = nir_op_b32all_iequal4; break; - case nir_op_bany_inequal2: alu->op = nir_op_b32any_inequal2; break; - case nir_op_bany_inequal3: alu->op = nir_op_b32any_inequal3; break; - case nir_op_bany_inequal4: alu->op = nir_op_b32any_inequal4; break; - - case nir_op_bcsel: alu->op = nir_op_b32csel; break; - - case nir_op_fisfinite: alu->op = nir_op_fisfinite32; break; + case nir_op_flt: + alu->op = nir_op_flt32; + break; + case nir_op_fge: + alu->op = nir_op_fge32; + break; + case nir_op_feq: + alu->op = nir_op_feq32; + break; + case nir_op_fneu: + alu->op = nir_op_fneu32; + break; + case nir_op_ilt: + alu->op = nir_op_ilt32; + break; + case nir_op_ige: + alu->op = nir_op_ige32; + break; + case nir_op_ieq: + alu->op = nir_op_ieq32; + break; + case nir_op_ine: + alu->op = nir_op_ine32; + break; + case nir_op_ult: + alu->op = nir_op_ult32; + break; + case nir_op_uge: + alu->op = nir_op_uge32; + break; + + case nir_op_ball_fequal2: + alu->op = nir_op_b32all_fequal2; + break; + case nir_op_ball_fequal3: + alu->op = nir_op_b32all_fequal3; + break; + case nir_op_ball_fequal4: + alu->op = nir_op_b32all_fequal4; + break; + case nir_op_bany_fnequal2: + alu->op = nir_op_b32any_fnequal2; + break; + case nir_op_bany_fnequal3: + alu->op = nir_op_b32any_fnequal3; + break; + case nir_op_bany_fnequal4: + alu->op = nir_op_b32any_fnequal4; + break; + case nir_op_ball_iequal2: + alu->op = nir_op_b32all_iequal2; + break; + case nir_op_ball_iequal3: + alu->op = nir_op_b32all_iequal3; + break; + case nir_op_ball_iequal4: + alu->op = nir_op_b32all_iequal4; + break; + case nir_op_bany_inequal2: + alu->op = nir_op_b32any_inequal2; + break; + case nir_op_bany_inequal3: + alu->op = nir_op_b32any_inequal3; + break; + case nir_op_bany_inequal4: + alu->op = nir_op_b32any_inequal4; + break; + + case nir_op_bcsel: + alu->op = nir_op_b32csel; + break; + + case nir_op_fisfinite: + alu->op = nir_op_fisfinite32; + break; default: assert(alu->dest.dest.ssa.bit_size > 1); @@ -181,6 +229,7 @@ nir_lower_bool_to_int32(nir_shader *shader) progress |= nir_shader_instructions_pass(shader, nir_lower_bool_to_int32_instr, nir_metadata_block_index | - nir_metadata_dominance, NULL); + nir_metadata_dominance, + NULL); return progress; } diff --git a/src/compiler/nir/nir_lower_cl_images.c b/src/compiler/nir/nir_lower_cl_images.c index a15ceb2..db6ee0d 100644 --- a/src/compiler/nir/nir_lower_cl_images.c +++ b/src/compiler/nir/nir_lower_cl_images.c @@ -85,7 +85,7 @@ nir_dedup_inline_samplers(nir_shader *nir) nir_shader_instructions_pass(nir, nir_dedup_inline_samplers_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &inline_samplers); /* If we found any inline samplers in the instructions pass, they'll now be @@ -188,7 +188,7 @@ nir_lower_cl_images(nir_shader *shader, bool lower_image_derefs, bool lower_samp b.cursor = nir_instr_remove(&deref->instr); nir_ssa_def *loc = nir_imm_intN_t(&b, deref->var->data.driver_location, - deref->dest.ssa.bit_size); + deref->dest.ssa.bit_size); nir_ssa_def_rewrite_uses(&deref->dest.ssa, loc); progress = true; break; @@ -275,7 +275,7 @@ nir_lower_cl_images(nir_shader *shader, bool lower_image_derefs, bool lower_samp if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_clamp_color_outputs.c b/src/compiler/nir/nir_lower_clamp_color_outputs.c index c790dad..71a0853 100644 --- a/src/compiler/nir/nir_lower_clamp_color_outputs.c +++ b/src/compiler/nir/nir_lower_clamp_color_outputs.c @@ -21,7 +21,6 @@ * SOFTWARE. */ - #include "nir.h" #include "nir_builder.h" @@ -102,6 +101,6 @@ nir_lower_clamp_color_outputs(nir_shader *shader) { return nir_shader_instructions_pass(shader, lower_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, shader); } diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c index 6bd69e6..e10440d 100644 --- a/src/compiler/nir/nir_lower_clip.c +++ b/src/compiler/nir/nir_lower_clip.c @@ -39,7 +39,6 @@ * and only once). */ - static nir_variable * create_clipdist_var(nir_shader *shader, bool output, gl_varying_slot slot, unsigned array_size) @@ -122,12 +121,12 @@ load_clipdist_input(nir_builder *b, nir_variable *in, int location_offset, if (b->shader->options->use_interpolated_input_intrinsics) { /* TODO: use sample when per-sample shading? */ nir_ssa_def *barycentric = nir_load_barycentric( - b, nir_intrinsic_load_barycentric_pixel, INTERP_MODE_NONE); + b, nir_intrinsic_load_barycentric_pixel, INTERP_MODE_NONE); load = nir_load_interpolated_input( - b, 4, 32, barycentric, nir_imm_int(b, location_offset), - .base = in->data.driver_location, - .dest_type = nir_type_float32, - .io_semantics = semantics); + b, 4, 32, barycentric, nir_imm_int(b, location_offset), + .base = in->data.driver_location, + .dest_type = nir_type_float32, + .io_semantics = semantics); } else { load = nir_load_input(b, 4, 32, nir_imm_int(b, location_offset), @@ -232,7 +231,6 @@ get_ucp(nir_builder *b, int plane, return nir_load_user_clip_plane(b, plane); } - static void lower_clip_outputs(nir_builder *b, nir_variable *position, nir_variable *clipvertex, nir_variable **out, @@ -462,7 +460,7 @@ lower_clip_fs(nir_function_impl *impl, unsigned ucp_enables, static bool fs_has_clip_dist_input_var(nir_shader *shader, nir_variable **io_vars, - unsigned *ucp_enables) + unsigned *ucp_enables) { assert(shader->info.stage == MESA_SHADER_FRAGMENT); nir_foreach_shader_in_variable(var, shader) { @@ -485,7 +483,7 @@ bool nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables, bool use_clipdist_array) { - nir_variable *in[2] = {0}; + nir_variable *in[2] = { 0 }; if (!ucp_enables) return false; diff --git a/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c b/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c index 4d27877..6c344e8 100644 --- a/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c +++ b/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c @@ -143,9 +143,9 @@ nir_lower_clip_cull_distance_arrays(nir_shader *nir) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs | - nir_metadata_loop_analysis); + nir_metadata_dominance | + nir_metadata_live_ssa_defs | + nir_metadata_loop_analysis); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_clip_disable.c b/src/compiler/nir/nir_lower_clip_disable.c index 2be9c44..7e5cba6 100644 --- a/src/compiler/nir/nir_lower_clip_disable.c +++ b/src/compiler/nir/nir_lower_clip_disable.c @@ -19,7 +19,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. - * + * * Authors: * Mike Blumenkrantz */ @@ -27,7 +27,6 @@ #include "nir.h" #include "nir_builder.h" - /** * This pass uses the enabled clip planes from the rasterizer state to rewrite * vertex shader store operations and store a 0 to the corresponding gl_ClipDistance[n] @@ -80,7 +79,7 @@ lower_clip_plane_store(nir_builder *b, nir_instr *instr_, void *cb_data) out = nir_deref_instr_get_variable(deref); if ((out->data.location != VARYING_SLOT_CLIP_DIST0 && out->data.location != VARYING_SLOT_CLIP_DIST1) || - out->data.mode != nir_var_shader_out) + out->data.mode != nir_var_shader_out) return false; b->cursor = nir_after_instr(&instr->instr); @@ -100,7 +99,7 @@ lower_clip_plane_store(nir_builder *b, nir_instr *instr_, void *cb_data) components[i] = nir_ssa_undef(b, 1, 32); } nir_store_deref(b, deref, nir_vec(b, components, instr->num_components), wrmask); - } else if (nir_src_is_const(deref->arr.index)) { + } else if (nir_src_is_const(deref->arr.index)) { /* storing using a constant index */ plane = nir_src_as_uint(deref->arr.index); /* no need to make changes if the clip plane is enabled */ @@ -131,6 +130,6 @@ nir_lower_clip_disable(nir_shader *shader, unsigned clip_plane_enable) return nir_shader_instructions_pass(shader, lower_clip_plane_store, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &clip_plane_enable); } diff --git a/src/compiler/nir/nir_lower_clip_halfz.c b/src/compiler/nir/nir_lower_clip_halfz.c index 48c4818..5418d96 100644 --- a/src/compiler/nir/nir_lower_clip_halfz.c +++ b/src/compiler/nir/nir_lower_clip_halfz.c @@ -64,6 +64,6 @@ nir_lower_clip_halfz(nir_shader *shader) nir_shader_instructions_pass(shader, lower_pos_write, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_const_arrays_to_uniforms.c b/src/compiler/nir/nir_lower_const_arrays_to_uniforms.c index 93065c7..ba113ef 100644 --- a/src/compiler/nir/nir_lower_const_arrays_to_uniforms.c +++ b/src/compiler/nir/nir_lower_const_arrays_to_uniforms.c @@ -58,7 +58,7 @@ set_const_initialiser(nir_deref_instr **p, nir_constant *top_level_init, assert(*p); nir_constant *ret = top_level_init; - for ( ; *p; p++) { + for (; *p; p++) { if ((*p)->deref_type == nir_deref_type_array) { assert(nir_src_is_const((*p)->arr.index)); @@ -81,7 +81,7 @@ set_const_initialiser(nir_deref_instr **p, nir_constant *top_level_init, */ nir_instr *src_instr = const_src->ssa->parent_instr; assert(src_instr->type == nir_instr_type_load_const); - nir_load_const_instr* load = nir_instr_as_load_const(src_instr); + nir_load_const_instr *load = nir_instr_as_load_const(src_instr); for (unsigned i = 0; i < load->def.num_components; i++) { if (!(writemask & (1 << i))) @@ -247,7 +247,7 @@ nir_lower_const_arrays_to_uniforms(nir_shader *shader, struct var_info *var_infos = ralloc_array(NULL, struct var_info, num_locals); nir_foreach_function_temp_variable(var, impl) { - var_infos[var->index] = (struct var_info) { + var_infos[var->index] = (struct var_info){ .var = var, .is_constant = true, .found_read = false, @@ -379,7 +379,7 @@ nir_lower_const_arrays_to_uniforms(nir_shader *shader, b.cursor = nir_before_instr(instr); - nir_variable *uni = (nir_variable *) entry->data; + nir_variable *uni = (nir_variable *)entry->data; nir_deref_instr *new_deref_instr = nir_build_deref_var(&b, uni); nir_deref_path path; @@ -408,7 +408,7 @@ nir_lower_const_arrays_to_uniforms(nir_shader *shader, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); ralloc_free(var_infos); _mesa_hash_table_destroy(const_array_vars, NULL); diff --git a/src/compiler/nir/nir_lower_continue_constructs.c b/src/compiler/nir/nir_lower_continue_constructs.c index 7d55d77..6dd408b 100644 --- a/src/compiler/nir/nir_lower_continue_constructs.c +++ b/src/compiler/nir/nir_lower_continue_constructs.c @@ -22,7 +22,6 @@ * */ - #include "nir.h" #include "nir_builder.h" #include "nir_control_flow.h" @@ -40,7 +39,7 @@ lower_loop_continue_block(nir_builder *b, nir_loop *loop, bool *repair_ssa) unsigned num_continue = 0; nir_block *single_predecessor = NULL; set_foreach(cont->predecessors, entry) { - nir_block *pred = (nir_block*) entry->key; + nir_block *pred = (nir_block *)entry->key; /* If the continue block has no predecessors, it is unreachable. */ if (pred->predecessors->entries == 0) continue; @@ -102,7 +101,6 @@ lower_loop_continue_block(nir_builder *b, nir_loop *loop, bool *repair_ssa) return true; } - static bool visit_cf_list(nir_builder *b, struct exec_list *list, bool *repair_ssa) { @@ -171,4 +169,3 @@ nir_lower_continue_constructs(nir_shader *shader) return progress; } - diff --git a/src/compiler/nir/nir_lower_convert_alu_types.c b/src/compiler/nir/nir_lower_convert_alu_types.c index 8fa51bc..b895370 100644 --- a/src/compiler/nir/nir_lower_convert_alu_types.c +++ b/src/compiler/nir/nir_lower_convert_alu_types.c @@ -95,7 +95,7 @@ opt_simplify_convert_alu_types_impl(nir_function_impl *impl) if (lowered_instr) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -143,7 +143,7 @@ lower_convert_alu_types_impl(nir_function_impl *impl, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_discard_if.c b/src/compiler/nir/nir_lower_discard_if.c index b8de642..15b966f 100644 --- a/src/compiler/nir/nir_lower_discard_if.c +++ b/src/compiler/nir/nir_lower_discard_if.c @@ -21,8 +21,8 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "nir.h" #include "compiler/nir/nir_builder.h" +#include "nir.h" static bool lower_discard_if_instr(nir_builder *b, nir_instr *instr_, void *cb_data) diff --git a/src/compiler/nir/nir_lower_discard_or_demote.c b/src/compiler/nir/nir_lower_discard_or_demote.c index c3c3c3e..5276c60 100644 --- a/src/compiler/nir/nir_lower_discard_or_demote.c +++ b/src/compiler/nir/nir_lower_discard_or_demote.c @@ -92,7 +92,6 @@ insert_is_helper(nir_builder *b, nir_instr *instr) return nir_is_helper_invocation(b, 1); } - static bool nir_lower_load_helper_to_is_helper(nir_builder *b, nir_instr *instr, void *data) { @@ -100,14 +99,14 @@ nir_lower_load_helper_to_is_helper(nir_builder *b, nir_instr *instr, void *data) return false; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - nir_ssa_def *is_helper = *(nir_ssa_def**) data; + nir_ssa_def *is_helper = *(nir_ssa_def **)data; switch (intrin->intrinsic) { case nir_intrinsic_demote: case nir_intrinsic_demote_if: /* insert is_helper at last top level occasion */ if (is_helper == NULL) { is_helper = insert_is_helper(b, instr); - *(nir_ssa_def**)data = is_helper; + *(nir_ssa_def **)data = is_helper; return true; } else { return false; @@ -165,9 +164,9 @@ nir_lower_discard_or_demote(nir_shader *shader, progress = nir_shader_instructions_pass(shader, nir_lower_discard_to_demote_instr, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs | - nir_metadata_instr_index, + nir_metadata_dominance | + nir_metadata_live_ssa_defs | + nir_metadata_instr_index, NULL); shader->info.fs.uses_demote = true; } else if (!shader->info.fs.needs_quad_helper_invocations && @@ -177,7 +176,7 @@ nir_lower_discard_or_demote(nir_shader *shader, progress = nir_shader_instructions_pass(shader, nir_lower_demote_to_discard_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); shader->info.fs.uses_demote = false; } else if (shader->info.fs.uses_demote && @@ -189,7 +188,7 @@ nir_lower_discard_or_demote(nir_shader *shader, progress = nir_shader_instructions_pass(shader, nir_lower_load_helper_to_is_helper, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &is_helper); BITSET_CLEAR(shader->info.system_values_read, nir_system_value_from_intrinsic(nir_intrinsic_load_helper_invocation)); diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c index b890ef5..5545765 100644 --- a/src/compiler/nir/nir_lower_double_ops.c +++ b/src/compiler/nir/nir_lower_double_ops.c @@ -25,8 +25,8 @@ #include "nir.h" #include "nir_builder.h" -#include #include +#include /* * Lowers some unsupported double operations, using only: @@ -98,8 +98,7 @@ fix_inv_result(nir_builder *b, nir_ssa_def *res, nir_ssa_def *src, * denorms properly. Note that this doesn't preserve positive/negative * zeros, but GLSL doesn't require it. */ - res = nir_bcsel(b, nir_ior(b, nir_ile_imm(b, exp, 0), - nir_feq_imm(b, nir_fabs(b, src), INFINITY)), + res = nir_bcsel(b, nir_ior(b, nir_ile_imm(b, exp, 0), nir_feq_imm(b, nir_fabs(b, src), INFINITY)), nir_imm_double(b, 0.0f), res); /* If the original input was 0, generate the correctly-signed infinity */ @@ -107,7 +106,6 @@ fix_inv_result(nir_builder *b, nir_ssa_def *res, nir_ssa_def *src, res, get_signed_inf(b, src)); return res; - } static nir_ssa_def * @@ -301,9 +299,8 @@ lower_sqrt_rsq(nir_builder *b, nir_ssa_def *src, bool sqrt) nir_imm_double(b, 0.0), src); } - res = nir_bcsel(b, nir_ior(b, nir_feq_imm(b, src_flushed, 0.0), - nir_feq_imm(b, src, INFINITY)), - src_flushed, res); + res = nir_bcsel(b, nir_ior(b, nir_feq_imm(b, src_flushed, 0.0), nir_feq_imm(b, src, INFINITY)), + src_flushed, res); } else { res = fix_inv_result(b, res, src, new_exp); } @@ -352,15 +349,14 @@ lower_trunc(nir_builder *b, nir_ssa_def *src) nir_ssa_def *src_lo = nir_unpack_64_2x32_split_x(b, src); nir_ssa_def *src_hi = nir_unpack_64_2x32_split_y(b, src); - return - nir_bcsel(b, - nir_ilt_imm(b, unbiased_exp, 0), - nir_imm_double(b, 0.0), - nir_bcsel(b, nir_ige_imm(b, unbiased_exp, 53), - src, - nir_pack_64_2x32_split(b, - nir_iand(b, mask_lo, src_lo), - nir_iand(b, mask_hi, src_hi)))); + return nir_bcsel(b, + nir_ilt_imm(b, unbiased_exp, 0), + nir_imm_double(b, 0.0), + nir_bcsel(b, nir_ige_imm(b, unbiased_exp, 53), + src, + nir_pack_64_2x32_split(b, + nir_iand(b, mask_lo, src_lo), + nir_iand(b, mask_hi, src_hi)))); } static nir_ssa_def * @@ -415,7 +411,8 @@ lower_round_even(nir_builder *b, nir_ssa_def *src) return nir_bcsel(b, nir_flt(b, nir_fabs(b, src), two52), nir_pack_64_2x32_split(b, nir_unpack_64_2x32_split_x(b, res), - nir_ior(b, nir_unpack_64_2x32_split_y(b, res), sign)), src); + nir_ior(b, nir_unpack_64_2x32_split_y(b, res), sign)), + src); } static nir_ssa_def * @@ -506,8 +503,7 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr, if (instr->src[0].src.ssa->bit_size == 64) { name = "__int64_to_fp64"; mangled_name = "__int64_to_fp64(i641;"; - } - else { + } else { name = "__int_to_fp64"; mangled_name = "__int_to_fp64(i1;"; } @@ -516,8 +512,7 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr, if (instr->src[0].src.ssa->bit_size == 64) { name = "__uint64_to_fp64"; mangled_name = "__uint64_to_fp64(u641;"; - } - else { + } else { name = "__uint_to_fp64"; mangled_name = "__uint_to_fp64(u1;"; } @@ -617,7 +612,9 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr, assert(func); } - nir_ssa_def *params[4] = { NULL, }; + nir_ssa_def *params[4] = { + NULL, + }; nir_variable *ret_tmp = nir_local_variable_create(b->impl, return_type, "return_tmp"); @@ -639,18 +636,30 @@ nir_lower_doubles_options nir_lower_doubles_op_to_options_mask(nir_op opcode) { switch (opcode) { - case nir_op_frcp: return nir_lower_drcp; - case nir_op_fsqrt: return nir_lower_dsqrt; - case nir_op_frsq: return nir_lower_drsq; - case nir_op_ftrunc: return nir_lower_dtrunc; - case nir_op_ffloor: return nir_lower_dfloor; - case nir_op_fceil: return nir_lower_dceil; - case nir_op_ffract: return nir_lower_dfract; - case nir_op_fround_even: return nir_lower_dround_even; - case nir_op_fmod: return nir_lower_dmod; - case nir_op_fsub: return nir_lower_dsub; - case nir_op_fdiv: return nir_lower_ddiv; - default: return 0; + case nir_op_frcp: + return nir_lower_drcp; + case nir_op_fsqrt: + return nir_lower_dsqrt; + case nir_op_frsq: + return nir_lower_drsq; + case nir_op_ftrunc: + return nir_lower_dtrunc; + case nir_op_ffloor: + return nir_lower_dfloor; + case nir_op_fceil: + return nir_lower_dceil; + case nir_op_ffract: + return nir_lower_dfract; + case nir_op_fround_even: + return nir_lower_dround_even; + case nir_op_fmod: + return nir_lower_dmod; + case nir_op_fsub: + return nir_lower_dsub; + case nir_op_fdiv: + return nir_lower_ddiv; + default: + return 0; } } @@ -771,7 +780,7 @@ nir_lower_doubles_impl(nir_function_impl *impl, nir_opt_deref_impl(impl); } else if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c index 52a9049..cabe2cb 100644 --- a/src/compiler/nir/nir_lower_drawpixels.c +++ b/src/compiler/nir/nir_lower_drawpixels.c @@ -33,7 +33,7 @@ typedef struct { const nir_lower_drawpixels_options *options; - nir_shader *shader; + nir_shader *shader; nir_variable *texcoord, *texcoord_const, *scale, *bias, *tex, *pixelmap; } lower_drawpixels_state; @@ -253,6 +253,6 @@ nir_lower_drawpixels(nir_shader *shader, nir_shader_instructions_pass(shader, lower_drawpixels_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); } diff --git a/src/compiler/nir/nir_lower_fb_read.c b/src/compiler/nir/nir_lower_fb_read.c index a61cff2..65c2af7 100644 --- a/src/compiler/nir/nir_lower_fb_read.c +++ b/src/compiler/nir/nir_lower_fb_read.c @@ -91,6 +91,6 @@ nir_lower_fb_read(nir_shader *shader) return nir_shader_instructions_pass(shader, nir_lower_fb_read_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_flatshade.c b/src/compiler/nir/nir_lower_flatshade.c index 15fbb7d..6edfd49 100644 --- a/src/compiler/nir/nir_lower_flatshade.c +++ b/src/compiler/nir/nir_lower_flatshade.c @@ -21,7 +21,6 @@ * SOFTWARE. */ - #include "nir.h" #include "nir_builder.h" diff --git a/src/compiler/nir/nir_lower_flrp.c b/src/compiler/nir/nir_lower_flrp.c index 574a282..9b84e4b 100644 --- a/src/compiler/nir/nir_lower_flrp.c +++ b/src/compiler/nir/nir_lower_flrp.c @@ -21,9 +21,9 @@ * IN THE SOFTWARE. */ #include +#include "util/u_vector.h" #include "nir.h" #include "nir_builder.h" -#include "util/u_vector.h" /** * Lower flrp instructions. @@ -615,7 +615,7 @@ lower_flrp_impl(nir_function_impl *impl, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } /** diff --git a/src/compiler/nir/nir_lower_fp16_conv.c b/src/compiler/nir/nir_lower_fp16_conv.c index b88406a..23ebd07 100644 --- a/src/compiler/nir/nir_lower_fp16_conv.c +++ b/src/compiler/nir/nir_lower_fp16_conv.c @@ -54,12 +54,10 @@ half_rounded(nir_builder *b, nir_ssa_def *value, nir_ssa_def *guard, nir_ssa_def return nir_iadd(b, value, nir_iand(b, guard, nir_ior(b, sticky, value))); case nir_rounding_mode_ru: sign = nir_ushr_imm(b, sign, 31); - return nir_iadd(b, value, nir_iand(b, nir_inot(b, sign), - nir_ior(b, guard, sticky))); + return nir_iadd(b, value, nir_iand(b, nir_inot(b, sign), nir_ior(b, guard, sticky))); case nir_rounding_mode_rd: sign = nir_ushr_imm(b, sign, 31); - return nir_iadd(b, value, nir_iand(b, sign, - nir_ior(b, guard, sticky))); + return nir_iadd(b, value, nir_iand(b, sign, nir_ior(b, guard, sticky))); default: return value; } @@ -80,9 +78,9 @@ float_to_half_impl(nir_builder *b, nir_ssa_def *src, nir_rounding_mode mode) /* NaN or INF. For rtne, overflow also becomes INF, so combine the comparisons */ nir_push_if(b, nir_ige(b, abs, mode == nir_rounding_mode_rtne ? f16max : f32infinity)); nir_ssa_def *inf_nanfp16 = nir_bcsel(b, - nir_ilt(b, f32infinity, abs), - nir_imm_int(b, 0x7E00), - nir_imm_int(b, 0x7C00)); + nir_ilt(b, f32infinity, abs), + nir_imm_int(b, 0x7E00), + nir_imm_int(b, 0x7C00)); nir_push_else(b, NULL); nir_ssa_def *overflowed_fp16 = NULL; @@ -101,7 +99,8 @@ float_to_half_impl(nir_builder *b, nir_ssa_def *src, nir_rounding_mode mode) /* Negative becomes inf, positive becomes max float */ overflowed_fp16 = nir_bcsel(b, nir_i2b(b, sign), nir_imm_int(b, 0x7C00), nir_imm_int(b, 0x7BFF)); break; - default: unreachable("Should've been handled already"); + default: + unreachable("Should've been handled already"); } nir_push_else(b, NULL); } diff --git a/src/compiler/nir/nir_lower_fragcolor.c b/src/compiler/nir/nir_lower_fragcolor.c index 7bd4a3e..1eacc98 100644 --- a/src/compiler/nir/nir_lower_fragcolor.c +++ b/src/compiler/nir/nir_lower_fragcolor.c @@ -19,7 +19,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. - * + * * Authors: * Mike Blumenkrantz */ @@ -68,10 +68,8 @@ lower_fragcolor_instr(nir_builder *b, nir_instr *intr, void *data) nir_ssa_def *frag_color = instr->src[1].ssa; ralloc_free(out->name); - const char *name = out->data.index == 0 ? "gl_FragData[0]" : - "gl_SecondaryFragDataEXT[0]"; - const char *name_tmpl = out->data.index == 0 ? "gl_FragData[%u]" : - "gl_SecondaryFragDataEXT[%u]"; + const char *name = out->data.index == 0 ? "gl_FragData[0]" : "gl_SecondaryFragDataEXT[0]"; + const char *name_tmpl = out->data.index == 0 ? "gl_FragData[%u]" : "gl_SecondaryFragDataEXT[%u]"; out->name = ralloc_strdup(out, name); @@ -85,7 +83,7 @@ lower_fragcolor_instr(nir_builder *b, nir_instr *intr, void *data) char name[28]; snprintf(name, sizeof(name), name_tmpl, i); nir_variable *out_color = nir_variable_create(b->shader, nir_var_shader_out, - out->type, name); + out->type, name); out_color->data.location = FRAG_RESULT_DATA0 + i; out_color->data.driver_location = b->shader->num_outputs++; out_color->data.index = out->data.index; @@ -102,5 +100,5 @@ nir_lower_fragcolor(nir_shader *shader, unsigned max_draw_buffers) return false; return nir_shader_instructions_pass(shader, lower_fragcolor_instr, - nir_metadata_block_index | nir_metadata_dominance, &max_draw_buffers); + nir_metadata_block_index | nir_metadata_dominance, &max_draw_buffers); } diff --git a/src/compiler/nir/nir_lower_fragcoord_wtrans.c b/src/compiler/nir/nir_lower_fragcoord_wtrans.c index fce8606..5fc1fa2 100644 --- a/src/compiler/nir/nir_lower_fragcoord_wtrans.c +++ b/src/compiler/nir/nir_lower_fragcoord_wtrans.c @@ -75,5 +75,4 @@ nir_lower_fragcoord_wtrans(nir_shader *shader) lower_fragcoord_wtrans_filter, lower_fragcoord_wtrans_impl, NULL); - } diff --git a/src/compiler/nir/nir_lower_frexp.c b/src/compiler/nir/nir_lower_frexp.c index 76d125e..6395a8c 100644 --- a/src/compiler/nir/nir_lower_frexp.c +++ b/src/compiler/nir/nir_lower_frexp.c @@ -129,7 +129,7 @@ lower_frexp_exp(nir_builder *b, nir_ssa_def *x) * exponent must be a 32-bit integer. */ exponent = nir_i2i32(b, nir_iadd(b, nir_ushr(b, abs_x, exponent_shift), - nir_bcsel(b, is_not_zero, exponent_bias, zero))); + nir_bcsel(b, is_not_zero, exponent_bias, zero))); break; } case 32: { @@ -137,7 +137,7 @@ lower_frexp_exp(nir_builder *b, nir_ssa_def *x) nir_ssa_def *exponent_bias = nir_imm_int(b, -126); exponent = nir_iadd(b, nir_ushr(b, abs_x, exponent_shift), - nir_bcsel(b, is_not_zero, exponent_bias, zero)); + nir_bcsel(b, is_not_zero, exponent_bias, zero)); break; } case 64: { @@ -148,7 +148,7 @@ lower_frexp_exp(nir_builder *b, nir_ssa_def *x) nir_ssa_def *abs_upper_x = nir_unpack_64_2x32_split_y(b, abs_x); exponent = nir_iadd(b, nir_ushr(b, abs_upper_x, exponent_shift), - nir_bcsel(b, is_not_zero, exponent_bias, zero32)); + nir_bcsel(b, is_not_zero, exponent_bias, zero32)); break; } default: @@ -190,6 +190,6 @@ nir_lower_frexp(nir_shader *shader) { return nir_shader_instructions_pass(shader, lower_frexp_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_global_vars_to_local.c b/src/compiler/nir/nir_lower_global_vars_to_local.c index dda6fb6..858e96a 100644 --- a/src/compiler/nir/nir_lower_global_vars_to_local.c +++ b/src/compiler/nir/nir_lower_global_vars_to_local.c @@ -51,7 +51,7 @@ mark_global_var_uses_block(nir_block *block, nir_function_impl *impl, struct hash_table *var_func_table) { nir_foreach_instr(instr, block) { - if (instr->type == nir_instr_type_deref) { + if (instr->type == nir_instr_type_deref) { nir_deref_instr *deref = nir_instr_as_deref(instr); if (deref->deref_type == nir_deref_type_var) register_var_use(deref->var, impl, var_func_table); @@ -89,8 +89,8 @@ nir_lower_global_vars_to_local(nir_shader *shader) var->data.mode = nir_var_function_temp; exec_list_push_tail(&impl->locals, &var->node); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs); + nir_metadata_dominance | + nir_metadata_live_ssa_defs); progress = true; } } diff --git a/src/compiler/nir/nir_lower_goto_ifs.c b/src/compiler/nir/nir_lower_goto_ifs.c index 10e5f01..c3874e4 100644 --- a/src/compiler/nir/nir_lower_goto_ifs.c +++ b/src/compiler/nir/nir_lower_goto_ifs.c @@ -174,8 +174,7 @@ set_path_vars_cond(nir_builder *b, struct path_fork *fork, nir_src condition, } fork = fork->paths[i].fork; break; - } - else { + } else { nir_ssa_def *ssa_def = condition.ssa; assert(ssa_def->bit_size == 1); assert(ssa_def->num_components == 1); @@ -206,17 +205,14 @@ route_to(nir_builder *b, struct routes *routing, nir_block *target) { if (_mesa_set_search(routing->regular.reachable, target)) { set_path_vars(b, routing->regular.fork, target); - } - else if (_mesa_set_search(routing->brk.reachable, target)) { + } else if (_mesa_set_search(routing->brk.reachable, target)) { set_path_vars(b, routing->brk.fork, target); nir_jump(b, nir_jump_break); - } - else if (_mesa_set_search(routing->cont.reachable, target)) { + } else if (_mesa_set_search(routing->cont.reachable, target)) { set_path_vars(b, routing->cont.fork, target); nir_jump(b, nir_jump_continue); - } - else { - assert(!target->successors[0]); /* target is endblock */ + } else { + assert(!target->successors[0]); /* target is endblock */ nir_jump(b, nir_jump_return); } } @@ -363,8 +359,7 @@ fork_condition(nir_builder *b, struct path_fork *fork) nir_ssa_def *ret; if (fork->is_var) { ret = nir_load_var(b, fork->path_var); - } - else + } else ret = fork->path_ssa; return ret; } @@ -382,21 +377,21 @@ loop_routing_end(struct routes *routing, nir_builder *b) assert(routing->cont.reachable == routing->regular.reachable); nir_pop_loop(b, NULL); if (routing->brk.fork && routing->brk.fork->paths[1].reachable == - routing_backup->cont.reachable) { + routing_backup->cont.reachable) { assert(!(routing->brk.fork->is_var && strcmp(routing->brk.fork->path_var->name, "path_continue"))); nir_push_if_src(b, nir_src_for_ssa( - fork_condition(b, routing->brk.fork))); + fork_condition(b, routing->brk.fork))); nir_jump(b, nir_jump_continue); nir_pop_if(b, NULL); routing->brk = routing->brk.fork->paths[0]; } if (routing->brk.fork && routing->brk.fork->paths[1].reachable == - routing_backup->brk.reachable) { + routing_backup->brk.reachable) { assert(!(routing->brk.fork->is_var && strcmp(routing->brk.fork->path_var->name, "path_break"))); nir_push_if_src(b, nir_src_for_ssa( - fork_condition(b, routing->brk.fork))); + fork_condition(b, routing->brk.fork))); nir_jump(b, nir_jump_break); nir_pop_if(b, NULL); routing->brk = routing->brk.fork->paths[0]; @@ -436,7 +431,6 @@ inside_outside(nir_block *block, struct set *loop_heads, struct set *outside, _mesa_set_add(remaining, block->dom_children[i]); } - if (NIR_LOWER_GOTO_IFS_DEBUG) { printf("inside_outside(%u):\n", block->index); printf(" loop_heads = "); @@ -454,7 +448,7 @@ inside_outside(nir_block *block, struct set *loop_heads, struct set *outside, while (remaining->entries && progress) { progress = false; set_foreach(remaining, child_entry) { - nir_block *dom_child = (nir_block *) child_entry->key; + nir_block *dom_child = (nir_block *)child_entry->key; bool can_jump_back = false; set_foreach(dom_child->dom_frontier, entry) { if (entry->key == dom_child) @@ -485,7 +479,7 @@ inside_outside(nir_block *block, struct set *loop_heads, struct set *outside, /* Recurse for each remaining */ set_foreach(remaining, entry) { - inside_outside((nir_block *) entry->key, loop_heads, outside, reach, + inside_outside((nir_block *)entry->key, loop_heads, outside, reach, brk_reachable, mem_ctx); } @@ -583,7 +577,8 @@ handle_irreducible(struct set *remaining, struct strct_lvl *curr_level, struct set *brk_reachable, void *mem_ctx) { nir_block *candidate = (nir_block *) - _mesa_set_next_entry(remaining, NULL)->key; + _mesa_set_next_entry(remaining, NULL) + ->key; struct set *old_candidates = _mesa_pointer_set_create(mem_ctx); while (candidate) { _mesa_set_add(old_candidates, candidate); @@ -594,7 +589,7 @@ handle_irreducible(struct set *remaining, struct strct_lvl *curr_level, candidate = NULL; set_foreach(remaining, entry) { - nir_block *remaining_block = (nir_block *) entry->key; + nir_block *remaining_block = (nir_block *)entry->key; if (!_mesa_set_search(curr_level->blocks, remaining_block) && _mesa_set_intersects(remaining_block->dom_frontier, curr_level->blocks)) { @@ -614,7 +609,7 @@ handle_irreducible(struct set *remaining, struct strct_lvl *curr_level, curr_level->reach = _mesa_pointer_set_create(curr_level); set_foreach(curr_level->blocks, entry) { _mesa_set_remove_key(remaining, entry->key); - inside_outside((nir_block *) entry->key, loop_heads, remaining, + inside_outside((nir_block *)entry->key, loop_heads, remaining, curr_level->reach, brk_reachable, mem_ctx); } _mesa_set_destroy(loop_heads, NULL); @@ -676,9 +671,9 @@ organize_levels(struct list_head *levels, struct set *remaining, while (remaining->entries) { _mesa_set_clear(remaining_frontier, NULL); set_foreach(remaining, entry) { - nir_block *remain_block = (nir_block *) entry->key; + nir_block *remain_block = (nir_block *)entry->key; set_foreach(remain_block->dom_frontier, frontier_entry) { - nir_block *frontier = (nir_block *) frontier_entry->key; + nir_block *frontier = (nir_block *)frontier_entry->key; if (frontier != remain_block) { _mesa_set_add(remaining_frontier, frontier); } @@ -688,7 +683,7 @@ organize_levels(struct list_head *levels, struct set *remaining, struct strct_lvl *curr_level = rzalloc(mem_ctx, struct strct_lvl); curr_level->blocks = _mesa_pointer_set_create(curr_level); set_foreach(remaining, entry) { - nir_block *candidate = (nir_block *) entry->key; + nir_block *candidate = (nir_block *)entry->key; if (!_mesa_set_search(remaining_frontier, candidate)) { _mesa_set_add(curr_level->blocks, candidate); _mesa_set_remove_key(remaining, candidate); @@ -723,7 +718,7 @@ organize_levels(struct list_head *levels, struct set *remaining, } set_foreach(curr_level->blocks, blocks_entry) { - nir_block *level_block = (nir_block *) blocks_entry->key; + nir_block *level_block = (nir_block *)blocks_entry->key; if (prev_frontier == NULL) { prev_frontier = _mesa_set_clone(level_block->dom_frontier, curr_level); @@ -827,9 +822,9 @@ plant_levels(struct list_head *levels, struct routes *routing, if (level->skip_start) { assert(routing->regular.fork); assert(!(routing->regular.fork->is_var && strcmp( - routing->regular.fork->path_var->name, "path_conditional"))); + routing->regular.fork->path_var->name, "path_conditional"))); nir_push_if_src(b, nir_src_for_ssa( - fork_condition(b, routing->regular.fork))); + fork_condition(b, routing->regular.fork))); routing->regular = routing->regular.fork->paths[1]; } struct path in_path = routing->regular; @@ -938,7 +933,7 @@ nir_lower_goto_ifs_impl(nir_function_impl *impl) nir_cf_list cf_list; nir_cf_extract(&cf_list, nir_before_cf_list(&impl->body), - nir_after_cf_list(&impl->body)); + nir_after_cf_list(&impl->body)); /* From this point on, it's structured */ impl->structured = true; @@ -956,7 +951,7 @@ nir_lower_goto_ifs_impl(nir_function_impl *impl) nir_block *start_block = nir_cf_node_as_block(start_node); struct routes *routing = rzalloc(mem_ctx, struct routes); - *routing = (struct routes) { + *routing = (struct routes){ .regular.reachable = end_set, .brk.reachable = empty_set, .cont.reachable = empty_set, diff --git a/src/compiler/nir/nir_lower_gs_intrinsics.c b/src/compiler/nir/nir_lower_gs_intrinsics.c index e8f0fdf..4313d32 100644 --- a/src/compiler/nir/nir_lower_gs_intrinsics.c +++ b/src/compiler/nir/nir_lower_gs_intrinsics.c @@ -278,7 +278,7 @@ append_set_vertex_and_primitive_count(nir_block *end_block, struct state *state) * but before any jump instructions (return). */ set_foreach(end_block->predecessors, entry) { - nir_block *pred = (nir_block *) entry->key; + nir_block *pred = (nir_block *)entry->key; b->cursor = nir_after_block_before_jump(pred); for (unsigned stream = 0; stream < NIR_MAX_XFB_STREAMS; ++stream) { @@ -293,8 +293,8 @@ append_set_vertex_and_primitive_count(nir_block *end_block, struct state *state) /* Inactive stream: vertex count is 0, primitive count is 0 or undef. */ vtx_cnt = nir_imm_int(b, 0); prim_cnt = state->count_prims || state->is_points - ? nir_imm_int(b, 0) - : nir_ssa_undef(b, 1, 32); + ? nir_imm_int(b, 0) + : nir_ssa_undef(b, 1, 32); } else { if (state->overwrite_incomplete) overwrite_incomplete_primitives(state, stream); @@ -328,8 +328,7 @@ static bool a_block_needs_set_vertex_and_primitive_count(nir_block *end_block, bool per_stream) { set_foreach(end_block->predecessors, entry) { - nir_block *pred = (nir_block *) entry->key; - + nir_block *pred = (nir_block *)entry->key; for (unsigned stream = 0; stream < NIR_MAX_XFB_STREAMS; ++stream) { /* When it's not per-stream, we only need to write one variable. */ diff --git a/src/compiler/nir/nir_lower_idiv.c b/src/compiler/nir/nir_lower_idiv.c index ccda7d4..f7b8df4 100644 --- a/src/compiler/nir/nir_lower_idiv.c +++ b/src/compiler/nir/nir_lower_idiv.c @@ -92,8 +92,8 @@ emit_idiv(nir_builder *bld, nir_ssa_def *numer, nir_ssa_def *denom, nir_op op) static nir_ssa_def * convert_instr_small(nir_builder *b, nir_op op, - nir_ssa_def *numer, nir_ssa_def *denom, - const nir_lower_idiv_options *options) + nir_ssa_def *numer, nir_ssa_def *denom, + const nir_lower_idiv_options *options) { unsigned sz = numer->bit_size; nir_alu_type int_type = nir_op_infos[op].output_type | sz; @@ -121,7 +121,7 @@ convert_instr_small(nir_builder *b, nir_op op, if (op == nir_op_imod) { nir_ssa_def *zero = nir_imm_zero(b, 1, sz); nir_ssa_def *diff_sign = - nir_ine(b, nir_ige(b, numer, zero), nir_ige(b, denom, zero)); + nir_ine(b, nir_ige(b, numer, zero), nir_ige(b, denom, zero)); nir_ssa_def *adjust = nir_iand(b, diff_sign, nir_ine(b, res, zero)); res = nir_iadd(b, res, nir_bcsel(b, adjust, denom, zero)); @@ -176,7 +176,7 @@ bool nir_lower_idiv(nir_shader *shader, const nir_lower_idiv_options *options) { return nir_shader_lower_instructions(shader, - inst_is_idiv, - lower_idiv, - (void *)options); + inst_is_idiv, + lower_idiv, + (void *)options); } diff --git a/src/compiler/nir/nir_lower_image.c b/src/compiler/nir/nir_lower_image.c index 0b3f112..e66e91f 100644 --- a/src/compiler/nir/nir_lower_image.c +++ b/src/compiler/nir/nir_lower_image.c @@ -222,5 +222,6 @@ nir_lower_image(nir_shader *nir, const nir_lower_image_options *options) { return nir_shader_instructions_pass(nir, lower_image_instr, nir_metadata_block_index | - nir_metadata_dominance, (void*)options); + nir_metadata_dominance, + (void *)options); } diff --git a/src/compiler/nir/nir_lower_image_atomics_to_global.c b/src/compiler/nir/nir_lower_image_atomics_to_global.c index 7408c25..035b761 100644 --- a/src/compiler/nir/nir_lower_image_atomics_to_global.c +++ b/src/compiler/nir/nir_lower_image_atomics_to_global.c @@ -24,11 +24,11 @@ lower(nir_builder *b, nir_instr *instr, UNUSED void *_) nir_intrinsic_op address_op; bool swap; -#define CASE(storage) \ - case nir_intrinsic_##storage##_atomic: \ - case nir_intrinsic_##storage##_atomic_swap: \ - address_op = nir_intrinsic_##storage##_texel_address; \ - swap = intr->intrinsic == nir_intrinsic_##storage##_atomic_swap; \ +#define CASE(storage) \ + case nir_intrinsic_##storage##_atomic: \ + case nir_intrinsic_##storage##_atomic_swap: \ + address_op = nir_intrinsic_##storage##_texel_address; \ + swap = intr->intrinsic == nir_intrinsic_##storage##_atomic_swap; \ break; switch (intr->intrinsic) { @@ -103,6 +103,6 @@ nir_lower_image_atomics_to_global(nir_shader *shader) { return nir_shader_instructions_pass(shader, lower, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_input_attachments.c b/src/compiler/nir/nir_lower_input_attachments.c index f827bb9..1ed521c 100644 --- a/src/compiler/nir/nir_lower_input_attachments.c +++ b/src/compiler/nir/nir_lower_input_attachments.c @@ -36,10 +36,8 @@ load_frag_coord(nir_builder *b, nir_deref_instr *deref, nir_ssa_def *unscaled_frag_coord = nir_load_frag_coord_unscaled_ir3(b); if (deref->deref_type == nir_deref_type_array) { nir_ssa_def *unscaled = - nir_i2b(b, nir_iand(b, nir_ishr(b, - nir_imm_int(b, options->unscaled_input_attachment_ir3 >> base), - deref->arr.index.ssa), - nir_imm_int(b, 1))); + nir_i2b(b, nir_iand(b, nir_ishr(b, nir_imm_int(b, options->unscaled_input_attachment_ir3 >> base), deref->arr.index.ssa), + nir_imm_int(b, 1))); frag_coord = nir_bcsel(b, unscaled, unscaled_frag_coord, frag_coord); } else { assert(deref->deref_type == nir_deref_type_var); @@ -75,8 +73,7 @@ load_layer_id(nir_builder *b, const nir_input_attachment_options *options) return nir_load_layer_id(b); } - gl_varying_slot slot = options->use_view_id_for_layer ? - VARYING_SLOT_VIEW_INDEX : VARYING_SLOT_LAYER; + gl_varying_slot slot = options->use_view_id_for_layer ? VARYING_SLOT_VIEW_INDEX : VARYING_SLOT_LAYER; nir_variable *layer_id = nir_get_variable_with_location(b->shader, nir_var_shader_in, slot, glsl_int_type()); layer_id->data.interpolation = INTERP_MODE_FLAT; @@ -173,7 +170,7 @@ try_lower_input_texop(nir_builder *b, nir_tex_instr *tex, nir_ssa_def *layer = load_layer_id(b, options); nir_ssa_def *coord = nir_vec3(b, nir_channel(b, frag_coord, 0), - nir_channel(b, frag_coord, 1), layer); + nir_channel(b, frag_coord, 1), layer); tex->coord_components = 3; @@ -220,6 +217,6 @@ nir_lower_input_attachments(nir_shader *shader, return nir_shader_instructions_pass(shader, lower_input_attachments_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, (void *)options); } diff --git a/src/compiler/nir/nir_lower_int64.c b/src/compiler/nir/nir_lower_int64.c index edbba70..d51d0c6 100644 --- a/src/compiler/nir/nir_lower_int64.c +++ b/src/compiler/nir/nir_lower_int64.c @@ -24,22 +24,23 @@ #include "nir.h" #include "nir_builder.h" -#define COND_LOWER_OP(b, name, ...) \ - (b->shader->options->lower_int64_options & \ - nir_lower_int64_op_to_options_mask(nir_op_##name)) ? \ - lower_##name##64(b, __VA_ARGS__) : nir_##name(b, __VA_ARGS__) - -#define COND_LOWER_CMP(b, name, ...) \ - (b->shader->options->lower_int64_options & \ - nir_lower_int64_op_to_options_mask(nir_op_##name)) ? \ - lower_int64_compare(b, nir_op_##name, __VA_ARGS__) : \ - nir_##name(b, __VA_ARGS__) - -#define COND_LOWER_CAST(b, name, ...) \ - (b->shader->options->lower_int64_options & \ - nir_lower_int64_op_to_options_mask(nir_op_##name)) ? \ - lower_##name(b, __VA_ARGS__) : \ - nir_##name(b, __VA_ARGS__) +#define COND_LOWER_OP(b, name, ...) \ + (b->shader->options->lower_int64_options & \ + nir_lower_int64_op_to_options_mask(nir_op_##name)) \ + ? lower_##name##64(b, __VA_ARGS__) \ + : nir_##name(b, __VA_ARGS__) + +#define COND_LOWER_CMP(b, name, ...) \ + (b->shader->options->lower_int64_options & \ + nir_lower_int64_op_to_options_mask(nir_op_##name)) \ + ? lower_int64_compare(b, nir_op_##name, __VA_ARGS__) \ + : nir_##name(b, __VA_ARGS__) + +#define COND_LOWER_CAST(b, name, ...) \ + (b->shader->options->lower_int64_options & \ + nir_lower_int64_op_to_options_mask(nir_op_##name)) \ + ? lower_##name(b, __VA_ARGS__) \ + : nir_##name(b, __VA_ARGS__) static nir_ssa_def * lower_b2i64(nir_builder *b, nir_ssa_def *x) @@ -59,7 +60,6 @@ lower_i2i16(nir_builder *b, nir_ssa_def *x) return nir_i2i16(b, nir_unpack_64_2x32_split_x(b, x)); } - static nir_ssa_def * lower_i2i32(nir_builder *b, nir_ssa_def *x) { @@ -107,7 +107,7 @@ lower_bcsel64(nir_builder *b, nir_ssa_def *cond, nir_ssa_def *x, nir_ssa_def *y) nir_ssa_def *y_hi = nir_unpack_64_2x32_split_y(b, y); return nir_pack_64_2x32_split(b, nir_bcsel(b, cond, x_lo, y_lo), - nir_bcsel(b, cond, x_hi, y_hi)); + nir_bcsel(b, cond, x_hi, y_hi)); } static nir_ssa_def * @@ -128,7 +128,7 @@ lower_iand64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) nir_ssa_def *y_hi = nir_unpack_64_2x32_split_y(b, y); return nir_pack_64_2x32_split(b, nir_iand(b, x_lo, y_lo), - nir_iand(b, x_hi, y_hi)); + nir_iand(b, x_hi, y_hi)); } static nir_ssa_def * @@ -140,7 +140,7 @@ lower_ior64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) nir_ssa_def *y_hi = nir_unpack_64_2x32_split_y(b, y); return nir_pack_64_2x32_split(b, nir_ior(b, x_lo, y_lo), - nir_ior(b, x_hi, y_hi)); + nir_ior(b, x_hi, y_hi)); } static nir_ssa_def * @@ -152,7 +152,7 @@ lower_ixor64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) nir_ssa_def *y_hi = nir_unpack_64_2x32_split_y(b, y); return nir_pack_64_2x32_split(b, nir_ixor(b, x_lo, y_lo), - nir_ixor(b, x_hi, y_hi)); + nir_ixor(b, x_hi, y_hi)); } static nir_ssa_def * @@ -190,14 +190,14 @@ lower_ishl64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) nir_ssa_def *res_if_lt_32 = nir_pack_64_2x32_split(b, lo_shifted, - nir_ior(b, hi_shifted, lo_shifted_hi)); + nir_ior(b, hi_shifted, lo_shifted_hi)); nir_ssa_def *res_if_ge_32 = nir_pack_64_2x32_split(b, nir_imm_int(b, 0), - nir_ishl(b, x_lo, reverse_count)); + nir_ishl(b, x_lo, reverse_count)); return nir_bcsel(b, nir_ieq_imm(b, y, 0), x, nir_bcsel(b, nir_uge_imm(b, y, 32), - res_if_ge_32, res_if_lt_32)); + res_if_ge_32, res_if_lt_32)); } static nir_ssa_def * @@ -237,14 +237,14 @@ lower_ishr64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) nir_ssa_def *res_if_lt_32 = nir_pack_64_2x32_split(b, nir_ior(b, lo_shifted, hi_shifted_lo), - hi_shifted); + hi_shifted); nir_ssa_def *res_if_ge_32 = nir_pack_64_2x32_split(b, nir_ishr(b, x_hi, reverse_count), - nir_ishr_imm(b, x_hi, 31)); + nir_ishr_imm(b, x_hi, 31)); return nir_bcsel(b, nir_ieq_imm(b, y, 0), x, nir_bcsel(b, nir_uge_imm(b, y, 32), - res_if_ge_32, res_if_lt_32)); + res_if_ge_32, res_if_lt_32)); } static nir_ssa_def * @@ -283,14 +283,14 @@ lower_ushr64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) nir_ssa_def *res_if_lt_32 = nir_pack_64_2x32_split(b, nir_ior(b, lo_shifted, hi_shifted_lo), - hi_shifted); + hi_shifted); nir_ssa_def *res_if_ge_32 = nir_pack_64_2x32_split(b, nir_ushr(b, x_hi, reverse_count), - nir_imm_int(b, 0)); + nir_imm_int(b, 0)); return nir_bcsel(b, nir_ieq_imm(b, y, 0), x, nir_bcsel(b, nir_uge_imm(b, y, 32), - res_if_ge_32, res_if_lt_32)); + res_if_ge_32, res_if_lt_32)); } static nir_ssa_def * @@ -356,12 +356,12 @@ lower_int64_compare(nir_builder *b, nir_op op, nir_ssa_def *x, nir_ssa_def *y) return nir_ior(b, nir_ine(b, x_hi, y_hi), nir_ine(b, x_lo, y_lo)); case nir_op_ult: return nir_ior(b, nir_ult(b, x_hi, y_hi), - nir_iand(b, nir_ieq(b, x_hi, y_hi), - nir_ult(b, x_lo, y_lo))); + nir_iand(b, nir_ieq(b, x_hi, y_hi), + nir_ult(b, x_lo, y_lo))); case nir_op_ilt: return nir_ior(b, nir_ilt(b, x_hi, y_hi), - nir_iand(b, nir_ieq(b, x_hi, y_hi), - nir_ult(b, x_lo, y_lo))); + nir_iand(b, nir_ieq(b, x_hi, y_hi), + nir_ult(b, x_lo, y_lo))); break; case nir_op_uge: /* Lower as !(x < y) in the hopes of better CSE */ @@ -418,8 +418,8 @@ lower_imul64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y) nir_ssa_def *mul_lo = nir_umul_2x32_64(b, x_lo, y_lo); nir_ssa_def *res_hi = nir_iadd(b, nir_unpack_64_2x32_split_y(b, mul_lo), - nir_iadd(b, nir_imul(b, x_lo, y_hi), - nir_imul(b, x_hi, y_lo))); + nir_iadd(b, nir_imul(b, x_lo, y_hi), + nir_imul(b, x_hi, y_lo))); return nir_pack_64_2x32_split(b, nir_unpack_64_2x32_split_x(b, mul_lo), res_hi); @@ -446,7 +446,9 @@ lower_mul_high64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, y32[2] = y32[3] = nir_imm_int(b, 0); } - nir_ssa_def *res[8] = { NULL, }; + nir_ssa_def *res[8] = { + NULL, + }; /* Yes, the following generates a pile of code. However, we throw res[0] * and res[1] away in the end and, if we're in the umul case, four of our @@ -541,13 +543,13 @@ lower_udiv64_mod64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d, nir_ssa_def *new_n_hi = nir_isub(b, n_hi, d_shift); nir_ssa_def *new_q_hi = nir_ior_imm(b, q_hi, 1ull << i); nir_ssa_def *cond = nir_iand(b, need_high_div, - nir_uge(b, n_hi, d_shift)); + nir_uge(b, n_hi, d_shift)); if (i != 0) { /* log2_d_lo is always <= 31, so we don't need to bother with it * in the last iteration. */ cond = nir_iand(b, cond, - nir_ile_imm(b, log2_d_lo, 31 - i)); + nir_ile_imm(b, log2_d_lo, 31 - i)); } n_hi = nir_bcsel(b, cond, new_n_hi, n_hi); q_hi = nir_bcsel(b, cond, new_q_hi, q_hi); @@ -576,7 +578,7 @@ lower_udiv64_mod64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d, * in the last iteration. */ cond = nir_iand(b, cond, - nir_ile_imm(b, log2_denom, 31 - i)); + nir_ile_imm(b, log2_denom, 31 - i)); } n = nir_bcsel(b, cond, new_n, n); q_lo = nir_bcsel(b, cond, new_q_lo, q_lo); @@ -601,7 +603,7 @@ lower_idiv64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d) nir_ssa_def *d_hi = nir_unpack_64_2x32_split_y(b, d); nir_ssa_def *negate = nir_ine(b, nir_ilt_imm(b, n_hi, 0), - nir_ilt_imm(b, d_hi, 0)); + nir_ilt_imm(b, d_hi, 0)); nir_ssa_def *q, *r; lower_udiv64_mod64(b, nir_iabs(b, n), nir_iabs(b, d), &q, &r); return nir_bcsel(b, negate, nir_ineg(b, q), q); @@ -629,8 +631,8 @@ lower_imod64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d) nir_ssa_def *rem = nir_bcsel(b, n_is_neg, nir_ineg(b, r), r); return nir_bcsel(b, nir_ieq_imm(b, r, 0), nir_imm_int64(b, 0), - nir_bcsel(b, nir_ieq(b, n_is_neg, d_is_neg), rem, - nir_iadd(b, rem, d))); + nir_bcsel(b, nir_ieq(b, n_is_neg, d_is_neg), rem, + nir_iadd(b, rem, d))); } static nir_ssa_def * @@ -658,12 +660,12 @@ lower_extract(nir_builder *b, nir_op op, nir_ssa_def *x, nir_ssa_def *c) nir_ssa_def *extract32; if (chunk < num_chunks_in_32) { extract32 = nir_build_alu(b, op, nir_unpack_64_2x32_split_x(b, x), - nir_imm_int(b, chunk), - NULL, NULL); + nir_imm_int(b, chunk), + NULL, NULL); } else { extract32 = nir_build_alu(b, op, nir_unpack_64_2x32_split_y(b, x), - nir_imm_int(b, chunk - num_chunks_in_32), - NULL, NULL); + nir_imm_int(b, chunk - num_chunks_in_32), + NULL, NULL); } if (op == nir_op_extract_i8 || op == nir_op_extract_i16) @@ -747,7 +749,7 @@ lower_2f(nir_builder *b, nir_ssa_def *x, unsigned dest_bit_size, nir_ssa_def *discard = nir_imax(b, nir_iadd_imm(b, exp, -significand_bits), - nir_imm_int(b, 0)); + nir_imm_int(b, 0)); nir_ssa_def *significand = COND_LOWER_OP(b, ushr, x, discard); if (significand_bits < 32) significand = COND_LOWER_CAST(b, u2u32, significand); @@ -767,7 +769,7 @@ lower_2f(nir_builder *b, nir_ssa_def *x, unsigned dest_bit_size, nir_ssa_def *halfway = nir_iand(b, COND_LOWER_CMP(b, ieq, rem, half), nir_ine_imm(b, discard, 0)); nir_ssa_def *is_odd = COND_LOWER_CMP(b, ine, nir_imm_int64(b, 0), - COND_LOWER_OP(b, iand, x, lsb_mask)); + COND_LOWER_OP(b, iand, x, lsb_mask)); nir_ssa_def *round_up = nir_ior(b, COND_LOWER_CMP(b, ilt, half, rem), nir_iand(b, halfway, is_odd)); if (significand_bits >= 32) @@ -1195,7 +1197,7 @@ static nir_ssa_def * lower_vote_ieq(nir_builder *b, nir_ssa_def *x) { return nir_iand(b, build_vote_ieq(b, nir_unpack_64_2x32_split_x(b, x)), - build_vote_ieq(b, nir_unpack_64_2x32_split_y(b, x))); + build_vote_ieq(b, nir_unpack_64_2x32_split_y(b, x))); } static nir_ssa_def * @@ -1220,8 +1222,7 @@ static nir_ssa_def * lower_scan_iadd64(nir_builder *b, const nir_intrinsic_instr *intrin) { unsigned cluster_size = - intrin->intrinsic == nir_intrinsic_reduce ? - nir_intrinsic_cluster_size(intrin) : 0; + intrin->intrinsic == nir_intrinsic_reduce ? nir_intrinsic_cluster_size(intrin) : 0; /* Split it into three chunks of no more than 24 bits each. With 8 bits * of headroom, we're guaranteed that there will never be overflow in the @@ -1234,19 +1235,19 @@ lower_scan_iadd64(nir_builder *b, const nir_intrinsic_instr *intrin) nir_u2u32(b, nir_iand_imm(b, x, 0xffffff)); nir_ssa_def *x_mid = nir_u2u32(b, nir_iand_imm(b, nir_ushr_imm(b, x, 24), - 0xffffff)); + 0xffffff)); nir_ssa_def *x_hi = nir_u2u32(b, nir_ushr_imm(b, x, 48)); nir_ssa_def *scan_low = build_scan_intrinsic(b, intrin->intrinsic, nir_op_iadd, - cluster_size, x_low); + cluster_size, x_low); nir_ssa_def *scan_mid = build_scan_intrinsic(b, intrin->intrinsic, nir_op_iadd, - cluster_size, x_mid); + cluster_size, x_mid); nir_ssa_def *scan_hi = build_scan_intrinsic(b, intrin->intrinsic, nir_op_iadd, - cluster_size, x_hi); + cluster_size, x_hi); scan_low = nir_u2u64(b, scan_low); scan_mid = nir_ishl_imm(b, nir_u2u64(b, scan_mid), 24); diff --git a/src/compiler/nir/nir_lower_int_to_float.c b/src/compiler/nir/nir_lower_int_to_float.c index 2d7ec29..a8136f9 100644 --- a/src/compiler/nir/nir_lower_int_to_float.c +++ b/src/compiler/nir/nir_lower_int_to_float.c @@ -107,9 +107,15 @@ lower_alu_instr(nir_builder *b, nir_alu_instr *alu) /* These we expect to have integers but the opcode doesn't change */ break; - case nir_op_b2i32: alu->op = nir_op_b2f32; break; - case nir_op_i2f32: alu->op = nir_op_mov; break; - case nir_op_u2f32: alu->op = nir_op_mov; break; + case nir_op_b2i32: + alu->op = nir_op_b2f32; + break; + case nir_op_i2f32: + alu->op = nir_op_mov; + break; + case nir_op_u2f32: + alu->op = nir_op_mov; + break; case nir_op_f2i32: { alu->op = nir_op_ftrunc; @@ -138,18 +144,38 @@ lower_alu_instr(nir_builder *b, nir_alu_instr *alu) break; } - case nir_op_f2u32: alu->op = nir_op_ffloor; break; + case nir_op_f2u32: + alu->op = nir_op_ffloor; + break; - case nir_op_ilt: alu->op = nir_op_flt; break; - case nir_op_ige: alu->op = nir_op_fge; break; - case nir_op_ieq: alu->op = nir_op_feq; break; - case nir_op_ine: alu->op = nir_op_fneu; break; - case nir_op_ult: alu->op = nir_op_flt; break; - case nir_op_uge: alu->op = nir_op_fge; break; + case nir_op_ilt: + alu->op = nir_op_flt; + break; + case nir_op_ige: + alu->op = nir_op_fge; + break; + case nir_op_ieq: + alu->op = nir_op_feq; + break; + case nir_op_ine: + alu->op = nir_op_fneu; + break; + case nir_op_ult: + alu->op = nir_op_flt; + break; + case nir_op_uge: + alu->op = nir_op_fge; + break; - case nir_op_iadd: alu->op = nir_op_fadd; break; - case nir_op_isub: alu->op = nir_op_fsub; break; - case nir_op_imul: alu->op = nir_op_fmul; break; + case nir_op_iadd: + alu->op = nir_op_fadd; + break; + case nir_op_isub: + alu->op = nir_op_fsub; + break; + case nir_op_imul: + alu->op = nir_op_fmul; + break; case nir_op_idiv: { nir_ssa_def *x = nir_ssa_for_alu_src(b, alu, 0); @@ -164,22 +190,50 @@ lower_alu_instr(nir_builder *b, nir_alu_instr *alu) break; } - case nir_op_iabs: alu->op = nir_op_fabs; break; - case nir_op_ineg: alu->op = nir_op_fneg; break; - case nir_op_imax: alu->op = nir_op_fmax; break; - case nir_op_imin: alu->op = nir_op_fmin; break; - case nir_op_umax: alu->op = nir_op_fmax; break; - case nir_op_umin: alu->op = nir_op_fmin; break; + case nir_op_iabs: + alu->op = nir_op_fabs; + break; + case nir_op_ineg: + alu->op = nir_op_fneg; + break; + case nir_op_imax: + alu->op = nir_op_fmax; + break; + case nir_op_imin: + alu->op = nir_op_fmin; + break; + case nir_op_umax: + alu->op = nir_op_fmax; + break; + case nir_op_umin: + alu->op = nir_op_fmin; + break; - case nir_op_ball_iequal2: alu->op = nir_op_ball_fequal2; break; - case nir_op_ball_iequal3: alu->op = nir_op_ball_fequal3; break; - case nir_op_ball_iequal4: alu->op = nir_op_ball_fequal4; break; - case nir_op_bany_inequal2: alu->op = nir_op_bany_fnequal2; break; - case nir_op_bany_inequal3: alu->op = nir_op_bany_fnequal3; break; - case nir_op_bany_inequal4: alu->op = nir_op_bany_fnequal4; break; + case nir_op_ball_iequal2: + alu->op = nir_op_ball_fequal2; + break; + case nir_op_ball_iequal3: + alu->op = nir_op_ball_fequal3; + break; + case nir_op_ball_iequal4: + alu->op = nir_op_ball_fequal4; + break; + case nir_op_bany_inequal2: + alu->op = nir_op_bany_fnequal2; + break; + case nir_op_bany_inequal3: + alu->op = nir_op_bany_fnequal3; + break; + case nir_op_bany_inequal4: + alu->op = nir_op_bany_fnequal4; + break; - case nir_op_i32csel_gt: alu->op = nir_op_fcsel_gt; break; - case nir_op_i32csel_ge: alu->op = nir_op_fcsel_ge; break; + case nir_op_i32csel_gt: + alu->op = nir_op_fcsel_gt; + break; + case nir_op_i32csel_ge: + alu->op = nir_op_fcsel_ge; + break; default: assert(nir_alu_type_get_base_type(info->output_type) != nir_type_int && @@ -246,7 +300,7 @@ nir_lower_int_to_float_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_interpolation.c b/src/compiler/nir/nir_lower_interpolation.c index 3a85448..1678d93 100644 --- a/src/compiler/nir/nir_lower_interpolation.c +++ b/src/compiler/nir/nir_lower_interpolation.c @@ -38,7 +38,7 @@ static bool nir_lower_interpolation_instr(nir_builder *b, nir_instr *instr, void *cb_data) { nir_lower_interpolation_options options = - *(nir_lower_interpolation_options *)cb_data; + *(nir_lower_interpolation_options *)cb_data; if (instr->type != nir_instr_type_intrinsic) return false; @@ -107,11 +107,11 @@ nir_lower_interpolation_instr(nir_builder *b, nir_instr *instr, void *cb_data) nir_ssa_def *val; val = nir_ffma(b, nir_channel(b, bary, 1), - nir_channel(b, iid, 1), - nir_channel(b, iid, 0)); + nir_channel(b, iid, 1), + nir_channel(b, iid, 0)); val = nir_ffma(b, nir_channel(b, bary, 0), - nir_channel(b, iid, 2), - val); + nir_channel(b, iid, 2), + val); comps[i] = val; } @@ -126,6 +126,6 @@ nir_lower_interpolation(nir_shader *shader, nir_lower_interpolation_options opti { return nir_shader_instructions_pass(shader, nir_lower_interpolation_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &options); } diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 38ed2a8..0532888 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -45,8 +45,10 @@ static nir_intrinsic_op ssbo_atomic_for_deref(nir_intrinsic_op deref_op) { switch (deref_op) { - case nir_intrinsic_deref_atomic: return nir_intrinsic_ssbo_atomic; - case nir_intrinsic_deref_atomic_swap: return nir_intrinsic_ssbo_atomic_swap; + case nir_intrinsic_deref_atomic: + return nir_intrinsic_ssbo_atomic; + case nir_intrinsic_deref_atomic_swap: + return nir_intrinsic_ssbo_atomic_swap; default: unreachable("Invalid SSBO atomic"); } @@ -78,8 +80,10 @@ static nir_intrinsic_op shared_atomic_for_deref(nir_intrinsic_op deref_op) { switch (deref_op) { - case nir_intrinsic_deref_atomic: return nir_intrinsic_shared_atomic; - case nir_intrinsic_deref_atomic_swap: return nir_intrinsic_shared_atomic_swap; + case nir_intrinsic_deref_atomic: + return nir_intrinsic_shared_atomic; + case nir_intrinsic_deref_atomic_swap: + return nir_intrinsic_shared_atomic_swap; default: unreachable("Invalid shared atomic"); } @@ -154,8 +158,9 @@ nir_is_arrayed_io(const nir_variable *var, gl_shader_stage stage) return false; } -static unsigned get_number_of_slots(struct lower_io_state *state, - const nir_variable *var) +static unsigned +get_number_of_slots(struct lower_io_state *state, + const nir_variable *var) { const struct glsl_type *type = var->type; @@ -280,14 +285,12 @@ emit_load(struct lower_io_state *state, op = nir_intrinsic_load_interpolated_input; } } else { - op = array_index ? nir_intrinsic_load_per_vertex_input : - nir_intrinsic_load_input; + op = array_index ? nir_intrinsic_load_per_vertex_input : nir_intrinsic_load_input; } break; case nir_var_shader_out: - op = !array_index ? nir_intrinsic_load_output : - var->data.per_primitive ? nir_intrinsic_load_per_primitive_output : - nir_intrinsic_load_per_vertex_output; + op = !array_index ? nir_intrinsic_load_output : var->data.per_primitive ? nir_intrinsic_load_per_primitive_output + : nir_intrinsic_load_per_vertex_output; break; case nir_var_uniform: op = nir_intrinsic_load_uniform; @@ -314,7 +317,7 @@ emit_load(struct lower_io_state *state, nir_intrinsic_set_dest_type(load, dest_type); if (load->intrinsic != nir_intrinsic_load_uniform) { - nir_io_semantics semantics = {0}; + nir_io_semantics semantics = { 0 }; semantics.location = var->data.location; semantics.num_slots = get_number_of_slots(state, var); semantics.fb_fetch_output = var->data.fb_fetch_output; @@ -400,9 +403,8 @@ emit_store(struct lower_io_state *state, nir_ssa_def *data, assert(var->data.mode == nir_var_shader_out); nir_intrinsic_op op = - !array_index ? nir_intrinsic_store_output : - var->data.per_primitive ? nir_intrinsic_store_per_primitive_output : - nir_intrinsic_store_per_vertex_output; + !array_index ? nir_intrinsic_store_output : var->data.per_primitive ? nir_intrinsic_store_per_primitive_output + : nir_intrinsic_store_per_vertex_output; nir_intrinsic_instr *store = nir_intrinsic_instr_create(state->builder.shader, op); @@ -436,7 +438,7 @@ emit_store(struct lower_io_state *state, nir_ssa_def *data, } } - nir_io_semantics semantics = {0}; + nir_io_semantics semantics = { 0 }; semantics.location = var->data.location; semantics.num_slots = get_number_of_slots(state, var); semantics.dual_source_blend_index = var->data.index; @@ -565,7 +567,7 @@ lower_interpolate_at(nir_intrinsic_instr *intrin, struct lower_io_state *state, nir_builder_instr_insert(b, &bary_setup->instr); - nir_io_semantics semantics = {0}; + nir_io_semantics semantics = { 0 }; semantics.location = var->data.location; semantics.num_slots = get_number_of_slots(state, var); semantics.medium_precision = @@ -636,30 +638,30 @@ nir_lower_io_block(nir_block *block, var->data.mode == nir_var_shader_out || var->data.bindless; - if (nir_deref_instr_is_known_out_of_bounds(deref)) { - /* Section 5.11 (Out-of-Bounds Accesses) of the GLSL 4.60 spec says: - * - * In the subsections described above for array, vector, matrix and - * structure accesses, any out-of-bounds access produced undefined - * behavior.... - * Out-of-bounds reads return undefined values, which - * include values from other variables of the active program or zero. - * Out-of-bounds writes may be discarded or overwrite - * other variables of the active program. - * - * GL_KHR_robustness and GL_ARB_robustness encourage us to return zero - * for reads. - * - * Otherwise get_io_offset would return out-of-bound offset which may - * result in out-of-bound loading/storing of inputs/outputs, - * that could cause issues in drivers down the line. - */ + if (nir_deref_instr_is_known_out_of_bounds(deref)) { + /* Section 5.11 (Out-of-Bounds Accesses) of the GLSL 4.60 spec says: + * + * In the subsections described above for array, vector, matrix and + * structure accesses, any out-of-bounds access produced undefined + * behavior.... + * Out-of-bounds reads return undefined values, which + * include values from other variables of the active program or zero. + * Out-of-bounds writes may be discarded or overwrite + * other variables of the active program. + * + * GL_KHR_robustness and GL_ARB_robustness encourage us to return zero + * for reads. + * + * Otherwise get_io_offset would return out-of-bound offset which may + * result in out-of-bound loading/storing of inputs/outputs, + * that could cause issues in drivers down the line. + */ if (intrin->intrinsic != nir_intrinsic_store_deref) { nir_ssa_def *zero = nir_imm_zero(b, intrin->dest.ssa.num_components, - intrin->dest.ssa.bit_size); + intrin->dest.ssa.bit_size); nir_ssa_def_rewrite_uses(&intrin->dest.ssa, - zero); + zero); } nir_instr_remove(&intrin->instr); @@ -939,7 +941,7 @@ build_addr_for_var(nir_builder *b, nir_variable *var, case nir_var_mem_global: return nir_iadd_imm(b, nir_load_global_base_ptr(b, num_comps, bit_size), - var->data.driver_location); + var->data.driver_location); default: unreachable("Unsupported variable mode"); @@ -971,7 +973,7 @@ build_runtime_addr_mode_check(nir_builder *b, nir_ssa_def *addr, case nir_var_mem_global: return nir_ior(b, nir_ieq_imm(b, mode_enum, 0x0), - nir_ieq_imm(b, mode_enum, 0x3)); + nir_ieq_imm(b, mode_enum, 0x3)); default: unreachable("Invalid mode check intrinsic"); @@ -987,18 +989,30 @@ unsigned nir_address_format_bit_size(nir_address_format addr_format) { switch (addr_format) { - case nir_address_format_32bit_global: return 32; - case nir_address_format_2x32bit_global: return 32; - case nir_address_format_64bit_global: return 64; - case nir_address_format_64bit_global_32bit_offset: return 32; - case nir_address_format_64bit_bounded_global: return 32; - case nir_address_format_32bit_index_offset: return 32; - case nir_address_format_32bit_index_offset_pack64: return 64; - case nir_address_format_vec2_index_32bit_offset: return 32; - case nir_address_format_62bit_generic: return 64; - case nir_address_format_32bit_offset: return 32; - case nir_address_format_32bit_offset_as_64bit: return 64; - case nir_address_format_logical: return 32; + case nir_address_format_32bit_global: + return 32; + case nir_address_format_2x32bit_global: + return 32; + case nir_address_format_64bit_global: + return 64; + case nir_address_format_64bit_global_32bit_offset: + return 32; + case nir_address_format_64bit_bounded_global: + return 32; + case nir_address_format_32bit_index_offset: + return 32; + case nir_address_format_32bit_index_offset_pack64: + return 64; + case nir_address_format_vec2_index_32bit_offset: + return 32; + case nir_address_format_62bit_generic: + return 64; + case nir_address_format_32bit_offset: + return 32; + case nir_address_format_32bit_offset_as_64bit: + return 64; + case nir_address_format_logical: + return 32; } unreachable("Invalid address format"); } @@ -1007,18 +1021,30 @@ unsigned nir_address_format_num_components(nir_address_format addr_format) { switch (addr_format) { - case nir_address_format_32bit_global: return 1; - case nir_address_format_2x32bit_global: return 2; - case nir_address_format_64bit_global: return 1; - case nir_address_format_64bit_global_32bit_offset: return 4; - case nir_address_format_64bit_bounded_global: return 4; - case nir_address_format_32bit_index_offset: return 2; - case nir_address_format_32bit_index_offset_pack64: return 1; - case nir_address_format_vec2_index_32bit_offset: return 3; - case nir_address_format_62bit_generic: return 1; - case nir_address_format_32bit_offset: return 1; - case nir_address_format_32bit_offset_as_64bit: return 1; - case nir_address_format_logical: return 1; + case nir_address_format_32bit_global: + return 1; + case nir_address_format_2x32bit_global: + return 2; + case nir_address_format_64bit_global: + return 1; + case nir_address_format_64bit_global_32bit_offset: + return 4; + case nir_address_format_64bit_bounded_global: + return 4; + case nir_address_format_32bit_index_offset: + return 2; + case nir_address_format_32bit_index_offset_pack64: + return 1; + case nir_address_format_vec2_index_32bit_offset: + return 3; + case nir_address_format_62bit_generic: + return 1; + case nir_address_format_32bit_offset: + return 1; + case nir_address_format_32bit_offset_as_64bit: + return 1; + case nir_address_format_logical: + return 1; } unreachable("Invalid address format"); } @@ -1036,7 +1062,8 @@ addr_to_index(nir_builder *b, nir_ssa_def *addr, case nir_address_format_vec2_index_32bit_offset: assert(addr->num_components == 3); return nir_trim_vector(b, addr, 2); - default: unreachable("Invalid address format"); + default: + unreachable("Invalid address format"); } } @@ -1108,7 +1135,7 @@ addr_to_global(nir_builder *b, nir_ssa_def *addr, case nir_address_format_64bit_bounded_global: assert(addr->num_components == 4); return nir_iadd(b, nir_pack_64_2x32(b, nir_trim_vector(b, addr, 2)), - nir_u2u64(b, nir_channel(b, addr, 3))); + nir_u2u64(b, nir_channel(b, addr, 3))); case nir_address_format_32bit_index_offset: case nir_address_format_32bit_index_offset_pack64: @@ -1136,7 +1163,7 @@ addr_is_in_bounds(nir_builder *b, nir_ssa_def *addr, assert(addr->num_components == 4); assert(size > 0); return nir_ult(b, nir_iadd_imm(b, nir_channel(b, addr, 3), size - 1), - nir_channel(b, addr, 2)); + nir_channel(b, addr, 2)); } static void @@ -1798,7 +1825,7 @@ build_explicit_io_atomic(nir_builder *b, nir_intrinsic_instr *intrin, nir_pop_if(b, NULL); return nir_if_phi(b, &atomic->dest.ssa, - nir_ssa_undef(b, 1, atomic->dest.ssa.bit_size)); + nir_ssa_undef(b, 1, atomic->dest.ssa.bit_size)); } else { nir_builder_instr_insert(b, &atomic->instr); return &atomic->dest.ssa; @@ -1887,7 +1914,9 @@ nir_lower_explicit_io_instr(nir_builder *b, case nir_intrinsic_load_deref: { nir_ssa_def *value; if (vec_stride > scalar_size) { - nir_ssa_def *comps[NIR_MAX_VEC_COMPONENTS] = { NULL, }; + nir_ssa_def *comps[NIR_MAX_VEC_COMPONENTS] = { + NULL, + }; for (unsigned i = 0; i < intrin->num_components; i++) { unsigned comp_offset = i * vec_stride; nir_ssa_def *comp_addr = nir_build_addr_iadd_imm(b, addr, addr_format, @@ -2137,7 +2166,7 @@ lower_explicit_io_array_length(nir_builder *b, nir_intrinsic_instr *intrin, offset = addr_to_offset(b, addr, addr_format); nir_ssa_def *index = addr_to_index(b, addr, addr_format); unsigned access = nir_intrinsic_access(intrin); - size = nir_get_ssbo_size(b, index, .access=access); + size = nir_get_ssbo_size(b, index, .access = access); break; } @@ -2360,9 +2389,9 @@ nir_lower_vars_to_explicit_types_impl(nir_function_impl *impl, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs | - nir_metadata_loop_analysis); + nir_metadata_dominance | + nir_metadata_live_ssa_defs | + nir_metadata_loop_analysis); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -2685,18 +2714,18 @@ const nir_const_value * nir_address_format_null_value(nir_address_format addr_format) { const static nir_const_value null_values[][NIR_MAX_VEC_COMPONENTS] = { - [nir_address_format_32bit_global] = {{0}}, - [nir_address_format_2x32bit_global] = {{0}}, - [nir_address_format_64bit_global] = {{0}}, - [nir_address_format_64bit_global_32bit_offset] = {{0}}, - [nir_address_format_64bit_bounded_global] = {{0}}, - [nir_address_format_32bit_index_offset] = {{.u32 = ~0}, {.u32 = ~0}}, - [nir_address_format_32bit_index_offset_pack64] = {{.u64 = ~0ull}}, - [nir_address_format_vec2_index_32bit_offset] = {{.u32 = ~0}, {.u32 = ~0}, {.u32 = ~0}}, - [nir_address_format_32bit_offset] = {{.u32 = ~0}}, - [nir_address_format_32bit_offset_as_64bit] = {{.u64 = ~0ull}}, - [nir_address_format_62bit_generic] = {{.u64 = 0}}, - [nir_address_format_logical] = {{.u32 = ~0}}, + [nir_address_format_32bit_global] = { { 0 } }, + [nir_address_format_2x32bit_global] = { { 0 } }, + [nir_address_format_64bit_global] = { { 0 } }, + [nir_address_format_64bit_global_32bit_offset] = { { 0 } }, + [nir_address_format_64bit_bounded_global] = { { 0 } }, + [nir_address_format_32bit_index_offset] = { { .u32 = ~0 }, { .u32 = ~0 } }, + [nir_address_format_32bit_index_offset_pack64] = { { .u64 = ~0ull } }, + [nir_address_format_vec2_index_32bit_offset] = { { .u32 = ~0 }, { .u32 = ~0 }, { .u32 = ~0 } }, + [nir_address_format_32bit_offset] = { { .u32 = ~0 } }, + [nir_address_format_32bit_offset_as_64bit] = { { .u64 = ~0ull } }, + [nir_address_format_62bit_generic] = { { .u64 = 0 } }, + [nir_address_format_logical] = { { .u32 = ~0 } }, }; assert(addr_format < ARRAY_SIZE(null_values)); @@ -2720,7 +2749,7 @@ nir_build_addr_ieq(nir_builder *b, nir_ssa_def *addr0, nir_ssa_def *addr1, case nir_address_format_64bit_global_32bit_offset: return nir_ball_iequal(b, nir_channels(b, addr0, 0xb), - nir_channels(b, addr1, 0xb)); + nir_channels(b, addr1, 0xb)); case nir_address_format_32bit_offset_as_64bit: assert(addr0->num_components == 1 && addr1->num_components == 1); @@ -2753,7 +2782,7 @@ nir_build_addr_isub(nir_builder *b, nir_ssa_def *addr0, nir_ssa_def *addr1, case nir_address_format_2x32bit_global: return nir_isub(b, addr_to_global(b, addr0, addr_format), - addr_to_global(b, addr1, addr_format)); + addr_to_global(b, addr1, addr_format)); case nir_address_format_32bit_offset_as_64bit: assert(addr0->num_components == 1); @@ -2763,7 +2792,7 @@ nir_build_addr_isub(nir_builder *b, nir_ssa_def *addr0, nir_ssa_def *addr1, case nir_address_format_64bit_global_32bit_offset: case nir_address_format_64bit_bounded_global: return nir_isub(b, addr_to_global(b, addr0, addr_format), - addr_to_global(b, addr1, addr_format)); + addr_to_global(b, addr1, addr_format)); case nir_address_format_32bit_index_offset: assert(addr0->num_components == 2); @@ -2805,7 +2834,8 @@ is_output(nir_intrinsic_instr *intrin) intrin->intrinsic == nir_intrinsic_store_per_primitive_output; } -static bool is_dual_slot(nir_intrinsic_instr *intrin) +static bool +is_dual_slot(nir_intrinsic_instr *intrin) { if (intrin->intrinsic == nir_intrinsic_store_output || intrin->intrinsic == nir_intrinsic_store_per_vertex_output || @@ -2903,8 +2933,8 @@ nir_lower_color_inputs(nir_shader *nir) nir_builder b = nir_builder_create(impl); - nir_foreach_block (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block(block, impl) { + nir_foreach_instr_safe(instr, block) { if (instr->type != nir_instr_type_intrinsic) continue; @@ -2969,7 +2999,7 @@ nir_lower_color_inputs(nir_shader *nir) if (progress) { nir_metadata_preserve(impl, nir_metadata_dominance | - nir_metadata_block_index); + nir_metadata_block_index); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -2985,8 +3015,8 @@ nir_io_add_intrinsic_xfb_info(nir_shader *nir) for (unsigned i = 0; i < NIR_MAX_XFB_BUFFERS; i++) nir->info.xfb_stride[i] = nir->xfb_info->buffers[i].stride / 4; - nir_foreach_block (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block(block, impl) { + nir_foreach_instr_safe(instr, block) { if (instr->type != nir_instr_type_intrinsic) continue; @@ -3007,8 +3037,7 @@ nir_io_add_intrinsic_xfb_info(nir_shader *nir) continue; nir_io_semantics sem = nir_intrinsic_io_semantics(intr); - unsigned writemask = nir_intrinsic_write_mask(intr) << - nir_intrinsic_component(intr); + unsigned writemask = nir_intrinsic_write_mask(intr) << nir_intrinsic_component(intr); nir_io_xfb xfb[2]; memset(xfb, 0, sizeof(xfb)); @@ -3113,13 +3142,14 @@ nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs) */ NIR_PASS_V(nir, nir_recompute_io_bases, (nir->info.stage != MESA_SHADER_VERTEX || - renumber_vs_inputs ? nir_var_shader_in : 0) | - nir_var_shader_out); + renumber_vs_inputs + ? nir_var_shader_in + : 0) | + nir_var_shader_out); /* nir_io_add_const_offset_to_base needs actual constants. */ NIR_PASS_V(nir, nir_opt_constant_folding); - NIR_PASS_V(nir, nir_io_add_const_offset_to_base, nir_var_shader_in | - nir_var_shader_out); + NIR_PASS_V(nir, nir_io_add_const_offset_to_base, nir_var_shader_in | nir_var_shader_out); /* Lower and remove dead derefs and variables to clean up the IR. */ NIR_PASS_V(nir, nir_lower_vars_to_ssa); diff --git a/src/compiler/nir/nir_lower_io_arrays_to_elements.c b/src/compiler/nir/nir_lower_io_arrays_to_elements.c index 799f8e3..225f7f5 100644 --- a/src/compiler/nir/nir_lower_io_arrays_to_elements.c +++ b/src/compiler/nir/nir_lower_io_arrays_to_elements.c @@ -63,11 +63,9 @@ get_io_offset(nir_builder *b, nir_deref_instr *deref, nir_variable *var, *xfb_offset += index * glsl_get_component_slots((*p)->type) * 4; - unsigned num_elements = glsl_type_is_array((*p)->type) ? - glsl_get_aoa_size((*p)->type) : 1; + unsigned num_elements = glsl_type_is_array((*p)->type) ? glsl_get_aoa_size((*p)->type) : 1; - num_elements *= glsl_type_is_matrix(glsl_without_array((*p)->type)) ? - glsl_get_matrix_columns(glsl_without_array((*p)->type)) : 1; + num_elements *= glsl_type_is_matrix(glsl_without_array((*p)->type)) ? glsl_get_matrix_columns(glsl_without_array((*p)->type)) : 1; *element_index += num_elements * index; } else if ((*p)->deref_type == nir_deref_type_struct) { @@ -94,16 +92,14 @@ get_array_elements(struct hash_table *ht, nir_variable *var, type = glsl_get_array_element(type); } - unsigned num_elements = glsl_type_is_array(type) ? - glsl_get_aoa_size(type) : 1; + unsigned num_elements = glsl_type_is_array(type) ? glsl_get_aoa_size(type) : 1; - num_elements *= glsl_type_is_matrix(glsl_without_array(type)) ? - glsl_get_matrix_columns(glsl_without_array(type)) : 1; + num_elements *= glsl_type_is_matrix(glsl_without_array(type)) ? glsl_get_matrix_columns(glsl_without_array(type)) : 1; - elements = (nir_variable **) calloc(num_elements, sizeof(nir_variable *)); + elements = (nir_variable **)calloc(num_elements, sizeof(nir_variable *)); _mesa_hash_table_insert(ht, var, elements); } else { - elements = (nir_variable **) entry->data; + elements = (nir_variable **)entry->data; } return elements; @@ -139,27 +135,27 @@ lower_array(nir_builder *b, nir_intrinsic_instr *intr, nir_variable *var, nir_variable *element = elements[elements_index]; if (!element) { - element = nir_variable_clone(var, b->shader); - element->data.location = var->data.location + io_offset; + element = nir_variable_clone(var, b->shader); + element->data.location = var->data.location + io_offset; - if (var->data.explicit_offset) - element->data.offset = var->data.offset + xfb_offset; + if (var->data.explicit_offset) + element->data.offset = var->data.offset + xfb_offset; - const struct glsl_type *type = glsl_without_array(element->type); + const struct glsl_type *type = glsl_without_array(element->type); - /* This pass also splits matrices so we need give them a new type. */ - if (glsl_type_is_matrix(type)) - type = glsl_get_column_type(type); + /* This pass also splits matrices so we need give them a new type. */ + if (glsl_type_is_matrix(type)) + type = glsl_get_column_type(type); - if (nir_is_arrayed_io(var, b->shader->info.stage)) { - type = glsl_array_type(type, glsl_get_length(element->type), - glsl_get_explicit_stride(element->type)); - } + if (nir_is_arrayed_io(var, b->shader->info.stage)) { + type = glsl_array_type(type, glsl_get_length(element->type), + glsl_get_explicit_stride(element->type)); + } - element->type = type; - elements[elements_index] = element; + element->type = type; + elements[elements_index] = element; - nir_shader_add_variable(b->shader, element); + nir_shader_add_variable(b->shader, element); } nir_deref_instr *element_deref = nir_build_deref_var(b, element); @@ -263,7 +259,7 @@ create_indirects_mask(nir_shader *shader, nir_deref_path_finish(&path); } } -} + } } static void @@ -321,7 +317,7 @@ lower_io_arrays_to_elements(nir_shader *shader, nir_variable_mode mask, * * TODO: Add support for struct splitting. */ - if ((!glsl_type_is_array(type) && !glsl_type_is_matrix(type))|| + if ((!glsl_type_is_array(type) && !glsl_type_is_matrix(type)) || glsl_type_is_struct_or_ifc(glsl_without_array(type))) continue; @@ -363,7 +359,7 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader, struct hash_table *split_inputs = _mesa_pointer_hash_table_create(NULL); struct hash_table *split_outputs = _mesa_pointer_hash_table_create(NULL); - BITSET_DECLARE(indirects, 4 * VARYING_SLOT_TESS_MAX) = {0}; + BITSET_DECLARE(indirects, 4 * VARYING_SLOT_TESS_MAX) = { 0 }; lower_io_arrays_to_elements(shader, nir_var_shader_out, indirects, split_outputs, true); @@ -374,7 +370,7 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader, /* Remove old input from the shaders inputs list */ hash_table_foreach(split_inputs, entry) { - nir_variable *var = (nir_variable *) entry->key; + nir_variable *var = (nir_variable *)entry->key; exec_node_remove(&var->node); free(entry->data); @@ -383,7 +379,7 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader, /* Remove old output from the shaders outputs list */ hash_table_foreach(split_outputs, entry) { - nir_variable *var = (nir_variable *) entry->key; + nir_variable *var = (nir_variable *)entry->key; exec_node_remove(&var->node); free(entry->data); @@ -401,7 +397,7 @@ nir_lower_io_arrays_to_elements(nir_shader *producer, nir_shader *consumer) struct hash_table *split_inputs = _mesa_pointer_hash_table_create(NULL); struct hash_table *split_outputs = _mesa_pointer_hash_table_create(NULL); - BITSET_DECLARE(indirects, 4 * VARYING_SLOT_TESS_MAX) = {0}; + BITSET_DECLARE(indirects, 4 * VARYING_SLOT_TESS_MAX) = { 0 }; create_indirects_mask(producer, indirects, nir_var_shader_out); create_indirects_mask(consumer, indirects, nir_var_shader_in); @@ -414,7 +410,7 @@ nir_lower_io_arrays_to_elements(nir_shader *producer, nir_shader *consumer) /* Remove old input from the shaders inputs list */ hash_table_foreach(split_inputs, entry) { - nir_variable *var = (nir_variable *) entry->key; + nir_variable *var = (nir_variable *)entry->key; exec_node_remove(&var->node); free(entry->data); @@ -422,7 +418,7 @@ nir_lower_io_arrays_to_elements(nir_shader *producer, nir_shader *consumer) /* Remove old output from the shaders outputs list */ hash_table_foreach(split_outputs, entry) { - nir_variable *var = (nir_variable *) entry->key; + nir_variable *var = (nir_variable *)entry->key; exec_node_remove(&var->node); free(entry->data); diff --git a/src/compiler/nir/nir_lower_io_to_scalar.c b/src/compiler/nir/nir_lower_io_to_scalar.c index b36cfcf..7038849 100644 --- a/src/compiler/nir/nir_lower_io_to_scalar.c +++ b/src/compiler/nir/nir_lower_io_to_scalar.c @@ -98,7 +98,8 @@ lower_load_to_scalar(nir_builder *b, nir_intrinsic_instr *intr) nir_intrinsic_set_align_offset(chan_intr, (nir_intrinsic_align_offset(intr) + - i * (intr->dest.ssa.bit_size / 8)) % nir_intrinsic_align_mul(intr)); + i * (intr->dest.ssa.bit_size / 8)) % + nir_intrinsic_align_mul(intr)); nir_intrinsic_set_align_mul(chan_intr, nir_intrinsic_align_mul(intr)); if (nir_intrinsic_has_access(intr)) nir_intrinsic_set_access(chan_intr, nir_intrinsic_access(intr)); @@ -154,14 +155,13 @@ lower_store_output_to_scalar(nir_builder *b, nir_intrinsic_instr *intr) unsigned component = nir_intrinsic_component(chan_intr); for (unsigned c = 0; c <= component; c++) { - nir_io_xfb xfb = c < 2 ? nir_intrinsic_io_xfb(intr) : - nir_intrinsic_io_xfb2(intr); + nir_io_xfb xfb = c < 2 ? nir_intrinsic_io_xfb(intr) : nir_intrinsic_io_xfb2(intr); if (component < c + xfb.out[c % 2].num_components) { nir_io_xfb scalar_xfb; memset(&scalar_xfb, 0, sizeof(scalar_xfb)); - scalar_xfb.out[component % 2].num_components = is_64bit ? 2 : 1; + scalar_xfb.out[component % 2].num_components = is_64bit ? 2 : 1; scalar_xfb.out[component % 2].buffer = xfb.out[c % 2].buffer; scalar_xfb.out[component % 2].offset = xfb.out[c % 2].offset + component - c; @@ -209,7 +209,8 @@ lower_store_to_scalar(nir_builder *b, nir_intrinsic_instr *intr) nir_intrinsic_set_write_mask(chan_intr, 0x1); nir_intrinsic_set_align_offset(chan_intr, (nir_intrinsic_align_offset(intr) + - i * (value->bit_size / 8)) % nir_intrinsic_align_mul(intr)); + i * (value->bit_size / 8)) % + nir_intrinsic_align_mul(intr)); nir_intrinsic_set_align_mul(chan_intr, nir_intrinsic_align_mul(intr)); if (nir_intrinsic_has_access(intr)) nir_intrinsic_set_access(chan_intr, nir_intrinsic_access(intr)); @@ -261,8 +262,8 @@ nir_lower_io_to_scalar_instr(nir_builder *b, nir_instr *instr, void *data) if ((intr->intrinsic == nir_intrinsic_load_output || intr->intrinsic == nir_intrinsic_load_per_vertex_output) && - (state->mask & nir_var_shader_out) && - (!state->filter || state->filter(instr, state->filter_data))) { + (state->mask & nir_var_shader_out) && + (!state->filter || state->filter(instr, state->filter_data))) { lower_load_input_to_scalar(b, intr); return true; } @@ -306,7 +307,7 @@ nir_lower_io_to_scalar(nir_shader *shader, nir_variable_mode mask, nir_instr_fil return nir_shader_instructions_pass(shader, nir_lower_io_to_scalar_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); } @@ -316,10 +317,10 @@ get_channel_variables(struct hash_table *ht, nir_variable *var) nir_variable **chan_vars; struct hash_entry *entry = _mesa_hash_table_search(ht, var); if (!entry) { - chan_vars = (nir_variable **) calloc(4, sizeof(nir_variable *)); + chan_vars = (nir_variable **)calloc(4, sizeof(nir_variable *)); _mesa_hash_table_insert(ht, var, chan_vars); } else { - chan_vars = (nir_variable **) entry->data; + chan_vars = (nir_variable **)entry->data; } return chan_vars; @@ -369,7 +370,7 @@ lower_load_to_scalar_early(nir_builder *b, nir_intrinsic_instr *intr, nir_variable *chan_var = chan_vars[var->data.location_frac + i]; if (!chan_vars[var->data.location_frac + i]) { chan_var = nir_variable_clone(var, b->shader); - chan_var->data.location_frac = var->data.location_frac + i; + chan_var->data.location_frac = var->data.location_frac + i; chan_var->type = glsl_channel_type(chan_var->type); chan_vars[var->data.location_frac + i] = chan_var; @@ -423,7 +424,7 @@ lower_store_output_to_scalar_early(nir_builder *b, nir_intrinsic_instr *intr, nir_variable *chan_var = chan_vars[var->data.location_frac + i]; if (!chan_vars[var->data.location_frac + i]) { chan_var = nir_variable_clone(var, b->shader); - chan_var->data.location_frac = var->data.location_frac + i; + chan_var->data.location_frac = var->data.location_frac + i; chan_var->type = glsl_channel_type(chan_var->type); chan_vars[var->data.location_frac + i] = chan_var; @@ -555,12 +556,12 @@ nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask) bool progress = nir_shader_instructions_pass(shader, nir_lower_io_to_scalar_early_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); /* Remove old input from the shaders inputs list */ hash_table_foreach(state.split_inputs, entry) { - nir_variable *var = (nir_variable *) entry->key; + nir_variable *var = (nir_variable *)entry->key; exec_node_remove(&var->node); free(entry->data); @@ -568,7 +569,7 @@ nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask) /* Remove old output from the shaders outputs list */ hash_table_foreach(state.split_outputs, entry) { - nir_variable *var = (nir_variable *) entry->key; + nir_variable *var = (nir_variable *)entry->key; exec_node_remove(&var->node); free(entry->data); diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c index 6d889de..e53cb4e 100644 --- a/src/compiler/nir/nir_lower_io_to_temporaries.c +++ b/src/compiler/nir/nir_lower_io_to_temporaries.c @@ -261,7 +261,7 @@ fixup_interpolation(struct lower_io_state *state, nir_function_impl *impl, continue; nir_intrinsic_instr *interp = nir_instr_as_intrinsic(instr); - + if (interp->intrinsic == nir_intrinsic_interp_deref_at_centroid || interp->intrinsic == nir_intrinsic_interp_deref_at_sample || interp->intrinsic == nir_intrinsic_interp_deref_at_offset || @@ -368,7 +368,7 @@ nir_lower_io_to_temporaries(nir_shader *shader, nir_function_impl *entrypoint, emit_output_copies_impl(&state, impl); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } exec_list_append(&shader->variables, &state.old_inputs); diff --git a/src/compiler/nir/nir_lower_io_to_vector.c b/src/compiler/nir/nir_lower_io_to_vector.c index ee7558e..2da3ed4 100644 --- a/src/compiler/nir/nir_lower_io_to_vector.c +++ b/src/compiler/nir/nir_lower_io_to_vector.c @@ -21,10 +21,10 @@ * IN THE SOFTWARE. */ +#include "util/u_dynarray.h" #include "nir.h" #include "nir_builder.h" #include "nir_deref.h" -#include "util/u_dynarray.h" /** @file nir_lower_io_to_vector.c * @@ -37,7 +37,7 @@ /* FRAG_RESULT_MAX+1 instead of just FRAG_RESULT_MAX because of how this pass * handles dual source blending */ -#define MAX_SLOTS MAX2(VARYING_SLOT_TESS_MAX, FRAG_RESULT_MAX+1) +#define MAX_SLOTS MAX2(VARYING_SLOT_TESS_MAX, FRAG_RESULT_MAX + 1) static unsigned get_slot(const nir_variable *var) @@ -214,7 +214,7 @@ create_new_io_vars(nir_shader *shader, nir_variable_mode mode, bool flat_vars[MAX_SLOTS], struct util_dynarray *demote_vars) { - nir_variable *old_vars[MAX_SLOTS][4] = {{0}}; + nir_variable *old_vars[MAX_SLOTS][4] = { { 0 } }; bool has_io_var = false; nir_foreach_variable_with_modes(var, shader, mode) { @@ -344,7 +344,7 @@ build_array_index(nir_builder *b, nir_deref_instr *deref, nir_ssa_def *base, return base; case nir_deref_type_array: { nir_ssa_def *index = nir_i2iN(b, deref->arr.index.ssa, - deref->dest.ssa.bit_size); + deref->dest.ssa.bit_size); if (nir_deref_instr_parent(deref)->deref_type == nir_deref_type_var && per_vertex) @@ -385,7 +385,7 @@ build_array_deref_of_new_var_flat(nir_shader *shader, bool vs_in = shader->info.stage == MESA_SHADER_VERTEX && new_var->data.mode == nir_var_shader_in; return nir_build_deref_array(b, deref, - build_array_index(b, leader, nir_imm_int(b, base), vs_in, per_vertex)); + build_array_index(b, leader, nir_imm_int(b, base), vs_in, per_vertex)); } ASSERTED static bool @@ -419,10 +419,10 @@ nir_lower_io_to_vector_impl(nir_function_impl *impl, nir_variable_mode modes) util_dynarray_init(&demote_vars, NULL); nir_shader *shader = impl->function->shader; - nir_variable *new_inputs[MAX_SLOTS][4] = {{0}}; - nir_variable *new_outputs[MAX_SLOTS][4] = {{0}}; - bool flat_inputs[MAX_SLOTS] = {0}; - bool flat_outputs[MAX_SLOTS] = {0}; + nir_variable *new_inputs[MAX_SLOTS][4] = { { 0 } }; + nir_variable *new_outputs[MAX_SLOTS][4] = { { 0 } }; + bool flat_inputs[MAX_SLOTS] = { 0 }; + bool flat_outputs[MAX_SLOTS] = { 0 }; if (modes & nir_var_shader_in) { /* Vertex shaders support overlapping inputs. We don't do those */ @@ -480,11 +480,8 @@ nir_lower_io_to_vector_impl(nir_function_impl *impl, nir_variable_mode modes) const unsigned loc = get_slot(old_var); const unsigned old_frac = old_var->data.location_frac; - nir_variable *new_var = old_var->data.mode == nir_var_shader_in ? - new_inputs[loc][old_frac] : - new_outputs[loc][old_frac]; - bool flat = old_var->data.mode == nir_var_shader_in ? - flat_inputs[loc] : flat_outputs[loc]; + nir_variable *new_var = old_var->data.mode == nir_var_shader_in ? new_inputs[loc][old_frac] : new_outputs[loc][old_frac]; + bool flat = old_var->data.mode == nir_var_shader_in ? flat_inputs[loc] : flat_outputs[loc]; if (!new_var) break; @@ -568,10 +565,11 @@ nir_lower_io_to_vector_impl(nir_function_impl *impl, nir_variable_mode modes) if (new_frac + c >= old_frac && (old_wrmask & 1 << (new_frac + c - old_frac))) { comps[c] = nir_get_ssa_scalar(old_value, - new_frac + c - old_frac); + new_frac + c - old_frac); } else { comps[c] = nir_get_ssa_scalar(nir_ssa_undef(&b, old_value->num_components, - old_value->bit_size), 0); + old_value->bit_size), + 0); } } nir_ssa_def *new_value = nir_vec_scalars(&b, comps, intrin->num_components); @@ -602,7 +600,7 @@ nir_lower_io_to_vector_impl(nir_function_impl *impl, nir_variable_mode modes) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } return progress; diff --git a/src/compiler/nir/nir_lower_is_helper_invocation.c b/src/compiler/nir/nir_lower_is_helper_invocation.c index bce5999..64b955f 100644 --- a/src/compiler/nir/nir_lower_is_helper_invocation.c +++ b/src/compiler/nir/nir_lower_is_helper_invocation.c @@ -46,7 +46,7 @@ nir_lower_load_and_store_is_helper(nir_builder *b, nir_instr *instr, void *data) return false; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - nir_deref_instr *is_helper_deref = (nir_deref_instr*) data; + nir_deref_instr *is_helper_deref = (nir_deref_instr *)data; switch (intrin->intrinsic) { case nir_intrinsic_demote: { @@ -106,12 +106,10 @@ nir_lower_is_helper_invocation(nir_shader *shader) nir_builder b = nir_builder_at(nir_before_cf_list(&entrypoint->body)); nir_variable *is_helper = nir_local_variable_create(entrypoint, - glsl_bool_type(), - "gl_IsHelperInvocationEXT"); + glsl_bool_type(), + "gl_IsHelperInvocationEXT"); - nir_ssa_def *started_as_helper = shader->options->lower_helper_invocation ? - nir_build_lowered_load_helper_invocation(&b) : - nir_load_helper_invocation(&b, 1); + nir_ssa_def *started_as_helper = shader->options->lower_helper_invocation ? nir_build_lowered_load_helper_invocation(&b) : nir_load_helper_invocation(&b, 1); nir_deref_instr *is_helper_deref = nir_build_deref_var(&b, is_helper); nir_store_deref(&b, is_helper_deref, started_as_helper, 1); diff --git a/src/compiler/nir/nir_lower_load_const_to_scalar.c b/src/compiler/nir/nir_lower_load_const_to_scalar.c index 0cd7a7d..6e3f7d8 100644 --- a/src/compiler/nir/nir_lower_load_const_to_scalar.c +++ b/src/compiler/nir/nir_lower_load_const_to_scalar.c @@ -77,7 +77,7 @@ nir_lower_load_const_to_scalar_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_locals_to_regs.c b/src/compiler/nir/nir_lower_locals_to_regs.c index ab9b47d..4010e30 100644 --- a/src/compiler/nir/nir_lower_locals_to_regs.c +++ b/src/compiler/nir/nir_lower_locals_to_regs.c @@ -152,7 +152,7 @@ get_deref_reg_location(nir_deref_instr *deref, * handle this case we just convert it to a direct reference. */ if (nir_intrinsic_num_array_elems(decl) == 0) - return (struct reg_location){.reg = reg}; + return (struct reg_location){ .reg = reg }; nir_ssa_def *indirect = NULL; unsigned base_offset = 0; @@ -262,7 +262,7 @@ lower_locals_to_regs_block(nir_block *block, .write_mask = write_mask); } else { nir_build_store_reg(b, val, loc.reg, .base = loc.base_offset, - .write_mask = write_mask); + .write_mask = write_mask); } nir_instr_remove(&intrin->instr); @@ -299,7 +299,7 @@ impl(nir_function_impl *impl, uint8_t bool_bitsize) } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); _mesa_hash_table_destroy(state.regs_table, NULL); diff --git a/src/compiler/nir/nir_lower_mediump.c b/src/compiler/nir/nir_lower_mediump.c index 7caa1b6..23fc4aa 100644 --- a/src/compiler/nir/nir_lower_mediump.c +++ b/src/compiler/nir/nir_lower_mediump.c @@ -72,8 +72,8 @@ nir_recompute_io_bases(nir_shader *nir, nir_variable_mode modes) BITSET_ZERO(outputs); /* Gather the bitmasks of used locations. */ - nir_foreach_block_safe (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block_safe(block, impl) { + nir_foreach_instr_safe(instr, block) { nir_variable_mode mode; nir_intrinsic_instr *intr = get_io_intrinsic(instr, modes, &mode); if (!intr) @@ -97,8 +97,8 @@ nir_recompute_io_bases(nir_shader *nir, nir_variable_mode modes) /* Renumber bases. */ bool changed = false; - nir_foreach_block_safe (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block_safe(block, impl) { + nir_foreach_instr_safe(instr, block) { nir_variable_mode mode; nir_intrinsic_instr *intr = get_io_intrinsic(instr, modes, &mode); if (!intr) @@ -125,7 +125,7 @@ nir_recompute_io_bases(nir_shader *nir, nir_variable_mode modes) if (changed) { nir_metadata_preserve(impl, nir_metadata_dominance | - nir_metadata_block_index); + nir_metadata_block_index); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -156,8 +156,8 @@ nir_lower_mediump_io(nir_shader *nir, nir_variable_mode modes, nir_builder b = nir_builder_create(impl); - nir_foreach_block_safe (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block_safe(block, impl) { + nir_foreach_instr_safe(instr, block) { nir_variable_mode mode; nir_intrinsic_instr *intr = get_io_intrinsic(instr, modes, &mode); if (!intr) @@ -171,7 +171,7 @@ nir_lower_mediump_io(nir_shader *nir, nir_variable_mode modes, mode == nir_var_shader_out); if (is_varying && sem.location <= VARYING_SLOT_VAR31 && - !(varying_mask & BITFIELD64_BIT(sem.location))) { + !(varying_mask & BITFIELD64_BIT(sem.location))) { continue; /* can't lower */ } @@ -265,7 +265,7 @@ nir_lower_mediump_io(nir_shader *nir, nir_variable_mode modes, if (changed) { nir_metadata_preserve(impl, nir_metadata_dominance | - nir_metadata_block_index); + nir_metadata_block_index); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -286,8 +286,8 @@ nir_force_mediump_io(nir_shader *nir, nir_variable_mode modes, nir_function_impl *impl = nir_shader_get_entrypoint(nir); assert(impl); - nir_foreach_block_safe (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block_safe(block, impl) { + nir_foreach_instr_safe(instr, block) { nir_variable_mode mode; nir_intrinsic_instr *intr = get_io_intrinsic(instr, modes, &mode); if (!intr) @@ -316,7 +316,7 @@ nir_force_mediump_io(nir_shader *nir, nir_variable_mode modes, /* Only accept generic varyings. */ if (sem.location < VARYING_SLOT_VAR0 || sem.location > VARYING_SLOT_VAR31) - continue; + continue; } sem.medium_precision = 1; @@ -327,7 +327,7 @@ nir_force_mediump_io(nir_shader *nir, nir_variable_mode modes, if (changed) { nir_metadata_preserve(impl, nir_metadata_dominance | - nir_metadata_block_index); + nir_metadata_block_index); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -346,8 +346,8 @@ nir_unpack_16bit_varying_slots(nir_shader *nir, nir_variable_mode modes) nir_function_impl *impl = nir_shader_get_entrypoint(nir); assert(impl); - nir_foreach_block_safe (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block_safe(block, impl) { + nir_foreach_instr_safe(instr, block) { nir_variable_mode mode; nir_intrinsic_instr *intr = get_io_intrinsic(instr, modes, &mode); if (!intr) @@ -373,7 +373,7 @@ nir_unpack_16bit_varying_slots(nir_shader *nir, nir_variable_mode modes) if (changed) { nir_metadata_preserve(impl, nir_metadata_dominance | - nir_metadata_block_index); + nir_metadata_block_index); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -541,7 +541,7 @@ nir_lower_mediump_vars_impl(nir_function_impl *impl, nir_variable_mode modes, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -658,8 +658,8 @@ nir_legalize_16bit_sampler_srcs(nir_shader *nir, nir_builder b = nir_builder_create(impl); - nir_foreach_block_safe (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block_safe(block, impl) { + nir_foreach_instr_safe(instr, block) { if (instr->type != nir_instr_type_tex) continue; @@ -700,12 +700,12 @@ nir_legalize_16bit_sampler_srcs(nir_shader *nir, switch (bit_size) { case 16: - convert = is_sint ? nir_i2i16 : - is_uint ? nir_u2u16 : nir_f2f16; + convert = is_sint ? nir_i2i16 : is_uint ? nir_u2u16 + : nir_f2f16; break; case 32: - convert = is_sint ? nir_i2i32 : - is_uint ? nir_u2u32 : nir_f2f32; + convert = is_sint ? nir_i2i32 : is_uint ? nir_u2u32 + : nir_f2f32; break; default: assert(!"unexpected bit size"); @@ -724,7 +724,7 @@ nir_legalize_16bit_sampler_srcs(nir_shader *nir, if (changed) { nir_metadata_preserve(impl, nir_metadata_dominance | - nir_metadata_block_index); + nir_metadata_block_index); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -745,14 +745,14 @@ static bool const_is_u16(nir_ssa_scalar scalar) { uint64_t value = nir_ssa_scalar_as_uint(scalar); - return value == (uint16_t) value; + return value == (uint16_t)value; } static bool const_is_i16(nir_ssa_scalar scalar) { int64_t value = nir_ssa_scalar_as_int(scalar); - return value == (int16_t) value; + return value == (int16_t)value; } static bool @@ -920,7 +920,6 @@ fold_16bit_tex_dest(nir_tex_instr *tex, unsigned exec_mode, return true; } - static bool fold_16bit_tex_srcs(nir_builder *b, nir_tex_instr *tex, struct nir_fold_tex_srcs_options *options) @@ -1059,8 +1058,9 @@ fold_16bit_tex_image(nir_builder *b, nir_instr *instr, void *params) return progress; } -bool nir_fold_16bit_tex_image(nir_shader *nir, - struct nir_fold_16bit_tex_image_options *options) +bool +nir_fold_16bit_tex_image(nir_shader *nir, + struct nir_fold_16bit_tex_image_options *options) { return nir_shader_instructions_pass(nir, fold_16bit_tex_image, diff --git a/src/compiler/nir/nir_lower_mem_access_bit_sizes.c b/src/compiler/nir/nir_lower_mem_access_bit_sizes.c index 2a0fef7..cdc40d4 100644 --- a/src/compiler/nir/nir_lower_mem_access_bit_sizes.c +++ b/src/compiler/nir/nir_lower_mem_access_bit_sizes.c @@ -22,9 +22,9 @@ * IN THE SOFTWARE. */ -#include "nir_builder.h" -#include "util/u_math.h" #include "util/bitscan.h" +#include "util/u_math.h" +#include "nir_builder.h" static nir_intrinsic_instr * dup_mem_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin, @@ -152,7 +152,7 @@ lower_mem_load(nir_builder *b, nir_intrinsic_instr *intrin, rev_shifted = nir_vec(b, comps, load->dest.ssa.num_components); shifted = nir_bcsel(b, nir_ieq_imm(b, shift, 0), &load->dest.ssa, - nir_ior(b, shifted, rev_shifted)); + nir_ior(b, shifted, rev_shifted)); } unsigned chunk_bit_size = MIN2(8 << (ffs(chunk_bytes) - 1), bit_size); @@ -225,8 +225,8 @@ lower_mem_load(nir_builder *b, nir_intrinsic_instr *intrin, static bool lower_mem_store(nir_builder *b, nir_intrinsic_instr *intrin, - nir_lower_mem_access_bit_sizes_cb mem_access_size_align_cb, - const void *cb_data, bool allow_unaligned_stores_as_atomics) + nir_lower_mem_access_bit_sizes_cb mem_access_size_align_cb, + const void *cb_data, bool allow_unaligned_stores_as_atomics) { nir_ssa_def *value = intrin->src[0].ssa; @@ -308,9 +308,7 @@ lower_mem_store(nir_builder *b, nir_intrinsic_instr *intrin, uint64_t align_mask = requested.align - 1; nir_ssa_def *chunk_offset = nir_iadd_imm(b, offset, chunk_start); - nir_ssa_def *pad = chunk_align < 4 ? - nir_iand_imm(b, chunk_offset, align_mask) : - nir_imm_intN_t(b, 0, chunk_offset->bit_size); + nir_ssa_def *pad = chunk_align < 4 ? nir_iand_imm(b, chunk_offset, align_mask) : nir_imm_intN_t(b, 0, chunk_offset->bit_size); chunk_offset = nir_iand_imm(b, chunk_offset, ~align_mask); unsigned max_pad = chunk_align < requested.align ? requested.align - chunk_align : 0; @@ -342,25 +340,25 @@ lower_mem_store(nir_builder *b, nir_intrinsic_instr *intrin, switch (intrin->intrinsic) { case nir_intrinsic_store_ssbo: nir_ssbo_atomic(b, 32, intrin->src[1].ssa, chunk_offset, iand_mask, - .atomic_op = nir_atomic_op_iand, - .access = nir_intrinsic_access(intrin)); + .atomic_op = nir_atomic_op_iand, + .access = nir_intrinsic_access(intrin)); nir_ssbo_atomic(b, 32, intrin->src[1].ssa, chunk_offset, data, - .atomic_op = nir_atomic_op_ior, - .access = nir_intrinsic_access(intrin)); + .atomic_op = nir_atomic_op_ior, + .access = nir_intrinsic_access(intrin)); break; case nir_intrinsic_store_global: nir_global_atomic(b, 32, chunk_offset, iand_mask, - .atomic_op = nir_atomic_op_iand); + .atomic_op = nir_atomic_op_iand); nir_global_atomic(b, 32, chunk_offset, data, - .atomic_op = nir_atomic_op_ior); + .atomic_op = nir_atomic_op_ior); break; case nir_intrinsic_store_shared: nir_shared_atomic(b, 32, chunk_offset, iand_mask, - .atomic_op = nir_atomic_op_iand, - .base = nir_intrinsic_base(intrin)); + .atomic_op = nir_atomic_op_iand, + .base = nir_intrinsic_base(intrin)); nir_shared_atomic(b, 32, chunk_offset, data, - .atomic_op = nir_atomic_op_ior, - .base = nir_intrinsic_base(intrin)); + .atomic_op = nir_atomic_op_ior, + .base = nir_intrinsic_base(intrin)); break; default: unreachable("Unsupported unaligned store"); @@ -374,7 +372,6 @@ lower_mem_store(nir_builder *b, nir_intrinsic_instr *intrin, dup_mem_intrinsic(b, intrin, chunk_offset, align_mul, chunk_align_offset, packed, requested.num_components, requested.bit_size); - } BITSET_CLEAR_RANGE(mask, chunk_start, (chunk_start + chunk_bytes - 1)); } @@ -462,6 +459,6 @@ nir_lower_mem_access_bit_sizes(nir_shader *shader, { return nir_shader_instructions_pass(shader, lower_mem_access_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, (void *)options); } diff --git a/src/compiler/nir/nir_lower_memcpy.c b/src/compiler/nir/nir_lower_memcpy.c index ba44347..c5addb8 100644 --- a/src/compiler/nir/nir_lower_memcpy.c +++ b/src/compiler/nir/nir_lower_memcpy.c @@ -34,11 +34,16 @@ static const struct glsl_type * copy_type_for_byte_size(unsigned size) { switch (size) { - case 1: return glsl_vector_type(GLSL_TYPE_UINT8, 1); - case 2: return glsl_vector_type(GLSL_TYPE_UINT16, 1); - case 4: return glsl_vector_type(GLSL_TYPE_UINT, 1); - case 8: return glsl_vector_type(GLSL_TYPE_UINT, 2); - case 16: return glsl_vector_type(GLSL_TYPE_UINT, 4); + case 1: + return glsl_vector_type(GLSL_TYPE_UINT8, 1); + case 2: + return glsl_vector_type(GLSL_TYPE_UINT16, 1); + case 4: + return glsl_vector_type(GLSL_TYPE_UINT, 1); + case 8: + return glsl_vector_type(GLSL_TYPE_UINT, 2); + case 16: + return glsl_vector_type(GLSL_TYPE_UINT, 4); default: unreachable("Unsupported size"); } @@ -149,7 +154,7 @@ lower_memcpy_impl(nir_function_impl *impl) glsl_uint8_t_type(), 1); nir_variable *i = nir_local_variable_create(impl, - glsl_uintN_t_type(size->bit_size), NULL); + glsl_uintN_t_type(size->bit_size), NULL); nir_store_var(&b, i, nir_imm_intN_t(&b, 0, size->bit_size), ~0); nir_push_loop(&b); { @@ -163,7 +168,7 @@ lower_memcpy_impl(nir_function_impl *impl) nir_ssa_def *value = memcpy_load_deref_elem(&b, copy_src, index); memcpy_store_deref_elem(&b, copy_dst, index, value); - nir_store_var(&b, i, nir_iadd_imm(&b, index, 1), ~0); + nir_store_var(&b, i, nir_iadd_imm(&b, index, 1), ~0); } nir_pop_loop(&b, NULL); } @@ -174,7 +179,7 @@ lower_memcpy_impl(nir_function_impl *impl) nir_metadata_preserve(impl, nir_metadata_none); } else if (found_const_memcpy) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_multiview.c b/src/compiler/nir/nir_lower_multiview.c index 8a7c3cc..15faeb6 100644 --- a/src/compiler/nir/nir_lower_multiview.c +++ b/src/compiler/nir/nir_lower_multiview.c @@ -22,8 +22,8 @@ * IN THE SOFTWARE. */ -#include "nir_control_flow.h" #include "nir_builder.h" +#include "nir_control_flow.h" /** * This file implements an optimization for multiview. Some GPU's have a @@ -246,7 +246,7 @@ nir_lower_multiview(nir_shader *shader, uint32_t view_mask) * original shader body. */ - nir_loop* loop = nir_push_loop(&b); + nir_loop *loop = nir_push_loop(&b); nir_ssa_def *loop_index = nir_load_deref(&b, loop_index_deref); nir_ssa_def *cmp = nir_ige_imm(&b, loop_index, view_count); @@ -314,4 +314,3 @@ nir_lower_multiview(nir_shader *shader, uint32_t view_mask) nir_metadata_preserve(entrypoint, nir_metadata_none); return true; } - diff --git a/src/compiler/nir/nir_lower_packing.c b/src/compiler/nir/nir_lower_packing.c index 457726c..e0e37db 100644 --- a/src/compiler/nir/nir_lower_packing.c +++ b/src/compiler/nir/nir_lower_packing.c @@ -38,38 +38,38 @@ static nir_ssa_def * lower_pack_64_from_32(nir_builder *b, nir_ssa_def *src) { return nir_pack_64_2x32_split(b, nir_channel(b, src, 0), - nir_channel(b, src, 1)); + nir_channel(b, src, 1)); } static nir_ssa_def * lower_unpack_64_to_32(nir_builder *b, nir_ssa_def *src) { return nir_vec2(b, nir_unpack_64_2x32_split_x(b, src), - nir_unpack_64_2x32_split_y(b, src)); + nir_unpack_64_2x32_split_y(b, src)); } static nir_ssa_def * lower_pack_32_from_16(nir_builder *b, nir_ssa_def *src) { return nir_pack_32_2x16_split(b, nir_channel(b, src, 0), - nir_channel(b, src, 1)); + nir_channel(b, src, 1)); } static nir_ssa_def * lower_unpack_32_to_16(nir_builder *b, nir_ssa_def *src) { return nir_vec2(b, nir_unpack_32_2x16_split_x(b, src), - nir_unpack_32_2x16_split_y(b, src)); + nir_unpack_32_2x16_split_y(b, src)); } static nir_ssa_def * lower_pack_64_from_16(nir_builder *b, nir_ssa_def *src) { nir_ssa_def *xy = nir_pack_32_2x16_split(b, nir_channel(b, src, 0), - nir_channel(b, src, 1)); + nir_channel(b, src, 1)); nir_ssa_def *zw = nir_pack_32_2x16_split(b, nir_channel(b, src, 2), - nir_channel(b, src, 3)); + nir_channel(b, src, 3)); return nir_pack_64_2x32_split(b, xy, zw); } @@ -81,18 +81,18 @@ lower_unpack_64_to_16(nir_builder *b, nir_ssa_def *src) nir_ssa_def *zw = nir_unpack_64_2x32_split_y(b, src); return nir_vec4(b, nir_unpack_32_2x16_split_x(b, xy), - nir_unpack_32_2x16_split_y(b, xy), - nir_unpack_32_2x16_split_x(b, zw), - nir_unpack_32_2x16_split_y(b, zw)); + nir_unpack_32_2x16_split_y(b, xy), + nir_unpack_32_2x16_split_x(b, zw), + nir_unpack_32_2x16_split_y(b, zw)); } static nir_ssa_def * lower_pack_32_from_8(nir_builder *b, nir_ssa_def *src) { return nir_pack_32_4x8_split(b, nir_channel(b, src, 0), - nir_channel(b, src, 1), - nir_channel(b, src, 2), - nir_channel(b, src, 3)); + nir_channel(b, src, 1), + nir_channel(b, src, 2), + nir_channel(b, src, 3)); } static bool @@ -101,7 +101,7 @@ lower_pack_instr(nir_builder *b, nir_instr *instr, void *data) if (instr->type != nir_instr_type_alu) return false; - nir_alu_instr *alu_instr = (nir_alu_instr *) instr; + nir_alu_instr *alu_instr = (nir_alu_instr *)instr; if (alu_instr->op != nir_op_pack_64_2x32 && alu_instr->op != nir_op_unpack_64_2x32 && @@ -152,5 +152,5 @@ bool nir_lower_pack(nir_shader *shader) { return nir_shader_instructions_pass(shader, lower_pack_instr, - nir_metadata_block_index | nir_metadata_dominance, NULL); + nir_metadata_block_index | nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_passthrough_edgeflags.c b/src/compiler/nir/nir_lower_passthrough_edgeflags.c index 32db90f..3d9053d 100644 --- a/src/compiler/nir/nir_lower_passthrough_edgeflags.c +++ b/src/compiler/nir/nir_lower_passthrough_edgeflags.c @@ -46,7 +46,7 @@ lower_impl(nir_function_impl *impl) util_bitcount64(shader->info.outputs_written)); /* Load an edge flag. */ - nir_io_semantics load_sem = {0}; + nir_io_semantics load_sem = { 0 }; load_sem.location = VERT_ATTRIB_EDGEFLAG; load_sem.num_slots = 1; @@ -58,7 +58,7 @@ lower_impl(nir_function_impl *impl) .io_semantics = load_sem); /* Store an edge flag. */ - nir_io_semantics semantics = {0}; + nir_io_semantics semantics = { 0 }; semantics.location = VARYING_SLOT_EDGE; semantics.num_slots = 1; @@ -70,7 +70,7 @@ lower_impl(nir_function_impl *impl) .write_mask = 0x1); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); return; } @@ -86,10 +86,11 @@ lower_impl(nir_function_impl *impl) nir_store_var(&b, out, def, 0xf); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } -void nir_lower_passthrough_edgeflags(nir_shader *shader) +void +nir_lower_passthrough_edgeflags(nir_shader *shader) { assert(shader->info.stage == MESA_SHADER_VERTEX); diff --git a/src/compiler/nir/nir_lower_patch_vertices.c b/src/compiler/nir/nir_lower_patch_vertices.c index 562c092..4eb59f9 100644 --- a/src/compiler/nir/nir_lower_patch_vertices.c +++ b/src/compiler/nir/nir_lower_patch_vertices.c @@ -93,7 +93,7 @@ nir_lower_patch_vertices(nir_shader *nir, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } } diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c index 36d386a..356dd95 100644 --- a/src/compiler/nir/nir_lower_phis_to_scalar.c +++ b/src/compiler/nir/nir_lower_phis_to_scalar.c @@ -88,7 +88,7 @@ is_phi_src_scalarizable(nir_phi_src *src, */ nir_deref_instr *deref = nir_src_as_deref(src_intrin->src[0]); return !nir_deref_mode_may_be(deref, nir_var_function_temp | - nir_var_shader_temp); + nir_var_shader_temp); } case nir_intrinsic_interp_deref_at_centroid: @@ -106,7 +106,7 @@ is_phi_src_scalarizable(nir_phi_src *src, break; } } - FALLTHROUGH; + FALLTHROUGH; default: /* We can't scalarize this type of instruction */ @@ -272,7 +272,7 @@ lower_phis_to_scalar_impl(nir_function_impl *impl, bool lower_all) } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); nir_instr_free_list(&state.dead_instrs); diff --git a/src/compiler/nir/nir_lower_pntc_ytransform.c b/src/compiler/nir/nir_lower_pntc_ytransform.c index 3ad4c2b..26a425e 100644 --- a/src/compiler/nir/nir_lower_pntc_ytransform.c +++ b/src/compiler/nir/nir_lower_pntc_ytransform.c @@ -30,9 +30,9 @@ typedef struct { const gl_state_index16 *pntc_state_tokens; - nir_shader *shader; - nir_builder b; - nir_variable *pntc_transform; + nir_shader *shader; + nir_builder b; + nir_variable *pntc_transform; } lower_pntc_ytransform_state; static nir_ssa_def * @@ -92,7 +92,7 @@ lower_pntc_ytransform_block(lower_pntc_ytransform_state *state, var->data.location == VARYING_SLOT_PNTC) || (var->data.mode == nir_var_system_value && var->data.location == SYSTEM_VALUE_POINT_COORD)) { - lower_load_pointcoord(state, intr); + lower_load_pointcoord(state, intr); } } } @@ -103,8 +103,8 @@ bool nir_lower_pntc_ytransform(nir_shader *shader, const gl_state_index16 pntc_state_tokens[][STATE_LENGTH]) { - if (!shader->options->lower_wpos_pntc) - return false; + if (!shader->options->lower_wpos_pntc) + return false; lower_pntc_ytransform_state state = { .pntc_state_tokens = *pntc_state_tokens, @@ -121,7 +121,7 @@ nir_lower_pntc_ytransform(nir_shader *shader, lower_pntc_ytransform_block(&state, block); } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } return state.pntc_transform != NULL; diff --git a/src/compiler/nir/nir_lower_point_size.c b/src/compiler/nir/nir_lower_point_size.c index b725e7d..f795725 100644 --- a/src/compiler/nir/nir_lower_point_size.c +++ b/src/compiler/nir/nir_lower_point_size.c @@ -78,8 +78,9 @@ nir_lower_point_size(nir_shader *s, float min, float max) assert(min > 0.0f || max > 0.0f); assert(min <= 0.0f || max <= 0.0f || min <= max); - float minmax[] = {min, max}; + float minmax[] = { min, max }; return nir_shader_instructions_pass(s, lower_point_size_instr, nir_metadata_block_index | - nir_metadata_dominance, minmax); + nir_metadata_dominance, + minmax); } diff --git a/src/compiler/nir/nir_lower_point_size_mov.c b/src/compiler/nir/nir_lower_point_size_mov.c index 5edb29d..3f76c41 100644 --- a/src/compiler/nir/nir_lower_point_size_mov.c +++ b/src/compiler/nir/nir_lower_point_size_mov.c @@ -55,7 +55,6 @@ lower_impl(nir_function_impl *impl, VARYING_SLOT_PSIZ, glsl_float_type()); } - if (!out) { b.cursor = nir_before_cf_list(&impl->body); nir_ssa_def *load = nir_load_var(&b, in); @@ -89,7 +88,7 @@ lower_impl(nir_function_impl *impl, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); return true; } diff --git a/src/compiler/nir/nir_lower_point_smooth.c b/src/compiler/nir/nir_lower_point_smooth.c index c72e35e..6411fb3 100644 --- a/src/compiler/nir/nir_lower_point_smooth.c +++ b/src/compiler/nir/nir_lower_point_smooth.c @@ -69,7 +69,8 @@ lower_point_smooth(nir_builder *b, nir_instr *instr, UNUSED void *_state) nir_ssa_def *point_size = nir_frcp(b, nir_fddx(b, nir_channel(b, coord, 0))); /* radius = point_size * 0.5 */ - nir_ssa_def *radius = nir_fmul_imm(b, point_size, 0.5);; + nir_ssa_def *radius = nir_fmul_imm(b, point_size, 0.5); + ; /** * Compute the distance of point from centre @@ -100,6 +101,7 @@ nir_lower_point_smooth(nir_shader *shader) assert(shader->info.stage == MESA_SHADER_FRAGMENT); return nir_shader_instructions_pass(shader, lower_point_smooth, nir_metadata_loop_analysis | - nir_metadata_block_index | - nir_metadata_dominance, NULL); + nir_metadata_block_index | + nir_metadata_dominance, + NULL); } diff --git a/src/compiler/nir/nir_lower_poly_line_smooth.c b/src/compiler/nir/nir_lower_poly_line_smooth.c index 72064fe..5f89a4a 100644 --- a/src/compiler/nir/nir_lower_poly_line_smooth.c +++ b/src/compiler/nir/nir_lower_poly_line_smooth.c @@ -60,7 +60,7 @@ lower_polylinesmooth(nir_builder *b, nir_instr *instr, void *data) /* coverage = (coverage) / SI_NUM_SMOOTH_AA_SAMPLES */ coverage = nir_bit_count(b, coverage); coverage = nir_u2f32(b, coverage); - coverage = nir_fmul_imm(b, coverage, 1.0 / *num_smooth_aa_sample); + coverage = nir_fmul_imm(b, coverage, 1.0 / *num_smooth_aa_sample); /* Write out the fragment color*vec4(1, 1, 1, alpha) */ nir_ssa_def *one = nir_imm_float(b, 1.0f); diff --git a/src/compiler/nir/nir_lower_printf.c b/src/compiler/nir/nir_lower_printf.c index 821da98..1a6047a 100644 --- a/src/compiler/nir/nir_lower_printf.c +++ b/src/compiler/nir/nir_lower_printf.c @@ -73,8 +73,7 @@ lower_printf_instr(nir_builder *b, nir_instr *instr, void *_options) /* Check if we're still in-bounds */ const unsigned default_buffer_size = 1024 * 1024; - unsigned buffer_size = (options && options->max_buffer_size) ? - options->max_buffer_size : default_buffer_size; + unsigned buffer_size = (options && options->max_buffer_size) ? options->max_buffer_size : default_buffer_size; int max_valid_offset = buffer_size - args_size - fmt_str_id_size - counter_size; nir_push_if(b, nir_ilt_imm(b, offset, max_valid_offset)); @@ -112,9 +111,8 @@ lower_printf_instr(nir_builder *b, nir_instr *instr, void *_options) unsigned field_offset = glsl_get_struct_field_offset(args->type, i); nir_ssa_def *arg_offset = - nir_i2iN(b, nir_iadd_imm(b, offset, - fmt_str_id_size + field_offset), - ptr_bit_size); + nir_i2iN(b, nir_iadd_imm(b, offset, fmt_str_id_size + field_offset), + ptr_bit_size); nir_deref_instr *dst_arg_deref = nir_build_deref_array(b, buffer, arg_offset); dst_arg_deref = nir_build_deref_cast(b, &dst_arg_deref->dest.ssa, diff --git a/src/compiler/nir/nir_lower_readonly_images_to_tex.c b/src/compiler/nir/nir_lower_readonly_images_to_tex.c index 94ad203..465c528 100644 --- a/src/compiler/nir/nir_lower_readonly_images_to_tex.c +++ b/src/compiler/nir/nir_lower_readonly_images_to_tex.c @@ -226,6 +226,6 @@ nir_lower_readonly_images_to_tex(nir_shader *shader, bool per_variable) struct readonly_image_lower_options options = { per_variable }; return nir_shader_instructions_pass(shader, lower_readonly_image_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &options); } diff --git a/src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c b/src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c index cd24cb8..bc449ea 100644 --- a/src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c +++ b/src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c @@ -129,7 +129,7 @@ nir_lower_reg_intrinsics_to_ssa_impl(nir_function_impl *impl) } nir_metadata_require(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); nir_index_ssa_defs(impl); void *dead_ctx = ralloc_context(NULL); @@ -168,7 +168,7 @@ nir_lower_reg_intrinsics_to_ssa_impl(nir_function_impl *impl) ralloc_free(dead_ctx); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); return true; } diff --git a/src/compiler/nir/nir_lower_returns.c b/src/compiler/nir/nir_lower_returns.c index 6e46ef3..1ab4cc3 100644 --- a/src/compiler/nir/nir_lower_returns.c +++ b/src/compiler/nir/nir_lower_returns.c @@ -71,7 +71,7 @@ predicate_following(nir_cf_node *node, struct lower_returns_state *state) */ nir_cf_list list; nir_cf_extract(&list, nir_after_cf_node(&if_stmt->cf_node), - nir_after_cf_list(state->cf_list)); + nir_after_cf_list(state->cf_list)); assert(!exec_list_is_empty(&list.list)); nir_cf_reinsert(&list, nir_before_cf_list(&if_stmt->else_list)); } @@ -168,7 +168,7 @@ lower_returns_in_block(nir_block *block, struct lower_returns_state *state) /* This block is unreachable. Delete it and everything after it. */ nir_cf_list list; nir_cf_extract(&list, nir_before_cf_node(&block->cf_node), - nir_after_cf_list(state->cf_list)); + nir_after_cf_list(state->cf_list)); if (exec_list_is_empty(&list.list)) { /* There's nothing here, which also means there's nothing in this diff --git a/src/compiler/nir/nir_lower_robust_access.c b/src/compiler/nir/nir_lower_robust_access.c index bd8595f..6571d38 100644 --- a/src/compiler/nir/nir_lower_robust_access.c +++ b/src/compiler/nir/nir_lower_robust_access.c @@ -20,7 +20,7 @@ rewrite_offset(nir_builder *b, nir_intrinsic_instr *instr, nir_iadd_imm(b, instr->src[offset_src].ssa, access_size - 1); nir_ssa_def *offset = nir_bcsel(b, nir_uge(b, max_access_offset, size), nir_imm_int(b, 0), - instr->src[offset_src].ssa); + instr->src[offset_src].ssa); /* Rewrite offset */ nir_instr_rewrite_src_ssa(&instr->instr, &instr->src[offset_src], offset); @@ -38,7 +38,7 @@ wrap_in_if(nir_builder *b, nir_intrinsic_instr *instr, nir_ssa_def *valid) if (has_dest) { zero = nir_imm_zero(b, instr->dest.ssa.num_components, - instr->dest.ssa.bit_size); + instr->dest.ssa.bit_size); } nir_push_if(b, valid); @@ -211,7 +211,6 @@ bool nir_lower_robust_access(nir_shader *s, const nir_lower_robust_access_options *opts) { - return nir_shader_instructions_pass(s, lower, nir_metadata_block_index | - nir_metadata_dominance, - (void*)opts); + return nir_shader_instructions_pass(s, lower, nir_metadata_block_index | nir_metadata_dominance, + (void *)opts); } diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c index 11e01ad..f1f37f6 100644 --- a/src/compiler/nir/nir_lower_samplers.c +++ b/src/compiler/nir/nir_lower_samplers.c @@ -100,9 +100,7 @@ lower_tex_src_to_offset(nir_builder *b, nir_instr_rewrite_src(&instr->instr, &src->src, nir_src_for_ssa(index)); - src->src_type = is_sampler ? - nir_tex_src_sampler_offset : - nir_tex_src_texture_offset; + src->src_type = is_sampler ? nir_tex_src_sampler_offset : nir_tex_src_texture_offset; } else { nir_tex_instr_remove_src(instr, src_idx); } @@ -149,6 +147,6 @@ nir_lower_samplers(nir_shader *shader) { return nir_shader_instructions_pass(shader, lower_sampler, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_scratch.c b/src/compiler/nir/nir_lower_scratch.c index 6bdcfc2..9348d9e 100644 --- a/src/compiler/nir/nir_lower_scratch.c +++ b/src/compiler/nir/nir_lower_scratch.c @@ -42,7 +42,7 @@ lower_load_store(nir_builder *b, nir_ssa_def *offset = nir_iadd_imm(b, nir_build_deref_offset(b, deref, size_align), - var->data.location); + var->data.location); unsigned align, UNUSED size; size_align(deref->type, &size, &align); @@ -50,7 +50,7 @@ lower_load_store(nir_builder *b, if (intrin->intrinsic == nir_intrinsic_load_deref) { unsigned bit_size = intrin->dest.ssa.bit_size; nir_ssa_def *value = nir_load_scratch( - b, intrin->num_components, bit_size == 1 ? 32 : bit_size, offset, .align_mul=align); + b, intrin->num_components, bit_size == 1 ? 32 : bit_size, offset, .align_mul = align); if (bit_size == 1) value = nir_b2b1(b, value); @@ -62,21 +62,22 @@ lower_load_store(nir_builder *b, if (value->bit_size == 1) value = nir_b2b32(b, value); - nir_store_scratch(b, value, offset, .align_mul=align, - .write_mask=nir_intrinsic_write_mask(intrin)); + nir_store_scratch(b, value, offset, .align_mul = align, + .write_mask = nir_intrinsic_write_mask(intrin)); } nir_instr_remove(&intrin->instr); nir_deref_instr_remove_if_unused(deref); } -static bool only_used_for_load_store(nir_deref_instr *deref) +static bool +only_used_for_load_store(nir_deref_instr *deref) { nir_foreach_use(src, &deref->dest.ssa) { if (!src->parent_instr) return false; if (src->parent_instr->type == nir_instr_type_deref) { - if (!only_used_for_load_store(nir_instr_as_deref(src->parent_instr))) + if (!only_used_for_load_store(nir_instr_as_deref(src->parent_instr))) return false; } else if (src->parent_instr->type != nir_instr_type_intrinsic) { return false; @@ -165,7 +166,7 @@ nir_lower_vars_to_scratch(nir_shader *shader, } set_foreach(set, entry) { - nir_variable* var = (void*)entry->key; + nir_variable *var = (void *)entry->key; /* Remove it from its list */ exec_node_remove(&var->node); @@ -213,7 +214,7 @@ nir_lower_vars_to_scratch(nir_shader *shader, if (impl_progress) { progress = true; nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_lower_shader_calls.c b/src/compiler/nir/nir_lower_shader_calls.c index d4415dd..655e42e 100644 --- a/src/compiler/nir/nir_lower_shader_calls.c +++ b/src/compiler/nir/nir_lower_shader_calls.c @@ -21,11 +21,11 @@ * IN THE SOFTWARE. */ +#include "util/u_dynarray.h" +#include "util/u_math.h" #include "nir.h" #include "nir_builder.h" #include "nir_phi_builder.h" -#include "util/u_dynarray.h" -#include "util/u_math.h" static bool move_system_values_to_top(nir_shader *shader) @@ -59,7 +59,7 @@ move_system_values_to_top(nir_shader *shader) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -91,7 +91,7 @@ struct sized_bitset { static struct sized_bitset bitset_create(void *mem_ctx, unsigned size) { - return (struct sized_bitset) { + return (struct sized_bitset){ .set = rzalloc_array(mem_ctx, BITSET_WORD, BITSET_WORDS(size)), .size = size, }; @@ -241,8 +241,8 @@ add_src_instr(nir_src *src, void *state) static int compare_instr_indexes(const void *_inst1, const void *_inst2) { - const nir_instr * const *inst1 = _inst1; - const nir_instr * const *inst2 = _inst2; + const nir_instr *const *inst1 = _inst1; + const nir_instr *const *inst2 = _inst2; return (*inst1)->index - (*inst2)->index; } @@ -302,7 +302,7 @@ can_remat_chain_ssa_def(nir_ssa_def *def, struct sized_bitset *remat, struct uti return true; - fail: +fail: util_dynarray_clear(buf); ralloc_free(mem_ctx); return false; @@ -451,9 +451,9 @@ spill_ssa_defs_and_lower_shader_calls(nir_shader *shader, uint32_t num_calls, nir_function_impl *impl = nir_shader_get_entrypoint(shader); nir_metadata_require(impl, nir_metadata_live_ssa_defs | - nir_metadata_dominance | - nir_metadata_block_index | - nir_metadata_instr_index); + nir_metadata_dominance | + nir_metadata_block_index | + nir_metadata_instr_index); void *mem_ctx = ralloc_context(shader); @@ -669,12 +669,12 @@ spill_ssa_defs_and_lower_shader_calls(nir_shader *shader, uint32_t num_calls, switch (call->intrinsic) { case nir_intrinsic_trace_ray: { nir_rt_trace_ray(b, call->src[0].ssa, call->src[1].ssa, - call->src[2].ssa, call->src[3].ssa, - call->src[4].ssa, call->src[5].ssa, - call->src[6].ssa, call->src[7].ssa, - call->src[8].ssa, call->src[9].ssa, - call->src[10].ssa, - .call_idx = call_idx, .stack_size = offset); + call->src[2].ssa, call->src[3].ssa, + call->src[4].ssa, call->src[5].ssa, + call->src[6].ssa, call->src[7].ssa, + call->src[8].ssa, call->src[9].ssa, + call->src[10].ssa, + .call_idx = call_idx, .stack_size = offset); break; } @@ -798,7 +798,7 @@ spill_ssa_defs_and_lower_shader_calls(nir_shader *shader, uint32_t num_calls, ralloc_free(mem_ctx); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } static nir_instr * @@ -929,7 +929,8 @@ cursor_is_after_jump(nir_cursor cursor) case nir_cursor_after_instr: return cursor.instr->type == nir_instr_type_jump; case nir_cursor_after_block: - return nir_block_ends_in_jump(cursor.block);; + return nir_block_ends_in_jump(cursor.block); + ; } unreachable("Invalid cursor option"); } @@ -1134,7 +1135,7 @@ found_resume: * copy the stuff after resume_node. */ nir_cf_extract(&cf_list, nir_after_cf_node(resume_node), - nir_after_cf_list(child_list)); + nir_after_cf_list(child_list)); } else { /* The loop contains its own cursor and still has useful stuff in it. * We want to move everything after and including the loop to before @@ -1142,7 +1143,7 @@ found_resume: */ assert(resume_node->type == nir_cf_node_loop); nir_cf_extract(&cf_list, nir_before_cf_node(resume_node), - nir_after_cf_list(child_list)); + nir_after_cf_list(child_list)); } } else { /* If we found the resume instruction in one of our blocks, grab @@ -1150,7 +1151,7 @@ found_resume: * place it before the cursor instr. */ nir_cf_extract(&cf_list, nir_after_instr(resume_instr), - nir_after_cf_list(child_list)); + nir_after_cf_list(child_list)); } /* If the resume instruction is in the first block of the child_list, @@ -1316,7 +1317,7 @@ replace_resume_with_halt(nir_shader *shader, nir_instr *keep) */ nir_cf_list cf_list; nir_cf_extract(&cf_list, nir_after_instr(&resume->instr), - nir_after_block(block)); + nir_after_block(block)); nir_cf_delete(&cf_list); b.cursor = nir_instr_remove(&resume->instr); nir_jump(&b, nir_jump_halt); @@ -1403,7 +1404,7 @@ nir_lower_stack_to_scratch(nir_shader *shader, return nir_shader_instructions_pass(shader, lower_stack_instr_to_scratch, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); } @@ -1442,7 +1443,7 @@ nir_opt_remove_respills(nir_shader *shader) return nir_shader_instructions_pass(shader, opt_remove_respills_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } @@ -1547,7 +1548,9 @@ nir_opt_trim_stack_values(nir_shader *shader) if (read_mask == 0) continue; - unsigned swiz_map[NIR_MAX_VEC_COMPONENTS] = { 0, }; + unsigned swiz_map[NIR_MAX_VEC_COMPONENTS] = { + 0, + }; unsigned swiz_count = 0; u_foreach_bit(idx, read_mask) swiz_map[idx] = swiz_count++; @@ -1583,11 +1586,10 @@ nir_opt_trim_stack_values(nir_shader *shader) } nir_metadata_preserve(impl, - progress ? - (nir_metadata_dominance | - nir_metadata_block_index | - nir_metadata_loop_analysis) : - nir_metadata_all); + progress ? (nir_metadata_dominance | + nir_metadata_block_index | + nir_metadata_loop_analysis) + : nir_metadata_all); _mesa_hash_table_u64_destroy(value_id_to_mask); @@ -1611,10 +1613,10 @@ sort_scratch_item_by_size_and_value_id(const void *_item1, const void *_item2) /* By ascending value_id */ if (item1->bit_size == item2->bit_size) - return (int) item1->value - (int) item2->value; + return (int)item1->value - (int)item2->value; /* By descending size */ - return (int) item2->bit_size - (int) item1->bit_size; + return (int)item2->bit_size - (int)item1->bit_size; } static bool @@ -1663,7 +1665,7 @@ nir_opt_sort_and_pack_stack(nir_shader *shader, }; util_dynarray_append(&ops, struct scratch_item, item); - _mesa_hash_table_u64_insert(value_id_to_item, value_id, (void *)(uintptr_t)true); + _mesa_hash_table_u64_insert(value_id_to_item, value_id, (void *)(uintptr_t) true); } } @@ -1673,7 +1675,6 @@ nir_opt_sort_and_pack_stack(nir_shader *shader, sizeof(struct scratch_item), sort_scratch_item_by_size_and_value_id); - /* Reorder things on the stack */ _mesa_hash_table_u64_clear(value_id_to_item); @@ -1804,7 +1805,7 @@ nir_opt_stack_loads(nir_shader *shader) nir_foreach_function_impl(impl, shader) { nir_metadata_require(impl, nir_metadata_dominance | - nir_metadata_block_index); + nir_metadata_block_index); bool func_progress = false; nir_foreach_block_safe(block, impl) { @@ -1832,8 +1833,8 @@ nir_opt_stack_loads(nir_shader *shader) nir_metadata_preserve(impl, func_progress ? (nir_metadata_block_index | nir_metadata_dominance | - nir_metadata_loop_analysis) : - nir_metadata_all); + nir_metadata_loop_analysis) + : nir_metadata_all); progress |= func_progress; } @@ -1863,7 +1864,9 @@ split_stack_components_instr(struct nir_builder *b, nir_instr *instr, void *data b->cursor = nir_before_instr(instr); if (intrin->intrinsic == nir_intrinsic_load_stack) { - nir_ssa_def *components[NIR_MAX_VEC_COMPONENTS] = { 0, }; + nir_ssa_def *components[NIR_MAX_VEC_COMPONENTS] = { + 0, + }; for (unsigned c = 0; c < intrin->dest.ssa.num_components; c++) { components[c] = nir_load_stack(b, 1, intrin->dest.ssa.bit_size, .base = nir_intrinsic_base(intrin) + @@ -1903,13 +1906,13 @@ nir_split_stack_components(nir_shader *shader) return nir_shader_instructions_pass(shader, split_stack_components_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } struct stack_op_vectorizer_state { - nir_should_vectorize_mem_func driver_callback; - void *driver_data; + nir_should_vectorize_mem_func driver_callback; + void *driver_data; }; static bool @@ -2003,7 +2006,7 @@ nir_lower_shader_calls(nir_shader *shader, nir_rematerialize_derefs_in_use_blocks_impl(impl); if (progress) - NIR_PASS(_, shader, nir_opt_dead_cf); + NIR_PASS(_, shader, nir_opt_dead_cf); } /* Save the start point of the call stack in scratch */ @@ -2057,7 +2060,7 @@ nir_lower_shader_calls(nir_shader *shader, struct stack_op_vectorizer_state vectorizer_state = { .driver_callback = options->vectorizer_callback, - .driver_data = options->vectorizer_data, + .driver_data = options->vectorizer_data, }; nir_load_store_vectorize_options vect_opts = { .modes = nir_var_shader_temp, diff --git a/src/compiler/nir/nir_lower_single_sampled.c b/src/compiler/nir/nir_lower_single_sampled.c index 65308fb..41899f4 100644 --- a/src/compiler/nir/nir_lower_single_sampled.c +++ b/src/compiler/nir/nir_lower_single_sampled.c @@ -68,7 +68,7 @@ lower_single_sampled_instr(nir_builder *b, case nir_intrinsic_load_barycentric_at_sample: b->cursor = nir_before_instr(instr); lowered = nir_load_barycentric(b, nir_intrinsic_load_barycentric_pixel, - nir_intrinsic_interp_mode(intrin)); + nir_intrinsic_interp_mode(intrin)); if (nir_intrinsic_interp_mode(intrin) == INTERP_MODE_NOPERSPECTIVE) { BITSET_SET(b->shader->info.system_values_read, @@ -122,6 +122,7 @@ nir_lower_single_sampled(nir_shader *shader) return nir_shader_instructions_pass(shader, lower_single_sampled_instr, nir_metadata_block_index | - nir_metadata_dominance, - NULL) || progress; + nir_metadata_dominance, + NULL) || + progress; } diff --git a/src/compiler/nir/nir_lower_ssbo.c b/src/compiler/nir/nir_lower_ssbo.c index cccf12f..be313fd 100644 --- a/src/compiler/nir/nir_lower_ssbo.c +++ b/src/compiler/nir/nir_lower_ssbo.c @@ -61,7 +61,7 @@ lower_ssbo_op(nir_intrinsic_op op) static inline nir_ssa_def * nir_load_ssbo_prop(nir_builder *b, nir_intrinsic_op op, - nir_src *idx, unsigned bitsize) + nir_src *idx, unsigned bitsize) { nir_intrinsic_instr *load = nir_intrinsic_instr_create(b->shader, op); load->num_components = 1; @@ -92,8 +92,8 @@ lower_ssbo_instr(nir_builder *b, nir_intrinsic_instr *intr) nir_ssa_def *address = nir_iadd(b, - nir_ssbo_prop(b, load_ssbo_address, &index, 64), - nir_u2u64(b, offset)); + nir_ssbo_prop(b, load_ssbo_address, &index, 64), + nir_u2u64(b, offset)); /* Create the replacement intrinsic */ @@ -161,16 +161,17 @@ nir_lower_ssbo(nir_shader *shader) nir_foreach_block(block, impl) { nir_foreach_instr_safe(instr, block) { - if (!should_lower_ssbo_instr(instr)) continue; + if (!should_lower_ssbo_instr(instr)) + continue; progress = true; b.cursor = nir_before_instr(instr); nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); nir_ssa_def *replace = lower_ssbo_instr(&b, intr); - if (replace) { + if (replace) { nir_ssa_def_rewrite_uses(&intr->dest.ssa, - replace); + replace); } nir_instr_remove(instr); diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index be7883c..0d146b4 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -21,9 +21,9 @@ * IN THE SOFTWARE. */ +#include "util/u_math.h" #include "nir.h" #include "nir_builder.h" -#include "util/u_math.h" /** * \file nir_opt_intrinsics.c @@ -111,7 +111,7 @@ lower_subgroup_op_to_scalar(nir_builder *b, nir_intrinsic_instr *intrin, assert(intrin->dest.ssa.num_components > 1); nir_ssa_def *value = nir_ssa_for_src(b, intrin->src[0], - intrin->num_components); + intrin->num_components); nir_ssa_def *reads[NIR_MAX_VEC_COMPONENTS]; for (unsigned i = 0; i < intrin->num_components; i++) { @@ -255,7 +255,7 @@ lower_to_shuffle(nir_builder *b, nir_intrinsic_instr *intrin, break; case nir_intrinsic_quad_broadcast: index = nir_ior(b, nir_iand_imm(b, index, ~0x3), - intrin->src[1].ssa); + intrin->src[1].ssa); break; case nir_intrinsic_quad_swap_horizontal: /* For Quad operations, subgroups are divided into quads where @@ -281,11 +281,10 @@ lower_to_shuffle(nir_builder *b, nir_intrinsic_instr *intrin, const unsigned cluster_size = nir_intrinsic_cluster_size(intrin); nir_ssa_def *rotation_group_mask = - cluster_size > 0 ? nir_imm_int(b, (int)(cluster_size - 1)) : - nir_iadd_imm(b, nir_load_subgroup_size(b), -1); + cluster_size > 0 ? nir_imm_int(b, (int)(cluster_size - 1)) : nir_iadd_imm(b, nir_load_subgroup_size(b), -1); index = nir_iand(b, nir_iadd(b, local_id, delta), - rotation_group_mask); + rotation_group_mask); if (cluster_size > 0) { index = nir_iadd(b, index, nir_iand(b, local_id, nir_inot(b, rotation_group_mask))); @@ -319,8 +318,7 @@ lower_to_shuffle(nir_builder *b, nir_intrinsic_instr *intrin, static const struct glsl_type * glsl_type_for_ssa(nir_ssa_def *def) { - const struct glsl_type *comp_type = def->bit_size == 1 ? glsl_bool_type() : - glsl_uintN_t_type(def->bit_size); + const struct glsl_type *comp_type = def->bit_size == 1 ? glsl_bool_type() : glsl_uintN_t_type(def->bit_size); return glsl_replace_vector_type(comp_type, def->num_components); } @@ -369,24 +367,32 @@ lower_shuffle(nir_builder *b, nir_intrinsic_instr *intrin) nir_variable *result = nir_local_variable_create(b->impl, glsl_type_for_ssa(val), "result"); - nir_loop *loop = nir_push_loop(b); { + nir_loop *loop = nir_push_loop(b); + { nir_ssa_def *first_id = nir_read_first_invocation(b, subgroup_id); nir_ssa_def *first_val = nir_read_first_invocation(b, val); nir_ssa_def *first_result = nir_read_invocation(b, val, nir_read_first_invocation(b, id)); - nir_if *nif = nir_push_if(b, nir_ieq(b, id, first_id)); { + nir_if *nif = nir_push_if(b, nir_ieq(b, id, first_id)); + { nir_store_var(b, result, first_val, BITFIELD_MASK(val->num_components)); - } nir_pop_if(b, nif); + } + nir_pop_if(b, nif); - nir_if *nif2 = nir_push_if(b, nir_elect(b, 1)); { - nir_if *nif3 = nir_push_if(b, nir_ult(b, subgroup_id, id)); { + nir_if *nif2 = nir_push_if(b, nir_elect(b, 1)); + { + nir_if *nif3 = nir_push_if(b, nir_ult(b, subgroup_id, id)); + { nir_store_var(b, result, first_result, BITFIELD_MASK(val->num_components)); - } nir_pop_if(b, nif3); + } + nir_pop_if(b, nif3); nir_jump(b, nir_jump_break); - } nir_pop_if(b, nif2); - } nir_pop_loop(b, loop); + } + nir_pop_if(b, nif2); + } + nir_pop_loop(b, loop); return nir_load_var(b, result); } @@ -487,8 +493,8 @@ build_subgroup_mask(nir_builder *b, /* First compute the result assuming one ballot component. */ nir_ssa_def *result = nir_ushr(b, nir_imm_intN_t(b, ~0ull, options->ballot_bit_size), - nir_isub_imm(b, options->ballot_bit_size, - subgroup_size)); + nir_isub_imm(b, options->ballot_bit_size, + subgroup_size)); /* Since the subgroup size and ballot bitsize are both powers of two, there * are two possible cases to consider: @@ -508,8 +514,8 @@ build_subgroup_mask(nir_builder *b, * in all cases. The other components will also get the correct value in * case (1) if we just use the rule in case (2), so we'll get the correct * result if we just follow (2) and then replace the first component with - * "result". - */ + * "result". + */ nir_const_value min_idx[4]; for (unsigned i = 0; i < options->ballot_components; i++) min_idx[i] = nir_const_value_for_int(i * options->ballot_bit_size, 32); @@ -669,11 +675,11 @@ lower_subgroups_instr(nir_builder *b, nir_instr *instr, void *_options) break; case nir_intrinsic_load_subgroup_ge_mask: val = nir_iand(b, build_subgroup_ge_mask(b, options), - build_subgroup_mask(b, options)); + build_subgroup_mask(b, options)); break; case nir_intrinsic_load_subgroup_gt_mask: val = nir_iand(b, build_subgroup_gt_mask(b, options), - build_subgroup_mask(b, options)); + build_subgroup_mask(b, options)); break; case nir_intrinsic_load_subgroup_le_mask: val = nir_inot(b, build_subgroup_gt_mask(b, options)); diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c index fd05625..6517257 100644 --- a/src/compiler/nir/nir_lower_system_values.c +++ b/src/compiler/nir/nir_lower_system_values.c @@ -25,10 +25,10 @@ * */ +#include "util/set.h" +#include "util/u_math.h" #include "nir.h" #include "nir_builder.h" -#include "util/u_math.h" -#include "util/set.h" struct lower_sysval_state { const nir_lower_compute_system_values_options *options; @@ -50,13 +50,13 @@ sanitize_32bit_sysval(nir_builder *b, nir_intrinsic_instr *intrin) return nir_u2uN(b, &intrin->dest.ssa, bit_size); } -static nir_ssa_def* +static nir_ssa_def * build_global_group_size(nir_builder *b, unsigned bit_size) { nir_ssa_def *group_size = nir_load_workgroup_size(b); nir_ssa_def *num_workgroups = nir_load_num_workgroups(b, bit_size); return nir_imul(b, nir_u2uN(b, group_size, bit_size), - num_workgroups); + num_workgroups); } static bool @@ -80,7 +80,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state) case nir_intrinsic_load_vertex_id: if (b->shader->options->vertex_id_zero_based) { return nir_iadd(b, nir_load_vertex_id_zero_base(b), - nir_load_first_vertex(b)); + nir_load_first_vertex(b)); } else { return NULL; } @@ -96,7 +96,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state) */ if (b->shader->options->lower_base_vertex) { return nir_iand(b, nir_load_is_indexed_draw(b), - nir_load_first_vertex(b)); + nir_load_first_vertex(b)); } else { return NULL; } @@ -167,8 +167,8 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state) nir_ssa_def *index = nir_ssa_for_src(b, arr_deref->arr.index, 1); nir_ssa_def *sysval = (deref->var->data.location == SYSTEM_VALUE_TESS_LEVEL_INNER) - ? nir_load_tess_level_inner(b) - : nir_load_tess_level_outer(b); + ? nir_load_tess_level_inner(b) + : nir_load_tess_level_outer(b); return nir_vector_extract(b, sysval, index); } @@ -191,7 +191,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state) switch (var->data.location) { case SYSTEM_VALUE_INSTANCE_INDEX: return nir_iadd(b, nir_load_instance_id(b), - nir_load_base_instance(b)); + nir_load_base_instance(b)); case SYSTEM_VALUE_SUBGROUP_EQ_MASK: case SYSTEM_VALUE_SUBGROUP_GE_MASK: @@ -275,8 +275,8 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state) case SYSTEM_VALUE_MESH_VIEW_INDICES: return nir_load_mesh_view_indices(b, intrin->dest.ssa.num_components, - bit_size, column, .base = 0, - .range = intrin->dest.ssa.num_components * bit_size / 8); + bit_size, column, .base = 0, + .range = intrin->dest.ssa.num_components * bit_size / 8); default: break; @@ -426,7 +426,6 @@ lower_id_to_index_no_umod(nir_builder *b, nir_ssa_def *index, } } - static nir_ssa_def * lower_id_to_index(nir_builder *b, nir_ssa_def *index, nir_ssa_def *size, unsigned bit_size) @@ -512,7 +511,7 @@ lower_compute_system_value_instr(nir_builder *b, */ nir_ssa_def *val = try_lower_id_to_index_1d(b, local_index, - b->shader->info.workgroup_size); + b->shader->info.workgroup_size); if (val) return val; } @@ -605,8 +604,7 @@ lower_compute_system_value_instr(nir_builder *b, if (!b->shader->info.workgroup_size_variable && is_zero) { nir_ssa_scalar defs[3]; for (unsigned i = 0; i < 3; i++) { - defs[i] = is_zero & (1 << i) ? nir_get_ssa_scalar(nir_imm_zero(b, 1, 32), 0) : - nir_get_ssa_scalar(&intrin->dest.ssa, i); + defs[i] = is_zero & (1 << i) ? nir_get_ssa_scalar(nir_imm_zero(b, 1, 32), 0) : nir_get_ssa_scalar(&intrin->dest.ssa, i); } return nir_vec_scalars(b, defs, 3); } @@ -637,9 +635,9 @@ lower_compute_system_value_instr(nir_builder *b, */ nir_ssa_def *index; index = nir_imul(b, nir_channel(b, local_id, 2), - nir_imul(b, size_x, size_y)); + nir_imul(b, size_x, size_y)); index = nir_iadd(b, index, - nir_imul(b, nir_channel(b, local_id, 1), size_x)); + nir_imul(b, nir_channel(b, local_id, 1), size_x)); index = nir_iadd(b, index, nir_channel(b, local_id, 0)); return nir_u2uN(b, index, bit_size); } else { @@ -671,9 +669,8 @@ lower_compute_system_value_instr(nir_builder *b, nir_ssa_def *group_id = nir_load_workgroup_id(b, bit_size); nir_ssa_def *local_id = nir_load_local_invocation_id(b); - return nir_iadd(b, nir_imul(b, group_id, - nir_u2uN(b, group_size, bit_size)), - nir_u2uN(b, local_id, bit_size)); + return nir_iadd(b, nir_imul(b, group_id, nir_u2uN(b, group_size, bit_size)), + nir_u2uN(b, local_id, bit_size)); } else { return NULL; } @@ -682,7 +679,7 @@ lower_compute_system_value_instr(nir_builder *b, case nir_intrinsic_load_global_invocation_id: { if (options && options->has_base_global_invocation_id) return nir_iadd(b, nir_load_global_invocation_id_zero_base(b, bit_size), - nir_load_base_global_invocation_id(b, bit_size)); + nir_load_base_global_invocation_id(b, bit_size)); else if ((options && options->has_base_workgroup_id) || !b->shader->options->has_cs_global_id) return nir_load_global_invocation_id_zero_base(b, bit_size); @@ -700,7 +697,7 @@ lower_compute_system_value_instr(nir_builder *b, /* index = id.x + ((id.y + (id.z * size.y)) * size.x) */ nir_ssa_def *index; index = nir_imul(b, nir_channel(b, global_id, 2), - nir_channel(b, global_size, 1)); + nir_channel(b, global_size, 1)); index = nir_iadd(b, nir_channel(b, global_id, 1), index); index = nir_imul(b, nir_channel(b, global_size, 0), index); index = nir_iadd(b, nir_channel(b, global_id, 0), index); @@ -710,12 +707,12 @@ lower_compute_system_value_instr(nir_builder *b, case nir_intrinsic_load_workgroup_id: { if (options && options->has_base_workgroup_id) return nir_iadd(b, nir_u2uN(b, nir_load_workgroup_id_zero_base(b), bit_size), - nir_load_base_workgroup_id(b, bit_size)); + nir_load_base_workgroup_id(b, bit_size)); else if (options && options->lower_workgroup_id_to_index) { nir_ssa_def *wg_idx = nir_load_workgroup_index(b); nir_ssa_def *val = - try_lower_id_to_index_1d(b, wg_idx, options->num_workgroups); + try_lower_id_to_index_1d(b, wg_idx, options->num_workgroups); if (val) return val; @@ -727,7 +724,6 @@ lower_compute_system_value_instr(nir_builder *b, } return NULL; - } case nir_intrinsic_load_num_workgroups: { @@ -773,7 +769,7 @@ nir_lower_compute_system_values(nir_shader *shader, nir_shader_lower_instructions(shader, lower_compute_system_value_filter, lower_compute_system_value_instr, - (void*)&state); + (void *)&state); ralloc_free(state.lower_once_list); /* Update this so as not to lower it again. */ diff --git a/src/compiler/nir/nir_lower_sysvals_to_varyings.c b/src/compiler/nir/nir_lower_sysvals_to_varyings.c index 6422e9c..ccb0a45 100644 --- a/src/compiler/nir/nir_lower_sysvals_to_varyings.c +++ b/src/compiler/nir/nir_lower_sysvals_to_varyings.c @@ -39,18 +39,18 @@ nir_lower_sysvals_to_varyings(nir_shader *shader, nir_foreach_variable_with_modes(var, shader, nir_var_system_value) { switch (var->data.location) { -#define SYSVAL_TO_VARYING(opt, sysval, varying) \ - case SYSTEM_VALUE_ ## sysval: \ - if (options->opt) { \ - var->data.mode = nir_var_shader_in; \ - var->data.location = VARYING_SLOT_ ## varying; \ - progress = true; \ - } \ - break +#define SYSVAL_TO_VARYING(opt, sysval, varying) \ + case SYSTEM_VALUE_##sysval: \ + if (options->opt) { \ + var->data.mode = nir_var_shader_in; \ + var->data.location = VARYING_SLOT_##varying; \ + progress = true; \ + } \ + break - SYSVAL_TO_VARYING(frag_coord, FRAG_COORD, POS); - SYSVAL_TO_VARYING(point_coord, POINT_COORD, PNTC); - SYSVAL_TO_VARYING(front_face, FRONT_FACE, FACE); + SYSVAL_TO_VARYING(frag_coord, FRAG_COORD, POS); + SYSVAL_TO_VARYING(point_coord, POINT_COORD, PNTC); + SYSVAL_TO_VARYING(front_face, FRONT_FACE, FACE); #undef SYSVAL_TO_VARYING diff --git a/src/compiler/nir/nir_lower_task_shader.c b/src/compiler/nir/nir_lower_task_shader.c index 565665d..2ca041b 100644 --- a/src/compiler/nir/nir_lower_task_shader.c +++ b/src/compiler/nir/nir_lower_task_shader.c @@ -25,9 +25,9 @@ * */ +#include "util/u_math.h" #include "nir.h" #include "nir_builder.h" -#include "util/u_math.h" typedef struct { uint32_t task_count_shared_addr; @@ -49,7 +49,7 @@ lower_nv_task_output(nir_builder *b, if (instr->type != nir_instr_type_intrinsic) return false; - lower_task_nv_state *s = (lower_task_nv_state *) state; + lower_task_nv_state *s = (lower_task_nv_state *)state; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); switch (intrin->intrinsic) { @@ -90,10 +90,10 @@ append_launch_mesh_workgroups_to_nv_task(nir_builder *b, nir_store_shared(b, zero, zero, .base = s->task_count_shared_addr); nir_barrier(b, - .execution_scope = SCOPE_WORKGROUP, - .memory_scope = SCOPE_WORKGROUP, - .memory_semantics = NIR_MEMORY_RELEASE, - .memory_modes = nir_var_mem_shared); + .execution_scope = SCOPE_WORKGROUP, + .memory_scope = SCOPE_WORKGROUP, + .memory_semantics = NIR_MEMORY_RELEASE, + .memory_modes = nir_var_mem_shared); /* At the end of the shader, read the task count from shared memory * and emit launch_mesh_workgroups. @@ -101,10 +101,10 @@ append_launch_mesh_workgroups_to_nv_task(nir_builder *b, b->cursor = nir_after_cf_list(&b->impl->body); nir_barrier(b, - .execution_scope = SCOPE_WORKGROUP, - .memory_scope = SCOPE_WORKGROUP, - .memory_semantics = NIR_MEMORY_ACQUIRE, - .memory_modes = nir_var_mem_shared); + .execution_scope = SCOPE_WORKGROUP, + .memory_scope = SCOPE_WORKGROUP, + .memory_semantics = NIR_MEMORY_ACQUIRE, + .memory_modes = nir_var_mem_shared); nir_ssa_def *task_count = nir_load_shared(b, 1, 32, zero, .base = s->task_count_shared_addr); @@ -172,8 +172,7 @@ lower_task_payload_to_shared(nir_builder *b, * have the same number of sources and same indices. */ unsigned base = nir_intrinsic_base(intrin); - nir_atomic_op atom_op = nir_intrinsic_has_atomic_op(intrin) ? - nir_intrinsic_atomic_op(intrin) : 0; + nir_atomic_op atom_op = nir_intrinsic_has_atomic_op(intrin) ? nir_intrinsic_atomic_op(intrin) : 0; intrin->intrinsic = shared_opcode_for_task_payload(intrin->intrinsic); nir_intrinsic_set_base(intrin, base + s->payload_shared_addr); @@ -220,10 +219,8 @@ emit_shared_to_payload_copy(nir_builder *b, const unsigned vec4_copies_per_invocation = whole_wg_vec4_copies / invocations; const unsigned remaining_vec4_copies = whole_wg_vec4_copies % invocations; const unsigned remaining_dwords = - DIV_ROUND_UP(payload_size - - vec4size * vec4_copies_per_invocation * invocations - - vec4size * remaining_vec4_copies, - 4); + DIV_ROUND_UP(payload_size - vec4size * vec4_copies_per_invocation * invocations - vec4size * remaining_vec4_copies, + 4); const unsigned base_shared_addr = s->payload_shared_addr + payload_addr; nir_ssa_def *invocation_index = nir_load_local_invocation_index(b); @@ -233,9 +230,9 @@ emit_shared_to_payload_copy(nir_builder *b, * This is necessary because we placed the payload in shared memory. */ nir_barrier(b, .execution_scope = SCOPE_WORKGROUP, - .memory_scope = SCOPE_WORKGROUP, - .memory_semantics = NIR_MEMORY_ACQ_REL, - .memory_modes = nir_var_mem_shared); + .memory_scope = SCOPE_WORKGROUP, + .memory_semantics = NIR_MEMORY_ACQ_REL, + .memory_modes = nir_var_mem_shared); /* Payload_size is a size of user-accessible payload, but on some * hardware (e.g. Intel) payload has a private header, which we have @@ -344,7 +341,7 @@ lower_task_intrin(nir_builder *b, if (instr->type != nir_instr_type_intrinsic) return false; - lower_task_state *s = (lower_task_state *) state; + lower_task_state *s = (lower_task_state *)state; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); switch (intrin->intrinsic) { @@ -373,21 +370,21 @@ requires_payload_in_shared(nir_shader *shader, bool atomics, bool small_types) nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); switch (intrin->intrinsic) { - case nir_intrinsic_task_payload_atomic: - case nir_intrinsic_task_payload_atomic_swap: - if (atomics) - return true; - break; - case nir_intrinsic_load_task_payload: - if (small_types && nir_dest_bit_size(intrin->dest) < 32) - return true; - break; - case nir_intrinsic_store_task_payload: - if (small_types && nir_src_bit_size(intrin->src[0]) < 32) - return true; - break; - default: - break; + case nir_intrinsic_task_payload_atomic: + case nir_intrinsic_task_payload_atomic_swap: + if (atomics) + return true; + break; + case nir_intrinsic_load_task_payload: + if (small_types && nir_dest_bit_size(intrin->dest) < 32) + return true; + break; + case nir_intrinsic_store_task_payload: + if (small_types && nir_src_bit_size(intrin->src[0]) < 32) + return true; + break; + default: + break; } } } diff --git a/src/compiler/nir/nir_lower_tess_coord_z.c b/src/compiler/nir/nir_lower_tess_coord_z.c index 2daaabc..36a2a13 100644 --- a/src/compiler/nir/nir_lower_tess_coord_z.c +++ b/src/compiler/nir/nir_lower_tess_coord_z.c @@ -39,5 +39,6 @@ nir_lower_tess_coord_z(nir_shader *shader, bool triangles) { return nir_shader_instructions_pass(shader, lower_tess_coord_z, nir_metadata_block_index | - nir_metadata_dominance, &triangles); + nir_metadata_dominance, + &triangles); } diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index 3ddd847..378bcff 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -47,34 +47,34 @@ typedef struct nir_const_value_3_4 { } nir_const_value_3_4; static const nir_const_value_3_4 bt601_limited_range_csc_coeffs = { { - { { .f32 = 1.16438356f }, { .f32 = 1.16438356f }, { .f32 = 1.16438356f } }, - { { .f32 = 0.0f }, { .f32 = -0.39176229f }, { .f32 = 2.01723214f } }, - { { .f32 = 1.59602678f }, { .f32 = -0.81296764f }, { .f32 = 0.0f } }, + { { .f32 = 1.16438356f }, { .f32 = 1.16438356f }, { .f32 = 1.16438356f } }, + { { .f32 = 0.0f }, { .f32 = -0.39176229f }, { .f32 = 2.01723214f } }, + { { .f32 = 1.59602678f }, { .f32 = -0.81296764f }, { .f32 = 0.0f } }, } }; static const nir_const_value_3_4 bt601_full_range_csc_coeffs = { { - { { .f32 = 1.0f }, { .f32 = 1.0f }, { .f32 = 1.0f } }, - { { .f32 = 0.0f }, { .f32 = -0.34413629f }, { .f32 = 1.772f } }, - { { .f32 = 1.402f }, { .f32 = -0.71413629f }, { .f32 = 0.0f } }, + { { .f32 = 1.0f }, { .f32 = 1.0f }, { .f32 = 1.0f } }, + { { .f32 = 0.0f }, { .f32 = -0.34413629f }, { .f32 = 1.772f } }, + { { .f32 = 1.402f }, { .f32 = -0.71413629f }, { .f32 = 0.0f } }, } }; static const nir_const_value_3_4 bt709_limited_range_csc_coeffs = { { - { { .f32 = 1.16438356f }, { .f32 = 1.16438356f }, { .f32 = 1.16438356f } }, - { { .f32 = 0.0f }, { .f32 = -0.21324861f }, { .f32 = 2.11240179f } }, - { { .f32 = 1.79274107f }, { .f32 = -0.53290933f }, { .f32 = 0.0f } }, + { { .f32 = 1.16438356f }, { .f32 = 1.16438356f }, { .f32 = 1.16438356f } }, + { { .f32 = 0.0f }, { .f32 = -0.21324861f }, { .f32 = 2.11240179f } }, + { { .f32 = 1.79274107f }, { .f32 = -0.53290933f }, { .f32 = 0.0f } }, } }; static const nir_const_value_3_4 bt709_full_range_csc_coeffs = { { - { { .f32 = 1.0f }, { .f32 = 1.0f }, { .f32 = 1.0f } }, - { { .f32 = 0.0f }, { .f32 = -0.18732427f }, { .f32 = 1.8556f } }, - { { .f32 = 1.5748f }, { .f32 = -0.46812427f }, { .f32 = 0.0f } }, + { { .f32 = 1.0f }, { .f32 = 1.0f }, { .f32 = 1.0f } }, + { { .f32 = 0.0f }, { .f32 = -0.18732427f }, { .f32 = 1.8556f } }, + { { .f32 = 1.5748f }, { .f32 = -0.46812427f }, { .f32 = 0.0f } }, } }; static const nir_const_value_3_4 bt2020_limited_range_csc_coeffs = { { - { { .f32 = 1.16438356f }, { .f32 = 1.16438356f }, { .f32 = 1.16438356f } }, - { { .f32 = 0.0f }, { .f32 = -0.18732610f }, { .f32 = 2.14177232f } }, - { { .f32 = 1.67878795f }, { .f32 = -0.65046843f }, { .f32 = 0.0f } }, + { { .f32 = 1.16438356f }, { .f32 = 1.16438356f }, { .f32 = 1.16438356f } }, + { { .f32 = 0.0f }, { .f32 = -0.18732610f }, { .f32 = 2.14177232f } }, + { { .f32 = 1.67878795f }, { .f32 = -0.65046843f }, { .f32 = 0.0f } }, } }; static const nir_const_value_3_4 bt2020_full_range_csc_coeffs = { { - { { .f32 = 1.0f }, { .f32 = 1.0f }, { .f32 = 1.0f } }, - { { .f32 = 0.0f }, { .f32 = -0.16455313f }, { .f32 = 1.88140000f } }, - { { .f32 = 1.4747f }, { .f32 = -0.57139187f }, { .f32 = 0.0f } }, + { { .f32 = 1.0f }, { .f32 = 1.0f }, { .f32 = 1.0f } }, + { { .f32 = 0.0f }, { .f32 = -0.16455313f }, { .f32 = 1.88140000f } }, + { { .f32 = 1.4747f }, { .f32 = -0.57139187f }, { .f32 = 0.0f } }, } }; static const float bt601_limited_range_csc_offsets[3] = { @@ -198,11 +198,11 @@ lower_offset(nir_builder *b, nir_tex_instr *tex) /* The offset is not applied to the array index */ if (tex->coord_components == 2) { offset_coord = nir_vec2(b, nir_channel(b, offset_coord, 0), - nir_channel(b, coord, 1)); + nir_channel(b, coord, 1)); } else if (tex->coord_components == 3) { offset_coord = nir_vec3(b, nir_channel(b, offset_coord, 0), - nir_channel(b, offset_coord, 1), - nir_channel(b, coord, 2)); + nir_channel(b, offset_coord, 1), + nir_channel(b, coord, 2)); } else { unreachable("Invalid number of components"); } @@ -491,18 +491,18 @@ lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) { - b->cursor = nir_after_instr(&tex->instr); - - nir_ssa_def *y = sample_plane(b, tex, 0, options); - nir_ssa_def *uxvx = sample_plane(b, tex, 1, options); - - convert_yuv_to_rgb(b, tex, - nir_channel(b, y, 1), - nir_channel(b, uxvx, 0), - nir_channel(b, uxvx, 2), - nir_imm_float(b, 1.0f), - options, - texture_index); + b->cursor = nir_after_instr(&tex->instr); + + nir_ssa_def *y = sample_plane(b, tex, 0, options); + nir_ssa_def *uxvx = sample_plane(b, tex, 1, options); + + convert_yuv_to_rgb(b, tex, + nir_channel(b, y, 1), + nir_channel(b, uxvx, 0), + nir_channel(b, uxvx, 2), + nir_imm_float(b, 1.0f), + options, + texture_index); } static void @@ -510,18 +510,18 @@ lower_xy_vxux_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) { - b->cursor = nir_after_instr(&tex->instr); - - nir_ssa_def *y = sample_plane(b, tex, 0, options); - nir_ssa_def *vxux = sample_plane(b, tex, 1, options); - - convert_yuv_to_rgb(b, tex, - nir_channel(b, y, 1), - nir_channel(b, vxux, 2), - nir_channel(b, vxux, 0), - nir_imm_float(b, 1.0f), - options, - texture_index); + b->cursor = nir_after_instr(&tex->instr); + + nir_ssa_def *y = sample_plane(b, tex, 0, options); + nir_ssa_def *vxux = sample_plane(b, tex, 1, options); + + convert_yuv_to_rgb(b, tex, + nir_channel(b, y, 1), + nir_channel(b, vxux, 2), + nir_channel(b, vxux, 0), + nir_imm_float(b, 1.0f), + options, + texture_index); } static void @@ -529,17 +529,17 @@ lower_ayuv_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) { - b->cursor = nir_after_instr(&tex->instr); + b->cursor = nir_after_instr(&tex->instr); - nir_ssa_def *ayuv = sample_plane(b, tex, 0, options); + nir_ssa_def *ayuv = sample_plane(b, tex, 0, options); - convert_yuv_to_rgb(b, tex, - nir_channel(b, ayuv, 2), - nir_channel(b, ayuv, 1), - nir_channel(b, ayuv, 0), - nir_channel(b, ayuv, 3), - options, - texture_index); + convert_yuv_to_rgb(b, tex, + nir_channel(b, ayuv, 2), + nir_channel(b, ayuv, 1), + nir_channel(b, ayuv, 0), + nir_channel(b, ayuv, 3), + options, + texture_index); } static void @@ -547,17 +547,17 @@ lower_y41x_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) { - b->cursor = nir_after_instr(&tex->instr); + b->cursor = nir_after_instr(&tex->instr); - nir_ssa_def *y41x = sample_plane(b, tex, 0, options); + nir_ssa_def *y41x = sample_plane(b, tex, 0, options); - convert_yuv_to_rgb(b, tex, - nir_channel(b, y41x, 1), - nir_channel(b, y41x, 0), - nir_channel(b, y41x, 2), - nir_channel(b, y41x, 3), - options, - texture_index); + convert_yuv_to_rgb(b, tex, + nir_channel(b, y41x, 1), + nir_channel(b, y41x, 0), + nir_channel(b, y41x, 2), + nir_channel(b, y41x, 3), + options, + texture_index); } static void @@ -565,17 +565,17 @@ lower_xyuv_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) { - b->cursor = nir_after_instr(&tex->instr); + b->cursor = nir_after_instr(&tex->instr); - nir_ssa_def *xyuv = sample_plane(b, tex, 0, options); + nir_ssa_def *xyuv = sample_plane(b, tex, 0, options); - convert_yuv_to_rgb(b, tex, - nir_channel(b, xyuv, 2), - nir_channel(b, xyuv, 1), - nir_channel(b, xyuv, 0), - nir_imm_float(b, 1.0f), - options, - texture_index); + convert_yuv_to_rgb(b, tex, + nir_channel(b, xyuv, 2), + nir_channel(b, xyuv, 1), + nir_channel(b, xyuv, 0), + nir_imm_float(b, 1.0f), + options, + texture_index); } static void @@ -583,17 +583,17 @@ lower_yuv_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) { - b->cursor = nir_after_instr(&tex->instr); + b->cursor = nir_after_instr(&tex->instr); - nir_ssa_def *yuv = sample_plane(b, tex, 0, options); + nir_ssa_def *yuv = sample_plane(b, tex, 0, options); - convert_yuv_to_rgb(b, tex, - nir_channel(b, yuv, 0), - nir_channel(b, yuv, 1), - nir_channel(b, yuv, 2), - nir_imm_float(b, 1.0f), - options, - texture_index); + convert_yuv_to_rgb(b, tex, + nir_channel(b, yuv, 0), + nir_channel(b, yuv, 1), + nir_channel(b, yuv, 2), + nir_imm_float(b, 1.0f), + options, + texture_index); } static void @@ -601,17 +601,17 @@ lower_yu_yv_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) { - b->cursor = nir_after_instr(&tex->instr); + b->cursor = nir_after_instr(&tex->instr); - nir_ssa_def *yuv = sample_plane(b, tex, 0, options); + nir_ssa_def *yuv = sample_plane(b, tex, 0, options); - convert_yuv_to_rgb(b, tex, - nir_channel(b, yuv, 1), - nir_channel(b, yuv, 2), - nir_channel(b, yuv, 0), - nir_imm_float(b, 1.0f), - options, - texture_index); + convert_yuv_to_rgb(b, tex, + nir_channel(b, yuv, 1), + nir_channel(b, yuv, 2), + nir_channel(b, yuv, 0), + nir_imm_float(b, 1.0f), + options, + texture_index); } static void @@ -619,17 +619,17 @@ lower_yv_yu_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) { - b->cursor = nir_after_instr(&tex->instr); + b->cursor = nir_after_instr(&tex->instr); - nir_ssa_def *yuv = sample_plane(b, tex, 0, options); + nir_ssa_def *yuv = sample_plane(b, tex, 0, options); - convert_yuv_to_rgb(b, tex, - nir_channel(b, yuv, 2), - nir_channel(b, yuv, 1), - nir_channel(b, yuv, 0), - nir_imm_float(b, 1.0f), - options, - texture_index); + convert_yuv_to_rgb(b, tex, + nir_channel(b, yuv, 2), + nir_channel(b, yuv, 1), + nir_channel(b, yuv, 0), + nir_imm_float(b, 1.0f), + options, + texture_index); } /* @@ -827,7 +827,7 @@ lower_gradient(nir_builder *b, nir_tex_instr *tex) nir_ssa_def *size = nir_channels(b, nir_i2f32(b, nir_get_texture_size(b, tex)), - component_mask); + component_mask); /* Scale the gradients by width and height. Effectively, the incoming * gradients are s'(x,y), t'(x,y), and r'(x,y) from equation 3.19 in the @@ -1107,7 +1107,7 @@ lower_tex_packing(nir_builder *b, nir_tex_instr *tex, return false; case nir_lower_tex_packing_16: { - static const unsigned bits[4] = {16, 16, 16, 16}; + static const unsigned bits[4] = { 16, 16, 16, 16 }; switch (nir_alu_type_get_base_type(tex->dest_type)) { case nir_type_float: @@ -1215,7 +1215,7 @@ lower_tg4_offsets(nir_builder *b, nir_tex_instr *tex) } nir_ssa_def *offset = nir_imm_ivec2(b, tex->tg4_offsets[i][0], - tex->tg4_offsets[i][1]); + tex->tg4_offsets[i][1]); nir_tex_src src = nir_tex_src_for_ssa(nir_tex_src_offset, offset); tex_copy->src[tex_copy->num_srcs - 1] = src; @@ -1299,9 +1299,9 @@ nir_lower_txs_cube_array(nir_builder *b, nir_tex_instr *tex) assert(tex->dest.ssa.num_components == 3); nir_ssa_def *size = &tex->dest.ssa; size = nir_vec3(b, nir_channel(b, size, 1), - nir_channel(b, size, 1), - nir_idiv(b, nir_channel(b, size, 2), - nir_imm_int(b, 6))); + nir_channel(b, size, 1), + nir_idiv(b, nir_channel(b, size, 2), + nir_imm_int(b, 6))); nir_ssa_def_rewrite_uses_after(&tex->dest.ssa, size, size->parent_instr); } @@ -1405,7 +1405,7 @@ nir_lower_lod_zero_width(nir_builder *b, nir_tex_instr *tex) /* Replace the raw LOD by -FLT_MAX if the sum is 0 for all coordinates. */ nir_ssa_def *adjusted_lod = nir_bcsel(b, is_zero, nir_imm_float(b, -FLT_MAX), - nir_channel(b, &tex->dest.ssa, 1)); + nir_channel(b, &tex->dest.ssa, 1)); nir_ssa_def *def = nir_vec2(b, nir_channel(b, &tex->dest.ssa, 0), adjusted_lod); @@ -1465,11 +1465,11 @@ nir_lower_tex_block(nir_block *block, nir_builder *b, /* ignore saturate for txf ops: these don't use samplers and can't GL_CLAMP */ if (nir_tex_instr_need_sampler(tex)) { if ((1 << tex->sampler_index) & options->saturate_r) - sat_mask |= (1 << 2); /* .z */ + sat_mask |= (1 << 2); /* .z */ if ((1 << tex->sampler_index) & options->saturate_t) - sat_mask |= (1 << 1); /* .y */ + sat_mask |= (1 << 1); /* .y */ if ((1 << tex->sampler_index) & options->saturate_s) - sat_mask |= (1 << 0); /* .x */ + sat_mask |= (1 << 0); /* .x */ } if (options->lower_index_to_offset) @@ -1722,7 +1722,7 @@ nir_lower_tex_impl(nir_function_impl *impl, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); return progress; } diff --git a/src/compiler/nir/nir_lower_tex_shadow.c b/src/compiler/nir/nir_lower_tex_shadow.c index 10a7e51..48030af 100644 --- a/src/compiler/nir/nir_lower_tex_shadow.c +++ b/src/compiler/nir/nir_lower_tex_shadow.c @@ -49,14 +49,13 @@ static const struct glsl_type * strip_shadow(const struct glsl_type *type) { const struct glsl_type *new_type = - glsl_sampler_type( - glsl_get_sampler_dim(type), - false, glsl_sampler_type_is_array(type), - GLSL_TYPE_FLOAT); + glsl_sampler_type( + glsl_get_sampler_dim(type), + false, glsl_sampler_type_is_array(type), + GLSL_TYPE_FLOAT); return new_type; } - static const struct glsl_type * strip_shadow_with_array(const struct glsl_type *type) { @@ -107,17 +106,16 @@ nir_lower_tex_shadow_impl(nir_builder *b, nir_instr *instr, void *options) if (proj_index >= 0) cmp = nir_fmul(b, cmp, nir_frcp(b, tex->src[proj_index].src.ssa)); - nir_ssa_def * result = - nir_compare_func(b, - sampler_binding < state->n_states ? - state->compare_func[sampler_binding] : COMPARE_FUNC_ALWAYS, - cmp, tex_r); + nir_ssa_def *result = + nir_compare_func(b, + sampler_binding < state->n_states ? state->compare_func[sampler_binding] : COMPARE_FUNC_ALWAYS, + cmp, tex_r); result = nir_b2f32(b, result); nir_ssa_def *one = nir_imm_float(b, 1.0); nir_ssa_def *zero = nir_imm_float(b, 0.0); - nir_ssa_def *lookup[6] = {result, NULL, NULL, NULL, zero, one}; + nir_ssa_def *lookup[6] = { result, NULL, NULL, NULL, zero, one }; nir_ssa_def *r[4] = { result, result, result, result }; if (sampler_binding < state->n_states) { @@ -146,12 +144,12 @@ nir_lower_tex_shadow(nir_shader *s, enum compare_func *compare_func, nir_lower_tex_shadow_swizzle *tex_swizzles) { - sampler_state state = {n_states, compare_func, tex_swizzles}; + sampler_state state = { n_states, compare_func, tex_swizzles }; bool result = - nir_shader_lower_instructions(s, - nir_lower_tex_shadow_filter, - nir_lower_tex_shadow_impl, - &state); + nir_shader_lower_instructions(s, + nir_lower_tex_shadow_filter, + nir_lower_tex_shadow_impl, + &state); return result; } diff --git a/src/compiler/nir/nir_lower_texcoord_replace.c b/src/compiler/nir/nir_lower_texcoord_replace.c index 9b342b5..849d2b9 100644 --- a/src/compiler/nir/nir_lower_texcoord_replace.c +++ b/src/compiler/nir/nir_lower_texcoord_replace.c @@ -87,8 +87,8 @@ nir_lower_texcoord_replace_impl(nir_function_impl *impl, if (yinvert) y = nir_fsub_imm(&b, 1.0, y); new_coord = nir_vec4(&b, nir_channel(&b, new_coord, 0), - y, - zero, one); + y, + zero, one); nir_foreach_block(block, impl) { nir_foreach_instr_safe(instr, block) { @@ -111,7 +111,7 @@ nir_lower_texcoord_replace_impl(nir_function_impl *impl, nir_ssa_def *index = get_io_index(&b, deref); nir_ssa_def *mask = nir_ishl(&b, nir_imm_int(&b, 1), - nir_iadd_imm(&b, index, base)); + nir_iadd_imm(&b, index, base)); nir_ssa_def *cond = nir_test_mask(&b, mask, coord_replace); nir_ssa_def *result = nir_bcsel(&b, cond, new_coord, @@ -124,7 +124,7 @@ nir_lower_texcoord_replace_impl(nir_function_impl *impl, } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } void diff --git a/src/compiler/nir/nir_lower_texcoord_replace_late.c b/src/compiler/nir/nir_lower_texcoord_replace_late.c index d699786..6a43974 100644 --- a/src/compiler/nir/nir_lower_texcoord_replace_late.c +++ b/src/compiler/nir/nir_lower_texcoord_replace_late.c @@ -85,22 +85,22 @@ nir_lower_texcoord_replace_late(nir_shader *s, unsigned coord_replace, assert(s->info.stage == MESA_SHADER_FRAGMENT); assert(coord_replace != 0); - uint64_t replace_mask = (((uint64_t) coord_replace) << VARYING_SLOT_TEX0); + uint64_t replace_mask = (((uint64_t)coord_replace) << VARYING_SLOT_TEX0); /* If no relevant texcoords are read, there's nothing to do */ if (!(s->info.inputs_read & replace_mask)) return; /* Otherwise, we're going to replace these texcoord reads with a PNTC read */ - s->info.inputs_read &= ~(((uint64_t) coord_replace) << VARYING_SLOT_TEX0); + s->info.inputs_read &= ~(((uint64_t)coord_replace) << VARYING_SLOT_TEX0); if (!point_coord_is_sysval) s->info.inputs_read |= BITFIELD64_BIT(VARYING_SLOT_PNTC); nir_shader_instructions_pass(s, pass, - nir_metadata_block_index | nir_metadata_dominance, - &(struct opts) { - .coord_replace = coord_replace, - .point_coord_is_sysval = point_coord_is_sysval, - }); + nir_metadata_block_index | nir_metadata_dominance, + &(struct opts){ + .coord_replace = coord_replace, + .point_coord_is_sysval = point_coord_is_sysval, + }); } diff --git a/src/compiler/nir/nir_lower_two_sided_color.c b/src/compiler/nir/nir_lower_two_sided_color.c index 6ef55d6..eed09f2 100644 --- a/src/compiler/nir/nir_lower_two_sided_color.c +++ b/src/compiler/nir/nir_lower_two_sided_color.c @@ -27,20 +27,19 @@ #include "nir.h" #include "nir_builder.h" -#define MAX_COLORS 2 /* VARYING_SLOT_COL0/COL1 */ +#define MAX_COLORS 2 /* VARYING_SLOT_COL0/COL1 */ typedef struct { - nir_builder b; - nir_shader *shader; + nir_builder b; + nir_shader *shader; bool face_sysval; struct { - nir_variable *front; /* COLn */ - nir_variable *back; /* BFCn */ + nir_variable *front; /* COLn */ + nir_variable *back; /* BFCn */ } colors[MAX_COLORS]; int colors_count; } lower_2side_state; - /* Lowering pass for fragment shaders to emulated two-sided-color. For * each COLOR input, a corresponding BCOLOR input is created, and bcsel * instruction used to select front or back color based on FACE. @@ -95,8 +94,8 @@ setup_inputs(lower_2side_state *state) slot = VARYING_SLOT_BFC1; state->colors[i].back = create_input( - state->shader, slot, - state->colors[i].front->data.interpolation); + state->shader, slot, + state->colors[i].front->data.interpolation); } return 0; @@ -138,12 +137,12 @@ nir_lower_two_sided_color_instr(nir_builder *b, nir_instr *instr, void *data) return false; /* replace load_input(COLn) with - * bcsel(load_system_value(FACE), load_input(COLn), load_input(BFCn)) - */ + * bcsel(load_system_value(FACE), load_input(COLn), load_input(BFCn)) + */ b->cursor = nir_before_instr(&intr->instr); /* gl_FrontFace is a boolean but the intrinsic constructor creates - * 32-bit value by default. - */ + * 32-bit value by default. + */ nir_ssa_def *face; if (state->face_sysval) face = nir_load_front_face(b, 1); @@ -157,10 +156,10 @@ nir_lower_two_sided_color_instr(nir_builder *b, nir_instr *instr, void *data) nir_ssa_def *front, *back; if (intr->intrinsic == nir_intrinsic_load_deref) { front = nir_load_var(b, state->colors[idx].front); - back = nir_load_var(b, state->colors[idx].back); + back = nir_load_var(b, state->colors[idx].back); } else { front = load_input(b, state->colors[idx].front); - back = load_input(b, state->colors[idx].back); + back = load_input(b, state->colors[idx].back); } nir_ssa_def *color = nir_bcsel(b, face, front, back); @@ -186,6 +185,6 @@ nir_lower_two_sided_color(nir_shader *shader, bool face_sysval) return nir_shader_instructions_pass(shader, nir_lower_two_sided_color_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); } diff --git a/src/compiler/nir/nir_lower_ubo_vec4.c b/src/compiler/nir/nir_lower_ubo_vec4.c index ba7c29e..e51f94e 100644 --- a/src/compiler/nir/nir_lower_ubo_vec4.c +++ b/src/compiler/nir/nir_lower_ubo_vec4.c @@ -105,7 +105,7 @@ nir_lower_ubo_vec4_lower(nir_builder *b, nir_instr *instr, void *data) unsigned num_components = intr->num_components; bool aligned_mul = (align_mul == 16 && - align_offset + chan_size_bytes * num_components <= 16); + align_offset + chan_size_bytes * num_components <= 16); if (!aligned_mul) num_components = chans_per_vec4; @@ -143,8 +143,8 @@ nir_lower_ubo_vec4_lower(nir_builder *b, nir_instr *instr, void *data) nir_component_mask_t high_channels = low_channels << (8 / chan_size_bytes); result = nir_bcsel(b, nir_test_mask(b, byte_offset, 8), - nir_channels(b, result, high_channels), - nir_channels(b, result, low_channels)); + nir_channels(b, result, high_channels), + nir_channels(b, result, low_channels)); } else { /* General fallback case: Per-result-channel bcsel-based extraction * from two separate vec4 loads. diff --git a/src/compiler/nir/nir_lower_undef_to_zero.c b/src/compiler/nir/nir_lower_undef_to_zero.c index c3c5193..93e5617 100644 --- a/src/compiler/nir/nir_lower_undef_to_zero.c +++ b/src/compiler/nir/nir_lower_undef_to_zero.c @@ -49,7 +49,7 @@ lower_undef_instr_to_zero(nir_builder *b, nir_instr *instr, UNUSED void *_state) nir_ssa_undef_instr *und = nir_instr_as_ssa_undef(instr); b->cursor = nir_instr_remove(&und->instr); nir_ssa_def *zero = nir_imm_zero(b, und->def.num_components, - und->def.bit_size); + und->def.bit_size); nir_ssa_def_rewrite_uses(&und->def, zero); return true; } @@ -59,5 +59,6 @@ nir_lower_undef_to_zero(nir_shader *shader) { return nir_shader_instructions_pass(shader, lower_undef_instr_to_zero, nir_metadata_block_index | - nir_metadata_dominance, NULL); + nir_metadata_dominance, + NULL); } diff --git a/src/compiler/nir/nir_lower_uniforms_to_ubo.c b/src/compiler/nir/nir_lower_uniforms_to_ubo.c index 4c1ab50..f38bd37 100644 --- a/src/compiler/nir/nir_lower_uniforms_to_ubo.c +++ b/src/compiler/nir/nir_lower_uniforms_to_ubo.c @@ -77,16 +77,16 @@ nir_lower_uniforms_to_ubo_instr(nir_builder *b, nir_instr *instr, void *data) */ assert(!state->dword_packed); load_result = nir_load_ubo_vec4(b, intr->num_components, intr->dest.ssa.bit_size, - ubo_idx, uniform_offset, .base=nir_intrinsic_base(intr)); + ubo_idx, uniform_offset, .base = nir_intrinsic_base(intr)); } else { /* For PIPE_CAP_PACKED_UNIFORMS, the uniforms are packed with the * base/offset in dword units instead of vec4 units. */ int multiplier = state->dword_packed ? 4 : 16; load_result = nir_load_ubo(b, intr->num_components, intr->dest.ssa.bit_size, - ubo_idx, - nir_iadd_imm(b, nir_imul_imm(b, uniform_offset, multiplier), - nir_intrinsic_base(intr) * multiplier)); + ubo_idx, + nir_iadd_imm(b, nir_imul_imm(b, uniform_offset, multiplier), + nir_intrinsic_base(intr) * multiplier)); nir_intrinsic_instr *load = nir_instr_as_intrinsic(load_result->parent_instr); /* If it's const, set the alignment to our known constant offset. If @@ -100,11 +100,10 @@ nir_lower_uniforms_to_ubo_instr(nir_builder *b, nir_instr *instr, void *data) if (nir_src_is_const(intr->src[0])) { nir_intrinsic_set_align(load, NIR_ALIGN_MUL_MAX, (nir_src_as_uint(intr->src[0]) + - nir_intrinsic_base(intr) * multiplier) % - NIR_ALIGN_MUL_MAX); + nir_intrinsic_base(intr) * multiplier) % + NIR_ALIGN_MUL_MAX); } else { - nir_intrinsic_set_align(load, MAX2(multiplier, - intr->dest.ssa.bit_size / 8), 0); + nir_intrinsic_set_align(load, MAX2(multiplier, intr->dest.ssa.bit_size / 8), 0); } nir_intrinsic_set_range_base(load, nir_intrinsic_base(intr) * multiplier); @@ -132,7 +131,7 @@ nir_lower_uniforms_to_ubo(nir_shader *shader, bool dword_packed, bool load_vec4) progress = nir_shader_instructions_pass(shader, nir_lower_uniforms_to_ubo_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); if (progress) { @@ -163,8 +162,8 @@ nir_lower_uniforms_to_ubo(nir_shader *shader, bool dword_packed, bool load_vec4) .location = -1, }; ubo->interface_type = - glsl_interface_type(&field, 1, GLSL_INTERFACE_PACKING_STD430, - false, "__ubo0_interface"); + glsl_interface_type(&field, 1, GLSL_INTERFACE_PACKING_STD430, + false, "__ubo0_interface"); } } diff --git a/src/compiler/nir/nir_lower_var_copies.c b/src/compiler/nir/nir_lower_var_copies.c index 8ca4fe2..c773807 100644 --- a/src/compiler/nir/nir_lower_var_copies.c +++ b/src/compiler/nir/nir_lower_var_copies.c @@ -21,10 +21,10 @@ * IN THE SOFTWARE. */ +#include "compiler/nir_types.h" #include "nir.h" #include "nir_builder.h" #include "nir_deref.h" -#include "compiler/nir_types.h" /* * Lowers all copy intrinsics to sequences of load/store intrinsics. @@ -105,9 +105,9 @@ nir_lower_deref_copy_instr(nir_builder *b, nir_intrinsic_instr *copy) b->cursor = nir_before_instr(©->instr); emit_deref_copy_load_store(b, dst_path.path[0], &dst_path.path[1], - src_path.path[0], &src_path.path[1], - nir_intrinsic_dst_access(copy), - nir_intrinsic_src_access(copy)); + src_path.path[0], &src_path.path[1], + nir_intrinsic_dst_access(copy), + nir_intrinsic_src_access(copy)); nir_deref_path_finish(&dst_path); nir_deref_path_finish(&src_path); @@ -144,6 +144,6 @@ nir_lower_var_copies(nir_shader *shader) return nir_shader_instructions_pass(shader, lower_var_copies_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_variable_initializers.c b/src/compiler/nir/nir_lower_variable_initializers.c index 40ccf7a..cf9ae5f 100644 --- a/src/compiler/nir/nir_lower_variable_initializers.c +++ b/src/compiler/nir/nir_lower_variable_initializers.c @@ -81,7 +81,6 @@ lower_const_initializer(struct nir_builder *b, struct exec_list *var_list, progress = true; var->pointer_initializer = NULL; } - } return progress; @@ -121,8 +120,8 @@ nir_lower_variable_initializers(nir_shader *shader, nir_variable_mode modes) if (impl_progress) { progress = true; nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs); + nir_metadata_dominance | + nir_metadata_live_ssa_defs); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -177,8 +176,8 @@ nir_zero_initialize_shared_memory(nir_shader *shader, nir_pop_if(&b, NULL); nir_store_shared(&b, nir_imm_zero(&b, chunk_comps, 32), offset, - .align_mul=chunk_size, - .write_mask=((1 << chunk_comps) - 1)); + .align_mul = chunk_size, + .write_mask = ((1 << chunk_comps) - 1)); nir_ssa_def *new_offset = nir_iadd_imm(&b, offset, chunk_size * local_count); nir_store_var(&b, it, new_offset, 0x1); diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c b/src/compiler/nir/nir_lower_vars_to_ssa.c index 9038d4f..3852ea9 100644 --- a/src/compiler/nir/nir_lower_vars_to_ssa.c +++ b/src/compiler/nir/nir_lower_vars_to_ssa.c @@ -27,7 +27,6 @@ #include "nir_phi_builder.h" #include "nir_vla.h" - struct deref_node { struct deref_node *parent; const struct glsl_type *type; @@ -246,8 +245,8 @@ get_deref_node(nir_deref_instr *deref, struct lower_variables_state *state) /* \sa foreach_deref_node_match */ static void foreach_deref_node_worker(struct deref_node *node, nir_deref_instr **path, - void (* cb)(struct deref_node *node, - struct lower_variables_state *state), + void (*cb)(struct deref_node *node, + struct lower_variables_state *state), struct lower_variables_state *state) { if (*path == NULL) { @@ -297,8 +296,8 @@ foreach_deref_node_worker(struct deref_node *node, nir_deref_instr **path, */ static void foreach_deref_node_match(nir_deref_path *path, - void (* cb)(struct deref_node *node, - struct lower_variables_state *state), + void (*cb)(struct deref_node *node, + struct lower_variables_state *state), struct lower_variables_state *state) { assert(path->path[0]->deref_type == nir_deref_type_var); @@ -802,7 +801,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl) nir_phi_builder_finish(state.phi_builder); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); ralloc_free(state.dead_ctx); diff --git a/src/compiler/nir/nir_lower_vec3_to_vec4.c b/src/compiler/nir/nir_lower_vec3_to_vec4.c index 3d3d3d9..9e84dd4 100644 --- a/src/compiler/nir/nir_lower_vec3_to_vec4.c +++ b/src/compiler/nir/nir_lower_vec3_to_vec4.c @@ -26,7 +26,7 @@ static bool lower_vec3_to_vec4_instr(nir_builder *b, nir_instr *instr, void *data) { - nir_variable_mode modes = *((nir_variable_mode*) data); + nir_variable_mode modes = *((nir_variable_mode *)data); switch (instr->type) { case nir_instr_type_deref: { @@ -89,12 +89,12 @@ lower_vec3_to_vec4_instr(nir_builder *b, nir_instr *instr, void *data) nir_deref_instr *dst = nir_src_as_deref(intrin->src[0]); nir_deref_instr *src = nir_src_as_deref(intrin->src[0]); /* If we convert once side of a copy and not the other, that - * would be very bad. - */ + * would be very bad. + */ if (nir_deref_mode_may_be(dst, modes) || nir_deref_mode_may_be(src, modes)) { - assert(nir_deref_mode_must_be(dst, modes)); - assert(nir_deref_mode_must_be(src, modes)); + assert(nir_deref_mode_must_be(dst, modes)); + assert(nir_deref_mode_must_be(src, modes)); } break; } @@ -147,7 +147,7 @@ nir_lower_vec3_to_vec4(nir_shader *shader, nir_variable_mode modes) progress |= nir_shader_instructions_pass(shader, lower_vec3_to_vec4_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &modes); return progress; diff --git a/src/compiler/nir/nir_lower_vec_to_regs.c b/src/compiler/nir/nir_lower_vec_to_regs.c index 9074ad5..d820bd2 100644 --- a/src/compiler/nir/nir_lower_vec_to_regs.c +++ b/src/compiler/nir/nir_lower_vec_to_regs.c @@ -35,7 +35,7 @@ insert_store(nir_builder *b, nir_ssa_def *reg, nir_alu_instr *vec, unsigned num_components = nir_dest_num_components(vec->dest.dest); assert(num_components == nir_op_infos[vec->op].num_inputs); unsigned write_mask = 0; - unsigned swiz[NIR_MAX_VEC_COMPONENTS] = {0}; + unsigned swiz[NIR_MAX_VEC_COMPONENTS] = { 0 }; for (unsigned i = start_idx; i < num_components; i++) { if (vec->src[i].src.ssa == src) { @@ -230,7 +230,7 @@ lower(nir_builder *b, nir_instr *instr, void *data_) nir_rewrite_uses_to_load_reg(b, &vec->dest.dest.ssa, reg); } else { /* Otherwise, we replace with a swizzle */ - unsigned swiz[NIR_MAX_VEC_COMPONENTS] = {0}; + unsigned swiz[NIR_MAX_VEC_COMPONENTS] = { 0 }; for (unsigned i = 0; i < num_components; ++i) { swiz[i] = vec->src[i].swizzle[0]; @@ -258,5 +258,6 @@ nir_lower_vec_to_regs(nir_shader *shader, nir_instr_writemask_filter_cb cb, return nir_shader_instructions_pass(shader, lower, nir_metadata_block_index | - nir_metadata_dominance, &data); + nir_metadata_dominance, + &data); } diff --git a/src/compiler/nir/nir_lower_viewport_transform.c b/src/compiler/nir/nir_lower_viewport_transform.c index dbf0f6a..31b2bf5 100644 --- a/src/compiler/nir/nir_lower_viewport_transform.c +++ b/src/compiler/nir/nir_lower_viewport_transform.c @@ -94,13 +94,11 @@ lower_viewport_transform_instr(nir_builder *b, nir_instr *instr, bool nir_lower_viewport_transform(nir_shader *shader) { - assert((shader->info.stage == MESA_SHADER_VERTEX) - || (shader->info.stage == MESA_SHADER_GEOMETRY) - || (shader->info.stage == MESA_SHADER_TESS_EVAL)); + assert((shader->info.stage == MESA_SHADER_VERTEX) || (shader->info.stage == MESA_SHADER_GEOMETRY) || (shader->info.stage == MESA_SHADER_TESS_EVAL)); return nir_shader_instructions_pass(shader, lower_viewport_transform_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_wpos_center.c b/src/compiler/nir/nir_lower_wpos_center.c index e275a46..b80221b 100644 --- a/src/compiler/nir/nir_lower_wpos_center.c +++ b/src/compiler/nir/nir_lower_wpos_center.c @@ -22,9 +22,9 @@ * IN THE SOFTWARE. */ +#include "program/prog_instruction.h" #include "nir.h" #include "nir_builder.h" -#include "program/prog_instruction.h" /** * This pass adds <0.5, 0.5> to all uses of gl_FragCoord. @@ -86,6 +86,6 @@ nir_lower_wpos_center(nir_shader *shader) return nir_shader_instructions_pass(shader, lower_wpos_center_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_lower_wpos_ytransform.c b/src/compiler/nir/nir_lower_wpos_ytransform.c index e2651ce..05a347f 100644 --- a/src/compiler/nir/nir_lower_wpos_ytransform.c +++ b/src/compiler/nir/nir_lower_wpos_ytransform.c @@ -36,8 +36,8 @@ typedef struct { const nir_lower_wpos_ytransform_options *options; - nir_shader *shader; - nir_builder b; + nir_shader *shader; + nir_builder b; nir_variable *transform; } lower_wpos_ytransform_state; @@ -114,14 +114,12 @@ emit_wpos_adjustment(lower_wpos_ytransform_state *state, */ if (invert) { /* wpos_temp.y = wpos_input * wpostrans.xxxx + wpostrans.yyyy */ - wpos_temp_y = nir_fadd(b, nir_fmul(b, nir_channel(b, wpos_temp, 1), - nir_channel(b, wpostrans, 0)), - nir_channel(b, wpostrans, 1)); + wpos_temp_y = nir_fadd(b, nir_fmul(b, nir_channel(b, wpos_temp, 1), nir_channel(b, wpostrans, 0)), + nir_channel(b, wpostrans, 1)); } else { /* wpos_temp.y = wpos_input * wpostrans.zzzz + wpostrans.wwww */ - wpos_temp_y = nir_fadd(b, nir_fmul(b, nir_channel(b, wpos_temp, 1), - nir_channel(b, wpostrans, 2)), - nir_channel(b, wpostrans, 3)); + wpos_temp_y = nir_fadd(b, nir_fmul(b, nir_channel(b, wpos_temp, 1), nir_channel(b, wpostrans, 2)), + nir_channel(b, wpostrans, 3)); } wpos_temp = nir_vec4(b, @@ -263,13 +261,12 @@ lower_interp_deref_or_load_baryc_at_offset(lower_wpos_ytransform_state *state, offset = nir_ssa_for_src(b, intr->src[offset_src], 2); flip_y = nir_fmul(b, nir_channel(b, offset, 1), - nir_channel(b, get_transform(state), 0)); + nir_channel(b, get_transform(state), 0)); nir_instr_rewrite_src(&intr->instr, &intr->src[offset_src], nir_src_for_ssa(nir_vec2(b, nir_channel(b, offset, 0), - flip_y))); + flip_y))); } - static void lower_load_sample_pos(lower_wpos_ytransform_state *state, nir_intrinsic_instr *intr) @@ -282,8 +279,8 @@ lower_load_sample_pos(lower_wpos_ytransform_state *state, nir_ssa_def *neg_scale = nir_channel(b, get_transform(state), 2); /* Either y or 1-y for scale equal to 1 or -1 respectively. */ nir_ssa_def *flipped_y = - nir_fadd(b, nir_fmax(b, neg_scale, nir_imm_float(b, 0.0)), - nir_fmul(b, nir_channel(b, pos, 1), scale)); + nir_fadd(b, nir_fmax(b, neg_scale, nir_imm_float(b, 0.0)), + nir_fmul(b, nir_channel(b, pos, 1), scale)); nir_ssa_def *flipped_pos = nir_vec2(b, nir_channel(b, pos, 0), flipped_y); nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, flipped_pos, @@ -346,6 +343,6 @@ nir_lower_wpos_ytransform(nir_shader *shader, return nir_shader_instructions_pass(shader, lower_wpos_ytransform_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); } diff --git a/src/compiler/nir/nir_lower_wrmasks.c b/src/compiler/nir/nir_lower_wrmasks.c index ea2d4f3..5485b67 100644 --- a/src/compiler/nir/nir_lower_wrmasks.c +++ b/src/compiler/nir/nir_lower_wrmasks.c @@ -98,19 +98,19 @@ split_wrmask(nir_builder *b, nir_intrinsic_instr *intr) b->cursor = nir_before_instr(&intr->instr); - assert(!info->has_dest); /* expecting only store intrinsics */ + assert(!info->has_dest); /* expecting only store intrinsics */ - unsigned num_srcs = info->num_srcs; - unsigned value_idx = value_src(intr->intrinsic); + unsigned num_srcs = info->num_srcs; + unsigned value_idx = value_src(intr->intrinsic); unsigned offset_idx = offset_src(intr->intrinsic); - unsigned num_comp = nir_intrinsic_src_components(intr, value_idx); + unsigned num_comp = nir_intrinsic_src_components(intr, value_idx); unsigned wrmask = nir_intrinsic_write_mask(intr); while (wrmask) { unsigned first_component = ffs(wrmask) - 1; unsigned length = ffs(~(wrmask >> first_component)) - 1; - nir_ssa_def *value = nir_ssa_for_src(b, intr->src[value_idx], num_comp); + nir_ssa_def *value = nir_ssa_for_src(b, intr->src[value_idx], num_comp); nir_ssa_def *offset = nir_ssa_for_src(b, intr->src[offset_idx], 1); /* swizzle out the consecutive components that we'll store @@ -121,7 +121,7 @@ split_wrmask(nir_builder *b, nir_intrinsic_instr *intr) /* and create the replacement intrinsic: */ nir_intrinsic_instr *new_intr = - nir_intrinsic_instr_create(b->shader, intr->intrinsic); + nir_intrinsic_instr_create(b->shader, intr->intrinsic); nir_intrinsic_copy_const_indices(new_intr, intr); nir_intrinsic_set_write_mask(new_intr, BITFIELD_MASK(length)); @@ -146,10 +146,10 @@ split_wrmask(nir_builder *b, nir_intrinsic_instr *intr) unsigned offset_adj = offset_units * first_component; if (nir_intrinsic_has_base(intr)) { nir_intrinsic_set_base(new_intr, - nir_intrinsic_base(intr) + offset_adj); + nir_intrinsic_base(intr) + offset_adj); } else { offset = nir_iadd(b, offset, - nir_imm_intN_t(b, offset_adj, offset->bit_size)); + nir_imm_intN_t(b, offset_adj, offset->bit_size)); } new_intr->num_components = length; @@ -228,6 +228,6 @@ nir_lower_wrmasks(nir_shader *shader, nir_instr_filter_cb cb, const void *data) return nir_shader_instructions_pass(shader, nir_lower_wrmasks_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); } diff --git a/src/compiler/nir/nir_mod_analysis.c b/src/compiler/nir/nir_mod_analysis.c index 680de3b..66672e9 100644 --- a/src/compiler/nir/nir_mod_analysis.c +++ b/src/compiler/nir/nir_mod_analysis.c @@ -55,129 +55,129 @@ nir_mod_analysis(nir_ssa_scalar val, nir_alu_type val_type, unsigned div, unsign assert(util_is_power_of_two_nonzero(div)); switch (val.def->parent_instr->type) { - case nir_instr_type_load_const: { - nir_load_const_instr *load = - nir_instr_as_load_const(val.def->parent_instr); - nir_alu_type base_type = nir_alu_type_get_base_type(val_type); - - if (base_type == nir_type_uint) { - assert(val.comp < load->def.num_components); - uint64_t ival = nir_const_value_as_uint(load->value[val.comp], - load->def.bit_size); - *mod = ival % div; - return true; - } else if (base_type == nir_type_int) { - assert(val.comp < load->def.num_components); - int64_t ival = nir_const_value_as_int(load->value[val.comp], - load->def.bit_size); + case nir_instr_type_load_const: { + nir_load_const_instr *load = + nir_instr_as_load_const(val.def->parent_instr); + nir_alu_type base_type = nir_alu_type_get_base_type(val_type); + + if (base_type == nir_type_uint) { + assert(val.comp < load->def.num_components); + uint64_t ival = nir_const_value_as_uint(load->value[val.comp], + load->def.bit_size); + *mod = ival % div; + return true; + } else if (base_type == nir_type_int) { + assert(val.comp < load->def.num_components); + int64_t ival = nir_const_value_as_int(load->value[val.comp], + load->def.bit_size); + + /* whole analysis collapses the moment we allow negative values */ + if (ival < 0) + return false; + + *mod = ((uint64_t)ival) % div; + return true; + } + + break; + } + + case nir_instr_type_alu: { + nir_alu_instr *alu = nir_instr_as_alu(val.def->parent_instr); + + if (alu->dest.dest.ssa.num_components != 1) + return false; + + switch (alu->op) { + case nir_op_ishr: { + if (nir_src_is_const(alu->src[1].src)) { + assert(alu->src[1].src.ssa->num_components == 1); + uint64_t shift = nir_src_as_uint(alu->src[1].src); + + if (util_last_bit(div) + shift > 32) + break; - /* whole analysis collapses the moment we allow negative values */ - if (ival < 0) + nir_alu_type type0 = nir_alu_src_type(alu, 0); + if (!nir_mod_analysis(nir_alu_arg(alu, 0, val.comp), type0, div << shift, mod)) return false; - *mod = ((uint64_t)ival) % div; + *mod >>= shift; return true; } - break; } - case nir_instr_type_alu: { - nir_alu_instr *alu = nir_instr_as_alu(val.def->parent_instr); - - if (alu->dest.dest.ssa.num_components != 1) + case nir_op_iadd: { + unsigned mod0; + nir_alu_type type0 = nir_alu_src_type(alu, 0); + if (!nir_mod_analysis(nir_alu_arg(alu, 0, val.comp), type0, div, &mod0)) return false; - switch (alu->op) { - case nir_op_ishr: { - if (nir_src_is_const(alu->src[1].src)) { - assert(alu->src[1].src.ssa->num_components == 1); - uint64_t shift = nir_src_as_uint(alu->src[1].src); - - if (util_last_bit(div) + shift > 32) - break; - - nir_alu_type type0 = nir_alu_src_type(alu, 0); - if (!nir_mod_analysis(nir_alu_arg(alu, 0, val.comp), type0, div << shift, mod)) - return false; - - *mod >>= shift; - return true; - } - break; - } + unsigned mod1; + nir_alu_type type1 = nir_alu_src_type(alu, 1); + if (!nir_mod_analysis(nir_alu_arg(alu, 1, val.comp), type1, div, &mod1)) + return false; - case nir_op_iadd: { - unsigned mod0; - nir_alu_type type0 = nir_alu_src_type(alu, 0); - if (!nir_mod_analysis(nir_alu_arg(alu, 0, val.comp), type0, div, &mod0)) - return false; + *mod = (mod0 + mod1) % div; + return true; + } - unsigned mod1; - nir_alu_type type1 = nir_alu_src_type(alu, 1); - if (!nir_mod_analysis(nir_alu_arg(alu, 1, val.comp), type1, div, &mod1)) - return false; + case nir_op_ishl: { + if (nir_src_is_const(alu->src[1].src)) { + assert(alu->src[1].src.ssa->num_components == 1); + uint64_t shift = nir_src_as_uint(alu->src[1].src); - *mod = (mod0 + mod1) % div; + if ((div >> shift) == 0) { + *mod = 0; return true; } + nir_alu_type type0 = nir_alu_src_type(alu, 0); + return nir_mod_analysis(nir_alu_arg(alu, 0, val.comp), type0, div >> shift, mod); + } + break; + } - case nir_op_ishl: { - if (nir_src_is_const(alu->src[1].src)) { - assert(alu->src[1].src.ssa->num_components == 1); - uint64_t shift = nir_src_as_uint(alu->src[1].src); - - if ((div >> shift) == 0) { - *mod = 0; - return true; - } - nir_alu_type type0 = nir_alu_src_type(alu, 0); - return nir_mod_analysis(nir_alu_arg(alu, 0, val.comp), type0, div >> shift, mod); - } - break; - } - - case nir_op_imul_32x16: /* multiply 32-bits with low 16-bits */ - case nir_op_imul: { - unsigned mod0; - nir_alu_type type0 = nir_alu_src_type(alu, 0); - bool s1 = nir_mod_analysis(nir_alu_arg(alu, 0, val.comp), type0, div, &mod0); - - if (s1 && (mod0 == 0)) { - *mod = 0; - return true; - } + case nir_op_imul_32x16: /* multiply 32-bits with low 16-bits */ + case nir_op_imul: { + unsigned mod0; + nir_alu_type type0 = nir_alu_src_type(alu, 0); + bool s1 = nir_mod_analysis(nir_alu_arg(alu, 0, val.comp), type0, div, &mod0); - /* if divider is larger than 2nd source max (interpreted) value - * then modulo of multiplication is unknown - */ - if (alu->op == nir_op_imul_32x16 && div > (1u << 16)) - return false; + if (s1 && (mod0 == 0)) { + *mod = 0; + return true; + } - unsigned mod1; - nir_alu_type type1 = nir_alu_src_type(alu, 1); - bool s2 = nir_mod_analysis(nir_alu_arg(alu, 1, val.comp), type1, div, &mod1); + /* if divider is larger than 2nd source max (interpreted) value + * then modulo of multiplication is unknown + */ + if (alu->op == nir_op_imul_32x16 && div > (1u << 16)) + return false; - if (s2 && (mod1 == 0)) { - *mod = 0; - return true; - } + unsigned mod1; + nir_alu_type type1 = nir_alu_src_type(alu, 1); + bool s2 = nir_mod_analysis(nir_alu_arg(alu, 1, val.comp), type1, div, &mod1); - if (!s1 || !s2) - return false; + if (s2 && (mod1 == 0)) { + *mod = 0; + return true; + } - *mod = (mod0 * mod1) % div; - return true; - } + if (!s1 || !s2) + return false; - default: - break; - } - break; + *mod = (mod0 * mod1) % div; + return true; } default: break; + } + break; + } + + default: + break; } return false; diff --git a/src/compiler/nir/nir_move_vec_src_uses_to_dest.c b/src/compiler/nir/nir_move_vec_src_uses_to_dest.c index d72304b..09fc679 100644 --- a/src/compiler/nir/nir_move_vec_src_uses_to_dest.c +++ b/src/compiler/nir/nir_move_vec_src_uses_to_dest.c @@ -117,7 +117,6 @@ move_vec_src_uses_to_dest_block(nir_block *block) if (use->parent_instr->type != nir_instr_type_alu) continue; - nir_alu_instr *use_alu = nir_instr_as_alu(use->parent_instr); /* Figure out which source we're actually looking at */ @@ -173,7 +172,7 @@ nir_move_vec_src_uses_to_dest_impl(nir_shader *shader, nir_function_impl *impl) } nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); return progress; } diff --git a/src/compiler/nir/nir_normalize_cubemap_coords.c b/src/compiler/nir/nir_normalize_cubemap_coords.c index 77b3997..ad61df2 100644 --- a/src/compiler/nir/nir_normalize_cubemap_coords.c +++ b/src/compiler/nir/nir_normalize_cubemap_coords.c @@ -69,6 +69,6 @@ nir_normalize_cubemap_coords(nir_shader *shader) { return nir_shader_instructions_pass(shader, normalize_cubemap_coords, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_opt_access.c b/src/compiler/nir/nir_opt_access.c index 10dbab4..13d5b1d 100644 --- a/src/compiler/nir/nir_opt_access.c +++ b/src/compiler/nir/nir_opt_access.c @@ -105,10 +105,12 @@ gather_intrinsic(struct access_state *state, nir_intrinsic_instr *instr) } if ((var->data.mode == nir_var_uniform || - var->data.mode == nir_var_image) && read) + var->data.mode == nir_var_image) && + read) _mesa_set_add(state->vars_read, var); if ((var->data.mode == nir_var_uniform || - var->data.mode == nir_var_image) && write) + var->data.mode == nir_var_image) && + write) _mesa_set_add(state->vars_written, var); break; @@ -278,12 +280,11 @@ opt_access_impl(struct access_state *state, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs | - nir_metadata_loop_analysis); + nir_metadata_dominance | + nir_metadata_live_ssa_defs | + nir_metadata_loop_analysis); } - return progress; } @@ -316,10 +317,7 @@ nir_opt_access(nir_shader *shader, const nir_opt_access_options *options) state.images_read |= state.buffers_read; } - nir_foreach_variable_with_modes(var, shader, nir_var_uniform | - nir_var_mem_ubo | - nir_var_mem_ssbo | - nir_var_image) + nir_foreach_variable_with_modes(var, shader, nir_var_uniform | nir_var_mem_ubo | nir_var_mem_ssbo | nir_var_image) var_progress |= process_variable(&state, var); nir_foreach_function_impl(impl, shader) { @@ -329,9 +327,9 @@ nir_opt_access(nir_shader *shader, const nir_opt_access_options *options) if (var_progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs | - nir_metadata_loop_analysis); + nir_metadata_dominance | + nir_metadata_live_ssa_defs | + nir_metadata_loop_analysis); } } diff --git a/src/compiler/nir/nir_opt_barriers.c b/src/compiler/nir/nir_opt_barriers.c index a4d1473..4cc1c8e 100644 --- a/src/compiler/nir/nir_opt_barriers.c +++ b/src/compiler/nir/nir_opt_barriers.c @@ -69,8 +69,8 @@ nir_opt_combine_barriers_impl( if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs); + nir_metadata_dominance | + nir_metadata_live_ssa_defs); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_combine_stores.c b/src/compiler/nir/nir_opt_combine_stores.c index bd7c206..d015cbe 100644 --- a/src/compiler/nir/nir_opt_combine_stores.c +++ b/src/compiler/nir/nir_opt_combine_stores.c @@ -74,7 +74,6 @@ struct combine_stores_state { nir_builder b; bool progress; - /* Allocator and freelist to reuse structs between functions. */ void *lin_ctx; struct list_head freelist; @@ -107,7 +106,7 @@ free_combined_store(struct combine_stores_state *state, static void combine_stores(struct combine_stores_state *state, - struct combined_store *combo) + struct combined_store *combo) { assert(combo->latest); assert(combo->latest->intrinsic == nir_intrinsic_store_deref); @@ -124,7 +123,7 @@ combine_stores(struct combine_stores_state *state, /* Build a new vec, to be used as source for the combined store. As it * gets build, remove previous stores that are not needed anymore. */ - nir_ssa_scalar comps[NIR_MAX_VEC_COMPONENTS] = {0}; + nir_ssa_scalar comps[NIR_MAX_VEC_COMPONENTS] = { 0 }; unsigned num_components = glsl_get_vector_elements(combo->dst->type); unsigned bit_size = combo->latest->src[1].ssa->bit_size; for (unsigned i = 0; i < num_components; i++) { @@ -169,7 +168,7 @@ combine_stores(struct combine_stores_state *state, static void combine_stores_with_deref(struct combine_stores_state *state, - nir_deref_instr *deref) + nir_deref_instr *deref) { if (!nir_deref_mode_may_be(deref, state->modes)) return; @@ -184,7 +183,7 @@ combine_stores_with_deref(struct combine_stores_state *state, static void combine_stores_with_modes(struct combine_stores_state *state, - nir_variable_mode modes) + nir_variable_mode modes) { if ((state->modes & modes) == 0) return; @@ -268,7 +267,7 @@ update_combined_store(struct combine_stores_state *state, nir_instr_remove(&prev_store->instr); } else { assert(glsl_type_is_vector( - nir_src_as_deref(prev_store->src[0])->type)); + nir_src_as_deref(prev_store->src[0])->type)); nir_component_mask_t prev_mask = nir_intrinsic_write_mask(prev_store); nir_intrinsic_set_write_mask(prev_store, prev_mask & ~(1 << i)); } @@ -284,11 +283,11 @@ combine_stores_block(struct combine_stores_state *state, nir_block *block) nir_foreach_instr_safe(instr, block) { if (instr->type == nir_instr_type_call) { combine_stores_with_modes(state, nir_var_shader_out | - nir_var_shader_temp | - nir_var_function_temp | - nir_var_mem_ssbo | - nir_var_mem_shared | - nir_var_mem_global); + nir_var_shader_temp | + nir_var_function_temp | + nir_var_mem_ssbo | + nir_var_mem_shared | + nir_var_mem_global); continue; } @@ -327,16 +326,16 @@ combine_stores_block(struct combine_stores_state *state, nir_block *block) case nir_intrinsic_report_ray_intersection: combine_stores_with_modes(state, nir_var_mem_ssbo | - nir_var_mem_global | - nir_var_shader_call_data | - nir_var_ray_hit_attrib); + nir_var_mem_global | + nir_var_shader_call_data | + nir_var_ray_hit_attrib); break; case nir_intrinsic_ignore_ray_intersection: case nir_intrinsic_terminate_ray: combine_stores_with_modes(state, nir_var_mem_ssbo | - nir_var_mem_global | - nir_var_shader_call_data); + nir_var_mem_global | + nir_var_shader_call_data); break; case nir_intrinsic_load_deref: { @@ -406,7 +405,7 @@ combine_stores_impl(struct combine_stores_state *state, nir_function_impl *impl) if (state->progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -419,7 +418,7 @@ nir_opt_combine_stores(nir_shader *shader, nir_variable_mode modes) { void *mem_ctx = ralloc_context(NULL); struct combine_stores_state state = { - .modes = modes, + .modes = modes, .lin_ctx = linear_zalloc_parent(mem_ctx, 0), }; diff --git a/src/compiler/nir/nir_opt_comparison_pre.c b/src/compiler/nir/nir_opt_comparison_pre.c index 919cc1e..cb4479e 100644 --- a/src/compiler/nir/nir_opt_comparison_pre.c +++ b/src/compiler/nir/nir_opt_comparison_pre.c @@ -21,10 +21,10 @@ * IN THE SOFTWARE. */ +#include "util/u_vector.h" +#include "nir_builder.h" #include "nir_instr_set.h" #include "nir_search_helpers.h" -#include "nir_builder.h" -#include "util/u_vector.h" /* Partial redundancy elimination of compares * @@ -82,12 +82,12 @@ block_queue_finish(struct block_queue *bq) { struct block_instructions *n; - while ((n = (struct block_instructions *) exec_list_pop_head(&bq->blocks)) != NULL) { + while ((n = (struct block_instructions *)exec_list_pop_head(&bq->blocks)) != NULL) { u_vector_finish(&n->instructions); free(n); } - while ((n = (struct block_instructions *) exec_list_pop_head(&bq->reusable_blocks)) != NULL) { + while ((n = (struct block_instructions *)exec_list_pop_head(&bq->reusable_blocks)) != NULL) { free(n); } } @@ -96,7 +96,7 @@ static struct block_instructions * push_block(struct block_queue *bq) { struct block_instructions *bi = - (struct block_instructions *) exec_list_pop_head(&bq->reusable_blocks); + (struct block_instructions *)exec_list_pop_head(&bq->reusable_blocks); if (bi == NULL) { bi = calloc(1, sizeof(struct block_instructions)); @@ -183,15 +183,15 @@ rewrite_compare_instruction(nir_builder *bld, nir_alu_instr *orig_cmp, nir_ssa_def *const b = nir_ssa_for_alu_src(bld, orig_cmp, 1); nir_ssa_def *const fadd = zero_on_left - ? nir_fadd(bld, b, nir_fneg(bld, a)) - : nir_fadd(bld, a, nir_fneg(bld, b)); + ? nir_fadd(bld, b, nir_fneg(bld, a)) + : nir_fadd(bld, a, nir_fneg(bld, b)); nir_ssa_def *const zero = nir_imm_floatN_t(bld, 0.0, orig_add->dest.dest.ssa.bit_size); nir_ssa_def *const cmp = zero_on_left - ? nir_build_alu(bld, orig_cmp->op, zero, fadd, NULL, NULL) - : nir_build_alu(bld, orig_cmp->op, fadd, zero, NULL, NULL); + ? nir_build_alu(bld, orig_cmp->op, zero, fadd, NULL, NULL) + : nir_build_alu(bld, orig_cmp->op, fadd, zero, NULL, NULL); /* Generating extra moves of the results is the easy way to make sure the * writemasks match the original instructions. Later optimization passes @@ -256,7 +256,7 @@ comparison_pre_block(nir_block *block, struct block_queue *bq, nir_builder *bld) if (alu->dest.dest.ssa.num_components != 1) continue; - static const uint8_t swizzle[NIR_MAX_VEC_COMPONENTS] = {0}; + static const uint8_t swizzle[NIR_MAX_VEC_COMPONENTS] = { 0 }; switch (alu->op) { case nir_op_fadd: { @@ -264,13 +264,14 @@ comparison_pre_block(nir_block *block, struct block_queue *bq, nir_builder *bld) * instructions that dominate it. */ struct block_instructions *b = - (struct block_instructions *) exec_list_get_head_raw(&bq->blocks); + (struct block_instructions *)exec_list_get_head_raw(&bq->blocks); while (b->node.next != NULL) { nir_alu_instr **a; bool rewrote_compare = false; - u_vector_foreach(a, &b->instructions) { + u_vector_foreach(a, &b->instructions) + { nir_alu_instr *const cmp = *a; if (cmp == NULL) @@ -330,7 +331,7 @@ comparison_pre_block(nir_block *block, struct block_queue *bq, nir_builder *bld) break; } - b = (struct block_instructions *) b->node.next; + b = (struct block_instructions *)b->node.next; } break; @@ -385,7 +386,7 @@ nir_opt_comparison_pre_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c index 24534b7..7f854dc 100644 --- a/src/compiler/nir/nir_opt_constant_folding.c +++ b/src/compiler/nir/nir_opt_constant_folding.c @@ -21,11 +21,11 @@ * IN THE SOFTWARE. */ +#include #include "nir.h" #include "nir_builder.h" #include "nir_constant_expressions.h" #include "nir_deref.h" -#include /* * Implements SSA-based constant folding. @@ -63,7 +63,7 @@ try_fold_alu(nir_builder *b, nir_alu_instr *alu) if (src_instr->type != nir_instr_type_load_const) return false; - nir_load_const_instr* load_const = nir_instr_as_load_const(src_instr); + nir_load_const_instr *load_const = nir_instr_as_load_const(src_instr); for (unsigned j = 0; j < nir_ssa_alu_instr_src_components(alu, i); j++) { @@ -85,8 +85,8 @@ try_fold_alu(nir_builder *b, nir_alu_instr *alu) b->cursor = nir_before_instr(&alu->instr); nir_ssa_def *imm = nir_build_imm(b, alu->dest.dest.ssa.num_components, - alu->dest.dest.ssa.bit_size, - dest); + alu->dest.dest.ssa.bit_size, + dest); nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, imm); nir_instr_remove(&alu->instr); nir_instr_free(&alu->instr); @@ -132,12 +132,12 @@ const_value_for_deref(nir_deref_instr *deref) uint64_t idx = nir_src_as_uint(p->arr.index); if (c->num_elements > 0) { - assert(glsl_type_is_array(path.path[i-1]->type)); + assert(glsl_type_is_array(path.path[i - 1]->type)); if (idx >= c->num_elements) goto fail; c = c->elements[idx]; } else { - assert(glsl_type_is_vector(path.path[i-1]->type)); + assert(glsl_type_is_vector(path.path[i - 1]->type)); assert(glsl_type_is_scalar(p->type)); if (idx >= NIR_MAX_VEC_COMPONENTS) goto fail; @@ -147,7 +147,7 @@ const_value_for_deref(nir_deref_instr *deref) } case nir_deref_type_struct: - assert(glsl_type_is_struct(path.path[i-1]->type)); + assert(glsl_type_is_struct(path.path[i - 1]->type)); assert(v == NULL && c->num_elements > 0); if (p->strct.index >= c->num_elements) goto fail; @@ -209,7 +209,7 @@ try_fold_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin, if (v) { b->cursor = nir_before_instr(&intrin->instr); nir_ssa_def *val = nir_build_imm(b, intrin->dest.ssa.num_components, - intrin->dest.ssa.bit_size, v); + intrin->dest.ssa.bit_size, v); nir_ssa_def_rewrite_uses(&intrin->dest.ssa, val); nir_instr_remove(&intrin->instr); return true; @@ -234,11 +234,11 @@ try_fold_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin, nir_ssa_def *val; if (offset >= range) { val = nir_ssa_undef(b, intrin->dest.ssa.num_components, - intrin->dest.ssa.bit_size); + intrin->dest.ssa.bit_size); } else { nir_const_value imm[NIR_MAX_VEC_COMPONENTS]; memset(imm, 0, sizeof(imm)); - uint8_t *data = (uint8_t*)b->shader->constant_data + base; + uint8_t *data = (uint8_t *)b->shader->constant_data + base; for (unsigned i = 0; i < intrin->num_components; i++) { unsigned bytes = intrin->dest.ssa.bit_size / 8; bytes = MIN2(bytes, range - offset); @@ -247,7 +247,7 @@ try_fold_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin, offset += bytes; } val = nir_build_imm(b, intrin->dest.ssa.num_components, - intrin->dest.ssa.bit_size, imm); + intrin->dest.ssa.bit_size, imm); } nir_ssa_def_rewrite_uses(&intrin->dest.ssa, val); nir_instr_remove(&intrin->instr); @@ -379,7 +379,7 @@ nir_opt_constant_folding(nir_shader *shader) bool progress = nir_shader_instructions_pass(shader, try_fold_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); /* This doesn't free the constant data if there are no constant loads because diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c index 9aa3d36..6ece986 100644 --- a/src/compiler/nir/nir_opt_copy_prop_vars.c +++ b/src/compiler/nir/nir_opt_copy_prop_vars.c @@ -236,8 +236,7 @@ gather_vars_written(struct copy_prop_var_state *state, /* Destination in all of store_deref, copy_deref and the atomics is src[0]. */ nir_deref_instr *dst = nir_src_as_deref(intrin->src[0]); - uintptr_t mask = intrin->intrinsic == nir_intrinsic_store_deref ? - nir_intrinsic_write_mask(intrin) : (1 << glsl_get_vector_elements(dst->type)) - 1; + uintptr_t mask = intrin->intrinsic == nir_intrinsic_store_deref ? nir_intrinsic_write_mask(intrin) : (1 << glsl_get_vector_elements(dst->type)) - 1; struct hash_entry *ht_entry = _mesa_hash_table_search(written->derefs, dst); if (ht_entry) @@ -295,9 +294,9 @@ gather_vars_written(struct copy_prop_var_state *state, _mesa_hash_table_search_pre_hashed(written->derefs, new_entry->hash, new_entry->key); if (old_entry) { - nir_component_mask_t merged = (uintptr_t) new_entry->data | - (uintptr_t) old_entry->data; - old_entry->data = (void *) ((uintptr_t) merged); + nir_component_mask_t merged = (uintptr_t)new_entry->data | + (uintptr_t)old_entry->data; + old_entry->data = (void *)((uintptr_t)merged); } else { _mesa_hash_table_insert_pre_hashed(written->derefs, new_entry->hash, new_entry->key, new_entry->data); @@ -350,7 +349,7 @@ get_copies_array_from_ht_entry(struct copy_prop_var_state *state, struct copies_dynarray *copies_array; if (copies_owns_ht_entry(copies, ht_entry)) { /* The array already exists so just return it */ - copies_array = (struct copies_dynarray *) ht_entry->data; + copies_array = (struct copies_dynarray *)ht_entry->data; } else { /* Clone the array and set the data value for future access */ copies_array = get_copies_dynarray(state); @@ -395,7 +394,6 @@ copies_array_for_deref(struct copy_prop_var_state *state, return copies_array; } - static struct copy_entry * copy_entry_create(struct copy_prop_var_state *state, struct copies *copies, nir_deref_and_path *deref) @@ -523,7 +521,7 @@ lookup_entry_and_kill_aliases(struct copy_prop_var_state *state, deref->_path->path[0]->var->data.mode == nir_var_mem_shared) { hash_table_foreach(copies->ht, ht_entry) { - nir_variable *var = (nir_variable *) ht_entry->key; + nir_variable *var = (nir_variable *)ht_entry->key; if (deref->_path->path[0]->deref_type == nir_deref_type_var && var->data.mode != deref->_path->path[0]->var->data.mode) continue; @@ -590,7 +588,7 @@ get_entry_and_kill_aliases(struct copy_prop_var_state *state, static void apply_barrier_for_modes_to_dynarr(struct util_dynarray *copies_array, - nir_variable_mode modes) + nir_variable_mode modes) { util_dynarray_foreach_reverse(copies_array, struct copy_entry, iter) { if (nir_deref_mode_may_be(iter->dst.instr, modes) || @@ -658,15 +656,15 @@ load_element_from_ssa_entry_value(struct copy_prop_var_state *state, assert(entry->src.ssa.component[index] < entry->src.ssa.def[index]->num_components); nir_ssa_def *def = nir_channel(b, entry->src.ssa.def[index], - entry->src.ssa.component[index]); + entry->src.ssa.component[index]); - *value = (struct value) { + *value = (struct value){ .is_ssa = true, { - .ssa = { - .def = { def }, - .component = { 0 }, - }, + .ssa = { + .def = { def }, + .component = { 0 }, + }, } }; @@ -924,9 +922,9 @@ invalidate_copies_for_cf_node(struct copy_prop_var_state *state, } } - hash_table_foreach (written->derefs, entry) { + hash_table_foreach(written->derefs, entry) { nir_deref_instr *deref_written = (nir_deref_instr *)entry->key; - nir_deref_and_path deref = {deref_written, NULL}; + nir_deref_and_path deref = { deref_written, NULL }; kill_aliases(state, copies, &deref, (uintptr_t)entry->data); } } @@ -979,7 +977,7 @@ dump_copy_entries(struct copies *copies) { hash_table_foreach(copies->ht, ht_entry) { struct util_dynarray *copies_array = - &((struct copies_dynarray *) ht_entry->data)->arr; + &((struct copies_dynarray *)ht_entry->data)->arr; util_dynarray_foreach(copies_array, struct copy_entry, iter) print_copy_entry(iter); @@ -1006,14 +1004,11 @@ copy_prop_vars_block(struct copy_prop_var_state *state, dump_instr(instr); if (instr->type == nir_instr_type_call) { - if (debug) dump_instr(instr); - apply_barrier_for_modes(state, copies, nir_var_shader_out | - nir_var_shader_temp | - nir_var_function_temp | - nir_var_mem_ssbo | - nir_var_mem_shared | - nir_var_mem_global); - if (debug) dump_copy_entries(copies); + if (debug) + dump_instr(instr); + apply_barrier_for_modes(state, copies, nir_var_shader_out | nir_var_shader_temp | nir_var_function_temp | nir_var_mem_ssbo | nir_var_mem_shared | nir_var_mem_global); + if (debug) + dump_copy_entries(copies); continue; } @@ -1023,7 +1018,8 @@ copy_prop_vars_block(struct copy_prop_var_state *state, nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); switch (intrin->intrinsic) { case nir_intrinsic_barrier: - if (debug) dump_instr(instr); + if (debug) + dump_instr(instr); if (nir_intrinsic_memory_semantics(intrin) & NIR_MEMORY_ACQUIRE) apply_barrier_for_modes(state, copies, nir_intrinsic_memory_modes(intrin)); @@ -1031,32 +1027,29 @@ copy_prop_vars_block(struct copy_prop_var_state *state, case nir_intrinsic_emit_vertex: case nir_intrinsic_emit_vertex_with_counter: - if (debug) dump_instr(instr); + if (debug) + dump_instr(instr); apply_barrier_for_modes(state, copies, nir_var_shader_out); break; case nir_intrinsic_report_ray_intersection: - apply_barrier_for_modes(state, copies, nir_var_mem_ssbo | - nir_var_mem_global | - nir_var_shader_call_data | - nir_var_ray_hit_attrib); + apply_barrier_for_modes(state, copies, nir_var_mem_ssbo | nir_var_mem_global | nir_var_shader_call_data | nir_var_ray_hit_attrib); break; case nir_intrinsic_ignore_ray_intersection: case nir_intrinsic_terminate_ray: - apply_barrier_for_modes(state, copies, nir_var_mem_ssbo | - nir_var_mem_global | - nir_var_shader_call_data); + apply_barrier_for_modes(state, copies, nir_var_mem_ssbo | nir_var_mem_global | nir_var_shader_call_data); break; case nir_intrinsic_load_deref: { - if (debug) dump_instr(instr); + if (debug) + dump_instr(instr); if (nir_intrinsic_access(intrin) & ACCESS_VOLATILE) break; - nir_deref_and_path src = {nir_src_as_deref(intrin->src[0]), NULL}; + nir_deref_and_path src = { nir_src_as_deref(intrin->src[0]), NULL }; /* If this is a load from a read-only mode, then all this pass would * do is combine redundant loads and CSE should be more efficient for @@ -1090,7 +1083,7 @@ copy_prop_vars_block(struct copy_prop_var_state *state, struct copy_entry *src_entry = lookup_entry_for_deref(state, copies, &src, nir_derefs_a_contains_b_bit, &src_entry_equal); - struct value value = {0}; + struct value value = { 0 }; if (try_load_from_entry(state, src_entry, b, intrin, &src, &value)) { if (value.is_ssa) { /* lookup_load has already ensured that we get a single SSA @@ -1152,9 +1145,10 @@ copy_prop_vars_block(struct copy_prop_var_state *state, } case nir_intrinsic_store_deref: { - if (debug) dump_instr(instr); + if (debug) + dump_instr(instr); - nir_deref_and_path dst = {nir_src_as_deref(intrin->src[0]), NULL}; + nir_deref_and_path dst = { nir_src_as_deref(intrin->src[0]), NULL }; assert(glsl_type_is_vector_or_scalar(dst.instr->type)); /* Direct array_derefs of vectors operate on the vectors (the parent @@ -1191,7 +1185,7 @@ copy_prop_vars_block(struct copy_prop_var_state *state, nir_instr_remove(instr); state->progress = true; } else { - struct value value = {0}; + struct value value = { 0 }; value_set_ssa_components(&value, intrin->src[1].ssa, intrin->num_components); unsigned wrmask = nir_intrinsic_write_mask(intrin); @@ -1204,10 +1198,11 @@ copy_prop_vars_block(struct copy_prop_var_state *state, } case nir_intrinsic_copy_deref: { - if (debug) dump_instr(instr); + if (debug) + dump_instr(instr); - nir_deref_and_path dst = {nir_src_as_deref(intrin->src[0]), NULL}; - nir_deref_and_path src = {nir_src_as_deref(intrin->src[1]), NULL}; + nir_deref_and_path dst = { nir_src_as_deref(intrin->src[0]), NULL }; + nir_deref_and_path src = { nir_src_as_deref(intrin->src[1]), NULL }; /* The copy_deref intrinsic doesn't keep track of num_components, so * get it ourselves. @@ -1261,7 +1256,7 @@ copy_prop_vars_block(struct copy_prop_var_state *state, state->progress = true; } else { - value = (struct value) { + value = (struct value){ .is_ssa = false, { .deref = src }, }; @@ -1285,10 +1280,12 @@ copy_prop_vars_block(struct copy_prop_var_state *state, case nir_intrinsic_execute_callable: case nir_intrinsic_rt_trace_ray: case nir_intrinsic_rt_execute_callable: { - if (debug) dump_instr(instr); + if (debug) + dump_instr(instr); nir_deref_and_path payload = { - nir_src_as_deref(*nir_get_shader_call_payload_src(intrin)), NULL}; + nir_src_as_deref(*nir_get_shader_call_payload_src(intrin)), NULL + }; nir_component_mask_t full_mask = (1 << glsl_get_vector_elements(payload.instr->type)) - 1; kill_aliases(state, copies, &payload, full_mask); break; @@ -1297,21 +1294,23 @@ copy_prop_vars_block(struct copy_prop_var_state *state, case nir_intrinsic_memcpy_deref: case nir_intrinsic_deref_atomic: case nir_intrinsic_deref_atomic_swap: - if (debug) dump_instr(instr); + if (debug) + dump_instr(instr); - nir_deref_and_path dst = {nir_src_as_deref(intrin->src[0]), NULL}; + nir_deref_and_path dst = { nir_src_as_deref(intrin->src[0]), NULL }; unsigned num_components = glsl_get_vector_elements(dst.instr->type); unsigned full_mask = (1 << num_components) - 1; kill_aliases(state, copies, &dst, full_mask); break; case nir_intrinsic_store_deref_block_intel: { - if (debug) dump_instr(instr); + if (debug) + dump_instr(instr); /* Invalidate the whole variable (or cast) and anything that alias * with it. */ - nir_deref_and_path dst = {nir_src_as_deref(intrin->src[0]), NULL}; + nir_deref_and_path dst = { nir_src_as_deref(intrin->src[0]), NULL }; while (nir_deref_instr_parent(dst.instr)) dst.instr = nir_deref_instr_parent(dst.instr); assert(dst.instr->deref_type == nir_deref_type_var || @@ -1327,7 +1326,8 @@ copy_prop_vars_block(struct copy_prop_var_state *state, continue; /* To skip the debug below. */ } - if (debug) dump_copy_entries(copies); + if (debug) + dump_copy_entries(copies); } } @@ -1494,7 +1494,7 @@ nir_copy_prop_vars_impl(nir_function_impl *impl) if (state.progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_copy_propagate.c b/src/compiler/nir/nir_opt_copy_propagate.c index 753bd70..8bc2f3e 100644 --- a/src/compiler/nir/nir_opt_copy_propagate.c +++ b/src/compiler/nir/nir_opt_copy_propagate.c @@ -159,7 +159,7 @@ nir_copy_prop_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_cse.c b/src/compiler/nir/nir_opt_cse.c index f57d978..147019e 100644 --- a/src/compiler/nir/nir_opt_cse.c +++ b/src/compiler/nir/nir_opt_cse.c @@ -50,7 +50,7 @@ nir_opt_cse_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -70,4 +70,3 @@ nir_opt_cse(nir_shader *shader) return progress; } - diff --git a/src/compiler/nir/nir_opt_dce.c b/src/compiler/nir/nir_opt_dce.c index 6d79464..5f000ed 100644 --- a/src/compiler/nir/nir_opt_dce.c +++ b/src/compiler/nir/nir_opt_dce.c @@ -239,7 +239,7 @@ nir_opt_dce_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_dead_cf.c b/src/compiler/nir/nir_opt_dead_cf.c index e583305..ab7e891 100644 --- a/src/compiler/nir/nir_opt_dead_cf.c +++ b/src/compiler/nir/nir_opt_dead_cf.c @@ -222,7 +222,7 @@ node_is_dead(nir_cf_node *node) if (instr->type == nir_instr_type_intrinsic) { nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); if (!(nir_intrinsic_infos[intrin->intrinsic].flags & - NIR_INTRINSIC_CAN_ELIMINATE)) + NIR_INTRINSIC_CAN_ELIMINATE)) return false; switch (intrin->intrinsic) { @@ -240,9 +240,9 @@ node_is_dead(nir_cf_node *node) if (intrin->intrinsic == nir_intrinsic_load_deref) { nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]); if (!nir_deref_mode_may_be(deref, nir_var_mem_ssbo | - nir_var_mem_shared | - nir_var_mem_global | - nir_var_shader_out)) + nir_var_mem_shared | + nir_var_mem_global | + nir_var_shader_out)) break; } if (nir_intrinsic_access(intrin) & ACCESS_CAN_REORDER) @@ -372,7 +372,7 @@ dead_cf_list(struct exec_list *list, bool *list_ends_in_jump) nir_block *next = nir_cf_node_as_block(nir_cf_node_next(cur)); if (next->predecessors->entries == 0 && (!exec_list_is_empty(&next->instr_list) || - !exec_node_is_tail_sentinel(next->cf_node.node.next))) { + !exec_node_is_tail_sentinel(next->cf_node.node.next))) { remove_after_cf_node(cur); return true; } diff --git a/src/compiler/nir/nir_opt_dead_write_vars.c b/src/compiler/nir/nir_opt_dead_write_vars.c index 71344cd..fe26352 100644 --- a/src/compiler/nir/nir_opt_dead_write_vars.c +++ b/src/compiler/nir/nir_opt_dead_write_vars.c @@ -119,11 +119,11 @@ remove_dead_write_vars_local(void *mem_ctx, nir_shader *shader, nir_block *block nir_foreach_instr_safe(instr, block) { if (instr->type == nir_instr_type_call) { clear_unused_for_modes(&unused_writes, nir_var_shader_out | - nir_var_shader_temp | - nir_var_function_temp | - nir_var_mem_ssbo | - nir_var_mem_shared | - nir_var_mem_global); + nir_var_shader_temp | + nir_var_function_temp | + nir_var_mem_ssbo | + nir_var_mem_shared | + nir_var_mem_global); continue; } @@ -237,7 +237,7 @@ remove_dead_write_vars_impl(void *mem_ctx, nir_shader *shader, nir_function_impl if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_find_array_copies.c b/src/compiler/nir/nir_opt_find_array_copies.c index 7a1723f..16b16fc 100644 --- a/src/compiler/nir/nir_opt_find_array_copies.c +++ b/src/compiler/nir/nir_opt_find_array_copies.c @@ -77,7 +77,7 @@ create_match_node(const struct glsl_type *type, struct match_state *state) struct match_node *node = rzalloc_size(state->dead_ctx, sizeof(struct match_node) + - num_children * sizeof(struct match_node *)); + num_children * sizeof(struct match_node *)); node->num_children = num_children; node->src_wildcard_idx = -1; node->first_src_read = UINT32_MAX; @@ -316,7 +316,7 @@ try_match_deref(nir_deref_path *base_path, int *path_array_idx, nir_deref_path *deref_path, int arr_idx, nir_deref_instr *dst) { - for (int i = 0; ; i++) { + for (int i = 0;; i++) { nir_deref_instr *b = base_path->path[i]; nir_deref_instr *d = deref_path->path[i]; /* They have to be the same length */ @@ -328,7 +328,8 @@ try_match_deref(nir_deref_path *base_path, int *path_array_idx, /* This can happen if one is a deref_array and the other a wildcard */ if (b->deref_type != d->deref_type) - return false;; + return false; + ; switch (b->deref_type) { case nir_deref_type_var: @@ -351,7 +352,7 @@ try_match_deref(nir_deref_path *base_path, int *path_array_idx, const_b_idx && b_idx == 0 && const_d_idx && d_idx == arr_idx && glsl_get_length(nir_deref_instr_parent(b)->type) == - glsl_get_length(nir_deref_instr_parent(dst)->type)) { + glsl_get_length(nir_deref_instr_parent(dst)->type)) { *path_array_idx = i; continue; } @@ -492,8 +493,8 @@ handle_write(nir_deref_instr *dst, nir_deref_instr *src, if (src_node->last_overwritten <= dst_node->first_src_read) { nir_copy_deref(b, build_wildcard_deref(b, &dst_path, idx), - build_wildcard_deref(b, &dst_node->first_src_path, - dst_node->src_wildcard_idx)); + build_wildcard_deref(b, &dst_node->first_src_path, + dst_node->src_wildcard_idx)); foreach_aliasing_node(&dst_path, clobber, state); return true; } @@ -501,7 +502,7 @@ handle_write(nir_deref_instr *dst, nir_deref_instr *src, continue; } -reset: + reset: dst_node->next_array_idx = 0; dst_node->src_wildcard_idx = -1; dst_node->last_successful_write = 0; @@ -601,7 +602,7 @@ opt_find_array_copies_block(nir_builder *b, nir_block *block, */ if (src_deref && !nir_deref_mode_must_be(src_deref, nir_var_function_temp | - nir_var_read_only_modes)) { + nir_var_read_only_modes)) { src_deref = NULL; } @@ -617,7 +618,7 @@ opt_find_array_copies_block(nir_builder *b, nir_block *block, nir_deref_instr_has_indirect(dst_deref) || !glsl_type_is_vector_or_scalar(src_deref->type) || glsl_get_bare_type(src_deref->type) != - glsl_get_bare_type(dst_deref->type))) { + glsl_get_bare_type(dst_deref->type))) { src_deref = NULL; } @@ -651,7 +652,7 @@ opt_find_array_copies_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_fragdepth.c b/src/compiler/nir/nir_opt_fragdepth.c index 7fa9226..aacf653 100644 --- a/src/compiler/nir/nir_opt_fragdepth.c +++ b/src/compiler/nir/nir_opt_fragdepth.c @@ -112,9 +112,9 @@ nir_opt_fragdepth(nir_shader *shader) nir_instr_remove(&store_intrin->instr); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_loop_analysis | - nir_metadata_instr_index); + nir_metadata_dominance | + nir_metadata_loop_analysis | + nir_metadata_instr_index); progress = true; } diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c index a13c82f..90553d4 100644 --- a/src/compiler/nir/nir_opt_gcm.c +++ b/src/compiler/nir/nir_opt_gcm.c @@ -66,11 +66,11 @@ struct gcm_instr_info { /* Flags used in the instr->pass_flags field for various instruction states */ enum { - GCM_INSTR_PINNED = (1 << 0), + GCM_INSTR_PINNED = (1 << 0), GCM_INSTR_SCHEDULE_EARLIER_ONLY = (1 << 1), - GCM_INSTR_SCHEDULED_EARLY = (1 << 2), - GCM_INSTR_SCHEDULED_LATE = (1 << 3), - GCM_INSTR_PLACED = (1 << 4), + GCM_INSTR_SCHEDULED_EARLY = (1 << 2), + GCM_INSTR_SCHEDULED_LATE = (1 << 3), + GCM_INSTR_PLACED = (1 << 4), }; struct gcm_state { @@ -427,7 +427,6 @@ gcm_schedule_early_src(nir_src *src, void *void_state) struct gcm_state *state = void_state; nir_instr *instr = state->instr; - gcm_schedule_early_instr(src->ssa->parent_instr, void_state); /* While the index isn't a proper dominance depth, it does have the @@ -538,7 +537,7 @@ set_block_for_loop_instr(struct gcm_state *state, nir_instr *instr, } static bool -set_block_to_if_block(struct gcm_state *state, nir_instr *instr, +set_block_to_if_block(struct gcm_state *state, nir_instr *instr, nir_block *block) { if (instr->type == nir_instr_type_load_const) @@ -571,17 +570,17 @@ gcm_choose_block_for_instr(nir_instr *instr, nir_block *early_block, continue; if (state->blocks[block->index].if_depth >= - state->blocks[best->index].if_depth && + state->blocks[best->index].if_depth && set_block_to_if_block(state, instr, block)) { - /* If we are pushing the instruction into an if we want it to be - * in the earliest block not the latest to avoid creating register - * pressure issues. So we don't break unless we come across the - * block the instruction was originally in. - */ - best = block; - block_set = true; - if (block == instr->block) - break; + /* If we are pushing the instruction into an if we want it to be + * in the earliest block not the latest to avoid creating register + * pressure issues. So we don't break unless we come across the + * block the instruction was originally in. + */ + best = block; + block_set = true; + if (block == instr->block) + break; } else if (block == instr->block) { /* If we couldn't push the instruction later just put is back where it * was previously. @@ -809,7 +808,7 @@ static bool opt_gcm_impl(nir_shader *shader, nir_function_impl *impl, bool value_number) { nir_metadata_require(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); nir_metadata_require(impl, nir_metadata_loop_analysis, shader->options->force_indirect_unrolling, shader->options->force_indirect_unrolling_sampler); @@ -871,8 +870,8 @@ opt_gcm_impl(nir_shader *shader, nir_function_impl *impl, bool value_number) ralloc_free(state.instr_infos); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_loop_analysis); + nir_metadata_dominance | + nir_metadata_loop_analysis); return state.progress; } diff --git a/src/compiler/nir/nir_opt_idiv_const.c b/src/compiler/nir/nir_opt_idiv_const.c index 394bf7a..1e546df 100644 --- a/src/compiler/nir/nir_opt_idiv_const.c +++ b/src/compiler/nir/nir_opt_idiv_const.c @@ -21,10 +21,10 @@ * IN THE SOFTWARE. */ -#include "nir.h" -#include "nir_builder.h" #include "util/fast_idiv_by_const.h" #include "util/u_math.h" +#include "nir.h" +#include "nir_builder.h" static nir_ssa_def * build_udiv(nir_builder *b, nir_ssa_def *n, uint64_t d) @@ -161,7 +161,6 @@ nir_opt_idiv_const_instr(nir_builder *b, nir_instr *instr, void *user_data) alu->op != nir_op_irem) return false; - if (alu->dest.dest.ssa.bit_size < *min_bit_size) return false; @@ -225,6 +224,6 @@ nir_opt_idiv_const(nir_shader *shader, unsigned min_bit_size) { return nir_shader_instructions_pass(shader, nir_opt_idiv_const_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &min_bit_size); } diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c index c08a9b9..d65a4d0 100644 --- a/src/compiler/nir/nir_opt_if.c +++ b/src/compiler/nir/nir_opt_if.c @@ -21,8 +21,8 @@ * IN THE SOFTWARE. */ -#include "nir.h" #include "nir/nir_builder.h" +#include "nir.h" #include "nir_constant_expressions.h" #include "nir_control_flow.h" #include "nir_loop_analyze.h" @@ -35,7 +35,7 @@ static nir_ssa_def *clone_alu_and_replace_src_defs(nir_builder *b, * Gets the single block that jumps back to the loop header. Already assumes * there is exactly one such block. */ -static nir_block* +static nir_block * find_continue_block(nir_loop *loop) { nir_block *header_block = nir_loop_first_block(loop); @@ -46,7 +46,7 @@ find_continue_block(nir_loop *loop) set_foreach(header_block->predecessors, pred_entry) { if (pred_entry->key != prev_block) - return (nir_block*)pred_entry->key; + return (nir_block *)pred_entry->key; } unreachable("Continue block not found!"); @@ -67,18 +67,18 @@ phi_has_constant_from_outside_and_one_from_inside_loop(nir_phi_instr *phi, *entry_val = false; *continue_val = false; - nir_foreach_phi_src(src, phi) { - if (!nir_src_is_const(src->src)) + nir_foreach_phi_src(src, phi) { + if (!nir_src_is_const(src->src)) return false; - if (src->pred != entry_block) { - *continue_val = nir_src_as_bool(src->src); - } else { - *entry_val = nir_src_as_bool(src->src); - } - } + if (src->pred != entry_block) { + *continue_val = nir_src_as_bool(src->src); + } else { + *entry_val = nir_src_as_bool(src->src); + } + } - return true; + return true; } /** @@ -226,12 +226,12 @@ opt_peel_loop_initial_if(nir_loop *loop) nir_cf_list header, tmp; nir_cf_extract(&header, nir_before_block(header_block), - nir_after_block(header_block)); + nir_after_block(header_block)); nir_cf_list_clone(&tmp, &header, &loop->cf_node, NULL); nir_cf_reinsert(&tmp, nir_before_cf_node(&loop->cf_node)); nir_cf_extract(&tmp, nir_before_cf_list(entry_list), - nir_after_cf_list(entry_list)); + nir_after_cf_list(entry_list)); nir_cf_reinsert(&tmp, nir_before_cf_node(&loop->cf_node)); nir_cf_reinsert(&header, @@ -243,7 +243,7 @@ opt_peel_loop_initial_if(nir_loop *loop) cf_node.node)); nir_cf_extract(&tmp, nir_before_cf_list(continue_list), - nir_after_cf_list(continue_list)); + nir_after_cf_list(continue_list)); /* Get continue block again as the previous reinsert might have removed the * block. Also, if both the continue list and the continue block ends in @@ -655,11 +655,13 @@ opt_simplify_bcsel_of_phi(nir_builder *b, nir_loop *loop) nir_phi_instr *const phi = nir_phi_instr_create(b->shader); nir_phi_instr_add_src(phi, prev_block, nir_phi_get_src_from_block(nir_instr_as_phi(bcsel->src[entry_src].src.ssa->parent_instr), - prev_block)->src); + prev_block) + ->src); nir_phi_instr_add_src(phi, continue_block, nir_phi_get_src_from_block(nir_instr_as_phi(bcsel->src[continue_src].src.ssa->parent_instr), - continue_block)->src); + continue_block) + ->src); nir_ssa_dest_init(&phi->instr, &phi->dest, nir_dest_num_components(bcsel->dest.dest), @@ -701,7 +703,7 @@ nir_block_ends_in_continue(nir_block *block) nir_instr *instr = nir_block_last_instr(block); return instr->type == nir_instr_type_jump && - nir_instr_as_jump(instr)->type == nir_jump_continue; + nir_instr_as_jump(instr)->type == nir_jump_continue; } /** @@ -798,7 +800,7 @@ opt_if_loop_last_continue(nir_loop *loop, bool aggressive_last_continue) /* Move the last block of the loop inside the last if-statement */ nir_cf_list tmp; nir_cf_extract(&tmp, nir_after_cf_node(if_node), - nir_after_block(last_block)); + nir_after_block(last_block)); if (then_ends_in_continue) nir_cf_reinsert(&tmp, nir_after_cf_list(&nif->else_list)); else @@ -897,7 +899,7 @@ opt_if_simplification(nir_builder *b, nir_if *nif) /* Finally, move the else block to the then block. */ nir_cf_list tmp; nir_cf_extract(&tmp, nir_before_cf_list(&nif->else_list), - nir_after_cf_list(&nif->else_list)); + nir_after_cf_list(&nif->else_list)); nir_cf_reinsert(&tmp, nir_before_cf_list(&nif->then_list)); return true; @@ -922,8 +924,11 @@ opt_if_phi_is_condition(nir_builder *b, nir_if *nif) continue; enum opt_bool { - T, F, UNKNOWN - } then_val = UNKNOWN, else_val = UNKNOWN; + T, + F, + UNKNOWN + } then_val = UNKNOWN, + else_val = UNKNOWN; nir_foreach_phi_src(src, phi) { assert(src->pred == then_block || src->pred == else_block); @@ -1042,7 +1047,7 @@ opt_merge_breaks(nir_if *nif) nir_instr_remove_v(jump); nir_instr_insert(nir_after_block(after_if), jump); return true; - } + } /* Single break: If there's a break after the branch and the non-breaking * side of the if falls through to it, then hoist that code after up into @@ -1058,7 +1063,7 @@ opt_merge_breaks(nir_if *nif) nir_cf_node *first = nir_cf_node_next(&nif->cf_node); nir_cf_node *last = first; while (!nir_cf_node_is_last(last)) { - if (contains_other_jump (last, NULL)) + if (contains_other_jump(last, NULL)) return false; last = nir_cf_node_next(last); } @@ -1074,7 +1079,7 @@ opt_merge_breaks(nir_if *nif) nir_cf_list tmp; nir_cf_extract(&tmp, nir_before_cf_node(first), - nir_after_block_before_jump(nir_cf_node_as_block(last))); + nir_after_block_before_jump(nir_cf_node_as_block(last))); if (then_break) nir_cf_reinsert(&tmp, nir_after_block(last_else)); else @@ -1134,9 +1139,7 @@ opt_if_loop_terminator(nir_if *nif) /* If the continue from block is empty then return as there is nothing to * move. */ - nir_block *first_continue_from_blk = continue_from_then ? - nir_if_first_then_block(nif) : - nir_if_first_else_block(nif); + nir_block *first_continue_from_blk = continue_from_then ? nir_if_first_then_block(nif) : nir_if_first_else_block(nif); if (is_block_empty(first_continue_from_blk)) return false; @@ -1153,7 +1156,7 @@ opt_if_loop_terminator(nir_if *nif) /* Finally, move the continue from branch after the if-statement. */ nir_cf_list tmp; nir_cf_extract(&tmp, nir_before_block(first_continue_from_blk), - nir_after_block(continue_from_blk)); + nir_after_block(continue_from_blk)); nir_cf_reinsert(&tmp, nir_after_cf_node(&nif->cf_node)); return true; @@ -1185,7 +1188,6 @@ clone_alu_and_replace_src_defs(nir_builder *b, const nir_alu_instr *alu, alu->dest.dest.ssa.num_components, alu->dest.dest.ssa.bit_size); - for (unsigned i = 0; i < nir_op_infos[alu->op].num_inputs; i++) { nalu->src[i].src = nir_src_for_ssa(src_defs[i]); memcpy(nalu->src[i].swizzle, alu->src[i].swizzle, @@ -1194,7 +1196,8 @@ clone_alu_and_replace_src_defs(nir_builder *b, const nir_alu_instr *alu, nir_builder_instr_insert(b, &nalu->instr); - return &nalu->dest.dest.ssa;; + return &nalu->dest.dest.ssa; + ; } /* @@ -1253,7 +1256,7 @@ propagate_condition_eval(nir_builder *b, nir_if *nif, nir_src *use_src, if (!evaluate_if_condition(nif, b->cursor, &bool_value)) return false; - nir_ssa_def *def[NIR_MAX_VEC_COMPONENTS] = {0}; + nir_ssa_def *def[NIR_MAX_VEC_COMPONENTS] = { 0 }; for (unsigned i = 0; i < nir_op_infos[alu->op].num_inputs; i++) { if (alu->src[i].src.ssa == use_src->ssa) { def[i] = nir_imm_bool(b, bool_value); @@ -1283,15 +1286,15 @@ can_propagate_through_alu(nir_src *src) nir_alu_instr *alu = nir_instr_as_alu(src->parent_instr); switch (alu->op) { - case nir_op_ior: - case nir_op_iand: - case nir_op_inot: - case nir_op_b2i32: - return true; - case nir_op_bcsel: - return src == &alu->src[0].src; - default: - return false; + case nir_op_ior: + case nir_op_iand: + case nir_op_inot: + case nir_op_b2i32: + return true; + case nir_op_bcsel: + return src == &alu->src[0].src; + default: + return false; } } @@ -1394,7 +1397,7 @@ rewrite_comp_uses_within_if(nir_builder *b, nir_if *nif, bool invert, * use(b) * if (c == (d=load_const)) * use(d) -*/ + */ static bool opt_if_rewrite_uniform_uses(nir_builder *b, nir_if *nif, nir_ssa_scalar cond, bool accept_ine) { @@ -1428,7 +1431,7 @@ opt_if_rewrite_uniform_uses(nir_builder *b, nir_if *nif, nir_ssa_scalar cond, bo (intrin->intrinsic != nir_intrinsic_reduce || nir_intrinsic_cluster_size(intrin))) continue; - nir_ssa_scalar intrin_src = {intrin->src[0].ssa, src_uni.comp}; + nir_ssa_scalar intrin_src = { intrin->src[0].ssa, src_uni.comp }; nir_ssa_scalar resolved_intrin_src = nir_ssa_scalar_resolved(intrin_src.def, intrin_src.comp); if (resolved_intrin_src.comp != src_div.comp || resolved_intrin_src.def != src_div.def) @@ -1673,10 +1676,10 @@ nir_opt_if(nir_shader *shader, nir_opt_if_options options) nir_builder b = nir_builder_create(impl); nir_metadata_require(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); progress = opt_if_safe_cf_list(&b, &impl->body); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); bool preserve = true; diff --git a/src/compiler/nir/nir_opt_intrinsics.c b/src/compiler/nir/nir_opt_intrinsics.c index 1a4e585..e1e8ab9 100644 --- a/src/compiler/nir/nir_opt_intrinsics.c +++ b/src/compiler/nir/nir_opt_intrinsics.c @@ -311,7 +311,7 @@ opt_intrinsics_intrin(nir_builder *b, nir_intrinsic_instr *intrin, alu->op == nir_op_ine) { /* Check for 0 in either operand. */ nir_const_value *const_val = - nir_src_as_const_value(alu->src[0].src); + nir_src_as_const_value(alu->src[0].src); if (!const_val) const_val = nir_src_as_const_value(alu->src[1].src); if (!const_val || const_val->i32 != 0) @@ -391,7 +391,7 @@ nir_opt_intrinsics(nir_shader *shader) if (opt_intrinsics_impl(impl, shader->options)) { progress = true; nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_large_constants.c b/src/compiler/nir/nir_opt_large_constants.c index eae4363..d79455b 100644 --- a/src/compiler/nir/nir_opt_large_constants.c +++ b/src/compiler/nir/nir_opt_large_constants.c @@ -184,7 +184,7 @@ nir_opt_large_constants(nir_shader *shader, struct var_info *var_infos = ralloc_array(NULL, struct var_info, num_locals); nir_foreach_function_temp_variable(var, impl) { - var_infos[var->index] = (struct var_info) { + var_infos[var->index] = (struct var_info){ .var = var, .is_constant = true, .found_read = false, @@ -402,6 +402,6 @@ nir_opt_large_constants(nir_shader *shader, ralloc_free(var_infos); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); return true; } diff --git a/src/compiler/nir/nir_opt_load_store_vectorize.c b/src/compiler/nir/nir_opt_load_store_vectorize.c index 271783a..5cf8358 100644 --- a/src/compiler/nir/nir_opt_load_store_vectorize.c +++ b/src/compiler/nir/nir_opt_load_store_vectorize.c @@ -40,13 +40,13 @@ * Handling these cases probably wouldn't provide much benefit though. * * This probably doesn't handle big-endian GPUs correctly. -*/ + */ +#include "util/u_dynarray.h" #include "nir.h" -#include "nir_deref.h" #include "nir_builder.h" +#include "nir_deref.h" #include "nir_worklist.h" -#include "util/u_dynarray.h" #include @@ -56,49 +56,50 @@ struct intrinsic_info { bool is_atomic; /* Indices into nir_intrinsic::src[] or -1 if not applicable. */ int resource_src; /* resource (e.g. from vulkan_resource_index) */ - int base_src; /* offset which it loads/stores from */ - int deref_src; /* deref which is loads/stores from */ - int value_src; /* the data it is storing */ + int base_src; /* offset which it loads/stores from */ + int deref_src; /* deref which is loads/stores from */ + int value_src; /* the data it is storing */ }; static const struct intrinsic_info * -get_info(nir_intrinsic_op op) { +get_info(nir_intrinsic_op op) +{ switch (op) { -#define INFO(mode, op, atomic, res, base, deref, val) \ -case nir_intrinsic_##op: {\ - static const struct intrinsic_info op##_info = {mode, nir_intrinsic_##op, atomic, res, base, deref, val};\ - return &op##_info;\ -} -#define LOAD(mode, op, res, base, deref) INFO(mode, load_##op, false, res, base, deref, -1) +#define INFO(mode, op, atomic, res, base, deref, val) \ + case nir_intrinsic_##op: { \ + static const struct intrinsic_info op##_info = { mode, nir_intrinsic_##op, atomic, res, base, deref, val }; \ + return &op##_info; \ + } +#define LOAD(mode, op, res, base, deref) INFO(mode, load_##op, false, res, base, deref, -1) #define STORE(mode, op, res, base, deref, val) INFO(mode, store_##op, false, res, base, deref, val) -#define ATOMIC(mode, type, res, base, deref, val) \ +#define ATOMIC(mode, type, res, base, deref, val) \ INFO(mode, type##_atomic, true, res, base, deref, val) \ - INFO(mode, type##_atomic_swap, true, res, base, deref, val) \ - - LOAD(nir_var_mem_push_const, push_constant, -1, 0, -1) - LOAD(nir_var_mem_ubo, ubo, 0, 1, -1) - LOAD(nir_var_mem_ssbo, ssbo, 0, 1, -1) - STORE(nir_var_mem_ssbo, ssbo, 1, 2, -1, 0) - LOAD(0, deref, -1, -1, 0) - STORE(0, deref, -1, -1, 0, 1) - LOAD(nir_var_mem_shared, shared, -1, 0, -1) - STORE(nir_var_mem_shared, shared, -1, 1, -1, 0) - LOAD(nir_var_mem_global, global, -1, 0, -1) - STORE(nir_var_mem_global, global, -1, 1, -1, 0) - LOAD(nir_var_mem_global, global_constant, -1, 0, -1) - LOAD(nir_var_mem_task_payload, task_payload, -1, 0, -1) - STORE(nir_var_mem_task_payload, task_payload, -1, 1, -1, 0) - ATOMIC(nir_var_mem_ssbo, ssbo, 0, 1, -1, 2) - ATOMIC(0, deref, -1, -1, 0, 1) - ATOMIC(nir_var_mem_shared, shared, -1, 0, -1, 1) - ATOMIC(nir_var_mem_global, global, -1, 0, -1, 1) - ATOMIC(nir_var_mem_task_payload, task_payload, -1, 0, -1, 1) - LOAD(nir_var_shader_temp, stack, -1, -1, -1) - STORE(nir_var_shader_temp, stack, -1, -1, -1, 0) - LOAD(nir_var_mem_ubo, ubo_uniform_block_intel, 0, 1, -1) - LOAD(nir_var_mem_ssbo, ssbo_uniform_block_intel, 0, 1, -1) - LOAD(nir_var_mem_shared, shared_uniform_block_intel, -1, 0, -1) - LOAD(nir_var_mem_global, global_constant_uniform_block_intel, -1, 0, -1) + INFO(mode, type##_atomic_swap, true, res, base, deref, val) + + LOAD(nir_var_mem_push_const, push_constant, -1, 0, -1) + LOAD(nir_var_mem_ubo, ubo, 0, 1, -1) + LOAD(nir_var_mem_ssbo, ssbo, 0, 1, -1) + STORE(nir_var_mem_ssbo, ssbo, 1, 2, -1, 0) + LOAD(0, deref, -1, -1, 0) + STORE(0, deref, -1, -1, 0, 1) + LOAD(nir_var_mem_shared, shared, -1, 0, -1) + STORE(nir_var_mem_shared, shared, -1, 1, -1, 0) + LOAD(nir_var_mem_global, global, -1, 0, -1) + STORE(nir_var_mem_global, global, -1, 1, -1, 0) + LOAD(nir_var_mem_global, global_constant, -1, 0, -1) + LOAD(nir_var_mem_task_payload, task_payload, -1, 0, -1) + STORE(nir_var_mem_task_payload, task_payload, -1, 1, -1, 0) + ATOMIC(nir_var_mem_ssbo, ssbo, 0, 1, -1, 2) + ATOMIC(0, deref, -1, -1, 0, 1) + ATOMIC(nir_var_mem_shared, shared, -1, 0, -1, 1) + ATOMIC(nir_var_mem_global, global, -1, 0, -1, 1) + ATOMIC(nir_var_mem_task_payload, task_payload, -1, 0, -1, 1) + LOAD(nir_var_shader_temp, stack, -1, -1, -1) + STORE(nir_var_shader_temp, stack, -1, -1, -1, 0) + LOAD(nir_var_mem_ubo, ubo_uniform_block_intel, 0, 1, -1) + LOAD(nir_var_mem_ssbo, ssbo_uniform_block_intel, 0, 1, -1) + LOAD(nir_var_mem_shared, shared_uniform_block_intel, -1, 0, -1) + LOAD(nir_var_mem_global, global_constant_uniform_block_intel, -1, 0, -1) default: break; #undef ATOMIC @@ -154,11 +155,12 @@ struct vectorize_ctx { struct hash_table *stores[nir_num_variable_modes]; }; -static uint32_t hash_entry_key(const void *key_) +static uint32_t +hash_entry_key(const void *key_) { /* this is careful to not include pointers in the hash calculation so that * the order of the hash table walk is deterministic */ - struct entry_key *key = (struct entry_key*)key_; + struct entry_key *key = (struct entry_key *)key_; uint32_t hash = 0; if (key->resource) @@ -179,10 +181,11 @@ static uint32_t hash_entry_key(const void *key_) return hash; } -static bool entry_key_equals(const void *a_, const void *b_) +static bool +entry_key_equals(const void *a_, const void *b_) { - struct entry_key *a = (struct entry_key*)a_; - struct entry_key *b = (struct entry_key*)b_; + struct entry_key *a = (struct entry_key *)a_; + struct entry_key *b = (struct entry_key *)b_; if (a->var != b->var || a->resource != b->resource) return false; @@ -204,16 +207,18 @@ static bool entry_key_equals(const void *a_, const void *b_) return true; } -static void delete_entry_dynarray(struct hash_entry *entry) +static void +delete_entry_dynarray(struct hash_entry *entry) { struct util_dynarray *arr = (struct util_dynarray *)entry->data; ralloc_free(arr); } -static int sort_entries(const void *a_, const void *b_) +static int +sort_entries(const void *a_, const void *b_) { - struct entry *a = *(struct entry*const*)a_; - struct entry *b = *(struct entry*const*)b_; + struct entry *a = *(struct entry *const *)a_; + struct entry *b = *(struct entry *const *)b_; if (a->offset_signed > b->offset_signed) return 1; @@ -226,9 +231,7 @@ static int sort_entries(const void *a_, const void *b_) static unsigned get_bit_size(struct entry *entry) { - unsigned size = entry->is_store ? - entry->intrin->src[entry->info->value_src].ssa->bit_size : - entry->intrin->dest.ssa.bit_size; + unsigned size = entry->is_store ? entry->intrin->src[entry->info->value_src].ssa->bit_size : entry->intrin->dest.ssa.bit_size; return size == 1 ? 32u : size; } @@ -352,7 +355,7 @@ create_entry_key_from_deref(void *mem_ctx, } unsigned offset_def_count = 0; - struct entry_key* key = ralloc(mem_ctx, struct entry_key); + struct entry_key *key = ralloc(mem_ctx, struct entry_key); key->resource = NULL; key->var = NULL; *offset_base = 0; @@ -373,7 +376,7 @@ create_entry_key_from_deref(void *mem_ctx, nir_ssa_def *index = deref->arr.index.ssa; uint32_t stride = nir_deref_instr_array_stride(deref); - nir_ssa_scalar base = {.def=index, .comp=0}; + nir_ssa_scalar base = { .def = index, .comp = 0 }; uint64_t offset = 0, base_mul = 1; parse_offset(&base, &base_mul, &offset); offset = util_mask_sign_extend(offset, index->bit_size); @@ -438,9 +441,9 @@ parse_entry_key_from_offset(struct entry_key *key, unsigned size, unsigned left, nir_ssa_scalar src1 = nir_ssa_scalar_chase_alu_src(base, 1); unsigned amount = parse_entry_key_from_offset(key, size, left - 1, src0, base_mul, offset); amount += parse_entry_key_from_offset(key, size + amount, left - amount, src1, base_mul, offset); - return amount; - } + return amount; } + } return add_to_entry_key(key->offset_defs, key->offset_defs_mul, size, base, base_mul); } @@ -457,7 +460,7 @@ create_entry_key_from_offset(void *mem_ctx, nir_ssa_def *base, uint64_t base_mul key->offset_defs = offset_defs; key->offset_defs_mul = offset_defs_mul; - nir_ssa_scalar scalar = {.def=base, .comp=0}; + nir_ssa_scalar scalar = { .def = base, .comp = 0 }; key->offset_def_count = parse_entry_key_from_offset(key, 0, 32, scalar, base_mul, offset); key->offset_defs = ralloc_array(mem_ctx, nir_ssa_scalar, key->offset_def_count); @@ -539,8 +542,7 @@ create_entry(struct vectorize_ctx *ctx, entry->key = create_entry_key_from_deref(entry, ctx, &path, &entry->offset); nir_deref_path_finish(&path); } else { - nir_ssa_def *base = entry->info->base_src >= 0 ? - intrin->src[entry->info->base_src].ssa : NULL; + nir_ssa_def *base = entry->info->base_src >= 0 ? intrin->src[entry->info->base_src].ssa : NULL; uint64_t offset = 0; if (nir_intrinsic_has_base(intrin)) offset += nir_intrinsic_base(intrin); @@ -579,11 +581,12 @@ static nir_deref_instr * cast_deref(nir_builder *b, unsigned num_components, unsigned bit_size, nir_deref_instr *deref) { if (glsl_get_components(deref->type) == num_components && - type_scalar_size_bytes(deref->type)*8u == bit_size) + type_scalar_size_bytes(deref->type) * 8u == bit_size) return deref; enum glsl_base_type types[] = { - GLSL_TYPE_UINT8, GLSL_TYPE_UINT16, GLSL_TYPE_UINT, GLSL_TYPE_UINT64}; + GLSL_TYPE_UINT8, GLSL_TYPE_UINT16, GLSL_TYPE_UINT, GLSL_TYPE_UINT64 + }; enum glsl_base_type base = types[ffs(bit_size / 8u) - 1u]; const struct glsl_type *type = glsl_vector_type(base, num_components); @@ -644,7 +647,8 @@ new_bitsize_acceptable(struct vectorize_ctx *ctx, unsigned new_bit_size, return true; } -static nir_deref_instr *subtract_deref(nir_builder *b, nir_deref_instr *deref, int64_t offset) +static nir_deref_instr * +subtract_deref(nir_builder *b, nir_deref_instr *deref, int64_t offset) { /* avoid adding another deref to the path */ if (deref->deref_type == nir_deref_type_ptr_as_array && @@ -665,7 +669,6 @@ static nir_deref_instr *subtract_deref(nir_builder *b, nir_deref_instr *deref, i b, parent, nir_src_as_int(deref->arr.index) - offset / stride); } - deref = nir_build_deref_cast(b, &deref->dest.ssa, deref->modes, glsl_scalar_type(GLSL_TYPE_UINT8), 1); return nir_build_deref_ptr_as_array( @@ -866,12 +869,12 @@ bindings_different_restrict(nir_shader *shader, struct entry *a, struct entry *b if (a_res.num_indices != b_res.num_indices || a_res.desc_set != b_res.desc_set || a_res.binding != b_res.binding) - different_bindings = true; + different_bindings = true; for (unsigned i = 0; i < a_res.num_indices; i++) { if (nir_src_is_const(a_res.indices[i]) && nir_src_is_const(b_res.indices[i]) && nir_src_as_uint(a_res.indices[i]) != nir_src_as_uint(b_res.indices[i])) - different_bindings = true; + different_bindings = true; } if (different_bindings) { @@ -1053,7 +1056,7 @@ is_strided_vector(const struct glsl_type *type) if (glsl_type_is_vector(type)) { unsigned explicit_stride = glsl_get_explicit_stride(type); return explicit_stride != 0 && explicit_stride != - type_scalar_size_bytes(glsl_get_array_element(type)); + type_scalar_size_bytes(glsl_get_array_element(type)); } else { return false; } @@ -1189,11 +1192,11 @@ try_vectorize_shared2(struct vectorize_ctx *ctx, nir_ssa_def *low_val = low->intrin->src[low->info->value_src].ssa; nir_ssa_def *high_val = high->intrin->src[high->info->value_src].ssa; nir_ssa_def *val = nir_vec2(&b, nir_bitcast_vector(&b, low_val, low_size * 8u), - nir_bitcast_vector(&b, high_val, low_size * 8u)); - nir_store_shared2_amd(&b, val, offset, .offset1=diff/stride, .st64=st64); + nir_bitcast_vector(&b, high_val, low_size * 8u)); + nir_store_shared2_amd(&b, val, offset, .offset1 = diff / stride, .st64 = st64); } else { - nir_ssa_def *new_def = nir_load_shared2_amd(&b, low_size * 8u, offset, .offset1=diff/stride, - .st64=st64); + nir_ssa_def *new_def = nir_load_shared2_amd(&b, low_size * 8u, offset, .offset1 = diff / stride, + .st64 = st64); nir_ssa_def_rewrite_uses(&low->intrin->dest.ssa, nir_bitcast_vector(&b, nir_channel(&b, new_def, 0), low_bit_size)); nir_ssa_def_rewrite_uses(&high->intrin->dest.ssa, @@ -1390,7 +1393,7 @@ process_block(nir_function_impl *impl, struct vectorize_ctx *ctx, nir_block *blo continue; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - const struct intrinsic_info *info = get_info(intrin->intrinsic); + const struct intrinsic_info *info = get_info(intrin->intrinsic); if (!info) continue; @@ -1462,8 +1465,8 @@ nir_opt_load_store_vectorize(nir_shader *shader, const nir_load_store_vectorize_ nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs); + nir_metadata_dominance | + nir_metadata_live_ssa_defs); } ralloc_free(ctx); diff --git a/src/compiler/nir/nir_opt_loop_unroll.c b/src/compiler/nir/nir_opt_loop_unroll.c index 801187a..a035c68 100644 --- a/src/compiler/nir/nir_opt_loop_unroll.c +++ b/src/compiler/nir/nir_opt_loop_unroll.c @@ -26,7 +26,6 @@ #include "nir_control_flow.h" #include "nir_loop_analyze.h" - /* This limit is chosen fairly arbitrarily. GLSL IR max iteration is 32 * instructions. (Multiply counting nodes and magic number 5.) But there is * no 1:1 mapping between GLSL IR and NIR so 25 was picked because it seemed @@ -523,9 +522,7 @@ complex_unroll_single_terminator(nir_loop *loop) nir_cf_list_clone_and_reinsert(&lcssa_list, loop->cf_node.parent, cursor, remap_table); - start_cursor = terminator->continue_from_then ? - nir_before_block(nir_if_first_else_block(if_stmt)) : - nir_before_block(nir_if_first_then_block(if_stmt)); + start_cursor = terminator->continue_from_then ? nir_before_block(nir_if_first_else_block(if_stmt)) : nir_before_block(nir_if_first_then_block(if_stmt)); /* Reinsert the cloned vars back where they came from */ nir_cf_reinsert(&lcssa_list, start_cursor); @@ -590,9 +587,7 @@ wrapper_unroll(nir_loop *loop) nir_cf_reinsert(&loop_body, nir_after_block(terminator->continue_from_block)); - loop_end = terminator->continue_from_then ? - nir_after_block(nir_if_last_then_block(terminator->nif)) : - nir_after_block(nir_if_last_else_block(terminator->nif)); + loop_end = terminator->continue_from_then ? nir_after_block(nir_if_last_then_block(terminator->nif)) : nir_after_block(nir_if_last_else_block(terminator->nif)); } } else { loop_prepare_for_unroll(loop); @@ -635,9 +630,7 @@ is_access_out_of_bounds(nir_loop_terminator *term, nir_deref_instr *deref, * the trip count any iteration over the loop will be an out of bounds * access of the array. */ - unsigned length = glsl_type_is_vector(parent->type) ? - glsl_get_vector_elements(parent->type) : - glsl_get_length(parent->type); + unsigned length = glsl_type_is_vector(parent->type) ? glsl_get_vector_elements(parent->type) : glsl_get_length(parent->type); return length <= trip_count; } @@ -720,7 +713,7 @@ partial_unroll(nir_shader *shader, nir_loop *loop, unsigned trip_count) nir_loop_terminator *terminator = list_first_entry(&loop->info->loop_terminator_list, - nir_loop_terminator, loop_terminator_link); + nir_loop_terminator, loop_terminator_link); assert(nir_is_trivial_loop_if(terminator->nif, terminator->break_block)); @@ -1002,9 +995,7 @@ process_loops(nir_shader *sh, nir_cf_node *cf_node, bool *has_nested_loop_out, * We trust that nir_opt_if() does its job well enough to * remove all instructions from the continue block when possible. */ - nir_block *first_continue_from_blk = t->continue_from_then ? - nir_if_first_then_block(t->nif) : - nir_if_first_else_block(t->nif); + nir_block *first_continue_from_blk = t->continue_from_then ? nir_if_first_then_block(t->nif) : nir_if_first_else_block(t->nif); if (!(nir_cf_node_is_last(&first_continue_from_blk->cf_node) && exec_list_is_empty(&first_continue_from_blk->instr_list))) @@ -1090,7 +1081,6 @@ process_loops(nir_shader *sh, nir_cf_node *cf_node, bool *has_nested_loop_out, list_first_entry(&loop->info->loop_terminator_list, nir_loop_terminator, loop_terminator_link); - if (terminator->nif == loop->info->limiting_terminator->nif) { limiting_term_second = false; terminator = @@ -1133,7 +1123,7 @@ nir_opt_loop_unroll_impl(nir_function_impl *impl, { bool progress = false; nir_metadata_require(impl, nir_metadata_loop_analysis, indirect_mask, - (int) force_unroll_sampler_indirect); + (int)force_unroll_sampler_indirect); nir_metadata_require(impl, nir_metadata_block_index); bool has_nested_loop = false; diff --git a/src/compiler/nir/nir_opt_memcpy.c b/src/compiler/nir/nir_opt_memcpy.c index 47c278e..d765855 100644 --- a/src/compiler/nir/nir_opt_memcpy.c +++ b/src/compiler/nir/nir_opt_memcpy.c @@ -278,7 +278,7 @@ opt_memcpy_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_move.c b/src/compiler/nir/nir_opt_move.c index 76fc2d9..bc00015 100644 --- a/src/compiler/nir/nir_opt_move.c +++ b/src/compiler/nir/nir_opt_move.c @@ -55,8 +55,7 @@ static bool nir_opt_move_block(nir_block *block, nir_move_options options) { bool progress = false; - nir_instr *last_instr = nir_block_ends_in_jump(block) ? - nir_block_last_instr(block) : NULL; + nir_instr *last_instr = nir_block_ends_in_jump(block) ? nir_block_last_instr(block) : NULL; const nir_if *iff = nir_block_get_following_if(block); const nir_instr *if_cond_instr = iff ? iff->condition.parent_instr : NULL; @@ -67,7 +66,7 @@ nir_opt_move_block(nir_block *block, nir_move_options options) * If multiple instructions have the same user, * the original order is kept. */ - unsigned index = 1; + unsigned index = 1; nir_foreach_instr_reverse_safe(instr, block) { instr->index = index++; @@ -137,8 +136,8 @@ nir_opt_move(nir_shader *shader, nir_move_options options) if (impl_progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs); + nir_metadata_dominance | + nir_metadata_live_ssa_defs); progress = true; } else { nir_metadata_preserve(impl, nir_metadata_all); diff --git a/src/compiler/nir/nir_opt_move_discards_to_top.c b/src/compiler/nir/nir_opt_move_discards_to_top.c index bb53b7b..9fa6e33 100644 --- a/src/compiler/nir/nir_opt_move_discards_to_top.c +++ b/src/compiler/nir/nir_opt_move_discards_to_top.c @@ -240,7 +240,7 @@ nir_opt_move_discards_to_top(nir_shader *shader) nir_foreach_function_impl(impl, shader) { if (opt_move_discards_to_top_impl(impl)) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); progress = true; } } diff --git a/src/compiler/nir/nir_opt_non_uniform_access.c b/src/compiler/nir/nir_opt_non_uniform_access.c index 6fab855..98ecc00 100644 --- a/src/compiler/nir/nir_opt_non_uniform_access.c +++ b/src/compiler/nir/nir_opt_non_uniform_access.c @@ -101,7 +101,7 @@ nir_has_non_uniform_access_impl(nir_function_impl *impl, enum nir_lower_non_unif case nir_instr_type_tex: { nir_tex_instr *tex = nir_instr_as_tex(instr); if ((types & nir_lower_non_uniform_texture_access) && - has_non_uniform_tex_access(tex)) + has_non_uniform_tex_access(tex)) return true; break; } @@ -110,15 +110,15 @@ nir_has_non_uniform_access_impl(nir_function_impl *impl, enum nir_lower_non_unif nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); if (is_ubo_intrinsic(intrin)) { if ((types & nir_lower_non_uniform_ubo_access) && - has_non_uniform_access_intrin(intrin)) + has_non_uniform_access_intrin(intrin)) return true; } else if (is_ssbo_intrinsic(intrin)) { if ((types & nir_lower_non_uniform_ssbo_access) && - has_non_uniform_access_intrin(intrin)) + has_non_uniform_access_intrin(intrin)) return true; } else if (is_image_intrinsic(intrin)) { if ((types & nir_lower_non_uniform_image_access) && - has_non_uniform_access_intrin(intrin)) + has_non_uniform_access_intrin(intrin)) return true; } else if (intrin->intrinsic == nir_intrinsic_get_ssbo_size) { if ((types & nir_lower_non_uniform_get_ssbo_size) && diff --git a/src/compiler/nir/nir_opt_offsets.c b/src/compiler/nir/nir_opt_offsets.c index 20e5af5..478a478 100644 --- a/src/compiler/nir/nir_opt_offsets.c +++ b/src/compiler/nir/nir_opt_offsets.c @@ -47,8 +47,8 @@ try_extract_const_addition(nir_builder *b, nir_ssa_scalar val, opt_offsets_state return val; nir_ssa_scalar src[2] = { - {alu->src[0].src.ssa, alu->src[0].swizzle[val.comp]}, - {alu->src[1].src.ssa, alu->src[1].swizzle[val.comp]}, + { alu->src[0].src.ssa, alu->src[0].swizzle[val.comp] }, + { alu->src[1].src.ssa, alu->src[1].swizzle[val.comp] }, }; /* Make sure that we aren't taking out an addition that could trigger @@ -92,8 +92,8 @@ try_extract_const_addition(nir_builder *b, nir_ssa_scalar val, opt_offsets_state b->cursor = nir_before_instr(&alu->instr); nir_ssa_def *r = - nir_iadd(b, nir_channel(b, src[0].def, src[0].comp), - nir_channel(b, src[1].def, src[1].comp)); + nir_iadd(b, nir_channel(b, src[0].def, src[0].comp), + nir_channel(b, src[1].def, src[1].comp)); return nir_get_ssa_scalar(r, 0); } @@ -118,7 +118,7 @@ try_fold_load_store(nir_builder *b, if (!nir_src_is_const(*off_src)) { uint32_t add_offset = 0; - nir_ssa_scalar val = {.def = off_src->ssa, .comp = 0}; + nir_ssa_scalar val = { .def = off_src->ssa, .comp = 0 }; val = try_extract_const_addition(b, val, state, &add_offset, max - off_const); if (add_offset == 0) return false; @@ -143,12 +143,11 @@ try_fold_load_store(nir_builder *b, static bool try_fold_shared2(nir_builder *b, - nir_intrinsic_instr *intrin, - opt_offsets_state *state, - unsigned offset_src_idx) + nir_intrinsic_instr *intrin, + opt_offsets_state *state, + unsigned offset_src_idx) { - unsigned comp_size = (intrin->intrinsic == nir_intrinsic_load_shared2_amd ? - intrin->dest.ssa.bit_size : intrin->src[0].ssa->bit_size) / 8; + unsigned comp_size = (intrin->intrinsic == nir_intrinsic_load_shared2_amd ? intrin->dest.ssa.bit_size : intrin->src[0].ssa->bit_size) / 8; unsigned stride = (nir_intrinsic_st64(intrin) ? 64 : 1) * comp_size; unsigned offset0 = nir_intrinsic_offset0(intrin) * stride; unsigned offset1 = nir_intrinsic_offset1(intrin) * stride; @@ -180,7 +179,7 @@ process_instr(nir_builder *b, nir_instr *instr, void *s) if (instr->type != nir_instr_type_intrinsic) return false; - opt_offsets_state *state = (opt_offsets_state *) s; + opt_offsets_state *state = (opt_offsets_state *)s; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); switch (intrin->intrinsic) { @@ -218,12 +217,11 @@ nir_opt_offsets(nir_shader *shader, const nir_opt_offsets_options *options) bool p = nir_shader_instructions_pass(shader, process_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, &state); if (state.range_ht) _mesa_hash_table_destroy(state.range_ht, NULL); - return p; } diff --git a/src/compiler/nir/nir_opt_peephole_select.c b/src/compiler/nir/nir_opt_peephole_select.c index 6830322..c34fa27 100644 --- a/src/compiler/nir/nir_opt_peephole_select.c +++ b/src/compiler/nir/nir_opt_peephole_select.c @@ -21,8 +21,8 @@ * IN THE SOFTWARE. */ -#include "nir.h" #include "nir/nir_builder.h" +#include "nir.h" #include "nir_control_flow.h" #include "nir_search_helpers.h" @@ -306,7 +306,7 @@ nir_opt_collapse_if(nir_if *if_stmt, nir_shader *shader, unsigned limit, nir_phi_src *else_src = nir_phi_get_src_from_block(phi, nir_if_first_else_block(if_stmt)); - nir_foreach_use (src, &phi->dest.ssa) { + nir_foreach_use(src, &phi->dest.ssa) { assert(src->parent_instr->type == nir_instr_type_phi); nir_phi_src *phi_src = nir_phi_get_src_from_block(nir_instr_as_phi(src->parent_instr), @@ -356,7 +356,7 @@ nir_opt_collapse_if(nir_if *if_stmt, nir_shader *shader, unsigned limit, /* move the whole inner if before the parent if */ nir_cf_list tmp; nir_cf_extract(&tmp, nir_before_block(first), - nir_after_block(last)); + nir_after_block(last)); nir_cf_reinsert(&tmp, nir_before_cf_node(&parent_if->cf_node)); /* The now empty parent if will be cleaned up by other passes */ diff --git a/src/compiler/nir/nir_opt_phi_precision.c b/src/compiler/nir/nir_opt_phi_precision.c index 85ef483..67e9653 100644 --- a/src/compiler/nir/nir_opt_phi_precision.c +++ b/src/compiler/nir/nir_opt_phi_precision.c @@ -96,13 +96,20 @@ static nir_op concrete_conversion(nir_op op) { switch (op) { - case nir_op_i2imp: return nir_op_i2i16; - case nir_op_i2fmp: return nir_op_i2f16; - case nir_op_u2fmp: return nir_op_u2f16; - case nir_op_f2fmp: return nir_op_f2f16; - case nir_op_f2imp: return nir_op_f2i16; - case nir_op_f2ump: return nir_op_f2u16; - default: return op; + case nir_op_i2imp: + return nir_op_i2i16; + case nir_op_i2fmp: + return nir_op_i2f16; + case nir_op_u2fmp: + return nir_op_u2f16; + case nir_op_f2fmp: + return nir_op_f2f16; + case nir_op_f2imp: + return nir_op_f2i16; + case nir_op_f2ump: + return nir_op_f2u16; + default: + return op; } } @@ -203,7 +210,7 @@ try_move_narrowing_dst(nir_builder *b, nir_phi_instr *phi) /* Are the only uses of the phi conversion instructions, and * are they all the same conversion? */ - nir_foreach_use_including_if (use, &phi->dest.ssa) { + nir_foreach_use_including_if(use, &phi->dest.ssa) { /* an if use means the phi is used directly in a conditional, ie. * without a conversion */ @@ -228,7 +235,7 @@ try_move_narrowing_dst(nir_builder *b, nir_phi_instr *phi) nir_alu_type_get_type_size(nir_op_infos[op].output_type)); /* Push the conversion into the new phi sources: */ - nir_foreach_phi_src (src, phi) { + nir_foreach_phi_src(src, phi) { /* insert new conversion instr in block of original phi src: */ b->cursor = nir_after_instr_and_phis(src->src.ssa->parent_instr); nir_ssa_def *old_src = src->src.ssa; @@ -242,7 +249,7 @@ try_move_narrowing_dst(nir_builder *b, nir_phi_instr *phi) * directly use the new phi, skipping the conversion out of the orig * phi */ - nir_foreach_use (use, &phi->dest.ssa) { + nir_foreach_use(use, &phi->dest.ssa) { /* We've previously established that all the uses were alu * conversion ops. Turn them into movs instead. */ @@ -278,7 +285,7 @@ can_convert_load_const(nir_load_const_instr *lc, nir_op op) break; case nir_type_float: if (lc->value[i].f32 != _mesa_half_to_float( - _mesa_float_to_half(lc->value[i].f32))) + _mesa_float_to_half(lc->value[i].f32))) return false; break; default: @@ -301,7 +308,7 @@ find_widening_op(nir_phi_instr *phi, unsigned *bit_size) bool has_load_const = false; *bit_size = 0; - nir_foreach_phi_src (src, phi) { + nir_foreach_phi_src(src, phi) { nir_instr *instr = src->src.ssa->parent_instr; if (instr->type == nir_instr_type_load_const) { has_load_const = true; @@ -337,7 +344,7 @@ find_widening_op(nir_phi_instr *phi, unsigned *bit_size) * loss of precision), then we could insert a narrowing->widening * sequence to make the rest of the transformation possible: */ - nir_foreach_phi_src (src, phi) { + nir_foreach_phi_src(src, phi) { nir_instr *instr = src->src.ssa->parent_instr; if (instr->type != nir_instr_type_load_const) continue; @@ -371,7 +378,7 @@ try_move_widening_src(nir_builder *b, nir_phi_instr *phi) phi->dest.ssa.num_components, bit_size); /* Remove the widening conversions from the phi sources: */ - nir_foreach_phi_src (src, phi) { + nir_foreach_phi_src(src, phi) { nir_instr *instr = src->src.ssa->parent_instr; nir_ssa_def *new_src; @@ -449,15 +456,15 @@ nir_opt_phi_precision(nir_shader *shader) nir_foreach_function_impl(impl, shader) { nir_builder b = nir_builder_create(impl); - nir_foreach_block (block, impl) { - nir_foreach_phi_safe (phi, block) + nir_foreach_block(block, impl) { + nir_foreach_phi_safe(phi, block) progress |= lower_phi(&b, phi); } if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -465,4 +472,3 @@ nir_opt_phi_precision(nir_shader *shader) return progress; } - diff --git a/src/compiler/nir/nir_opt_preamble.c b/src/compiler/nir/nir_opt_preamble.c index 41eee40..281377e 100644 --- a/src/compiler/nir/nir_opt_preamble.c +++ b/src/compiler/nir/nir_opt_preamble.c @@ -32,7 +32,6 @@ * in case backends want to insert their own code. */ - nir_function_impl * nir_shader_get_preamble(nir_shader *shader) { @@ -209,7 +208,7 @@ can_move_intrinsic(nir_intrinsic_instr *instr, opt_preamble_ctx *ctx) case nir_intrinsic_load_ssbo: case nir_intrinsic_load_ssbo_ir3: return (nir_intrinsic_access(instr) & ACCESS_CAN_REORDER) && - can_move_srcs(&instr->instr, ctx); + can_move_srcs(&instr->instr, ctx); default: return false; @@ -354,8 +353,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, ctx.states = calloc(impl->ssa_alloc, sizeof(*ctx.states)); /* Step 1: Calculate can_move */ - nir_foreach_block (block, impl) { - nir_foreach_instr (instr, block) { + nir_foreach_block(block, impl) { + nir_foreach_instr(instr, block) { nir_ssa_def *def = nir_instr_ssa_def(instr); if (!def) continue; @@ -380,8 +379,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, * program because it has a non-can_move user, including recursively. */ unsigned num_candidates = 0; - nir_foreach_block_reverse (block, impl) { - nir_foreach_instr_reverse (instr, block) { + nir_foreach_block_reverse(block, impl) { + nir_foreach_instr_reverse(instr, block) { nir_ssa_def *def = nir_instr_ssa_def(instr); if (!def) continue; @@ -394,7 +393,7 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, bool is_candidate = !avoid_instr(instr, options); state->candidate = false; state->must_stay = false; - nir_foreach_use (use, def) { + nir_foreach_use(use, def) { nir_ssa_def *use_def = nir_instr_ssa_def(use->parent_instr); if (!use_def || !ctx.states[use_def->index].can_move || ctx.states[use_def->index].must_stay) { @@ -407,7 +406,7 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, } } - nir_foreach_if_use (use, def) { + nir_foreach_if_use(use, def) { if (is_candidate) state->candidate = true; else @@ -440,8 +439,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, * * While we're here, also collect an array of candidates. */ - nir_foreach_block (block, impl) { - nir_foreach_instr (instr, block) { + nir_foreach_block(block, impl) { + nir_foreach_instr(instr, block) { nir_ssa_def *def = nir_instr_ssa_def(instr); if (!def) continue; @@ -452,7 +451,7 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, ctx.def = def; nir_foreach_src(instr, update_src_value, &ctx); - + /* If this instruction is a candidate, its value shouldn't be * propagated so we skip dividing it. * @@ -468,7 +467,7 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, if (state->candidate) { state->benefit = state->value - - options->rewrite_cost_cb(def, options->cb_data); + options->rewrite_cost_cb(def, options->cb_data); if (state->benefit > 0) { options->def_size(def, &state->size, &state->align); @@ -497,7 +496,7 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, */ if (((*size) + total_size) > options->preamble_storage_size) { - qsort(candidates, num_candidates, sizeof(*candidates), candidate_sort); + qsort(candidates, num_candidates, sizeof(*candidates), candidate_sort); } unsigned offset = *size; @@ -526,8 +525,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, nir_builder preamble_builder = nir_builder_at(nir_before_cf_list(&preamble->body)); nir_builder *b = &preamble_builder; - nir_foreach_block (block, impl) { - nir_foreach_instr (instr, block) { + nir_foreach_block(block, impl) { + nir_foreach_instr(instr, block) { nir_ssa_def *def = nir_instr_ssa_def(instr); if (!def) continue; @@ -570,8 +569,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, nir_builder builder = nir_builder_create(impl); b = &builder; - nir_foreach_block (block, impl) { - nir_foreach_instr_safe (instr, block) { + nir_foreach_block(block, impl) { + nir_foreach_instr_safe(instr, block) { nir_ssa_def *def = nir_instr_ssa_def(instr); if (!def) continue; @@ -586,7 +585,6 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, nir_load_preamble(b, def->num_components, def->bit_size, .base = state->offset); - nir_ssa_def_rewrite_uses(def, new_def); nir_instr_free_and_dce(instr); } @@ -594,7 +592,7 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); ralloc_free(remap_table); free(ctx.states); diff --git a/src/compiler/nir/nir_opt_ray_queries.c b/src/compiler/nir/nir_opt_ray_queries.c index cc725ce..b1dd703 100644 --- a/src/compiler/nir/nir_opt_ray_queries.c +++ b/src/compiler/nir/nir_opt_ray_queries.c @@ -25,8 +25,8 @@ #include "nir_builder.h" #include "util/hash_table.h" -#include "util/set.h" #include "util/macros.h" +#include "util/set.h" #include "util/u_dynarray.h" /** @file nir_opt_ray_queries.c @@ -132,7 +132,7 @@ nir_opt_ray_queries(nir_shader *shader) nir_shader_instructions_pass(shader, nir_replace_unread_queries_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, read_queries); /* Update the number of queries if some have been removed. */ @@ -150,7 +150,7 @@ nir_opt_ray_queries(nir_shader *shader) /** * Merge ray queries that are not used in parallel to reduce scratch memory: - * + * * 1. Store all the ray queries we will consider into an array for * convenient access. Ignore arrays since it would be really complex * to handle and will be rare in praxis. @@ -163,16 +163,16 @@ nir_opt_ray_queries(nir_shader *shader) * * 1. rq_initialize can be inside some form of controlflow which can result * in incorrect ranges and invalid merging. - * + * * SOLUTION: Discard the entire ray query when encountering an * instruction that is not dominated by the rq_initialize * of the range. - * + * * 2. With loops, we can underestimate the range because the state may * have to be preserved for multiple iterations. - * + * * SOLUTION: Track parent loops. - * + * * 4. Try to rewrite the variables. For that, we iterate over every ray query * and try to move its ranges to the preceding ray queries. */ @@ -197,7 +197,7 @@ count_ranges(struct nir_builder *b, nir_instr *instr, void *data) nir_intrinsic_instr *intrinsic = nir_instr_as_intrinsic(instr); if (intrinsic->intrinsic == nir_intrinsic_rq_initialize) - (*(uint32_t *) data)++; + (*(uint32_t *)data)++; return false; } @@ -245,13 +245,13 @@ nir_opt_ray_query_ranges(nir_shader *shader) nir_metadata_require(func->impl, nir_metadata_instr_index | nir_metadata_dominance); - nir_variable **ray_queries = ralloc_array(mem_ctx, nir_variable*, ray_query_count); + nir_variable **ray_queries = ralloc_array(mem_ctx, nir_variable *, ray_query_count); ray_query_count = 0; nir_foreach_variable_in_shader(var, shader) { if (!var->data.ray_query || glsl_type_is_array(var->type)) continue; - + ray_queries[ray_query_count] = var; ray_query_count++; } @@ -259,7 +259,7 @@ nir_opt_ray_query_ranges(nir_shader *shader) nir_foreach_function_temp_variable(var, func->impl) { if (!var->data.ray_query || glsl_type_is_array(var->type)) continue; - + ray_queries[ray_query_count] = var; ray_query_count++; } @@ -305,12 +305,12 @@ nir_opt_ray_query_ranges(nir_shader *shader) struct hash_entry *index_entry = _mesa_hash_table_search(range_indices, ray_query_deref->var); struct rq_range *range = ranges + (uintptr_t)index_entry->data; - + if (intrinsic->intrinsic != nir_intrinsic_rq_initialize) { /* If the initialize instruction does not dominate every other * instruction in the range, we have to reject the enire query * since we can not be certain about the ranges: - * + * * rayQuery rq; * if (i == 0) * init(rq); diff --git a/src/compiler/nir/nir_opt_reassociate_bfi.c b/src/compiler/nir/nir_opt_reassociate_bfi.c index f6a9141..ed239ee 100644 --- a/src/compiler/nir/nir_opt_reassociate_bfi.c +++ b/src/compiler/nir/nir_opt_reassociate_bfi.c @@ -137,9 +137,8 @@ nir_opt_reassociate_bfi(nir_shader *shader) bool progress = nir_shader_instructions_pass(shader, nir_opt_reassociate_bfi_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); return progress; } - diff --git a/src/compiler/nir/nir_opt_rematerialize_compares.c b/src/compiler/nir/nir_opt_rematerialize_compares.c index 7bcb70a..16b3d26 100644 --- a/src/compiler/nir/nir_opt_rematerialize_compares.c +++ b/src/compiler/nir/nir_opt_rematerialize_compares.c @@ -21,8 +21,8 @@ * IN THE SOFTWARE. */ -#include "nir.h" #include "nir/nir_builder.h" +#include "nir.h" #include "nir_constant_expressions.h" #include "nir_control_flow.h" #include "nir_loop_analyze.h" @@ -155,7 +155,7 @@ nir_opt_rematerialize_compares_impl(nir_shader *shader, nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c index f96879f..84de32f 100644 --- a/src/compiler/nir/nir_opt_remove_phis.c +++ b/src/compiler/nir/nir_opt_remove_phis.c @@ -87,9 +87,9 @@ remove_phis_block(nir_block *block, nir_builder *b) */ if (src->src.ssa == &phi->dest.ssa) continue; - + if (def == NULL) { - def = src->src.ssa; + def = src->src.ssa; mov = get_parent_mov(def); } else if (nir_src_is_undef(src->src) && nir_block_dominates(def->parent_instr->block, src->pred)) { @@ -154,7 +154,7 @@ nir_opt_remove_phis_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -172,4 +172,3 @@ nir_opt_remove_phis(nir_shader *shader) return progress; } - diff --git a/src/compiler/nir/nir_opt_shrink_stores.c b/src/compiler/nir/nir_opt_shrink_stores.c index 288e583..6f1f1d3 100644 --- a/src/compiler/nir/nir_opt_shrink_stores.c +++ b/src/compiler/nir/nir_opt_shrink_stores.c @@ -115,7 +115,7 @@ nir_opt_shrink_stores(nir_shader *shader, bool shrink_image_store) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_shrink_vectors.c b/src/compiler/nir/nir_opt_shrink_vectors.c index 91acc4b..ee1790f 100644 --- a/src/compiler/nir/nir_opt_shrink_vectors.c +++ b/src/compiler/nir/nir_opt_shrink_vectors.c @@ -43,9 +43,9 @@ * elimination. */ +#include "util/u_math.h" #include "nir.h" #include "nir_builder.h" -#include "util/u_math.h" /* * Round up a vector size to a vector size that's valid in NIR. At present, NIR @@ -127,7 +127,7 @@ reswizzle_alu_uses(nir_ssa_def *def, uint8_t *reswizzle) nir_foreach_use(use_src, def) { /* all uses must be ALU instructions */ assert(use_src->parent_instr->type == nir_instr_type_alu); - nir_alu_src *alu_src = (nir_alu_src*)use_src; + nir_alu_src *alu_src = (nir_alu_src *)use_src; /* reswizzle ALU sources */ for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) @@ -207,15 +207,15 @@ opt_shrink_vectors_alu(nir_builder *b, nir_alu_instr *instr) return false; switch (instr->op) { - /* don't use nir_op_is_vec() as not all vector sizes are supported. */ - case nir_op_vec4: - case nir_op_vec3: - case nir_op_vec2: - return opt_shrink_vector(b, instr); - default: - if (nir_op_infos[instr->op].output_size != 0) - return false; - break; + /* don't use nir_op_is_vec() as not all vector sizes are supported. */ + case nir_op_vec4: + case nir_op_vec3: + case nir_op_vec2: + return opt_shrink_vector(b, instr); + default: + if (nir_op_infos[instr->op].output_size != 0) + return false; + break; } /* don't remove any channels if used by non-ALU */ @@ -413,7 +413,6 @@ opt_shrink_vectors_phi(nir_builder *b, nir_phi_instr *instr) if (def->num_components > 4) return false; - /* Check the uses. */ nir_component_mask_t mask = 0; nir_foreach_use(src, def) { @@ -545,7 +544,7 @@ nir_opt_shrink_vectors(nir_shader *shader) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_opt_sink.c b/src/compiler/nir/nir_opt_sink.c index 36446c7..7fd50a8 100644 --- a/src/compiler/nir/nir_opt_sink.c +++ b/src/compiler/nir/nir_opt_sink.c @@ -30,7 +30,6 @@ #include "nir.h" - /* * A simple pass that moves some instructions into the least common * anscestor of consuming instructions. @@ -80,7 +79,7 @@ get_innermost_loop(nir_cf_node *node) { for (; node != NULL; node = node->parent) { if (node->type == nir_cf_node_loop) - return (nir_loop*)node; + return (nir_loop *)node; } return NULL; } @@ -121,8 +120,8 @@ adjust_block_for_loops(nir_block *use_block, nir_block *def_block, if (next && next->type == nir_cf_node_loop) { nir_loop *following_loop = nir_cf_node_as_loop(next); if (loop_contains_block(following_loop, use_block)) { - use_block = cur_block; - continue; + use_block = cur_block; + continue; } } } @@ -218,7 +217,7 @@ nir_opt_sink(nir_shader *shader, nir_move_options options) instr->type != nir_instr_type_intrinsic || can_sink_out_of_loop(nir_instr_as_intrinsic(instr)); nir_block *use_block = - get_preferred_block(def, sink_out_of_loops); + get_preferred_block(def, sink_out_of_loops); if (!use_block || use_block == instr->block) continue; diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_undef.c index 6ce9b4b..1aec350 100644 --- a/src/compiler/nir/nir_opt_undef.c +++ b/src/compiler/nir/nir_opt_undef.c @@ -133,7 +133,7 @@ opt_undef_store(nir_intrinsic_instr *intrin) case nir_intrinsic_store_shared: case nir_intrinsic_store_global: case nir_intrinsic_store_scratch: - arg_index = 0; + arg_index = 0; break; default: return false; @@ -197,6 +197,6 @@ nir_opt_undef(nir_shader *shader) return nir_shader_instructions_pass(shader, nir_opt_undef_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_opt_uniform_atomics.c b/src/compiler/nir/nir_opt_uniform_atomics.c index 4ec9143..9ad2e6f 100644 --- a/src/compiler/nir/nir_opt_uniform_atomics.c +++ b/src/compiler/nir/nir_opt_uniform_atomics.c @@ -43,17 +43,28 @@ static nir_op atomic_op_to_alu(nir_atomic_op op) { switch (op) { - case nir_atomic_op_iadd: return nir_op_iadd; - case nir_atomic_op_imin: return nir_op_imin; - case nir_atomic_op_umin: return nir_op_umin; - case nir_atomic_op_imax: return nir_op_imax; - case nir_atomic_op_umax: return nir_op_umax; - case nir_atomic_op_iand: return nir_op_iand; - case nir_atomic_op_ior: return nir_op_ior; - case nir_atomic_op_ixor: return nir_op_ixor; - case nir_atomic_op_fadd: return nir_op_fadd; - case nir_atomic_op_fmin: return nir_op_fmin; - case nir_atomic_op_fmax: return nir_op_fmax; + case nir_atomic_op_iadd: + return nir_op_iadd; + case nir_atomic_op_imin: + return nir_op_imin; + case nir_atomic_op_umin: + return nir_op_umin; + case nir_atomic_op_imax: + return nir_op_imax; + case nir_atomic_op_umax: + return nir_op_umax; + case nir_atomic_op_iand: + return nir_op_iand; + case nir_atomic_op_ior: + return nir_op_ior; + case nir_atomic_op_ixor: + return nir_op_ixor; + case nir_atomic_op_fadd: + return nir_op_fadd; + case nir_atomic_op_fmin: + return nir_op_fmin; + case nir_atomic_op_fmax: + return nir_op_fmax; /* We don't handle exchanges or wraps */ case nir_atomic_op_xchg: @@ -184,7 +195,7 @@ is_atomic_already_optimized(nir_shader *shader, nir_intrinsic_instr *instr) if (!within_then) continue; - nir_ssa_scalar cond = {nir_cf_node_as_if(cf)->condition.ssa, 0}; + nir_ssa_scalar cond = { nir_cf_node_as_if(cf)->condition.ssa, 0 }; dims |= match_invocation_comparison(cond); } } @@ -193,7 +204,8 @@ is_atomic_already_optimized(nir_shader *shader, nir_intrinsic_instr *instr) unsigned dims_needed = 0; for (unsigned i = 0; i < 3; i++) dims_needed |= (shader->info.workgroup_size_variable || - shader->info.workgroup_size[i] > 1) << i; + shader->info.workgroup_size[i] > 1) + << i; if ((dims & dims_needed) == dims_needed) return true; } @@ -207,14 +219,14 @@ reduce_data(nir_builder *b, nir_op op, nir_ssa_def *data, nir_ssa_def **reduce, nir_ssa_def **scan) { if (scan) { - *scan = nir_exclusive_scan(b, data, .reduction_op=op); + *scan = nir_exclusive_scan(b, data, .reduction_op = op); if (reduce) { nir_ssa_def *last_lane = nir_last_invocation(b); nir_ssa_def *res = nir_build_alu(b, op, *scan, data, NULL, NULL); *reduce = nir_read_invocation(b, res, last_lane); } } else { - *reduce = nir_reduce(b, data, .reduction_op=op); + *reduce = nir_reduce(b, data, .reduction_op = op); } } diff --git a/src/compiler/nir/nir_opt_vectorize.c b/src/compiler/nir/nir_opt_vectorize.c index 1947646..da6d28f 100644 --- a/src/compiler/nir/nir_opt_vectorize.c +++ b/src/compiler/nir/nir_opt_vectorize.c @@ -32,10 +32,10 @@ * The max vectorization width must be a power of 2. */ +#include "util/u_dynarray.h" #include "nir.h" -#include "nir_vla.h" #include "nir_builder.h" -#include "util/u_dynarray.h" +#include "nir_vla.h" #define HASH(hash, data) XXH32(&data, sizeof(data), hash) @@ -65,7 +65,7 @@ hash_alu_src(uint32_t hash, const nir_alu_src *src, static uint32_t hash_instr(const void *data) { - const nir_instr *instr = (nir_instr *) data; + const nir_instr *instr = (nir_instr *)data; assert(instr->type == nir_instr_type_alu); nir_alu_instr *alu = nir_instr_as_alu(instr); @@ -102,8 +102,8 @@ alu_srcs_equal(const nir_alu_src *src1, const nir_alu_src *src2, static bool instrs_equal(const void *data1, const void *data2) { - const nir_instr *instr1 = (nir_instr *) data1; - const nir_instr *instr2 = (nir_instr *) data2; + const nir_instr *instr1 = (nir_instr *)data1; + const nir_instr *instr2 = (nir_instr *)data2; assert(instr1->type == nir_instr_type_alu); assert(instr2->type == nir_instr_type_alu); @@ -219,9 +219,7 @@ instr_try_combine(struct set *instr_set, nir_instr *instr1, nir_instr *instr2) unsigned bit_size = alu1->src[i].src.ssa->bit_size; for (unsigned j = 0; j < total_components; j++) { - value[j].u64 = j < alu1_components ? - c1[alu1->src[i].swizzle[j]].u64 : - c2[alu2->src[i].swizzle[j - alu1_components]].u64; + value[j].u64 = j < alu1_components ? c1[alu1->src[i].swizzle[j]].u64 : c2[alu2->src[i].swizzle[j - alu1_components]].u64; } nir_ssa_def *def = nir_build_imm(&b, total_components, bit_size, value); @@ -331,7 +329,7 @@ vec_instr_set_add_or_rewrite(struct set *instr_set, nir_instr *instr, struct set_entry *entry = _mesa_set_search(instr_set, instr); if (entry) { - nir_instr *old_instr = (nir_instr *) entry->key; + nir_instr *old_instr = (nir_instr *)entry->key; _mesa_set_remove(instr_set, entry); nir_instr *new_instr = instr_try_combine(instr_set, old_instr, instr); if (new_instr) { @@ -382,7 +380,7 @@ nir_opt_vectorize_impl(nir_function_impl *impl, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_passthrough_gs.c b/src/compiler/nir/nir_passthrough_gs.c index 5d22437..ff56842 100644 --- a/src/compiler/nir/nir_passthrough_gs.c +++ b/src/compiler/nir/nir_passthrough_gs.c @@ -21,10 +21,10 @@ * SOFTWARE. */ +#include "util/u_memory.h" #include "nir.h" -#include "nir_xfb_info.h" #include "nir_builder.h" -#include "util/u_memory.h" +#include "nir_xfb_info.h" static unsigned int gs_in_prim_for_topology(enum mesa_prim prim) @@ -133,8 +133,7 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options, nir_shader *nir = b.shader; nir->info.gs.input_primitive = gs_in_prim_for_topology(primitive_type); - nir->info.gs.output_primitive = (force_line_strip_out || emulate_edgeflags) ? - MESA_PRIM_LINE_STRIP : original_our_prim; + nir->info.gs.output_primitive = (force_line_strip_out || emulate_edgeflags) ? MESA_PRIM_LINE_STRIP : original_our_prim; nir->info.gs.vertices_in = vertices_out; nir->info.gs.vertices_out = needs_closing ? vertices_out + 1 : vertices_out; nir->info.gs.invocations = 1; diff --git a/src/compiler/nir/nir_passthrough_tcs.c b/src/compiler/nir/nir_passthrough_tcs.c index 2abaf6e..ec59418 100644 --- a/src/compiler/nir/nir_passthrough_tcs.c +++ b/src/compiler/nir/nir_passthrough_tcs.c @@ -54,7 +54,7 @@ nir_create_passthrough_tcs_impl(const nir_shader_compiler_options *options, nir_store_var(&b, out_inner, inner, 0x3); nir_variable *in_outer = - nir_create_variable_with_location(b.shader, nir_var_system_value, + nir_create_variable_with_location(b.shader, nir_var_system_value, SYSTEM_VALUE_TESS_LEVEL_OUTER_DEFAULT, glsl_vec4_type()); nir_variable *out_outer = @@ -75,7 +75,7 @@ nir_create_passthrough_tcs_impl(const nir_shader_compiler_options *options, continue; nir_variable *in = nir_create_variable_with_location(b.shader, nir_var_shader_in, - semantic, type); + semantic, type); nir_variable *out = nir_create_variable_with_location(b.shader, nir_var_shader_out, semantic, type); @@ -92,7 +92,6 @@ nir_create_passthrough_tcs_impl(const nir_shader_compiler_options *options, return b.shader; } - nir_shader * nir_create_passthrough_tcs(const nir_shader_compiler_options *options, const nir_shader *vs, uint8_t patch_vertices) @@ -100,7 +99,7 @@ nir_create_passthrough_tcs(const nir_shader_compiler_options *options, unsigned locations[MAX_VARYING]; unsigned num_outputs = 0; - nir_foreach_shader_out_variable (var, vs) { + nir_foreach_shader_out_variable(var, vs) { assert(num_outputs < ARRAY_SIZE(locations)); locations[num_outputs++] = var->data.location; } diff --git a/src/compiler/nir/nir_phi_builder.c b/src/compiler/nir/nir_phi_builder.c index 3f13e6b..af05635 100644 --- a/src/compiler/nir/nir_phi_builder.c +++ b/src/compiler/nir/nir_phi_builder.c @@ -85,7 +85,7 @@ struct nir_phi_builder_value { * _mesa_hash_pointer drops the two least significant bits, but that's where * most of our data likely is. Shift by 2 and add 1 to make everything happy. */ -#define INDEX_TO_KEY(x) ((void *)(uintptr_t) ((x << 2) + 1)) +#define INDEX_TO_KEY(x) ((void *)(uintptr_t)((x << 2) + 1)) struct nir_phi_builder * nir_phi_builder_create(nir_function_impl *impl) @@ -141,7 +141,7 @@ nir_phi_builder_add_value(struct nir_phi_builder *pb, unsigned num_components, while (w_start != w_end) { nir_block *cur = pb->W[w_start++]; set_foreach(cur->dom_frontier, dom_entry) { - nir_block *next = (nir_block *) dom_entry->key; + nir_block *next = (nir_block *)dom_entry->key; /* If there's more than one return statement, then the end block * can be a join point for some definitions. However, there are @@ -243,7 +243,7 @@ nir_phi_builder_value_get_block_def(struct nir_phi_builder_value *val, * phi node created by the case above or one passed to us through * nir_phi_builder_value_set_block_def(). */ - def = (struct nir_ssa_def *) he->data; + def = (struct nir_ssa_def *)he->data; } /* Walk the chain and stash the def in all of the applicable blocks. We do diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 1fb5e49..ae6f5f3 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -25,16 +25,16 @@ * */ -#include "nir.h" +#include /* for PRIx64 macro */ +#include +#include +#include #include "compiler/shader_enums.h" #include "util/half_float.h" #include "util/memstream.h" #include "util/mesa-sha1.h" #include "vulkan/vulkan_core.h" -#include -#include -#include -#include /* for PRIx64 macro */ +#include "nir.h" static void print_indentation(unsigned levels, FILE *fp) @@ -99,7 +99,7 @@ print_annotation(print_state *state, void *obj) static const char *sizes[] = { "x??", " ", "x2 ", "x3 ", "x4 ", "x5 ", "x??", "x??", "x8 ", "x??", "x??", "x??", "x??", - "x??", "x??", "x??", "x16"}; + "x??", "x??", "x??", "x16" }; static const char * divergence_status(print_state *state, bool divergent) @@ -121,8 +121,7 @@ print_ssa_def(nir_ssa_def *def, print_state *state) { FILE *fp = state->fp; - const unsigned ssa_padding = state->max_dest_index ? - count_digits(state->max_dest_index) - count_digits(def->index) : 0; + const unsigned ssa_padding = state->max_dest_index ? count_digits(state->max_dest_index) - count_digits(def->index) : 0; const unsigned padding = (def->bit_size == 1) + 1 + ssa_padding; @@ -156,10 +155,18 @@ static void print_hex_padded_const_value(const nir_const_value *value, unsigned bit_size, FILE *fp) { switch (bit_size) { - case 64: fprintf(fp, "0x%016" PRIx64, value->u64); break; - case 32: fprintf(fp, "0x%08x", value->u32); break; - case 16: fprintf(fp, "0x%04x", value->u16); break; - case 8: fprintf(fp, "0x%02x", value->u8); break; + case 64: + fprintf(fp, "0x%016" PRIx64, value->u64); + break; + case 32: + fprintf(fp, "0x%08x", value->u32); + break; + case 16: + fprintf(fp, "0x%04x", value->u16); + break; + case 8: + fprintf(fp, "0x%02x", value->u8); + break; default: unreachable("unhandled bit size"); } @@ -169,10 +176,18 @@ static void print_hex_terse_const_value(const nir_const_value *value, unsigned bit_size, FILE *fp) { switch (bit_size) { - case 64: fprintf(fp, "0x%" PRIx64, value->u64); break; - case 32: fprintf(fp, "0x%x", value->u32); break; - case 16: fprintf(fp, "0x%x", value->u16); break; - case 8: fprintf(fp, "0x%x", value->u8); break; + case 64: + fprintf(fp, "0x%" PRIx64, value->u64); + break; + case 32: + fprintf(fp, "0x%x", value->u32); + break; + case 16: + fprintf(fp, "0x%x", value->u16); + break; + case 8: + fprintf(fp, "0x%x", value->u8); + break; default: unreachable("unhandled bit size"); } @@ -182,9 +197,15 @@ static void print_float_const_value(const nir_const_value *value, unsigned bit_size, FILE *fp) { switch (bit_size) { - case 64: fprintf(fp, "%f", value->f64); break; - case 32: fprintf(fp, "%f", value->f32); break; - case 16: fprintf(fp, "%f", _mesa_half_to_float(value->u16)); break; + case 64: + fprintf(fp, "%f", value->f64); + break; + case 32: + fprintf(fp, "%f", value->f32); + break; + case 16: + fprintf(fp, "%f", _mesa_half_to_float(value->u16)); + break; default: unreachable("unhandled bit size"); } @@ -194,10 +215,18 @@ static void print_int_const_value(const nir_const_value *value, unsigned bit_size, FILE *fp) { switch (bit_size) { - case 64: fprintf(fp, "%+" PRIi64, value->i64); break; - case 32: fprintf(fp, "%+d", value->i32); break; - case 16: fprintf(fp, "%+d", value->i16); break; - case 8: fprintf(fp, "%+d", value->i8); break; + case 64: + fprintf(fp, "%+" PRIi64, value->i64); + break; + case 32: + fprintf(fp, "%+d", value->i32); + break; + case 16: + fprintf(fp, "%+d", value->i16); + break; + case 8: + fprintf(fp, "%+d", value->i8); + break; default: unreachable("unhandled bit size"); } @@ -207,10 +236,18 @@ static void print_uint_const_value(const nir_const_value *value, unsigned bit_size, FILE *fp) { switch (bit_size) { - case 64: fprintf(fp, "%" PRIu64, value->u64); break; - case 32: fprintf(fp, "%u", value->u32); break; - case 16: fprintf(fp, "%u", value->u16); break; - case 8: fprintf(fp, "%u", value->u8); break; + case 64: + fprintf(fp, "%" PRIu64, value->u64); + break; + case 32: + fprintf(fp, "%u", value->u32); + break; + case 16: + fprintf(fp, "%u", value->u16); + break; + case 8: + fprintf(fp, "%u", value->u8); + break; default: unreachable("unhandled bit size"); } @@ -259,20 +296,20 @@ print_const_from_load(nir_load_const_instr *instr, print_state *state, nir_alu_t } } } else { - #define PRINT_VALUES(F) \ - do { \ - for (unsigned i = 0; i < num_components; i++) { \ - if (i != 0) \ - fprintf(fp, ", "); \ - F(&instr->value[i], bit_size, fp); \ - } \ - } while (0) - - #define SEPARATOR() \ - if (num_components > 1) \ - fprintf(fp, ") = ("); \ - else \ - fprintf(fp, " = ") +#define PRINT_VALUES(F) \ + do { \ + for (unsigned i = 0; i < num_components; i++) { \ + if (i != 0) \ + fprintf(fp, ", "); \ + F(&instr->value[i], bit_size, fp); \ + } \ + } while (0) + +#define SEPARATOR() \ + if (num_components > 1) \ + fprintf(fp, ") = ("); \ + else \ + fprintf(fp, " = ") bool needs_float = bit_size > 8; bool needs_signed = false; @@ -281,19 +318,19 @@ print_const_from_load(nir_load_const_instr *instr, print_state *state, nir_alu_t const nir_const_value *v = &instr->value[i]; switch (bit_size) { case 64: - needs_signed |= v->i64 < 0; + needs_signed |= v->i64 < 0; needs_decimal |= v->u64 >= 10; break; case 32: - needs_signed |= v->i32 < 0; + needs_signed |= v->i32 < 0; needs_decimal |= v->u32 >= 10; break; case 16: - needs_signed |= v->i16 < 0; + needs_signed |= v->i16 < 0; needs_decimal |= v->u16 >= 10; break; case 8: - needs_signed |= v->i8 < 0; + needs_signed |= v->i8 < 0; needs_decimal |= v->u8 >= 10; break; default: @@ -497,12 +534,18 @@ static const char * get_constant_sampler_addressing_mode(enum cl_sampler_addressing_mode mode) { switch (mode) { - case SAMPLER_ADDRESSING_MODE_NONE: return "none"; - case SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: return "clamp_to_edge"; - case SAMPLER_ADDRESSING_MODE_CLAMP: return "clamp"; - case SAMPLER_ADDRESSING_MODE_REPEAT: return "repeat"; - case SAMPLER_ADDRESSING_MODE_REPEAT_MIRRORED: return "repeat_mirrored"; - default: unreachable("Invalid addressing mode"); + case SAMPLER_ADDRESSING_MODE_NONE: + return "none"; + case SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: + return "clamp_to_edge"; + case SAMPLER_ADDRESSING_MODE_CLAMP: + return "clamp"; + case SAMPLER_ADDRESSING_MODE_REPEAT: + return "repeat"; + case SAMPLER_ADDRESSING_MODE_REPEAT_MIRRORED: + return "repeat_mirrored"; + default: + unreachable("Invalid addressing mode"); } } @@ -510,9 +553,12 @@ static const char * get_constant_sampler_filter_mode(enum cl_sampler_filter_mode mode) { switch (mode) { - case SAMPLER_FILTER_MODE_NEAREST: return "nearest"; - case SAMPLER_FILTER_MODE_LINEAR: return "linear"; - default: unreachable("Invalid filter mode"); + case SAMPLER_FILTER_MODE_NEAREST: + return "nearest"; + case SAMPLER_FILTER_MODE_LINEAR: + return "linear"; + default: + unreachable("Invalid filter mode"); } } @@ -530,7 +576,8 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state assert(cols == 1); for (i = 0; i < rows; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "%s", c->values[i].b ? "true" : "false"); } break; @@ -541,7 +588,8 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state assert(cols == 1); for (i = 0; i < rows; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "0x%02x", c->values[i].u8); } break; @@ -552,7 +600,8 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state assert(cols == 1); for (i = 0; i < rows; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "0x%04x", c->values[i].u16); } break; @@ -563,7 +612,8 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state assert(cols == 1); for (i = 0; i < rows; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "0x%08x", c->values[i].u32); } break; @@ -573,28 +623,32 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state case GLSL_TYPE_DOUBLE: if (cols > 1) { for (i = 0; i < cols; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); print_constant(c->elements[i], glsl_get_column_type(type), state); } } else { switch (glsl_get_base_type(type)) { case GLSL_TYPE_FLOAT16: for (i = 0; i < rows; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "%f", _mesa_half_to_float(c->values[i].u16)); } break; case GLSL_TYPE_FLOAT: for (i = 0; i < rows; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "%f", c->values[i].f32); } break; case GLSL_TYPE_DOUBLE: for (i = 0; i < rows; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "%f", c->values[i].f64); } break; @@ -611,7 +665,8 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state assert(cols == 1); for (i = 0; i < cols; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "0x%08" PRIx64, c->values[i].u64); } break; @@ -619,7 +674,8 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state case GLSL_TYPE_STRUCT: case GLSL_TYPE_INTERFACE: for (i = 0; i < c->num_elements; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "{ "); print_constant(c->elements[i], glsl_get_struct_field(type, i), state); fprintf(fp, " }"); @@ -628,7 +684,8 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state case GLSL_TYPE_ARRAY: for (i = 0; i < c->num_elements; i++) { - if (i > 0) fprintf(fp, ", "); + if (i > 0) + fprintf(fp, ", "); fprintf(fp, "{ "); print_constant(c->elements[i], glsl_get_array_element(type), state); fprintf(fp, " }"); @@ -756,10 +813,8 @@ print_var_decl(nir_variable *var, print_state *state) const char *const ronly = (access & ACCESS_NON_WRITEABLE) ? "readonly " : ""; const char *const wonly = (access & ACCESS_NON_READABLE) ? "writeonly " : ""; const char *const reorder = (access & ACCESS_CAN_REORDER) ? "reorderable " : ""; - const char *const non_temporal = (access & ACCESS_NON_TEMPORAL) ? - "non-temporal" : ""; - const char *const include_helpers = (access & ACCESS_INCLUDE_HELPERS) ? - "include-helpers " : ""; + const char *const non_temporal = (access & ACCESS_NON_TEMPORAL) ? "non-temporal" : ""; + const char *const include_helpers = (access & ACCESS_INCLUDE_HELPERS) ? "include-helpers " : ""; fprintf(fp, "%s%s%s%s%s%s%s%s", coher, volat, restr, ronly, wonly, reorder, non_temporal, include_helpers); @@ -797,7 +852,7 @@ print_var_decl(nir_variable *var, print_state *state) unsigned int num_components = glsl_get_components(glsl_without_array(var->type)); const char *components = NULL; - char components_local[18] = {'.' /* the rest is 0-filled */}; + char components_local[18] = { '.' /* the rest is 0-filled */ }; switch (var->data.mode) { case nir_var_shader_in: case nir_var_shader_out: @@ -900,7 +955,7 @@ print_deref_link(const nir_deref_instr *instr, bool whole_chain, print_state *st case nir_deref_type_array: case nir_deref_type_ptr_as_array: { if (nir_src_is_const(instr->arr.index)) { - fprintf(fp, "[%"PRId64"]", nir_src_as_int(instr->arr.index)); + fprintf(fp, "[%" PRId64 "]", nir_src_as_int(instr->arr.index)); } else { fprintf(fp, "["); print_src(&instr->arr.index, state, nir_type_invalid); @@ -957,7 +1012,7 @@ print_deref_instr(nir_deref_instr *instr, print_state *state) while (modes) { int m = u_bit_scan(&modes); fprintf(fp, "%s%s", get_variable_mode_str(1 << m, true), - modes ? "|" : ""); + modes ? "|" : ""); } fprintf(fp, " %s)", glsl_get_type_name(instr->type)); @@ -979,20 +1034,34 @@ static const char * vulkan_descriptor_type_name(VkDescriptorType type) { switch (type) { - case VK_DESCRIPTOR_TYPE_SAMPLER: return "sampler"; - case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: return "texture+sampler"; - case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: return "texture"; - case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: return "image"; - case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: return "texture-buffer"; - case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: return "image-buffer"; - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: return "UBO"; - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: return "SSBO"; - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: return "UBO"; - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: return "SSBO"; - case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: return "input-att"; - case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK: return "inline-UBO"; - case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR: return "accel-struct"; - default: return "unknown"; + case VK_DESCRIPTOR_TYPE_SAMPLER: + return "sampler"; + case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: + return "texture+sampler"; + case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: + return "texture"; + case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: + return "image"; + case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: + return "texture-buffer"; + case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: + return "image-buffer"; + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + return "UBO"; + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: + return "SSBO"; + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: + return "UBO"; + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: + return "SSBO"; + case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: + return "input-att"; + case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK: + return "inline-UBO"; + case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR: + return "accel-struct"; + default: + return "unknown"; } } @@ -1004,11 +1073,20 @@ print_alu_type(nir_alu_type type, print_state *state) const char *name; switch (nir_alu_type_get_base_type(type)) { - case nir_type_int: name = "int"; break; - case nir_type_uint: name = "uint"; break; - case nir_type_bool: name = "bool"; break; - case nir_type_float: name = "float"; break; - default: name = "invalid"; + case nir_type_int: + name = "int"; + break; + case nir_type_uint: + name = "uint"; + break; + case nir_type_bool: + name = "bool"; + break; + case nir_type_float: + name = "float"; + break; + default: + name = "invalid"; } if (size) fprintf(fp, "%s%u", name, size); @@ -1067,22 +1145,54 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) fprintf(fp, "atomic_op="); switch (atomic_op) { - case nir_atomic_op_iadd: fprintf(fp, "iadd"); break; - case nir_atomic_op_imin: fprintf(fp, "imin"); break; - case nir_atomic_op_umin: fprintf(fp, "umin"); break; - case nir_atomic_op_imax: fprintf(fp, "imax"); break; - case nir_atomic_op_umax: fprintf(fp, "umax"); break; - case nir_atomic_op_iand: fprintf(fp, "iand"); break; - case nir_atomic_op_ior: fprintf(fp, "ior"); break; - case nir_atomic_op_ixor: fprintf(fp, "ixor"); break; - case nir_atomic_op_xchg: fprintf(fp, "xchg"); break; - case nir_atomic_op_fadd: fprintf(fp, "fadd"); break; - case nir_atomic_op_fmin: fprintf(fp, "fmin"); break; - case nir_atomic_op_fmax: fprintf(fp, "fmax"); break; - case nir_atomic_op_cmpxchg: fprintf(fp, "cmpxchg"); break; - case nir_atomic_op_fcmpxchg: fprintf(fp, "fcmpxchg"); break; - case nir_atomic_op_inc_wrap: fprintf(fp, "inc_wrap"); break; - case nir_atomic_op_dec_wrap: fprintf(fp, "dec_wrap"); break; + case nir_atomic_op_iadd: + fprintf(fp, "iadd"); + break; + case nir_atomic_op_imin: + fprintf(fp, "imin"); + break; + case nir_atomic_op_umin: + fprintf(fp, "umin"); + break; + case nir_atomic_op_imax: + fprintf(fp, "imax"); + break; + case nir_atomic_op_umax: + fprintf(fp, "umax"); + break; + case nir_atomic_op_iand: + fprintf(fp, "iand"); + break; + case nir_atomic_op_ior: + fprintf(fp, "ior"); + break; + case nir_atomic_op_ixor: + fprintf(fp, "ixor"); + break; + case nir_atomic_op_xchg: + fprintf(fp, "xchg"); + break; + case nir_atomic_op_fadd: + fprintf(fp, "fadd"); + break; + case nir_atomic_op_fmin: + fprintf(fp, "fmin"); + break; + case nir_atomic_op_fmax: + fprintf(fp, "fmax"); + break; + case nir_atomic_op_cmpxchg: + fprintf(fp, "cmpxchg"); + break; + case nir_atomic_op_fcmpxchg: + fprintf(fp, "fcmpxchg"); + break; + case nir_atomic_op_inc_wrap: + fprintf(fp, "inc_wrap"); + break; + case nir_atomic_op_dec_wrap: + fprintf(fp, "dec_wrap"); + break; } break; } @@ -1143,8 +1253,8 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) fprintf(fp, "%d", (mask >> (i * 2) & 3)); } else if (instr->intrinsic == nir_intrinsic_masked_swizzle_amd) { fprintf(fp, "((id & %d) | %d) ^ %d", mask & 0x1F, - (mask >> 5) & 0x1F, - (mask >> 10) & 0x1F); + (mask >> 5) & 0x1F, + (mask >> 10) & 0x1F); } else { fprintf(fp, "%d", mask); } @@ -1155,13 +1265,23 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) nir_memory_semantics semantics = nir_intrinsic_memory_semantics(instr); fprintf(fp, "mem_semantics="); switch (semantics & (NIR_MEMORY_ACQUIRE | NIR_MEMORY_RELEASE)) { - case 0: fprintf(fp, "NONE"); break; - case NIR_MEMORY_ACQUIRE: fprintf(fp, "ACQ"); break; - case NIR_MEMORY_RELEASE: fprintf(fp, "REL"); break; - default: fprintf(fp, "ACQ|REL"); break; + case 0: + fprintf(fp, "NONE"); + break; + case NIR_MEMORY_ACQUIRE: + fprintf(fp, "ACQ"); + break; + case NIR_MEMORY_RELEASE: + fprintf(fp, "REL"); + break; + default: + fprintf(fp, "ACQ|REL"); + break; } - if (semantics & (NIR_MEMORY_MAKE_AVAILABLE)) fprintf(fp, "|AVAILABLE"); - if (semantics & (NIR_MEMORY_MAKE_VISIBLE)) fprintf(fp, "|VISIBLE"); + if (semantics & (NIR_MEMORY_MAKE_AVAILABLE)) + fprintf(fp, "|AVAILABLE"); + if (semantics & (NIR_MEMORY_MAKE_VISIBLE)) + fprintf(fp, "|VISIBLE"); break; } @@ -1245,10 +1365,10 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) fprintf(fp, " no_sysval_output"); if (state->shader && - state->shader->info.stage == MESA_SHADER_GEOMETRY && - (instr->intrinsic == nir_intrinsic_store_output || - instr->intrinsic == nir_intrinsic_store_per_primitive_output || - instr->intrinsic == nir_intrinsic_store_per_vertex_output)) { + state->shader->info.stage == MESA_SHADER_GEOMETRY && + (instr->intrinsic == nir_intrinsic_store_output || + instr->intrinsic == nir_intrinsic_store_per_primitive_output || + instr->intrinsic == nir_intrinsic_store_per_vertex_output)) { unsigned gs_streams = io.gs_streams; fprintf(fp, " gs_streams("); for (unsigned i = 0; i < 4; i++) { @@ -1268,8 +1388,7 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) bool first = true; for (unsigned i = 0; i < 2; i++) { unsigned start_comp = (idx == NIR_INTRINSIC_IO_XFB ? 0 : 2) + i; - nir_io_xfb xfb = start_comp < 2 ? nir_intrinsic_io_xfb(instr) : - nir_intrinsic_io_xfb2(instr); + nir_io_xfb xfb = start_comp < 2 ? nir_intrinsic_io_xfb(instr) : nir_intrinsic_io_xfb2(instr); if (!xfb.out[i].num_components) continue; @@ -1294,12 +1413,24 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) case NIR_INTRINSIC_ROUNDING_MODE: { fprintf(fp, "rounding_mode="); switch (nir_intrinsic_rounding_mode(instr)) { - case nir_rounding_mode_undef: fprintf(fp, "undef"); break; - case nir_rounding_mode_rtne: fprintf(fp, "rtne"); break; - case nir_rounding_mode_ru: fprintf(fp, "ru"); break; - case nir_rounding_mode_rd: fprintf(fp, "rd"); break; - case nir_rounding_mode_rtz: fprintf(fp, "rtz"); break; - default: fprintf(fp, "unknown"); break; + case nir_rounding_mode_undef: + fprintf(fp, "undef"); + break; + case nir_rounding_mode_rtne: + fprintf(fp, "rtne"); + break; + case nir_rounding_mode_ru: + fprintf(fp, "ru"); + break; + case nir_rounding_mode_rd: + fprintf(fp, "rd"); + break; + case nir_rounding_mode_rtz: + fprintf(fp, "rtz"); + break; + default: + fprintf(fp, "unknown"); + break; } break; } @@ -1307,27 +1438,32 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) case NIR_INTRINSIC_RAY_QUERY_VALUE: { fprintf(fp, "ray_query_value="); switch (nir_intrinsic_ray_query_value(instr)) { -#define VAL(_name) case nir_ray_query_value_##_name: fprintf(fp, #_name); break - VAL(intersection_type); - VAL(intersection_t); - VAL(intersection_instance_custom_index); - VAL(intersection_instance_id); - VAL(intersection_instance_sbt_index); - VAL(intersection_geometry_index); - VAL(intersection_primitive_index); - VAL(intersection_barycentrics); - VAL(intersection_front_face); - VAL(intersection_object_ray_direction); - VAL(intersection_object_ray_origin); - VAL(intersection_object_to_world); - VAL(intersection_world_to_object); - VAL(intersection_candidate_aabb_opaque); - VAL(tmin); - VAL(flags); - VAL(world_ray_direction); - VAL(world_ray_origin); +#define VAL(_name) \ + case nir_ray_query_value_##_name: \ + fprintf(fp, #_name); \ + break + VAL(intersection_type); + VAL(intersection_t); + VAL(intersection_instance_custom_index); + VAL(intersection_instance_id); + VAL(intersection_instance_sbt_index); + VAL(intersection_geometry_index); + VAL(intersection_primitive_index); + VAL(intersection_barycentrics); + VAL(intersection_front_face); + VAL(intersection_object_ray_direction); + VAL(intersection_object_ray_origin); + VAL(intersection_object_to_world); + VAL(intersection_world_to_object); + VAL(intersection_candidate_aabb_opaque); + VAL(tmin); + VAL(flags); + VAL(world_ray_direction); + VAL(world_ray_origin); #undef VAL - default: fprintf(fp, "unknown"); break; + default: + fprintf(fp, "unknown"); + break; } break; } @@ -1340,12 +1476,21 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) while (modes) { nir_resource_data_intel i = 1u << u_bit_scan(&modes); switch (i) { - case nir_resource_intel_bindless: fprintf(fp, "bindless"); break; - case nir_resource_intel_pushable: fprintf(fp, "pushable"); break; - case nir_resource_intel_sampler: fprintf(fp, "sampler"); break; + case nir_resource_intel_bindless: + fprintf(fp, "bindless"); + break; + case nir_resource_intel_pushable: + fprintf(fp, "pushable"); + break; + case nir_resource_intel_sampler: + fprintf(fp, "sampler"); + break; case nir_resource_intel_non_uniform: - fprintf(fp, "non-uniform"); break; - default: fprintf(fp, "unknown"); break; + fprintf(fp, "non-uniform"); + break; + default: + fprintf(fp, "unknown"); + break; } fprintf(fp, "%s", modes ? "|" : ""); } @@ -1386,10 +1531,10 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) nir_foreach_variable_with_modes(var, state->shader, var_mode) { if ((var->data.driver_location == nir_intrinsic_base(instr)) && (instr->intrinsic == nir_intrinsic_load_uniform || - (nir_intrinsic_component(instr) >= var->data.location_frac && + (nir_intrinsic_component(instr) >= var->data.location_frac && nir_intrinsic_component(instr) < - (var->data.location_frac + glsl_get_components(var->type)))) && - var->name) { + (var->data.location_frac + glsl_get_components(var->type)))) && + var->name) { fprintf(fp, " // %s", var->name); break; } @@ -1482,7 +1627,7 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) print_src(&instr->src[i].src, state, nir_tex_instr_src_type(instr, i)); fprintf(fp, " "); - switch(instr->src[i].src_type) { + switch (instr->src[i].src_type) { case nir_tex_src_backend1: fprintf(fp, "(backend1)"); break; @@ -1645,7 +1790,7 @@ print_jump_instr(nir_jump_instr *instr, print_state *state) } static void -print_ssa_undef_instr(nir_ssa_undef_instr* instr, print_state *state) +print_ssa_undef_instr(nir_ssa_undef_instr *instr, print_state *state) { FILE *fp = state->fp; print_ssa_def(&instr->def, state); @@ -1830,8 +1975,7 @@ print_block(nir_block *block, print_state *state, unsigned tabs) } const unsigned block_length = 7 + count_digits(block->index) + 1; - const unsigned pred_padding = block_length < state->padding_for_no_dest ? - state->padding_for_no_dest - block_length : 0; + const unsigned pred_padding = block_length < state->padding_for_no_dest ? state->padding_for_no_dest - block_length : 0; fprintf(fp, "%*s// preds: ", pred_padding, ""); print_block_preds(block, state); @@ -2014,18 +2158,20 @@ destroy_print_state(print_state *state) static const char * primitive_name(unsigned primitive) { -#define PRIM(X) case MESA_PRIM_ ## X : return #X +#define PRIM(X) \ + case MESA_PRIM_##X: \ + return #X switch (primitive) { - PRIM(POINTS); - PRIM(LINES); - PRIM(LINE_LOOP); - PRIM(LINE_STRIP); - PRIM(TRIANGLES); - PRIM(TRIANGLE_STRIP); - PRIM(TRIANGLE_FAN); - PRIM(QUADS); - PRIM(QUAD_STRIP); - PRIM(POLYGON); + PRIM(POINTS); + PRIM(LINES); + PRIM(LINE_LOOP); + PRIM(LINE_STRIP); + PRIM(TRIANGLES); + PRIM(TRIANGLE_STRIP); + PRIM(TRIANGLE_FAN); + PRIM(QUADS); + PRIM(QUAD_STRIP); + PRIM(POLYGON); default: return "UNKNOWN"; } @@ -2066,7 +2212,7 @@ static void print_nz_x64(FILE *fp, const char *label, uint64_t value) { if (value) { - char acc[256] = {0}; + char acc[256] = { 0 }; char buf[32]; int start = 0; int count = 0; @@ -2216,10 +2362,7 @@ print_shader_info(const struct shader_info *info, FILE *fp) info->xfb_stride[2], info->xfb_stride[3]); - bool has_inlinable_uniform_dw_offsets = info->inlinable_uniform_dw_offsets[0] - || info->inlinable_uniform_dw_offsets[1] - || info->inlinable_uniform_dw_offsets[2] - || info->inlinable_uniform_dw_offsets[3]; + bool has_inlinable_uniform_dw_offsets = info->inlinable_uniform_dw_offsets[0] || info->inlinable_uniform_dw_offsets[1] || info->inlinable_uniform_dw_offsets[2] || info->inlinable_uniform_dw_offsets[3]; if (has_inlinable_uniform_dw_offsets) fprintf(fp, "inlinable_uniform_dw_offsets: {%u, %u, %u, %u}\n", info->inlinable_uniform_dw_offsets[0], @@ -2318,9 +2461,7 @@ print_shader_info(const struct shader_info *info, FILE *fp) break; case MESA_SHADER_COMPUTE: - if (info->cs.workgroup_size_hint[0] - || info->cs.workgroup_size_hint[1] - || info->cs.workgroup_size_hint[2]) + if (info->cs.workgroup_size_hint[0] || info->cs.workgroup_size_hint[1] || info->cs.workgroup_size_hint[2]) fprintf(fp, "workgroup_size_hint: {%u, %u, %u}\n", info->cs.workgroup_size_hint[0], info->cs.workgroup_size_hint[1], @@ -2452,8 +2593,9 @@ nir_print_deref(const nir_deref_instr *deref, FILE *fp) print_deref_link(deref, true, &state); } -void nir_log_shader_annotated_tagged(enum mesa_log_level level, const char *tag, - nir_shader *shader, struct hash_table *annotations) +void +nir_log_shader_annotated_tagged(enum mesa_log_level level, const char *tag, + nir_shader *shader, struct hash_table *annotations) { char *str = nir_shader_as_str_annotated(shader, annotations, NULL); _mesa_log_multiline(level, tag, str); diff --git a/src/compiler/nir/nir_propagate_invariant.c b/src/compiler/nir/nir_propagate_invariant.c index 9944996..bf5e6be 100644 --- a/src/compiler/nir/nir_propagate_invariant.c +++ b/src/compiler/nir/nir_propagate_invariant.c @@ -66,7 +66,7 @@ add_var(nir_variable *var, struct set *invariants) } static bool -var_is_invariant(nir_variable *var, struct set * invariants) +var_is_invariant(nir_variable *var, struct set *invariants) { /* Because we pass the result of nir_intrinsic_get_var directly to this * function, it's possible for var to be NULL if, for instance, there's a @@ -173,8 +173,8 @@ propagate_invariant_impl(nir_function_impl *impl, struct set *invariants) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance | - nir_metadata_live_ssa_defs); + nir_metadata_dominance | + nir_metadata_live_ssa_defs); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index cf88a6c..ee6d0ab 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -20,14 +20,14 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -#include -#include -#include "nir.h" #include "nir_range_analysis.h" +#include +#include #include "util/hash_table.h" -#include "util/u_math.h" #include "util/u_dynarray.h" +#include "util/u_math.h" #include "c99_alloca.h" +#include "nir.h" /** * Analyzes a sequence of operations to determine some aspects of the range of @@ -71,7 +71,7 @@ perform_analysis(struct analysis_state *state) { while (state->query_stack.size) { struct analysis_query *cur = - (struct analysis_query *)((char*)util_dynarray_end(&state->query_stack) - state->query_size); + (struct analysis_query *)((char *)util_dynarray_end(&state->query_stack) - state->query_size); uint32_t *result = util_dynarray_element(&state->result_stack, uint32_t, cur->result_index); uintptr_t key = state->get_key(cur); @@ -80,13 +80,13 @@ perform_analysis(struct analysis_state *state) * them by testing pushed_queries. */ if (cur->pushed_queries == 0 && key && - (he = _mesa_hash_table_search(state->range_ht, (void*)key))) { + (he = _mesa_hash_table_search(state->range_ht, (void *)key))) { *result = (uintptr_t)he->data; state->query_stack.size -= state->query_size; continue; } - uint32_t *src = (uint32_t*)util_dynarray_end(&state->result_stack) - cur->pushed_queries; + uint32_t *src = (uint32_t *)util_dynarray_end(&state->result_stack) - cur->pushed_queries; state->result_stack.size -= sizeof(uint32_t) * cur->pushed_queries; uint32_t prev_num_queries = state->query_stack.size; @@ -101,7 +101,7 @@ perform_analysis(struct analysis_state *state) } if (key) - _mesa_hash_table_insert(state->range_ht, (void*)key, (void*)(uintptr_t)*result); + _mesa_hash_table_insert(state->range_ht, (void *)key, (void *)(uintptr_t)*result); state->query_stack.size -= state->query_size; } @@ -137,9 +137,9 @@ static struct ssa_result_range unpack_data(uint32_t v) { return (struct ssa_result_range){ - .range = v & 0xff, + .range = v & 0xff, .is_integral = (v & 0x00100) != 0, - .is_finite = (v & 0x00200) != 0, + .is_finite = (v & 0x00200) != 0, .is_a_number = (v & 0x00400) != 0 }; } @@ -297,52 +297,48 @@ analyze_constant(const struct nir_alu_instr *instr, unsigned src, */ #define _______ unknown - #if defined(__clang__) - /* clang wants _Pragma("unroll X") */ - #define pragma_unroll_5 _Pragma("unroll 5") - #define pragma_unroll_7 _Pragma("unroll 7") +/* clang wants _Pragma("unroll X") */ +#define pragma_unroll_5 _Pragma("unroll 5") +#define pragma_unroll_7 _Pragma("unroll 7") /* gcc wants _Pragma("GCC unroll X") */ #elif defined(__GNUC__) - #if __GNUC__ >= 8 - #define pragma_unroll_5 _Pragma("GCC unroll 5") - #define pragma_unroll_7 _Pragma("GCC unroll 7") - #else - #pragma GCC optimize ("unroll-loops") - #define pragma_unroll_5 - #define pragma_unroll_7 - #endif +#if __GNUC__ >= 8 +#define pragma_unroll_5 _Pragma("GCC unroll 5") +#define pragma_unroll_7 _Pragma("GCC unroll 7") #else - /* MSVC doesn't have C99's _Pragma() */ - #define pragma_unroll_5 - #define pragma_unroll_7 +#pragma GCC optimize("unroll-loops") +#define pragma_unroll_5 +#define pragma_unroll_7 +#endif +#else +/* MSVC doesn't have C99's _Pragma() */ +#define pragma_unroll_5 +#define pragma_unroll_7 #endif - #ifndef NDEBUG -#define ASSERT_TABLE_IS_COMMUTATIVE(t) \ - do { \ - static bool first = true; \ - if (first) { \ - first = false; \ - pragma_unroll_7 \ - for (unsigned r = 0; r < ARRAY_SIZE(t); r++) { \ - pragma_unroll_7 \ - for (unsigned c = 0; c < ARRAY_SIZE(t[0]); c++) \ - assert(t[r][c] == t[c][r]); \ - } \ - } \ +#define ASSERT_TABLE_IS_COMMUTATIVE(t) \ + do { \ + static bool first = true; \ + if (first) { \ + first = false; \ + pragma_unroll_7 for (unsigned r = 0; r < ARRAY_SIZE(t); r++) \ + { \ + pragma_unroll_7 for (unsigned c = 0; c < ARRAY_SIZE(t[0]); c++) \ + assert(t[r][c] == t[c][r]); \ + } \ + } \ } while (false) -#define ASSERT_TABLE_IS_DIAGONAL(t) \ - do { \ - static bool first = true; \ - if (first) { \ - first = false; \ - pragma_unroll_7 \ - for (unsigned r = 0; r < ARRAY_SIZE(t); r++) \ - assert(t[r][r] == r); \ - } \ +#define ASSERT_TABLE_IS_DIAGONAL(t) \ + do { \ + static bool first = true; \ + if (first) { \ + first = false; \ + pragma_unroll_7 for (unsigned r = 0; r < ARRAY_SIZE(t); r++) \ + assert(t[r][r] == r); \ + } \ } while (false) #else @@ -374,26 +370,26 @@ union_ranges(enum ssa_ranges a, enum ssa_ranges b) /* Verify that the 'unknown' entry in each row (or column) of the table is the * union of all the other values in the row (or column). */ -#define ASSERT_UNION_OF_OTHERS_MATCHES_UNKNOWN_2_SOURCE(t) \ - do { \ - static bool first = true; \ - if (first) { \ - first = false; \ - pragma_unroll_7 \ - for (unsigned i = 0; i < last_range; i++) { \ - enum ssa_ranges col_range = t[i][unknown + 1]; \ - enum ssa_ranges row_range = t[unknown + 1][i]; \ - \ - pragma_unroll_5 \ - for (unsigned j = unknown + 2; j < last_range; j++) { \ - col_range = union_ranges(col_range, t[i][j]); \ - row_range = union_ranges(row_range, t[j][i]); \ - } \ - \ - assert(col_range == t[i][unknown]); \ - assert(row_range == t[unknown][i]); \ - } \ - } \ +#define ASSERT_UNION_OF_OTHERS_MATCHES_UNKNOWN_2_SOURCE(t) \ + do { \ + static bool first = true; \ + if (first) { \ + first = false; \ + pragma_unroll_7 for (unsigned i = 0; i < last_range; i++) \ + { \ + enum ssa_ranges col_range = t[i][unknown + 1]; \ + enum ssa_ranges row_range = t[unknown + 1][i]; \ + \ + pragma_unroll_5 for (unsigned j = unknown + 2; j < last_range; j++) \ + { \ + col_range = union_ranges(col_range, t[i][j]); \ + row_range = union_ranges(row_range, t[j][i]); \ + } \ + \ + assert(col_range == t[i][unknown]); \ + assert(row_range == t[unknown][i]); \ + } \ + } \ } while (false) /* For most operations, the union of ranges for a strict inequality and @@ -403,24 +399,24 @@ union_ranges(enum ssa_ranges a, enum ssa_ranges b) * Does not apply to selection-like opcodes (bcsel, fmin, fmax, etc.). */ #define ASSERT_UNION_OF_EQ_AND_STRICT_INEQ_MATCHES_NONSTRICT_1_SOURCE(t) \ - do { \ - assert(union_ranges(t[lt_zero], t[eq_zero]) == t[le_zero]); \ - assert(union_ranges(t[gt_zero], t[eq_zero]) == t[ge_zero]); \ + do { \ + assert(union_ranges(t[lt_zero], t[eq_zero]) == t[le_zero]); \ + assert(union_ranges(t[gt_zero], t[eq_zero]) == t[ge_zero]); \ } while (false) -#define ASSERT_UNION_OF_EQ_AND_STRICT_INEQ_MATCHES_NONSTRICT_2_SOURCE(t) \ - do { \ - static bool first = true; \ - if (first) { \ - first = false; \ - pragma_unroll_7 \ - for (unsigned i = 0; i < last_range; i++) { \ +#define ASSERT_UNION_OF_EQ_AND_STRICT_INEQ_MATCHES_NONSTRICT_2_SOURCE(t) \ + do { \ + static bool first = true; \ + if (first) { \ + first = false; \ + pragma_unroll_7 for (unsigned i = 0; i < last_range; i++) \ + { \ assert(union_ranges(t[i][lt_zero], t[i][eq_zero]) == t[i][le_zero]); \ assert(union_ranges(t[i][gt_zero], t[i][eq_zero]) == t[i][ge_zero]); \ assert(union_ranges(t[lt_zero][i], t[eq_zero][i]) == t[le_zero][i]); \ assert(union_ranges(t[gt_zero][i], t[eq_zero][i]) == t[ge_zero][i]); \ - } \ - } \ + } \ + } \ } while (false) /* Several other unordered tuples span the range of "everything." Each should @@ -436,35 +432,35 @@ union_ranges(enum ssa_ranges a, enum ssa_ranges b) * possibilities, so the union of all the unions of disjoint ranges is * equivalent to the union of "others." */ -#define ASSERT_UNION_OF_DISJOINT_MATCHES_UNKNOWN_1_SOURCE(t) \ - do { \ - assert(union_ranges(t[lt_zero], t[ge_zero]) == t[unknown]); \ - assert(union_ranges(t[le_zero], t[gt_zero]) == t[unknown]); \ - assert(union_ranges(t[eq_zero], t[ne_zero]) == t[unknown]); \ +#define ASSERT_UNION_OF_DISJOINT_MATCHES_UNKNOWN_1_SOURCE(t) \ + do { \ + assert(union_ranges(t[lt_zero], t[ge_zero]) == t[unknown]); \ + assert(union_ranges(t[le_zero], t[gt_zero]) == t[unknown]); \ + assert(union_ranges(t[eq_zero], t[ne_zero]) == t[unknown]); \ } while (false) -#define ASSERT_UNION_OF_DISJOINT_MATCHES_UNKNOWN_2_SOURCE(t) \ - do { \ - static bool first = true; \ - if (first) { \ - first = false; \ - pragma_unroll_7 \ - for (unsigned i = 0; i < last_range; i++) { \ - assert(union_ranges(t[i][lt_zero], t[i][ge_zero]) == \ - t[i][unknown]); \ - assert(union_ranges(t[i][le_zero], t[i][gt_zero]) == \ - t[i][unknown]); \ - assert(union_ranges(t[i][eq_zero], t[i][ne_zero]) == \ - t[i][unknown]); \ - \ - assert(union_ranges(t[lt_zero][i], t[ge_zero][i]) == \ - t[unknown][i]); \ - assert(union_ranges(t[le_zero][i], t[gt_zero][i]) == \ - t[unknown][i]); \ - assert(union_ranges(t[eq_zero][i], t[ne_zero][i]) == \ - t[unknown][i]); \ - } \ - } \ +#define ASSERT_UNION_OF_DISJOINT_MATCHES_UNKNOWN_2_SOURCE(t) \ + do { \ + static bool first = true; \ + if (first) { \ + first = false; \ + pragma_unroll_7 for (unsigned i = 0; i < last_range; i++) \ + { \ + assert(union_ranges(t[i][lt_zero], t[i][ge_zero]) == \ + t[i][unknown]); \ + assert(union_ranges(t[i][le_zero], t[i][gt_zero]) == \ + t[i][unknown]); \ + assert(union_ranges(t[i][eq_zero], t[i][ne_zero]) == \ + t[i][unknown]); \ + \ + assert(union_ranges(t[lt_zero][i], t[ge_zero][i]) == \ + t[unknown][i]); \ + assert(union_ranges(t[le_zero][i], t[gt_zero][i]) == \ + t[unknown][i]); \ + assert(union_ranges(t[eq_zero][i], t[ne_zero][i]) == \ + t[unknown][i]); \ + } \ + } \ } while (false) #else @@ -512,11 +508,20 @@ get_fp_key(struct analysis_query *q) * As a result, the number of bits does not need to be encoded here. */ switch (nir_alu_type_get_base_type(fp_q->use_type)) { - case nir_type_int: type_encoding = 0; break; - case nir_type_uint: type_encoding = 1; break; - case nir_type_bool: type_encoding = 2; break; - case nir_type_float: type_encoding = 3; break; - default: unreachable("Invalid base type."); + case nir_type_int: + type_encoding = 0; + break; + case nir_type_uint: + type_encoding = 1; + break; + case nir_type_bool: + type_encoding = 2; + break; + case nir_type_float: + type_encoding = 3; + break; + default: + unreachable("Invalid base type."); } return ptr | type_encoding; @@ -549,12 +554,12 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 } if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_alu) { - *result = pack_data((struct ssa_result_range){unknown, false, false, false}); + *result = pack_data((struct ssa_result_range){ unknown, false, false, false }); return; } const struct nir_alu_instr *const alu = - nir_instr_as_alu(instr->src[src].src.ssa->parent_instr); + nir_instr_as_alu(instr->src[src].src.ssa->parent_instr); /* Bail if the type of the instruction generating the value does not match * the type the value will be interpreted as. int/uint/bool can be @@ -570,7 +575,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 if (use_base_type != src_base_type && (use_base_type == nir_type_float || src_base_type == nir_type_float)) { - *result = pack_data((struct ssa_result_range){unknown, false, false, false}); + *result = pack_data((struct ssa_result_range){ unknown, false, false, false }); return; } } @@ -627,7 +632,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 } } - struct ssa_result_range r = {unknown, false, false, false}; + struct ssa_result_range r = { unknown, false, false, false }; /* ge_zero: ge_zero + ge_zero * @@ -719,14 +724,13 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 ASSERT_UNION_OF_EQ_AND_STRICT_INEQ_MATCHES_NONSTRICT_2_SOURCE(fmul_table); static const enum ssa_ranges fneg_table[last_range + 1] = { - /* unknown lt_zero le_zero gt_zero ge_zero ne_zero eq_zero */ + /* unknown lt_zero le_zero gt_zero ge_zero ne_zero eq_zero */ _______, gt_zero, ge_zero, lt_zero, le_zero, ne_zero, eq_zero }; ASSERT_UNION_OF_DISJOINT_MATCHES_UNKNOWN_1_SOURCE(fneg_table); ASSERT_UNION_OF_EQ_AND_STRICT_INEQ_MATCHES_NONSTRICT_1_SOURCE(fneg_table); - switch (alu->op) { case nir_op_b2f32: case nir_op_b2i32: @@ -737,7 +741,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 * 1.401298464324817e-45. The latter is subnormal, but it is finite and * a number. */ - r = (struct ssa_result_range){ge_zero, alu->op == nir_op_b2f32, true, true}; + r = (struct ssa_result_range){ ge_zero, alu->op == nir_op_b2f32, true, true }; break; case nir_op_bcsel: { @@ -812,7 +816,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 * operands is finite, then the result cannot be NaN. */ r.is_a_number = left.is_a_number && right.is_a_number && - (left.is_finite || right.is_finite); + (left.is_finite || right.is_finite); break; } @@ -822,7 +826,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 * parameters, the result will flush to zero. */ static const enum ssa_ranges table[last_range + 1] = { - /* unknown lt_zero le_zero gt_zero ge_zero ne_zero eq_zero */ + /* unknown lt_zero le_zero gt_zero ge_zero ne_zero eq_zero */ ge_zero, ge_zero, ge_zero, gt_zero, gt_zero, ge_zero, gt_zero }; @@ -1033,9 +1037,9 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 * the other cannot be zero, then the result must be a number. */ r.is_a_number = (left.is_a_number && right.is_a_number) && - ((left.is_finite && right.is_finite) || - (!is_not_zero(left.range) && right.is_finite) || - (left.is_finite && !is_not_zero(right.range))); + ((left.is_finite && right.is_finite) || + (!is_not_zero(left.range) && right.is_finite) || + (left.is_finite && !is_not_zero(right.range))); } else { /* nir_op_fmulz: unlike nir_op_fmul, 0 * ±Inf is a number. */ r.is_a_number = left.is_a_number && right.is_a_number; @@ -1107,7 +1111,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 case nir_op_fsqrt: case nir_op_frsq: - r = (struct ssa_result_range){ge_zero, false, false, false}; + r = (struct ssa_result_range){ ge_zero, false, false, false }; break; case nir_op_ffloor: { @@ -1186,7 +1190,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 case nir_op_ult: case nir_op_uge: /* Boolean results are 0 or -1. */ - r = (struct ssa_result_range){le_zero, false, true, false}; + r = (struct ssa_result_range){ le_zero, false, true, false }; break; case nir_op_fdot2: @@ -1210,11 +1214,11 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 * Inf-Inf in the dot-product, the result must also be a number. */ if (nir_alu_srcs_equal(alu, alu, 0, 1)) { - r = (struct ssa_result_range){ge_zero, false, left.is_a_number, false }; + r = (struct ssa_result_range){ ge_zero, false, left.is_a_number, false }; } else if (nir_alu_srcs_negative_equal(alu, alu, 0, 1)) { - r = (struct ssa_result_range){le_zero, false, left.is_a_number, false }; + r = (struct ssa_result_range){ le_zero, false, left.is_a_number, false }; } else { - r = (struct ssa_result_range){unknown, false, false, false}; + r = (struct ssa_result_range){ unknown, false, false, false }; } break; } @@ -1337,7 +1341,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 } default: - r = (struct ssa_result_range){unknown, false, false, false}; + r = (struct ssa_result_range){ unknown, false, false, false }; break; } @@ -1345,7 +1349,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 r.is_integral = true; /* Just like isfinite(), the is_finite flag implies the value is a number. */ - assert((int) r.is_finite <= (int) r.is_a_number); + assert((int)r.is_finite <= (int)r.is_a_number); *result = pack_data(r); } @@ -1372,11 +1376,14 @@ nir_analyze_range(struct hash_table *range_ht, return unpack_data(perform_analysis(&state)); } -static uint32_t bitmask(uint32_t size) { +static uint32_t +bitmask(uint32_t size) +{ return size >= 32 ? 0xffffffffu : ((uint32_t)1 << size) - 1u; } -static uint64_t mul_clamp(uint32_t a, uint32_t b) +static uint64_t +mul_clamp(uint32_t a, uint32_t b) { if (a != 0 && (a * b) / a != b) return (uint64_t)UINT32_MAX + 1; @@ -1400,7 +1407,7 @@ search_phi_bcsel(nir_ssa_scalar scalar, nir_ssa_scalar *buf, unsigned buf_size, nir_foreach_phi_src(src, phi) { num_sources_left--; unsigned added = search_phi_bcsel(nir_get_ssa_scalar(src->src.ssa, scalar.comp), - buf + total_added, buf_size - num_sources_left, visited); + buf + total_added, buf_size - num_sources_left, visited); assert(added <= buf_size); buf_size -= added; total_added += added; @@ -1445,18 +1452,46 @@ static const nir_unsigned_upper_bound_config default_ub_config = { * unbounded. On some hardware max_workgroup_count[1] and * max_workgroup_count[2] may be smaller. */ - .max_workgroup_count = {UINT32_MAX, UINT32_MAX, UINT32_MAX}, + .max_workgroup_count = { UINT32_MAX, UINT32_MAX, UINT32_MAX }, /* max_workgroup_size is the local invocation maximum. This is generally * small the OpenGL 4.2 minimum maximum is 1024. */ - .max_workgroup_size = {UINT16_MAX, UINT16_MAX, UINT16_MAX}, + .max_workgroup_size = { UINT16_MAX, UINT16_MAX, UINT16_MAX }, .vertex_attrib_max = { - UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, - UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, - UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, - UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, + UINT32_MAX, }, }; @@ -1479,8 +1514,8 @@ get_uub_key(struct analysis_query *q) /* keys can't be 0, so we have to add 1 to the index */ unsigned shift_amount = ffs(NIR_MAX_VEC_COMPONENTS) - 1; return nir_ssa_scalar_is_const(scalar) - ? 0 - : ((uintptr_t)(scalar.def->index + 1) << shift_amount) | scalar.comp; + ? 0 + : ((uintptr_t)(scalar.def->index + 1) << shift_amount) | scalar.comp; } static void @@ -1506,7 +1541,8 @@ get_intrinsic_uub(struct analysis_state *state, struct uub_query q, uint32_t *re } else { *result = (shader->info.workgroup_size[0] * shader->info.workgroup_size[1] * - shader->info.workgroup_size[2]) - 1u; + shader->info.workgroup_size[2]) - + 1u; } break; case nir_intrinsic_load_local_invocation_id: @@ -1524,17 +1560,19 @@ get_intrinsic_uub(struct analysis_state *state, struct uub_query q, uint32_t *re case nir_intrinsic_load_global_invocation_id: if (shader->info.workgroup_size_variable) { *result = mul_clamp(config->max_workgroup_size[q.scalar.comp], - config->max_workgroup_count[q.scalar.comp]) - 1u; + config->max_workgroup_count[q.scalar.comp]) - + 1u; } else { *result = (shader->info.workgroup_size[q.scalar.comp] * - config->max_workgroup_count[q.scalar.comp]) - 1u; + config->max_workgroup_count[q.scalar.comp]) - + 1u; } break; case nir_intrinsic_load_invocation_id: if (shader->info.stage == MESA_SHADER_TESS_CTRL) *result = shader->info.tess.tcs_vertices_out - ? (shader->info.tess.tcs_vertices_out - 1) - : 511; /* Generous maximum output patch size of 512 */ + ? (shader->info.tess.tcs_vertices_out - 1) + : 511; /* Generous maximum output patch size of 512 */ break; case nir_intrinsic_load_subgroup_invocation: case nir_intrinsic_first_invocation: @@ -1632,7 +1670,7 @@ get_intrinsic_uub(struct analysis_state *state, struct uub_query q, uint32_t *re if (format == PIPE_FORMAT_NONE) break; - const struct util_format_description* desc = util_format_description(format); + const struct util_format_description *desc = util_format_description(format); if (desc->channel[q.scalar.comp].type != UTIL_FORMAT_TYPE_UNSIGNED) break; @@ -1768,7 +1806,8 @@ get_alu_uub(struct analysis_state *state, struct uub_query q, uint32_t *result, nir_ssa_scalar src1_scalar = nir_ssa_scalar_chase_alu_src(q.scalar, 1); if (nir_ssa_scalar_is_const(src1_scalar)) *result = nir_ssa_scalar_as_uint(src1_scalar) - ? src[0] / nir_ssa_scalar_as_uint(src1_scalar) : 0; + ? src[0] / nir_ssa_scalar_as_uint(src1_scalar) + : 0; else *result = src[0]; break; @@ -1864,7 +1903,7 @@ get_phi_uub(struct analysis_state *state, struct uub_query q, uint32_t *result, if (!prev || prev->type == nir_cf_node_block) { /* Resolve cycles by inserting max into range_ht. */ uint32_t max = bitmask(q.scalar.def->bit_size); - _mesa_hash_table_insert(state->range_ht, (void*)get_uub_key(&q.head), (void*)(uintptr_t)max); + _mesa_hash_table_insert(state->range_ht, (void *)get_uub_key(&q.head), (void *)(uintptr_t)max); struct set *visited = _mesa_pointer_set_create(NULL); nir_ssa_scalar *defs = alloca(sizeof(nir_ssa_scalar) * 64); @@ -1899,7 +1938,8 @@ process_uub_query(struct analysis_state *state, struct analysis_query *aq, uint3 uint32_t nir_unsigned_upper_bound(nir_shader *shader, struct hash_table *range_ht, nir_ssa_scalar scalar, - const nir_unsigned_upper_bound_config *config) { + const nir_unsigned_upper_bound_config *config) +{ if (!config) config = &default_ub_config; diff --git a/src/compiler/nir/nir_remove_dead_variables.c b/src/compiler/nir/nir_remove_dead_variables.c index 8c42831..853a132 100644 --- a/src/compiler/nir/nir_remove_dead_variables.c +++ b/src/compiler/nir/nir_remove_dead_variables.c @@ -190,7 +190,8 @@ nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes, if (modes & ~nir_var_function_temp) { progress = remove_dead_vars(&shader->variables, modes, - live, opts) || progress; + live, opts) || + progress; } if (modes & nir_var_function_temp) { @@ -208,7 +209,7 @@ nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes, if (progress) { remove_dead_var_writes(shader); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_remove_tex_shadow.c b/src/compiler/nir/nir_remove_tex_shadow.c index 4d37d64..8646821 100644 --- a/src/compiler/nir/nir_remove_tex_shadow.c +++ b/src/compiler/nir/nir_remove_tex_shadow.c @@ -28,14 +28,13 @@ static const struct glsl_type * strip_shadow(const struct glsl_type *type) { const struct glsl_type *new_type = - glsl_sampler_type( - glsl_get_sampler_dim(type), - false, glsl_sampler_type_is_array(type), - GLSL_TYPE_FLOAT); + glsl_sampler_type( + glsl_get_sampler_dim(type), + false, glsl_sampler_type_is_array(type), + GLSL_TYPE_FLOAT); return new_type; } - static inline const struct glsl_type * strip_shadow_with_array(const struct glsl_type *type) { @@ -49,7 +48,7 @@ change_deref_var_type(struct nir_builder *b, nir_instr *instr, void *data) return false; nir_variable *sampler = data; - nir_deref_instr *deref = nir_instr_as_deref (instr); + nir_deref_instr *deref = nir_instr_as_deref(instr); if (deref->var == sampler) { deref->type = sampler->type; return true; diff --git a/src/compiler/nir/nir_repair_ssa.c b/src/compiler/nir/nir_repair_ssa.c index f5ec38c..31fdb67 100644 --- a/src/compiler/nir/nir_repair_ssa.c +++ b/src/compiler/nir/nir_repair_ssa.c @@ -152,7 +152,7 @@ nir_repair_ssa_impl(nir_function_impl *impl) state.progress = false; nir_metadata_require(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); nir_foreach_block(block, impl) { nir_foreach_instr_safe(instr, block) { @@ -162,7 +162,7 @@ nir_repair_ssa_impl(nir_function_impl *impl) if (state.progress) nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); if (state.phi_builder) { nir_phi_builder_finish(state.phi_builder); diff --git a/src/compiler/nir/nir_scale_fdiv.c b/src/compiler/nir/nir_scale_fdiv.c index 6c00a5b..2be14b4 100644 --- a/src/compiler/nir/nir_scale_fdiv.c +++ b/src/compiler/nir/nir_scale_fdiv.c @@ -51,10 +51,10 @@ nir_scale_fdiv_instr(nir_builder *b, nir_instr *instr, UNUSED void *_data) nir_ssa_def *final_a = nir_bcsel(b, big, scaled_down_a, - (nir_bcsel(b, small, scaled_up_a, orig_a))); + (nir_bcsel(b, small, scaled_up_a, orig_a))); nir_ssa_def *final_b = nir_bcsel(b, big, scaled_down_b, - (nir_bcsel(b, small, scaled_up_b, orig_b))); + (nir_bcsel(b, small, scaled_up_b, orig_b))); nir_ssa_def *new_div = nir_fdiv(b, final_a, final_b); nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, new_div); @@ -74,6 +74,6 @@ nir_scale_fdiv(nir_shader *shader) { return nir_shader_instructions_pass(shader, nir_scale_fdiv_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_schedule.c b/src/compiler/nir/nir_schedule.c index 40d7584..ddb50cd 100644 --- a/src/compiler/nir/nir_schedule.c +++ b/src/compiler/nir/nir_schedule.c @@ -115,7 +115,8 @@ typedef struct { /* When walking the instructions in reverse, we use this flag to swap * before/after in add_dep(). */ -enum direction { F, R }; +enum direction { F, + R }; struct nir_schedule_class_dep { int klass; @@ -212,7 +213,6 @@ add_dep(nir_deps_state *state, dag_add_edge(&after->dag, &before->dag, 0); } - static void add_read_dep(nir_deps_state *state, nir_schedule_node *before, @@ -1124,7 +1124,7 @@ nir_schedule_dag_max_delay_cb(struct dag_node *node, void *state) } n->max_delay = MAX2(n->max_delay, max_delay + n->delay); - } +} static void nir_schedule_block(nir_schedule_scoreboard *scoreboard, nir_block *block) @@ -1233,7 +1233,7 @@ nir_schedule_validate_uses(nir_schedule_scoreboard *scoreboard) set_foreach(remaining_uses, instr_entry) { if (!any_uses) { fprintf(stderr, "Tracked uses remain after scheduling. " - "Affected instructions: \n"); + "Affected instructions: \n"); any_uses = true; } nir_print_instr(instr_entry->key, stderr); diff --git a/src/compiler/nir/nir_schedule.h b/src/compiler/nir/nir_schedule.h index 263136e..0065263 100644 --- a/src/compiler/nir/nir_schedule.h +++ b/src/compiler/nir/nir_schedule.h @@ -68,15 +68,15 @@ typedef struct nir_schedule_options { * true then a dependency should be added and dep is filled in to describe * it. */ - bool (* intrinsic_cb)(nir_intrinsic_instr *intr, - nir_schedule_dependency *dep, - void *user_data); + bool (*intrinsic_cb)(nir_intrinsic_instr *intr, + nir_schedule_dependency *dep, + void *user_data); /* Data to pass to the intrinsic callback */ void *intrinsic_cb_data; /* Callback used to specify instruction delays */ - unsigned (* instr_delay_cb)(nir_instr *instr, void *user_data); + unsigned (*instr_delay_cb)(nir_instr *instr, void *user_data); /* Data to pass to the instruction delay callback */ void *instr_delay_cb_data; diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c index 6c615b5..3c0b512 100644 --- a/src/compiler/nir/nir_search.c +++ b/src/compiler/nir/nir_search.c @@ -21,11 +21,11 @@ * IN THE SOFTWARE. */ -#include #include "nir_search.h" +#include +#include "util/half_float.h" #include "nir_builder.h" #include "nir_worklist.h" -#include "util/half_float.h" /* This should be the same as nir_search_max_comm_ops in nir_algebraic.py. */ #define NIR_SEARCH_MAX_COMM_OPS 8 @@ -53,12 +53,23 @@ static bool nir_algebraic_automaton(nir_instr *instr, struct util_dynarray *states, const struct per_op_table *pass_op_table); -static const uint8_t identity_swizzle[NIR_MAX_VEC_COMPONENTS] = -{ - 0, 1, 2, 3, - 4, 5, 6, 7, - 8, 9, 10, 11, - 12, 13, 14, 15, +static const uint8_t identity_swizzle[NIR_MAX_VEC_COMPONENTS] = { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, }; /** @@ -109,29 +120,29 @@ nir_op_matches_search_op(nir_op nop, uint16_t sop) if (sop <= nir_last_opcode) return nop == sop; -#define MATCH_FCONV_CASE(op) \ - case nir_search_op_##op: \ +#define MATCH_FCONV_CASE(op) \ + case nir_search_op_##op: \ return nop == nir_op_##op##16 || \ nop == nir_op_##op##32 || \ nop == nir_op_##op##64; -#define MATCH_ICONV_CASE(op) \ - case nir_search_op_##op: \ - return nop == nir_op_##op##8 || \ +#define MATCH_ICONV_CASE(op) \ + case nir_search_op_##op: \ + return nop == nir_op_##op##8 || \ nop == nir_op_##op##16 || \ nop == nir_op_##op##32 || \ nop == nir_op_##op##64; switch (sop) { - MATCH_FCONV_CASE(i2f) - MATCH_FCONV_CASE(u2f) - MATCH_FCONV_CASE(f2f) - MATCH_ICONV_CASE(f2u) - MATCH_ICONV_CASE(f2i) - MATCH_ICONV_CASE(u2u) - MATCH_ICONV_CASE(i2i) - MATCH_FCONV_CASE(b2f) - MATCH_ICONV_CASE(b2i) + MATCH_FCONV_CASE(i2f) + MATCH_FCONV_CASE(u2f) + MATCH_FCONV_CASE(f2f) + MATCH_ICONV_CASE(f2u) + MATCH_ICONV_CASE(f2i) + MATCH_ICONV_CASE(u2u) + MATCH_ICONV_CASE(i2i) + MATCH_FCONV_CASE(b2f) + MATCH_ICONV_CASE(b2i) default: unreachable("Invalid nir_search_op"); } @@ -144,29 +155,28 @@ uint16_t nir_search_op_for_nir_op(nir_op nop) { #define MATCH_FCONV_CASE(op) \ - case nir_op_##op##16: \ - case nir_op_##op##32: \ - case nir_op_##op##64: \ + case nir_op_##op##16: \ + case nir_op_##op##32: \ + case nir_op_##op##64: \ return nir_search_op_##op; #define MATCH_ICONV_CASE(op) \ - case nir_op_##op##8: \ - case nir_op_##op##16: \ - case nir_op_##op##32: \ - case nir_op_##op##64: \ + case nir_op_##op##8: \ + case nir_op_##op##16: \ + case nir_op_##op##32: \ + case nir_op_##op##64: \ return nir_search_op_##op; - switch (nop) { - MATCH_FCONV_CASE(i2f) - MATCH_FCONV_CASE(u2f) - MATCH_FCONV_CASE(f2f) - MATCH_ICONV_CASE(f2u) - MATCH_ICONV_CASE(f2i) - MATCH_ICONV_CASE(u2u) - MATCH_ICONV_CASE(i2i) - MATCH_FCONV_CASE(b2f) - MATCH_ICONV_CASE(b2i) + MATCH_FCONV_CASE(i2f) + MATCH_FCONV_CASE(u2f) + MATCH_FCONV_CASE(f2f) + MATCH_ICONV_CASE(f2u) + MATCH_ICONV_CASE(f2i) + MATCH_ICONV_CASE(u2u) + MATCH_ICONV_CASE(i2i) + MATCH_FCONV_CASE(b2f) + MATCH_ICONV_CASE(b2i) default: return nop; } @@ -181,35 +191,44 @@ nir_op_for_search_op(uint16_t sop, unsigned bit_size) if (sop <= nir_last_opcode) return sop; -#define RET_FCONV_CASE(op) \ - case nir_search_op_##op: \ - switch (bit_size) { \ - case 16: return nir_op_##op##16; \ - case 32: return nir_op_##op##32; \ - case 64: return nir_op_##op##64; \ - default: unreachable("Invalid bit size"); \ +#define RET_FCONV_CASE(op) \ + case nir_search_op_##op: \ + switch (bit_size) { \ + case 16: \ + return nir_op_##op##16; \ + case 32: \ + return nir_op_##op##32; \ + case 64: \ + return nir_op_##op##64; \ + default: \ + unreachable("Invalid bit size"); \ } -#define RET_ICONV_CASE(op) \ - case nir_search_op_##op: \ - switch (bit_size) { \ - case 8: return nir_op_##op##8; \ - case 16: return nir_op_##op##16; \ - case 32: return nir_op_##op##32; \ - case 64: return nir_op_##op##64; \ - default: unreachable("Invalid bit size"); \ +#define RET_ICONV_CASE(op) \ + case nir_search_op_##op: \ + switch (bit_size) { \ + case 8: \ + return nir_op_##op##8; \ + case 16: \ + return nir_op_##op##16; \ + case 32: \ + return nir_op_##op##32; \ + case 64: \ + return nir_op_##op##64; \ + default: \ + unreachable("Invalid bit size"); \ } switch (sop) { - RET_FCONV_CASE(i2f) - RET_FCONV_CASE(u2f) - RET_FCONV_CASE(f2f) - RET_ICONV_CASE(f2u) - RET_ICONV_CASE(f2i) - RET_ICONV_CASE(u2u) - RET_ICONV_CASE(i2i) - RET_FCONV_CASE(b2f) - RET_ICONV_CASE(b2i) + RET_FCONV_CASE(i2f) + RET_FCONV_CASE(u2f) + RET_FCONV_CASE(f2f) + RET_ICONV_CASE(f2u) + RET_ICONV_CASE(f2i) + RET_ICONV_CASE(u2u) + RET_ICONV_CASE(i2i) + RET_FCONV_CASE(b2f) + RET_ICONV_CASE(b2i) default: unreachable("Invalid nir_search_op"); } @@ -384,8 +403,9 @@ match_expression(const nir_algebraic_table *table, const nir_search_expression * */ unsigned comm_op_flip = (expr->comm_expr_idx >= 0 && - expr->comm_expr_idx < NIR_SEARCH_MAX_COMM_OPS) ? - ((state->comm_op_direction >> expr->comm_expr_idx) & 1) : 0; + expr->comm_expr_idx < NIR_SEARCH_MAX_COMM_OPS) + ? ((state->comm_op_direction >> expr->comm_expr_idx) & 1) + : 0; bool matched = true; for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { @@ -522,7 +542,8 @@ construct_value(nir_builder *build, } } -UNUSED static void dump_value(const nir_algebraic_table *table, const nir_search_value *val) +UNUSED static void +dump_value(const nir_algebraic_table *table, const nir_search_value *val) { switch (val->type) { case nir_search_value_constant: { @@ -532,10 +553,10 @@ UNUSED static void dump_value(const nir_algebraic_table *table, const nir_search fprintf(stderr, "%f", sconst->data.d); break; case nir_type_int: - fprintf(stderr, "%"PRId64, sconst->data.i); + fprintf(stderr, "%" PRId64, sconst->data.i); break; case nir_type_uint: - fprintf(stderr, "0x%"PRIx64, sconst->data.u); + fprintf(stderr, "0x%" PRIx64, sconst->data.u); break; case nir_type_bool: fprintf(stderr, "%s", sconst->data.u != 0 ? "True" : "False"); @@ -560,13 +581,15 @@ UNUSED static void dump_value(const nir_algebraic_table *table, const nir_search if (expr->inexact) fprintf(stderr, "~"); switch (expr->opcode) { -#define CASE(n) \ - case nir_search_op_##n: fprintf(stderr, #n); break; - CASE(b2f) - CASE(b2i) - CASE(i2i) - CASE(f2i) - CASE(i2f) +#define CASE(n) \ + case nir_search_op_##n: \ + fprintf(stderr, #n); \ + break; + CASE(b2f) + CASE(b2i) + CASE(i2i) + CASE(f2i) + CASE(i2f) #undef CASE default: fprintf(stderr, "%s", nir_op_infos[expr->opcode].name); @@ -856,7 +879,7 @@ nir_algebraic_impl(nir_function_impl *impl, * state 0 is the default state, which means we don't have to visit * anything other than constants and ALU instructions. */ - struct util_dynarray states = {0}; + struct util_dynarray states = { 0 }; if (!util_dynarray_resize(&states, uint16_t, impl->ssa_alloc)) { nir_metadata_preserve(impl, nir_metadata_all); return false; @@ -911,7 +934,7 @@ nir_algebraic_impl(nir_function_impl *impl, if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } diff --git a/src/compiler/nir/nir_search.h b/src/compiler/nir/nir_search.h index 72a5a35..421722c 100644 --- a/src/compiler/nir/nir_search.h +++ b/src/compiler/nir/nir_search.h @@ -24,9 +24,9 @@ #ifndef _NIR_SEARCH_ #define _NIR_SEARCH_ +#include "util/u_dynarray.h" #include "nir.h" #include "nir_worklist.h" -#include "util/u_dynarray.h" #define NIR_SEARCH_MAX_VARIABLES 16 @@ -173,7 +173,7 @@ struct per_op_table { }; struct transform { - uint16_t search; /* Index in table->values[] for the search expression. */ + uint16_t search; /* Index in table->values[] for the search expression. */ uint16_t replace; /* Index in table->values[] for the replace value. */ unsigned condition_offset; }; diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h index a9d1996..c30340f 100644 --- a/src/compiler/nir/nir_search_helpers.h +++ b/src/compiler/nir/nir_search_helpers.h @@ -27,10 +27,10 @@ #ifndef _NIR_SEARCH_HELPERS_ #define _NIR_SEARCH_HELPERS_ -#include "nir.h" +#include #include "util/bitscan.h" +#include "nir.h" #include "nir_range_analysis.h" -#include static inline bool is_pos_power_of_two(UNUSED struct hash_table *ht, const nir_alu_instr *instr, @@ -111,25 +111,25 @@ is_bitcount2(UNUSED struct hash_table *ht, const nir_alu_instr *instr, return true; } -#define MULTIPLE(test) \ -static inline bool \ -is_unsigned_multiple_of_ ## test(UNUSED struct hash_table *ht, \ - const nir_alu_instr *instr, \ - unsigned src, unsigned num_components, \ - const uint8_t *swizzle) \ -{ \ - /* only constant srcs: */ \ - if (!nir_src_is_const(instr->src[src].src)) \ - return false; \ - \ - for (unsigned i = 0; i < num_components; i++) { \ - uint64_t val = nir_src_comp_as_uint(instr->src[src].src, swizzle[i]); \ - if (val % test != 0) \ - return false; \ - } \ - \ - return true; \ -} +#define MULTIPLE(test) \ + static inline bool \ + is_unsigned_multiple_of_##test(UNUSED struct hash_table *ht, \ + const nir_alu_instr *instr, \ + unsigned src, unsigned num_components, \ + const uint8_t *swizzle) \ + { \ + /* only constant srcs: */ \ + if (!nir_src_is_const(instr->src[src].src)) \ + return false; \ + \ + for (unsigned i = 0; i < num_components; i++) { \ + uint64_t val = nir_src_comp_as_uint(instr->src[src].src, swizzle[i]); \ + if (val % test != 0) \ + return false; \ + } \ + \ + return true; \ + } MULTIPLE(2) MULTIPLE(4) @@ -447,7 +447,7 @@ is_only_used_as_float(const nir_alu_instr *instr) const nir_alu_instr *const user_alu = nir_instr_as_alu(user_instr); assert(instr != user_alu); - unsigned index = (nir_alu_src*)container_of(src, nir_alu_src, src) - user_alu->src; + unsigned index = (nir_alu_src *)container_of(src, nir_alu_src, src) - user_alu->src; nir_alu_type type = nir_op_infos[user_alu->op].input_types[index]; if (nir_alu_type_get_base_type(type) != nir_type_float) return false; @@ -507,7 +507,8 @@ is_upper_half_zero(UNUSED struct hash_table *ht, const nir_alu_instr *instr, unsigned half_bit_size = nir_src_bit_size(instr->src[src].src) / 2; uint64_t high_bits = u_bit_consecutive64(half_bit_size, half_bit_size); if ((nir_src_comp_as_uint(instr->src[src].src, - swizzle[i]) & high_bits) != 0) { + swizzle[i]) & + high_bits) != 0) { return false; } } @@ -549,7 +550,8 @@ is_upper_half_negative_one(UNUSED struct hash_table *ht, const nir_alu_instr *in unsigned half_bit_size = nir_src_bit_size(instr->src[src].src) / 2; uint64_t high_bits = u_bit_consecutive64(half_bit_size, half_bit_size); if ((nir_src_comp_as_uint(instr->src[src].src, - swizzle[i]) & high_bits) != high_bits) { + swizzle[i]) & + high_bits) != high_bits) { return false; } } @@ -619,25 +621,24 @@ is_finite_not_zero(UNUSED struct hash_table *ht, const nir_alu_instr *instr, (v.range == lt_zero || v.range == gt_zero || v.range == ne_zero); } - -#define RELATION(r) \ -static inline bool \ -is_ ## r (struct hash_table *ht, const nir_alu_instr *instr, \ - unsigned src, UNUSED unsigned num_components, \ - UNUSED const uint8_t *swizzle) \ -{ \ - const struct ssa_result_range v = nir_analyze_range(ht, instr, src); \ - return v.range == r; \ -} \ - \ -static inline bool \ -is_a_number_ ## r (struct hash_table *ht, const nir_alu_instr *instr, \ - unsigned src, UNUSED unsigned num_components, \ - UNUSED const uint8_t *swizzle) \ -{ \ - const struct ssa_result_range v = nir_analyze_range(ht, instr, src); \ - return v.is_a_number && v.range == r; \ -} +#define RELATION(r) \ + static inline bool \ + is_##r(struct hash_table *ht, const nir_alu_instr *instr, \ + unsigned src, UNUSED unsigned num_components, \ + UNUSED const uint8_t *swizzle) \ + { \ + const struct ssa_result_range v = nir_analyze_range(ht, instr, src); \ + return v.range == r; \ + } \ + \ + static inline bool \ + is_a_number_##r(struct hash_table *ht, const nir_alu_instr *instr, \ + unsigned src, UNUSED unsigned num_components, \ + UNUSED const uint8_t *swizzle) \ + { \ + const struct ssa_result_range v = nir_analyze_range(ht, instr, src); \ + return v.is_a_number && v.range == r; \ + } RELATION(lt_zero) RELATION(le_zero) @@ -663,7 +664,6 @@ is_a_number_not_negative(struct hash_table *ht, const nir_alu_instr *instr, (v.range == ge_zero || v.range == gt_zero || v.range == eq_zero); } - static inline bool is_not_positive(struct hash_table *ht, const nir_alu_instr *instr, unsigned src, UNUSED unsigned num_components, UNUSED const uint8_t *swizzle) diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index 430f0d9..3630794 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -22,13 +22,13 @@ */ #include "nir_serialize.h" -#include "nir_control_flow.h" -#include "nir_xfb_info.h" #include "util/u_dynarray.h" #include "util/u_math.h" +#include "nir_control_flow.h" +#include "nir_xfb_info.h" #define NIR_SERIALIZE_FUNC_HAS_IMPL ((void *)(intptr_t)1) -#define MAX_OBJECT_IDS (1 << 20) +#define MAX_OBJECT_IDS (1 << 20) typedef struct { size_t blob_offset; @@ -94,7 +94,7 @@ write_add_object(write_ctx *ctx, const void *obj) { uint32_t index = ctx->next_idx++; assert(index != MAX_OBJECT_IDS); - _mesa_hash_table_insert(ctx->remap_table, obj, (void *)(uintptr_t) index); + _mesa_hash_table_insert(ctx->remap_table, obj, (void *)(uintptr_t)index); } static uint32_t @@ -102,7 +102,7 @@ write_lookup_object(write_ctx *ctx, const void *obj) { struct hash_entry *entry = _mesa_hash_table_search(ctx->remap_table, obj); assert(entry); - return (uint32_t)(uintptr_t) entry->data; + return (uint32_t)(uintptr_t)entry->data; } static void @@ -143,7 +143,7 @@ decode_bit_size_3bits(uint8_t bit_size) return 0; } -#define NUM_COMPONENTS_IS_SEPARATE_7 7 +#define NUM_COMPONENTS_IS_SEPARATE_7 7 static uint8_t encode_num_components_in_3bits(uint8_t num_components) @@ -210,25 +210,25 @@ enum var_data_encoding { union packed_var { uint32_t u32; struct { - unsigned has_name:1; - unsigned has_constant_initializer:1; - unsigned has_pointer_initializer:1; - unsigned has_interface_type:1; - unsigned num_state_slots:7; - unsigned data_encoding:2; - unsigned type_same_as_last:1; - unsigned interface_type_same_as_last:1; - unsigned ray_query:1; - unsigned num_members:16; + unsigned has_name : 1; + unsigned has_constant_initializer : 1; + unsigned has_pointer_initializer : 1; + unsigned has_interface_type : 1; + unsigned num_state_slots : 7; + unsigned data_encoding : 2; + unsigned type_same_as_last : 1; + unsigned interface_type_same_as_last : 1; + unsigned ray_query : 1; + unsigned num_members : 16; } u; }; union packed_var_data_diff { uint32_t u32; struct { - int location:13; - int location_frac:3; - int driver_location:16; + int location : 13; + int location_frac : 3; + int driver_location : 16; } u; }; @@ -337,7 +337,7 @@ write_variable(write_ctx *ctx, const nir_variable *var) blob_write_uint32(ctx->blob, write_lookup_object(ctx, var->pointer_initializer)); if (var->num_members > 0) { - blob_write_bytes(ctx->blob, (uint8_t *) var->members, + blob_write_bytes(ctx->blob, (uint8_t *)var->members, var->num_members * sizeof(*var->members)); } } @@ -379,7 +379,7 @@ read_variable(read_ctx *ctx) else if (flags.u.data_encoding == var_encode_function_temp) var->data.mode = nir_var_function_temp; else if (flags.u.data_encoding == var_encode_full) { - blob_copy_bytes(ctx->blob, (uint8_t *) &var->data, sizeof(var->data)); + blob_copy_bytes(ctx->blob, (uint8_t *)&var->data, sizeof(var->data)); ctx->last_var_data = var->data; } else { /* var_encode_location_diff */ union packed_var_data_diff diff; @@ -418,7 +418,7 @@ read_variable(read_ctx *ctx) if (var->num_members > 0) { var->members = ralloc_array(var, struct nir_variable_data, var->num_members); - blob_copy_bytes(ctx->blob, (uint8_t *) var->members, + blob_copy_bytes(ctx->blob, (uint8_t *)var->members, var->num_members * sizeof(*var->members)); } @@ -448,22 +448,22 @@ read_var_list(read_ctx *ctx, struct exec_list *dst) union packed_src { uint32_t u32; struct { - unsigned _pad:2; /* <-- Header */ - unsigned object_idx:20; - unsigned _footer:10; /* <-- Footer */ + unsigned _pad : 2; /* <-- Header */ + unsigned object_idx : 20; + unsigned _footer : 10; /* <-- Footer */ } any; struct { - unsigned _header:22; /* <-- Header */ - unsigned _pad:2; /* <-- Footer */ - unsigned swizzle_x:2; - unsigned swizzle_y:2; - unsigned swizzle_z:2; - unsigned swizzle_w:2; + unsigned _header : 22; /* <-- Header */ + unsigned _pad : 2; /* <-- Footer */ + unsigned swizzle_x : 2; + unsigned swizzle_y : 2; + unsigned swizzle_z : 2; + unsigned swizzle_w : 2; } alu; struct { - unsigned _header:22; /* <-- Header */ - unsigned src_type:5; /* <-- Footer */ - unsigned _pad:5; + unsigned _header : 22; /* <-- Header */ + unsigned src_type : 5; /* <-- Footer */ + unsigned _pad : 5; } tex; }; @@ -477,7 +477,7 @@ write_src_full(write_ctx *ctx, const nir_src *src, union packed_src header) static void write_src(write_ctx *ctx, const nir_src *src) { - union packed_src header = {0}; + union packed_src header = { 0 }; write_src_full(ctx, src, header); } @@ -495,10 +495,10 @@ read_src(read_ctx *ctx, nir_src *src) union packed_dest { uint8_t u8; struct { - uint8_t _pad:1; - uint8_t num_components:3; - uint8_t bit_size:3; - uint8_t divergent:1; + uint8_t _pad : 1; + uint8_t num_components : 3; + uint8_t bit_size : 3; + uint8_t divergent : 1; }; }; @@ -531,77 +531,77 @@ enum load_const_packing { union packed_instr { uint32_t u32; struct { - unsigned instr_type:4; /* always present */ - unsigned _pad:20; - unsigned dest:8; /* always last */ + unsigned instr_type : 4; /* always present */ + unsigned _pad : 20; + unsigned dest : 8; /* always last */ } any; struct { - unsigned instr_type:4; - unsigned exact:1; - unsigned no_signed_wrap:1; - unsigned no_unsigned_wrap:1; - unsigned padding:1; + unsigned instr_type : 4; + unsigned exact : 1; + unsigned no_signed_wrap : 1; + unsigned no_unsigned_wrap : 1; + unsigned padding : 1; /* Reg: writemask; SSA: swizzles for 2 srcs */ - unsigned writemask_or_two_swizzles:4; - unsigned op:9; - unsigned packed_src_ssa_16bit:1; + unsigned writemask_or_two_swizzles : 4; + unsigned op : 9; + unsigned packed_src_ssa_16bit : 1; /* Scalarized ALUs always have the same header. */ - unsigned num_followup_alu_sharing_header:2; - unsigned dest:8; + unsigned num_followup_alu_sharing_header : 2; + unsigned dest : 8; } alu; struct { - unsigned instr_type:4; - unsigned deref_type:3; - unsigned cast_type_same_as_last:1; - unsigned modes:5; /* See (de|en)code_deref_modes() */ - unsigned _pad:9; - unsigned in_bounds:1; - unsigned packed_src_ssa_16bit:1; /* deref_var redefines this */ - unsigned dest:8; + unsigned instr_type : 4; + unsigned deref_type : 3; + unsigned cast_type_same_as_last : 1; + unsigned modes : 5; /* See (de|en)code_deref_modes() */ + unsigned _pad : 9; + unsigned in_bounds : 1; + unsigned packed_src_ssa_16bit : 1; /* deref_var redefines this */ + unsigned dest : 8; } deref; struct { - unsigned instr_type:4; - unsigned deref_type:3; - unsigned _pad:1; - unsigned object_idx:16; /* if 0, the object ID is a separate uint32 */ - unsigned dest:8; + unsigned instr_type : 4; + unsigned deref_type : 3; + unsigned _pad : 1; + unsigned object_idx : 16; /* if 0, the object ID is a separate uint32 */ + unsigned dest : 8; } deref_var; struct { - unsigned instr_type:4; - unsigned intrinsic:10; - unsigned const_indices_encoding:2; - unsigned packed_const_indices:8; - unsigned dest:8; + unsigned instr_type : 4; + unsigned intrinsic : 10; + unsigned const_indices_encoding : 2; + unsigned packed_const_indices : 8; + unsigned dest : 8; } intrinsic; struct { - unsigned instr_type:4; - unsigned last_component:4; - unsigned bit_size:3; - unsigned packing:2; /* enum load_const_packing */ - unsigned packed_value:19; /* meaning determined by packing */ + unsigned instr_type : 4; + unsigned last_component : 4; + unsigned bit_size : 3; + unsigned packing : 2; /* enum load_const_packing */ + unsigned packed_value : 19; /* meaning determined by packing */ } load_const; struct { - unsigned instr_type:4; - unsigned last_component:4; - unsigned bit_size:3; - unsigned _pad:21; + unsigned instr_type : 4; + unsigned last_component : 4; + unsigned bit_size : 3; + unsigned _pad : 21; } undef; struct { - unsigned instr_type:4; - unsigned num_srcs:4; - unsigned op:5; - unsigned _pad:11; - unsigned dest:8; + unsigned instr_type : 4; + unsigned num_srcs : 4; + unsigned op : 5; + unsigned _pad : 11; + unsigned dest : 8; } tex; struct { - unsigned instr_type:4; - unsigned num_srcs:20; - unsigned dest:8; + unsigned instr_type : 4; + unsigned num_srcs : 20; + unsigned dest : 8; } phi; struct { - unsigned instr_type:4; - unsigned type:2; - unsigned _pad:26; + unsigned instr_type : 4; + unsigned type : 2; + unsigned _pad : 26; } jump; }; @@ -768,8 +768,7 @@ write_alu(write_ctx *ctx, const nir_alu_instr *alu) unsigned value = 0; for (unsigned j = 0; j < 8 && o + j < src_channels; j++) { - value |= (uint32_t)alu->src[i].swizzle[o + j] << - (4 * j); /* 4 bits per swizzle */ + value |= (uint32_t)alu->src[i].swizzle[o + j] << (4 * j); /* 4 bits per swizzle */ } blob_write_uint32(ctx->blob, value); @@ -1352,19 +1351,19 @@ read_ssa_undef(read_ctx *ctx, union packed_instr header) union packed_tex_data { uint32_t u32; struct { - unsigned sampler_dim:4; - unsigned dest_type:8; - unsigned coord_components:3; - unsigned is_array:1; - unsigned is_shadow:1; - unsigned is_new_style_shadow:1; - unsigned is_sparse:1; - unsigned component:2; - unsigned texture_non_uniform:1; - unsigned sampler_non_uniform:1; - unsigned array_is_lowered_cube:1; - unsigned is_gather_implicit_lod:1; - unsigned unused:5; /* Mark unused for valgrind. */ + unsigned sampler_dim : 4; + unsigned dest_type : 8; + unsigned coord_components : 3; + unsigned is_array : 1; + unsigned is_shadow : 1; + unsigned is_new_style_shadow : 1; + unsigned is_sparse : 1; + unsigned component : 2; + unsigned texture_non_uniform : 1; + unsigned sampler_non_uniform : 1; + unsigned array_is_lowered_cube : 1; + unsigned is_gather_implicit_lod : 1; + unsigned unused : 5; /* Mark unused for valgrind. */ } u; }; @@ -1511,8 +1510,8 @@ read_phi(read_ctx *ctx, nir_block *blk, union packed_instr header) nir_instr_insert_after_block(blk, &phi->instr); for (unsigned i = 0; i < header.phi.num_srcs; i++) { - nir_ssa_def *def = (nir_ssa_def *)(uintptr_t) blob_read_uint32(ctx->blob); - nir_block *pred = (nir_block *)(uintptr_t) blob_read_uint32(ctx->blob); + nir_ssa_def *def = (nir_ssa_def *)(uintptr_t)blob_read_uint32(ctx->blob); + nir_block *pred = (nir_block *)(uintptr_t)blob_read_uint32(ctx->blob); nir_phi_src *src = nir_phi_instr_add_src(phi, pred, nir_src_for_ssa(def)); /* Since we're not letting nir_insert_instr handle use/def stuff for us, @@ -1970,7 +1969,7 @@ read_xfb_info(read_ctx *ctx) void nir_serialize(struct blob *blob, const nir_shader *nir, bool strip) { - write_ctx ctx = {0}; + write_ctx ctx = { 0 }; ctx.remap_table = _mesa_pointer_hash_table_create(NULL); ctx.blob = blob; ctx.nir = nir; @@ -1991,7 +1990,7 @@ nir_serialize(struct blob *blob, const nir_shader *nir, bool strip) if (!strip && info.label) blob_write_string(blob, info.label); info.name = info.label = NULL; - blob_write_bytes(blob, (uint8_t *) &info, sizeof(info)); + blob_write_bytes(blob, (uint8_t *)&info, sizeof(info)); write_var_list(&ctx, &nir->variables); @@ -2041,7 +2040,7 @@ nir_deserialize(void *mem_ctx, const struct nir_shader_compiler_options *options, struct blob_reader *blob) { - read_ctx ctx = {0}; + read_ctx ctx = { 0 }; ctx.blob = blob; list_inithead(&ctx.phi_srcs); ctx.idx_table_len = blob_read_uint32(blob); @@ -2052,7 +2051,7 @@ nir_deserialize(void *mem_ctx, char *label = (strings & 0x2) ? blob_read_string(blob) : NULL; struct shader_info info; - blob_copy_bytes(blob, (uint8_t *) &info, sizeof(info)); + blob_copy_bytes(blob, (uint8_t *)&info, sizeof(info)); ctx.nir = nir_shader_create(mem_ctx, info.stage, options, NULL); diff --git a/src/compiler/nir/nir_serialize.h b/src/compiler/nir/nir_serialize.h index e813f2c..d20c6df 100644 --- a/src/compiler/nir/nir_serialize.h +++ b/src/compiler/nir/nir_serialize.h @@ -24,8 +24,8 @@ #ifndef _NIR_SERIALIZE_H #define _NIR_SERIALIZE_H -#include "nir.h" #include "util/blob.h" +#include "nir.h" #ifdef __cplusplus extern "C" { diff --git a/src/compiler/nir/nir_split_64bit_vec3_and_vec4.c b/src/compiler/nir/nir_split_64bit_vec3_and_vec4.c index 3c09dff..973aa4e 100644 --- a/src/compiler/nir/nir_split_64bit_vec3_and_vec4.c +++ b/src/compiler/nir/nir_split_64bit_vec3_and_vec4.c @@ -27,8 +27,8 @@ #include "nir.h" #include "nir_builder.h" -#include "nir_deref.h" #include "util/hash_table.h" +#include "nir_deref.h" /* This pass splits stores to and loads from 64 bit vec3 * and vec4 local variables to use at most vec2, and it also @@ -43,7 +43,7 @@ nir_split_64bit_vec3_and_vec4_filter(const nir_instr *instr, const void *data) { switch (instr->type) { - case nir_instr_type_intrinsic: { + case nir_instr_type_intrinsic: { nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); switch (intr->intrinsic) { @@ -63,16 +63,16 @@ nir_split_64bit_vec3_and_vec4_filter(const nir_instr *instr, return false; return nir_src_num_components(intr->src[1]) >= 3; default: - return false; - } + return false; + } } } case nir_instr_type_phi: { - nir_phi_instr *phi = nir_instr_as_phi(instr); - if (nir_dest_bit_size(phi->dest) != 64) - return false; - return nir_dest_num_components(phi->dest) >= 3; - } + nir_phi_instr *phi = nir_instr_as_phi(instr); + if (nir_dest_bit_size(phi->dest) != 64) + return false; + return nir_dest_num_components(phi->dest) >= 3; + } default: return false; @@ -84,7 +84,6 @@ typedef struct { nir_variable *zw; } variable_pair; - static nir_ssa_def * merge_to_vec3_or_vec4(nir_builder *b, nir_ssa_def *load1, nir_ssa_def *load2) @@ -128,14 +127,13 @@ get_linear_array_offset(nir_builder *b, nir_deref_instr *deref) return offset; } - static variable_pair * get_var_pair(nir_builder *b, nir_variable *old_var, - struct hash_table *split_vars) + struct hash_table *split_vars) { variable_pair *new_var = NULL; unsigned old_components = glsl_get_components( - glsl_without_array_or_matrix(old_var->type)); + glsl_without_array_or_matrix(old_var->type)); assert(old_components > 2 && old_components <= 4); @@ -161,7 +159,7 @@ get_var_pair(nir_builder *b, nir_variable *old_var, _mesa_hash_table_insert(split_vars, old_var, new_var); } else - new_var = (variable_pair *)entry->data; + new_var = (variable_pair *)entry->data; return new_var; } @@ -171,7 +169,7 @@ split_load_deref(nir_builder *b, nir_intrinsic_instr *intr, { nir_variable *old_var = nir_intrinsic_get_var(intr, 0); unsigned old_components = glsl_get_components( - glsl_without_array_or_matrix(old_var->type)); + glsl_without_array_or_matrix(old_var->type)); variable_pair *vars = get_var_pair(b, old_var, split_vars); @@ -230,7 +228,7 @@ split_phi(nir_builder *b, nir_phi_instr *phi) nir_ssa_dest_init(&vec->instr, &vec->dest.dest, phi->dest.ssa.num_components, 64); - int num_comp[2] = {2, phi->dest.ssa.num_components - 2}; + int num_comp[2] = { 2, phi->dest.ssa.num_components - 2 }; nir_phi_instr *new_phi[2]; @@ -275,26 +273,25 @@ nir_split_64bit_vec3_and_vec4_impl(nir_builder *b, nir_instr *instr, void *d) case nir_intrinsic_load_deref: { nir_deref_instr *deref = - nir_instr_as_deref(intr->src[0].ssa->parent_instr); + nir_instr_as_deref(intr->src[0].ssa->parent_instr); if (deref->deref_type == nir_deref_type_var) return split_load_deref(b, intr, NULL, split_vars); else if (deref->deref_type == nir_deref_type_array) { return split_load_deref(b, intr, get_linear_array_offset(b, deref), split_vars); - } - else + } else unreachable("Only splitting of loads from vars and arrays"); } case nir_intrinsic_store_deref: { nir_deref_instr *deref = - nir_instr_as_deref(intr->src[0].ssa->parent_instr); + nir_instr_as_deref(intr->src[0].ssa->parent_instr); if (deref->deref_type == nir_deref_type_var) return split_store_deref(b, intr, NULL, split_vars); else if (deref->deref_type == nir_deref_type_array) - return split_store_deref(b, intr, get_linear_array_offset(b, deref), split_vars); + return split_store_deref(b, intr, get_linear_array_offset(b, deref), split_vars); else unreachable("Only splitting of stores to vars and arrays"); - } + } default: unreachable("Only splitting load_deref and store_deref"); @@ -313,17 +310,16 @@ nir_split_64bit_vec3_and_vec4_impl(nir_builder *b, nir_instr *instr, void *d) return NULL; } - bool nir_split_64bit_vec3_and_vec4(nir_shader *sh) { struct hash_table *split_vars = _mesa_pointer_hash_table_create(NULL); bool progress = - nir_shader_lower_instructions(sh, - nir_split_64bit_vec3_and_vec4_filter, - nir_split_64bit_vec3_and_vec4_impl, - split_vars); + nir_shader_lower_instructions(sh, + nir_split_64bit_vec3_and_vec4_filter, + nir_split_64bit_vec3_and_vec4_impl, + split_vars); _mesa_hash_table_destroy(split_vars, NULL); return progress; diff --git a/src/compiler/nir/nir_split_per_member_structs.c b/src/compiler/nir/nir_split_per_member_structs.c index 2e92012..d761a51 100644 --- a/src/compiler/nir/nir_split_per_member_structs.c +++ b/src/compiler/nir/nir_split_per_member_structs.c @@ -166,9 +166,7 @@ nir_split_per_member_structs(nir_shader *shader) struct hash_table *var_to_member_map = _mesa_pointer_hash_table_create(dead_ctx); - nir_foreach_variable_with_modes_safe(var, shader, nir_var_shader_in | - nir_var_shader_out | - nir_var_system_value) { + nir_foreach_variable_with_modes_safe(var, shader, nir_var_shader_in | nir_var_shader_out | nir_var_system_value) { if (var->num_members == 0) continue; @@ -184,7 +182,7 @@ nir_split_per_member_structs(nir_shader *shader) nir_shader_instructions_pass(shader, rewrite_deref_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, var_to_member_map); ralloc_free(dead_ctx); diff --git a/src/compiler/nir/nir_split_var_copies.c b/src/compiler/nir/nir_split_var_copies.c index 83a90ef..9723368 100644 --- a/src/compiler/nir/nir_split_var_copies.c +++ b/src/compiler/nir/nir_split_var_copies.c @@ -71,14 +71,14 @@ split_deref_copy_instr(nir_builder *b, } else if (glsl_type_is_struct_or_ifc(src->type)) { for (unsigned i = 0; i < glsl_get_length(src->type); i++) { split_deref_copy_instr(b, nir_build_deref_struct(b, dst, i), - nir_build_deref_struct(b, src, i), - dst_access, src_access); + nir_build_deref_struct(b, src, i), + dst_access, src_access); } } else { assert(glsl_type_is_matrix(src->type) || glsl_type_is_array(src->type)); split_deref_copy_instr(b, nir_build_deref_array_wildcard(b, dst), - nir_build_deref_array_wildcard(b, src), - dst_access, src_access); + nir_build_deref_array_wildcard(b, src), + dst_access, src_access); } } @@ -108,6 +108,6 @@ nir_split_var_copies(nir_shader *shader) { return nir_shader_instructions_pass(shader, split_var_copies_instr, nir_metadata_block_index | - nir_metadata_dominance, + nir_metadata_dominance, NULL); } diff --git a/src/compiler/nir/nir_split_vars.c b/src/compiler/nir/nir_split_vars.c index dea2133..73d5c41 100644 --- a/src/compiler/nir/nir_split_vars.c +++ b/src/compiler/nir/nir_split_vars.c @@ -129,7 +129,7 @@ init_field_for_type(struct field *field, struct field *parent, const char *name, struct split_var_state *state) { - *field = (struct field) { + *field = (struct field){ .parent = parent, .type = type, }; @@ -361,7 +361,7 @@ nir_split_struct_vars(nir_shader *shader, nir_variable_mode modes) modes, mem_ctx); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); progress = true; } else { nir_metadata_preserve(impl, nir_metadata_all); @@ -427,7 +427,7 @@ init_var_list_array_infos(nir_shader *shader, struct array_var_info *info = rzalloc_size(mem_ctx, sizeof(*info) + - num_levels * sizeof(info->levels[0])); + num_levels * sizeof(info->levels[0])); info->base_var = var; info->num_levels = num_levels; @@ -770,7 +770,7 @@ split_array_copies_impl(nir_function_impl *impl, b.cursor = nir_instr_remove(©->instr); emit_split_copies(&b, dst_info, &dst_path, 0, dst_path.path[0], - src_info, &src_path, 0, src_path.path[0]); + src_info, &src_path, 0, src_path.path[0]); } } } @@ -835,7 +835,7 @@ split_array_access_impl(nir_function_impl *impl, if (intrin->intrinsic == nir_intrinsic_load_deref) { nir_ssa_def *u = nir_ssa_undef(&b, intrin->dest.ssa.num_components, - intrin->dest.ssa.bit_size); + intrin->dest.ssa.bit_size); nir_ssa_def_rewrite_uses(&intrin->dest.ssa, u); } @@ -952,7 +952,7 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes) split_array_access_impl(impl, var_info_map, modes, mem_ctx); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); progress = true; } else { nir_metadata_preserve(impl, nir_metadata_all); @@ -1017,7 +1017,7 @@ get_vec_var_usage(nir_variable *var, struct vec_var_usage *usage = rzalloc_size(mem_ctx, sizeof(*usage) + - num_levels * sizeof(usage->levels[0])); + num_levels * sizeof(usage->levels[0])); usage->num_levels = num_levels; const struct glsl_type *type = var->type; @@ -1131,8 +1131,7 @@ mark_deref_used(nir_deref_instr *deref, unsigned max_used; if (deref->deref_type == nir_deref_type_array) { - max_used = nir_src_is_const(deref->arr.index) ? - nir_src_as_uint(deref->arr.index) : UINT_MAX; + max_used = nir_src_is_const(deref->arr.index) ? nir_src_as_uint(deref->arr.index) : UINT_MAX; } else { /* For wildcards, we read or wrote the whole thing. */ assert(deref->deref_type == nir_deref_type_array_wildcard); @@ -1554,7 +1553,7 @@ shrink_vec_var_access_impl(nir_function_impl *impl, if (intrin->intrinsic == nir_intrinsic_load_deref) { nir_ssa_def *u = nir_ssa_undef(&b, intrin->dest.ssa.num_components, - intrin->dest.ssa.bit_size); + intrin->dest.ssa.bit_size); nir_ssa_def_rewrite_uses(&intrin->dest.ssa, u); } @@ -1706,7 +1705,7 @@ nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes) shrink_vec_var_access_impl(impl, var_usage_map, modes); nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); progress = true; } else { nir_metadata_preserve(impl, nir_metadata_all); diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c index 5ac7f59..5eeedf7 100644 --- a/src/compiler/nir/nir_sweep.c +++ b/src/compiler/nir/nir_sweep.c @@ -35,8 +35,10 @@ * earlier, and even many times, trading CPU cycles for memory savings. */ -#define steal_list(mem_ctx, type, list) \ - foreach_list_typed(type, obj, node, list) { ralloc_steal(mem_ctx, obj); } +#define steal_list(mem_ctx, type, list) \ + foreach_list_typed(type, obj, node, list) { \ + ralloc_steal(mem_ctx, obj); \ + } static void sweep_cf_node(nir_shader *nir, nir_cf_node *cf_node); diff --git a/src/compiler/nir/nir_to_lcssa.c b/src/compiler/nir/nir_to_lcssa.c index fb7be32..d6805f0 100644 --- a/src/compiler/nir/nir_to_lcssa.c +++ b/src/compiler/nir/nir_to_lcssa.c @@ -156,7 +156,6 @@ phi_is_invariant(nir_phi_instr *instr, nir_loop *loop) return invariant; } - /* An instruction is said to be loop-invariant if it * - has no sideeffects and * - solely depends on variables defined outside of the loop or @@ -180,7 +179,7 @@ instr_is_invariant(nir_instr *instr, nir_loop *loop) if (!(nir_intrinsic_infos[intrinsic->intrinsic].flags & NIR_INTRINSIC_CAN_REORDER)) return not_invariant; } - FALLTHROUGH; + FALLTHROUGH; default: return nir_foreach_src(instr, src_is_invariant, loop) ? invariant : not_invariant; } @@ -351,7 +350,7 @@ convert_to_lcssa(nir_cf_node *cf_node, lcssa_state *state) } } -end: + end: /* For outer loops, the LCSSA-phi should be considered not invariant */ if (state->skip_invariants) { nir_foreach_instr(instr, state->block_after_loop) { @@ -382,7 +381,7 @@ nir_convert_loop_to_lcssa(nir_loop *loop) state->skip_invariants = false; state->skip_bool_invariants = false; - nir_foreach_block_in_cf_node (block, &loop->cf_node) { + nir_foreach_block_in_cf_node(block, &loop->cf_node) { nir_foreach_instr(instr, block) nir_foreach_ssa_def(instr, convert_loop_exit_for_ssa, state); } @@ -409,7 +408,7 @@ nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants, bool skip_bool_in if (state->progress) { progress = true; nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); + nir_metadata_dominance); } else { nir_metadata_preserve(impl, nir_metadata_all); } @@ -418,4 +417,3 @@ nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants, bool skip_bool_in ralloc_free(state); return progress; } - diff --git a/src/compiler/nir/nir_trivialize_registers.c b/src/compiler/nir/nir_trivialize_registers.c index 954d9aa..278aa1d 100644 --- a/src/compiler/nir/nir_trivialize_registers.c +++ b/src/compiler/nir/nir_trivialize_registers.c @@ -86,7 +86,7 @@ move_reg_decls(nir_block *block) } } - /* +/* * Any load can be trivialized by copying immediately after the load and then * rewriting uses of the load to read from the copy. That has no functional * change, but it means that for every use of the load (the copy), there is no @@ -363,7 +363,6 @@ trivialize_source(nir_src *src, void *state) trivialize_read_after_write(load_reg, possibly_trivial_stores); return true; - } static void diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index d382ff6..786a155 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -25,11 +25,11 @@ * */ -#include "nir.h" -#include "nir_xfb_info.h" +#include #include "c11/threads.h" #include "util/simple_mtx.h" -#include +#include "nir.h" +#include "nir_xfb_info.h" /* * This file checks for invalid IR indicating a bug somewhere in the compiler. @@ -118,7 +118,6 @@ validate_assert_impl(validate_state *state, bool cond, const char *str, #define validate_assert(state, cond) \ validate_assert_impl(state, (cond), #cond, __FILE__, __LINE__) - static void validate_src(nir_src *src, validate_state *state, unsigned bit_sizes, unsigned num_components); @@ -239,7 +238,7 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state) if (nir_alu_type_get_base_type(src_type) == nir_type_float) { /* 8-bit float isn't a thing */ validate_assert(state, src_bit_size == 16 || src_bit_size == 32 || - src_bit_size == 64); + src_bit_size == 64); } /* In nir_opcodes.py, these are defined to take general uint or int @@ -273,7 +272,7 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state) if (nir_alu_type_get_base_type(dest_type) == nir_type_float) { /* 8-bit float isn't a thing */ validate_assert(state, dest_bit_size == 16 || dest_bit_size == 32 || - dest_bit_size == 64); + dest_bit_size == 64); } validate_alu_dest(instr, state); @@ -285,7 +284,7 @@ validate_var_use(nir_variable *var, validate_state *state) struct hash_entry *entry = _mesa_hash_table_search(state->var_defs, var); validate_assert(state, entry); if (entry && var->data.mode == nir_var_function_temp) - validate_assert(state, (nir_function_impl *) entry->data == state->impl); + validate_assert(state, (nir_function_impl *)entry->data == state->impl); } static void @@ -345,9 +344,9 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state) case nir_deref_type_struct: validate_assert(state, glsl_type_is_struct_or_ifc(parent->type)); validate_assert(state, - instr->strct.index < glsl_get_length(parent->type)); + instr->strct.index < glsl_get_length(parent->type)); validate_assert(state, instr->type == - glsl_get_struct_field(parent->type, instr->strct.index)); + glsl_get_struct_field(parent->type, instr->strct.index)); break; case nir_deref_type_array: @@ -358,15 +357,15 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state) * Fortunately, nir_lower_io handles these just fine. */ validate_assert(state, glsl_type_is_array(parent->type) || - glsl_type_is_matrix(parent->type) || - glsl_type_is_vector(parent->type)); + glsl_type_is_matrix(parent->type) || + glsl_type_is_vector(parent->type)); } else { /* Most of NIR cannot handle array derefs on vectors */ validate_assert(state, glsl_type_is_array(parent->type) || - glsl_type_is_matrix(parent->type)); + glsl_type_is_matrix(parent->type)); } validate_assert(state, - instr->type == glsl_get_array_element(parent->type)); + instr->type == glsl_get_array_element(parent->type)); if (instr->deref_type == nir_deref_type_array) { validate_src(&instr->arr.index, state, @@ -381,8 +380,8 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state) */ validate_assert(state, parent->deref_type == nir_deref_type_array || - parent->deref_type == nir_deref_type_ptr_as_array || - parent->deref_type == nir_deref_type_cast); + parent->deref_type == nir_deref_type_ptr_as_array || + parent->deref_type == nir_deref_type_cast); validate_src(&instr->arr.index, state, nir_dest_bit_size(instr->dest), 1); break; @@ -479,7 +478,9 @@ static void validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) { unsigned dest_bit_size = 0; - unsigned src_bit_sizes[NIR_INTRINSIC_MAX_INPUTS] = { 0, }; + unsigned src_bit_sizes[NIR_INTRINSIC_MAX_INPUTS] = { + 0, + }; switch (instr->intrinsic) { case nir_intrinsic_decl_reg: assert(state->block == nir_start_block(state->impl)); @@ -522,10 +523,10 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) nir_deref_instr *src = nir_src_as_deref(instr->src[0]); assert(src); validate_assert(state, glsl_type_is_vector_or_scalar(src->type) || - (src->modes == nir_var_uniform && - glsl_get_base_type(src->type) == GLSL_TYPE_SUBROUTINE)); + (src->modes == nir_var_uniform && + glsl_get_base_type(src->type) == GLSL_TYPE_SUBROUTINE)); validate_assert(state, instr->num_components == - glsl_get_vector_elements(src->type)); + glsl_get_vector_elements(src->type)); dest_bit_size = glsl_get_bit_size(src->type); /* Also allow 32-bit boolean load operations */ if (glsl_type_is_boolean(src->type)) @@ -538,7 +539,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) assert(dst); validate_assert(state, glsl_type_is_vector_or_scalar(dst->type)); validate_assert(state, instr->num_components == - glsl_get_vector_elements(dst->type)); + glsl_get_vector_elements(dst->type)); src_bit_sizes[1] = glsl_get_bit_size(dst->type); /* Also allow 32-bit boolean store operations */ if (glsl_type_is_boolean(dst->type)) @@ -551,7 +552,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) nir_deref_instr *dst = nir_src_as_deref(instr->src[0]); nir_deref_instr *src = nir_src_as_deref(instr->src[1]); validate_assert(state, glsl_get_bare_type(dst->type) == - glsl_get_bare_type(src->type)); + glsl_get_bare_type(src->type)); validate_assert(state, !nir_deref_mode_may_be(dst, nir_var_read_only_modes)); /* FIXME: now that we track if the var copies were lowered, it would be * good to validate here that no new copy derefs were added. Right now @@ -566,7 +567,9 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) int bit_size = nir_dest_bit_size(instr->dest); validate_assert(state, bit_size >= 8); validate_assert(state, (nir_intrinsic_component(instr) + - instr->num_components) * (bit_size / 8) <= 16); + instr->num_components) * + (bit_size / 8) <= + 16); break; } @@ -582,9 +585,9 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) case nir_intrinsic_load_constant: /* These memory load operations must have alignments */ validate_assert(state, - util_is_power_of_two_nonzero(nir_intrinsic_align_mul(instr))); + util_is_power_of_two_nonzero(nir_intrinsic_align_mul(instr))); validate_assert(state, nir_intrinsic_align_offset(instr) < - nir_intrinsic_align_mul(instr)); + nir_intrinsic_align_mul(instr)); FALLTHROUGH; case nir_intrinsic_load_uniform: @@ -605,9 +608,9 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) case nir_intrinsic_store_scratch: /* These memory store operations must also have alignments */ validate_assert(state, - util_is_power_of_two_nonzero(nir_intrinsic_align_mul(instr))); + util_is_power_of_two_nonzero(nir_intrinsic_align_mul(instr))); validate_assert(state, nir_intrinsic_align_offset(instr) < - nir_intrinsic_align_mul(instr)); + nir_intrinsic_align_mul(instr)); FALLTHROUGH; case nir_intrinsic_store_output: @@ -619,7 +622,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) case nir_intrinsic_deref_mode_is: case nir_intrinsic_addr_mode_is: validate_assert(state, - util_bitcount(nir_intrinsic_memory_modes(instr)) == 1); + util_bitcount(nir_intrinsic_memory_modes(instr)) == 1); break; case nir_intrinsic_image_deref_atomic: @@ -655,7 +658,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) validate_assert(state, allowed); validate_assert(state, nir_dest_bit_size(instr->dest) == - util_format_get_blocksizebits(format)); + util_format_get_blocksizebits(format)); } break; } @@ -667,7 +670,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) /* Make sure the writemask is derived from the component count. */ validate_assert(state, writemask == - BITFIELD_MASK(nir_src_num_components(instr->src[0]))); + BITFIELD_MASK(nir_src_num_components(instr->src[0]))); } break; @@ -715,8 +718,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) unsigned used_mask = 0; for (unsigned i = 0; i < 4; i++) { - nir_io_xfb xfb = i < 2 ? nir_intrinsic_io_xfb(instr) : - nir_intrinsic_io_xfb2(instr); + nir_io_xfb xfb = i < 2 ? nir_intrinsic_io_xfb(instr) : nir_intrinsic_io_xfb2(instr); unsigned xfb_mask = BITFIELD_RANGE(i, xfb.out[i % 2].num_components); /* Each component can be used only once by transform feedback info. */ @@ -733,8 +735,8 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) validate_assert(state, (nir_slot_is_sysval_output(sem.location, MESA_SHADER_NONE) && !sem.no_sysval_output) || - (nir_slot_is_varying(sem.location) && !sem.no_varying) || - nir_instr_xfb_write_mask(instr)); + (nir_slot_is_varying(sem.location) && !sem.no_varying) || + nir_instr_xfb_write_mask(instr)); } } @@ -759,14 +761,14 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state) case nir_tex_src_bias: validate_assert(state, instr->op == nir_texop_txb || - instr->op == nir_texop_tg4); + instr->op == nir_texop_tg4); break; case nir_tex_src_lod: validate_assert(state, instr->op != nir_texop_tex && - instr->op != nir_texop_txb && - instr->op != nir_texop_txd && - instr->op != nir_texop_lod); + instr->op != nir_texop_txb && + instr->op != nir_texop_txd && + instr->op != nir_texop_lod); break; case nir_tex_src_ddx: @@ -780,8 +782,8 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state) break; validate_assert(state, glsl_type_is_image(deref->type) || - glsl_type_is_texture(deref->type) || - glsl_type_is_sampler(deref->type)); + glsl_type_is_texture(deref->type) || + glsl_type_is_sampler(deref->type)); switch (instr->op) { case nir_texop_descriptor_amd: case nir_texop_sampler_descriptor_amd: @@ -799,15 +801,15 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state) case nir_texop_fragment_mask_fetch_amd: case nir_texop_txf_ms_mcs_intel: validate_assert(state, nir_alu_type_get_base_type(instr->dest_type) == nir_type_int || - nir_alu_type_get_base_type(instr->dest_type) == nir_type_uint); + nir_alu_type_get_base_type(instr->dest_type) == nir_type_uint); break; default: validate_assert(state, glsl_get_sampler_result_type(deref->type) == GLSL_TYPE_VOID || - glsl_base_type_is_integer(glsl_get_sampler_result_type(deref->type)) == - (nir_alu_type_get_base_type(instr->dest_type) == nir_type_int || - nir_alu_type_get_base_type(instr->dest_type) == nir_type_uint)); + glsl_base_type_is_integer(glsl_get_sampler_result_type(deref->type)) == + (nir_alu_type_get_base_type(instr->dest_type) == nir_type_int || + nir_alu_type_get_base_type(instr->dest_type) == nir_type_uint)); } break; } @@ -862,7 +864,7 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state) unsigned bit_size = nir_alu_type_get_type_size(instr->dest_type); validate_assert(state, (bit_size ? bit_size : 32) == - nir_dest_bit_size(instr->dest)); + nir_dest_bit_size(instr->dest)); } static void @@ -938,7 +940,7 @@ validate_phi_instr(nir_phi_instr *instr, validate_state *state) exec_list_validate(&instr->srcs); validate_assert(state, exec_list_length(&instr->srcs) == - state->block->predecessors->entries); + state->block->predecessors->entries); } static void @@ -1062,7 +1064,6 @@ validate_phi_src(nir_phi_instr *instr, nir_block *pred, validate_state *state) { state->instr = &instr->instr; - exec_list_validate(&instr->srcs); nir_foreach_phi_src(src, instr) { if (src->pred == pred) { @@ -1144,7 +1145,7 @@ validate_block_predecessors(nir_block *block, validate_state *state) /* And we have to be in our successor's predecessors set */ validate_assert(state, - _mesa_set_search(block->successors[i]->predecessors, block)); + _mesa_set_search(block->successors[i]->predecessors, block)); validate_phi_srcs(block, block->successors[i], state); } @@ -1157,7 +1158,7 @@ validate_block_predecessors(nir_block *block, validate_state *state) const nir_block *pred = entry->key; validate_assert(state, _mesa_set_search(state->blocks, pred)); validate_assert(state, pred->successors[0] == block || - pred->successors[1] == block); + pred->successors[1] == block); } } @@ -1172,7 +1173,7 @@ validate_block(nir_block *block, validate_state *state) nir_foreach_instr(instr, block) { if (instr->type == nir_instr_type_phi) { validate_assert(state, instr == nir_block_first_instr(block) || - nir_instr_prev(instr)->type == nir_instr_type_phi); + nir_instr_prev(instr)->type == nir_instr_type_phi); } validate_instr(instr, state); @@ -1194,7 +1195,7 @@ validate_block(nir_block *block, validate_state *state) validate_assert(state, block->successors[0] == cont); } else { validate_assert(state, nir_loop_has_continue_construct(state->loop) && - block == nir_loop_last_continue_block(state->loop)); + block == nir_loop_last_continue_block(state->loop)); nir_block *head = nir_loop_first_block(state->loop); validate_assert(state, block->successors[0] == head); } @@ -1224,23 +1225,22 @@ validate_block(nir_block *block, validate_state *state) if (next->type == nir_cf_node_if) { nir_if *if_stmt = nir_cf_node_as_if(next); validate_assert(state, block->successors[0] == - nir_if_first_then_block(if_stmt)); + nir_if_first_then_block(if_stmt)); validate_assert(state, block->successors[1] == - nir_if_first_else_block(if_stmt)); + nir_if_first_else_block(if_stmt)); } else if (next->type == nir_cf_node_loop) { nir_loop *loop = nir_cf_node_as_loop(next); validate_assert(state, block->successors[0] == - nir_loop_first_block(loop)); + nir_loop_first_block(loop)); validate_assert(state, block->successors[1] == NULL); } else { validate_assert(state, - !"Structured NIR cannot have consecutive blocks"); + !"Structured NIR cannot have consecutive blocks"); } } } } - static void validate_end_block(nir_block *block, validate_state *state) { @@ -1433,8 +1433,7 @@ validate_var_decl(nir_variable *var, nir_variable_mode valid_modes, */ _mesa_hash_table_insert(state->var_defs, var, - valid_modes == nir_var_function_temp ? - state->impl : NULL); + valid_modes == nir_var_function_temp ? state->impl : NULL); state->var = NULL; } @@ -1480,8 +1479,8 @@ validate_ssa_dominance(nir_function_impl *impl, validate_state *state) nir_phi_instr *phi = nir_instr_as_phi(instr); nir_foreach_phi_src(src, phi) { validate_assert(state, - nir_block_dominates(src->src.ssa->parent_instr->block, - src->pred)); + nir_block_dominates(src->src.ssa->parent_instr->block, + src->pred)); } } else { nir_foreach_src(instr, validate_src_dominance, state); @@ -1525,8 +1524,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state) state->ssa_defs_found = reralloc(state->mem_ctx, state->ssa_defs_found, BITSET_WORD, BITSET_WORDS(impl->ssa_alloc)); - memset(state->ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * - sizeof(BITSET_WORD)); + memset(state->ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * sizeof(BITSET_WORD)); _mesa_set_clear(state->blocks, NULL); _mesa_set_resize(state->blocks, impl->num_blocks); @@ -1547,8 +1545,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state) NIR_DEBUG(VALIDATE_SSA_DOMINANCE); } if (validate_dominance) { - memset(state->ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * - sizeof(BITSET_WORD)); + memset(state->ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * sizeof(BITSET_WORD)); validate_ssa_dominance(impl, state); } } @@ -1658,7 +1655,7 @@ nir_validate_shader(nir_shader *shader, const char *when) exec_list_validate(&shader->variables); nir_foreach_variable_in_shader(var, shader) - validate_var_decl(var, valid_modes, &state); + validate_var_decl(var, valid_modes, &state); exec_list_validate(&shader->functions); foreach_list_typed(nir_function, func, node, &shader->functions) { @@ -1670,8 +1667,8 @@ nir_validate_shader(nir_shader *shader, const char *when) * has real transform feedback going on. */ validate_assert(&state, shader->info.stage == MESA_SHADER_VERTEX || - shader->info.stage == MESA_SHADER_TESS_EVAL || - shader->info.stage == MESA_SHADER_GEOMETRY); + shader->info.stage == MESA_SHADER_TESS_EVAL || + shader->info.stage == MESA_SHADER_GEOMETRY); validate_assert(&state, shader->xfb_info->buffers_written != 0); validate_assert(&state, shader->xfb_info->streams_written != 0); validate_assert(&state, shader->xfb_info->output_count > 0); @@ -1698,8 +1695,7 @@ nir_validate_ssa_dominance(nir_shader *shader, const char *when) state.ssa_defs_found = reralloc(state.mem_ctx, state.ssa_defs_found, BITSET_WORD, BITSET_WORDS(impl->ssa_alloc)); - memset(state.ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * - sizeof(BITSET_WORD)); + memset(state.ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * sizeof(BITSET_WORD)); state.impl = impl; validate_ssa_dominance(impl, &state); diff --git a/src/compiler/nir/nir_vla.h b/src/compiler/nir/nir_vla.h index d01c039..b80d1ce 100644 --- a/src/compiler/nir/nir_vla.h +++ b/src/compiler/nir/nir_vla.h @@ -30,12 +30,10 @@ #include "c99_alloca.h" - /* Declare a variable length array, with no initialization */ #define NIR_VLA(_type, _name, _length) \ _type *_name = alloca((_length) * sizeof *_name) - /* Declare a variable length array, and initialize it with the given byte. * * _length is evaluated twice, so expressions with side-effects must be @@ -44,7 +42,6 @@ #define NIR_VLA_FILL(_type, _name, _length, _byte) \ _type *_name = memset(alloca((_length) * sizeof *_name), _byte, (_length) * sizeof *_name) - /* Declare a variable length array, and zero it. * * Just like NIR_VLA_FILL, _length is evaluated twice, so expressions with diff --git a/src/compiler/nir/nir_worklist.h b/src/compiler/nir/nir_worklist.h index 736bd83..e8cb7ee 100644 --- a/src/compiler/nir/nir_worklist.h +++ b/src/compiler/nir/nir_worklist.h @@ -24,10 +24,10 @@ #ifndef _NIR_WORKLIST_ #define _NIR_WORKLIST_ -#include "nir.h" #include "util/set.h" #include "util/u_vector.h" #include "util/u_worklist.h" +#include "nir.h" #ifdef __cplusplus extern "C" { @@ -36,29 +36,29 @@ extern "C" { typedef u_worklist nir_block_worklist; #define nir_block_worklist_init(w, num_blocks, mem_ctx) \ - u_worklist_init(w, num_blocks, mem_ctx) + u_worklist_init(w, num_blocks, mem_ctx) #define nir_block_worklist_fini(w) u_worklist_fini(w) #define nir_block_worklist_is_empty(w) u_worklist_is_empty(w) #define nir_block_worklist_push_head(w, block) \ - u_worklist_push_head(w, block, index) + u_worklist_push_head(w, block, index) #define nir_block_worklist_peek_head(w) \ - u_worklist_peek_head(w, nir_block, index) + u_worklist_peek_head(w, nir_block, index) #define nir_block_worklist_pop_head(w) \ - u_worklist_pop_head(w, nir_block, index) + u_worklist_pop_head(w, nir_block, index) #define nir_block_worklist_push_tail(w, block) \ - u_worklist_push_tail(w, block, index) + u_worklist_push_tail(w, block, index) #define nir_block_worklist_peek_tail(w) \ - u_worklist_peek_tail(w, nir_block, index) + u_worklist_peek_tail(w, nir_block, index) #define nir_block_worklist_pop_tail(w) \ - u_worklist_pop_tail(w, nir_block, index) + u_worklist_pop_tail(w, nir_block, index) void nir_block_worklist_add_all(nir_block_worklist *w, nir_function_impl *impl); @@ -79,7 +79,8 @@ typedef struct { } nir_instr_worklist; static inline nir_instr_worklist * -nir_instr_worklist_create() { +nir_instr_worklist_create() +{ nir_instr_worklist *wl = malloc(sizeof(nir_instr_worklist)); if (!wl) return NULL; @@ -133,7 +134,7 @@ void nir_instr_worklist_add_ssa_srcs(nir_instr_worklist *wl, nir_instr *instr); #define nir_foreach_instr_in_worklist(instr, wl) \ - for (nir_instr *instr; (instr = nir_instr_worklist_pop_head(wl));) + for (nir_instr * instr; (instr = nir_instr_worklist_pop_head(wl));) #ifdef __cplusplus } /* extern "C" */