Re: [Mesa-dev] [PATCH 2/2] mesa: fix unpack_ARGB1555_REV()

2011-12-01 Thread Michel Dänzer
On Mit, 2011-11-30 at 20:36 -0700, Brian Paul wrote: 
> We weren't doing the necessary byte swap.

I just stumbled over this as well.


> ---
>  src/mesa/main/format_unpack.c |9 +
>  1 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> index 4b4ee6b..fc0db34 100644
> --- a/src/mesa/main/format_unpack.c
> +++ b/src/mesa/main/format_unpack.c
> @@ -275,10 +275,11 @@ unpack_ARGB1555_REV(const void *src, GLfloat dst[][4], 
> GLuint n)
> const GLushort *s = ((const GLushort *) src);
> GLuint i;
> for (i = 0; i < n; i++) {
> -  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((s[i] >>  7) & 0xf8) | ((s[i] >> 12) 
> & 0x7) );
> -  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((s[i] >>  2) & 0xf8) | ((s[i] >>  7) 
> & 0x7) );
> -  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((s[i] <<  3) & 0xf8) | ((s[i] >>  2) 
> & 0x7) );
> -  dst[i][ACOMP] = UBYTE_TO_FLOAT( ((s[i] >> 15) & 0x01) * 255 );
> +  GLushort tmp = (s[i] << 8) | (s[i] >> 8); /* byteswap */

A BSWAP16() macro might be nice for this, but I wouldn't let that hold
up this fix.

> +  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((tmp >>  7) & 0xf8) | ((tmp >> 12) & 
> 0x7) );
> +  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((tmp >>  2) & 0xf8) | ((tmp >>  7) & 
> 0x7) );
> +  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((tmp <<  3) & 0xf8) | ((tmp >>  2) & 
> 0x7) );

Don't these lines need to be changed to be the same as in
unpack_ARGB1555()?


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43404] Git head fails to build-No rule to make target 'default' in src/gallium/drivers/failover

2011-12-01 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43404

José Fonseca  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||WORKSFORME

--- Comment #3 from José Fonseca  2011-12-01 02:11:58 PST 
---
I've reproduced it, and re-runing ./autogen.sh solved the issue.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/6] patches to increase the brw eu instruction store size dynamically

2011-12-01 Thread Yuanhan Liu

Actually the first 5 patches are all prepare work for patch 6.

I checked those patches will all intel oglc testcases, and found no regressions.
What's better, it fixed something.


Yuanhan Liu (6):
  i965: let all the brw_OPCODE functions return an instruction index
instead
  i965: remove the second unused parameter of gen6_CONT
  i965: let all the while loop stack to store an instruction index
instead
  i965: let if_stack just store the instruction index
  i965: let brw_lan_fwd_jump() get the jmp_insn by the instruction
index
  i965: increase the brw eu instruction store size dynamically

 src/mesa/drivers/dri/i965/brw_clip_line.c |2 +-
 src/mesa/drivers/dri/i965/brw_clip_tri.c  |6 +-
 src/mesa/drivers/dri/i965/brw_clip_unfilled.c |4 +-
 src/mesa/drivers/dri/i965/brw_eu.c|   10 +-
 src/mesa/drivers/dri/i965/brw_eu.h|   46 +++---
 src/mesa/drivers/dri/i965/brw_eu_emit.c   |  235 +
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp |   15 +-
 src/mesa/drivers/dri/i965/brw_sf_emit.c   |2 +-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp   |   23 ++--
 src/mesa/drivers/dri/i965/brw_vs_emit.c   |   15 +-
 src/mesa/drivers/dri/i965/brw_wm.h|   14 +-
 src/mesa/drivers/dri/i965/brw_wm_emit.c   |   16 +-
 12 files changed, 202 insertions(+), 186 deletions(-)

-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/6] i965: let all the brw_OPCODE functions return an instruction index instead

2011-12-01 Thread Yuanhan Liu
Let all the brw_OPCODE functions return an instruction index instead,
and use brw_insn_of(p, index) macro to reference the instruction stored
at p->store[].

This is a prepare work of let us increase the instruction store size
dynamically by reralloc.

Signed-off-by: Yuanhan Liu 
---
 src/mesa/drivers/dri/i965/brw_clip_line.c |2 +-
 src/mesa/drivers/dri/i965/brw_clip_tri.c  |6 +-
 src/mesa/drivers/dri/i965/brw_clip_unfilled.c |6 +-
 src/mesa/drivers/dri/i965/brw_eu.h|   32 ++--
 src/mesa/drivers/dri/i965/brw_eu_emit.c   |  194 -
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp |4 +-
 src/mesa/drivers/dri/i965/brw_sf_emit.c   |6 +-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp   |   12 +-
 src/mesa/drivers/dri/i965/brw_vs_emit.c   |7 +-
 src/mesa/drivers/dri/i965/brw_wm.h|   14 +-
 src/mesa/drivers/dri/i965/brw_wm_emit.c   |   16 +-
 11 files changed, 146 insertions(+), 153 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip_line.c 
