From: Rob Clark <robcl...@freedesktop.org> We are going to start using nir_builder.h from some gallium code, which is currently only C90. Which results in:
In file included from nir/nir_emulate.c:26:0: ../../../src/glsl/nir/nir_builder.h: In function ‘nir_build_alu’: ../../../src/glsl/nir/nir_builder.h:132:4: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] unsigned num_components = op_info->output_size; ^ In file included from nir/nir_emulate.c:26:0: ../../../src/glsl/nir/nir_builder.h: In function ‘nir_ssa_for_src’: ../../../src/glsl/nir/nir_builder.h:271:4: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] nir_alu_src alu = { NIR_SRC_INIT }; ^ cc1: some warnings being treated as errors Signed-off-by: Rob Clark <robcl...@freedesktop.org> --- Not sure if I should just go ahead and push this sort of thing. Or if we can start requiring C99 for gallium? src/glsl/nir/nir_builder.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index 332bb02..6f30306 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -115,6 +115,8 @@ nir_build_alu(nir_builder *build, nir_op op, nir_ssa_def *src0, { const nir_op_info *op_info = &nir_op_infos[op]; nir_alu_instr *instr = nir_alu_instr_create(build->shader, op); + unsigned num_components; + if (!instr) return NULL; @@ -129,7 +131,7 @@ nir_build_alu(nir_builder *build, nir_op op, nir_ssa_def *src0, /* Guess the number of components the destination temporary should have * based on our input sizes, if it's not fixed for the op. */ - unsigned num_components = op_info->output_size; + num_components = op_info->output_size; if (num_components == 0) { for (unsigned i = 0; i < op_info->num_inputs; i++) { if (op_info->input_sizes[i] == 0) @@ -265,10 +267,11 @@ nir_channel(nir_builder *b, nir_ssa_def *def, unsigned c) static inline nir_ssa_def * nir_ssa_for_src(nir_builder *build, nir_src src, int num_components) { + nir_alu_src alu = { NIR_SRC_INIT }; + if (src.is_ssa && src.ssa->num_components == num_components) return src.ssa; - nir_alu_src alu = { NIR_SRC_INIT }; alu.src = src; for (int j = 0; j < 4; j++) alu.swizzle[j] = j; -- 2.5.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev