Hello,
Yes .. i see my mistake ... thanks for ping me.
I am sending again the patchs with the fix and adding a new patch that
add a test to dfrac so no more mistakes there :>.
The test has the same output of frc test.


Igor
On Wed, Jan 20, 2010 at 3:53 AM, michal <mic...@vmware.com> wrote:
> Igor Oliveira wrote on 2010-01-20 00:37:
>>
>> Hi,
>>
>> These patches add support to dfrac, dldexp and fracexp opcodes.
>> The fracexp opcode i think it is the only opcode that use 2 DST registers.
>> The first one is used to store the fractional part(it store in a
>> double) and the second one is used to store the exponent part(it is a
>> int).
>> In the tests we can see it working.
>>
>>  static void
>> +micro_dfrac(union tgsi_double_channel *dst,
>> +            const union tgsi_double_channel *src)
>> +{
>> +   dst->d[0] = src->d[0] - floor(src->d[0]);
>> +   dst->d[1] = src->d[1] - floor(src->d[0]);
>> +   dst->d[2] = src->d[2] - floor(src->d[0]);
>> +   dst->d[3] = src->d[3] - floor(src->d[0])
>
> Igor,
>
> Shouldn't the second line have floor(src->d[1]), and so on?
>
From c7731a40ab136fffffd98848f9155f9ce5ae3436 Mon Sep 17 00:00:00 2001
From: Igor Oliveira <igor.olive...@openbossa.org>
Date: Tue, 19 Jan 2010 17:01:50 -0400
Subject: [PATCH 1/6] gallium: add dfrac and dldexp opcodes

---
 src/gallium/include/pipe/p_shader_tokens.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 15f8b0d..9ab18c4 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -334,7 +334,9 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_DRCP                157
 #define TGSI_OPCODE_DSQRT               158
 #define TGSI_OPCODE_DMAD                159
-#define TGSI_OPCODE_LAST                160
+#define TGSI_OPCODE_DFRAC               160
+#define TGSI_OPCODE_DLDEXP              161
+#define TGSI_OPCODE_LAST                162
 
 #define TGSI_SAT_NONE            0  /* do not saturate */
 #define TGSI_SAT_ZERO_ONE        1  /* clamp to [0,1] */
-- 
1.6.3.3

From 8d92fc49c50f815fa6075cdfe0c340c5bcd7a7dd Mon Sep 17 00:00:00 2001
From: Igor Oliveira <igor.olive...@openbossa.org>
Date: Tue, 19 Jan 2010 17:02:34 -0400
Subject: [PATCH 2/6] tgsi: implement DFRAC and DLDEXP opcode

---
 src/gallium/auxiliary/tgsi/tgsi_exec.c |   28 ++++++++++++++++++++++++++++
 src/gallium/auxiliary/tgsi/tgsi_info.c |    4 +++-
 2 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index f8a4468..efb9ea1 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -290,6 +290,26 @@ micro_dmad(union tgsi_double_channel *dst,
 }
 
 static void
+micro_dfrac(union tgsi_double_channel *dst,
+            const union tgsi_double_channel *src)
+{
+   dst->d[0] = src->d[0] - floor(src->d[0]);
+   dst->d[1] = src->d[1] - floor(src->d[1]);
+   dst->d[2] = src->d[2] - floor(src->d[2]);
+   dst->d[3] = src->d[3] - floor(src->d[3]);
+}
+
+static void
+micro_dldexp(union tgsi_double_channel *dst,
+             const union tgsi_double_channel *src)
+{
+   dst->d[0] = ldexp(src[0].d[0], src[1].d[0]);
+   dst->d[1] = ldexp(src[0].d[1], src[1].d[1]);
+   dst->d[2] = ldexp(src[0].d[2], src[1].d[2]);
+   dst->d[3] = ldexp(src[0].d[3], src[1].d[3]);
+}
+
+static void
 micro_exp2(union tgsi_exec_channel *dst,
            const union tgsi_exec_channel *src)
 {
@@ -3907,6 +3927,14 @@ exec_instruction(
       exec_double_trinary(mach, inst, micro_dmad);
       break;
 
+   case TGSI_OPCODE_DFRAC:
+      exec_double_unary(mach, inst, micro_dfrac);
+      break;
+
+   case TGSI_OPCODE_DLDEXP:
+      exec_double_binary(mach, inst, micro_dldexp);
+      break;
+
    default:
       printf("%d", inst->Instruction.Opcode);
       assert( 0 );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 269ef73..8340b07 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -190,7 +190,9 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
    { 1, 2, 0, 0, 0, 0, "DSEQ", TGSI_OPCODE_DSEQ },
    { 1, 1, 0, 0, 0, 0, "DRCP", TGSI_OPCODE_DRCP },
    { 1, 1, 0, 0 ,0, 0, "DSQRT", TGSI_OPCODE_DSQRT },
-   { 1, 3, 0, 0 ,0, 0, "DMAD", TGSI_OPCODE_DMAD }
+   { 1, 3, 0, 0 ,0, 0, "DMAD", TGSI_OPCODE_DMAD },
+   { 1, 1, 0, 0, 0, 0, "DFRAC", TGSI_OPCODE_DFRAC},
+   { 1, 2, 0, 0, 0, 0, "DLDEXP", TGSI_OPCODE_DLDEXP}
 };
 
 const struct tgsi_opcode_info *
-- 
1.6.3.3

From bf1c40a2bc8d365d41e9a1c8149283a0addc7acf Mon Sep 17 00:00:00 2001
From: Igor Oliveira <igor.olive...@openbossa.org>
Date: Tue, 19 Jan 2010 19:20:53 -0400
Subject: [PATCH 3/6] gallium: DFRACEXP opcode to tgsi

---
 src/gallium/include/pipe/p_shader_tokens.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 9ab18c4..e0c191c 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -336,7 +336,8 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_DMAD                159
 #define TGSI_OPCODE_DFRAC               160
 #define TGSI_OPCODE_DLDEXP              161
-#define TGSI_OPCODE_LAST                162
+#define TGSI_OPCODE_DFRACEXP            162
+#define TGSI_OPCODE_LAST                163
 
 #define TGSI_SAT_NONE            0  /* do not saturate */
 #define TGSI_SAT_ZERO_ONE        1  /* clamp to [0,1] */
-- 
1.6.3.3

From 00bedaeefad548686315cc44391f2c8eaa427d90 Mon Sep 17 00:00:00 2001
From: Igor Oliveira <igor.olive...@openbossa.org>
Date: Tue, 19 Jan 2010 19:21:47 -0400
Subject: [PATCH 4/6] tgsi: implement DFRACEXP

---
 src/gallium/auxiliary/tgsi/tgsi_exec.c |   40 ++++++++++++++++++++++++++++++++
 src/gallium/auxiliary/tgsi/tgsi_info.c |    3 +-
 2 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index efb9ea1..09c4d3a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -310,6 +310,17 @@ micro_dldexp(union tgsi_double_channel *dst,
 }
 
 static void
+micro_dfracexp(union tgsi_double_channel *dst,
+               union tgsi_exec_channel *dst_exp,
+               const union tgsi_double_channel *src)
+{
+   dst->d[0] = frexp(src->d[0], &dst_exp->i[0]);
+   dst->d[1] = frexp(src->d[1], &dst_exp->i[1]);
+   dst->d[2] = frexp(src->d[2], &dst_exp->i[2]);
+   dst->d[3] = frexp(src->d[3], &dst_exp->i[3]);
+}
+
+static void
 micro_exp2(union tgsi_exec_channel *dst,
            const union tgsi_exec_channel *src)
 {
@@ -2453,6 +2464,31 @@ exec_d2f(struct tgsi_exec_machine *mach,
 }
 
 static void
+exec_dfracexp(struct tgsi_exec_machine *mach,
+              const struct tgsi_full_instruction *inst)
+{
+   union tgsi_double_channel src;
+   union tgsi_double_channel dst;
+   union tgsi_exec_channel dst_exp;
+
+   if (((inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_XY) == TGSI_WRITEMASK_XY) &&
+       ((inst->Dst[1].Register.WriteMask & TGSI_WRITEMASK_X) == TGSI_WRITEMASK_X)) {
+      fetch_double_channel(mach, &src, &inst->Src[0], CHAN_X, CHAN_Y);
+      micro_dfracexp(&dst, &dst_exp, &src);
+      store_double_channel(mach, &dst, &inst->Dst[0], inst, CHAN_X, CHAN_Y);
+      store_dest(mach, &dst_exp, &inst->Dst[1], inst, CHAN_X, TGSI_EXEC_DATA_INT);
+   }
+   if (((inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_ZW) == TGSI_WRITEMASK_ZW) &&
+       ((inst->Dst[1].Register.WriteMask & TGSI_WRITEMASK_Y) == TGSI_WRITEMASK_Y)) {
+      fetch_double_channel(mach, &src, &inst->Src[0], CHAN_Z, CHAN_W);
+      micro_dfracexp(&dst, &dst_exp, &src);
+      store_double_channel(mach, &dst, &inst->Dst[0], inst, CHAN_Z, CHAN_W);
+      store_dest(mach, &dst_exp, &inst->Dst[1], inst, CHAN_Y, TGSI_EXEC_DATA_INT);
+   }
+}
+
+
+static void
 micro_i2f(union tgsi_exec_channel *dst,
           const union tgsi_exec_channel *src)
 {
@@ -3935,6 +3971,10 @@ exec_instruction(
       exec_double_binary(mach, inst, micro_dldexp);
       break;
 
+   case TGSI_OPCODE_DFRACEXP:
+      exec_dfracexp(mach, inst);
+      break;
+
    default:
       printf("%d", inst->Instruction.Opcode);
       assert( 0 );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 8340b07..cc8d6e5 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -192,7 +192,8 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
    { 1, 1, 0, 0 ,0, 0, "DSQRT", TGSI_OPCODE_DSQRT },
    { 1, 3, 0, 0 ,0, 0, "DMAD", TGSI_OPCODE_DMAD },
    { 1, 1, 0, 0, 0, 0, "DFRAC", TGSI_OPCODE_DFRAC},
-   { 1, 2, 0, 0, 0, 0, "DLDEXP", TGSI_OPCODE_DLDEXP}
+   { 1, 2, 0, 0, 0, 0, "DLDEXP", TGSI_OPCODE_DLDEXP},
+   { 2, 1, 0, 0, 0, 0, "DFRACEXP", TGSI_OPCODE_DFRACEXP}
 };
 
 const struct tgsi_opcode_info *
-- 
1.6.3.3

From e656f2a44ac1d174c199ede615c581fc3d73940a Mon Sep 17 00:00:00 2001
From: Igor Oliveira <igor.olive...@openbossa.org>
Date: Tue, 19 Jan 2010 19:29:29 -0400
Subject: [PATCH 5/6] regress: add test to DFRACEXP and DLDEXP

---
 .../regress/fragment-shader/frag-ldexp-frexp.sh    |   22 ++++++++++++++++++++
 .../regress/fragment-shader/fragment-shader.py     |    1 +
 2 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ldexp-frexp.sh

diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ldexp-frexp.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ldexp-frexp.sh
new file mode 100644
index 0000000..3de53eb
--- /dev/null
+++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ldexp-frexp.sh
@@ -0,0 +1,22 @@
+FRAG
+
+DCL IN[0], COLOR, LINEAR
+DCL OUT[0], COLOR
+DCL TEMP[0..5]
+
+F2D TEMP[0], IN[0]
+F2D TEMP[1],  IN[0].zwzw
+
+DFRACEXP TEMP[4], TEMP[5], TEMP[1]
+DLDEXP TEMP[1], TEMP[4], TEMP[5]
+
+MOV TEMP[2].zw, TEMP[0]
+MOV TEMP[3].xy, TEMP[1].zwzw
+D2F OUT[0].x, TEMP[0]
+D2F OUT[0].y, TEMP[2]
+D2F TEMP[0].x, TEMP[1]
+D2F TEMP[1].x, TEMP[3]
+MOV OUT[0].z, TEMP[0].zzxz
+MOV OUT[0].w, TEMP[1].xxxx
+
+END
diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
index d3e9f1d..afed426 100644
--- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
+++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
@@ -195,6 +195,7 @@ def main():
         'dslt',
         'dsqrt',
         'dmad',
+        'ldexp-frexp',
         'dp3',
         'dp4',
         'dst',
-- 
1.6.3.3

From c564a1c6238eab14c67ed97404e4158b18665dfd Mon Sep 17 00:00:00 2001
From: Igor Oliveira <igor.olive...@openbossa.org>
Date: Wed, 20 Jan 2010 04:45:36 -0400
Subject: [PATCH 6/6] regress: add DFRAC test

---
 .../tests/regress/fragment-shader/frag-dfrac.sh    |   29 ++++++++++++++++++++
 .../regress/fragment-shader/fragment-shader.py     |    1 +
 2 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dfrac.sh

diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dfrac.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dfrac.sh
new file mode 100644
index 0000000..dc20c1f
--- /dev/null
+++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dfrac.sh
@@ -0,0 +1,29 @@
+FRAG
+
+DCL IN[0], COLOR, LINEAR
+DCL OUT[0], COLOR
+DCL TEMP[0..5]
+
+IMM FLT32 { 2.7, 3.1, 4.5, 1.0 }
+
+F2D TEMP[0], IN[0]
+F2D TEMP[1], IN[0].zwzw
+F2D TEMP[4], IMM[0]
+F2D TEMP[5], IMM[0].zwzw
+
+DMUL TEMP[0], TEMP[0], TEMP[4]
+DMUL TEMP[1], TEMP[1], TEMP[5]
+DFRAC TEMP[0], TEMP[0]
+DFRAC TEMP[1], TEMP[1]
+
+MOV TEMP[2].zw, TEMP[0]
+MOV TEMP[3].xy, TEMP[1].zwzw
+D2F OUT[0].x, TEMP[0]
+D2F OUT[0].y, TEMP[2]
+D2F TEMP[0].x, TEMP[1]
+D2F TEMP[1].x, TEMP[3]
+MOV OUT[0].z, TEMP[0].zzxz
+MOV OUT[0].w, TEMP[1].xxxx
+
+
+END
diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
index afed426..a6c79f5 100644
--- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
+++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
@@ -196,6 +196,7 @@ def main():
         'dsqrt',
         'dmad',
         'ldexp-frexp',
+        'dfrac',
         'dp3',
         'dp4',
         'dst',
-- 
1.6.3.3

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to