b/src/mesa/drivers/dri/i965/brw_clip_line.c
index 75c64c0..4313637 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_line.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_line.c
@@ -160,7 +160,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
 
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 
-   plane_loop = brw_DO(p, BRW_EXECUTE_1);
+   plane_loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
{
   /* if (planemask & 1)
*/
diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c 
b/src/mesa/drivers/dri/i965/brw_clip_tri.c
index ffbfe94..97eae35 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_tri.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c
@@ -244,7 +244,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
 
brw_MOV(p, get_addr_reg(freelist_ptr), brw_address(c->reg.vertex[3]) );
 
-   plane_loop = brw_DO(p, BRW_EXECUTE_1);
+   plane_loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
{
   /* if (planemask & 1)
*/
@@ -266,7 +266,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
 brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
 brw_MOV(p, c->reg.nr_verts, brw_imm_ud(0));
 
-vertex_loop = brw_DO(p, BRW_EXECUTE_1);
+vertex_loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
 {
/* vtx = *input_ptr;
 */
@@ -427,7 +427,7 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
   brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
   brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
 
-  loop = brw_DO(p, BRW_EXECUTE_1);
+  loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
   {
 brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_TRIFAN << 2));
   
diff --git a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c 
b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c
index ae84e19..2a984fe 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c
@@ -285,7 +285,7 @@ static void emit_lines(struct brw_clip_compile *c,
   brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
   brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
 
-  loop = brw_DO(p, BRW_EXECUTE_1);
+  loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
   {
 brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
 brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
@@ -307,7 +307,7 @@ static void emit_lines(struct brw_clip_compile *c,
brw_ADD(p, get_addr_reg(v1ptr), get_addr_reg(v1ptr), 
retype(c->reg.nr_verts, BRW_REGISTER_TYPE_UW));
brw_MOV(p, deref_1uw(v1ptr, 0), deref_1uw(v0ptr, 0));
 
-   loop = brw_DO(p, BRW_EXECUTE_1);
+   loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
{
   brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
   brw_MOV(p, get_addr_reg(v1), deref_1uw(v0ptr, 2));
@@ -346,7 +346,7 @@ static void emit_points(struct brw_clip_compile *c,
brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
 
-   loop = brw_DO(p, BRW_EXECUTE_1);
+   loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
{
   brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
   brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index 8a446eb..61d3178 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -797,7 +797,7 @@ void brw_init_compile(struct brw_context *, struct 
brw_compile *p,
  void *mem_ctx);
 const GLuint *brw_get_program( struct brw_compile *p, GLuint *sz );
 
-struct brw_instruction *brw_next_insn(struct brw_compile *p, GLuint opcode);
+int brw_next_insn(struct brw_compile *p, GLuint opcode);
 void brw_set_dest(struct brw_compile *p, struct brw_instruction *insn,
  struct brw_reg dest);
 void brw_set_src0(struct brw_compile *p, str

[Mesa-dev] [PATCH 2/6] i965: remove the second unused parameter of gen6_CONT

2011-12-01 Thread Yuanhan Liu
Signed-off-by: Yuanhan Liu 
---
 src/mesa/drivers/dri/i965/brw_eu.h  |2 +-
 src/mesa/drivers/dri/i965/brw_eu_emit.c |2 +-
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp   |2 +-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |2 +-
 src/mesa/drivers/dri/i965/brw_vs_emit.c |2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index 61d3178..53c0383 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -1006,7 +1006,7 @@ int brw_WHILE(struct brw_compile *p, struct 
brw_instruction *patch_insn);
 
 int brw_BREAK(struct brw_compile *p, int pop_count);
 int brw_CONT(struct brw_compile *p, int pop_count);
-int gen6_CONT(struct brw_compile *p, struct brw_instruction *do_insn);
+int gen6_CONT(struct brw_compile *p);
 /* Forward jumps:
  */
 void brw_land_fwd_jump(struct brw_compile *p, 
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 4c0de2c..9b37e81 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -1218,7 +1218,7 @@ int brw_BREAK(struct brw_compile *p, int pop_count)
return insn_idx;
 }
 
-int gen6_CONT(struct brw_compile *p, struct brw_instruction *do_insn)
+int gen6_CONT(struct brw_compile *p)
 {
int insn_idx = next_insn(p, BRW_OPCODE_CONTINUE);
struct brw_instruction *insn = brw_insn_of(p, insn_idx);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
index 3b1577d..f78723e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
@@ -796,7 +796,7 @@ fs_visitor::generate_code()
   case BRW_OPCODE_CONTINUE:
 /* FINISHME: We need to write the loop instruction support still. */
 if (intel->gen >= 6)
-   gen6_CONT(p, loop_stack[loop_stack_depth - 1]);
+   gen6_CONT(p);
 else
brw_CONT(p, if_depth_in_loop[loop_stack_depth]);
 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index a279e87..e36adae 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -827,7 +827,7 @@ vec4_visitor::generate_code()
   case BRW_OPCODE_CONTINUE:
 /* FINISHME: We need to write the loop instruction support still. */
 if (intel->gen >= 6)
-   gen6_CONT(p, loop_stack[loop_stack_depth - 1]);
+   gen6_CONT(p);
 else
brw_CONT(p, if_depth_in_loop[loop_stack_depth]);
 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c 
b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index 0a0cfbe..6d50fad 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -2107,7 +2107,7 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
   case OPCODE_CONT:
 brw_set_predicate_control(p, get_predicate(inst));
 if (intel->gen >= 6) {
-   gen6_CONT(p, loop_inst[loop_depth - 1]);
+   gen6_CONT(p);
 } else {
brw_CONT(p, if_depth_in_loop[loop_depth]);
 }
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/6] i965: let all the while loop stack to store an instruction index instead

2011-12-01 Thread Yuanhan Liu
Let all the while loop stack just store the instruction index. This is
somehow more flexible than store the instruction memory address.

This is a prepare work of let us increase the instruction store size
dynamically by reralloc.

Signed-off-by: Yuanhan Liu 
---
 src/mesa/drivers/dri/i965/brw_clip_line.c |4 ++--
 src/mesa/drivers/dri/i965/brw_clip_tri.c  |   12 ++--
 src/mesa/drivers/dri/i965/brw_clip_unfilled.c |   10 +-
 src/mesa/drivers/dri/i965/brw_eu.h|2 +-
 src/mesa/drivers/dri/i965/brw_eu_emit.c   |   11 ++-
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp |   15 ---
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp   |   15 ---
 src/mesa/drivers/dri/i965/brw_vs_emit.c   |   12 +++-
 8 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip_line.c 
b/src/mesa/drivers/dri/i965/brw_clip_line.c
index 4313637..c37ac53 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_line.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_line.c
@@ -132,7 +132,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
struct brw_indirect newvtx0   = brw_indirect(2, 0);
struct brw_indirect newvtx1   = brw_indirect(3, 0);
struct brw_indirect plane_ptr = brw_indirect(4, 0);
-   struct brw_instruction *plane_loop;
+   int plane_loop;
struct brw_reg v1_null_ud = retype(vec1(brw_null_reg()), 
BRW_REGISTER_TYPE_UD);
GLuint hpos_offset = brw_vert_result_to_offset(&c->vue_map,
   VERT_RESULT_HPOS);
@@ -160,7 +160,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
 
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 
-   plane_loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
+   plane_loop = brw_DO(p, BRW_EXECUTE_1);
{
   /* if (planemask & 1)
*/
diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c 
b/src/mesa/drivers/dri/i965/brw_clip_tri.c
index 97eae35..3182a98 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_tri.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c
@@ -232,8 +232,8 @@ void brw_clip_tri( struct brw_clip_compile *c )
struct brw_indirect inlist_ptr = brw_indirect(4, 0);
struct brw_indirect outlist_ptr = brw_indirect(5, 0);
struct brw_indirect freelist_ptr = brw_indirect(6, 0);
-   struct brw_instruction *plane_loop;
-   struct brw_instruction *vertex_loop;
+   int plane_loop;
+   int vertex_loop;
GLuint hpos_offset = brw_vert_result_to_offset(&c->vue_map,
   VERT_RESULT_HPOS);

@@ -244,7 +244,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
 
brw_MOV(p, get_addr_reg(freelist_ptr), brw_address(c->reg.vertex[3]) );
 
-   plane_loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
+   plane_loop = brw_DO(p, BRW_EXECUTE_1);
{
   /* if (planemask & 1)
*/
@@ -266,7 +266,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
 brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
 brw_MOV(p, c->reg.nr_verts, brw_imm_ud(0));
 
-vertex_loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
+vertex_loop = brw_DO(p, BRW_EXECUTE_1);
 {
/* vtx = *input_ptr;
 */
@@ -404,7 +404,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
 void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
 {
struct brw_compile *p = &c->func;
-   struct brw_instruction *loop;
+   int loop;
 
/* for (loopcount = nr_verts-2; loopcount > 0; loopcount--)
 */
@@ -427,7 +427,7 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
   brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
   brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
 
-  loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
+  loop = brw_DO(p, BRW_EXECUTE_1);
   {
 brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_TRIFAN << 2));
   
diff --git a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c 
b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c
index 2a984fe..d057695 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c
@@ -273,7 +273,7 @@ static void emit_lines(struct brw_clip_compile *c,
   bool do_offset)
 {
struct brw_compile *p = &c->func;
-   struct brw_instruction *loop;
+   int loop;
struct brw_indirect v0 = brw_indirect(0, 0);
struct brw_indirect v1 = brw_indirect(1, 0);
struct brw_indirect v0ptr = brw_indirect(2, 0);
@@ -285,7 +285,7 @@ static void emit_lines(struct brw_clip_compile *c,
   brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
   brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
 
-  loop = brw_insn_of(p, brw_DO(p, BRW_EXECUTE_1));
+  loop = brw_DO(p, BRW_EXECUTE_1);
   {
 brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
 brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
@@ -307,7 +307,7 @@ static void emit_line

[Mesa-dev] [PATCH 4/6] i965: let if_stack just store the instruction index

2011-12-01 Thread Yuanhan Liu
Let if_stack just store the instruction pointer(an index). This is
somehow more flexible than store the instruction memory address.

This is a prepare work of let us increase the instruction store size
dynamically by reralloc.

Signed-off-by: Yuanhan Liu 
---
 src/mesa/drivers/dri/i965/brw_eu.c  |3 +--
 src/mesa/drivers/dri/i965/brw_eu.h  |4 +++-
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   16 
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
b/src/mesa/drivers/dri/i965/brw_eu.c
index b5a858b..77eb2cf 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -191,8 +191,7 @@ brw_init_compile(struct brw_context *brw, struct 
brw_compile *p, void *mem_ctx)
/* Set up control flow stack */
p->if_stack_depth = 0;
p->if_stack_array_size = 16;
-   p->if_stack =
-  rzalloc_array(mem_ctx, struct brw_instruction *, p->if_stack_array_size);
+   p->if_stack = rzalloc_array(mem_ctx, int, p->if_stack_array_size);
 }
 
 
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index 638358f..cb324fe 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -123,8 +123,10 @@ struct brw_compile {
/* Control flow stacks:
 * - if_stack contains IF and ELSE instructions which must be patched
 *   (and popped) once the matching ENDIF instruction is encountered.
+*
+*   Just store the instruction pointer(an index).
 */
-   struct brw_instruction **if_stack;
+   int *if_stack;
int if_stack_depth;
int if_stack_array_size;
 
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index a611a1b..352c72c 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -898,14 +898,14 @@ int brw_JMPI(struct brw_compile *p,
 }
 
 static void
-push_if_stack(struct brw_compile *p, struct brw_instruction *inst)
+push_if_stack(struct brw_compile *p, GLuint inst)
 {
p->if_stack[p->if_stack_depth] = inst;
 
p->if_stack_depth++;
if (p->if_stack_array_size <= p->if_stack_depth) {
   p->if_stack_array_size *= 2;
-  p->if_stack = reralloc(p->mem_ctx, p->if_stack, struct brw_instruction *,
+  p->if_stack = reralloc(p->mem_ctx, p->if_stack, int,
 p->if_stack_array_size);
}
 }
@@ -957,7 +957,7 @@ int brw_IF(struct brw_compile *p, GLuint execute_size)
 
p->current->header.predicate_control = BRW_PREDICATE_NONE;
 
-   push_if_stack(p, insn);
+   push_if_stack(p, insn_idx);
return insn_idx;
 }
 
@@ -988,7 +988,7 @@ gen6_IF(struct brw_compile *p, uint32_t conditional,
if (!p->single_program_flow)
   insn->header.thread_control = BRW_THREAD_SWITCH;
 
-   push_if_stack(p, insn);
+   push_if_stack(p, insn_idx);
return insn_idx;
 }
 
@@ -1137,7 +1137,7 @@ brw_ELSE(struct brw_compile *p)
if (!p->single_program_flow)
   insn->header.thread_control = BRW_THREAD_SWITCH;
 
-   push_if_stack(p, insn);
+   push_if_stack(p, insn_idx);
 }
 
 void
@@ -1150,11 +1150,11 @@ brw_ENDIF(struct brw_compile *p)
 
/* Pop the IF and (optional) ELSE instructions from the stack */
p->if_stack_depth--;
-   if (p->if_stack[p->if_stack_depth]->header.opcode == BRW_OPCODE_ELSE) {
-  else_inst = p->if_stack[p->if_stack_depth];
+   if (p->store[p->if_stack[p->if_stack_depth]].header.opcode == 
BRW_OPCODE_ELSE) {
+  else_inst = &p->store[p->if_stack[p->if_stack_depth]];
   p->if_stack_depth--;
}
-   if_inst = p->if_stack[p->if_stack_depth];
+   if_inst = &p->store[p->if_stack[p->if_stack_depth]];
 
if (p->single_program_flow) {
   /* ENDIF is useless; don't bother emitting it. */
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/6] i965: let brw_lan_fwd_jump() get the jmp_insn by the instruction index

2011-12-01 Thread Yuanhan Liu
This is a prepare work of let us increase the instruction store size
dynamically by reralloc.

Signed-off-by: Yuanhan Liu 
---
 src/mesa/drivers/dri/i965/brw_eu.h  |3 +--
 src/mesa/drivers/dri/i965/brw_eu_emit.c |4 ++--
 src/mesa/drivers/dri/i965/brw_sf_emit.c |8 
 src/mesa/drivers/dri/i965/brw_wm_emit.c |4 ++--
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index cb324fe..4207238 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -1011,8 +1011,7 @@ int brw_CONT(struct brw_compile *p, int pop_count);
 int gen6_CONT(struct brw_compile *p);
 /* Forward jumps:
  */
-void brw_land_fwd_jump(struct brw_compile *p, 
-  struct brw_instruction *jmp_insn);
+void brw_land_fwd_jump(struct brw_compile *p, int jmp);
 
 
 
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 352c72c..8f8a5a5 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -1346,11 +1346,11 @@ int brw_WHILE(struct brw_compile *p, int do_insn_idx)
 
 /* FORWARD JUMPS:
  */
-void brw_land_fwd_jump(struct brw_compile *p, 
-  struct brw_instruction *jmp_insn)
+void brw_land_fwd_jump(struct brw_compile *p, int jmp)
 {
struct intel_context *intel = &p->brw->intel;
struct brw_instruction *landing = &p->store[p->nr_insn];
+   struct brw_instruction *jmp_insn = brw_insn_of(p, jmp);
GLuint jmpi = 1;
 
if (intel->gen >= 5)
diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c 
b/src/mesa/drivers/dri/i965/brw_sf_emit.c
index 6570ad0..ba890d4 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c
@@ -717,7 +717,7 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
struct brw_reg payload_prim = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0);
struct brw_reg payload_attr = 
get_element_ud(brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0), 0); 
struct brw_reg primmask;
-   struct brw_instruction *jmp;
+   int jmp;
struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), 
BRW_REGISTER_TYPE_UD));

GLuint saveflag;
@@ -738,7 +738,7 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
   (1<<_3DPRIM_POLYGON) |
   (1<<_3DPRIM_RECTLIST) |
   (1<<_3DPRIM_TRIFAN_NOSTIPPLE)));
-   jmp = brw_insn_of(p, brw_JMPI(p, ip, ip, brw_imm_d(0)));
+   jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
{
   saveflag = p->flag_value;
   brw_push_insn_state(p); 
@@ -759,7 +759,7 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
   (1<<_3DPRIM_LINESTRIP_CONT) |
   (1<<_3DPRIM_LINESTRIP_BF) |
   (1<<_3DPRIM_LINESTRIP_CONT_BF)));
-   jmp = brw_insn_of(p, brw_JMPI(p, ip, ip, brw_imm_d(0)));
+   jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
{
   saveflag = p->flag_value;
   brw_push_insn_state(p); 
@@ -772,7 +772,7 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
 
brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
brw_AND(p, v1_null_ud, payload_attr, 
brw_imm_ud(1

[Mesa-dev] [PATCH 6/6] i965: increase the brw eu instruction store size dynamically

2011-12-01 Thread Yuanhan Liu
Here is the final patch to increase the brw eu instruction store size
dynamically instead of just allocating it statically with a constant
limit. This would fix something like 'GL_MAX_PROGRAM_INSTRUCTIONS_ARB
was 16384 while the driver would limit it to 1'.

Signed-off-by: Yuanhan Liu 
---
 src/mesa/drivers/dri/i965/brw_eu.c  |7 +++
 src/mesa/drivers/dri/i965/brw_eu.h  |7 ---
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   12 +++-
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
b/src/mesa/drivers/dri/i965/brw_eu.c
index 77eb2cf..f13affe 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -174,6 +174,13 @@ void
 brw_init_compile(struct brw_context *brw, struct brw_compile *p, void *mem_ctx)
 {
p->brw = brw;
+   /*
+* Set the initial instruction store array size to 1024, if found that
+* isn't enough, then it will double the store size at brw_next_insn()
+* until it meet the BRW_EU_MAX_INSN
+*/
+   p->store_size = 1024;
+   p->store = rzalloc_array(mem_ctx, struct brw_instruction, p->store_size);
p->nr_insn = 0;
p->current = p->stack;
p->compressed = false;
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index 4207238..88f1def 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -100,11 +100,12 @@ struct brw_glsl_call;
 
 
 
-#define BRW_EU_MAX_INSN_STACK 5
-#define BRW_EU_MAX_INSN 1
+#define BRW_EU_MAX_INSN_STACK   5
+#define BRW_EU_MAX_INSN (1024 * 1024)
 
 struct brw_compile {
-   struct brw_instruction store[BRW_EU_MAX_INSN];
+   struct brw_instruction *store;
+   int store_size;
GLuint nr_insn;
 
void *mem_ctx;
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 8f8a5a5..0bcc015 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -686,7 +686,17 @@ int brw_next_insn(struct brw_compile *p, GLuint opcode)
 {
int insn;
 
-   assert(p->nr_insn + 1 < BRW_EU_MAX_INSN);
+   if (p->nr_insn + 1 > p->store_size) {
+  if (p->nr_insn + 1 > BRW_EU_MAX_INSN) {
+ assert(!"exceed max brw allowed eu instructions");
+  } else {
+ if (0)
+printf("incresing the store size to %d\n", p->store_size << 1);
+ p->store_size <<= 1;
+ p->store = reralloc(p->mem_ctx, p->store,
+ struct brw_instruction, p->store_size);
+  }
+   }
 
insn = p->nr_insn++;
 
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] mesa: fix unpack_ARGB1555_REV()

2011-12-01 Thread Brian Paul

On 12/01/2011 02:42 AM, Michel Dänzer wrote:

On Mit, 2011-11-30 at 20:36 -0700, Brian Paul wrote:

We weren't doing the necessary byte swap.


I just stumbled over this as well.



---
  src/mesa/main/format_unpack.c |9 +
  1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 4b4ee6b..fc0db34 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -275,10 +275,11 @@ unpack_ARGB1555_REV(const void *src, GLfloat dst[][4], 
GLuint n)
 const GLushort *s = ((const GLushort *) src);
 GLuint i;
 for (i = 0; i<  n; i++) {
-  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((s[i]>>   7)&  0xf8) | ((s[i]>>  12)&  
0x7) );
-  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((s[i]>>   2)&  0xf8) | ((s[i]>>   7)&  
0x7) );
-  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((s[i]<<   3)&  0xf8) | ((s[i]>>   2)&  
0x7) );
-  dst[i][ACOMP] = UBYTE_TO_FLOAT( ((s[i]>>  15)&  0x01) * 255 );
+  GLushort tmp = (s[i]<<  8) | (s[i]>>  8); /* byteswap */


A BSWAP16() macro might be nice for this, but I wouldn't let that hold
up this fix.


+  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((tmp>>   7)&  0xf8) | ((tmp>>  12)&  
0x7) );
+  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((tmp>>   2)&  0xf8) | ((tmp>>   7)&  
0x7) );
+  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((tmp<<   3)&  0xf8) | ((tmp>>   2)&  
0x7) );


Don't these lines need to be changed to be the same as in
unpack_ARGB1555()?


It should be equivalent (lookup table vs. arithmetic).  It would nice 
if someone could write a little benchmark to see which is really faster.


I'll commit this later if there's no other concerns.

-Brian
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] u_vbuf: Silence uninitialized variable warnings.

2011-12-01 Thread Brian Paul

On 11/30/2011 04:35 PM, Vinson Lee wrote:

Fixes these GCC warnings.
u_vbuf.c: In function ‘u_vbuf_draw_begin’:
u_vbuf.c:839:20: warning: ‘max_index’ may be used uninitialized in this 
function [-Wuninitialized]
u_vbuf.c:838:20: warning: ‘min_index’ may be used uninitialized in this 
function [-Wuninitialized]

Signed-off-by: Vinson Lee
---
  src/gallium/auxiliary/util/u_vbuf.c |2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index f6da912..5b0e26e 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -808,6 +808,8 @@ static void u_vbuf_get_minmax_index(struct pipe_context 
*pipe,
 }
 default:
assert(0);
+  *out_min_index = 0;
+  *out_max_index = 0;
 }

 if (transfer) {



Reviewed-by: Brian Paul 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] mesa: fix unpack_ARGB1555_REV()

2011-12-01 Thread Michel Dänzer
On Don, 2011-12-01 at 07:28 -0700, Brian Paul wrote: 
> On 12/01/2011 02:42 AM, Michel Dänzer wrote:
> > On Mit, 2011-11-30 at 20:36 -0700, Brian Paul wrote:
> >
> >> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> >> index 4b4ee6b..fc0db34 100644
> >> --- a/src/mesa/main/format_unpack.c
> >> +++ b/src/mesa/main/format_unpack.c
> >> @@ -275,10 +275,11 @@ unpack_ARGB1555_REV(const void *src, GLfloat 
> >> dst[][4], GLuint n)
> >>  const GLushort *s = ((const GLushort *) src);
> >>  GLuint i;
> >>  for (i = 0; i<  n; i++) {
> >> -  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((s[i]>>   7)&  0xf8) | ((s[i]>>  
> >> 12)&  0x7) );
> >> -  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((s[i]>>   2)&  0xf8) | ((s[i]>>   
> >> 7)&  0x7) );
> >> -  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((s[i]<<   3)&  0xf8) | ((s[i]>>   
> >> 2)&  0x7) );
> >> -  dst[i][ACOMP] = UBYTE_TO_FLOAT( ((s[i]>>  15)&  0x01) * 255 );
> >> +  GLushort tmp = (s[i]<<  8) | (s[i]>>  8); /* byteswap */
> >
> > A BSWAP16() macro might be nice for this, but I wouldn't let that hold
> > up this fix.
> >
> >> +  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((tmp>>   7)&  0xf8) | ((tmp>>  
> >> 12)&  0x7) );
> >> +  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((tmp>>   2)&  0xf8) | ((tmp>>   
> >> 7)&  0x7) );
> >> +  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((tmp<<   3)&  0xf8) | ((tmp>>   
> >> 2)&  0x7) );
> >
> > Don't these lines need to be changed to be the same as in
> > unpack_ARGB1555()?
> 
> It should be equivalent (lookup table vs. arithmetic).  It would nice 
> if someone could write a little benchmark to see which is really faster.

I still don't understand why these lines should be different between
unpack_ARGB1555_REV() and unpack_ARGB1555(), as the only difference
between the two formats is the swapped bytes, right? If both variants
are equivalent, I don't particularly care which one is considered
better, but I think the other one should be adapted to match.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Use of nested functions in nouveau_array.c

2011-12-01 Thread İsmail Dönmez
Hi;

On Wed, Nov 9, 2011 at 8:08 PM, İsmail Dönmez  wrote:

> Another thing to notice that nested functions require executable stack.
> This is also another reason to get rid of them.
>
> On Wed, Nov 9, 2011 at 3:11 PM, İsmail Dönmez  wrote:
>
>> Hi;
>>
>> nouveau_array.c seems to be using nested functions which is not supported
>> by clang (or the EDG based compilers it seems), the reduced testcase looks
>> like this:
>>
>> foo()
>> {
>> auto void f();
>> void f() {};
>> }
>>
>> I talked to the clang developers and they don't plan to support this GNU
>> extension since (they say) it would be too hard to support it in the
>> parser. Clang website notes the following about this issue (from
>> http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc )
>>
>> 
>> clang does not support nested functions; this is a complex feature which
>> is infrequently used, so it is unlikely to be implemented anytime soon.
>> 
>>
>> Is there any chance of removing such code from Mesa?
>>
>
Would be nice to get a comment on this.

Thanks,
ismail
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] mesa: fix unpack_ARGB1555_REV()

2011-12-01 Thread Brian Paul

On 12/01/2011 07:35 AM, Michel Dänzer wrote:

On Don, 2011-12-01 at 07:28 -0700, Brian Paul wrote:

On 12/01/2011 02:42 AM, Michel Dänzer wrote:

On Mit, 2011-11-30 at 20:36 -0700, Brian Paul wrote:


diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 4b4ee6b..fc0db34 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -275,10 +275,11 @@ unpack_ARGB1555_REV(const void *src, GLfloat dst[][4], 
GLuint n)
  const GLushort *s = ((const GLushort *) src);
  GLuint i;
  for (i = 0; i<   n; i++) {
-  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((s[i]>>7)&   0xf8) | ((s[i]>>   
12)&   0x7) );
-  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((s[i]>>2)&   0xf8) | ((s[i]>>
7)&   0x7) );
-  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((s[i]<<3)&   0xf8) | ((s[i]>>
2)&   0x7) );
-  dst[i][ACOMP] = UBYTE_TO_FLOAT( ((s[i]>>   15)&   0x01) * 255 );
+  GLushort tmp = (s[i]<<   8) | (s[i]>>   8); /* byteswap */


A BSWAP16() macro might be nice for this, but I wouldn't let that hold
up this fix.


+  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((tmp>>7)&   0xf8) | ((tmp>>   12)&  
 0x7) );
+  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((tmp>>2)&   0xf8) | ((tmp>>7)&  
 0x7) );
+  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((tmp<<3)&   0xf8) | ((tmp>>2)&  
 0x7) );


Don't these lines need to be changed to be the same as in
unpack_ARGB1555()?


It should be equivalent (lookup table vs. arithmetic).  It would nice
if someone could write a little benchmark to see which is really faster.


I still don't understand why these lines should be different between
unpack_ARGB1555_REV() and unpack_ARGB1555(), as the only difference
between the two formats is the swapped bytes, right? If both variants
are equivalent, I don't particularly care which one is considered
better, but I think the other one should be adapted to match.


