[Mesa-dev] [WIP 05/25] i965/fs: Prepare virtual registers for double precision floats

Pohjolainen, Topi topi.pohjolainen at intel.com
Thu Oct 16 10:17:36 PDT 2014


On Thu, Oct 16, 2014 at 07:29:10AM -0700, Jason Ekstrand wrote:
>    On Oct 16, 2014 5:24 AM, "Topi Pohjolainen" <topi.pohjolainen at intel.com>
>    wrote:
>    >
>    > Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
>    > ---
>    >  src/mesa/drivers/dri/i965/brw_fs.cpp | 5 ++++-
>    >  1 file changed, 4 insertions(+), 1 deletion(-)
>    >
>    > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp
>    b/src/mesa/drivers/dri/i965/brw_fs.cpp
>    > index e2e942c..bec7418 100644
>    > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
>    > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
>    > @@ -1087,9 +1087,12 @@ fs_reg::fs_reg(fs_visitor *v, const struct
>    glsl_type *type)
>    >     int reg_width = v->dispatch_width / 8;
>    >
>    >     this->file = GRF;
>    > -   this->reg = v->virtual_grf_alloc(v->type_size(type) * reg_width);
>    >     this->reg_offset = 0;
>    >     this->type = brw_type_for_base_type(type);
>    > +
>    > +   const int dmul = (this->type == BRW_REGISTER_TYPE_DF) ? 2 : 1;
>    > +   this->reg = v->virtual_grf_alloc(v->type_size(type) * dmul *
>    reg_width);
> 
>    Why not just make type_size return 2 for doubles?

I'm glad you asked, I forgot to write about this into the commit message. I
had that originally and I still think that this would be the right thing
to do. The thing is that we have, for exmaple:

---
void
fs_visitor::visit(ir_dereference_array *ir)
{
   ir_constant *constant_index;
   fs_reg src;
   int element_size = type_size(ir->type);

   constant_index = ir->array_index->as_constant();

   ir->array->accept(this);
   src = this->result;
   src.type = brw_type_for_base_type(ir->type);

   if (constant_index) {
      assert(src.file == UNIFORM || src.file == GRF || src.file == HW_REG);
      src = offset(src, constant_index->value.i[0] * element_size);
---

which gives the value returned by type_size() as logical element index to
"offset()". I patched offset() to do the element size multiplication as the
other callers of offset() treat the argument as logical index not taking
into account the size of the element type.
I can try to patch this "visit(ir_dereference_array *ir)" to drop the
element_size and then modify the type_size(). Would that make sense tpo you?


More information about the mesa-dev mailing list