[Mesa-dev] [WIP 15/25] i965/gen8: Add support for double precision constant operands

Topi Pohjolainen topi.pohjolainen at intel.com
Thu Oct 16 05:24:27 PDT 2014


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
Signed-off-by: Tapani P\344lli <tapani.palli at intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 src/mesa/drivers/dri/i965/brw_fs.cpp           | 8 ++++++++
 src/mesa/drivers/dri/i965/brw_fs.h             | 1 +
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 3 +++
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 5 +++++
 src/mesa/drivers/dri/i965/brw_reg.h            | 9 +++++++++
 5 files changed, 26 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 0b41ad3..71729be 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -552,6 +552,14 @@ fs_reg::fs_reg()
 }
 
 /** Immediate value constructor. */
+fs_reg::fs_reg(double df)
+{
+   init();
+   this->file = IMM;
+   this->type = BRW_REGISTER_TYPE_DF;
+   this->fixed_hw_reg.dw1.df = df;
+}
+
 fs_reg::fs_reg(float f)
 {
    init();
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index f7b7b24..9637b90 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -73,6 +73,7 @@ public:
    void init();
 
    fs_reg();
+   explicit fs_reg(double df);
    explicit fs_reg(float f);
    explicit fs_reg(int32_t i);
    explicit fs_reg(uint32_t u);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 2b20f7c..0abcbeb 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1234,6 +1234,9 @@ brw_reg_from_fs_reg(fs_reg *reg)
       break;
    case IMM:
       switch (reg->type) {
+      case BRW_REGISTER_TYPE_DF:
+         brw_reg = brw_imm_df(reg->fixed_hw_reg.dw1.df);
+         break;
       case BRW_REGISTER_TYPE_F:
 	 brw_reg = brw_imm_f(reg->fixed_hw_reg.dw1.f);
 	 break;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index e5883a9..c352631 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2299,6 +2299,11 @@ fs_visitor::visit(ir_constant *ir)
 
       for (unsigned i = 0; i < size; i++) {
 	 switch (ir->type->base_type) {
+         case GLSL_TYPE_DOUBLE:
+            if (brw->gen >= 8) {
+               emit(MOV(dst_reg, fs_reg(ir->value.d[i])));
+            }
+            break;
 	 case GLSL_TYPE_FLOAT:
 	    emit(MOV(dst_reg, fs_reg(ir->value.f[i])));
 	    break;
diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h
index 7cf748f..20c0708 100644
--- a/src/mesa/drivers/dri/i965/brw_reg.h
+++ b/src/mesa/drivers/dri/i965/brw_reg.h
@@ -153,6 +153,7 @@ struct brw_reg {
          unsigned pad1:10;        /* two dwords total */
       } bits;
 
+      double df;
       float f;
       int   d;
       unsigned ud;
@@ -449,6 +450,14 @@ brw_imm_reg(enum brw_reg_type type)
 
 /** Construct float immediate register */
 static inline struct brw_reg
+brw_imm_df(double df)
+{
+   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_DF);
+   imm.dw1.df = df;
+   return imm;
+}
+
+static inline struct brw_reg
 brw_imm_f(float f)
 {
    struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_F);
-- 
1.8.3.1



More information about the mesa-dev mailing list