It's just copy and paste from the s_texfetch_tmp.h file (I'd have to 
go through git history to see what the story is there).  I'll make 
them the same and post a new patch.


-Brian
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: fix unpack_ARGB1555_REV()

2011-12-01 Thread Brian Paul
We weren't doing the necessary byte swap.

v2: use same arithmetic as unpack_ARGB1555() to be consistent.
---
 src/mesa/main/format_unpack.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 4b4ee6b..2332ce8 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -275,10 +275,11 @@ unpack_ARGB1555_REV(const void *src, GLfloat dst[][4], 
GLuint n)
const GLushort *s = ((const GLushort *) src);
GLuint i;
for (i = 0; i < n; i++) {
-  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((s[i] >>  7) & 0xf8) | ((s[i] >> 12) & 
0x7) );
-  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((s[i] >>  2) & 0xf8) | ((s[i] >>  7) & 
0x7) );
-  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((s[i] <<  3) & 0xf8) | ((s[i] >>  2) & 
0x7) );
-  dst[i][ACOMP] = UBYTE_TO_FLOAT( ((s[i] >> 15) & 0x01) * 255 );
+  GLushort tmp = (s[i] << 8) | (s[i] >> 8); /* byteswap */
+  dst[i][RCOMP] = ((tmp >> 10) & 0x1f) * (1.0F / 31.0F);
+  dst[i][GCOMP] = ((tmp >>  5) & 0x1f) * (1.0F / 31.0F);
+  dst[i][BCOMP] = ((tmp >>  0) & 0x1f) * (1.0F / 31.0F);
+  dst[i][ACOMP] = ((tmp >> 15) & 0x01) * 1.0F;
}
 }
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Use of nested functions in nouveau_array.c

2011-12-01 Thread Brian Paul

On 12/01/2011 07:36 AM, İsmail Dönmez wrote:

Hi;

On Wed, Nov 9, 2011 at 8:08 PM, İsmail Dönmez mailto:ism...@namtrac.org>> wrote:

Another thing to notice that nested functions require executable
stack. This is also another reason to get rid of them.

On Wed, Nov 9, 2011 at 3:11 PM, İsmail Dönmez mailto:ism...@namtrac.org>> wrote:

Hi;

nouveau_array.c seems to be using nested functions which is
not supported by clang (or the EDG based compilers it seems),
the reduced testcase looks like this:

foo()
{
 auto void f();
 void f() {};
}

I talked to the clang developers and they don't plan to
support this GNU extension since (they say) it would be too
hard to support it in the parser. Clang website notes the
following about this issue (from
http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc )


clang does not support nested functions; this is a complex
feature which is infrequently used, so it is unlikely to be
implemented anytime soon.


Is there any chance of removing such code from Mesa?


Would be nice to get a comment on this.


I imagine you're the first person to try to compile that driver with 
clang because nobody else has mentioned this before.


I don't think anyone would object to the code being rewritten to avoid 
nested functions.  Is that something that you could do?


-Brian
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Use of nested functions in nouveau_array.c

2011-12-01 Thread İsmail Dönmez
Hi;

On Thu, Dec 1, 2011 at 3:46 PM, Brian Paul  wrote:

> On 12/01/2011 07:36 AM, İsmail Dönmez wrote:
>
>> Hi;
>>
>> On Wed, Nov 9, 2011 at 8:08 PM, İsmail Dönmez > > wrote:
>>
>>Another thing to notice that nested functions require executable
>>stack. This is also another reason to get rid of them.
>>
>>On Wed, Nov 9, 2011 at 3:11 PM, İsmail Dönmez >> wrote:
>>
>>Hi;
>>
>>nouveau_array.c seems to be using nested functions which is
>>not supported by clang (or the EDG based compilers it seems),
>>the reduced testcase looks like this:
>>
>>foo()
>>{
>> auto void f();
>> void f() {};
>>}
>>
>>I talked to the clang developers and they don't plan to
>>support this GNU extension since (they say) it would be too
>>hard to support it in the parser. Clang website notes the
>>following about this issue (from
>>
>> http://clang.llvm.org/docs/**UsersManual.html#c_unimpl_gcc)
>>
>>
>>clang does not support nested functions; this is a complex
>>feature which is infrequently used, so it is unlikely to be
>>implemented anytime soon.
>>
>>
>>Is there any chance of removing such code from Mesa?
>>
>>
>> Would be nice to get a comment on this.
>>
>
> I imagine you're the first person to try to compile that driver with clang
> because nobody else has mentioned this before.
>
> I don't think anyone would object to the code being rewritten to avoid
> nested functions.  Is that something that you could do?


I imagined I had to the real work ;) I'll see what I can do.

Regards,
ismail


>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: fix unpack_ARGB1555_REV()

2011-12-01 Thread Michel Dänzer
On Don, 2011-12-01 at 07:44 -0700, Brian Paul wrote: 
> We weren't doing the necessary byte swap.
> 
> v2: use same arithmetic as unpack_ARGB1555() to be consistent.
> ---
>  src/mesa/main/format_unpack.c |9 +
>  1 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> index 4b4ee6b..2332ce8 100644
> --- a/src/mesa/main/format_unpack.c
> +++ b/src/mesa/main/format_unpack.c
> @@ -275,10 +275,11 @@ unpack_ARGB1555_REV(const void *src, GLfloat dst[][4], 
> GLuint n)
> const GLushort *s = ((const GLushort *) src);
> GLuint i;
> for (i = 0; i < n; i++) {
> -  dst[i][RCOMP] = UBYTE_TO_FLOAT( ((s[i] >>  7) & 0xf8) | ((s[i] >> 12) 
> & 0x7) );
> -  dst[i][GCOMP] = UBYTE_TO_FLOAT( ((s[i] >>  2) & 0xf8) | ((s[i] >>  7) 
> & 0x7) );
> -  dst[i][BCOMP] = UBYTE_TO_FLOAT( ((s[i] <<  3) & 0xf8) | ((s[i] >>  2) 
> & 0x7) );
> -  dst[i][ACOMP] = UBYTE_TO_FLOAT( ((s[i] >> 15) & 0x01) * 255 );
> +  GLushort tmp = (s[i] << 8) | (s[i] >> 8); /* byteswap */
> +  dst[i][RCOMP] = ((tmp >> 10) & 0x1f) * (1.0F / 31.0F);
> +  dst[i][GCOMP] = ((tmp >>  5) & 0x1f) * (1.0F / 31.0F);
> +  dst[i][BCOMP] = ((tmp >>  0) & 0x1f) * (1.0F / 31.0F);
> +  dst[i][ACOMP] = ((tmp >> 15) & 0x01) * 1.0F;
> }
>  }

Reviewed-by: Michel Dänzer 


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] Add depth cube map support to mesa swrast

2011-12-01 Thread Brian Paul

On 11/30/2011 12:39 PM, Anuj Phogat wrote:

From: Anuj Phogat

I made the suggested changes to swrast/s_texfilter.c (see the patch listed 
below). Now it render
polygons without any texture (black) in depth-cube-map test (see the patch sent 
on Nov 28 to piglit mailing list).
But the expected output is polygons rendered with different greyscale (depth) 
textures.

Some debugging info:
_mesa_choose_tex_format() returns MESA_FORMAT_Z32
_mesa_get_texstore_func() returns _mesa_texstore_z32
Based on MESA_FORMAT_Z32, selected dstType = GL_UNSIGNED_INT
Verified the values stored in depthValues[i] in _mesa_unpack_depth_span(). 
Correct pixel values (depth values) are reflected in this variable.
depthValues[i] is converted to GLuint and stored in zValues[i]

But while rendering swImg->FetchTexel() (called from sample_depth_texture() in 
swrast/s_texfilter.c) is unable to fetch the corect texel values.

Any thoughts on what could go wrong after storing the depth texture correctly?


Off-hand, I don't know.  I'd have to debug it a bit, but I probably 
won't have time to do that for a while.  Maybe you could take a closer 
look.


In any case, the patch looks correct.  I think the bug is elsewhere.

Reviewed-by: Brian Paul 

Can you commit this?

-Brian
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] UBO support update, working on some demo

2011-12-01 Thread Vincent Lejeune
Hi,

Here are an updated set of patches adding UBO support to Mesa.
It still work in progress, however I got some demo working on gallium
(namely blinking-teapot submitted to mesa-demos via another patch). 
However not every gallium works, nouveau and softpipe does but llvmpipe crashes
(seems not to support multiple const buffer even if it advertises it) and
r600g gives me a white teapot (it should varies from pink to blue).

I've merged against master yesterday so there should be no collision with 
uniform
related work that was integrated recently into master.

Any review would be appreciated.

Vincent

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/9] glapi: Add Uniform Buffer Object API

2011-12-01 Thread Vincent Lejeune
   v2: Fix a typo spotted by Eric Anholt.
---
 src/mapi/glapi/gen/ARB_Uniform_Buffer_Object.xml |  115 ++
 src/mapi/glapi/gen/Makefile  |1 +
 src/mapi/glapi/gen/gl_API.xml|2 +
 3 files changed, 118 insertions(+), 0 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_Uniform_Buffer_Object.xml

diff --git a/src/mapi/glapi/gen/ARB_Uniform_Buffer_Object.xml 
b/src/mapi/glapi/gen/ARB_Uniform_Buffer_Object.xml
new file mode 100644
index 000..604c05c
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_Uniform_Buffer_Object.xml
@@ -0,0 +1,115 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/Makefile b/src/mapi/glapi/gen/Makefile
index 4110cda..c3a3be2 100644
--- a/src/mapi/glapi/gen/Makefile
+++ b/src/mapi/glapi/gen/Makefile
@@ -93,6 +93,7 @@ API_XML = \
ARB_vertex_type_2_10_10_10_rev.xml \
APPLE_object_purgeable.xml \
APPLE_vertex_array_object.xml \
+   ARB_Uniform_Buffer_Object.xml \
EXT_draw_buffers2.xml \
EXT_framebuffer_object.xml \
EXT_gpu_shader4.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 3fd7738..8266d21 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -12441,4 +12441,6 @@
 
 http://www.w3.org/2001/XInclude"/>
 
+http://www.w3.org/2001/XInclude"/>
+
 
-- 
1.7.7

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/9] mesa : advertise GL_ARB_Uniform_Buffer_Object extension

2011-12-01 Thread Vincent Lejeune
---
 src/glsl/glsl_parser_extras.cpp |1 +
 src/glsl/glsl_parser_extras.h   |2 ++
 src/mesa/main/mfeatures.h   |1 +
 3 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 0b4ccac..71b4c5c 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -269,6 +269,7 @@ static const _mesa_glsl_extension 
_mesa_glsl_supported_extensions[] = {
EXT(AMD_shader_stencil_export,  false, false, true,  true,  false, 
ARB_shader_stencil_export),
EXT(OES_texture_3D, true,  false, true,  false, true,  
EXT_texture3D),
EXT(OES_EGL_image_external, true,  false, true,  false, true,  
OES_EGL_image_external),
+   EXT(ARB_uniform_buffer_object,  true,  false, true,  true,  false, 
ARB_uniform_buffer_object),
 };
 
 #undef EXT
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index dd93295..572e614 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -194,6 +194,8 @@ struct _mesa_glsl_parse_state {
bool OES_texture_3D_warn;
bool OES_EGL_image_external_enable;
bool OES_EGL_image_external_warn;
+   bool ARB_uniform_buffer_object_enable;
+   bool ARB_uniform_buffer_object_warn;
/*@}*/
 
/** Extensions supported by the OpenGL implementation. */
diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h
index 33db508..f8f9091 100644
--- a/src/mesa/main/mfeatures.h
+++ b/src/mesa/main/mfeatures.h
@@ -118,6 +118,7 @@
 #define FEATURE_ARB_shader_objects(FEATURE_ARB_vertex_shader || 
FEATURE_ARB_fragment_shader)
 #define FEATURE_ARB_shading_language_100  FEATURE_ARB_shader_objects
 #define FEATURE_ARB_geometry_shader4  FEATURE_ARB_shader_objects
+#define FEATURE_ARB_uniform_buffer_object FEATURE_ARB_shader_objects
 
 #define FEATURE_ARB_framebuffer_object(FEATURE_GL && 
FEATURE_EXT_framebuffer_object)
 #define FEATURE_ARB_map_buffer_range  FEATURE_GL
-- 
1.7.7

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/9] mesa: Uniform Buffer Objects data structures

2011-12-01 Thread Vincent Lejeune
   v2:Big cleanup of data structures used
   v3:Data structures moved to mtypes.h
---
 src/mesa/main/config.h|4 ++
 src/mesa/main/mtypes.h|  109 +
 src/mesa/main/shaderobj.c |   25 -
 src/mesa/program/prog_parameter.h |1 +
 4 files changed, 138 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 7b7740e..1c4c810 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -357,5 +357,9 @@
  */
 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
 
+/**
+ * UBO Variables
+ */
+#define MAX_UBO_COUNT 8
 
 #endif /* MESA_CONFIG_H_INCLUDED */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 08cd80a..654ae98 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1653,6 +1653,14 @@ struct gl_array_attrib
struct gl_buffer_object *ArrayBufferObj;
 };
 
+/**
+ * UBO state
+ */
+struct gl_ubo_attribs
+{
+struct gl_buffer_object *UniformObj;
+struct gl_buffer_object *BindingPoint[MAX_UBO_COUNT];
+};
 
 /**
  * Feedback buffer state
@@ -2127,6 +2135,82 @@ struct gl_sl_pragmas
GLboolean Debug; /**< defaults off */
 };
 
+/**
+ * Uniform Buffer Object variable informations.
+ * This come in 2 flavors :
+ * As layout informations (Size,Offset,...) are defined per program and not 
per shader,
+ * shaders_ubo_variable only store the relevant information to preserve memory.
+ * program_ubo_variable stores everything that can be retrieved by 
GetActiveUniformsiv
+ * (which makes it bigger than the data it refers to...).
+ */
+
+struct gl_shader_ubo_variable
+{
+   char* Name;
+   const struct glsl_type* Type;
+};
+
+struct gl_program_ubo_variable
+{
+   char* Name;
+   GLenum Type; /** TYPE_ARRAY,TYPE_RECORD,TYPE_FLOAT,TYPE_VEC */
+   GLuint Size; /** In bytes */
+   GLuint Offset; /** In bytes, from start of UBO */
+   GLuint Stride; /** In TYPE_ARRAY case, stride between 2 consecutive 
elements, undef otherwise */
+   GLuint IndexInUBO; /** Position inside UBO declaration */
+   GLuint ContainedVariablesCount; /** For TYPE_ARRAY and TYPE_RECORD, number 
of element in ContainedVariables */
+   struct gl_program_ubo_variable* ContainedVariables; /** For TYPE_ARRAY and 
TYPE_RECORD, array holding child data */
+   struct gl_uniform_buffer_object* UBO; /** Pointer to containing UBO 
structure inside program */
+};
+
+
+/**
+ * glsl_base_type doesn't have a VEC type,
+ * we have to define our own enum here
+ * FIXME:investigate if glsl_base_type can accept another item ?
+ */
+enum {
+   TYPE_ARRAY,
+   TYPE_RECORD,
+   TYPE_SCALAR,
+   TYPE_VEC,
+};
+
+enum UBOLayout {
+   UBO_LAYOUT_PACKED,
+   UBO_LAYOUT_SHARED,
+   UBO_LAYOUT_SDT140,
+};
+
+enum UBOMatrixLayout {
+   UBO_MATRIX_LAYOUT_ROW_MAJOR,
+   UBO_MATRIX_LAYOUT_COLUMN_MAJOR,
+};
+
+/**
+ * Uniform Buffer Object Information.
+ * This struct is used by shader and program struct ;
+ * For StorageLayout, Compact form is used in shader,
+ * Full form is used in program.
+ */
+
+struct gl_uniform_buffer_object
+{
+   char* Name;
+   GLuint Index;
+   union {
+  struct gl_program_ubo_variable*  Full;  /** Malloced, sefined in program 
*/
+  struct gl_shader_ubo_variable* Compact; /** Ralloced, defined in shader 
*/
+   } StorageLayout; /** array of variables that are part of the UBO  */
+   GLuint Layout; /** packed, shared or std140 */
+   GLuint MatrixLayout; /** rowmajor or columnmajor */
+   GLuint NumberOfVariables; /**< number of UBOVariableInfo in StorageLayout */
+   unsigned ReferencedByVS:1; /** Is it present in VS ? Set at link time */
+   unsigned ReferencedByGS:1; /** Is it present in GS ? Set at link time */
+   unsigned ReferencedByFS:1; /** Is it present in FS ? Set at link time */
+   unsigned Size; /** In bytes, with padding included */
+};
+
 
 /**
  * A GLSL vertex or fragment shader object.
@@ -2162,6 +2246,8 @@ struct gl_shader
/** Shaders containing built-in functions that are used for linking. */
struct gl_shader *builtins_to_link[16];
unsigned num_builtins_to_link;
+   struct gl_uniform_buffer_object* UniformBufferObjects;
+   unsigned UBOCount;
 };
 
 
