[Mesa-dev] [PATCH 3/9] glsl/lower_64bit: extract non-64bit sources from vectors.

Erik Faye-Lund kusmabite at gmail.com
Sat Feb 3 10:26:07 UTC 2018


On Feb 1, 2018 04:35, "Dave Airlie" <airlied at gmail.com> wrote:

From: Dave Airlie <airlied at redhat.com>

In order to deal with conversions properly we need to extract
non-64bit sources from vectors instead of expanding them as
the 64-bit code does.

We need non-64bit sources for the 32->64 conversion functions.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/compiler/glsl/lower_64bit.cpp | 38 ++++++++++++++++++++++++++++++
++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_
64bit.cpp
index ac62d1db1e..c7c6d1cb31 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -52,6 +52,7 @@ using namespace ir_builder;

 namespace lower_64bit {
 void expand_source(ir_factory &, ir_rvalue *val, ir_variable
**expanded_src);
+void extract_source(ir_factory &, ir_rvalue *val, ir_variable
**extracted_src);

 ir_dereference_variable *compact_destination(ir_factory &,
                                              const glsl_type *type,
@@ -226,6 +227,25 @@ lower_64bit::expand_source(ir_factory &body,
       expanded_src[i] = expanded_src[0];
 }

+void
+lower_64bit::extract_source(ir_factory &body,
+                            ir_rvalue *val,
+                            ir_variable **extracted_src)
+{
+   ir_variable *const temp = body.make_temp(val->type, "tmp");
+
+   body.emit(assign(temp, val));
+   unsigned i;
+   for (i = 0; i < val->type->vector_elements; i++) {
+      extracted_src[i] = body.make_temp(val->type->get_scalar_type(),
"extracted_source");
+
+      body.emit(assign(extracted_src[i], swizzle(temp, i, 1)));
+   }
+
+   for (/* empty */; i < 4; i++)
+      extracted_src[i] = extracted_src[0];
+}
+
 /**
  * Convert a series of uvec2 results into a single 64-bit integer vector
  */
@@ -262,14 +282,24 @@ lower_64bit::lower_op_to_function_call(ir_instruction
*base_ir,
    void *const mem_ctx = ralloc_parent(ir);
    exec_list instructions;
    unsigned source_components = 0;
-   const glsl_type *const result_type =
-      ir->type->base_type == GLSL_TYPE_UINT64
-      ? glsl_type::uvec2_type : glsl_type::ivec2_type;
+   const glsl_type *result_type;
+
+   if (ir->type->is_64bit()) {
+      if (ir->type->base_type == GLSL_TYPE_UINT64 ||
+          ir->type->base_type == GLSL_TYPE_DOUBLE)
+         result_type = glsl_type::uvec2_type;
+      else
+         result_type = glsl_type::ivec2_type;
+   } else
+      result_type = ir->type->get_scalar_type();

    ir_factory body(&instructions, mem_ctx);

    for (unsigned i = 0; i < num_operands; i++) {
-      expand_source(body, ir->operands[i], src[i]);
+      if (ir->operands[i]->type->is_64bit())
+         expand_source(body, ir->operands[i], src[i]);
+      else
+         extract_source(body, ir->operands[i], src[i]);


This change looks like a nop to me. Was the different sides of the else
supposed to do different things?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180203/f0ff5755/attachment.html>


More information about the mesa-dev mailing list