From 93f047b6ffa5e9d2db0491b1885c60a9df88ac19 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Fri, 5 May 2023 21:34:16 +0200 Subject: [PATCH] gallivm: Zero initialize param structs Zero all param structs using {0} because it's shorter than a memset and there were some instances where the structs weren't zero initialized. Reviewed-by: Dave Airlie Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 13 ++++--------- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 24 +++++++----------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index db12c0f..a155586 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1622,9 +1622,8 @@ visit_load_image(struct lp_build_nir_context *bld_base, LLVMBuilderRef builder = gallivm->builder; LLVMValueRef coord_val = get_src(bld_base, instr->src[1]); LLVMValueRef coords[5]; - struct lp_img_params params; + struct lp_img_params params = { 0 }; - memset(¶ms, 0, sizeof(params)); params.target = glsl_sampler_to_pipe(nir_intrinsic_image_dim(instr), nir_intrinsic_image_array(instr)); for (unsigned i = 0; i < 4; i++) @@ -1656,9 +1655,8 @@ visit_store_image(struct lp_build_nir_context *bld_base, LLVMValueRef coord_val = get_src(bld_base, instr->src[1]); LLVMValueRef in_val = get_src(bld_base, instr->src[3]); LLVMValueRef coords[5]; - struct lp_img_params params; + struct lp_img_params params = { 0 }; - memset(¶ms, 0, sizeof(params)); params.target = glsl_sampler_to_pipe(nir_intrinsic_image_dim(instr), nir_intrinsic_image_array(instr)); for (unsigned i = 0; i < 4; i++) coords[i] = LLVMBuildExtractValue(builder, coord_val, i, ""); @@ -1743,13 +1741,11 @@ visit_atomic_image(struct lp_build_nir_context *bld_base, { struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; - struct lp_img_params params; + struct lp_img_params params = { 0 }; LLVMValueRef coord_val = get_src(bld_base, instr->src[1]); LLVMValueRef in_val = get_src(bld_base, instr->src[3]); LLVMValueRef coords[5]; - memset(¶ms, 0, sizeof(params)); - params.target = glsl_sampler_to_pipe(nir_intrinsic_image_dim(instr), nir_intrinsic_image_array(instr)); for (unsigned i = 0; i < 4; i++) { @@ -2418,7 +2414,7 @@ visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *instr) LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; LLVMValueRef explicit_lod = NULL, ms_index = NULL; - struct lp_sampler_params params; + struct lp_sampler_params params = { 0 }; struct lp_derivatives derivs; nir_deref_instr *texture_deref_instr = NULL; nir_deref_instr *sampler_deref_instr = NULL; @@ -2426,7 +2422,6 @@ visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *instr) LLVMValueRef texel[NIR_MAX_VEC_COMPONENTS]; LLVMValueRef coord_undef = LLVMGetUndef(bld_base->base.vec_type); unsigned coord_vals = is_aos(bld_base) ? 1 : instr->coord_components; - memset(¶ms, 0, sizeof(params)); for (unsigned i = 0; i < instr->num_srcs; i++) { switch (instr->src[i].src_type) { diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index f639de7..a6175ca 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -2086,15 +2086,13 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; struct lp_derivatives derivs; - struct lp_sampler_params params; + struct lp_sampler_params params = { 0 }; enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned num_derivs, num_offsets, i; unsigned shadow_coord = 0; unsigned layer_coord = 0; unsigned sample_key = sampler_op << LP_SAMPLER_OP_TYPE_SHIFT; - memset(¶ms, 0, sizeof(params)); - if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); for (i = 0; i < 4; i++) { @@ -2301,15 +2299,13 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; struct lp_derivatives derivs; - struct lp_sampler_params params; + struct lp_sampler_params params = { 0 }; enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned num_offsets, num_derivs, i; unsigned layer_coord = 0; unsigned sample_key = sample_type << LP_SAMPLER_OP_TYPE_SHIFT; - memset(¶ms, 0, sizeof(params)); - if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); for (i = 0; i < 4; i++) { @@ -2483,14 +2479,12 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; LLVMValueRef ms_index = NULL; - struct lp_sampler_params params; + struct lp_sampler_params params = { 0 }; enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned dims, i; unsigned layer_coord = 0; unsigned sample_key = LP_SAMPLER_OP_FETCH << LP_SAMPLER_OP_TYPE_SHIFT; - memset(¶ms, 0, sizeof(params)); - if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); for (i = 0; i < 4; i++) { @@ -2627,7 +2621,7 @@ emit_size_query( struct lp_build_tgsi_soa_context *bld, unsigned unit = inst->Src[1].Register.Index; enum tgsi_texture_type target; enum pipe_texture_target pipe_target; - struct lp_sampler_size_query_params params; + struct lp_sampler_size_query_params params = { 0 }; if (is_sviewinfo) { target = bld->sv[unit].Resource; @@ -3439,7 +3433,7 @@ img_load_emit( struct lp_build_emit_data * emit_data) { struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base); - struct lp_img_params params; + struct lp_img_params params = { 0 }; LLVMValueRef coords[5]; LLVMValueRef coord_undef = LLVMGetUndef(bld->bld_base.base.int_vec_type); unsigned dims; @@ -3457,8 +3451,6 @@ img_load_emit( if (layer_coord) coords[2] = lp_build_emit_fetch(&bld->bld_base, emit_data->inst, 1, layer_coord); - memset(¶ms, 0, sizeof(params)); - params.type = bld->bld_base.base.type; params.resources_type = bld->resources_type; params.resources_ptr = bld->resources_ptr; @@ -3591,7 +3583,7 @@ img_store_emit( struct lp_build_emit_data * emit_data) { struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base); - struct lp_img_params params; + struct lp_img_params params = { 0 }; LLVMValueRef coords[5]; LLVMValueRef coord_undef = LLVMGetUndef(bld->bld_base.base.int_vec_type); unsigned dims; @@ -3607,7 +3599,6 @@ img_store_emit( } if (layer_coord) coords[2] = lp_build_emit_fetch(&bld->bld_base, emit_data->inst, 0, layer_coord); - memset(¶ms, 0, sizeof(params)); params.type = bld->bld_base.base.type; params.resources_type = bld->resources_type; @@ -3743,7 +3734,7 @@ img_atomic_emit( LLVMAtomicRMWBinOp op) { struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base); - struct lp_img_params params; + struct lp_img_params params = { 0 }; LLVMValueRef coords[5]; LLVMValueRef coord_undef = LLVMGetUndef(bld->bld_base.base.int_vec_type); unsigned dims; @@ -3760,7 +3751,6 @@ img_atomic_emit( } if (layer_coord) coords[2] = lp_build_emit_fetch(&bld->bld_base, emit_data->inst, 1, layer_coord); - memset(¶ms, 0, sizeof(params)); params.type = bld->bld_base.base.type; params.resources_type = bld->resources_type; -- 2.7.4