@@ -2275,6 +2361,26 @@ struct gl_shader_program
 * \c NULL.
 */
struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES];
+   /**
+* Program Scope UBO
+*/
+   struct gl_uniform_buffer_object *UniformBufferObject;
+   unsigned UBOCount;
+
+   /** All uniforms (in UBO or not) have to be accessed by a 1D index ;
+* For classical uniform, index equals location (matches others drivers)
+* For variables in UBO, we use an array of gl_ubo_variable* pointing to
+* structures already stored inside program's
+* gl_uniform_buffer_object.StorageLayout.Full
+*/
+   GLuint IndexedVariableCount;
+   struct gl_program_ubo_variable** IndexedUBOVariables; /** 1D array of 
pointers */
+   /** String to GLuint hashtable, provides a quick access to (moreless) 
variable
+*

[Mesa-dev] [PATCH 5/9] glsl: change IR to add UBO information

2011-12-01 Thread Vincent Lejeune
---
 src/glsl/ir.cpp|1 +
 src/glsl/ir.h  |6 ++
 src/glsl/ir_clone.cpp  |1 +
 src/glsl/opt_dead_code.cpp |6 ++
 4 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index a5eca5a..bf11e4f 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1335,6 +1335,7 @@ ir_variable::ir_variable(const struct glsl_type *type, 
const char *name,
this->pixel_center_integer = false;
this->depth_layout = ir_depth_layout_none;
this->used = false;
+   this->is_ubo_variable = false;
 
if (type && type->base_type == GLSL_TYPE_SAMPLER)
   this->read_only = true;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 1faae3c..dc77dec 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -398,6 +398,12 @@ public:
int location;
 
/**
+* True if the variable is defined in the scope of a shader range Uniform
+* Buffer Object.
+*/
+   bool is_ubo_variable;
+
+   /**
 * Built-in state that backs this uniform
 *
 * Once set at variable creation, \c state_slots must remain invariant.
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index c63615c..479f258 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -52,6 +52,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
var->explicit_location = this->explicit_location;
var->has_initializer = this->has_initializer;
var->depth_layout = this->depth_layout;
+   var->is_ubo_variable = this->is_ubo_variable;
 
var->num_state_slots = this->num_state_slots;
if (this->state_slots) {
diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp
index 5b9546a..58ff534 100644
--- a/src/glsl/opt_dead_code.cpp
+++ b/src/glsl/opt_dead_code.cpp
@@ -27,6 +27,7 @@
  * Eliminates dead assignments and variable declarations from the code.
  */
 
+#include "../mesa/main/mtypes.h"
 #include "ir.h"
 #include "ir_visitor.h"
 #include "ir_variable_refcount.h"
@@ -100,6 +101,11 @@ do_dead_code(exec_list *instructions, bool 
uniform_locations_assigned)
 if (entry->var->mode == ir_var_uniform &&
 (uniform_locations_assigned || entry->var->constant_value))
continue;
+   /*if(entry->var->mode == ir_var_uniform && entry->var->UBO) {
+  if(entry->var->UBO->UBO->Layout != packed)
+continue;
+   }*/
+
 
 entry->var->remove();
 progress = true;
-- 
1.7.7

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 6/9] glsl: parser UBO support

2011-12-01 Thread Vincent Lejeune
   v2:Instance name an UBO array are not supported. The parser
   will now return an error message if they are met.
---
 src/glsl/ast.h  |   23 +++
 src/glsl/ast_to_hir.cpp |   75 +-
 src/glsl/glsl_lexer.ll  |3 +-
 src/glsl/glsl_parser.yy |  333 +--
 src/glsl/glsl_parser_extras.cpp |5 +
 src/glsl/glsl_parser_extras.h   |7 +
 src/mesa/program/ir_to_mesa.cpp |   12 ++-
 7 files changed, 369 insertions(+), 89 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index d899bc6..8effa5b 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -351,6 +351,15 @@ struct ast_type_qualifier {
  */
 unsigned explicit_location:1;
 
+ /** UBO Layout, should be 2 enum but using bit instead
+  *  to be coherent with struct definition
+  */
+ unsigned std140:1;
+ unsigned packed:1;
+ unsigned shared:1;
+ unsigned column_major:1;
+ unsigned row_major:1;
+
  /** \name Layout qualifiers for GL_AMD_conservative_depth */
  /** \{ */
  unsigned depth_any:1;
@@ -539,6 +548,20 @@ public:
int invariant;
 };
 
+class ast_uniform_buffer_object : public ast_node {
+public:
+ast_uniform_buffer_object(ast_declarator_list* lst,char* n) : name(n) {
+  components.push_degenerate_list_at_head(& lst->link);
+}
+
+virtual ir_rvalue *hir(exec_list *instructions,
+   struct _mesa_glsl_parse_state *state);
+
+exec_list components;
+ast_type_qualifier layout_qualifier;
+const char* name;
+};
+
 
 class ast_parameter_declarator : public ast_node {
 public:
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index d5b04e9..a76523a 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -81,6 +81,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct 
_mesa_glsl_parse_state *state)
 * by the linker.
 */
state->symbols->push_scope();
+   state->ubo_count = 0;
 
foreach_list_typed (ast_node, ast, link, & state->translation_unit)
   ast->hir(instructions, state);
@@ -1967,8 +1968,9 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
else if (qual->flags.q.out
|| (qual->flags.q.varying && (state->target == vertex_shader)))
   var->mode = ir_var_out;
-   else if (qual->flags.q.uniform)
+   else if (qual->flags.q.uniform) {
   var->mode = ir_var_uniform;
+   }
 
if (state->all_invariant && (state->current_function == NULL)) {
   switch (state->target) {
@@ -2915,6 +2917,77 @@ ast_declarator_list::hir(exec_list *instructions,
return result;
 }
 
+ir_rvalue *
+ast_uniform_buffer_object::hir(exec_list *instructions, _mesa_glsl_parse_state 
*state)
+{
+   void *ctx = state;
+   YYLTYPE loc = this->get_location();
+
+#if FEATURE_ARB_uniform_buffer_object
+
+   /**
+ * Counting variable the hard way.
+ */
+   int var_count = 0;
+   foreach_list_typed (ast_declarator_list, decl_list, link,
+   &this->components) {
+  decl_list->hir(instructions,state);
+
+  foreach_list_typed (ast_declaration, decl, link,
+  &decl_list->declarations) {
+ var_count++;
+  }
+   }
+
+   if(state->ubo_count == 0)
+  state->UniformBufferObjects = (struct gl_uniform_buffer_object*)
+ralloc_array_size(ctx, sizeof(gl_uniform_buffer_object),1);
+   else
+  state->UniformBufferObjects =  (struct gl_uniform_buffer_object*)
+reralloc_array_size(ctx, state->UniformBufferObjects, 
sizeof(gl_uniform_buffer_object), state->ubo_count + 1);
+
+   gl_uniform_buffer_object& new_ubo = 
state->UniformBufferObjects[state->ubo_count];
+
+   state->ubo_count++;
+
+   void* inner_ctx = (void*) state->UniformBufferObjects;
+   new_ubo.NumberOfVariables = var_count;
+   new_ubo.StorageLayout.Compact = (struct gl_shader_ubo_variable*) 
ralloc_array_size(inner_ctx,sizeof(gl_shader_ubo_variable),var_count);
+   new_ubo.Name = ralloc_strdup(inner_ctx,this->name);
+
+   int var_position = 0;
+   foreach_list_typed (ast_declarator_list, decl_list, link,
+   &this->components) {
+  foreach_list_typed (ast_declaration, decl, link,
+  &decl_list->declarations) {
+ struct gl_shader_ubo_variable& var_ubo = 
new_ubo.StorageLayout.Compact[var_position];
+ var_ubo.Name = ralloc_strdup(inner_ctx,decl->identifier);
+
+ ir_variable* var = state->symbols->get_variable(var_ubo.Name);
+ var->mode = ir_var_uniform;
+ var->is_ubo_variable = true;
+ var_ubo.Type = var->type;
+
+ var_position++;
+  }
+   }
+
+   if(this->layout_qualifier.flags.q.std140)
+  new_ubo.Layout = UBO_LAYOUT_SDT140;
+   if(this->layout_qualifier.flags.q.packed)
+  new_ubo.Layout = UBO_LAYOUT_PACKED;
+   if(this->layout_qualifier.flags.q.shared)
+  new_ubo.Layout = UBO_LAYOUT_SHARE

[Mesa-dev] [PATCH 7/9] glsl : Linker support for UBO

2011-12-01 Thread Vincent Lejeune
   v2 :
   - Fix format issue thank to Brian Paul comments.
   - UBOs are now sent to program correctly.
---
 src/glsl/link_uniforms.cpp |2 +-
 src/glsl/linker.cpp|  310 +++-
 2 files changed, 309 insertions(+), 3 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index c7de480..bacf2e9 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -308,7 +308,7 @@ link_assign_uniform_locations(struct gl_shader_program 
*prog)
   foreach_list(node, prog->_LinkedShaders[i]->ir) {
 ir_variable *const var = ((ir_instruction *) node)->as_variable();
 
-if ((var == NULL) || (var->mode != ir_var_uniform))
+   if ((var == NULL) || (var->mode != ir_var_uniform) || 
var->is_ubo_variable)
continue;
 
 /* FINISHME: Update code to process built-in uniforms!
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 3527088..786ebcf 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -64,7 +64,9 @@
  * \author Ian Romanick 
  */
 
+#include 
 #include "main/core.h"
+#include "main/hash.h"
 #include "glsl_symbol_table.h"
 #include "ir.h"
 #include "program.h"
@@ -847,6 +849,81 @@ get_main_function_signature(gl_shader *sh)
return NULL;
 }
 
+/**
+ * This function duplicates content of a ubo source into shader ubo array.
+ */
+static struct gl_uniform_buffer_object*
+append_ubo (const struct gl_uniform_buffer_object& source, struct gl_shader* 
merged_shader)
+{
+   /* Use shorter alias */
+   unsigned& current_ubo_count = merged_shader->UBOCount;
+   struct gl_uniform_buffer_object*& ubo_array = 
merged_shader->UniformBufferObjects;
+
+   if (current_ubo_count == 0)
+  ubo_array = (gl_uniform_buffer_object*) 
ralloc_array_size(merged_shader,sizeof(gl_uniform_buffer_object),current_ubo_count
 + 1);
+   else
+  ubo_array = (gl_uniform_buffer_object*) 
reralloc_array_size(merged_shader,ubo_array,sizeof(gl_uniform_buffer_object),current_ubo_count
 + 1);
+   struct gl_uniform_buffer_object& dest = ubo_array[current_ubo_count];
+   dest = source; // copy everything, but need to duplicate ptr afterward
+   dest.Name = ralloc_strdup(merged_shader,source.Name);
+   dest.StorageLayout.Compact = (gl_shader_ubo_variable*) 
ralloc_array_size(merged_shader,sizeof(gl_shader_ubo_variable),source.NumberOfVariables);
+   for (unsigned i = 0; i < dest.NumberOfVariables; i++) {
+  dest.StorageLayout.Compact[i] = source.StorageLayout.Compact[i];
+  dest.StorageLayout.Compact[i].Name = 
ralloc_strdup(merged_shader,source.StorageLayout.Compact[i].Name);
+   }
+   current_ubo_count++;
+   return &dest;
+}
+
+/**
+ * TODO : write the function
+ * This function should check consistency between 2 UBO having same name
+ * from different shaders :
+ * - Same layout
+ * - Same variables (name and type) in same order
+ * - Same matrix layout (ie row/column major)
+ */
+static bool validate_separate_ubo(const gl_uniform_buffer_object& first, const 
gl_uniform_buffer_object& second)
+{
+   return true;
+}
+
+
+#ifdef FEATURE_ARB_uniform_buffer_object
+/**
+ * At intrastage, when several shaders of same type are merged in a single one,
+ * this function generates UBOs of the newly created shader from them and
+ * performs necessary check.
+ */
+static
+void merge_intrastage_ubo ( gl_shader_program* prog, struct gl_shader* 
merged_shader,
+struct gl_shader **shader_list, unsigned 
num_shaders)
+{
+   hash_table *ht = hash_table_ctor(0, hash_table_string_hash,
+hash_table_string_compare);
+
+   for (unsigned shad_id=0; shad_id < num_shaders; shad_id++)
+   {
+  for(unsigned ubo_id=0; ubo_id < shader_list[shad_id]->UBOCount; ubo_id++)
+  {
+ struct gl_uniform_buffer_object* current_ubo = 
&(shader_list[shad_id]->UniformBufferObjects[ubo_id]);
+ struct gl_uniform_buffer_object* sh = (struct 
gl_uniform_buffer_object*) hash_table_find(ht,current_ubo->Name);
+ if(!sh)
+ {
+append_ubo(*current_ubo,merged_shader);
+hash_table_insert(ht,current_ubo,current_ubo->Name);
+ }
+ else
+ {
+if(!validate_separate_ubo(*current_ubo,*sh))
+   linker_error(prog,"Uniform Buffer Object '%s definition 
mismatch",sh->Name);
+ }
+  }
+   }
+
+   hash_table_dtor(ht);
+}
+#endif
 
 /**
  * Combine a group of shaders for a single stage to generate a linked shader
@@ -1017,7 +1094,9 @@ link_intrastage_shaders(void *mem_ctx,
 
   v.run(linked->ir);
}
-
+#if FEATURE_ARB_uniform_buffer_object
+   merge_intrastage_ubo(prog,linked,shader_list,num_shaders);
+#endif
return linked;
 }
 
@@ -1048,7 +1127,8 @@ update_array_sizes(struct gl_shader_program *prog)
 
 if ((var == NULL) || (var->mode != ir_var_uniform &&
   var->mode != ir_var_in &&
-  var->mode != ir_var

[Mesa-dev] [PATCH 8/9] mesa: add Uniform Buffer Object API implementation

2011-12-01 Thread Vincent Lejeune
   v2:Move implementation to ubo.cpp and ubo.h as suggested by
   Brian Paul
---
 src/mesa/main/api_exec.c |2 +
 src/mesa/main/bufferobj.c|   11 +
 src/mesa/main/ubo.c  |  268 ++
 src/mesa/main/ubo.cpp|  263 +
 src/mesa/main/ubo.h  |   33 +++
 src/mesa/sources.mak |1 +
 src/mesa/state_tracker/st_cb_bufferobjects.c |6 +-
 7 files changed, 583 insertions(+), 1 deletions(-)
 create mode 100644 src/mesa/main/ubo.c
 create mode 100644 src/mesa/main/ubo.cpp
 create mode 100644 src/mesa/main/ubo.h

diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c
index e0bf90d..c908719 100644
--- a/src/mesa/main/api_exec.c
+++ b/src/mesa/main/api_exec.c
@@ -102,6 +102,7 @@
 #if FEATURE_ARB_shader_objects
 #include "shaderapi.h"
 #include "uniforms.h"
+#include "ubo.h"
 #endif
 #include "syncobj.h"
 #include "main/dispatch.h"
@@ -307,6 +308,7 @@ _mesa_create_exec_table(void)
 #if FEATURE_ARB_shader_objects
_mesa_init_shader_dispatch(exec);
_mesa_init_shader_uniform_dispatch(exec);
+   _mesa_init_shader_uniform_buffer_objects(exec);
 #endif
 
/* 2. GL_EXT_blend_color */
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index b7e59e8..d74b78c 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -98,6 +98,8 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
  return &ctx->Texture.BufferObject;
   }
   break;
+   case GL_UNIFORM_BUFFER:
+  return &ctx->UniformBufferObject.UniformObj;
default:
   return NULL;
}
@@ -734,6 +736,10 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint 
buffer)
 
  break;
 #endif
+#if FEATURE_ARB_uniform_buffer_object
+  case GL_UNIFORM_BUFFER:
+ break;
+#endif
   default:
  _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)");
  break;
