Jason Ekstrand <ja...@jlekstrand.net> writes: > On Tue, Jul 21, 2015 at 9:38 AM, Francisco Jerez <curroje...@riseup.net> > wrote: >> v2: Move the image_params array back to brw_stage_prog_data. >> --- >> src/mesa/drivers/dri/i965/brw_fs.h | 1 + >> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 50 >> +++++++++++++++++++++++++++----- >> 2 files changed, 43 insertions(+), 8 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.h >> b/src/mesa/drivers/dri/i965/brw_fs.h >> index 4749c47..97df784 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs.h >> +++ b/src/mesa/drivers/dri/i965/brw_fs.h >> @@ -264,6 +264,7 @@ public: >> nir_jump_instr *instr); >> fs_reg get_nir_src(nir_src src); >> fs_reg get_nir_dest(nir_dest dest); >> + fs_reg get_nir_image_deref(const nir_deref_var *deref); >> void emit_percomp(const brw::fs_builder &bld, const fs_inst &inst, >> unsigned wr_mask); >> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >> index 6ec96c4..31024b7 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >> @@ -234,17 +234,26 @@ fs_visitor::nir_setup_uniform(nir_variable *var) >> continue; >> } >> >> - unsigned slots = storage->type->component_slots(); >> - if (storage->array_elements) >> - slots *= storage->array_elements; >> + if (storage->type->is_image()) { >> + /* Images don't get a valid location assigned by nir_lower_io() >> + * because their size is driver-specific, so we need to allocate >> + * space for them here at the end of the parameter array. >> + */ >> + var->data.driver_location = uniforms; >> + param_size[uniforms] = >> + BRW_IMAGE_PARAM_SIZE * MAX2(storage->array_elements, 1); >> + >> + setup_image_uniform_values(storage); >> + } else { >> + unsigned slots = storage->type->component_slots(); >> + if (storage->array_elements) >> + slots *= storage->array_elements; >> >> - for (unsigned i = 0; i < slots; i++) { >> - stage_prog_data->param[index++] = &storage->storage[i]; >> + for (unsigned i = 0; i < slots; i++) { >> + stage_prog_data->param[index++] = &storage->storage[i]; >> + } >> } >> } >> - >> - /* Make sure we actually initialized the right amount of stuff here. */ >> - assert(var->data.driver_location + var->type->component_slots() == >> index); >> } >> >> void >> @@ -1193,6 +1202,31 @@ fs_visitor::get_nir_dest(nir_dest dest) >> dest.reg.indirect); >> } >> >> +fs_reg >> +fs_visitor::get_nir_image_deref(const nir_deref_var *deref) >> +{ >> + fs_reg image(UNIFORM, deref->var->data.driver_location, >> + BRW_REGISTER_TYPE_UD); >> + >> + if (deref->deref.child) { >> + const nir_deref_array *deref_array = >> + nir_deref_as_array(deref->deref.child); >> + assert(deref_array->deref.child == NULL); > > You should probably assert that the deref type of the child is an > array before casting. > Wouldn't it make sense for nir_deref_as_array() to do that?
>> + >> + image = offset(image, bld, >> + deref_array->base_offset * BRW_IMAGE_PARAM_SIZE); >> + >> + if (deref_array->deref_array_type == nir_deref_array_type_indirect) { >> + fs_reg *tmp = new(mem_ctx) fs_reg(vgrf(glsl_type::int_type)); >> + bld.MUL(*tmp, get_nir_src(deref_array->indirect), >> + fs_reg(BRW_IMAGE_PARAM_SIZE)); >> + image.reladdr = tmp; >> + } >> + } >> + >> + return image; >> +} >> + >> void >> fs_visitor::emit_percomp(const fs_builder &bld, const fs_inst &inst, >> unsigned wr_mask) >> -- >> 2.4.3 >> >> _______________________________________________ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
signature.asc
Description: PGP signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev