Re: [Mesa-dev] 3D DRI running on i5 GMA HD/vxWorks 6.8 (demo video attached)

2012-04-11 Thread Kenneth Graunke

On 04/11/2012 12:41 AM, Srinivasulu Reddy Malapati -ERS, HCL Tech wrote:

Hi Josh ,

I am also trying integration of Mesa on VxWorks with Wokbench 3.2. I
have selected “VxWorks Application Project” Type to start with and I am
getting a lot of errors . Can you please suggest me on how to proceed in
that and it will be a great help for me.

Thanking you in Advance

Srinivas.


Hi,

You probably want to contact the original poster directly (joshua he 
), seeing as this thread is a full year old.  I 
don't know if he reads this mailing list actively; as far as I know he's 
only posted twice, once in July 2010, and again in April 2011.


I doubt anyone else on mesa-dev has worked much with vxWorks, so you 
probably won't be able to find much help here.


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


Re: [Mesa-dev] [PATCH] glsl: If an "if" has no "then" or "else" code left, remove it.

2012-04-11 Thread Kenneth Graunke

On 04/11/2012 08:49 PM, Matt Turner wrote:

On Wed, Apr 11, 2012 at 9:33 PM, Eric Anholt  wrote:

Cuts 8/1068 instructions from glyphy's fragment shaders on i965.
---
  src/glsl/opt_if_simplification.cpp |8 
  1 file changed, 8 insertions(+)

diff --git a/src/glsl/opt_if_simplification.cpp 
b/src/glsl/opt_if_simplification.cpp
index 940dd08..7e88208 100644
--- a/src/glsl/opt_if_simplification.cpp
+++ b/src/glsl/opt_if_simplification.cpp
@@ -66,6 +66,14 @@ do_if_simplification(exec_list *instructions)
  ir_visitor_status
  ir_if_simplification_visitor::visit_leave(ir_if *ir)
  {
+   /* If the if statement has nothing on either side, remove it. */
+   if (ir->then_instructions.is_empty()&&
+   ir->else_instructions.is_empty()) {
+  ir->remove();
+  this->made_progress = true;
+  return visit_continue;
+   }
+
/* FINISHME: Ideally there would be a way to note that the condition results
 * FINISHME: in a constant before processing both of the other subtrees.
 * FINISHME: This can probably be done with some flags, but it would take
--
1.7.9.5


Follow on: If then_instructions is empty, is there any benefit in
inverting the if conditional and moving the else_instructions into the
place of then_instructions?

Matt


Yeah.  I think in that case, i965 would ultimately emit the assembly:

if(8) ...
else(8)
...actual code...
endif(8)

which is silly.  This is a good place to patch that up.

(I could've sworn we did that already, but I can't seem to find it.)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] 3D DRI running on i5 GMA HD/vxWorks 6.8 (demo video attached)

2012-04-11 Thread Srinivasulu Reddy Malapati -ERS, HCL Tech
Hi Josh ,
I am also trying  integration of Mesa on VxWorks with Wokbench 3.2. I have 
selected  "VxWorks Application Project" Type to start with and I am getting a 
lot of errors . Can you please suggest me on how to proceed in that and it will 
be a great help for me.

Thanking you in Advance

Srinivas.


::DISCLAIMER::
---

The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. 
Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the 
opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is 
strictly prohibited. If you have
received this email in error please delete it and notify the sender 
immediately. Before opening any mail and
attachments please check them for viruses and defect.

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


[Mesa-dev] [PATCH] ir_to_mesa: Fix uninitialized member in add_uniform_to_shader.

2012-04-11 Thread Vinson Lee
Fix uninitialized scalar field defect reported by Coverity.

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Vinson Lee 
---
 src/mesa/program/ir_to_mesa.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 6f4a095..840648e 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2358,7 +2358,7 @@ class add_uniform_to_shader : public 
uniform_field_visitor {
 public:
add_uniform_to_shader(struct gl_shader_program *shader_program,
 struct gl_program_parameter_list *params)
-  : shader_program(shader_program), params(params)
+  : shader_program(shader_program), params(params), idx(-1)
{
   /* empty */
}
-- 
1.7.9.4

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


Re: [Mesa-dev] [PATCH] glsl: If an "if" has no "then" or "else" code left, remove it.

2012-04-11 Thread Matt Turner
On Wed, Apr 11, 2012 at 9:33 PM, Eric Anholt  wrote:
> Cuts 8/1068 instructions from glyphy's fragment shaders on i965.
> ---
>  src/glsl/opt_if_simplification.cpp |    8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/glsl/opt_if_simplification.cpp 
> b/src/glsl/opt_if_simplification.cpp
> index 940dd08..7e88208 100644
> --- a/src/glsl/opt_if_simplification.cpp
> +++ b/src/glsl/opt_if_simplification.cpp
> @@ -66,6 +66,14 @@ do_if_simplification(exec_list *instructions)
>  ir_visitor_status
>  ir_if_simplification_visitor::visit_leave(ir_if *ir)
>  {
> +   /* If the if statement has nothing on either side, remove it. */
> +   if (ir->then_instructions.is_empty() &&
> +       ir->else_instructions.is_empty()) {
> +      ir->remove();
> +      this->made_progress = true;
> +      return visit_continue;
> +   }
> +
>    /* FINISHME: Ideally there would be a way to note that the condition 
> results
>     * FINISHME: in a constant before processing both of the other subtrees.
>     * FINISHME: This can probably be done with some flags, but it would take
> --
> 1.7.9.5

Follow on: If then_instructions is empty, is there any benefit in
inverting the if conditional and moving the else_instructions into the
place of then_instructions?

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


Re: [Mesa-dev] [PATCH] glsl: If an "if" has no "then" or "else" code left, remove it.

2012-04-11 Thread Kenneth Graunke

On 04/11/2012 06:33 PM, Eric Anholt wrote:

Cuts 8/1068 instructions from glyphy's fragment shaders on i965.
---
  src/glsl/opt_if_simplification.cpp |8 
  1 file changed, 8 insertions(+)

diff --git a/src/glsl/opt_if_simplification.cpp 
b/src/glsl/opt_if_simplification.cpp
index 940dd08..7e88208 100644
--- a/src/glsl/opt_if_simplification.cpp
+++ b/src/glsl/opt_if_simplification.cpp
@@ -66,6 +66,14 @@ do_if_simplification(exec_list *instructions)
  ir_visitor_status
  ir_if_simplification_visitor::visit_leave(ir_if *ir)
  {
+   /* If the if statement has nothing on either side, remove it. */
+   if (ir->then_instructions.is_empty()&&
+   ir->else_instructions.is_empty()) {
+  ir->remove();
+  this->made_progress = true;
+  return visit_continue;
+   }
+
 /* FINISHME: Ideally there would be a way to note that the condition 
results
  * FINISHME: in a constant before processing both of the other subtrees.
  * FINISHME: This can probably be done with some flags, but it would take


Hah :) Such an obviously good idea.

Reviewed-by: Kenneth Graunke 

I was about to say "but wait, side effects in the condition!" but 
quickly remembered: we can't represent those anymore.  It's nice not to 
have to worry about that. :)

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


[Mesa-dev] [Bug 48535] Spurious GL_INVALID_OPERATION error generated by glColor()

2012-04-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=48535

Alex Deucher  changed:

   What|Removed |Added

 AssignedTo|dri-devel@lists.freedesktop |mesa-dev@lists.freedesktop.
   |.org|org
  Component|Drivers/DRI/Radeon  |Mesa core

-- 
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 05/21] u_vbuf: override set_index_buffer

2012-04-11 Thread Brian Paul
On Wed, Apr 11, 2012 at 9:38 AM, Marek Olšák  wrote:
> This makes u_vbuf_mgr call the driver instead of the other way around.
> ---
>  src/gallium/auxiliary/util/u_vbuf.c          |   35 ++---
>  src/gallium/auxiliary/util/u_vbuf.h          |    6 
>  src/gallium/drivers/r300/r300_context.h      |    2 +-
>  src/gallium/drivers/r300/r300_render.c       |   22 
>  src/gallium/drivers/r300/r300_state.c        |   15 +--
>  src/gallium/drivers/r600/r600_pipe.h         |    1 +
>  src/gallium/drivers/r600/r600_state_common.c |   16 +++
>  7 files changed, 60 insertions(+), 37 deletions(-)


I looked at patches 5-16 and they seem OK to me but someone more
familiar with r300 might want to double-check.

In the patch where you add the new gallium PIPE_CAP_ tokens, you're
using "DWORD".  I think that's the first occurrence of that term in
the gallium interface.

Coming from a workstation-centric background I've never been a big fan
of dword since I always thought of a word as being 32-bits.  Would
something like "4BYTE" be acceptable in this case?  I guess it's not a
big deal though.

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


Re: [Mesa-dev] [PATCH 04/21] st/mesa: use cso_set_index_buffer and cso_draw_vbo

2012-04-11 Thread Brian Paul
On Wed, Apr 11, 2012 at 9:38 AM, Marek Olšák  wrote:
> ---
>  src/mesa/state_tracker/st_draw.c |   16 +---
>  1 files changed, 9 insertions(+), 7 deletions(-)


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 03/21] gallium/util: use cso_draw_arrays in util_draw_vertex_buffer

2012-04-11 Thread Brian Paul
On Wed, Apr 11, 2012 at 9:38 AM, Marek Olšák  wrote:
> ---
>  src/gallium/auxiliary/util/u_draw_quad.c |    9 -
>  1 files changed, 4 insertions(+), 5 deletions(-)

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


[Mesa-dev] [PATCH] glsl: If an "if" has no "then" or "else" code left, remove it.

2012-04-11 Thread Eric Anholt
Cuts 8/1068 instructions from glyphy's fragment shaders on i965.
---
 src/glsl/opt_if_simplification.cpp |8 
 1 file changed, 8 insertions(+)

diff --git a/src/glsl/opt_if_simplification.cpp 
b/src/glsl/opt_if_simplification.cpp
index 940dd08..7e88208 100644
--- a/src/glsl/opt_if_simplification.cpp
+++ b/src/glsl/opt_if_simplification.cpp
@@ -66,6 +66,14 @@ do_if_simplification(exec_list *instructions)
 ir_visitor_status
 ir_if_simplification_visitor::visit_leave(ir_if *ir)
 {
+   /* If the if statement has nothing on either side, remove it. */
+   if (ir->then_instructions.is_empty() &&
+   ir->else_instructions.is_empty()) {
+  ir->remove();
+  this->made_progress = true;
+  return visit_continue;
+   }
+
/* FINISHME: Ideally there would be a way to note that the condition results
 * FINISHME: in a constant before processing both of the other subtrees.
 * FINISHME: This can probably be done with some flags, but it would take
-- 
1.7.9.5

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


Re: [Mesa-dev] [PATCH 02/21] cso: add set_index_buffer and draw_vbo passthrough functions

2012-04-11 Thread Brian Paul
On Wed, Apr 11, 2012 at 9:38 AM, Marek Olšák  wrote:
> ---
>  src/gallium/auxiliary/cso_cache/cso_context.c |   18 ++
>  src/gallium/auxiliary/cso_cache/cso_context.h |   25 
> +
>  2 files changed, 43 insertions(+), 0 deletions(-)
>
> diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
> b/src/gallium/auxiliary/cso_cache/cso_context.c
> index 43b8343..5fea531 100644
> --- a/src/gallium/auxiliary/cso_cache/cso_context.c
> +++ b/src/gallium/auxiliary/cso_cache/cso_context.c
> @@ -1290,3 +1290,21 @@ cso_restore_stream_outputs(struct cso_context *ctx)
>    ctx->nr_so_targets = ctx->nr_so_targets_saved;
>    ctx->nr_so_targets_saved = 0;
>  }
> +
> +/* drawing */
> +
> +void
> +cso_set_index_buffer(struct cso_context *cso,
> +                     const struct pipe_index_buffer *ib)
> +{
> +   struct pipe_context *pipe = cso->pipe;
> +   pipe->set_index_buffer(pipe, ib);
> +}
> +
> +void
> +cso_draw_vbo(struct cso_context *cso,
> +             const struct pipe_draw_info *info)
> +{
> +   struct pipe_context *pipe = cso->pipe;
> +   pipe->draw_vbo(pipe, info);
> +}
> diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h 
> b/src/gallium/auxiliary/cso_cache/cso_context.h
> index 8cc1bbf..84203e6 100644
> --- a/src/gallium/auxiliary/cso_cache/cso_context.h
> +++ b/src/gallium/auxiliary/cso_cache/cso_context.h
> @@ -217,6 +217,31 @@ cso_save_vertex_sampler_views(struct cso_context *cso);
>  void
>  cso_restore_vertex_sampler_views(struct cso_context *cso);
>
> +/* drawing */
> +
> +void
> +cso_set_index_buffer(struct cso_context *cso,
> +                     const struct pipe_index_buffer *ib);
> +
> +void
> +cso_draw_vbo(struct cso_context *cso,
> +             const struct pipe_draw_info *info);
> +
> +static INLINE void
> +cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count)
> +{
> +   struct pipe_draw_info info = {0};
> +
> +   info.instance_count = 1;
> +   info.max_index = 0x;
> +   info.mode = mode;
> +   info.start = start;
> +   info.count = count;
> +   info.min_index = start;
> +   info.max_index = start + count - 1;

We have a util_draw_init_info() function that could be used there.

Otherwise, 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 01/21] cso: unreference saved vertex buffers when restoring

2012-04-11 Thread Brian Paul
On Wed, Apr 11, 2012 at 9:38 AM, Marek Olšák  wrote:
> ---
>  src/gallium/auxiliary/cso_cache/cso_context.c |    8 
>  1 files changed, 8 insertions(+), 0 deletions(-)

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 5/5] i965/fs: Avoid generating extra AND instructions on bool logic ops.

2012-04-11 Thread Kenneth Graunke

On 03/26/2012 01:59 PM, Eric Anholt wrote:

By making a bool fs_reg only have a defined low bit (matching CMP
output), instead of being a full 0 or 1 value, we reduce the ANDs
generated in logic chains like:


Ohh.  I finally figured out what's going on here.

Prior to this patch, in the i965 driver, we define bool values as full 
32-bit 0 or 1 values.  That is:


true  = 0001
false = 

This patch relaxes that so that only the low bit is defined...or, in 
other words, the top 31 bits can be *anything*:


true  = xxx1
false = xxx0

So, when we convert from a bool to an int, we need to AND with 1 to get 
rid of all the random values in the top-31 bits to get a proper 0 or 1.


And the logic_xor stuff looks like it's just a clean-up, since those now 
become the same code as the default case.  Still not sure what's going 
on with the generation checks.


Sorry for being so dense.  I'll give this one an:
Acked-by: Kenneth Graunke 

One comment below.



if (v_texcoord.x<  0.0 || v_texcoord.x>  texwidth ||
v_texcoord.y<  0.0 || v_texcoord.y>  1.0)
   discard;

My concern originally when writing this code was that we would end up
generating unnecessary ANDs on bool uniforms, so I put the ANDs right
at the point of doing the CMPs that otherwise set only the low bit.
However, in order to use a bool, we're generating some instruction
anyway (e.g. moving it so as to produce a condition code update), and
those instructions can often be turned into an AND at that point.  It
turns out in the shaders I have on hand, none of them regress in
instruction count:

Total instructions: 262649 ->  262545
39/2148 programs affected (1.8%)
14253 ->  14149 instructions in affected programs (0.7% reduction)
---
  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |   36 ++
  1 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 3460d14..6315957 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -394,7 +394,6 @@ fs_visitor::visit(ir_expression *ir)

inst = emit(BRW_OPCODE_CMP, temp, op[0], op[1]);
inst->conditional_mod = brw_conditional_for_comparison(ir->operation);
-  emit(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1));
break;

 case ir_binop_logic_xor:
@@ -440,11 +439,19 @@ fs_visitor::visit(ir_expression *ir)
break;
 case ir_unop_i2f:
 case ir_unop_u2f:
-   case ir_unop_b2f:
-   case ir_unop_b2i:
 case ir_unop_f2i:
emit(BRW_OPCODE_MOV, this->result, op[0]);
break;
+
+   case ir_unop_b2i:
+  inst = emit(BRW_OPCODE_AND, this->result, op[0], fs_reg(1));
+  break;
+   case ir_unop_b2f:
+  temp = fs_reg(this, glsl_type::int_type);
+  emit(BRW_OPCODE_AND, temp, op[0], fs_reg(1));
+  emit(BRW_OPCODE_MOV, this->result, temp);


If my memory serves me...you should be able to just do this in one 
instruction: AND dst op0 1D.  I know you can't mix float/int 
_source_ types(*), but I thought the destination could be a separate type.


(*) ISA Reference/Execution Environment/Registers and Register 
Regions/Execution Data Type



+  break;
+
 case ir_unop_f2b:
 case ir_unop_i2b:
temp = this->result;
@@ -456,7 +463,6 @@ fs_visitor::visit(ir_expression *ir)

inst = emit(BRW_OPCODE_CMP, temp, op[0], fs_reg(0.0f));
inst->conditional_mod = BRW_CONDITIONAL_NZ;
-  inst = emit(BRW_OPCODE_AND, this->result, this->result, fs_reg(1));
break;

 case ir_unop_trunc:
@@ -1488,19 +1494,9 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir)
 break;

case ir_binop_logic_xor:
-inst = emit(BRW_OPCODE_XOR, reg_null_d, op[0], op[1]);
-inst->conditional_mod = BRW_CONDITIONAL_NZ;
-break;
-
case ir_binop_logic_or:
-inst = emit(BRW_OPCODE_OR, reg_null_d, op[0], op[1]);
-inst->conditional_mod = BRW_CONDITIONAL_NZ;
-break;
-
case ir_binop_logic_and:
-inst = emit(BRW_OPCODE_AND, reg_null_d, op[0], op[1]);
-inst->conditional_mod = BRW_CONDITIONAL_NZ;
-break;
+goto out;

case ir_unop_f2b:
 if (intel->gen>= 6) {
@@ -1541,15 +1537,11 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir)
return;
 }

+out:
 ir->accept(this);

-   if (intel->gen>= 6) {
-  fs_inst *inst = emit(BRW_OPCODE_AND, reg_null_d, this->result, 
fs_reg(1));
-  inst->conditional_mod = BRW_CONDITIONAL_NZ;
-   } else {
-  fs_inst *inst = emit(BRW_OPCODE_MOV, reg_null_d, this->result);
-  inst->conditional_mod = BRW_CONDITIONAL_NZ;
-   }
+   fs_inst *inst = emit(BRW_OPCODE_AND, reg_null_d, this->result, fs_reg(1));
+   inst->conditional_mod = BRW_CONDITIONAL_NZ;
  }

  /**

[Mesa-dev] [PATCH 4/4] st/dri: pass config options to the state tracker

2012-04-11 Thread Vadim Girlin

Signed-off-by: Vadim Girlin 
---
 .../state_trackers/dri/common/dri_context.c|8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_context.c 
b/src/gallium/state_trackers/dri/common/dri_context.c
index 9e59023..0403826 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -49,6 +49,13 @@ dri_pp_query(struct dri_context *ctx)
}
 }
 
+static void dri_fill_st_options(struct st_config_options *options,
+const struct driOptionCache * optionCache)
+{
+   options->force_glsl_extensions_warn =
+  driQueryOptionb(optionCache, "force_glsl_extensions_warn");
+}
+
 GLboolean
 dri_create_context(gl_api api, const struct gl_config * visual,
   __DRIcontext * cPriv,
@@ -107,6 +114,7 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
driParseConfigFiles(&ctx->optionCache,
   &screen->optionCache, sPriv->myNum, 
driver_descriptor.name);
 
+   dri_fill_st_options(&attribs.options, &ctx->optionCache);
dri_fill_st_visual(&attribs.visual, screen, visual);
ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
   st_share);
-- 
1.7.7.6

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


[Mesa-dev] [PATCH 3/4] st/mesa: accept and handle configuration options from st/dri

2012-04-11 Thread Vadim Girlin
Currently there is a single option - force_glsl_extensions_warn.

Signed-off-by: Vadim Girlin 
---
 src/gallium/include/state_tracker/st_api.h |   14 ++
 src/mesa/state_tracker/st_context.c|   10 +++---
 src/mesa/state_tracker/st_context.h|5 -
 src/mesa/state_tracker/st_extensions.c |2 ++
 src/mesa/state_tracker/st_manager.c|2 +-
 5 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h 
b/src/gallium/include/state_tracker/st_api.h
index 3af1dfc..8d829c2 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -221,6 +221,15 @@ struct st_visual
enum st_attachment_type render_buffer;
 };
 
+
+/**
+ * Configuration options from driconf
+ */
+struct st_config_options
+{
+   boolean force_glsl_extensions_warn;
+};
+
 /**
  * Represent the attributes of a context.
  */
@@ -243,6 +252,11 @@ struct st_context_attribs
 * The visual of the framebuffers the context will be bound to.
 */
struct st_visual visual;
+
+   /**
+* Configuration options.
+*/
+   struct st_config_options options;
 };
 
 /**
diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index a3fd4db..dfd5870 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -111,11 +111,14 @@ st_get_msaa(void)
 
 
 static struct st_context *
-st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe )
+st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
+   const struct st_config_options *options)
 {
uint i;
struct st_context *st = ST_CALLOC_STRUCT( st_context );

+   st->options = *options;
+
ctx->st = st;
 
st->ctx = ctx;
@@ -179,7 +182,8 @@ st_create_context_priv( struct gl_context *ctx, struct 
pipe_context *pipe )
 
 struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
  const struct gl_config *visual,
- struct st_context *share)
+ struct st_context *share,
+ const struct st_config_options *options)
 {
struct gl_context *ctx;
struct gl_context *shareCtx = share ? share->ctx : NULL;
@@ -204,7 +208,7 @@ struct st_context *st_create_context(gl_api api, struct 
pipe_context *pipe,
if (debug_get_option_mesa_mvp_dp4())
   _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
 
-   return st_create_context_priv(ctx, pipe);
+   return st_create_context_priv(ctx, pipe, options);
 }
 
 
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index da03719..23b780f 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -209,6 +209,8 @@ struct st_context
 
int32_t draw_stamp;
int32_t read_stamp;
+
+   struct st_config_options options;
 };
 
 
@@ -281,7 +283,8 @@ st_get_msaa(void);
 extern struct st_context *
 st_create_context(gl_api api, struct pipe_context *pipe,
   const struct gl_config *visual,
-  struct st_context *share);
+  struct st_context *share,
+  const struct st_config_options *options);
 
 extern void
 st_destroy_context(struct st_context *st);
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index afea0ea..7cdbf32 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -629,4 +629,6 @@ void st_init_extensions(struct st_context *st)
  break;
   }
}
+   if (st->options.force_glsl_extensions_warn)
+  ctx->Const.ForceGLSLExtensionsWarn = 1;
 }
diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index d54b7ed..77eb20f 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -635,7 +635,7 @@ st_api_create_context(struct st_api *stapi, struct 
st_manager *smapi,
}
 
st_visual_to_context_mode(&attribs->visual, &mode);
-   st = st_create_context(api, pipe, &mode, shared_ctx);
+   st = st_create_context(api, pipe, &mode, shared_ctx, &attribs->options);
if (!st) {
   *error = ST_CONTEXT_ERROR_NO_MEMORY;
   pipe->destroy(pipe);
-- 
1.7.7.6

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


[Mesa-dev] [PATCH 2/4] st/dri: add force_glsl_extensions_warn option to dri options

2012-04-11 Thread Vadim Girlin

Signed-off-by: Vadim Girlin 
---
 src/gallium/state_trackers/dri/common/dri_screen.c |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c 
b/src/gallium/state_trackers/dri/common/dri_screen.c
index 24efbde..3c6d24b 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.c
+++ b/src/gallium/state_trackers/dri/common/dri_screen.c
@@ -41,6 +41,8 @@
 
 #include "util/u_debug.h"
 
+#undef false
+
 PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN
   DRI_CONF_SECTION_PERFORMANCE
@@ -58,9 +60,16 @@ PUBLIC const char __driConfigOptions[] =
  DRI_CONF_PP_JIMENEZMLAA(0, 0, 32)
  DRI_CONF_PP_JIMENEZMLAA_COLOR(0, 0, 32)
   DRI_CONF_SECTION_END
+
+  DRI_CONF_SECTION_DEBUG
+ DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN(false)
+  DRI_CONF_SECTION_END
+
DRI_CONF_END;
 
-static const uint __driNConfigOptions = 9;
+#define false 0
+
+static const uint __driNConfigOptions = 10;
 
 static const __DRIconfig **
 dri_fill_in_modes(struct dri_screen *screen,
-- 
1.7.7.6

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


[Mesa-dev] [PATCH 1/4] st/dri: use driver name for driconf section lookup

2012-04-11 Thread Vadim Girlin
The name is taken from the driver_descriptor, so it will be the same as
expected by driconf utility.

Signed-off-by: Vadim Girlin 
---
 .../state_trackers/dri/common/dri_context.c|3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_context.c 
b/src/gallium/state_trackers/dri/common/dri_context.c
index e07e168..9e59023 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -34,6 +34,7 @@
 #include "dri_screen.h"
 #include "dri_drawable.h"
 #include "dri_context.h"
+#include "state_tracker/drm_driver.h"
 
 #include "pipe/p_context.h"
 #include "state_tracker/st_context.h"
@@ -104,7 +105,7 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
ctx->sPriv = sPriv;
 
driParseConfigFiles(&ctx->optionCache,
-  &screen->optionCache, sPriv->myNum, "dri");
+  &screen->optionCache, sPriv->myNum, 
driver_descriptor.name);
 
dri_fill_st_visual(&attribs.visual, screen, visual);
ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
-- 
1.7.7.6

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


[Mesa-dev] [PATCH 0/4] v2: force_glsl_extensions_warn option for gallium drivers

2012-04-11 Thread Vadim Girlin
v2: Updated with the proposed changes:

 - using the driver name from the driver_descriptor
 - using new "struct st_config_options" to pass the options


  st/dri: use driver name for driconf section lookup
  st/dri: add force_glsl_extensions_warn option to dri options
  st/mesa: accept and handle configuration options from st/dri
  st/dri: pass config options to the state tracker

 src/gallium/include/state_tracker/st_api.h |   14 ++
 .../state_trackers/dri/common/dri_context.c|   11 ++-
 src/gallium/state_trackers/dri/common/dri_screen.c |   11 ++-
 src/mesa/state_tracker/st_context.c|   10 +++---
 src/mesa/state_tracker/st_context.h|5 -
 src/mesa/state_tracker/st_extensions.c |2 ++
 src/mesa/state_tracker/st_manager.c|2 +-
 7 files changed, 48 insertions(+), 7 deletions(-)

-- 
1.7.7.6

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


Re: [Mesa-dev] [PATCH 4/5] i965/fs: Try to avoid generating extra MOVs to do saturates.

2012-04-11 Thread Kenneth Graunke

On 03/26/2012 01:59 PM, Eric Anholt wrote:

This change (before the previous two) produced a .23% +/- .11%
performance improvement in Unigine Tropics at 1024x768 on IVB.

Total instructions: 269270 ->  262649
614/2148 programs affected (28.6%)
179386 ->  172765 instructions in affected programs (3.7% reduction)

v2: Move some of the logic of finding the instruction that produced
 the result of an expression tree to a helper.


I like it!  Much nicer having that factored out.

Reviewed-by: Kenneth Graunke 

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


Re: [Mesa-dev] [PATCH 3/5] glsl: Extend the array splitting optimization pass to matrices.

2012-04-11 Thread Kenneth Graunke

On 03/26/2012 01:59 PM, Eric Anholt wrote:

This should fit in well with our lower_mat_op_to_vec code: now, in
addition to having expressions on each column of a matrix, we also
split the columns to separate variables so they can be tracked
individually by the copy propagation, dead code, and other passes.

This optimizes out some more code generation in unigine and gstreamer
shaders.

Total instructions: 269342 ->  269270
14/2148 programs affected (0.7%)
2226 ->  2154 instructions in affected programs (3.2% reduction)
---
  src/glsl/opt_array_splitting.cpp |   29 ++---
  1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/glsl/opt_array_splitting.cpp b/src/glsl/opt_array_splitting.cpp
index 1e278c1..f11b516 100644
--- a/src/glsl/opt_array_splitting.cpp
+++ b/src/glsl/opt_array_splitting.cpp
@@ -53,9 +53,14 @@ public:
this->declaration = false;
this->components = NULL;
this->mem_ctx = NULL;
+  if (var->type->is_array())
+this->size = var->type->length;
+  else
+this->size = var->type->matrix_columns;
 }

 ir_variable *var; /* The key: the variable's pointer. */
+   unsigned size; /* array length or matrix columns */

 /** Number of times the variable is referenced, including assignments. */
 unsigned whole_array_access;
@@ -112,13 +117,13 @@ 
ir_array_reference_visitor::get_variable_entry(ir_variable *var)
 var->mode != ir_var_temporary)
return NULL;

-   if (!var->type->is_array())
+   if (!(var->type->is_array() || var->type->is_matrix()))
return NULL;

 /* If the array hasn't been sized yet, we can't split it.  After
  * linking, this should be resolved.
  */
-   if (var->type->length == 0)
+   if (var->type->is_array()&&  var->type->length == 0)
return NULL;

 foreach_iter(exec_list_iterator, iter, this->variable_list) {
@@ -239,9 +244,6 @@ ir_array_splitting_visitor::get_splitting_entry(ir_variable 
*var)
  {
 assert(var);

-   if (!var->type->is_array())
-  return NULL;
-
 foreach_iter(exec_list_iterator, iter, *this->variable_list) {
variable_entry *entry = (variable_entry *)iter.get();
if (entry->var == var) {
@@ -271,7 +273,7 @@ ir_array_splitting_visitor::split_deref(ir_dereference 
**deref)
 ir_constant *constant = deref_array->array_index->as_constant();
 assert(constant);

-   if (constant->value.i[0]<  (int)var->type->length) {
+   if (constant->value.i[0]<  (int)entry->size) {
*deref = new(entry->mem_ctx)
 ir_dereference_variable(entry->components[constant->value.i[0]]);
 } else {
@@ -343,21 +345,26 @@ optimize_split_arrays(exec_list *instructions, bool 
linked)
 foreach_iter(exec_list_iterator, iter, refs.variable_list) {
variable_entry *entry = (variable_entry *)iter.get();
const struct glsl_type *type = entry->var->type;
+  const struct glsl_type *subtype;
+
+  if (type->is_matrix())
+subtype = glsl_type::get_instance(GLSL_TYPE_FLOAT,
+  type->vector_elements, 1);
+  else
+subtype = type->fields.array;


If you want, you could just do:
  subtype = type->is_array() ? type->fields.array : 
type->column_type();




entry->mem_ctx = ralloc_parent(entry->var);

entry->components = ralloc_array(mem_ctx,
   ir_variable *,
-  type->length);
+  entry->size);

-  for (unsigned int i = 0; i<  type->length; i++) {
+  for (unsigned int i = 0; i<  entry->size; i++) {
 const char *name = ralloc_asprintf(mem_ctx, "%s_%d",
entry->var->name, i);

 entry->components[i] =
-   new(entry->mem_ctx) ir_variable(type->fields.array,
-   name,
-   ir_var_temporary);
+   new(entry->mem_ctx) ir_variable(subtype, name, ir_var_temporary);
 entry->var->insert_before(entry->components[i]);
}



Looks great!
Reviewed-by: Kenneth Graunke 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/5] glsl: Add an array splitting pass.

2012-04-11 Thread Kenneth Graunke

On 03/26/2012 01:59 PM, Eric Anholt wrote:

I've had this code laying around almost done for a long time.  The
idea is like opt_structure_splitting, that we've got a bunch of
transforms at the GLSL IR level that only understand scalars and
vectors, which just skip complicated dereferences.  While driver
backends may manage some optimization after they split matrices up
themselves, it would be better to bring all of our optimization to
bear on the problem.

While I wasn't expecting changes quite yet, a few programs end up
winning: a gstreamer convolution shader, and the Humus dynamic
branching demo:
Total instructions: 269430 ->  269342
3/2148 programs affected (0.1%)
1498 ->  1410 instructions in affected programs (5.9% reduction)
---
  src/glsl/Makefile.sources|1 +
  src/glsl/glsl_parser_extras.cpp  |1 +
  src/glsl/ir_optimization.h   |1 +
  src/glsl/opt_array_splitting.cpp |  377 ++
  4 files changed, 380 insertions(+), 0 deletions(-)
  create mode 100644 src/glsl/opt_array_splitting.cpp

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 06728da..15f5e1f 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -62,6 +62,7 @@ LIBGLSL_CXX_FILES := \
lower_vector.cpp \
lower_output_reads.cpp \
opt_algebraic.cpp \
+   opt_array_splitting.cpp \
opt_constant_folding.cpp \
opt_constant_propagation.cpp \
opt_constant_variable.cpp \
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 21c3c6e..be619c7 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1044,6 +1044,7 @@ do_common_optimization(exec_list *ir, bool linked,
 progress = do_swizzle_swizzle(ir) || progress;
 progress = do_noop_swizzle(ir) || progress;

+   progress = optimize_split_arrays(ir, linked) || progress;
 progress = optimize_redundant_jumps(ir) || progress;

 loop_state *ls = analyze_loop_variables(ir);
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index 085b969..3567835 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -74,6 +74,7 @@ bool lower_quadop_vector(exec_list *instructions, bool 
dont_lower_swz);
  bool lower_clip_distance(exec_list *instructions);
  void lower_output_reads(exec_list *instructions);
  bool optimize_redundant_jumps(exec_list *instructions);
+bool optimize_split_arrays(exec_list *instructions, bool linked);

  ir_rvalue *
  compare_index_block(exec_list *instructions, ir_variable *index,
diff --git a/src/glsl/opt_array_splitting.cpp b/src/glsl/opt_array_splitting.cpp
new file mode 100644
index 000..1e278c1
--- /dev/null
+++ b/src/glsl/opt_array_splitting.cpp
@@ -0,0 +1,377 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+/**
+ * \file opt_array_splitting.cpp
+ *
+ * If an array is always dereferenced with a constant index, then
+ * split it apart into its elements, making it more amenable to other
+ * optimization passes.
+ *
+ * This skips uniform/varying arrays, which would need careful
+ * handling due to their ir->location fields tying them to the GL API
+ * and other shader stages.
+ */
+
+#include "ir.h"
+#include "ir_visitor.h"
+#include "ir_rvalue_visitor.h"
+#include "ir_print_visitor.h"
+#include "glsl_types.h"
+
+static bool debug = false;
+
+namespace opt_array_splitting {
+
+class variable_entry : public exec_node
+{
+public:
+   variable_entry(ir_variable *var)
+   {
+  this->var = var;
+  this->whole_array_access = 0;
+  this->declaration = false;
+  this->components = NULL;
+  this->mem_ctx = NULL;
+   }
+
+   ir_variable *var; /* The key: the variable's pointer. */
+
+   /** Number of times the variable is referenced, including assignments. */
+   unsigned whole_array_access;
+
+   bool d

[Mesa-dev] [PATCH 2/5] i965: Add basic block generator.

2012-04-11 Thread Eric Anholt
This takes the fs_inst list generated by the visitor, and generates a
list of basic blocks with edges between them.  This is a building
block for data-flow analysis.
---
 src/mesa/drivers/dri/i965/Makefile.sources |1 +
 src/mesa/drivers/dri/i965/brw_fs.h |4 +
 src/mesa/drivers/dri/i965/brw_fs_cfg.cpp   |  249 
 src/mesa/drivers/dri/i965/brw_fs_cfg.h |  101 +++
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp  |   37 +
 5 files changed, 392 insertions(+)
 create mode 100644 src/mesa/drivers/dri/i965/brw_fs_cfg.cpp
 create mode 100644 src/mesa/drivers/dri/i965/brw_fs_cfg.h

diff --git a/src/mesa/drivers/dri/i965/Makefile.sources 
b/src/mesa/drivers/dri/i965/Makefile.sources
index 750be51..7421351 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -114,6 +114,7 @@ i965_C_FILES := \
 i965_CXX_FILES := \
brw_cubemap_normalize.cpp \
brw_fs.cpp \
+   brw_fs_cfg.cpp \
brw_fs_emit.cpp \
brw_fs_visitor.cpp \
brw_fs_channel_expressions.cpp \
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 7aebffa..a07a02d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -25,6 +25,8 @@
  *
  */
 
+#pragma once
+
 #include "brw_shader.h"
 
 extern "C" {
@@ -646,6 +648,8 @@ public:
 
int force_uncompressed_stack;
int force_sechalf_stack;
+
+   class fs_bblock *bblock;
 };
 
 bool brw_do_channel_expressions(struct exec_list *instructions);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cfg.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_cfg.cpp
new file mode 100644
index 000..7c4c481
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_fs_cfg.cpp
@@ -0,0 +1,249 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ *Eric Anholt 
+ *
+ */
+
+#include "brw_fs_cfg.h"
+
+/** @file brw_fs_cfg.cpp
+ *
+ * Walks the shader instructions generated and creates a set of basic
+ * blocks with successor/predecessor edges connecting them.
+ */
+
+static fs_bblock *
+pop_stack(exec_list *list)
+{
+   fs_bblock_link *link = (fs_bblock_link *)list->get_tail();
+   fs_bblock *block = link->block;
+   link->remove();
+
+   return block;
+}
+
+fs_bblock::fs_bblock()
+{
+   start = NULL;
+   end = NULL;
+
+   parents.make_empty();
+   children.make_empty();
+}
+
+void
+fs_bblock::add_successor(void *mem_ctx, fs_bblock *successor)
+{
+   successor->parents.push_tail(this->make_list(mem_ctx));
+   children.push_tail(successor->make_list(mem_ctx));
+}
+
+fs_bblock_link *
+fs_bblock::make_list(void *mem_ctx)
+{
+   return new(mem_ctx) fs_bblock_link(this);
+}
+
+fs_cfg::fs_cfg(fs_visitor *v)
+{
+   mem_ctx = ralloc_context(v->mem_ctx);
+   block_list.make_empty();
+   num_blocks = 0;
+   ip = 0;
+   cur = NULL;
+
+   fs_bblock *entry = new_block();
+   fs_bblock *cur_if = NULL, *cur_else = NULL, *cur_endif = NULL;
+   fs_bblock *cur_do = NULL, *cur_while = NULL;
+   exec_list if_stack, else_stack, endif_stack, do_stack, while_stack;
+   fs_bblock *next;
+
+   set_next_block(entry);
+
+   entry->start = (fs_inst *)v->instructions.get_head();
+
+   foreach_list(node, &v->instructions) {
+  fs_inst *inst = (fs_inst *)node;
+
+  cur->end = inst;
+
+  /* set_next_block wants the post-incremented ip */
+  ip++;
+
+  switch (inst->opcode) {
+  case BRW_OPCODE_IF:
+/* Push our information onto a stack so we can recover from
+ * nested ifs.
+ */
+if_stack.push_tail(cur_if->make_list(mem_ctx));
+else_stack.push_tail(cur_else->make_list(mem_ctx));
+endif_stack.push_tail(cur_endif->make_list(mem_ctx));
+
+cur_if = cur;
+cur_else = NULL;
+/* Set up the block just after the endif.  Don't know when exactly
+ * it wil

[Mesa-dev] [PATCH 4/5] i965: Move the old live interval analysis code next to the new live vars code.

2012-04-11 Thread Eric Anholt
I'm about to replace the insides of this using the new analysis.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp   |  122 
 src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp |  122 
 2 files changed, 122 insertions(+), 122 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 5f3d79d..e8f4e1f 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -49,8 +49,6 @@ extern "C" {
 #include "glsl/glsl_types.h"
 #include "glsl/ir_print_visitor.h"
 
-#define MAX_INSTRUCTION (1 << 30)
-
 int
 fs_visitor::type_size(const struct glsl_type *type)
 {
@@ -988,83 +986,6 @@ fs_visitor::setup_pull_constants()
c->prog_data.nr_pull_params = pull_uniform_count;
 }
 
-void
-fs_visitor::calculate_live_intervals()
-{
-   int num_vars = this->virtual_grf_next;
-   int *def = ralloc_array(mem_ctx, int, num_vars);
-   int *use = ralloc_array(mem_ctx, int, num_vars);
-   int loop_depth = 0;
-   int loop_start = 0;
-
-   if (this->live_intervals_valid)
-  return;
-
-   for (int i = 0; i < num_vars; i++) {
-  def[i] = MAX_INSTRUCTION;
-  use[i] = -1;
-   }
-
-   int ip = 0;
-   foreach_list(node, &this->instructions) {
-  fs_inst *inst = (fs_inst *)node;
-
-  if (inst->opcode == BRW_OPCODE_DO) {
-if (loop_depth++ == 0)
-   loop_start = ip;
-  } else if (inst->opcode == BRW_OPCODE_WHILE) {
-loop_depth--;
-
-if (loop_depth == 0) {
-   /* Patches up the use of vars marked for being live across
-* the whole loop.
-*/
-   for (int i = 0; i < num_vars; i++) {
-  if (use[i] == loop_start) {
- use[i] = ip;
-  }
-   }
-}
-  } else {
-for (unsigned int i = 0; i < 3; i++) {
-   if (inst->src[i].file == GRF) {
-  int reg = inst->src[i].reg;
-
-  if (!loop_depth) {
- use[reg] = ip;
-  } else {
- def[reg] = MIN2(loop_start, def[reg]);
- use[reg] = loop_start;
-
- /* Nobody else is going to go smash our start to
-  * later in the loop now, because def[reg] now
-  * points before the bb header.
-  */
-  }
-   }
-}
-if (inst->dst.file == GRF) {
-   int reg = inst->dst.reg;
-
-   if (!loop_depth) {
-  def[reg] = MIN2(def[reg], ip);
-   } else {
-  def[reg] = MIN2(def[reg], loop_start);
-   }
-}
-  }
-
-  ip++;
-   }
-
-   ralloc_free(this->virtual_grf_def);
-   ralloc_free(this->virtual_grf_use);
-   this->virtual_grf_def = def;
-   this->virtual_grf_use = use;
-
-   this->live_intervals_valid = true;
-}
-
 /**
  * Attempts to move immediate constants into the immediate
  * constant slot of following instructions.
@@ -1675,49 +1596,6 @@ fs_visitor::remove_duplicate_mrf_writes()
 }
 
 bool
-fs_visitor::virtual_grf_interferes(int a, int b)
-{
-   int start = MAX2(this->virtual_grf_def[a], this->virtual_grf_def[b]);
-   int end = MIN2(this->virtual_grf_use[a], this->virtual_grf_use[b]);
-
-   /* We can't handle dead register writes here, without iterating
-* over the whole instruction stream to find every single dead
-* write to that register to compare to the live interval of the
-* other register.  Just assert that dead_code_eliminate() has been
-* called.
-*/
-   assert((this->virtual_grf_use[a] != -1 ||
-  this->virtual_grf_def[a] == MAX_INSTRUCTION) &&
- (this->virtual_grf_use[b] != -1 ||
-  this->virtual_grf_def[b] == MAX_INSTRUCTION));
-
-   /* If the register is used to store 16 values of less than float
-* size (only the case for pixel_[xy]), then we can't allocate
-* another dword-sized thing to that register that would be used in
-* the same instruction.  This is because when the GPU decodes (for
-* example):
-*
-* (declare (in ) vec4 gl_FragCoord@0x97766a0)
-* add(16) g6<1>F  g6<8,8,1>UW 0.5F { align1 compr };
-*
-* it's actually processed as:
-* add(8) g6<1>F  g6<8,8,1>UW 0.5F { align1 };
-* add(8) g7<1>F  g6.8<8,8,1>UW   0.5F { align1 sechalf };
-*
-* so our second half values in g6 got overwritten in the first
-* half.
-*/
-   if (c->dispatch_width == 16 && (this->pixel_x.reg == a ||
-  this->pixel_x.reg == b ||
-  this->pixel_y.reg == a ||
-  this->pixel_y.reg == b)) {
-  return start <= end;
-   }
-
-   return start < end;
-}
-
-bool
 fs_visitor::run()
 {
uint32_t prog_offset_16 = 0;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp
index 338ff5c..d

[Mesa-dev] [PATCH 5/5] i965: Convert live interval computation to using live variable analysis.

2012-04-11 Thread Eric Anholt
Our previous live interval analysis just said that anything in a loop
was live for the whole loop.  If you had to spill a reg in a loop,
then we would consider the unspilled value live across the loop too,
so you never made progress by spilling.  Eventually it would consider
everything in the loop unspillable and fail out.

With the new analysis, things completely deffed and used inside the
loop won't be marked live across the loop, so even if you
spill/unspill something that used to be live across the loop, you
reduce register pressure.  But you usually don't even have to spill
any more, since our intervals are smaller than before.

This fixes assertion failure trying to compile the shader for the
"glyphy" text rasterier.

Improves Unigine Tropics performance 1.3% +/- 0.2% (n=5), by allowing
more shaders to be compiled in 16-wide mode.
---
 src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp |   65 
 1 file changed, 26 insertions(+), 39 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp
index dacdace..b61393e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp
@@ -165,8 +165,6 @@ fs_visitor::calculate_live_intervals()
int num_vars = this->virtual_grf_next;
int *def = ralloc_array(mem_ctx, int, num_vars);
int *use = ralloc_array(mem_ctx, int, num_vars);
-   int loop_depth = 0;
-   int loop_start = 0;
 
if (this->live_intervals_valid)
   return;
@@ -176,58 +174,47 @@ fs_visitor::calculate_live_intervals()
   use[i] = -1;
}
 
+   /* Start by setting up the intervals with no knowledge of control
+* flow.
+*/
int ip = 0;
foreach_list(node, &this->instructions) {
   fs_inst *inst = (fs_inst *)node;
 
-  if (inst->opcode == BRW_OPCODE_DO) {
-if (loop_depth++ == 0)
-   loop_start = ip;
-  } else if (inst->opcode == BRW_OPCODE_WHILE) {
-loop_depth--;
-
-if (loop_depth == 0) {
-   /* Patches up the use of vars marked for being live across
-* the whole loop.
-*/
-   for (int i = 0; i < num_vars; i++) {
-  if (use[i] == loop_start) {
- use[i] = ip;
-  }
-   }
-}
-  } else {
-for (unsigned int i = 0; i < 3; i++) {
-   if (inst->src[i].file == GRF) {
-  int reg = inst->src[i].reg;
-
-  if (!loop_depth) {
- use[reg] = ip;
-  } else {
- def[reg] = MIN2(loop_start, def[reg]);
- use[reg] = loop_start;
+  for (unsigned int i = 0; i < 3; i++) {
+if (inst->src[i].file == GRF) {
+   int reg = inst->src[i].reg;
 
- /* Nobody else is going to go smash our start to
-  * later in the loop now, because def[reg] now
-  * points before the bb header.
-  */
-  }
-   }
+   use[reg] = ip;
 }
 if (inst->dst.file == GRF) {
int reg = inst->dst.reg;
 
-   if (!loop_depth) {
-  def[reg] = MIN2(def[reg], ip);
-   } else {
-  def[reg] = MIN2(def[reg], loop_start);
-   }
+   def[reg] = MIN2(def[reg], ip);
 }
   }
 
   ip++;
}
 
+   /* Now, extend those intervals using our analysis of control flow. */
+   fs_cfg cfg(this);
+   fs_livevariables livevars(this, &cfg);
+
+   for (int b = 0; b < cfg.num_blocks; b++) {
+  for (int i = 0; i < num_vars; i++) {
+if (livevars.bd[b].livein[i]) {
+   def[i] = MIN2(def[i], cfg.blocks[b]->start_ip);
+   use[i] = MAX2(use[i], cfg.blocks[b]->start_ip);
+}
+
+if (livevars.bd[b].liveout[i]) {
+   def[i] = MIN2(def[i], cfg.blocks[b]->end_ip);
+   use[i] = MAX2(use[i], cfg.blocks[b]->end_ip);
+}
+  }
+   }
+
ralloc_free(this->virtual_grf_def);
ralloc_free(this->virtual_grf_use);
this->virtual_grf_def = def;
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 3/5] i965: Add support for live variable analysis using dataflow analysis.

2012-04-11 Thread Eric Anholt
---
 src/mesa/drivers/dri/i965/Makefile.sources |1 +
 src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp |  158 
 src/mesa/drivers/dri/i965/brw_fs_livevariables.h   |   86 +++
 3 files changed, 245 insertions(+)
 create mode 100644 src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp
 create mode 100644 src/mesa/drivers/dri/i965/brw_fs_livevariables.h

diff --git a/src/mesa/drivers/dri/i965/Makefile.sources 
b/src/mesa/drivers/dri/i965/Makefile.sources
index 7421351..098accd 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -116,6 +116,7 @@ i965_CXX_FILES := \
brw_fs.cpp \
brw_fs_cfg.cpp \
brw_fs_emit.cpp \
+   brw_fs_livevariables.cpp \
brw_fs_visitor.cpp \
brw_fs_channel_expressions.cpp \
brw_fs_reg_allocate.cpp \
diff --git a/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp
new file mode 100644
index 000..338ff5c
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_fs_livevariables.cpp
@@ -0,0 +1,158 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ *Eric Anholt 
+ *
+ */
+
+#include "brw_fs_cfg.h"
+#include "brw_fs_livevariables.h"
+
+using namespace brw;
+
+/** @file brw_fs_livevariables.cpp
+ *
+ * Support for computing at the basic block level which variables
+ * (virtual GRFs in our case) are live at entry and exit.
+ *
+ * See Muchnik's Advanced Compiler Design and Implementation, section
+ * 14.1 (p444).
+ */
+
+/**
+ * Sets up the use[] and def[] arrays.
+ *
+ * The basic-block-level live variable analysis needs to know which
+ * variables get used before they're completely defined, and which
+ * variables are completely defined before they're used.
+ */
+void
+fs_livevariables::setup_def_use()
+{
+   int ip = 0;
+
+   for (int b = 0; b < cfg->num_blocks; b++) {
+  fs_bblock *block = cfg->blocks[b];
+
+  assert(ip == block->start_ip);
+  if (b > 0)
+assert(cfg->blocks[b - 1]->end_ip == ip - 1);
+
+  for (fs_inst *inst = block->start;
+  inst != block->end->next;
+  inst = (fs_inst *)inst->next) {
+
+/* Set use[] for this instruction */
+for (unsigned int i = 0; i < 3; i++) {
+   if (inst->src[i].file == GRF) {
+  int reg = inst->src[i].reg;
+
+  if (!bd[b].def[reg])
+ bd[b].use[reg] = true;
+   }
+}
+
+/* Check for unconditional writes to whole registers. These
+ * are the things that screen off preceding definitions of a
+ * variable, and thus qualify for being in def[].
+ */
+if (inst->dst.file == GRF &&
+inst->regs_written() == v->virtual_grf_sizes[inst->dst.reg] &&
+!inst->predicated &&
+!inst->force_uncompressed &&
+!inst->force_sechalf) {
+   int reg = inst->dst.reg;
+   if (!bd[b].use[reg])
+  bd[b].def[reg] = true;
+}
+
+ip++;
+  }
+   }
+}
+
+/**
+ * The algorithm incrementally sets bits in liveout and livein,
+ * propagating it through control flow.  It will eventually terminate
+ * because it only ever adds bits, and stops when no bits are added in
+ * a pass.
+ */
+void
+fs_livevariables::compute_live_variables()
+{
+   bool cont = true;
+
+   while (cont) {
+  cont = false;
+
+  for (int b = 0; b < cfg->num_blocks; b++) {
+/* Update livein */
+for (int i = 0; i < num_vars; i++) {
+   if (bd[b].use[i] || (bd[b].liveout[i] && !bd[b].def[i])) {
+  if (!bd[b].livein[i]) {
+ bd[b].livein[i] = true;
+ cont = true;
+  }
+   }
+}
+
+/* Update liveout */
+foreach_list(block_node, &cfg->blocks[b]-

[Mesa-dev] [PATCH 1/5] i965/fs: Suppress printing the whole loop in BRW_OPCODE_DO annotation.

2012-04-11 Thread Eric Anholt
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 0052428..836d501 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1696,6 +1696,7 @@ fs_visitor::visit(ir_loop *ir)
   }
}
 
+   this->base_ir = NULL;
emit(BRW_OPCODE_DO);
 
if (ir->to) {
@@ -1722,6 +1723,7 @@ fs_visitor::visit(ir_loop *ir)
   emit(BRW_OPCODE_ADD, counter, counter, this->result);
}
 
+   this->base_ir = NULL;
emit(BRW_OPCODE_WHILE);
 }
 
-- 
1.7.9.5

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


Re: [Mesa-dev] [PATCH 0/8] [RFC] improve driconf support for gallium

2012-04-11 Thread Jose Fonseca


- Original Message -
> On Mit, 2012-04-11 at 08:43 +0200, Michel Dänzer wrote:
> > On Die, 2012-04-10 at 22:04 +0400, Vadim Girlin wrote:
> > > On Tue, 2012-04-10 at 09:56 +0200, Michel Dänzer wrote:
> > > > On Mon, 2012-04-09 at 19:32 +0400, Vadim Girlin wrote:
> > > > > These patches allow to use driver-specific driconf settings,
> > > > > [...]
> > > > 
> > > > How does it allow that? The list of supported driconf options
> > > > is still
> > > > in st/dri, isn't it?
> > > 
> > > Yes, it seems I used the wrong word. The list of options is still
> > > the
> > > same for all gallium drivers.
> > > 
> > > Anyway, my primary goal with these patches is to handle
> > > force_glsl_extensions_warn, to make unigine apps work correctly.
> > > The
> > > idea about pipe_screen::get_driver_name is more a question than a
> > > proposal, probably we can drop it for now.
> > 
> > On second thought, it might still make sense to be able to set
> > different
> > settings for different Gallium drivers in one drirc file. However,
> > I
> > wonder if it wouldn't be better to use the DRI driver name (the
> > output
> > of xdriinfo driver ), i.e. e.g. 'r600' instead of 'r600g'.
> > Isn't
> > there a discrepancy otherwise between the settings shown by the
> > driconf
> > GUI and those actually taking effect?
> 
> Which could probably even be handled by st/dri internally, without
> the
> need for a new driver hook.

Yep. Either pipe_screen::get_driver_name is something that has meaning and use 
beyond linux/driconf, or that bit of info is better stored somewhere with more 
knowledge about the platform (e.g., target).

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


Re: [Mesa-dev] [PATCH 1/5] glsl: Don't apply optimization passes to builtins.

2012-04-11 Thread Kenneth Graunke

On 03/26/2012 01:59 PM, Eric Anholt wrote:

The builtins we have are generally optimized, having been
hand-written.  This avoids generating bad code when an optimization
pass prints debug output.


*laughs*.  You'd think, but...we actually only run the compiler on the 
*prototypes*, not any actual code!  So running optimization passes is 
completely 100% pointless.


I've been thinking of reworking this now that we have ir_builder.  But 
then again, I'm always threatening to rework this, so...


Reviewed-by: Kenneth Graunke 


---
  src/glsl/builtins/tools/generate_builtins.py |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/glsl/builtins/tools/generate_builtins.py 
b/src/glsl/builtins/tools/generate_builtins.py
index 0d97140..f58196f 100755
--- a/src/glsl/builtins/tools/generate_builtins.py
+++ b/src/glsl/builtins/tools/generate_builtins.py
@@ -59,7 +59,7 @@ def write_function_definitions():
  print stringify(v), ';'

  def run_compiler(args):
-command = [compiler, '--dump-lir'] + args
+command = [compiler, '--dump-hir'] + args
  p = Popen(command, 1, stdout=PIPE, shell=False)
  output = p.communicate()[0]


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


Re: [Mesa-dev] [PATCH 00/21] Gallium: making user vertex buffers optional and other goodness

2012-04-11 Thread Christoph Bumiller
On 11.04.2012 17:38, Marek Olšák wrote:
> Hi everyone,
>
> This series adds these optional features to st/mesa:
> - uploading user vertex buffers
> - translating unsupported vertex formats into floats
> - vertex data with unaligned buffer_offset, src_offset, or stride is 
> transformed such that it's aligned
>

Now before anyone comes with the idea again of making the st
unconditionally upload all user buffers and removing them from the API:
I'd really like to keep my specialized low-overhead upload path in the
driver that gives me 42 fps in TORCS over 32 when I let the state
tracker do it ...
(TORCS is an extreme example, in nexuiz the difference is only 89 over 85).

Thanks, Christoph

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


[Mesa-dev] [PATCH] wayland-drm: Implement wl_buffer.damage in old versions of Wayland

2012-04-11 Thread Neil Roberts
Commit 272bc48976 removed the damage implementation for the
wl_buffer_interface because that has been removed from git master of
Wayland. However this breaks building with the 0.85 branch of Wayland
because it would end up initialising the struct incorrectly.

For the time being it's quite convenient for some compositors to track
the 0.85 branch of Wayland because the protocol is stable but they
will also want to track the master branch of Mesa so that they can use
the gbm surface changes.

This patch adds a compile-time check for the version of Wayland so
that it can work with either Wayland master or the 0.85 branch.
---
 src/egl/wayland/wayland-drm/wayland-drm.c |   26 ++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c 
b/src/egl/wayland/wayland-drm/wayland-drm.c
index 101b2c4..f5c31db 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -70,7 +70,33 @@ buffer_destroy(struct wl_client *client, struct wl_resource 
*resource)
wl_resource_destroy(resource, 0);
 }
 
+/* In Git master of Wayland, the damage member of wl_buffer_interface
+ * has been removed. For the time being, it's convenient to be able to
+ * build Mesa against both master and 0.85.0 of Wayland so to make
+ * this work we'll do a compile-time version check and add a dummy
+ * damage implementation for old Wayland */
+#define VERSION_ENCODE(major, minor, micro) \
+  (((major) << 20) | ((minor) << 10) | (micro))
+#if !defined (WAYLAND_VERSION_MAJOR) || \
+  VERSION_ENCODE (WAYLAND_VERSION_MAJOR,\
+  WAYLAND_VERSION_MINOR,\
+  WAYLAND_VERSION_MICRO) <  \
+  VERSION_ENCODE (0, 99, 0)
+#define BUFFER_INTERFACE_HAS_DAMAGE
+#endif
+
+#ifdef BUFFER_INTERFACE_HAS_DAMAGE
+static void
+buffer_damage(struct wl_client *client, struct wl_resource *buffer,
+  int32_t x, int32_t y, int32_t width, int32_t height)
+{
+}
+#endif
+
 const static struct wl_buffer_interface drm_buffer_interface = {
+#ifdef BUFFER_INTERFACE_HAS_DAMAGE
+   buffer_damage,
+#endif
buffer_destroy
 };
 
-- 
1.7.3.16.g9464b

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


[Mesa-dev] [PATCH 21/21] st/mesa: always expose ARB_ES2_compatibility

2012-04-11 Thread Marek Olšák
u_vbuf translates GL_FIXED too if needed.
---
 src/mesa/state_tracker/st_extensions.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 817fe3e..63b1b91 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -455,9 +455,6 @@ void st_init_extensions(struct st_context *st)
 
/* Required: vertex fetch support. */
static const struct st_extension_format_mapping vertex_mapping[] = {
-  { { o(ARB_ES2_compatibility) },
-{ PIPE_FORMAT_R32G32B32A32_FIXED } },
-
   { { o(ARB_vertex_type_2_10_10_10_rev) },
 { PIPE_FORMAT_R10G10B10A2_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
@@ -472,6 +469,7 @@ void st_init_extensions(struct st_context *st)
/*
 * Extensions that are supported by all Gallium drivers:
 */
+   ctx->Extensions.ARB_ES2_compatibility = GL_TRUE;
ctx->Extensions.ARB_copy_buffer = GL_TRUE;
ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE;
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 20/21] st/mesa: always expose ARB_half_float_vertex

2012-04-11 Thread Marek Olšák
u_vbuf kicks in and translates it to float if it's unsupported.
---
 src/mesa/state_tracker/st_extensions.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index afea0ea..817fe3e 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -458,9 +458,6 @@ void st_init_extensions(struct st_context *st)
   { { o(ARB_ES2_compatibility) },
 { PIPE_FORMAT_R32G32B32A32_FIXED } },
 
-  { { o(ARB_half_float_vertex) },
-{ PIPE_FORMAT_R16G16B16A16_FLOAT } },
-
   { { o(ARB_vertex_type_2_10_10_10_rev) },
 { PIPE_FORMAT_R10G10B10A2_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
@@ -482,6 +479,7 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.ARB_fragment_program = GL_TRUE;
ctx->Extensions.ARB_fragment_shader = GL_TRUE;
ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
+   ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
ctx->Extensions.ARB_sampler_objects = GL_TRUE;
ctx->Extensions.ARB_shader_objects = GL_TRUE;
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 19/21] gallium: make user vertex buffers optional

2012-04-11 Thread Marek Olšák
This couldn't be split because it would break bisecting.

Summary:
* r300g,r600g: stop using u_vbuf
* r300g,r600g: also report that the FIXED vertex type is unsupported
* u_vbuf: refactor for use in the state tracker
* cso: wire up u_vbuf with cso_context
* st/mesa: conditionally install u_vbuf
---
 src/gallium/auxiliary/cso_cache/cso_context.c |   66 +-
 src/gallium/auxiliary/cso_cache/cso_context.h |3 +
 src/gallium/auxiliary/util/u_vbuf.c   |  304 -
 src/gallium/auxiliary/util/u_vbuf.h   |   50 ++---
 src/gallium/drivers/r300/r300_blit.c  |   12 +-
 src/gallium/drivers/r300/r300_context.c   |   16 --
 src/gallium/drivers/r300/r300_context.h   |1 -
 src/gallium/drivers/r300/r300_screen.c|7 +-
 src/gallium/drivers/r600/r600_blit.c  |6 +-
 src/gallium/drivers/r600/r600_buffer.c|4 +-
 src/gallium/drivers/r600/r600_formats.h   |3 +-
 src/gallium/drivers/r600/r600_pipe.c  |   14 --
 src/gallium/drivers/r600/r600_pipe.h  |1 -
 src/mesa/state_tracker/st_context.c   |   26 ++
 src/mesa/state_tracker/st_context.h   |3 +
 15 files changed, 276 insertions(+), 240 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 5fea531..f49d95c 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -40,6 +40,7 @@
 #include "util/u_inlines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_vbuf.h"
 #include "tgsi/tgsi_parse.h"
 
 #include "cso_cache/cso_context.h"
@@ -77,6 +78,7 @@ struct sampler_info
 struct cso_context {
struct pipe_context *pipe;
struct cso_cache *cache;
+   struct u_vbuf *vbuf;
 
boolean has_geometry_shader;
boolean has_streamout;
@@ -267,6 +269,10 @@ out:
return NULL;
 }
 
+void cso_install_vbuf(struct cso_context *ctx, struct u_vbuf *vbuf)
+{
+   ctx->vbuf = vbuf;
+}
 
 /**
  * Prior to context destruction, this function unbinds all state objects.
@@ -779,11 +785,17 @@ enum pipe_error cso_set_vertex_elements(struct 
cso_context *ctx,
 unsigned count,
 const struct pipe_vertex_element 
*states)
 {
+   struct u_vbuf *vbuf = ctx->vbuf;
unsigned key_size, hash_key;
struct cso_hash_iter iter;
void *handle;
struct cso_velems_state velems_state;
 
+   if (vbuf) {
+  u_vbuf_set_vertex_elements(vbuf, count, states);
+  return PIPE_OK;
+   }
+
/* need to include the count into the stored state data too.
   Otherwise first few count pipe_vertex_elements could be identical even 
if count
   is different, and there's no guarantee the hash would be different in 
that
@@ -825,12 +837,26 @@ enum pipe_error cso_set_vertex_elements(struct 
cso_context *ctx,
 
 void cso_save_vertex_elements(struct cso_context *ctx)
 {
+   struct u_vbuf *vbuf = ctx->vbuf;
+
+   if (vbuf) {
+  u_vbuf_save_vertex_elements(vbuf);
+  return;
+   }
+
assert(!ctx->velements_saved);
ctx->velements_saved = ctx->velements;
 }
 
 void cso_restore_vertex_elements(struct cso_context *ctx)
 {
+   struct u_vbuf *vbuf = ctx->vbuf;
+
+   if (vbuf) {
+  u_vbuf_restore_vertex_elements(vbuf);
+  return;
+   }
+
if (ctx->velements != ctx->velements_saved) {
   ctx->velements = ctx->velements_saved;
   ctx->pipe->bind_vertex_elements_state(ctx->pipe, ctx->velements_saved);
@@ -844,6 +870,13 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
 unsigned count,
 const struct pipe_vertex_buffer *buffers)
 {
+   struct u_vbuf *vbuf = ctx->vbuf;
+
+   if (vbuf) {
+  u_vbuf_set_vertex_buffers(vbuf, count, buffers);
+  return;
+   }
+
if (count != ctx->nr_vertex_buffers ||
memcmp(buffers, ctx->vertex_buffers,
   sizeof(struct pipe_vertex_buffer) * count) != 0) {
@@ -855,6 +888,13 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
 
 void cso_save_vertex_buffers(struct cso_context *ctx)
 {
+   struct u_vbuf *vbuf = ctx->vbuf;
+
+   if (vbuf) {
+  u_vbuf_save_vertex_buffers(vbuf);
+  return;
+   }
+
util_copy_vertex_buffers(ctx->vertex_buffers_saved,
 &ctx->nr_vertex_buffers_saved,
 ctx->vertex_buffers,
@@ -864,6 +904,12 @@ void cso_save_vertex_buffers(struct cso_context *ctx)
 void cso_restore_vertex_buffers(struct cso_context *ctx)
 {
unsigned i;
+   struct u_vbuf *vbuf = ctx->vbuf;
+
+   if (vbuf) {
+  u_vbuf_restore_vertex_buffers(vbuf);
+  return;
+   }
 
util_copy_vertex_buffers(ctx->vertex_buffers,
 &ctx->nr_vertex_buffers,
@@ -1297,14 +1343,26 @@ void
 cso_set_index_buffer(struct cso_context *cso,
  const struct pipe_index_buffer *ib)
 {
-   struct pipe_context *pipe 

[Mesa-dev] [PATCH 18/21] i915g: report that all vertex formats are supported

2012-04-11 Thread Marek Olšák
So that u_vbuf isn't enabled.
---
 src/gallium/drivers/i915/i915_screen.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index b147e61..1546ee8 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -337,8 +337,10 @@ i915_is_format_supported(struct pipe_screen *screen,
   list = depth_supported;
else if (tex_usage & PIPE_BIND_RENDER_TARGET)
   list = render_supported;
-   else
+   else if (tex_usage & PIPE_BIND_SAMPLER_VIEW)
   list = tex_supported;
+   else
+  return TRUE; /* PIPE_BIND_{VERTEX,INDEX}_BUFFER */
 
for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
   if (list[i] == format)
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 17/21] r600g: don't share u_upload_mgr with u_vbuf, create its own

2012-04-11 Thread Marek Olšák
---
 src/gallium/drivers/r600/r600_pipe.c |   10 ++
 src/gallium/drivers/r600/r600_pipe.h |1 +
 src/gallium/drivers/r600/r600_state_common.c |6 +++---
 src/gallium/drivers/r600/r600_translate.c|2 +-
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c 
b/src/gallium/drivers/r600/r600_pipe.c
index 9c9fa4d..814274e 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -28,6 +28,7 @@
 #include "util/u_blitter.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_simple_shaders.h"
+#include "util/u_upload_mgr.h"
 #include "vl/vl_decoder.h"
 #include "vl/vl_video_buffer.h"
 #include "os/os_time.h"
@@ -194,6 +195,9 @@ static void r600_destroy_context(struct pipe_context 
*context)
if (rctx->vbuf_mgr) {
u_vbuf_destroy(rctx->vbuf_mgr);
}
+   if (rctx->uploader) {
+   u_upload_destroy(rctx->uploader);
+   }
util_slab_destroy(&rctx->pool_transfers);
 
r600_update_num_contexts(rctx->screen, -1);
@@ -304,6 +308,12 @@ static struct pipe_context *r600_create_context(struct 
pipe_screen *screen, void
if (!rctx->vbuf_mgr)
goto fail;
 
+rctx->uploader = u_upload_create(&rctx->context, 1024 * 1024, 256,
+ PIPE_BIND_INDEX_BUFFER |
+ PIPE_BIND_CONSTANT_BUFFER);
+if (!rctx->uploader)
+goto fail;
+
rctx->blitter = util_blitter_create(&rctx->context);
if (rctx->blitter == NULL)
goto fail;
diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index c4e0557..76b20b8 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -280,6 +280,7 @@ struct r600_context {
struct r600_textures_info   ps_samplers;
 
struct u_vbuf   *vbuf_mgr;
+   struct u_upload_mgr *uploader;
struct util_slab_mempoolpool_transfers;
boolean have_depth_texture, have_depth_fb;
 
diff --git a/src/gallium/drivers/r600/r600_state_common.c 
b/src/gallium/drivers/r600/r600_state_common.c
index 2a30470..9d44323 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -577,10 +577,10 @@ void r600_set_constant_buffer(struct pipe_context *ctx, 
uint shader, uint index,
tmpPtr[i] = bswap_32(((uint32_t *)ptr)[i]);
}
 
-   u_upload_data(rctx->vbuf_mgr->uploader, 0, size, 
tmpPtr, &cb->buffer_offset, &cb->buffer);
+   u_upload_data(rctx->uploader, 0, size, tmpPtr, 
&cb->buffer_offset, &cb->buffer);
free(tmpPtr);
} else {
-   u_upload_data(rctx->vbuf_mgr->uploader, 0, 
buffer->width0, ptr, &cb->buffer_offset, &cb->buffer);
+   u_upload_data(rctx->uploader, 0, buffer->width0, ptr, 
&cb->buffer_offset, &cb->buffer);
}
} else {
/* Setup the hw buffer. */
@@ -779,7 +779,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *dinfo)
 
ptr = ib.buffer->user_ptr;
if (ptr) {
-   u_upload_data(rctx->vbuf_mgr->uploader, 0, info.count * 
ib.index_size,
+   u_upload_data(rctx->uploader, 0, info.count * 
ib.index_size,
  ptr, &ib.offset, &ib.buffer);
}
} else {
diff --git a/src/gallium/drivers/r600/r600_translate.c 
b/src/gallium/drivers/r600/r600_translate.c
index a556782..af3b8ca 100644
--- a/src/gallium/drivers/r600/r600_translate.c
+++ b/src/gallium/drivers/r600/r600_translate.c
@@ -38,7 +38,7 @@ void r600_translate_index_buffer(struct r600_context *r600,
 
switch (ib->index_size) {
case 1:
-   u_upload_alloc(r600->vbuf_mgr->uploader, 0, count * 2,
+   u_upload_alloc(r600->uploader, 0, count * 2,
   &out_offset, &out_buffer, &ptr);
 
util_shorten_ubyte_elts_to_userptr(
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 16/21] r300g: don't share u_upload_mgr with u_vbuf, create its own

2012-04-11 Thread Marek Olšák
---
 src/gallium/drivers/r300/r300_context.c  |5 +
 src/gallium/drivers/r300/r300_context.h  |1 +
 src/gallium/drivers/r300/r300_render_translate.c |6 +++---
 src/gallium/drivers/r300/r300_screen_buffer.c|2 +-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_context.c 
b/src/gallium/drivers/r300/r300_context.c
index 6a93575..658ce1e 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -103,6 +103,8 @@ static void r300_destroy_context(struct pipe_context* 
context)
 if (r300->vbuf_mgr)
 u_vbuf_destroy(r300->vbuf_mgr);
 
+u_upload_destroy(r300->uploader);
+
 /* XXX: This function assumes r300->query_list was initialized */
 r300_release_referenced_objects(r300);
 
@@ -440,6 +442,9 @@ struct pipe_context* r300_create_context(struct 
pipe_screen* screen,
 goto fail;
 }
 
+r300->uploader = u_upload_create(&r300->context, 256 * 1024, 16,
+ PIPE_BIND_INDEX_BUFFER);
+
 r300->blitter = util_blitter_create(&r300->context);
 if (r300->blitter == NULL)
 goto fail;
diff --git a/src/gallium/drivers/r300/r300_context.h 
b/src/gallium/drivers/r300/r300_context.h
index 29f2717..8f125d1 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -580,6 +580,7 @@ struct r300_context {
 struct pipe_index_buffer index_buffer;
 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
 unsigned nr_vertex_buffers;
+struct u_upload_mgr *uploader;
 
 struct util_slab_mempool pool_transfers;
 
diff --git a/src/gallium/drivers/r300/r300_render_translate.c 
b/src/gallium/drivers/r300/r300_render_translate.c
index c2eb3c5..022e8a7 100644
--- a/src/gallium/drivers/r300/r300_render_translate.c
+++ b/src/gallium/drivers/r300/r300_render_translate.c
@@ -36,7 +36,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
 
 switch (*index_size) {
 case 1:
-u_upload_alloc(r300->vbuf_mgr->uploader, 0, count * 2,
+u_upload_alloc(r300->uploader, 0, count * 2,
&out_offset, &out_buffer, &ptr);
 
 util_shorten_ubyte_elts_to_userptr(
@@ -51,7 +51,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
 
 case 2:
 if (index_offset) {
-u_upload_alloc(r300->vbuf_mgr->uploader, 0, count * 2,
+u_upload_alloc(r300->uploader, 0, count * 2,
&out_offset, &out_buffer, &ptr);
 
 util_rebuild_ushort_elts_to_userptr(&r300->context, *index_buffer,
@@ -66,7 +66,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
 
 case 4:
 if (index_offset) {
-u_upload_alloc(r300->vbuf_mgr->uploader, 0, count * 4,
+u_upload_alloc(r300->uploader, 0, count * 4,
&out_offset, &out_buffer, &ptr);
 
 util_rebuild_uint_elts_to_userptr(&r300->context, *index_buffer,
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c 
b/src/gallium/drivers/r300/r300_screen_buffer.c
index c92b831..d89cceb 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -41,7 +41,7 @@ void r300_upload_index_buffer(struct r300_context *r300,
 
 *index_buffer = NULL;
 
-u_upload_data(r300->vbuf_mgr->uploader,
+u_upload_data(r300->uploader,
   0, count * index_size,
   ptr + (*start * index_size),
   &index_offset,
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 15/21] u_vbuf: pull u_vbuf_draw_max_vertex_count into r300g

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_vbuf.c|   50 ---
 src/gallium/auxiliary/util/u_vbuf.h|1 -
 src/gallium/drivers/r300/r300_render.c |   51 +++-
 3 files changed, 50 insertions(+), 52 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index 31f670c..932b040 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -859,56 +859,6 @@ u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
}
 }
 
-unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgrb)
-{
-   struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
-   unsigned i, nr = mgr->ve->count;
-   struct pipe_vertex_element *velems =
- mgr->fallback_ve ? mgr->fallback_velems : mgr->ve->ve;
-   unsigned result = ~0;
-
-   for (i = 0; i < nr; i++) {
-  struct pipe_vertex_buffer *vb =
-&mgr->real_vertex_buffer[velems[i].vertex_buffer_index];
-  unsigned size, max_count, value;
-
-  /* We're not interested in constant and per-instance attribs. */
-  if (!vb->buffer ||
-  !vb->stride ||
-  velems[i].instance_divisor) {
- continue;
-  }
-
-  size = vb->buffer->width0;
-
-  /* Subtract buffer_offset. */
-  value = vb->buffer_offset;
-  if (value >= size) {
- return 0;
-  }
-  size -= value;
-
-  /* Subtract src_offset. */
-  value = velems[i].src_offset;
-  if (value >= size) {
- return 0;
-  }
-  size -= value;
-
-  /* Subtract format_size. */
-  value = mgr->ve->native_format_size[i];
-  if (value >= size) {
- return 0;
-  }
-  size -= value;
-
-  /* Compute the max count. */
-  max_count = 1 + size / vb->stride;
-  result = MIN2(result, max_count);
-   }
-   return result;
-}
-
 static boolean u_vbuf_need_minmax_index(struct u_vbuf_priv *mgr)
 {
unsigned i, nr = mgr->ve->count;
diff --git a/src/gallium/auxiliary/util/u_vbuf.h 
b/src/gallium/auxiliary/util/u_vbuf.h
index 1c05629..80983f7 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -90,6 +90,5 @@ u_vbuf_create(struct pipe_context *pipe,
 
 void u_vbuf_destroy(struct u_vbuf *mgr);
 
-unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgr);
 
 #endif
diff --git a/src/gallium/drivers/r300/r300_render.c 
b/src/gallium/drivers/r300/r300_render.c
index d5ba4fa..830b0d9 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -740,6 +740,55 @@ static void r300_draw_elements_instanced(struct 
r300_context *r300,
 r300_draw_elements(r300, info, i);
 }
 
+static unsigned r300_max_vertex_count(struct r300_context *r300)
+{
+   unsigned i, nr = r300->velems->count;
+   struct pipe_vertex_element *velems = r300->velems->velem;
+   unsigned result = ~0;
+
+   for (i = 0; i < nr; i++) {
+  struct pipe_vertex_buffer *vb =
+&r300->vertex_buffer[velems[i].vertex_buffer_index];
+  unsigned size, max_count, value;
+
+  /* We're not interested in constant and per-instance attribs. */
+  if (!vb->buffer ||
+  !vb->stride ||
+  velems[i].instance_divisor) {
+ continue;
+  }
+
+  size = vb->buffer->width0;
+
+  /* Subtract buffer_offset. */
+  value = vb->buffer_offset;
+  if (value >= size) {
+ return 0;
+  }
+  size -= value;
+
+  /* Subtract src_offset. */
+  value = velems[i].src_offset;
+  if (value >= size) {
+ return 0;
+  }
+  size -= value;
+
+  /* Subtract format_size. */
+  value = r300->velems->format_size[i];
+  if (value >= size) {
+ return 0;
+  }
+  size -= value;
+
+  /* Compute the max count. */
+  max_count = 1 + size / vb->stride;
+  result = MIN2(result, max_count);
+   }
+   return result;
+}
+
+
 static void r300_draw_vbo(struct pipe_context* pipe,
   const struct pipe_draw_info *dinfo)
 {
@@ -757,7 +806,7 @@ static void r300_draw_vbo(struct pipe_context* pipe,
 
 /* Draw. */
 if (info.indexed) {
-unsigned max_count = u_vbuf_draw_max_vertex_count(r300->vbuf_mgr);
+unsigned max_count = r300_max_vertex_count(r300);
 
 if (!max_count) {
fprintf(stderr, "r300: Skipping a draw command. There is a buffer "
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 14/21] u_vbuf: make use of the new CAPs to determine what to do

2012-04-11 Thread Marek Olšák
This adds the ability to initialize u_vbuf_caps before creating u_vbuf itself.
It will be useful for determining if u_vbuf should be used or not.

Also adapt r300g and r600g.
---
 src/gallium/auxiliary/util/u_vbuf.c |   51 +-
 src/gallium/auxiliary/util/u_vbuf.h |   14 -
 src/gallium/drivers/r300/r300_context.c |   11 --
 src/gallium/drivers/r300/r300_screen.c  |4 ++
 src/gallium/drivers/r600/r600_pipe.c|   18 +++
 5 files changed, 58 insertions(+), 40 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index 2482c8a..31f670c 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -68,6 +68,7 @@ enum {
 
 struct u_vbuf_priv {
struct u_vbuf b;
+   struct u_vbuf_caps caps;
struct pipe_context *pipe;
struct translate_cache *translate_cache;
struct cso_cache *cso_cache;
@@ -114,46 +115,56 @@ struct u_vbuf_priv {
const struct pipe_draw_info *info);
 };
 
-static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
+void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps)
 {
-   struct pipe_screen *screen = mgr->pipe->screen;
-
-   mgr->b.caps.format_fixed32 =
+   caps->format_fixed32 =
   screen->is_format_supported(screen, PIPE_FORMAT_R32_FIXED, PIPE_BUFFER,
   0, PIPE_BIND_VERTEX_BUFFER);
 
-   mgr->b.caps.format_float16 =
+   caps->format_float16 =
   screen->is_format_supported(screen, PIPE_FORMAT_R16_FLOAT, PIPE_BUFFER,
   0, PIPE_BIND_VERTEX_BUFFER);
 
-   mgr->b.caps.format_float64 =
+   caps->format_float64 =
   screen->is_format_supported(screen, PIPE_FORMAT_R64_FLOAT, PIPE_BUFFER,
   0, PIPE_BIND_VERTEX_BUFFER);
 
-   mgr->b.caps.format_norm32 =
+   caps->format_norm32 =
   screen->is_format_supported(screen, PIPE_FORMAT_R32_UNORM, PIPE_BUFFER,
   0, PIPE_BIND_VERTEX_BUFFER) &&
   screen->is_format_supported(screen, PIPE_FORMAT_R32_SNORM, PIPE_BUFFER,
   0, PIPE_BIND_VERTEX_BUFFER);
 
-   mgr->b.caps.format_scaled32 =
+   caps->format_scaled32 =
   screen->is_format_supported(screen, PIPE_FORMAT_R32_USCALED, PIPE_BUFFER,
   0, PIPE_BIND_VERTEX_BUFFER) &&
   screen->is_format_supported(screen, PIPE_FORMAT_R32_SSCALED, PIPE_BUFFER,
   0, PIPE_BIND_VERTEX_BUFFER);
+
+   caps->fetch_dword_unaligned =
+  !screen->get_param(screen,
+PIPE_CAP_VERTEX_BUFFER_OFFSET_DWORD_ALIGNED_ONLY) &&
+  !screen->get_param(screen,
+PIPE_CAP_VERTEX_BUFFER_STRIDE_DWORD_ALIGNED_ONLY) &&
+  !screen->get_param(screen,
+PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_DWORD_ALIGNED_ONLY);
+
+   caps->user_vertex_buffers =
+  screen->get_param(screen, PIPE_CAP_USER_VERTEX_BUFFERS);
 }
 
 static void u_vbuf_install(struct u_vbuf_priv *mgr);
 
 struct u_vbuf *
 u_vbuf_create(struct pipe_context *pipe,
+  struct u_vbuf_caps *caps,
   unsigned upload_buffer_size,
   unsigned upload_buffer_alignment,
-  unsigned upload_buffer_bind,
-  enum u_fetch_alignment fetch_alignment)
+  unsigned upload_buffer_bind)
 {
struct u_vbuf_priv *mgr = CALLOC_STRUCT(u_vbuf_priv);
 
+   mgr->caps = *caps;
mgr->pipe = pipe;
mgr->cso_cache = cso_cache_create();
mgr->translate_cache = translate_cache_create();
@@ -163,10 +174,6 @@ u_vbuf_create(struct pipe_context *pipe,
  upload_buffer_alignment,
  upload_buffer_bind);
 
-   mgr->b.caps.fetch_dword_unaligned =
- fetch_alignment == U_VERTEX_FETCH_BYTE_ALIGNED;
-
-   u_vbuf_init_format_caps(mgr);
u_vbuf_install(mgr);
return &mgr->b;
 }
@@ -588,7 +595,7 @@ u_vbuf_create_vertex_elements(struct pipe_context *pipe,
   /* Choose a native format.
* For now we don't care about the alignment, that's going to
* be sorted out later. */
-  if (!mgr->b.caps.format_fixed32) {
+  if (!mgr->caps.format_fixed32) {
  switch (format) {
 FORMAT_REPLACE(R32_FIXED,   R32_FLOAT);
 FORMAT_REPLACE(R32G32_FIXED,R32G32_FLOAT);
@@ -597,7 +604,7 @@ u_vbuf_create_vertex_elements(struct pipe_context *pipe,
 default:;
  }
   }
-  if (!mgr->b.caps.format_float16) {
+  if (!mgr->caps.format_float16) {
  switch (format) {
 FORMAT_REPLACE(R16_FLOAT,   R32_FLOAT);
 FORMAT_REPLACE(R16G16_FLOAT,R32G32_FLOAT);
@@ -606,7 +613,7 @@ u_vbuf_create_vertex_elements(struct pipe_context *pipe,
 default:;
  }
   }
-  if (!mgr->b.caps.format_float64) {
+  if (!mgr->caps

[Mesa-dev] [PATCH 13/21] gallium drivers: report that user vertex buffers are supported

2012-04-11 Thread Marek Olšák
---
 src/gallium/drivers/i915/i915_screen.c   |1 +
 src/gallium/drivers/llvmpipe/lp_screen.c |2 ++
 src/gallium/drivers/nv50/nv50_screen.c   |2 ++
 src/gallium/drivers/nvc0/nvc0_screen.c   |2 ++
 src/gallium/drivers/nvfx/nvfx_screen.c   |2 ++
 src/gallium/drivers/softpipe/sp_screen.c |2 ++
 src/gallium/drivers/svga/svga_screen.c   |2 ++
 7 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 9703210..b147e61 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -180,6 +180,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_BLEND_EQUATION_SEPARATE:
case PIPE_CAP_TGSI_INSTANCEID:
case PIPE_CAP_VERTEX_COLOR_CLAMPED:
+   case PIPE_CAP_USER_VERTEX_BUFFERS:
   return 1;
 
/* Unsupported features (boolean caps). */
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 7f0f17e..3e0808d 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -159,6 +159,8 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
   return 1;
case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
   return 0;
+   case PIPE_CAP_USER_VERTEX_BUFFERS:
+  return 1;
default:
   return 0;
}
diff --git a/src/gallium/drivers/nv50/nv50_screen.c 
b/src/gallium/drivers/nv50/nv50_screen.c
index 27566e2..e0900f7 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -151,6 +151,8 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS:
case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
   return 0; /* state trackers will know better */
+   case PIPE_CAP_USER_VERTEX_BUFFERS:
+  return 1;
default:
   NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
   return 0;
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nvc0/nvc0_screen.c
index f7637ee..17c4df3 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -137,6 +137,8 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS:
case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
   return 0; /* state trackers will know better */
+   case PIPE_CAP_USER_VERTEX_BUFFERS:
+  return 1;
default:
   NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
   return 0;
diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c 
b/src/gallium/drivers/nvfx/nvfx_screen.c
index 71e7c15..a71b5de 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.c
+++ b/src/gallium/drivers/nvfx/nvfx_screen.c
@@ -79,6 +79,8 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
return 0; // TODO: implement depth clamp
case PIPE_CAP_PRIMITIVE_RESTART:
return 0; // TODO: implement primitive restart
+   case PIPE_CAP_USER_VERTEX_BUFFERS:
+  return 1;
case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
case PIPE_CAP_TGSI_INSTANCEID:
case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
diff --git a/src/gallium/drivers/softpipe/sp_screen.c 
b/src/gallium/drivers/softpipe/sp_screen.c
index 183ed9a..bfbcd62 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -136,6 +136,8 @@ softpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
   return 130;
case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
   return 0;
+   case PIPE_CAP_USER_VERTEX_BUFFERS:
+  return 1;
default:
   return 0;
}
diff --git a/src/gallium/drivers/svga/svga_screen.c 
b/src/gallium/drivers/svga/svga_screen.c
index a5d28b1..66f5079 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -158,6 +158,8 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
   return 1;
case PIPE_CAP_TEXTURE_SWIZZLE:
   return 1;
+   case PIPE_CAP_USER_VERTEX_BUFFERS:
+  return 1;
 
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
   {
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 12/21] gallium: add CAPs for vertex fetcher

2012-04-11 Thread Marek Olšák
Supported vertex formats can be queried using
is_format_supported(.., PIPE_BIND_VERTEX_BUFFER, ..).
---
 src/gallium/include/pipe/p_defines.h |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index e49d192..2ecea3c 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -473,7 +473,11 @@ enum pipe_cap {
PIPE_CAP_VERTEX_COLOR_UNCLAMPED = 60,
PIPE_CAP_VERTEX_COLOR_CLAMPED = 61,
PIPE_CAP_GLSL_FEATURE_LEVEL = 62,
-   PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 63
+   PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 63,
+   PIPE_CAP_USER_VERTEX_BUFFERS = 64,
+   PIPE_CAP_VERTEX_BUFFER_OFFSET_DWORD_ALIGNED_ONLY = 65,
+   PIPE_CAP_VERTEX_BUFFER_STRIDE_DWORD_ALIGNED_ONLY = 66,
+   PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_DWORD_ALIGNED_ONLY = 67,
 };
 
 /**
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 11/21] u_vbuf: remove u_vbuf_resource

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_vbuf.h   |   13 ---
 src/gallium/drivers/r300/r300_context.h   |2 +-
 src/gallium/drivers/r300/r300_emit.c  |6 +-
 src/gallium/drivers/r300/r300_fs.c|2 +-
 src/gallium/drivers/r300/r300_render.c|   14 ++--
 src/gallium/drivers/r300/r300_screen_buffer.c |   54 ++---
 src/gallium/drivers/r300/r300_state.c |4 +-
 src/gallium/drivers/r300/r300_state_derived.c |6 +-
 src/gallium/drivers/r300/r300_texture.c   |   16 ++--
 src/gallium/drivers/r300/r300_texture_desc.c  |  102 
 src/gallium/drivers/r300/r300_transfer.c  |6 +-
 src/gallium/drivers/r600/evergreen_state.c|6 +-
 src/gallium/drivers/r600/r600.h   |3 +-
 src/gallium/drivers/r600/r600_blit.c  |   10 +-
 src/gallium/drivers/r600/r600_buffer.c|   58 +++---
 src/gallium/drivers/r600/r600_hw_context.c|6 +-
 src/gallium/drivers/r600/r600_query.c |4 +-
 src/gallium/drivers/r600/r600_state.c |2 +-
 src/gallium/drivers/r600/r600_state_common.c  |4 +-
 src/gallium/drivers/r600/r600_texture.c   |   28 
 20 files changed, 165 insertions(+), 181 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.h 
b/src/gallium/auxiliary/util/u_vbuf.h
index b5b7298..a17d64a 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -35,7 +35,6 @@
 
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
-#include "util/u_transfer.h"
 
 /* Hardware vertex fetcher limitations can be described by this structure. */
 struct u_vbuf_caps {
@@ -78,12 +77,6 @@ struct u_vbuf {
void *vertex_elements;
 };
 
-/* XXX this is no longer needed and can be removed */
-struct u_vbuf_resource {
-   struct u_resource b;
-   uint8_t *user_ptr;
-};
-
 enum u_fetch_alignment {
U_VERTEX_FETCH_BYTE_ALIGNED,
U_VERTEX_FETCH_DWORD_ALIGNED
@@ -101,10 +94,4 @@ void u_vbuf_destroy(struct u_vbuf *mgr);
 
 unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgr);
 
-
-static INLINE struct u_vbuf_resource *u_vbuf_resource(struct pipe_resource *r)
-{
-   return (struct u_vbuf_resource*)r;
-}
-
 #endif
diff --git a/src/gallium/drivers/r300/r300_context.h 
b/src/gallium/drivers/r300/r300_context.h
index 9367fc0..29f2717 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -383,7 +383,7 @@ struct r300_texture_desc {
 
 struct r300_resource
 {
-struct u_vbuf_resource b;
+struct u_resource b;
 
 /* Winsys buffer backing this resource. */
 struct pb_buffer *buf;
diff --git a/src/gallium/drivers/r300/r300_emit.c 
b/src/gallium/drivers/r300/r300_emit.c
index 355fa3f..cb2fc0a 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -120,9 +120,9 @@ static void get_rc_constant_state(
 case RC_STATE_R300_TEXSCALE_FACTOR:
 tex = 
r300_resource(texstate->sampler_views[constant->u.State[1]]->base.texture);
 /* Add a small number to the texture size to work around rounding 
errors in hw. */
-vec[0] = tex->b.b.b.width0  / (tex->tex.width0  + 0.001f);
-vec[1] = tex->b.b.b.height0 / (tex->tex.height0 + 0.001f);
-vec[2] = tex->b.b.b.depth0  / (tex->tex.depth0  + 0.001f);
+vec[0] = tex->b.b.width0  / (tex->tex.width0  + 0.001f);
+vec[1] = tex->b.b.height0 / (tex->tex.height0 + 0.001f);
+vec[2] = tex->b.b.depth0  / (tex->tex.depth0  + 0.001f);
 vec[3] = 1;
 break;
 
diff --git a/src/gallium/drivers/r300/r300_fs.c 
b/src/gallium/drivers/r300/r300_fs.c
index 051b292..8a492d2 100644
--- a/src/gallium/drivers/r300/r300_fs.c
+++ b/src/gallium/drivers/r300/r300_fs.c
@@ -212,7 +212,7 @@ static void get_external_state(
 state->unit[i].wrap_mode = RC_WRAP_NONE;
 }
 
-if (t->b.b.b.target == PIPE_TEXTURE_3D)
+if (t->b.b.target == PIPE_TEXTURE_3D)
 state->unit[i].clamp_and_scale_before_fetch = TRUE;
 }
 }
diff --git a/src/gallium/drivers/r300/r300_render.c 
b/src/gallium/drivers/r300/r300_render.c
index c0f5687..d5ba4fa 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -529,7 +529,7 @@ static void r300_draw_elements_immediate(struct 
r300_context *r300,
 
 switch (index_size) {
 case 1:
-ptr1 = r300_resource(r300->index_buffer.buffer)->b.user_ptr;
+ptr1 = r300->index_buffer.buffer->user_ptr;
 ptr1 += info->start;
 
 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) |
@@ -553,7 +553,7 @@ static void r300_draw_elements_immediate(struct 
r300_context *r300,
 break;
 
 case 2:
-ptr2 = (uint16_t*)r300_resource(r300->index_buffer.buffer)->b.user_ptr;
+ptr2 = (uint16_t*)r300->index_buffer.buffer->user_ptr;
 ptr2 += in

[Mesa-dev] [PATCH 10/21] u_vbuf: use user_ptr from pipe_resource

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_vbuf.c |   22 +++---
 src/gallium/auxiliary/util/u_vbuf.h |1 +
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index b63de48..2482c8a 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -255,8 +255,8 @@ u_vbuf_translate_buffers(struct u_vbuf_priv *mgr, struct 
translate_key *key,
  unsigned offset = vb->buffer_offset + vb->stride * start_vertex;
  uint8_t *map;
 
- if (u_vbuf_resource(vb->buffer)->user_ptr) {
-map = u_vbuf_resource(vb->buffer)->user_ptr + offset;
+ if (vb->buffer->user_ptr) {
+map = vb->buffer->user_ptr + offset;
  } else {
 unsigned size = vb->stride ? num_vertices * vb->stride
: sizeof(double)*4;
@@ -287,8 +287,8 @@ u_vbuf_translate_buffers(struct u_vbuf_priv *mgr, struct 
translate_key *key,
 
   assert(ib->buffer && ib->index_size);
 
-  if (u_vbuf_resource(ib->buffer)->user_ptr) {
- map = u_vbuf_resource(ib->buffer)->user_ptr + offset;
+  if (ib->buffer->user_ptr) {
+ map = ib->buffer->user_ptr + offset;
   } else {
  map = pipe_buffer_map_range(mgr->pipe, ib->buffer, offset,
  num_indices * ib->index_size,
@@ -729,7 +729,7 @@ static void u_vbuf_set_vertex_buffers(struct pipe_context 
*pipe,
  continue;
   }
 
-  if (u_vbuf_resource(vb->buffer)->user_ptr) {
+  if (vb->buffer->user_ptr) {
  pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
  mgr->any_user_vbs = TRUE;
  continue;
@@ -796,7 +796,7 @@ u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
 
   assert(vb->buffer);
 
-  if (!u_vbuf_resource(vb->buffer)->user_ptr) {
+  if (!vb->buffer->user_ptr) {
  continue;
   }
 
@@ -843,7 +843,7 @@ u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
   assert(start < end);
 
   real_vb = &mgr->real_vertex_buffer[i];
-  ptr = u_vbuf_resource(mgr->b.vertex_buffer[i].buffer)->user_ptr;
+  ptr = mgr->b.vertex_buffer[i].buffer->user_ptr;
 
   u_upload_data(mgr->b.uploader, start, end - start, ptr + start,
 &real_vb->buffer_offset, &real_vb->buffer);
@@ -924,7 +924,7 @@ static boolean u_vbuf_need_minmax_index(struct u_vbuf_priv 
*mgr)
   }
 
   /* Per-vertex attribs need min/max_index. */
-  if (u_vbuf_resource(vb->buffer)->user_ptr ||
+  if (vb->buffer->user_ptr ||
   mgr->ve->incompatible_layout_elem[i] ||
   mgr->incompatible_vb[index]) {
  return TRUE;
@@ -957,7 +957,7 @@ static boolean u_vbuf_mapping_vertex_buffer_blocks(struct 
u_vbuf_priv *mgr)
 
   /* Return true for the hw buffers which don't need to be translated. */
   /* XXX we could use some kind of a is-busy query. */
-  if (!u_vbuf_resource(vb->buffer)->user_ptr &&
+  if (!vb->buffer->user_ptr &&
   !mgr->ve->incompatible_layout_elem[i] &&
   !mgr->incompatible_vb[index]) {
  return TRUE;
@@ -978,8 +978,8 @@ static void u_vbuf_get_minmax_index(struct pipe_context 
*pipe,
unsigned i;
unsigned restart_index = info->restart_index;
 
-   if (u_vbuf_resource(ib->buffer)->user_ptr) {
-  indices = u_vbuf_resource(ib->buffer)->user_ptr +
+   if (ib->buffer->user_ptr) {
+  indices = ib->buffer->user_ptr +
 ib->offset + info->start * ib->index_size;
} else {
   indices = pipe_buffer_map_range(pipe, ib->buffer,
diff --git a/src/gallium/auxiliary/util/u_vbuf.h 
b/src/gallium/auxiliary/util/u_vbuf.h
index 4f3235b..b5b7298 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -78,6 +78,7 @@ struct u_vbuf {
void *vertex_elements;
 };
 
+/* XXX this is no longer needed and can be removed */
 struct u_vbuf_resource {
struct u_resource b;
uint8_t *user_ptr;
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 09/21] gallium: add user_ptr in pipe_resource

2012-04-11 Thread Marek Olšák
I need to access the pointer in st/mesa when I only have pipe_resource.
---
 src/gallium/drivers/i915/i915_resource_buffer.c |1 +
 src/gallium/drivers/llvmpipe/lp_texture.c   |1 +
 src/gallium/drivers/nouveau/nouveau_buffer.c|1 +
 src/gallium/drivers/nvfx/nvfx_buffer.c  |1 +
 src/gallium/drivers/r300/r300_screen_buffer.c   |2 ++
 src/gallium/drivers/r600/r600_buffer.c  |2 ++
 src/gallium/drivers/softpipe/sp_texture.c   |1 +
 src/gallium/drivers/svga/svga_resource_buffer.c |1 +
 src/gallium/include/pipe/p_state.h  |3 +++
 9 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c 
b/src/gallium/drivers/i915/i915_resource_buffer.c
index 77c0345..6718948 100644
--- a/src/gallium/drivers/i915/i915_resource_buffer.c
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -183,6 +183,7 @@ i915_user_buffer_create(struct pipe_screen *screen,
buf->b.b.height0 = 1;
buf->b.b.depth0 = 1;
buf->b.b.array_size = 1;
+   buf->b.b.user_ptr = ptr;
 
buf->data = ptr;
buf->free_on_destroy = FALSE;
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index 28e5aa9..f6a1ec2 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -770,6 +770,7 @@ llvmpipe_user_buffer_create(struct pipe_screen *screen,
buffer->base.height0 = 1;
buffer->base.depth0 = 1;
buffer->base.array_size = 1;
+   buffer->base.user_ptr = ptr;
buffer->userBuffer = TRUE;
buffer->data = ptr;
 
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c 
b/src/gallium/drivers/nouveau/nouveau_buffer.c
index f822625..016c0d3 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -383,6 +383,7 @@ nouveau_user_buffer_create(struct pipe_screen *pscreen, 
void *ptr,
buffer->base.width0 = bytes;
buffer->base.height0 = 1;
buffer->base.depth0 = 1;
+   buffer->base.user_ptr = ptr;
 
buffer->data = ptr;
buffer->status = NOUVEAU_BUFFER_STATUS_USER_MEMORY;
diff --git a/src/gallium/drivers/nvfx/nvfx_buffer.c 
b/src/gallium/drivers/nvfx/nvfx_buffer.c
index 76b7f45..3b84809 100644
--- a/src/gallium/drivers/nvfx/nvfx_buffer.c
+++ b/src/gallium/drivers/nvfx/nvfx_buffer.c
@@ -66,6 +66,7 @@ nvfx_user_buffer_create(struct pipe_screen *pscreen,
buffer->base.base.height0 = 1;
buffer->base.base.depth0 = 1;
buffer->base.base.array_size = 1;
+   buffer->base.base.user_ptr = ptr;
buffer->data = ptr;
buffer->size = bytes;
buffer->bytes_to_draw_until_static = bytes * 
screen->static_reuse_threshold;
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c 
b/src/gallium/drivers/r300/r300_screen_buffer.c
index 37f6e8d..fba17a2 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -193,6 +193,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen 
*screen,
 rbuf->b.b.vtbl = &r300_buffer_vtbl;
 pipe_reference_init(&rbuf->b.b.b.reference, 1);
 rbuf->b.b.b.screen = screen;
+rbuf->b.b.b.user_ptr = NULL;
 rbuf->b.user_ptr = NULL;
 rbuf->domain = RADEON_DOMAIN_GTT;
 rbuf->buf = NULL;
@@ -239,6 +240,7 @@ struct pipe_resource *r300_user_buffer_create(struct 
pipe_screen *screen,
 rbuf->b.b.b.depth0 = 1;
 rbuf->b.b.b.array_size = 1;
 rbuf->b.b.b.flags = 0;
+rbuf->b.b.b.user_ptr = ptr;
 rbuf->b.b.vtbl = &r300_buffer_vtbl;
 rbuf->b.user_ptr = ptr;
 rbuf->domain = RADEON_DOMAIN_GTT;
diff --git a/src/gallium/drivers/r600/r600_buffer.c 
b/src/gallium/drivers/r600/r600_buffer.c
index 4708d01..440af56 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -222,6 +222,7 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen 
*screen,
rbuffer->b.b.b = *templ;
pipe_reference_init(&rbuffer->b.b.b.reference, 1);
rbuffer->b.b.b.screen = screen;
+   rbuffer->b.b.b.user_ptr = NULL;
rbuffer->b.b.vtbl = &r600_buffer_vtbl;
rbuffer->b.user_ptr = NULL;
 
@@ -253,6 +254,7 @@ struct pipe_resource *r600_user_buffer_create(struct 
pipe_screen *screen,
rbuffer->b.b.b.depth0 = 1;
rbuffer->b.b.b.array_size = 1;
rbuffer->b.b.b.flags = 0;
+   rbuffer->b.b.b.user_ptr = ptr;
rbuffer->b.user_ptr = ptr;
rbuffer->buf = NULL;
return &rbuffer->b.b.b;
diff --git a/src/gallium/drivers/softpipe/sp_texture.c 
b/src/gallium/drivers/softpipe/sp_texture.c
index 95374c3..f5c6f56 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -476,6 +476,7 @@ softpipe_user_buffer_create(struct pipe_screen *screen,
spr->base.height0 = 1;
spr->base.depth0 = 1;
spr->base.array_size = 1;
+   spr->base.user_ptr = ptr;
spr->userBuffer = T

[Mesa-dev] [PATCH 08/21] u_vbuf: override draw_vbo

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_vbuf.c  |   52 --
 src/gallium/auxiliary/util/u_vbuf.h  |5 --
 src/gallium/drivers/r300/r300_render.c   |6 +--
 src/gallium/drivers/r600/r600_state_common.c |2 -
 4 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index f3ba89f..b63de48 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -76,6 +76,7 @@ struct u_vbuf_priv {
 * There are no user buffers. */
struct pipe_vertex_buffer real_vertex_buffer[PIPE_MAX_ATTRIBS];
int nr_real_vertex_buffers;
+   boolean vertex_buffers_dirty;
 
/* The index buffer. */
struct pipe_index_buffer index_buffer;
@@ -109,6 +110,8 @@ struct u_vbuf_priv {
   const struct pipe_vertex_element *);
void (*driver_bind_vertex_elements_state)(struct pipe_context *, void *);
void (*driver_delete_vertex_elements_state)(struct pipe_context *, void *);
+   void (*driver_draw_vbo)(struct pipe_context *pipe,
+   const struct pipe_draw_info *info);
 };
 
 static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
@@ -744,11 +747,7 @@ static void u_vbuf_set_vertex_buffers(struct pipe_context 
*pipe,
 
mgr->b.nr_vertex_buffers = count;
mgr->nr_real_vertex_buffers = count;
-
-   if (!mgr->any_user_vbs && !mgr->incompatible_vb_layout) {
-  mgr->driver_set_vertex_buffers(pipe, mgr->nr_real_vertex_buffers,
- mgr->real_vertex_buffer);
-   }
+   mgr->vertex_buffers_dirty = TRUE;
 }
 
 static void u_vbuf_set_index_buffer(struct pipe_context *pipe,
@@ -1067,17 +1066,26 @@ static void u_vbuf_get_minmax_index(struct pipe_context 
*pipe,
}
 }
 
-void u_vbuf_draw_begin(struct u_vbuf *mgrb,
-   struct pipe_draw_info *info)
+static void u_vbuf_draw_vbo(struct pipe_context *pipe,
+const struct pipe_draw_info *info)
 {
-   struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
+   struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)pipe->draw;
int start_vertex, min_index;
unsigned num_vertices;
bool unroll_indices = false;
 
+   /* Normal draw. No fallback and no user buffers. */
if (!mgr->incompatible_vb_layout &&
!mgr->ve->incompatible_layout &&
!mgr->any_user_vbs) {
+  /* Set vertex buffers if needed. */
+  if (mgr->vertex_buffers_dirty) {
+ mgr->driver_set_vertex_buffers(pipe, mgr->nr_real_vertex_buffers,
+mgr->real_vertex_buffer);
+ mgr->vertex_buffers_dirty = FALSE;
+  }
+
+  mgr->driver_draw_vbo(pipe, info);
   return;
}
 
@@ -1164,25 +1172,26 @@ void u_vbuf_draw_begin(struct u_vbuf *mgrb,
}
*/
 
-   if (unroll_indices) {
-  info->indexed = FALSE;
-  info->index_bias = 0;
-  info->min_index = 0;
-  info->max_index = info->count - 1;
-  info->start = 0;
-   }
-
mgr->driver_set_vertex_buffers(mgr->pipe, mgr->nr_real_vertex_buffers,
   mgr->real_vertex_buffer);
-}
 
-void u_vbuf_draw_end(struct u_vbuf *mgrb)
-{
-   struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
+   if (unlikely(unroll_indices)) {
+  struct pipe_draw_info new_info = *info;
+  new_info.indexed = FALSE;
+  new_info.index_bias = 0;
+  new_info.min_index = 0;
+  new_info.max_index = info->count - 1;
+  new_info.start = 0;
+
+  mgr->driver_draw_vbo(pipe, &new_info);
+   } else {
+  mgr->driver_draw_vbo(pipe, info);
+   }
 
if (mgr->fallback_ve) {
   u_vbuf_translate_end(mgr);
}
+   mgr->vertex_buffers_dirty = TRUE;
 }
 
 static void u_vbuf_install(struct u_vbuf_priv *mgr)
@@ -1198,9 +1207,12 @@ static void u_vbuf_install(struct u_vbuf_priv *mgr)
mgr->driver_bind_vertex_elements_state = pipe->bind_vertex_elements_state;
mgr->driver_delete_vertex_elements_state =
   pipe->delete_vertex_elements_state;
+   mgr->driver_draw_vbo = pipe->draw_vbo;
+
pipe->set_index_buffer = u_vbuf_set_index_buffer;
pipe->set_vertex_buffers = u_vbuf_set_vertex_buffers;
pipe->create_vertex_elements_state = u_vbuf_create_vertex_elements;
pipe->bind_vertex_elements_state = u_vbuf_bind_vertex_elements;
pipe->delete_vertex_elements_state = u_vbuf_delete_vertex_elements;
+   pipe->draw_vbo = u_vbuf_draw_vbo;
 }
diff --git a/src/gallium/auxiliary/util/u_vbuf.h 
b/src/gallium/auxiliary/util/u_vbuf.h
index 99b97a2..4f3235b 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -98,13 +98,8 @@ u_vbuf_create(struct pipe_context *pipe,
 
 void u_vbuf_destroy(struct u_vbuf *mgr);
 
-void u_vbuf_draw_begin(struct u_vbuf *mgr,
-   struct pipe_draw_info *info);
-
 unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgr);
 
-void u_vbuf_draw_end(struct u_vbuf *mgr);
-
 
 st

[Mesa-dev] [PATCH 07/21] u_vbuf: override create/bind/destroy_vertex_elements_state

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_vbuf.c  |   83 +
 src/gallium/auxiliary/util/u_vbuf.h  |   21 ++-
 src/gallium/drivers/r300/r300_blit.c |3 +-
 src/gallium/drivers/r300/r300_context.h  |2 -
 src/gallium/drivers/r300/r300_state.c|   17 +-
 src/gallium/drivers/r600/r600_blit.c |2 +-
 src/gallium/drivers/r600/r600_pipe.h |1 -
 src/gallium/drivers/r600/r600_state_common.c |7 +--
 8 files changed, 54 insertions(+), 82 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index 92a7df1..f3ba89f 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -55,6 +55,8 @@ struct u_vbuf_elements {
boolean incompatible_layout;
/* Per-element flags. */
boolean incompatible_layout_elem[PIPE_MAX_ATTRIBS];
+
+   void *driver_cso;
 };
 
 enum {
@@ -78,8 +80,6 @@ struct u_vbuf_priv {
/* The index buffer. */
struct pipe_index_buffer index_buffer;
 
-   /* Vertex element state bound by the state tracker. */
-   void *saved_ve;
/* and its associated helper structure for this module. */
struct u_vbuf_elements *ve;
 
@@ -91,9 +91,6 @@ struct u_vbuf_priv {
/* The vertex buffer slot index where translated vertices have been
 * stored in. */
unsigned fallback_vbs[VB_NUM];
-   /* When binding the fallback vertex element state, we don't want to
-* change saved_ve and ve. This is set to TRUE in such cases. */
-   boolean ve_binding_lock;
 
/* Whether there is any user buffer. */
boolean any_user_vbs;
@@ -107,6 +104,11 @@ struct u_vbuf_priv {
void (*driver_set_vertex_buffers)(struct pipe_context *,
 unsigned num_buffers,
 const struct pipe_vertex_buffer *);
+   void *(*driver_create_vertex_elements_state)(struct pipe_context *,
+  unsigned num_elements,
+  const struct pipe_vertex_element *);
+   void (*driver_bind_vertex_elements_state)(struct pipe_context *, void *);
+   void (*driver_delete_vertex_elements_state)(struct pipe_context *, void *);
 };
 
 static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
@@ -168,7 +170,7 @@ u_vbuf_create(struct pipe_context *pipe,
 
 /* XXX I had to fork this off of cso_context. */
 static void *
-u_vbuf_pipe_set_vertex_elements(struct u_vbuf_priv *mgr,
+u_vbuf_cache_set_vertex_elements(struct u_vbuf_priv *mgr,
 unsigned count,
 const struct pipe_vertex_element *states)
 {
@@ -190,10 +192,10 @@ u_vbuf_pipe_set_vertex_elements(struct u_vbuf_priv *mgr,
   struct cso_velements *cso = MALLOC_STRUCT(cso_velements);
   memcpy(&cso->state, &velems_state, key_size);
   cso->data =
-mgr->pipe->create_vertex_elements_state(mgr->pipe, count,
-&cso->state.velems[0]);
+mgr->driver_create_vertex_elements_state(mgr->pipe, count,
+ &cso->state.velems[0]);
   cso->delete_state =
-(cso_state_callback)mgr->pipe->delete_vertex_elements_state;
+(cso_state_callback)mgr->driver_delete_vertex_elements_state;
   cso->context = mgr->pipe;
 
   iter = cso_insert_state(mgr->cso_cache, hash_key, CSO_VELEMENTS, cso);
@@ -202,7 +204,7 @@ u_vbuf_pipe_set_vertex_elements(struct u_vbuf_priv *mgr,
   handle = ((struct cso_velements *)cso_hash_iter_data(iter))->data;
}
 
-   mgr->pipe->bind_vertex_elements_state(mgr->pipe, handle);
+   mgr->driver_bind_vertex_elements_state(mgr->pipe, handle);
return handle;
 }
 
@@ -531,11 +533,8 @@ u_vbuf_translate_begin(struct u_vbuf_priv *mgr,
   }
}
 
-   /* Preserve saved_ve. */
-   mgr->ve_binding_lock = TRUE;
-   mgr->fallback_ve = u_vbuf_pipe_set_vertex_elements(mgr, mgr->ve->count,
-  mgr->fallback_velems);
-   mgr->ve_binding_lock = FALSE;
+   mgr->fallback_ve = u_vbuf_cache_set_vertex_elements(mgr, mgr->ve->count,
+   mgr->fallback_velems);
return TRUE;
 }
 
@@ -544,8 +543,7 @@ static void u_vbuf_translate_end(struct u_vbuf_priv *mgr)
unsigned i;
 
/* Restore vertex elements. */
-   /* Note that saved_ve will be overwritten in bind_vertex_elements_state. */
-   mgr->pipe->bind_vertex_elements_state(mgr->pipe, mgr->saved_ve);
+   mgr->driver_bind_vertex_elements_state(mgr->pipe, mgr->ve->driver_cso);
mgr->fallback_ve = NULL;
 
/* Unreference the now-unused VBOs. */
@@ -562,22 +560,18 @@ static void u_vbuf_translate_end(struct u_vbuf_priv *mgr)
 #define FORMAT_REPLACE(what, withwhat) \
 case PIPE_FORMAT_##what: format = PIPE_FORMAT_##withwhat; break
 
-struct u_vbuf_elements *
-u_vbuf_create_vertex_elements(struct u_

[Mesa-dev] [PATCH 06/21] u_vbuf: override set_vertex_buffers

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_vbuf.c  |   81 +++---
 src/gallium/auxiliary/util/u_vbuf.h  |   18 +-
 src/gallium/drivers/r300/r300_blit.c |4 +-
 src/gallium/drivers/r300/r300_context.c  |4 +-
 src/gallium/drivers/r300/r300_context.h  |6 +-
 src/gallium/drivers/r300/r300_emit.c |9 ++-
 src/gallium/drivers/r300/r300_render.c   |   22 +++
 src/gallium/drivers/r300/r300_state.c|   12 ++--
 src/gallium/drivers/r600/evergreen_state.c   |4 +-
 src/gallium/drivers/r600/r600_pipe.h |2 +
 src/gallium/drivers/r600/r600_state.c|4 +-
 src/gallium/drivers/r600/r600_state_common.c |8 +-
 12 files changed, 86 insertions(+), 88 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index 7883845..92a7df1 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -70,6 +70,11 @@ struct u_vbuf_priv {
struct translate_cache *translate_cache;
struct cso_cache *cso_cache;
 
+   /* Vertex buffers for the driver.
+* There are no user buffers. */
+   struct pipe_vertex_buffer real_vertex_buffer[PIPE_MAX_ATTRIBS];
+   int nr_real_vertex_buffers;
+
/* The index buffer. */
struct pipe_index_buffer index_buffer;
 
@@ -99,6 +104,9 @@ struct u_vbuf_priv {
 
void (*driver_set_index_buffer)(struct pipe_context *pipe,
   const struct pipe_index_buffer *);
+   void (*driver_set_vertex_buffers)(struct pipe_context *,
+unsigned num_buffers,
+const struct pipe_vertex_buffer *);
 };
 
 static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
@@ -209,8 +217,8 @@ void u_vbuf_destroy(struct u_vbuf *mgrb)
for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
   pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
}
-   for (i = 0; i < mgr->b.nr_real_vertex_buffers; i++) {
-  pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+   for (i = 0; i < mgr->nr_real_vertex_buffers; i++) {
+  pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
}
 
translate_cache_destroy(mgr->translate_cache);
@@ -324,13 +332,13 @@ u_vbuf_translate_buffers(struct u_vbuf_priv *mgr, struct 
translate_key *key,
}
 
/* Setup the new vertex buffer. */
-   mgr->b.real_vertex_buffer[out_vb].buffer_offset = out_offset;
-   mgr->b.real_vertex_buffer[out_vb].stride = key->output_stride;
+   mgr->real_vertex_buffer[out_vb].buffer_offset = out_offset;
+   mgr->real_vertex_buffer[out_vb].stride = key->output_stride;
 
/* Move the buffer reference. */
pipe_resource_reference(
-  &mgr->b.real_vertex_buffer[out_vb].buffer, NULL);
-   mgr->b.real_vertex_buffer[out_vb].buffer = out_buffer;
+  &mgr->real_vertex_buffer[out_vb].buffer, NULL);
+   mgr->real_vertex_buffer[out_vb].buffer = out_buffer;
 }
 
 static boolean
@@ -364,15 +372,15 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf_priv 
*mgr,
/*printf("found slot=%i for type=%i\n", i, type);*/
fallback_vbs[type] = i;
i++;
-   if (i > mgr->b.nr_real_vertex_buffers) {
-  mgr->b.nr_real_vertex_buffers = i;
+   if (i > mgr->nr_real_vertex_buffers) {
+  mgr->nr_real_vertex_buffers = i;
}
break;
 }
  }
  if (i == PIPE_MAX_ATTRIBS) {
 /* fail, reset the number to its original value */
-mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
+mgr->nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
 return FALSE;
  }
   }
@@ -495,7 +503,7 @@ u_vbuf_translate_begin(struct u_vbuf_priv *mgr,
 
  /* Fixup the stride for constant attribs. */
  if (type == VB_CONST) {
-mgr->b.real_vertex_buffer[mgr->fallback_vbs[VB_CONST]].stride = 0;
+mgr->real_vertex_buffer[mgr->fallback_vbs[VB_CONST]].stride = 0;
  }
   }
}
@@ -544,11 +552,11 @@ static void u_vbuf_translate_end(struct u_vbuf_priv *mgr)
for (i = 0; i < VB_NUM; i++) {
   unsigned vb = mgr->fallback_vbs[i];
   if (vb != ~0) {
- pipe_resource_reference(&mgr->b.real_vertex_buffer[vb].buffer, NULL);
+ pipe_resource_reference(&mgr->real_vertex_buffer[vb].buffer, NULL);
  mgr->fallback_vbs[i] = ~0;
   }
}
-   mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
+   mgr->nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
 }
 
 #define FORMAT_REPLACE(what, withwhat) \
@@ -682,11 +690,11 @@ void u_vbuf_destroy_vertex_elements(struct u_vbuf *mgr,
FREE(ve);
 }
 
-void u_vbuf_set_vertex_buffers(struct u_vbuf *mgrb,
-   unsigned count,
-   const struct pipe_vertex_buffer *bufs)
+static void u_vbuf_set

[Mesa-dev] [PATCH 05/21] u_vbuf: override set_index_buffer

2012-04-11 Thread Marek Olšák
This makes u_vbuf_mgr call the driver instead of the other way around.
---
 src/gallium/auxiliary/util/u_vbuf.c  |   35 ++---
 src/gallium/auxiliary/util/u_vbuf.h  |6 
 src/gallium/drivers/r300/r300_context.h  |2 +-
 src/gallium/drivers/r300/r300_render.c   |   22 
 src/gallium/drivers/r300/r300_state.c|   15 +--
 src/gallium/drivers/r600/r600_pipe.h |1 +
 src/gallium/drivers/r600/r600_state_common.c |   16 +++
 7 files changed, 60 insertions(+), 37 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index 50c35af..7883845 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -70,6 +70,9 @@ struct u_vbuf_priv {
struct translate_cache *translate_cache;
struct cso_cache *cso_cache;
 
+   /* The index buffer. */
+   struct pipe_index_buffer index_buffer;
+
/* Vertex element state bound by the state tracker. */
void *saved_ve;
/* and its associated helper structure for this module. */
@@ -93,6 +96,9 @@ struct u_vbuf_priv {
boolean incompatible_vb_layout;
/* Per-buffer flags. */
boolean incompatible_vb[PIPE_MAX_ATTRIBS];
+
+   void (*driver_set_index_buffer)(struct pipe_context *pipe,
+  const struct pipe_index_buffer *);
 };
 
 static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
@@ -124,6 +130,8 @@ static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
   0, PIPE_BIND_VERTEX_BUFFER);
 }
 
+static void u_vbuf_install(struct u_vbuf_priv *mgr);
+
 struct u_vbuf *
 u_vbuf_create(struct pipe_context *pipe,
   unsigned upload_buffer_size,
@@ -146,7 +154,7 @@ u_vbuf_create(struct pipe_context *pipe,
  fetch_alignment == U_VERTEX_FETCH_BYTE_ALIGNED;
 
u_vbuf_init_format_caps(mgr);
-
+   u_vbuf_install(mgr);
return &mgr->b;
 }
 
@@ -195,6 +203,9 @@ void u_vbuf_destroy(struct u_vbuf *mgrb)
struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
unsigned i;
 
+   assert(mgr->pipe->draw);
+   mgr->pipe->draw = NULL;
+
for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
   pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
}
@@ -256,7 +267,7 @@ u_vbuf_translate_buffers(struct u_vbuf_priv *mgr, struct 
translate_key *key,
 
/* Translate. */
if (unroll_indices) {
-  struct pipe_index_buffer *ib = &mgr->b.index_buffer;
+  struct pipe_index_buffer *ib = &mgr->index_buffer;
   struct pipe_transfer *transfer = NULL;
   unsigned offset = ib->offset + start_index * ib->index_size;
   uint8_t *map;
@@ -732,9 +743,11 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgrb,
mgr->b.nr_real_vertex_buffers = count;
 }
 
-void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
- const struct pipe_index_buffer *ib)
+static void u_vbuf_set_index_buffer(struct pipe_context *pipe,
+const struct pipe_index_buffer *ib)
 {
+   struct u_vbuf_priv *mgr = pipe->draw;
+
if (ib && ib->buffer) {
   assert(ib->offset % ib->index_size == 0);
   pipe_resource_reference(&mgr->index_buffer.buffer, ib->buffer);
@@ -743,6 +756,8 @@ void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
} else {
   pipe_resource_reference(&mgr->index_buffer.buffer, NULL);
}
+
+   mgr->driver_set_index_buffer(pipe, ib);
 }
 
 static void
@@ -1068,7 +1083,7 @@ u_vbuf_draw_begin(struct u_vbuf *mgrb,
  max_index = info->max_index;
  index_bounds_valid = true;
   } else if (u_vbuf_need_minmax_index(mgr)) {
- u_vbuf_get_minmax_index(mgr->pipe, &mgr->b.index_buffer, info,
+ u_vbuf_get_minmax_index(mgr->pipe, &mgr->index_buffer, info,
  &min_index, &max_index);
  index_bounds_valid = true;
   }
@@ -1161,3 +1176,13 @@ void u_vbuf_draw_end(struct u_vbuf *mgrb)
   u_vbuf_translate_end(mgr);
}
 }
+
+static void u_vbuf_install(struct u_vbuf_priv *mgr)
+{
+   struct pipe_context *pipe = mgr->pipe;
+   assert(!pipe->draw);
+
+   pipe->draw = mgr;
+   mgr->driver_set_index_buffer = pipe->set_index_buffer;
+   pipe->set_index_buffer = u_vbuf_set_index_buffer;
+}
diff --git a/src/gallium/auxiliary/util/u_vbuf.h 
b/src/gallium/auxiliary/util/u_vbuf.h
index 3669c9b..4a449fc 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -67,9 +67,6 @@ struct u_vbuf {
struct pipe_vertex_buffer real_vertex_buffer[PIPE_MAX_ATTRIBS];
int nr_real_vertex_buffers;
 
-   /* The index buffer. */
-   struct pipe_index_buffer index_buffer;
-
/* This uploader can optionally be used by the driver.
 *
 * Allowed functions:
@@ -126,9 +123,6 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
unsigned count,
const struct pipe_vertex_buffer *bufs);
 

[Mesa-dev] [PATCH 04/21] st/mesa: use cso_set_index_buffer and cso_draw_vbo

2012-04-11 Thread Marek Olšák
---
 src/mesa/state_tracker/st_draw.c |   16 +---
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 0a35ab2..edab76b 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -795,7 +795,8 @@ find_sub_primitives(const void *elements, unsigned 
element_size,
  * sub-primitives.
  */
 static void
-handle_fallback_primitive_restart(struct pipe_context *pipe,
+handle_fallback_primitive_restart(struct cso_context *cso,
+  struct pipe_context *pipe,
   const struct _mesa_index_buffer *ib,
   struct pipe_index_buffer *ibuffer,
   struct pipe_draw_info *orig_info)
@@ -851,7 +852,7 @@ handle_fallback_primitive_restart(struct pipe_context *pipe,
  info.start = sub_prims[i].start;
  info.count = sub_prims[i].count;
  if (u_trim_pipe_prim(info.mode, &info.count)) {
-pipe->draw_vbo(pipe, &info);
+cso_draw_vbo(cso, &info);
  }
   }
}
@@ -1075,7 +1076,7 @@ st_draw_vbo(struct gl_context *ctx,
}
 
setup_index_buffer(ctx, ib, &ibuffer);
-   pipe->set_index_buffer(pipe, &ibuffer);
+   cso_set_index_buffer(st->cso_context, &ibuffer);
 
util_draw_init_info(&info);
if (ib) {
@@ -1110,20 +,21 @@ st_draw_vbo(struct gl_context *ctx,
   }
 
   if (info.count_from_stream_output) {
- pipe->draw_vbo(pipe, &info);
+ cso_draw_vbo(st->cso_context, &info);
   }
   else if (info.primitive_restart) {
  if (st->sw_primitive_restart) {
 /* Handle primitive restart for drivers that doesn't support it */
-handle_fallback_primitive_restart(pipe, ib, &ibuffer, &info);
+handle_fallback_primitive_restart(st->cso_context, pipe, ib,
+  &ibuffer, &info);
  }
  else {
 /* don't trim, restarts might be inside index list */
-pipe->draw_vbo(pipe, &info);
+cso_draw_vbo(st->cso_context, &info);
  }
   }
   else if (u_trim_pipe_prim(info.mode, &info.count))
- pipe->draw_vbo(pipe, &info);
+ cso_draw_vbo(st->cso_context, &info);
}
 
pipe_resource_reference(&ibuffer.buffer, NULL);
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 03/21] gallium/util: use cso_draw_arrays in util_draw_vertex_buffer

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_draw_quad.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_draw_quad.c 
b/src/gallium/auxiliary/util/u_draw_quad.c
index 8ed3b3c..590fa0c 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.c
+++ b/src/gallium/auxiliary/util/u_draw_quad.c
@@ -57,16 +57,15 @@ util_draw_vertex_buffer(struct pipe_context *pipe,
vbuffer.stride = num_attribs * 4 * sizeof(float);  /* vertex size */
vbuffer.buffer_offset = offset;
 
+   /* note: vertex elements already set by caller */
+
if (cso) {
   cso_set_vertex_buffers(cso, 1, &vbuffer);
+  cso_draw_arrays(cso, prim_type, 0, num_verts);
} else {
   pipe->set_vertex_buffers(pipe, 1, &vbuffer);
+  util_draw_arrays(pipe, prim_type, 0, num_verts);
}
-
-   /* note: vertex elements already set by caller */
-
-   /* draw */
-   util_draw_arrays(pipe, prim_type, 0, num_verts);
 }
 
 
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 02/21] cso: add set_index_buffer and draw_vbo passthrough functions

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/cso_cache/cso_context.c |   18 ++
 src/gallium/auxiliary/cso_cache/cso_context.h |   25 +
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 43b8343..5fea531 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -1290,3 +1290,21 @@ cso_restore_stream_outputs(struct cso_context *ctx)
ctx->nr_so_targets = ctx->nr_so_targets_saved;
ctx->nr_so_targets_saved = 0;
 }
+
+/* drawing */
+
+void
+cso_set_index_buffer(struct cso_context *cso,
+ const struct pipe_index_buffer *ib)
+{
+   struct pipe_context *pipe = cso->pipe;
+   pipe->set_index_buffer(pipe, ib);
+}
+
+void
+cso_draw_vbo(struct cso_context *cso,
+ const struct pipe_draw_info *info)
+{
+   struct pipe_context *pipe = cso->pipe;
+   pipe->draw_vbo(pipe, info);
+}
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h 
b/src/gallium/auxiliary/cso_cache/cso_context.h
index 8cc1bbf..84203e6 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -217,6 +217,31 @@ cso_save_vertex_sampler_views(struct cso_context *cso);
 void
 cso_restore_vertex_sampler_views(struct cso_context *cso);
 
+/* drawing */
+
+void
+cso_set_index_buffer(struct cso_context *cso,
+ const struct pipe_index_buffer *ib);
+
+void
+cso_draw_vbo(struct cso_context *cso,
+ const struct pipe_draw_info *info);
+
+static INLINE void
+cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count)
+{
+   struct pipe_draw_info info = {0};
+
+   info.instance_count = 1;
+   info.max_index = 0x;
+   info.mode = mode;
+   info.start = start;
+   info.count = count;
+   info.min_index = start;
+   info.max_index = start + count - 1;
+
+   cso_draw_vbo(cso, &info);
+}
 
 #ifdef __cplusplus
 }
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 01/21] cso: unreference saved vertex buffers when restoring

2012-04-11 Thread Marek Olšák
---
 src/gallium/auxiliary/cso_cache/cso_context.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 60a6e02..43b8343 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -863,10 +863,18 @@ void cso_save_vertex_buffers(struct cso_context *ctx)
 
 void cso_restore_vertex_buffers(struct cso_context *ctx)
 {
+   unsigned i;
+
util_copy_vertex_buffers(ctx->vertex_buffers,
 &ctx->nr_vertex_buffers,
 ctx->vertex_buffers_saved,
 ctx->nr_vertex_buffers_saved);
+
+   for (i = 0; i < ctx->nr_vertex_buffers_saved; i++) {
+  pipe_resource_reference(&ctx->vertex_buffers_saved[i].buffer, NULL);
+   }
+   ctx->nr_vertex_buffers_saved = 0;
+
ctx->pipe->set_vertex_buffers(ctx->pipe, ctx->nr_vertex_buffers,
  ctx->vertex_buffers);
 }
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 00/21] Gallium: making user vertex buffers optional and other goodness

2012-04-11 Thread Marek Olšák
Hi everyone,

This series adds these optional features to st/mesa:
- uploading user vertex buffers
- translating unsupported vertex formats into floats
- vertex data with unaligned buffer_offset, src_offset, or stride is 
transformed such that it's aligned

These vertex formats are automatically translated into float if the driver 
doesn't expose them through is_format_supported(PIPE_BIND_VERTEX_BUFFER):
- PIPE_FORMAT_*16_FLOAT
- PIPE_FORMAT_*64_FLOAT
- PIPE_FORMAT_*32_FIXED
- PIPE_FORMAT_*32_UNORM
- PIPE_FORMAT_*32_SNORM
- PIPE_FORMAT_*32_USCALED
- PIPE_FORMAT_*32_SSCALED

This series doesn't deal with uploads of:
- user index buffers
- user constant buffers

It's all done by moving the u_vbuf module out of the radeon drivers and into 
the Mesa state tracker. u_vbuf is installed into cso_context, where it 
overrides a few functions. The installation is done only when the driver 
doesn't support a certain feature (a vertex format or user buffers or has 
buffer alignment restrictions). That's pretty much it.

There are new CAPs for vertex buffer alignment and, of course, user vertex 
buffers. I had to add "uint8_t *user_ptr" into pipe_resource, so that I could 
access the user buffer pointer in the state tracker.

A couple of problems may arise with this:

1) r300g and r600g rely on what u_vbuf does, so other state trackers should 
either use u_vbuf too or be very careful about how they setup vertex buffers 
and vertex elements. Not every combination of states works and u_vbuf is good 
at not letting through what doesn't.

2) Drivers should properly handle PIPE_BIND_VERTEX_BUFFER in 
is_format_supported.

3) u_vbuf always and unconditionally uploads user vertex buffers if it's 
active. For example, if you only don't support PIPE_FORMAT_R64G64B64A64_FLOAT 
as a vertex format, but otherwise support user vertex buffers, then u_vbuf gets 
installed into cso_context and takes control. Drivers using the Draw module 
should expose all vertex formats, the user-vertex-buffer CAP, and not expose 
the buffer-alignment-restriction CAPs in order to avoid u_vbuf kicking in.

4) Drivers should not crash when receiving NULL vertex buffers via 
set_vertex_buffers. Such buffer are always unused by the vertex element state. 
The thing is one of the codepaths in u_vbuf is using the translate module, 
which usually takes a new vertex buffer slot. If you receive this in 
set_vertex_buffers: count=4, buffers={NULL, NULL, NULL, buffer}, it means the 
last buffer probably comes from translate and the other 3 were originally user 
buffers, which u_vbuf never lets through, so they end up being NULL.

(2) must be fixed in some drivers, (3) can be fixed in u_vbuf if needed. I 
prefer (4) to be fixed in drivers.

There is also a lot of refactoring code in r300g and r600g, but nothing 
significant.

Please review & comment.

Marek Olšák (21):
  cso: unreference saved vertex buffers when restoring
  cso: add set_index_buffer and draw_vbo passthrough functions
  gallium/util: use cso_draw_arrays in util_draw_vertex_buffer
  st/mesa: use cso_set_index_buffer and cso_draw_vbo
  u_vbuf: override set_index_buffer
  u_vbuf: override set_vertex_buffers
  u_vbuf: override create/bind/destroy_vertex_elements_state
  u_vbuf: override draw_vbo
  gallium: add user_ptr in pipe_resource
  u_vbuf: use user_ptr from pipe_resource
  u_vbuf: remove u_vbuf_resource
  gallium: add CAPs for vertex fetcher
  gallium drivers: report that user vertex buffers are supported
  u_vbuf: make use of the new CAPs to determine what to do
  u_vbuf: pull u_vbuf_draw_max_vertex_count into r300g
  r300g: don't share u_upload_mgr with u_vbuf, create its own
  r600g: don't share u_upload_mgr with u_vbuf, create its own
  i915g: report that all vertex formats are supported
  gallium: make user vertex buffers optional
  st/mesa: always expose ARB_half_float_vertex
  st/mesa: always expose ARB_ES2_compatibility

 src/gallium/auxiliary/cso_cache/cso_context.c|   84 
 src/gallium/auxiliary/cso_cache/cso_context.h|   28 ++
 src/gallium/auxiliary/util/u_draw_quad.c |9 +-
 src/gallium/auxiliary/util/u_vbuf.c  |  480 +++---
 src/gallium/auxiliary/util/u_vbuf.h  |   99 +
 src/gallium/drivers/i915/i915_resource_buffer.c  |1 +
 src/gallium/drivers/i915/i915_screen.c   |5 +-
 src/gallium/drivers/llvmpipe/lp_screen.c |2 +
 src/gallium/drivers/llvmpipe/lp_texture.c|1 +
 src/gallium/drivers/nouveau/nouveau_buffer.c |1 +
 src/gallium/drivers/nv50/nv50_screen.c   |2 +
 src/gallium/drivers/nvc0/nvc0_screen.c   |2 +
 src/gallium/drivers/nvfx/nvfx_buffer.c   |1 +
 src/gallium/drivers/nvfx/nvfx_screen.c   |2 +
 src/gallium/drivers/r300/r300_blit.c |9 +-
 src/gallium/drivers/r300/r300_context.c  |   18 +-
 src/gallium/drivers/r300/

[Mesa-dev] [Bug 48545] New: LLVMpipe glReadPixels Firefox hits the slow path (WebGL rendering)

2012-04-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=48545

 Bug #: 48545
   Summary: LLVMpipe glReadPixels Firefox hits the slow path
(WebGL rendering)
Classification: Unclassified
   Product: Mesa
   Version: 8.0
  Platform: x86 (IA32)
OS/Version: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: cosinusoid...@yahoo.co.uk


I've reported this bug to Mozilla
(https://bugzilla.mozilla.org/show_bug.cgi?id=743585), but I think Mesa may be
needlessly going through the glReadPixels slow path so I thought I'd best
report the bug here too.

I think what's happening is Firefox is creating a RGBA backing store of some
kind, and then attempting to read it back BGRA. This is then in turn causing
fast_read_rgba_pixels_memcpy (in /src/mesa/main/readpix.c) to fail and instead
fall back to the slow path. As Firefox will read back the whole frame buffer
each frame, this signifcantly damages performance.

I assume another fast path could be added which does the read back with a
swizzle? In the mozilla bug report I included a patch to mesa that does this
(which is a horrible hack). I'd be happy to try and turn that hack into a more
general solution. Is that worth doing? If so, what's the best line of attack?

-- 
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] glsl parser: Select typelist as early as possible.

2012-04-11 Thread Olivier Galibert
Type selection must be extended w.r.t version and extension lines as
soon as it is possible, and in any case before the lookahead is done
to check the nature of the next line.  Otherwise code such as:

  #version 400

  dmat2 function inverse(dmat2 m) { ... }

fails because "dmat2" has already been lexed as a NEW_IDENTIFIER
before _mesa_glsl_initialize_types is called.

Signed-off-by: Olivier Galibert 
---
 src/glsl/glsl_parser.yy |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

[Sorry, resent with the correct subject...]

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 64506b6..9a0af95 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -233,9 +233,6 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state 
*st, const char *msg)
 
 translation_unit: 
version_statement extension_statement_list
-   {
-  _mesa_glsl_initialize_types(state);
-   }
external_declaration_list
{
   delete state->symbols;
@@ -285,6 +282,7 @@ version_statement:
   state->version_string,
   state->supported_version_string);
   }
+  _mesa_glsl_initialize_types(state);
}
;
 
@@ -322,6 +320,7 @@ extension_statement:
   if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) {
  YYERROR;
   }
+  _mesa_glsl_initialize_types(state);
}
;
 
-- 
1.7.4

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


[Mesa-dev] [PATCH 1/2] glsl: Support GL_ARB_shading_language_include internally.

2012-04-11 Thread Olivier Galibert
No hookup with GL yet.  Planned to be used to simplify profiles.

Signed-off-by: Olivier Galibert 
---
 src/glsl/ast.h  |   12 ++-
 src/glsl/glcpp/glcpp-lex.l  |  135 --
 src/glsl/glcpp/glcpp-parse.y|   75 +-
 src/glsl/glcpp/glcpp.c  |   14 +++-
 src/glsl/glcpp/glcpp.h  |   56 ++-
 src/glsl/glcpp/pp.c |   92 -
 src/glsl/glsl_lexer.ll  |   32 ++-
 src/glsl/glsl_parser.yy |  203 ---
 src/glsl/glsl_parser_extras.cpp |   23 -
 src/glsl/glsl_parser_extras.h   |   16 +++-
 src/glsl/main.cpp   |   24 -
 src/glsl/test_optpass.cpp   |2 +-
 src/mesa/program/ir_to_mesa.cpp |2 +-
 13 files changed, 542 insertions(+), 144 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 1f78af8..b0bfb28 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -65,6 +65,9 @@ public:
 * ralloc_free in that case. */
static void operator delete(void *table)
{
+  ast_node *an = static_cast(table);
+  if(an->location.source)
+ralloc_free(an->location.source);
   ralloc_free(table);
}
 
@@ -92,6 +95,7 @@ public:
   struct YYLTYPE locp;
 
   locp.source = this->location.source;
+  locp.source_id = this->location.source_id;
   locp.first_line = this->location.line;
   locp.first_column = this->location.column;
   locp.last_line = locp.first_line;
@@ -105,9 +109,10 @@ public:
 *
 * \sa ast_node::get_location
 */
-   void set_location(const struct YYLTYPE &locp)
+   void set_location(const struct YYLTYPE &locp, void *ctx)
{
-  this->location.source = locp.source;
+  this->location.source = locp.source ? ralloc_strdup(ctx, locp.source) : 
0;
+  this->location.source_id = locp.source_id;
   this->location.line = locp.first_line;
   this->location.column = locp.first_column;
}
@@ -116,7 +121,8 @@ public:
 * Source location of the AST node.
 */
struct {
-  unsigned source;/**< GLSL source number. */
+  unsigned source_id; /**< GLSL source number (if source is NULL)  */
+  char *source;   /**< GLSL source file or NULL */
   unsigned line;  /**< Line number within the source string. */
   unsigned column;/**< Column in the line. */
} location;
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index b34f2c0..2ce1547 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -44,6 +44,8 @@ void glcpp_set_column (int  column_no , yyscan_t yyscanner);
do { \
   yylloc->first_column = yycolumn + 1;  \
   yylloc->first_line = yylineno;\
+  yylloc->source = yyextra->source; \
+  yylloc->source_id = yyextra->source_id;   \
   yycolumn += yyleng;   \
} while(0);
 
@@ -51,17 +53,16 @@ void glcpp_set_column (int  column_no , yyscan_t yyscanner);
do {\
yylineno = 1;   \
yycolumn = 1;   \
-   yylloc->source = 0; \
} while(0)
 %}
 
-%option bison-bridge bison-locations reentrant noyywrap
+%option bison-bridge bison-locations reentrant
 %option extra-type="glcpp_parser_t *"
 %option prefix="glcpp_"
 %option stack
 %option never-interactive
 
-%x DONE COMMENT UNREACHABLE SKIP
+%x DONE COMMENT UNREACHABLE SKIP EXTENSION
 
 SPACE  [[:space:]]
 NONSPACE   [^[:space:]]
@@ -69,7 +70,8 @@ NEWLINE   [\n]
 HSPACE [ \t]
 HASH   ^{HSPACE}*#{HSPACE}*
 IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
-PUNCTUATION[][(){}.&*~!/%<>^|;,=+-]
+PUNCTUATION[][(){}.&*~!/%<>^|;,=+-:]
+STRING "\""[^"\n]+"\""
 
 /* The OTHER class is simply a catch-all for things that the CPP
 parser just doesn't care about. Since flex regular expressions that
@@ -78,7 +80,7 @@ strings, we have to be careful to avoid OTHER matching and 
hiding
 something that CPP does care about. So we simply exclude all
 characters that appear in any other expressions. */
 
-OTHER  [^][_#[:space:]#a-zA-Z0-9(){}.&*~!/%<>^|;,=+-]
+OTHER  [^][_#[:space:]#a-zA-Z0-9(){}.&*~!/%<>^|;,=+-:]
 
 DIGITS [0-9][0-9]*
 DECIMAL_INTEGER[1-9][0-9]*[uU]?
@@ -120,15 +122,45 @@ HEXADECIMAL_INTEGER   0[xX][0-9a-fA-F]+[uU]?
return HASH_VERSION;
 }
 
-   /* glcpp doesn't handle #extension, #version, or #pragma directives.
+{HASH}extension{HSPACE}+ {
+   return HASH_EXTENSION;
+}
+
+   /* glcpp doesn't handle #pragma directives.
 * Simply pass them through to the main compiler's lexer/parser. */
-{HASH}(extension|pragma)[^\n]+ {
+{HASH}pragma[^\n]+ {
yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;

[Mesa-dev] toto

2012-04-11 Thread Olivier Galibert
Type selection must be extended w.r.t version and extension lines as
soon as it is possible, and in any case before the lookahead is done
to check the nature of the next line.  Otherwise code such as:

  #version 400

  dmat2 function inverse(dmat2 m) { ... }

fails because "dmat2" has already been lexed as a NEW_IDENTIFIER
before _mesa_glsl_initialize_types is called.

Signed-off-by: Olivier Galibert 
---
 src/glsl/glsl_parser.yy |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 64506b6..9a0af95 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -233,9 +233,6 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state 
*st, const char *msg)
 
 translation_unit: 
version_statement extension_statement_list
-   {
-  _mesa_glsl_initialize_types(state);
-   }
external_declaration_list
{
   delete state->symbols;
@@ -285,6 +282,7 @@ version_statement:
   state->version_string,
   state->supported_version_string);
   }
+  _mesa_glsl_initialize_types(state);
}
;
 
@@ -322,6 +320,7 @@ extension_statement:
   if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) {
  YYERROR;
   }
+  _mesa_glsl_initialize_types(state);
}
;
 
-- 
1.7.4

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