@@ -756,6 +762,11 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint 
buffer)
  _mesa_bind_buffer_range_for_transform_feedback(ctx, index, bufObj, 0, 
size);
  break;
 #endif
+#if FEATURE_ARB_uniform_buffer_object
+  case GL_UNIFORM_BUFFER:
+ ctx->UniformBufferObject.BindingPoint[index] = bufObj;
+ break;
+#endif
   default: /* should not go here */
  break;
}
diff --git a/src/mesa/main/ubo.c b/src/mesa/main/ubo.c
new file mode 100644
index 000..1e31df8
--- /dev/null
+++ b/src/mesa/main/ubo.c
@@ -0,0 +1,268 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2004-2011  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009-2011  VMware, Inc.  All Rights Reserved.
+ * Copyright © 2010-2011 Intel Corporation
+ * Copyright (C) 2011 Vincent Lejeune.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * API implementation of GL_ARB_uniform_buffer_object.
+ *
+ * Every uniform (in an UBO or not) is given an index that identifies it when
+ * calling one of these functions. Strictly speaking, such an index doesn't
+ * need to match location for classic uniform ; others drivers however use this
+ * approach so we're also matching them for compatibility purpose.
+ */
+
+#include 
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/dispatch.h"
+#include "main/image.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
+#include "main/shaderapi.h"
+#include "main/shaderobj.h"
+#include "main/uniforms.h"
+#include "main/hash.h"
+#include "program/prog_parameter.h"
+#include "program/prog_statevars.h"
+#include "program/prog_uniform.h"
+#include "program/prog_instruction.h"
+#include "main/ubo.h"
+#include "main/bufferobj.h"
+
+static void
+get_ubo_info (struct gl_context *ctx,
+  struct gl_shader_program *shProg, GLint ubo_index,
+  GLenum query, int *data)
+{
+  if (ubo_index > shProg->UBOCount || 

[Mesa-dev] [PATCH 9/9] gallium : st_glsl_to_tgsi handles UBO

2011-12-01 Thread Vincent Lejeune
---
 src/mesa/main/ubo.c|  268 
 src/mesa/state_tracker/st_atom_constbuf.c  |8 +
 src/mesa/state_tracker/st_extensions.c |4 +
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   92 +-
 4 files changed, 59 insertions(+), 313 deletions(-)
 delete mode 100644 src/mesa/main/ubo.c

diff --git a/src/mesa/main/ubo.c b/src/mesa/main/ubo.c
deleted file mode 100644
index 1e31df8..000
--- a/src/mesa/main/ubo.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2004-2011  Brian Paul   All Rights Reserved.
- * Copyright (C) 2009-2011  VMware, Inc.  All Rights Reserved.
- * Copyright © 2010-2011 Intel Corporation
- * Copyright (C) 2011 Vincent Lejeune.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * API implementation of GL_ARB_uniform_buffer_object.
- *
- * Every uniform (in an UBO or not) is given an index that identifies it when
- * calling one of these functions. Strictly speaking, such an index doesn't
- * need to match location for classic uniform ; others drivers however use this
- * approach so we're also matching them for compatibility purpose.
- */
-
-#include 
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/dispatch.h"
-#include "main/image.h"
-#include "main/mfeatures.h"
-#include "main/mtypes.h"
-#include "main/shaderapi.h"
-#include "main/shaderobj.h"
-#include "main/uniforms.h"
-#include "main/hash.h"
-#include "program/prog_parameter.h"
-#include "program/prog_statevars.h"
-#include "program/prog_uniform.h"
-#include "program/prog_instruction.h"
-#include "main/ubo.h"
-#include "main/bufferobj.h"
-
-static void
-get_ubo_info (struct gl_context *ctx,
-  struct gl_shader_program *shProg, GLint ubo_index,
-  GLenum query, int *data)
-{
-  if (ubo_index > shProg->UBOCount || ubo_index < 0)
-_mesa_error (ctx, GL_INVALID_VALUE,
-"glGetActiveUniformBlock(uniformBlockIndex)");
-
-  struct gl_uniform_buffer_object current_ubo =
-shProg->UniformBufferObject[ubo_index];
-
-  switch (query)
-{
-case GL_UNIFORM_BLOCK_BINDING:
-  //*data = current_ubo.BoundBuffer;
-  break;
-case GL_UNIFORM_BLOCK_DATA_SIZE:
-  //*data = 0;
-  break;
-case GL_UNIFORM_BLOCK_NAME_LENGTH:
-  *data = strlen (current_ubo.Name);
-  break;
-case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
-  *data = current_ubo.NumberOfVariables;
-  break;
-case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
-case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER:
-case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
-  //*data = 0;
-  break;
-default:
-  break;
-}
-}
-
-static GLuint
-get_indice (const struct gl_shader_program *prog, const char *name)
-{
-  void* index =
-hash_table_find (prog->Uniforms->NamedAccessUBOVariables, name);
-  if (index) {
- uintptr_t faked_index = (uintptr_t) index;
- return faked_index - 1;
-  }
-
-  return GL_INVALID_INDEX;
-}
-
-/**
- * This function checks if it can copy source into dest.
- * If it cannot, it returns 1, otherwise it returns 0 and
- * write size to *length if non NULL
- */
-static int
-copy_char_buffer (const char *source, char *dest, unsigned destsize,
- int *length)
-{
-  unsigned sourcesize = strlen (source);
-  if (sourcesize > destsize + 1)
-{
-  return -1;
-}
-  memcpy (dest, source, sourcesize);
-  dest[sourcesize] = '0';
-  if (length)
-*length = sourcesize;
-  return 0;
-}
-
-static void
-get_ubo_name (struct gl_context *ctx, struct gl_shader_program *shProg,
- GLint index, GLsizei bufsize, GLsizei * length, char *buffer)
-{
-  if (index >= shProg->UBOCount || index < 0)
-{
-  _mesa_error (ctx, GL_INVALID_VALUE,
-  "GetActiveUniformBlockName(uniformBlockIndex)");
-  return;
-}
-
-  struct gl_uniform_buffer_object current_ubo =
-shProg->Unifo

Re: [Mesa-dev] [PATCH] st/mesa: only resolve is number of samples is > 1

2011-12-01 Thread Roland Scheidegger
Am 30.11.2011 21:43, schrieb Jose Fonseca:
> 
> 
> - Original Message -
>> On 11/30/2011 09:10 PM, Dave Airlie wrote:
>>> From: Dave Airlie 
>>> 
>>> This fixes the firefox crash but I've no idea if its correct.
>> 
>> I don't think it is. Visual.samples is the value passed to
>> RenderbufferStorageMultisample, and 1 here means "a desired minimum
>> number of samples" so the actual sample count may (even if very
>> unlikely) be > 1.
>> 
>> If you don't implement resource_resolve, mesa/st shouldn't expose 
>> framebuffer_multisample for you, or you shouldn't expose > 0
>> samples (that's an issue with the gallium interface, which doesn't
>> define whether 0 means "no storage" or "single sampled").
> 
> src/gallium/docs/source/screen.rst is crystal clear on this matter: 0
> or 1 means single-sampled.
> 
> And isn't "multi-sampling" with "single-sampled" storage a paradox?
> 
> But now you mention, it's probably better to make 0 samples illegal,
> as it only creates unnecessary complexity (and I'm not sure it's
> handled correctly everywhere).
This is probably a fine change. I think the zero and one sample both
meaning single-sampled is because a) when it was introduced this meant
it did not needed to be initialized to some new value and b) in OGL
rendering single-sampled and multi-sampled but with only one sample
isn't actually the same. I don't think the latter case is handled right
though everywhere nor do I know if anyone cares (changes some
rasterization rules).

Roland


> 
> Jose
> 
>>> 
>>> Signed-off-by: Dave Airlie  --- 
>>> src/mesa/state_tracker/st_cb_blit.c |2 +- 1 files changed, 1
>>> insertions(+), 1 deletions(-)
>>> 
>>> diff --git a/src/mesa/state_tracker/st_cb_blit.c 
>>> b/src/mesa/state_tracker/st_cb_blit.c index 750f541..8f0c2e8
>>> 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++
>>> b/src/mesa/state_tracker/st_cb_blit.c @@ -178,7 +178,7 @@
>>> st_BlitFramebuffer(struct gl_context *ctx, 
>>> st->pipe->render_condition(st->pipe, NULL, 0); }
>>> 
>>> -   if (readFB->Visual.sampleBuffers > 
>>> drawFB->Visual.sampleBuffers) { +   if
>>> (readFB->Visual.sampleBuffers > drawFB->Visual.sampleBuffers &&
>>> readFB->Visual.samples > 1) { struct pipe_resolve_info info;
>>> 
>>> if (dstX0 < dstX1) {
>> 
>> ___ mesa-dev mailing
>> list mesa-dev@lists.freedesktop.org 
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> 
> ___ mesa-dev mailing
> list mesa-dev@lists.freedesktop.org 
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43404] Git head fails to build-No rule to make target 'default' in src/gallium/drivers/failover

2011-12-01 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43404

--- Comment #4 from idun...@lavabit.com 2011-12-01 08:18:11 PST ---
OK. 
Well, now to get autogen.sh to work--I don't have an intel card, but autogen.sh
needs libdrm_intel updated anyhow.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43404] Git head fails to build-No rule to make target 'default' in src/gallium/drivers/failover

2011-12-01 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43404

--- Comment #5 from José Fonseca  2011-12-01 08:22:28 PST 
---
./autogen.sh invokes ./configure automatically. You can pass the same arguments
as configure has, and tell it not to build intel drivers.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/9] glsl: change IR to add UBO information

2011-12-01 Thread Matt Turner
On Thu, Dec 1, 2011 at 3:35 PM, Vincent Lejeune  wrote:
> ---
>  src/glsl/ir.cpp            |    1 +
>  src/glsl/ir.h              |    6 ++
>  src/glsl/ir_clone.cpp      |    1 +
>  src/glsl/opt_dead_code.cpp |    6 ++
>  4 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
> index a5eca5a..bf11e4f 100644
> --- a/src/glsl/ir.cpp
> +++ b/src/glsl/ir.cpp
> @@ -1335,6 +1335,7 @@ ir_variable::ir_variable(const struct glsl_type *type, 
> const char *name,
>    this->pixel_center_integer = false;
>    this->depth_layout = ir_depth_layout_none;
>    this->used = false;
> +   this->is_ubo_variable = false;
>
>    if (type && type->base_type == GLSL_TYPE_SAMPLER)
>       this->read_only = true;
> diff --git a/src/glsl/ir.h b/src/glsl/ir.h
> index 1faae3c..dc77dec 100644
> --- a/src/glsl/ir.h
> +++ b/src/glsl/ir.h
> @@ -398,6 +398,12 @@ public:
>    int location;
>
>    /**
> +    * True if the variable is defined in the scope of a shader range Uniform
> +    * Buffer Object.
> +    */
> +   bool is_ubo_variable;
> +
> +   /**
>     * Built-in state that backs this uniform
>     *
>     * Once set at variable creation, \c state_slots must remain invariant.
> diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
> index c63615c..479f258 100644
> --- a/src/glsl/ir_clone.cpp
> +++ b/src/glsl/ir_clone.cpp
> @@ -52,6 +52,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) 
> const
>    var->explicit_location = this->explicit_location;
>    var->has_initializer = this->has_initializer;
>    var->depth_layout = this->depth_layout;
> +   var->is_ubo_variable = this->is_ubo_variable;
>
>    var->num_state_slots = this->num_state_slots;
>    if (this->state_slots) {
> diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp
> index 5b9546a..58ff534 100644
> --- a/src/glsl/opt_dead_code.cpp
> +++ b/src/glsl/opt_dead_code.cpp
> @@ -27,6 +27,7 @@
>  * Eliminates dead assignments and variable declarations from the code.
>  */
>
> +#include "../mesa/main/mtypes.h"
>  #include "ir.h"
>  #include "ir_visitor.h"
>  #include "ir_variable_refcount.h"
> @@ -100,6 +101,11 @@ do_dead_code(exec_list *instructions, bool 
> uniform_locations_assigned)
>         if (entry->var->mode == ir_var_uniform &&
>             (uniform_locations_assigned || entry->var->constant_value))
>            continue;
> +       /*if(entry->var->mode == ir_var_uniform && entry->var->UBO) {
> +          if(entry->var->UBO->UBO->Layout != packed)
> +            continue;
> +       }*/
> +

Is this meant to be commented-out?

Matt
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] r600g: Make tiling alignment restrictions match the DDX

2011-12-01 Thread Simon Farnsworth
It's unclear exactly what the alignment requirements are for Radeon tiled
surfaces, but they differ between the DDX and Mesa. Make Mesa match the DDX.

Signed-off-by: Simon Farnsworth 
---
This basically copies across the DDX versions of the restrictions. They
differ, and I'm not sure which one's right.

Someone from AMD should review this before it's applied.

 src/gallium/drivers/r600/r600_texture.c |   22 ++
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 2d041b0..5ac39aa 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -89,21 +89,21 @@ static unsigned r600_get_block_alignment(struct pipe_screen 
*screen,
int p_align;
 
switch(array_mode) {
-   case V_038000_ARRAY_1D_TILED_THIN1:
-   p_align = MAX2(8,
-  ((rscreen->tiling_info.group_bytes / 8 / 
pixsize)));
-   break;
case V_038000_ARRAY_2D_TILED_THIN1:
p_align = MAX2(rscreen->tiling_info.num_banks,
-  (((rscreen->tiling_info.group_bytes / 8 / 
pixsize)) *
-   rscreen->tiling_info.num_banks)) * 8;
+  (((rscreen->tiling_info.group_bytes / 8) / 
pixsize) * rscreen->tiling_info.num_banks)) * 8;
+   /* further restrictions for scanout */
+   p_align = MAX2(rscreen->tiling_info.num_banks * 8, p_align);
break;
-   case V_038000_ARRAY_LINEAR_ALIGNED:
-   p_align = MAX2(64, rscreen->tiling_info.group_bytes / pixsize);
+   case V_038000_ARRAY_1D_TILED_THIN1:
+   p_align = MAX2(8, (rscreen->tiling_info.group_bytes / (8 * 
pixsize)));
+   /* further restrictions for scanout */
+   p_align = MAX2((rscreen->tiling_info.group_bytes / pixsize), 
p_align);
break;
+   case V_038000_ARRAY_LINEAR_ALIGNED:
case V_038000_ARRAY_LINEAR_GENERAL:
default:
-   p_align = rscreen->tiling_info.group_bytes / pixsize;
+   p_align = MAX2(64, rscreen->tiling_info.group_bytes / pixsize);
break;
}
return p_align;
@@ -121,11 +121,9 @@ static unsigned r600_get_height_alignment(struct 
pipe_screen *screen,
break;
case V_038000_ARRAY_1D_TILED_THIN1:
case V_038000_ARRAY_LINEAR_ALIGNED:
-   h_align = 8;
-   break;
case V_038000_ARRAY_LINEAR_GENERAL:
default:
-   h_align = 1;
+   h_align = 8;
break;
}
return h_align;
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] r600g: Set tile_type correctly when textures are created

2011-12-01 Thread Simon Farnsworth
>From discussion on IRC, tile_type should be 1 for depth or stencil textures.

On Evergreen, it should also be 1 for some color buffers, but that's handled
in the evergreen_cb function when required.

Signed-off-by: Simon Farnsworth 
---

Doesn't fix my tiled scanout fun, but is needed for correctness.

 src/gallium/drivers/r600/r600_texture.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 5ac39aa..6143133 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -391,6 +391,7 @@ r600_texture_create_object(struct pipe_screen *screen,
resource->b.b.b.screen = screen;
rtex->pitch_override = pitch_in_bytes_override;
rtex->real_format = base->format;
+   rtex->tile_type = util_format_is_depth_or_stencil(base->format) ? 1 : 0;
 
/* We must split depth and stencil into two separate buffers on 
Evergreen. */
if (!(base->flags & R600_RESOURCE_FLAG_TRANSFER) &&
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Friday Night Segfaults

2011-12-01 Thread Kevin H. Hobbs
On 11/07/2011 06:02 PM, Brian Paul wrote:
> 
> No problem.  I pushed the first glReadPixels patch.  That should fix 
> reads from regular windows (non-FBOs).
> 
> -Brian
> 
> 

The OSMesa tests on the VTK and ParaView dashboards are still failing
with a solid color output image.

I've seen a lot of chatter about swrast on the list but I can't tell if
it relates to these failures.

Is osmesa being worked on?



signature.asc
Description: OpenPGP digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/2] update tnl module to the recent VERT_ATTRIB* changes.

2011-12-01 Thread Mathias Fröhlich

These two patches should fix:

https://bugs.freedesktop.org/show_bug.cgi?id=3D43353

Please review.


Mathias Fröhlich (2):
  mesa: Extend BITSET64_*_RANGE to work on arbitrary ranges.
  mesa: Renumber the tnl attributes to match VERT_ATTRIB*.

 src/mesa/main/bitset.h   |   21 ++--
 src/mesa/tnl/t_context.h |   58 
+++---
 2 files changed, 47 insertions(+), 32 deletions(-)

-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] mesa: Extend BITSET64_*_RANGE to work on arbitrary ranges.

2011-12-01 Thread Mathias Fröhlich
The BITSET64_{TEST,SET,CLEAR}_RANGE macros only work on ranges
wither in the lower 32 or in the upper 32 bits of the bitset.
This change extends these macros to work on arbitrary ranges
possibly crossing the bitset word boundary.

Signed-off-by: Mathias Froehlich 
---
 src/mesa/main/bitset.h |   21 ++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/bitset.h b/src/mesa/main/bitset.h
index 7a0704b..c27b4c4 100644
--- a/src/mesa/main/bitset.h
+++ b/src/mesa/main/bitset.h
@@ -129,17 +129,32 @@ __bitset_ffs(const BITSET_WORD *x, int n)
 
 /* bit range operations
  */
-#define BITSET64_TEST_RANGE(x, b, e) \
+#define BITSET64_TEST_SUBRANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
((x)[BITSET64_BITWORD(b)] & BITSET64_RANGE(b, e)) : \
(assert (!"BITSET64_TEST_RANGE: bit range crosses word boundary"), 0))
-#define BITSET64_SET_RANGE(x, b, e) \
+#define BITSET64_TEST_RANGE(x, b, e) \
+   (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
+   (BITSET64_TEST_SUBRANGE(x, b, e)) : \
+   (BITSET64_TEST_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \
+BITSET64_TEST_SUBRANGE(x, BITSET64_WORDBITS, e)))
+#define BITSET64_SET_SUBRANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
((x)[BITSET64_BITWORD(b)] |= BITSET64_RANGE(b, e)) : \
(assert (!"BITSET64_SET_RANGE: bit range crosses word boundary"), 0))
-#define BITSET64_CLEAR_RANGE(x, b, e) \
+#define BITSET64_SET_RANGE(x, b, e) \
+   (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
+   (BITSET64_SET_SUBRANGE(x, b, e)) : \
+   (BITSET64_SET_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \
+BITSET64_SET_SUBRANGE(x, BITSET64_WORDBITS, e)))
+#define BITSET64_CLEAR_SUBRANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
((x)[BITSET64_BITWORD(b)] &= ~BITSET64_RANGE(b, e)) : \
(assert (!"BITSET64_CLEAR_RANGE: bit range crosses word boundary"), 0))
+#define BITSET64_CLEAR_RANGE(x, b, e) \
+   (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
+   (BITSET64_CLEAR_SUBRANGE(x, b, e)) : \
+   (BITSET64_CLEAR_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \
+BITSET64_CLEAR_SUBRANGE(x, BITSET64_WORDBITS, e)))
 
 #endif
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] mesa: Renumber the tnl attributes to match VERT_ATTRIB*.

2011-12-01 Thread Mathias Fröhlich
Also renumber the tnl modules vertex attributes to match
the renumbered VERT_ATTRIB_* values.

This should fix

https://bugs.freedesktop.org/show_bug.cgi?id=43353

Signed-off-by: Mathias Froehlich 
---
 src/mesa/tnl/t_context.h |   58 
+++---
 1 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index a7e8c7c..36b1043 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -93,22 +93,22 @@ enum {
_TNL_ATTRIB_TEX6 = 14,
_TNL_ATTRIB_TEX7 = 15,
 
-   _TNL_ATTRIB_GENERIC0 = 16, /* doesn't really exist! */
-   _TNL_ATTRIB_GENERIC1 = 17,
-   _TNL_ATTRIB_GENERIC2 = 18,
-   _TNL_ATTRIB_GENERIC3 = 19,
-   _TNL_ATTRIB_GENERIC4 = 20,
-   _TNL_ATTRIB_GENERIC5 = 21,
-   _TNL_ATTRIB_GENERIC6 = 22,
-   _TNL_ATTRIB_GENERIC7 = 23,
-   _TNL_ATTRIB_GENERIC8 = 24,
-   _TNL_ATTRIB_GENERIC9 = 25,
-   _TNL_ATTRIB_GENERIC10 = 26,
-   _TNL_ATTRIB_GENERIC11 = 27,
-   _TNL_ATTRIB_GENERIC12 = 28,
-   _TNL_ATTRIB_GENERIC13 = 29,
-   _TNL_ATTRIB_GENERIC14 = 30,
-   _TNL_ATTRIB_GENERIC15 = 31,
+   _TNL_ATTRIB_GENERIC0 = 17, /* doesn't really exist! */
+   _TNL_ATTRIB_GENERIC1 = 18,
+   _TNL_ATTRIB_GENERIC2 = 19,
+   _TNL_ATTRIB_GENERIC3 = 20,
+   _TNL_ATTRIB_GENERIC4 = 21,
+   _TNL_ATTRIB_GENERIC5 = 22,
+   _TNL_ATTRIB_GENERIC6 = 23,
+   _TNL_ATTRIB_GENERIC7 = 24,
+   _TNL_ATTRIB_GENERIC8 = 25,
+   _TNL_ATTRIB_GENERIC9 = 26,
+   _TNL_ATTRIB_GENERIC10 = 27,
+   _TNL_ATTRIB_GENERIC11 = 28,
+   _TNL_ATTRIB_GENERIC12 = 29,
+   _TNL_ATTRIB_GENERIC13 = 30,
+   _TNL_ATTRIB_GENERIC14 = 31,
+   _TNL_ATTRIB_GENERIC15 = 32,
 
/* These alias with the generics, but they are not active
 * concurrently, so it's not a problem.  The TNL module
@@ -120,25 +120,25 @@ enum {
 * generic attribute in order to pick up per-vertex material
 * data.
 */
-   _TNL_ATTRIB_MAT_FRONT_AMBIENT = 16,
-   _TNL_ATTRIB_MAT_BACK_AMBIENT = 17,
-   _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 18,
-   _TNL_ATTRIB_MAT_BACK_DIFFUSE = 19,
-   _TNL_ATTRIB_MAT_FRONT_SPECULAR = 20,
-   _TNL_ATTRIB_MAT_BACK_SPECULAR = 21,
-   _TNL_ATTRIB_MAT_FRONT_EMISSION = 22,
-   _TNL_ATTRIB_MAT_BACK_EMISSION = 23,
-   _TNL_ATTRIB_MAT_FRONT_SHININESS = 24,
-   _TNL_ATTRIB_MAT_BACK_SHININESS = 25,
-   _TNL_ATTRIB_MAT_FRONT_INDEXES = 26,
-   _TNL_ATTRIB_MAT_BACK_INDEXES = 27,
+   _TNL_ATTRIB_MAT_FRONT_AMBIENT = 17,
+   _TNL_ATTRIB_MAT_BACK_AMBIENT = 18,
+   _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 19,
+   _TNL_ATTRIB_MAT_BACK_DIFFUSE = 20,
+   _TNL_ATTRIB_MAT_FRONT_SPECULAR = 21,
+   _TNL_ATTRIB_MAT_BACK_SPECULAR = 22,
+   _TNL_ATTRIB_MAT_FRONT_EMISSION = 23,
+   _TNL_ATTRIB_MAT_BACK_EMISSION = 24,
+   _TNL_ATTRIB_MAT_FRONT_SHININESS = 25,
+   _TNL_ATTRIB_MAT_BACK_SHININESS = 26,
+   _TNL_ATTRIB_MAT_FRONT_INDEXES = 27,
+   _TNL_ATTRIB_MAT_BACK_INDEXES = 28,
 
/* This is really a VERT_RESULT, not an attrib.  Need to fix
 * tnl to understand the difference.
 */
_TNL_ATTRIB_POINTSIZE = 16,
 
-   _TNL_ATTRIB_MAX = 32
+   _TNL_ATTRIB_MAX = 33
 } ;
 
 #define _TNL_ATTRIB_TEX(u)   (_TNL_ATTRIB_TEX0 + (u))
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] swrast: Fix signed/unsigned problems with negative strides.

2011-12-01 Thread Mathias Fröhlich

Hi,

The attached patch fixes a core dump in glReadPixels with traditional swrast.
The problem looks pretty much the same like the one the VTK guy Kevin H. Hobbs 
reports. At least his backtrace is mostly the same.

Please review.

Thanks

Mathias
From 92eaecb0f471d6705121ca346b43e3709989847f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= 
Date: Thu, 1 Dec 2011 20:48:10 +0100
Subject: [PATCH] swrast: Fix signed/unsigned problems with negative strides.

In swrast_map_renderbuffer negative strides lead to
render buffer map pointers that are off by 2^32.
Make sure that intermediate negative values are not
converted to an unsigned.

Signed-off-by: Mathias Froehlich 
---
 src/mesa/drivers/dri/swrast/swrast.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index bc115e8..6297604 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -419,8 +419,8 @@ swrast_map_renderbuffer(struct gl_context *ctx,
   stride = -stride;
}
 
-   map += y * stride;
-   map += x * cpp;
+   map += (GLsizei)y * stride;
+   map += (GLsizei)x * cpp;
 
*out_map = map;
*out_stride = stride;
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] swrast: Fix signed/unsigned problems with negative strides.

2011-12-01 Thread Brian Paul

On 12/01/2011 01:14 PM, Mathias Fröhlich wrote:


Hi,

The attached patch fixes a core dump in glReadPixels with traditional swrast.
The problem looks pretty much the same like the one the VTK guy Kevin H. Hobbs
reports. At least his backtrace is mostly the same.

Please review.

Thanks

Mathias



Reviewed-by: Brian Paul 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 0/2] update tnl module to the recent VERT_ATTRIB* changes.

2011-12-01 Thread Brian Paul

On 12/01/2011 01:03 PM, Mathias Fröhlich wrote:


These two patches should fix:

https://bugs.freedesktop.org/show_bug.cgi?id=3D43353

Please review.


Mathias Fröhlich (2):
   mesa: Extend BITSET64_*_RANGE to work on arbitrary ranges.
   mesa: Renumber the tnl attributes to match VERT_ATTRIB*.

  src/mesa/main/bitset.h   |   21 ++--
  src/mesa/tnl/t_context.h |   58
+++---
  2 files changed, 47 insertions(+), 32 deletions(-)



Looks good.  The piglit test passes again for me.

Reviewed-by: Brian Paul 

BTW, the bitset stuff is a mess, it's only used in one place and could 
be replaced by a GLbitfield64.


-Brian
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] Add depth cube map support to mesa swrast

2011-12-01 Thread Anuj Phogat
On Thu 01 Dec 2011 06:56:09 AM PST, Brian Paul wrote:
> On 11/30/2011 12:39 PM, Anuj Phogat wrote:
>> From: Anuj Phogat
>>
>> I made the suggested changes to swrast/s_texfilter.c (see the patch
>> listed below). Now it render
>> polygons without any texture (black) in depth-cube-map test (see the
>> patch sent on Nov 28 to piglit mailing list).
>> But the expected output is polygons rendered with different greyscale
>> (depth) textures.
>>
>> Some debugging info:
>> _mesa_choose_tex_format() returns MESA_FORMAT_Z32
>> _mesa_get_texstore_func() returns _mesa_texstore_z32
>> Based on MESA_FORMAT_Z32, selected dstType = GL_UNSIGNED_INT
>> Verified the values stored in depthValues[i] in
>> _mesa_unpack_depth_span(). Correct pixel values (depth values) are
>> reflected in this variable.
>> depthValues[i] is converted to GLuint and stored in zValues[i]
>>
>> But while rendering swImg->FetchTexel() (called from
>> sample_depth_texture() in swrast/s_texfilter.c) is unable to fetch
>> the corect texel values.
>>
>> Any thoughts on what could go wrong after storing the depth texture
>> correctly?
>
> Off-hand, I don't know.  I'd have to debug it a bit, but I probably
> won't have time to do that for a while.  Maybe you could take a closer
> look.
Yes, I'll dig in further.

> In any case, the patch looks correct.  I think the bug is elsewhere.
> Reviewed-by: Brian Paul 
>
> Can you commit this?
I don't have push access on mesa-dev. I'll appreciate if you can do it 
for me. Please make sure to commit the patch
for src/mesa/main/teximage.c as well. I sent it on same thread on Nov 
23.

Thanks
-Anuj


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/6] vl: Add missing mpeg fields to pipe_mpeg12_picture_desc

2011-12-01 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 src/gallium/include/pipe/p_video_state.h  |3 +++
 src/gallium/state_trackers/vdpau/decode.c |3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/gallium/include/pipe/p_video_state.h 
b/src/gallium/include/pipe/p_video_state.h
index 1940bf1..9a70eb7 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -134,6 +134,9 @@ struct pipe_mpeg12_picture_desc
unsigned concealment_motion_vectors;
unsigned intra_dc_precision;
unsigned f_code[2][2];
+   unsigned top_field_first;
+   unsigned full_pel_forward_vector;
+   unsigned full_pel_backward_vector;
unsigned num_slices;
 };
 
diff --git a/src/gallium/state_trackers/vdpau/decode.c 
b/src/gallium/state_trackers/vdpau/decode.c
index f135129..47212e3 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -245,6 +245,9 @@ vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder,
picture.f_code[1][0] = picture_info->f_code[1][0] - 1;
picture.f_code[1][1] = picture_info->f_code[1][1] - 1;
picture.num_slices = picture_info->slice_count;
+   picture.top_field_first = picture_info->top_field_first;
+   picture.full_pel_forward_vector = picture_info->full_pel_forward_vector;
+   picture.full_pel_backward_vector = picture_info->full_pel_backward_vector;
 
decoder->set_picture_parameters(decoder, &picture.base);
 
-- 
1.7.7.3



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/6] vl: Get rid of video_buffer.sampler_view_components

2011-12-01 Thread Maarten Lankhorst
No point in having it when just having sampler_view_planes is good enough. :-)

Signed-off-by: Maarten Lankhorst 
---
 src/gallium/auxiliary/vl/vl_compositor.c|   36 ++-
 src/gallium/auxiliary/vl/vl_compositor.h|2 +-
 src/gallium/auxiliary/vl/vl_video_buffer.c  |   46 +++---
 src/gallium/auxiliary/vl/vl_video_buffer.h  |1 -
 src/gallium/drivers/nouveau/nouveau_video.c |   48 +++
 src/gallium/drivers/nouveau/nouveau_video.h |1 -
 src/gallium/include/pipe/p_video_decoder.h  |5 ---
 7 files changed, 37 insertions(+), 102 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_compositor.c 
b/src/gallium/auxiliary/vl/vl_compositor.c
index 322ef8e..fff4340 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -71,7 +71,7 @@ create_vert_shader(struct vl_compositor *c)
 }
 
 static void *
