[Lima] [PATCH v2 6/8] gallium: add lima driver

Qiang Yu yuq825 at gmail.com
Tue Mar 26 02:29:47 UTC 2019


On Fri, Mar 22, 2019 at 11:25 PM Alyssa Rosenzweig <alyssa at rosenzweig.io> wrote:
>
> > +
> > +static bool gpir_lower_viewport_transform(gpir_compiler *comp)
> > +{
> > +   gpir_node *rcpw = NULL;
> > +
> > +   /* rcpw = 1 / w */
> > +   list_for_each_entry(gpir_block, block, &comp->block_list, list) {
> > +      list_for_each_entry(gpir_node, node, &block->node_list, list) {
> > +         if (node->op == gpir_op_store_varying) {
> > +            gpir_store_node *store = gpir_node_to_store(node);
> > +            if (store->index == 0 && store->component == 3) {
> > +               gpir_node *w = store->child;
> > +
> > +               rcpw = gpir_node_create(block, gpir_op_rcp);
> > +               if (!rcpw)
> > +                  return false;
> > +               list_addtail(&rcpw->list, &node->list);
> > +
> > +               gpir_alu_node *alu = gpir_node_to_alu(rcpw);
> > +               alu->children[0] = w;
> > +               alu->num_child = 1;
> > +               store->child = rcpw;
> > +
> > +               gpir_node_insert_child(node, w, rcpw);
> > +               goto found;
> > +            }
> > +         }
> > +      }
> > +   }
> > +
> > +found:
> > +   assert(rcpw);
> > +
> > +   /* xyz = xyz * rcpw * scale + transition */
> > +   list_for_each_entry(gpir_block, block, &comp->block_list, list) {
> > +      list_for_each_entry(gpir_node, node, &block->node_list, list) {
> > +         if (node->op == gpir_op_store_varying) {
> > +            gpir_store_node *store = gpir_node_to_store(node);
> > +            if (store->index == 0 && store->component < 3) {
> > +               gpir_node *xyz = store->child;
> > +
> > +               gpir_node *mul1 =
> > +                  gpir_lower_create_insert_node(node, xyz, rcpw, gpir_op_mul);
> > +               if (!mul1)
> > +                  return false;
> > +
> > +               gpir_load_node *scale = gpir_node_create(block, gpir_op_load_uniform);
> > +               if (!scale)
> > +                  return false;
> > +               scale->index = comp->constant_base;
> > +               scale->component = store->component;
> > +               list_addtail(&scale->node.list, &node->list);
> > +
> > +               gpir_node *mul2 =
> > +                  gpir_lower_create_insert_node(node, mul1, &scale->node, gpir_op_mul);
> > +               if (!mul2)
> > +                  return false;
> > +
> > +               gpir_load_node *translate = gpir_node_create(block, gpir_op_load_uniform);
> > +               if (!translate)
> > +                  return false;
> > +               translate->index = comp->constant_base + 1;
> > +               translate->component = store->component;
> > +               list_addtail(&translate->node.list, &node->list);
> > +
> > +               gpir_node *add =
> > +                  gpir_lower_create_insert_node(node, mul2, &translate->node, gpir_op_add);
> > +               if (!add)
> > +                  return false;
> > +
> > +               store->child = add;
> > +            }
> > +         }
> > +      }
> > +   }
> > +
> > +   comp->constant_base += 2;
> > +   return true;
> > +}
>
> I have this routine implemented in Panfrost at the NIR level, rather
> than the ISA level. Do we want to move this to common NIR code?
>
Seems Panfrost implementation does not take depth uniforms? I think we can
move it to nir if we both use the viewport scale/transform vector as the uniform
in this lower pass. But due to lima pad special uniforms instead of prefix like
panfrost, we need to add a uniform location parameter to the API function.

> > +static int gpir_get_max_start(gpir_node *node)
>
> Read until here (note to self, gotta go, will read more later).


More information about the lima mailing list