[Mesa-dev] [PATCH 04/10] i965/vec4: Add vector float immediate infrastructure.

Matt Turner mattst88 at gmail.com
Thu Oct 23 16:44:06 PDT 2014


---
 src/mesa/drivers/dri/i965/brw_vec4.cpp           | 20 ++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_vec4.h             |  1 +
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp |  3 +++
 3 files changed, 24 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 46aa7d5..53b86bd 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -31,6 +31,7 @@ extern "C" {
 #include "main/shaderobj.h"
 #include "program/prog_print.h"
 #include "program/prog_parameter.h"
+#include "brw_packed_float.h"
 }
 
 #define MAX_INSTRUCTION (1 << 30)
@@ -112,6 +113,18 @@ src_reg::src_reg(int32_t i)
    this->fixed_hw_reg.dw1.d = i;
 }
 
+src_reg::src_reg(uint8_t vf[4])
+{
+   init();
+
+   this->file = IMM;
+   this->type = BRW_REGISTER_TYPE_VF;
+   this->fixed_hw_reg.dw1.ud = (vf[0] <<  0) |
+                               (vf[1] <<  8) |
+                               (vf[2] << 16) |
+                               (vf[3] << 24);
+}
+
 src_reg::src_reg(struct brw_reg reg)
 {
    init();
@@ -1375,6 +1388,13 @@ vec4_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
          case BRW_REGISTER_TYPE_UD:
             fprintf(file, "%uU", inst->src[i].fixed_hw_reg.dw1.ud);
             break;
+         case BRW_REGISTER_TYPE_VF:
+            fprintf(stderr, "[%.7f, %.7f, %.7f, %.7f]",
+                    brw_vf_to_float((inst->src[i].fixed_hw_reg.dw1.ud >>  0) & 0xff),
+                    brw_vf_to_float((inst->src[i].fixed_hw_reg.dw1.ud >>  8) & 0xff),
+                    brw_vf_to_float((inst->src[i].fixed_hw_reg.dw1.ud >> 16) & 0xff),
+                    brw_vf_to_float((inst->src[i].fixed_hw_reg.dw1.ud >> 24) & 0xff));
+            break;
          default:
             fprintf(file, "???");
             break;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 750f491..00888f8 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -102,6 +102,7 @@ public:
    src_reg(float f);
    src_reg(uint32_t u);
    src_reg(int32_t i);
+   src_reg(uint8_t vf[4]);
    src_reg(struct brw_reg reg);
 
    bool equals(const src_reg &r) const;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index e522567..4e31cd2 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -92,6 +92,9 @@ vec4_instruction::get_src(const struct brw_vec4_prog_data *prog_data, int i)
       case BRW_REGISTER_TYPE_UD:
 	 brw_reg = brw_imm_ud(src[i].fixed_hw_reg.dw1.ud);
 	 break;
+      case BRW_REGISTER_TYPE_VF:
+         brw_reg = brw_imm_vf(src[i].fixed_hw_reg.dw1.ud);
+         break;
       default:
 	 unreachable("not reached");
       }
-- 
2.0.4



More information about the mesa-dev mailing list