-create_frag_shader_video_buffer(struct vl_compositor *c)
+create_frag_shader_video_buffer(struct vl_compositor *c, unsigned planes)
 {
struct ureg_program *shader;
struct ureg_src tc;
@@ -88,7 +88,8 @@ create_frag_shader_video_buffer(struct vl_compositor *c)
tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, 1, 
TGSI_INTERPOLATE_LINEAR);
for (i = 0; i < 3; ++i) {
   csc[i] = ureg_DECL_constant(shader, i);
-  sampler[i] = ureg_DECL_sampler(shader, i);
+  if (i < planes)
+ sampler[i] = ureg_DECL_sampler(shader, i);
}
texel = ureg_DECL_temporary(shader);
fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
@@ -97,8 +98,13 @@ create_frag_shader_video_buffer(struct vl_compositor *c)
 * texel.xyz = tex(tc, sampler[i])
 * fragment = csc * texel
 */
-   for (i = 0; i < 3; ++i)
-  ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), 
TGSI_TEXTURE_2D, tc, sampler[i]);
+   if (planes == 2) {
+  ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X), 
TGSI_TEXTURE_2D, tc, sampler[0]);
+  ureg_TEX(shader, ureg_writemask(texel, 
TGSI_WRITEMASK_Y|TGSI_WRITEMASK_Z), TGSI_TEXTURE_2D, tc, sampler[1]);
+   } else {
+  for (i = 0; i < 3; ++i)
+ ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), 
TGSI_TEXTURE_2D, tc, sampler[i]);
+   }
 
ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_W), 
ureg_imm1f(shader, 1.0f));
 
@@ -198,9 +204,14 @@ init_shaders(struct vl_compositor *c)
   return false;
}
 
-   c->fs_video_buffer = create_frag_shader_video_buffer(c);
-   if (!c->fs_video_buffer) {
-  debug_printf("Unable to create YCbCr-to-RGB fragment shader.\n");
+   c->fs_video_buffer2 = create_frag_shader_video_buffer(c, 2);
+   if (!c->fs_video_buffer2) {
+  debug_printf("Unable to create YCbCr-to-RGB fragment shader for 2 
planes.\n");
+  return false;
+   }
+   c->fs_video_buffer3 = create_frag_shader_video_buffer(c, 3);
+   if (!c->fs_video_buffer3) {
+  debug_printf("Unable to create YCbCr-to-RGB fragment shader for 3 
planes.\n");
   return false;
}
 
@@ -230,7 +241,8 @@ static void cleanup_shaders(struct vl_compositor *c)
assert(c);
 
c->pipe->delete_vs_state(c->pipe, c->vs);
-   c->pipe->delete_fs_state(c->pipe, c->fs_video_buffer);
+   c->pipe->delete_fs_state(c->pipe, c->fs_video_buffer2);
+   c->pipe->delete_fs_state(c->pipe, c->fs_video_buffer3);
c->pipe->delete_fs_state(c->pipe, c->fs_palette.yuv);
c->pipe->delete_fs_state(c->pipe, c->fs_palette.rgb);
c->pipe->delete_fs_state(c->pipe, c->fs_rgba);
@@ -644,13 +656,17 @@ vl_compositor_set_buffer_layer(struct vl_compositor *c,
assert(layer < VL_COMPOSITOR_MAX_LAYERS);
 
c->used_layers |= 1 << layer;
-   c->layers[layer].fs = c->fs_video_buffer;
 
-   sampler_views = buffer->get_sampler_view_components(buffer);
+   sampler_views = buffer->get_sampler_view_planes(buffer);
for (i = 0; i < 3; ++i) {
   c->layers[layer].samplers[i] = c->sampler_linear;
   pipe_sampler_view_reference(&c->layers[layer].sampler_views[i], 
sampler_views[i]);
}
+   if (sampler_views[2])
+  c->layers[layer].fs = c->fs_video_buffer3;
+   else
+  c->layers[layer].fs = c->fs_video_buffer2;
+   assert(sampler_views[1]);
 
calc_src_and_dst(&c->layers[layer], buffer->width, buffer->height,
 src_rect ? *src_rect : default_rect(&c->layers[layer]),
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h 
b/src/gallium/auxiliary/vl/vl_compositor.h
index f60f7da..cc91c2b 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -73,7 +73,7 @@ struct vl_compositor
void *vertex_elems_state;
 
void *vs;
-   void *fs_video_buffer;
+   void *fs_video_buffer2, *fs_video_buffer3;
void *fs_rgba;
 
struct {
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c 
b/src/gallium/auxiliary/vl/vl_video_buffer.c
index 6d714d4..a95a1dd 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/src/gallium/auxiliary/vl/vl_v

[Mesa-dev] [PATCH 3/6] nvc0: Add support for autobinding

2011-12-01 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 

---
 src/gallium/drivers/nvc0/nvc0_winsys.h |   19 ---
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_winsys.h 
b/src/gallium/drivers/nvc0/nvc0_winsys.h
index 0fcf994..dd4c887 100644
--- a/src/gallium/drivers/nvc0/nvc0_winsys.h
+++ b/src/gallium/drivers/nvc0/nvc0_winsys.h
@@ -20,6 +20,17 @@
 #define NV04_PFIFO_MAX_PACKET_LEN 2047
 #endif
 
+static INLINE void
+nouveau_bo_validate(struct nouveau_channel *chan,
+struct nouveau_bo *bo, unsigned flags)
+{
+   nouveau_reloc_emit(chan, NULL, 0, NULL, bo, 0, 0, flags, 0, 0);
+}
+
+#ifdef NVC0_USE_AUTOBIND
+#include "nouveau/nvc0_pushbuf.h"
+#else
+
 #define NVC0_SUBCH_3D 1
 #define NVC0_SUBCH_2D 2
 #define NVC0_SUBCH_MF 3
@@ -44,13 +55,6 @@ nouveau_bo_tile_layout(const struct nouveau_bo *bo)
return bo->tile_flags & NOUVEAU_BO_TILE_LAYOUT_MASK;
 }
 
-static INLINE void
-nouveau_bo_validate(struct nouveau_channel *chan,
-struct nouveau_bo *bo, unsigned flags)
-{
-   nouveau_reloc_emit(chan, NULL, 0, NULL, bo, 0, 0, flags, 0, 0);
-}
-
 /* incremental methods */
 static INLINE void
 BEGIN_RING(struct nouveau_channel *chan, uint32_t mthd, unsigned size)
@@ -116,5 +120,6 @@ BIND_RING(struct nouveau_channel *chan, struct 
nouveau_grobj *gr, unsigned s)
BEGIN_RING(chan, RING_GR(gr, 0x), 1);
OUT_RING  (chan, gr->grclass);
 }
+#endif
 
 #endif
-- 
1.7.7.3



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/6] nvc0: Add NVC0_RESOURCE_FLAG_VIDEO

2011-12-01 Thread Maarten Lankhorst
Video buffers require a specific tiling mode.

Signed-off-by: Maarten Lankhorst 

---
 src/gallium/drivers/nvc0/nvc0_miptree.c  |2 ++
 src/gallium/drivers/nvc0/nvc0_resource.h |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_miptree.c 
b/src/gallium/drivers/nvc0/nvc0_miptree.c
index a9d2c85..ba34095 100644
--- a/src/gallium/drivers/nvc0/nvc0_miptree.c
+++ b/src/gallium/drivers/nvc0/nvc0_miptree.c
@@ -213,6 +213,8 @@ nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt)
   lvl->offset = mt->total_size;
 
   lvl->tile_mode = nvc0_tex_choose_tile_dims(nbx, nby, d);
+  if (unlikely(pt->flags & NVC0_RESOURCE_FLAG_VIDEO))
+ lvl->tile_mode = 0x10;
 
   tsx = NVC0_TILE_SIZE_X(lvl->tile_mode); /* x is tile row pitch in bytes 
*/
   tsy = NVC0_TILE_SIZE_Y(lvl->tile_mode);
diff --git a/src/gallium/drivers/nvc0/nvc0_resource.h 
b/src/gallium/drivers/nvc0/nvc0_resource.h
index 6d946c8..1d68029 100644
--- a/src/gallium/drivers/nvc0/nvc0_resource.h
+++ b/src/gallium/drivers/nvc0/nvc0_resource.h
@@ -4,6 +4,7 @@
 
 #include "nv50/nv50_resource.h"
 
+#define NVC0_RESOURCE_FLAG_VIDEO (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 0)
 
 #define NVC0_TILE_SHIFT_X(m) m) >> 0) & 0xf) + 6)
 #define NVC0_TILE_SHIFT_Y(m) m) >> 4) & 0xf) + 3)
-- 
1.7.7.3



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/6] vl: Remove most members of pipe_video_decoder

2011-12-01 Thread Maarten Lankhorst
create_buffer, destroy_buffer and set_buffer are a curiosity of 
vl_mpeg12_decoder
and shouldn't be part of the api.

set_quant_matrix and set_reference_frames shouldn't be separate calls, but part 
of
picparm, which is a requirement for h264 to work.
set_decode_target and set_picture_parameters should instead be passed as 
argument to
decode_(bitstream,macroblocks). flush is used to signal in XvMC that current 
frame has
ended. begin_frame and end_frame are moved into vl_mpeg12_decoder internally.

Signed-off-by: Maarten Lankhorst 

---
 src/gallium/auxiliary/vl/vl_decoder.c  |   13 -
 src/gallium/auxiliary/vl/vl_decoder.h  |6 -
 src/gallium/auxiliary/vl/vl_idct.c |   14 +-
 src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c |   44 ++--
 src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h |4 +-
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c   |  124 -
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.h   |3 +-
 src/gallium/auxiliary/vl/vl_vlc.h  |   18 +-
 src/gallium/drivers/nouveau/nouveau_video.c|   57 +---
 src/gallium/drivers/nvfx/nvfx_screen.c |2 -
 src/gallium/drivers/r300/r300_screen.c |2 -
 src/gallium/drivers/r600/r600_pipe.c   |2 -
 src/gallium/drivers/softpipe/sp_screen.c   |2 -
 src/gallium/include/pipe/p_video_decoder.h |   58 +
 src/gallium/include/pipe/p_video_enums.h   |3 +-
 src/gallium/include/pipe/p_video_state.h   |   15 +-
 src/gallium/state_trackers/vdpau/decode.c  |  295 
 src/gallium/state_trackers/vdpau/vdpau_private.h   |3 -
 src/gallium/state_trackers/xorg/xvmc/surface.c |  109 +---
 .../state_trackers/xorg/xvmc/xvmc_private.h|1 -
 20 files changed, 251 insertions(+), 524 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_decoder.c 
b/src/gallium/auxiliary/vl/vl_decoder.c
index 383e02d..da905a6 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_decoder.c
@@ -44,19 +44,6 @@ vl_profile_supported(struct pipe_screen *screen, enum 
pipe_video_profile profile
}
 }
 
-unsigned
-vl_num_buffers_desired(struct pipe_screen *screen, enum pipe_video_profile 
profile)
-{
-   assert(screen);
-   switch (u_reduce_video_profile(profile)) {
-  case PIPE_VIDEO_CODEC_MPEG12:
- return 4;
-
-  default:
- return 1;
-   }
-}
-
 struct pipe_video_decoder *
 vl_create_decoder(struct pipe_context *pipe,
   enum pipe_video_profile profile,
diff --git a/src/gallium/auxiliary/vl/vl_decoder.h 
b/src/gallium/auxiliary/vl/vl_decoder.h
index a997516..a7abe9c 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.h
+++ b/src/gallium/auxiliary/vl/vl_decoder.h
@@ -38,12 +38,6 @@ bool
 vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile 
profile);
 
 /**
- * the desired number of buffers for optimal operation
- */
-unsigned
-vl_num_buffers_desired(struct pipe_screen *screen, enum pipe_video_profile 
profile);
-
-/**
  * standard implementation of pipe->create_video_decoder
  */
 struct pipe_video_decoder *
diff --git a/src/gallium/auxiliary/vl/vl_idct.c 
b/src/gallium/auxiliary/vl/vl_idct.c
index a2b3537..8394542 100644
--- a/src/gallium/auxiliary/vl/vl_idct.c
+++ b/src/gallium/auxiliary/vl/vl_idct.c
@@ -614,9 +614,9 @@ init_source(struct vl_idct *idct, struct vl_idct_buffer 
*buffer)
 }
 
 static void
-cleanup_source(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+cleanup_source(struct vl_idct_buffer *buffer)
 {
-   assert(idct && buffer);
+   assert(buffer);
 
pipe_surface_reference(&buffer->fb_state_mismatch.cbufs[0], NULL);
 
@@ -665,13 +665,13 @@ error_surfaces:
 }
 
 static void
-cleanup_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+cleanup_intermediate(struct vl_idct_buffer *buffer)
 {
unsigned i;
 
-   assert(idct && buffer);
+   assert(buffer);
 
-   for(i = 0; i < idct->nr_of_render_targets; ++i)
+   for(i = 0; i < buffer->fb_state.nr_cbufs; ++i)
   pipe_surface_reference(&buffer->fb_state.cbufs[i], NULL);
 
pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, 
NULL);
@@ -823,8 +823,8 @@ vl_idct_cleanup_buffer(struct vl_idct_buffer *buffer)
 {
assert(buffer);
 
-   cleanup_source(buffer->idct, buffer);
-   cleanup_intermediate(buffer->idct, buffer);
+   cleanup_source(buffer);
+   cleanup_intermediate(buffer);
 
pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, NULL);
pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, 
NULL);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
index 936cf2c..ddeaf31 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
@@ -823,7 +823,7 @@ decode_slice(struct vl_mpg12_bs *bs)
   inc += vl_vlc_get_vlclbf(&bs->vlc, tbl_

[Mesa-dev] [PATCH 6/6] vl: Add support for h264

2011-12-01 Thread Maarten Lankhorst
And the reason why I needed quant/reference_frames calls gone..

Signed-off-by: Maarten Lankhorst 

---
 src/gallium/include/pipe/p_video_state.h  |   47 +
 src/gallium/state_trackers/vdpau/decode.c |   63 +
 2 files changed, 110 insertions(+), 0 deletions(-)

diff --git a/src/gallium/include/pipe/p_video_state.h 
b/src/gallium/include/pipe/p_video_state.h
index 0650b19..4a1c018 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -240,6 +240,53 @@ struct pipe_vc1_picture_desc
uint8_t pquant;
 };
 
+struct pipe_h264_reference_frame
+{
+   struct pipe_video_buffer *surface;
+   bool is_long_term;
+   bool top_is_reference;
+   bool bottom_is_reference;
+   int32_t field_order_cnt[2];
+   uint16_t frame_idx;
+};
+
+struct pipe_h264_picture_desc
+{
+   struct pipe_picture_desc base;
+   uint32_t slice_count;
+   int32_t field_order_cnt[2];
+   bool is_reference;
+
+   uint16_t frame_num;
+   uint8_t field_pic_flag;
+   uint8_t bottom_field_flag;
+   uint8_t num_ref_frames;
+   uint8_t mb_adaptive_frame_field_flag;
+   uint8_t constrained_intra_pred_flag;
+   uint8_t weighted_pred_flag;
+   uint8_t weighted_bipred_idc;
+   uint8_t frame_mbs_only_flag;
+   uint8_t transform_8x8_mode_flag;
+   int8_t chroma_qp_index_offset;
+   int8_t second_chroma_qp_index_offset;
+   int8_t pic_init_qp_minus26;
+   uint8_t num_ref_idx_l0_active_minus1;
+   uint8_t num_ref_idx_l1_active_minus1;
+   uint8_t log2_max_frame_num_minus4;
+   uint8_t pic_order_cnt_type;
+   uint8_t log2_max_pic_order_cnt_lsb_minus4;
+   uint8_t delta_pic_order_always_zero_flag;
+   uint8_t direct_8x8_inference_flag;
+   uint8_t entropy_coding_mode_flag;
+   uint8_t pic_order_present_flag;
+   uint8_t deblocking_filter_control_present_flag;
+   uint8_t redundant_pic_cnt_present_flag;
+
+   uint8_t *scaling_lists_4x4;
+   uint8_t *scaling_lists_8x8;
+   struct pipe_h264_reference_frame refs[16];
+};
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/gallium/state_trackers/vdpau/decode.c 
b/src/gallium/state_trackers/vdpau/decode.c
index 45009ef..eea7077 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -309,6 +309,65 @@ vlVdpDecoderRenderVC1(struct pipe_vc1_picture_desc 
*picture,
return VDP_STATUS_OK;
 }
 
+static VdpStatus
+vlVdpDecoderRenderH264(struct pipe_h264_picture_desc *p,
+   VdpPictureInfoH264 *vdp)
+{
+   unsigned i;
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding H264\n");
+
+   p->slice_count = vdp->slice_count;
+   p->field_order_cnt[0] = vdp->field_order_cnt[0];
+   p->field_order_cnt[1] = vdp->field_order_cnt[1];
+   p->is_reference = vdp->is_reference;
+
+   p->frame_num = vdp->frame_num;
+   p->field_pic_flag = vdp->field_pic_flag;
+   p->bottom_field_flag = vdp->bottom_field_flag;
+   p->num_ref_frames = vdp->num_ref_frames;
+   p->mb_adaptive_frame_field_flag = vdp->mb_adaptive_frame_field_flag;
+   p->constrained_intra_pred_flag = vdp->constrained_intra_pred_flag;
+   p->weighted_pred_flag = vdp->weighted_pred_flag;
+   p->weighted_bipred_idc = vdp->weighted_bipred_idc;
+   p->frame_mbs_only_flag = vdp->frame_mbs_only_flag;
+   p->transform_8x8_mode_flag = vdp->transform_8x8_mode_flag;
+   p->chroma_qp_index_offset = vdp->chroma_qp_index_offset;
+   p->second_chroma_qp_index_offset = vdp->second_chroma_qp_index_offset;
+   p->pic_init_qp_minus26 = vdp->pic_init_qp_minus26;
+   p->num_ref_idx_l0_active_minus1 = vdp->num_ref_idx_l0_active_minus1;
+   p->num_ref_idx_l1_active_minus1 = vdp->num_ref_idx_l1_active_minus1;
+   p->log2_max_frame_num_minus4 = vdp->log2_max_frame_num_minus4;
+   p->pic_order_cnt_type = vdp->pic_order_cnt_type;
+   p->log2_max_pic_order_cnt_lsb_minus4 = 
vdp->log2_max_pic_order_cnt_lsb_minus4;
+   p->delta_pic_order_always_zero_flag = vdp->delta_pic_order_always_zero_flag;
+   p->direct_8x8_inference_flag = vdp->direct_8x8_inference_flag;
+   p->entropy_coding_mode_flag = vdp->entropy_coding_mode_flag;
+   p->pic_order_present_flag = vdp->pic_order_present_flag;
+   p->deblocking_filter_control_present_flag = 
vdp->deblocking_filter_control_present_flag;
+   p->redundant_pic_cnt_present_flag = vdp->redundant_pic_cnt_present_flag;
+
+   p->scaling_lists_4x4 = vdp->scaling_lists_4x4[0];
+   p->scaling_lists_8x8 = vdp->scaling_lists_8x8[0];
+   for (i = 0; i < 16; ++i) {
+  struct pipe_h264_reference_frame *ref = &p->refs[i];
+  VdpReferenceFrameH264 *vdp_ref = &vdp->referenceFrames[i];
+  if (vdp_ref->surface != VDP_INVALID_HANDLE) {
+ vlVdpSurface *surf = vlGetDataHTAB(vdp_ref->surface);
+ if (!surf)
+return VDP_STATUS_INVALID_HANDLE;
+ ref->surface = surf->video_buffer;
+  } else
+ ref->surface = NULL;
+  ref->is_long_term = vdp_ref->is_long_term;
+  ref->top_is_reference = vdp_ref->top_is_reference;
+  ref->bottom_is_reference = vdp_ref->bottom_is_reference;
+ 

Re: [Mesa-dev] [PATCH 3/6] nvc0: Add support for autobinding

2011-12-01 Thread Maarten Lankhorst
Hey,

On 12/02/2011 01:03 AM, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst 
>
> ---
>  src/gallium/drivers/nvc0/nvc0_winsys.h |   19 ---
>  1 files changed, 12 insertions(+), 7 deletions(-)
>
Ignore this patch please, not really needed.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/6] glsl: return visit_stop in ir_validate::visit_enter() to silence warning

2011-12-01 Thread Brian Paul
---
 src/glsl/ir_validate.cpp |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index a352012..20a0377 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -585,6 +585,7 @@ dump_ir:
printf("callee:\n");
callee->print();
abort();
+   return visit_stop;
 }
 
 void
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/6] mesa: fix potential mem leak in generate_mipmap_compressed()

2011-12-01 Thread Brian Paul
Fixes a coverity warning.
---
 src/mesa/main/mipmap.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index c621800..fd6e582 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -2048,6 +2048,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum 
target,
   dstImage = _mesa_get_tex_image(ctx, texObj, target, level + 1);
   if (!dstImage) {
  _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
+ free(temp_dst);
  return;
   }
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/6] mesa: move _mesa_error() call in compressedteximage()

2011-12-01 Thread Brian Paul
We shouldn't call _mesa_error() if the target is a proxy texture.
Errors are handled later in the function.
Fixes a Coverity warning.
---
 src/mesa/main/teximage.c |9 ++---
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 2bc7abd..69d5642 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3310,14 +3310,9 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
   internalFormat, width, height, depth,
   border, imageSize, &reason);
 
-   if (error) {
-  _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason);
-  return;
-   }
-
 #if FEATURE_ES
/* XXX this is kind of a hack */
-   if (dims == 2) {
+   if (!error && dims == 2) {
   switch (internalFormat) {
   case GL_PALETTE4_RGB8_OES:
   case GL_PALETTE4_RGBA8_OES:
@@ -3371,7 +3366,7 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
   struct gl_texture_image *texImage;
 
   if (error) {
- _mesa_error(ctx, error, "glCompressedTexImage%uD", dims);
+ _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason);
  return;
   }
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/6] vbo: remove unreachable _mesa_error() call

2011-12-01 Thread Brian Paul
If mode is not GL_POINT/LINE/FILL we'll have already reported the
error earlier in the function and returned so we can never get here.
---
 src/mesa/vbo/vbo_exec_api.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 70551e0..4be0169 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -655,9 +655,6 @@ vbo_exec_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint 
j1, GLint j2)
 CALL_End(GET_DISPATCH(), ());
   }
   break;
-   default:
-  _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
-  return;
}
 }
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/6] mesa: remove unreachable code in _mesa_unpack_color_span_ubyte()

2011-12-01 Thread Brian Paul
We checked if srcType == GL_UNSIGNED_BYTE earlier so there was no
way to reach this code.  This was left-over code from the GLchan
removal work.
---
 src/mesa/main/pack.c |   64 --
 1 files changed, 0 insertions(+), 64 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 4754d34..0bd4ff1 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -3611,70 +3611,6 @@ _mesa_unpack_color_span_ubyte(struct gl_context *ctx,
 return;
  }
   }
-  /*
-   * Common situation, loading 8bit RGBA/RGB source images
-   * into 16/32 bit destination. (OSMesa16/32)
-   */
-  else if (srcType == GL_UNSIGNED_BYTE) {
- if (dstFormat == GL_RGBA) {
-if (srcFormat == GL_RGB) {
-   GLuint i;
-   const GLubyte *src = (const GLubyte *) source;
-   GLubyte *dst = dest;
-   for (i = 0; i < n; i++) {
-  dst[0] = src[0];
-  dst[1] = src[1];
-  dst[2] = src[2];
-  dst[3] = 255;
-  src += 3;
-  dst += 4;
-   }
-   return;
-}
-else if (srcFormat == GL_RGBA) {
-   GLuint i;
-   const GLubyte *src = (const GLubyte *) source;
-   GLubyte *dst = dest;
-   for (i = 0; i < n; i++) {
-  dst[0] = src[0];
-  dst[1] = src[1];
-  dst[2] = src[2];
-  dst[3] = src[3];
-  src += 4;
-  dst += 4;
-   }
-   return;
- }
- }
- else if (dstFormat == GL_RGB) {
-if (srcFormat == GL_RGB) {
-   GLuint i;
-   const GLubyte *src = (const GLubyte *) source;
-   GLubyte *dst = dest;
-   for (i = 0; i < n; i++) {
-  dst[0] = src[0];
-  dst[1] = src[1];
-  dst[2] = src[2];
-  src += 3;
-  dst += 3;
-   }
-   return;
-}
-else if (srcFormat == GL_RGBA) {
-   GLuint i;
-   const GLubyte *src = (const GLubyte *) source;
-   GLubyte *dst = dest;
-   for (i = 0; i < n; i++) {
-  dst[0] = src[0];
-  dst[1] = src[1];
-  dst[2] = src[2];
-  src += 4;
-  dst += 3;
-   }
-   return;
-}
- }
-  }
}
 
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 6/6] mesa: add casts to fix unpack_SIGNED_GR1616()

2011-12-01 Thread Brian Paul
We were passing unsigned values to the macro before.
---
 src/mesa/main/format_unpack.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 26f9243..d8fa0cb 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1195,8 +1195,8 @@ unpack_SIGNED_GR1616(const void *src, GLfloat dst[][4], 
GLuint n)
const GLuint *s = ((const GLuint *) src);
GLuint i;
for (i = 0; i < n; i++) {
-  dst[i][RCOMP] = SHORT_TO_FLOAT_TEX( s[i] & 0x );
-  dst[i][GCOMP] = SHORT_TO_FLOAT_TEX( s[i] >> 16 );
+  dst[i][RCOMP] = SHORT_TO_FLOAT_TEX( (GLshort) (s[i] & 0x) );
+  dst[i][GCOMP] = SHORT_TO_FLOAT_TEX( (GLshort) (s[i] >> 16) );
   dst[i][BCOMP] = 0.0F;
   dst[i][ACOMP] = 1.0F;
}
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: Reject glDrawPixels(integer format).

2011-12-01 Thread Eric Anholt
When folding GL_EXT_texture_integer into the core, a new (and very
sensible) restriction was added.
---
 src/mesa/main/drawpix.c |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 412cc15..c9e714b 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -30,6 +30,7 @@
 #include "enums.h"
 #include "feedback.h"
 #include "framebuffer.h"
+#include "image.h"
 #include "mfeatures.h"
 #include "pbo.h"
 #include "readpix.h"
@@ -76,6 +77,23 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
   goto end;  /* the error code was recorded */
}
 
+   /* GL 3.0 introduced a new restriction on glDrawPixels() over what was in
+* GL_EXT_texture_integer.  From section 3.7.4 ("Rasterization of Pixel
+* Rectangles) on page 151 of the GL 3.0 specification:
+*
+* "If format contains integer components, as shown in table 3.6, an
+*  INVALID OPERATION error is generated."
+*
+* Since DrawPixels rendering would be merely undefined if not an error (due
+* to a lack of defined mapping from integer data to gl_Color fragment 
shader
+* input), NVIDIA's implementation also just returns this error despite
+* exposing GL_EXT_texture_integer, just return an error regardless.
+*/
+   if (_mesa_is_integer_format(format)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(integer format)");
+  goto end;
+   }
+
if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) {
   goto end;  /* the error code was recorded */
}
-- 
1.7.7.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] mesa: Fix assertions for block size handling in glCompressedTexSubImage2D.

2011-12-01 Thread Eric Anholt
Anything of less than (bw, bh) size is possible when you consider
rectangular textures, and this code is (now) safe for those.  Even for
power-of-two textures, width could be 4 for FXT1 while not being
aligned to block size.

Fixes piglit compressedteximage GL_COMPRESSED_RGB_FXT1_3DFX
---
 src/mesa/main/texstore.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 78b64ce..620734c 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -5115,8 +5115,8 @@ _mesa_store_compressed_texsubimage2d(struct gl_context 
*ctx, GLenum target,
_mesa_get_format_block_size(texFormat, &bw, &bh);
 
/* these should have been caught sooner */
-   ASSERT((width % bw) == 0 || width == 2 || width == 1);
-   ASSERT((height % bh) == 0 || height == 2 || height == 1);
+   ASSERT((width % bw) == 0 || width < bw);
+   ASSERT((height % bh) == 0 || height < bh);
ASSERT((xoffset % bw) == 0);
ASSERT((yoffset % bh) == 0);
 
-- 
1.7.7.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] mesa: Fix glCompressedTexSubImage (and non-Sub) for height == 2 or 1.

2011-12-01 Thread Eric Anholt
Generally this code works with width and height aligned to compressed
blocks, but but at the 2x2 and 1x1 levels of a square texture (or
height < bh in general), we were skipping uploading our single row of
blocks.

Fixes piglit compressedteximage GL_COMPRESSED_RGBA_S3TC_DXT5_EXT.
---
 src/mesa/main/texstore.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index ef43ed9..78b64ce 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -5138,7 +5138,7 @@ _mesa_store_compressed_texsubimage2d(struct gl_context 
*ctx, GLenum target,
 
if (dstMap) {
   bytesPerRow = srcRowStride;  /* bytes per row of blocks */
-  rows = height / bh;  /* rows in blocks */
+  rows = (height + bh - 1) / bh;  /* rows in blocks */
 
   /* copy rows of blocks */
   for (i = 0; i < rows; i++) {
-- 
1.7.7.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/6] mesa: fix potential mem leak in generate_mipmap_compressed()

2011-12-01 Thread Vinson Lee

On Dec 1, 2011, at 4:45 PM, Brian Paul wrote:

> Fixes a coverity warning.
> ---
> src/mesa/main/mipmap.c |1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
> index c621800..fd6e582 100644
> --- a/src/mesa/main/mipmap.c
> +++ b/src/mesa/main/mipmap.c
> @@ -2048,6 +2048,7 @@ generate_mipmap_compressed(struct gl_context *ctx, 
> GLenum target,
>   dstImage = _mesa_get_tex_image(ctx, texObj, target, level + 1);
>   if (!dstImage) {
>  _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
> + free(temp_dst);
>  return;
>   }
> 
> -- 
> 1.7.3.4
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Reviewed-by: Vinson Lee 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: Use VERT_{ATTRIB, BIT}* for ARB input validation.

2011-12-01 Thread Mathias Fröhlich

Hi,

Attached is a change to the ARB program parser that should fix

https://bugs.freedesktop.org/show_bug.cgi?id=43407

Please review.

Thanks

Mathias
From 4a3d9f06651c5cd51edcb394fa598153e5fea2f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= 
Date: Fri, 2 Dec 2011 08:08:07 +0100
Subject: [PATCH] mesa: Use VERT_{ATTRIB,BIT}* for ARB input validation.

For validating ARB program inputs replace hard
coded bitfield and attribute number with the appropriate
VERT_{ATTRIB,BIT}* variant.

This should fix:

https://bugs.freedesktop.org/show_bug.cgi?id=43407

Signed-off-by: Mathias Froehlich 
---
 src/mesa/program/program_parse.y  |6 +++---
 src/mesa/program/program_parser.h |2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y
index 9fdb99d..4f958a9 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -1110,7 +1110,7 @@ ATTRIB_statement: ATTRIB IDENTIFIER '=' attribBinding
 	  YYERROR;
 	   } else {
 	  s->attrib_binding = $4;
-	  state->InputsBound |= (1U << s->attrib_binding);
+	  state->InputsBound |= BITFIELD64_BIT(s->attrib_binding);
 
 	  if (!validate_inputs(& @4, state)) {
 		 YYERROR;
@@ -2403,9 +2403,9 @@ set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index,
 int
 validate_inputs(struct YYLTYPE *locp, struct asm_parser_state *state)
 {
-   const int inputs = state->prog->InputsRead | state->InputsBound;
+   const GLbitfield64 inputs = state->prog->InputsRead | state->InputsBound;
 
-   if (((inputs & 0x0) & (inputs >> 16)) != 0) {
+   if (((inputs & VERT_BIT_FF_ALL) & (inputs >> VERT_ATTRIB_GENERIC0)) != 0) {
   yyerror(locp, state, "illegal use of generic attribute and name attribute");
   return 0;
}
diff --git a/src/mesa/program/program_parser.h b/src/mesa/program/program_parser.h
index 5637598..bc75614 100644
--- a/src/mesa/program/program_parser.h
+++ b/src/mesa/program/program_parser.h
@@ -191,7 +191,7 @@ struct asm_parser_state {
 * multiple ATTRIB statements bind illegal combinations of vertex
 * attributes.
 */
-   unsigned InputsBound;
+   GLbitfield64 InputsBound;
 
enum {
   invalid_mode = 0,
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev