From: Iago Toral Quiroga Date: Tue, 16 Jun 2015 19:55:14 +0000 (+0200) Subject: i965/nir/vec4: Implement load_uniform intrinsic X-Git-Tag: upstream/17.1.0~17168 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6cafb5dfdef8d8d25ee1e3375304cf35897d1f7;p=platform%2Fupstream%2Fmesa.git i965/nir/vec4: Implement load_uniform intrinsic For the indirect case we need to take the index delivered by NIR and compute the parent uniform that we are accessing (the one that we uploaded to a surface) and the constant offset into that surface. Reviewed-by: Jason Ekstrand --- diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp index d9af945..ff218a5 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp @@ -522,10 +522,32 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr) } case nir_intrinsic_load_uniform_indirect: + has_indirect = true; /* fallthrough */ - case nir_intrinsic_load_uniform: - /* @TODO: Not yet implemented */ + case nir_intrinsic_load_uniform: { + int uniform = instr->const_index[0]; + + dest = get_nir_dest(instr->dest); + + if (has_indirect) { + /* Split addressing into uniform and offset */ + int offset = uniform - nir_uniform_driver_location[uniform]; + assert(offset >= 0); + + uniform -= offset; + assert(uniform >= 0); + + src = src_reg(dst_reg(UNIFORM, uniform)); + src.reg_offset = offset; + src_reg tmp = get_nir_src(instr->src[0], BRW_REGISTER_TYPE_D, 1); + src.reladdr = new(mem_ctx) src_reg(tmp); + } else { + src = src_reg(dst_reg(UNIFORM, uniform)); + } + + emit(MOV(dest, src)); break; + } case nir_intrinsic_atomic_counter_read: case nir_intrinsic_atomic_counter_inc: