Re: [Mesa-dev] [PATCH 1/6] glsl: Create an ir_builder helper for hand-generating IR.

2012-04-10 Thread Kenneth Graunke

On 04/09/2012 02:22 PM, Eric Anholt wrote:

The C++ constructors with placement new, while functional, are
extremely verbose, leading to generation of simple GLSL IR expressions
like (a * b + c * d) expanding to many lines of code and using lots of
temporary variables.  By creating a new ir_builder.h that puts simple
generators in our namespace and taking advantage of ralloc_parent(),
we can generate much more compact code, at a minor runtime cost.
---
  src/glsl/Makefile.sources|1 +
  src/glsl/ir_builder.cpp  |   69 ++
  src/glsl/ir_builder.h|   35 ++
  src/mesa/main/ff_fragment_shader.cpp |  128 --
  4 files changed, 151 insertions(+), 82 deletions(-)
  create mode 100644 src/glsl/ir_builder.cpp
  create mode 100644 src/glsl/ir_builder.h

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 06728da..4e3b074 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -26,6 +26,7 @@ LIBGLSL_CXX_FILES := \
glsl_symbol_table.cpp \
hir_field_selection.cpp \
ir_basic_block.cpp \
+   ir_builder.cpp \
ir_clone.cpp \
ir_constant_expression.cpp \
ir.cpp \
diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
new file mode 100644
index 000..c699e24
--- /dev/null
+++ b/src/glsl/ir_builder.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#include ir_builder.h
+
+using namespace ir_builder;
+
+namespace ir_builder {
+
+ir_expression *
+expr(ir_expression_operation op,
+ ir_rvalue *a, ir_rvalue *b)
+{
+   void *mem_ctx = ralloc_parent(a);
+
+   return new(mem_ctx) ir_expression(op, a-as_rvalue(), b-as_rvalue());


:) You just want ir_expression(op, a, b) here.

Harmless, though, since you delete this code in the next patch anyway.

With or without that change,
Reviewed-by: Kenneth Graunke kenn...@whitecape.org


+}
+
+ir_expression *add(ir_rvalue *a, ir_rvalue *b)
+{
+   return expr(ir_binop_add, a, b);
+}
+
+ir_expression *sub(ir_rvalue *a, ir_rvalue *b)
+{
+   return expr(ir_binop_sub, a, b);
+}
+
+ir_expression *mul(ir_rvalue *a, ir_rvalue *b)
+{
+   return expr(ir_binop_mul, a, b);
+}
+
+ir_expression *dot(ir_rvalue *a, ir_rvalue *b)
+{
+   return expr(ir_binop_dot, a, b);
+}
+
+ir_expression *
+saturate(ir_rvalue *a)
+{
+   void *mem_ctx = ralloc_parent(a);
+
+   return expr(ir_binop_max,
+  expr(ir_binop_min, a, new(mem_ctx) ir_constant(1.0f)),
+  new(mem_ctx) ir_constant(0.0f));
+}
+
+} /* namespace ir_builder */
diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
new file mode 100644
index 000..5d6f476
--- /dev/null
+++ b/src/glsl/ir_builder.h
@@ -0,0 +1,35 @@
+/*
+ * 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 

Re: [Mesa-dev] [PATCH 4/6] glsl: Make a little tracking class for emitting IR lists.

2012-04-10 Thread Kenneth Graunke

On 04/09/2012 02:22 PM, Eric Anholt wrote:

This lets us significantly shorten p-instructions-push_tail(ir), and
will be used in a few more places.
---
  src/glsl/ir_builder.cpp  |6 +++
  src/glsl/ir_builder.h|8 
  src/mesa/main/ff_fragment_shader.cpp |   78 --
  3 files changed, 42 insertions(+), 50 deletions(-)

diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index 29cc9bc..98ac3c1 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -28,6 +28,12 @@ using namespace ir_builder;

  namespace ir_builder {

+void
+ir_factory::emit(ir_instruction *ir)
+{
+   instructions-push_tail(ir);
+}
+
  ir_swizzle *
  swizzle(operand a, int swizzle, int components)
  {
diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
index d2c729a..350f9a3 100644
--- a/src/glsl/ir_builder.h
+++ b/src/glsl/ir_builder.h
@@ -50,6 +50,14 @@ public:
 ir_rvalue *val;
  };

+class ir_factory {
+public:
+   void emit(ir_instruction *ir);
+
+   exec_list *instructions;
+   void *mem_ctx;
+};
+
  ir_expression *expr(ir_expression_operation op, operand a, operand b);
  ir_expression *add(operand a, operand b);
  ir_expression *sub(operand a, operand b);
diff --git a/src/mesa/main/ff_fragment_shader.cpp 
b/src/mesa/main/ff_fragment_shader.cpp
index bc77ebd..555df42 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -511,12 +511,11 @@ static GLuint make_state_key( struct gl_context *ctx,  
struct state_key *key )

  /** State used to build the fragment program:
   */
-struct texenv_fragment_program {
+class texenv_fragment_program : public ir_factory {
+public:
 struct gl_shader_program *shader_program;
 struct gl_shader *shader;
-   exec_list *instructions;
 exec_list *top_instructions;
-   void *mem_ctx;
 struct state_key *state;

 ir_variable *src_texture[MAX_TEXTURE_COORD_UNITS];
@@ -827,10 +826,9 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
 ir_variable *temp_var = new(p-mem_ctx) ir_variable(glsl_type::vec4_type,
   texenv_combine,
   ir_var_temporary);
-   p-instructions-push_tail(temp_var);
+   p-emit(temp_var);

 ir_dereference *deref;
-   ir_assignment *assign;
 ir_rvalue *val;

 /* Emit the RGB and A combine ops
@@ -846,8 +844,7 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
 val = saturate(val);

deref = new(p-mem_ctx) ir_dereference_variable(temp_var);
-  assign = new(p-mem_ctx) ir_assignment(deref, val);
-  p-instructions-push_tail(assign);
+  p-emit(new(p-mem_ctx) ir_assignment(deref, val));
 }
 else if (key-unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT ||
key-unit[unit].ModeRGB == MODE_DOT3_RGBA) {
@@ -859,8 +856,7 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
if (rgb_saturate)
 val = saturate(val);
deref = new(p-mem_ctx) ir_dereference_variable(temp_var);
-  assign = new(p-mem_ctx) ir_assignment(deref, val);
-  p-instructions-push_tail(assign);
+  p-emit(new(p-mem_ctx) ir_assignment(deref, val));
 }
 else {
/* Need to do something to stop from re-emitting identical
@@ -874,8 +870,7 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
if (rgb_saturate)
 val = saturate(val);
deref = new(p-mem_ctx) ir_dereference_variable(temp_var);
-  assign = new(p-mem_ctx) ir_assignment(deref, val, NULL, WRITEMASK_XYZ);
-  p-instructions-push_tail(assign);
+  p-emit(new(p-mem_ctx) ir_assignment(deref, val, NULL, WRITEMASK_XYZ));

val = emit_combine(p, unit,
 key-unit[unit].NumArgsA,
@@ -885,8 +880,7 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
if (alpha_saturate)
 val = saturate(val);
deref = new(p-mem_ctx) ir_dereference_variable(temp_var);
-  assign = new(p-mem_ctx) ir_assignment(deref, val, NULL, WRITEMASK_W);
-  p-instructions-push_tail(assign);
+  p-emit(new(p-mem_ctx) ir_assignment(deref, val, NULL, WRITEMASK_W));
 }

 deref = new(p-mem_ctx) ir_dereference_variable(temp_var);
@@ -923,7 +917,6 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
  static void load_texture( struct texenv_fragment_program *p, GLuint unit )
  {
 ir_dereference *deref;
-   ir_assignment *assign;

 if (p-src_texture[unit])
return;
@@ -948,12 +941,11 @@ static void load_texture( struct texenv_fragment_program 
*p, GLuint unit )
p-src_texture[unit] = new(p-mem_ctx) ir_variable(glsl_type::vec4_type,
 dummy_tex,
 ir_var_temporary);
-  p-instructions-push_tail(p-src_texture[unit]);
+  p-emit(p-src_texture[unit]);

deref = 

Re: [Mesa-dev] ir_builder take 2

2012-04-10 Thread Kenneth Graunke

On 04/09/2012 02:22 PM, Eric Anholt wrote:

Here's the udpated ir_builder changeset.  Now at +140 lines, I think
I'll still land it given that idr has said he's interested in it for
the ARB programs to GLSL conversion work.  It now uses C++ tricks
(noted in a big comment) to get compile-time type checking and
ir_dereference_variable generation.  Oh, and it actually passes
piglit.


Eric,

This series is fantastic!  The code is so much more readable.  You can 
actually just read through it and understand what's going on now, 
without getting lost in derefs, deref copies, and bizarre 2, 2, 2, 3, 3 
swizzle representations.


This has my wholehearted approval.  For the series:
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

As a follow-on clean-up, it'd be really sweet to see:

operand(float x)
{
   return new(...) ir_constant(x);
}

because then you could just do: mul(temp, 0.5).  So simple and clean! :)
Of course, that assumes you have a mem_ctx to put where I wrote ..., 
and...well...you don't.


It makes me wonder if we want to rework this to thread a memory context 
through somehow, rather than using ralloc_parent.  Classes, explicit 
argument, or #define hackery, I guess.  Who knows if it's worth it.


I'd love to play around with this more sometime, at any rate.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] r600g: store glsl_feature_level in the r600_screen

2012-04-10 Thread Michel Dänzer
On Mon, 2012-04-09 at 19:35 +0400, Vadim Girlin wrote: 
 Signed-off-by: Vadim Girlin vadimgir...@gmail.com

Both patches are

Reviewed-by: Michel Dänzer mic...@daenzer.net


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


Re: [Mesa-dev] [PATCH 5/8] st/mesa: pass the configuration options to st_init_extensions

2012-04-10 Thread Michel Dänzer
On Mon, 2012-04-09 at 19:32 +0400, Vadim Girlin wrote: 
 Signed-off-by: Vadim Girlin vadimgir...@gmail.com
 ---
  src/mesa/state_tracker/st_context.c|9 +
  src/mesa/state_tracker/st_context.h|3 ++-
  src/mesa/state_tracker/st_extensions.c |2 +-
  src/mesa/state_tracker/st_extensions.h |2 +-
  src/mesa/state_tracker/st_manager.c|2 +-
  5 files changed, 10 insertions(+), 8 deletions(-)
 
 diff --git a/src/mesa/state_tracker/st_context.c 
 b/src/mesa/state_tracker/st_context.c
 index a3fd4db..1e76501 100644
 --- a/src/mesa/state_tracker/st_context.c
 +++ b/src/mesa/state_tracker/st_context.c
 @@ -111,7 +111,7 @@ 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 driOptionCache * optionCache )

This adds DRI specific code to the mesa state tracker, which is also
used for non-DRI targets. I'm afraid there would have to be some kind of
abstraction for this.


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


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

2012-04-10 Thread Michel Dänzer
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?


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


[Mesa-dev] [PATCH] wayland-drm: remove wl_buffer.damage

2012-04-10 Thread Pekka Paalanen
This is a related fix for the Wayland change:

commit 83685c506e76212ae4e5cb722205d98d3b0603b9
Author: Kristian Høgsberg k...@bitplanet.net
Date:   Mon Mar 26 16:33:24 2012 -0400

Remove wl_buffer.damage and simplify shm implementation

Apparently, this should also fix a memory leak. When wl_buffer.damage
was removed from Wayland and Mesa was not fixed, wl_buffer.destroy ended
up in the (empty) damage function instead of calling
wl_resource_destroy().

Spotted during build as:
  CC wayland-drm-protocol.lo
wayland-drm.c:80:2: warning: initialization from incompatible pointer type
wayland-drm.c:82:1: warning: excess elements in struct initializer
wayland-drm.c:82:1: warning: (near initialization for 'drm_buffer_interface')

Signed-off-by: Pekka Paalanen ppaala...@gmail.com
---
 src/egl/wayland/wayland-drm/wayland-drm.c |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c 
b/src/egl/wayland/wayland-drm/wayland-drm.c
index 42e6788..101b2c4 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -54,12 +54,6 @@ struct wl_drm_buffer {
 };
 
 static void
-buffer_damage(struct wl_client *client, struct wl_resource *buffer,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
-}
-
-static void
 destroy_buffer(struct wl_resource *resource)
 {
struct wl_drm_buffer *buffer = resource-data;
@@ -77,7 +71,6 @@ buffer_destroy(struct wl_client *client, struct wl_resource 
*resource)
 }
 
 const static struct wl_buffer_interface drm_buffer_interface = {
-   buffer_damage,
buffer_destroy
 };
 
-- 
1.7.3.4

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


[Mesa-dev] [Bug 48424] Fix warnings/errors reported by clang's scan-build tool

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

Johannes Obermayr johannesoberm...@gmx.de changed:

   What|Removed |Added

   See Also||http://llvm.org/bugs/show_b
   ||ug.cgi?id=12520

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


[Mesa-dev] [Bug 48441] gnome-control-center crashes with nouveau driver

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

Ionut Biru biru.io...@gmail.com changed:

   What|Removed |Added

   Priority|medium  |high
 AssignedTo|nouveau@lists.freedesktop.o |mesa-dev@lists.freedesktop.
   |rg  |org
  Component|Drivers/DRI/nouveau |Mesa core

--- Comment #1 from Ionut Biru biru.io...@gmail.com 2012-04-10 09:06:59 PDT 
---
We have users that told us that is not related only to nouveau. Ati is involved
as well and the main developer of clutter said that it might be a bug in
llvmpipe or its usage.

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


[Mesa-dev] [Bug 48441] gnome-control-center crashes with nouveau driver

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

Ionut Biru biru.io...@gmail.com changed:

   What|Removed |Added

 CC||biru.io...@gmail.com

-- 
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 0/8] [RFC] improve driconf support for gallium

2012-04-10 Thread Kenneth Graunke

On 04/09/2012 08:32 AM, Vadim Girlin wrote:

These patches allow to use driver-specific driconf settings, and to handle these
options in the state tracker.

It's then used to handle force_glsl_extensions_warn option, so we could use it
e.g. for unigine applications.


I haven't looked at your series, but if people object to plumbing 
driconf into Gallium, another option might be to pull driconf out of DRI 
and into core Mesa.  As far as I can tell, it really doesn't have 
anything to do with DRI at all.

___
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-10 Thread Vadim Girlin
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. I don't know much about these
areas, so I'm not sure if it's a right way at all.

Vadim






___
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-10 Thread Vadim Girlin
On Tue, 2012-04-10 at 10:42 -0700, Kenneth Graunke wrote:
 On 04/09/2012 08:32 AM, Vadim Girlin wrote:
  These patches allow to use driver-specific driconf settings, and to handle 
  these
  options in the state tracker.
 
  It's then used to handle force_glsl_extensions_warn option, so we could use 
  it
  e.g. for unigine applications.
 
 I haven't looked at your series, but if people object to plumbing 
 driconf into Gallium, another option might be to pull driconf out of DRI 
 and into core Mesa.  As far as I can tell, it really doesn't have 
 anything to do with DRI at all.

Yes, I thought about that too. Though I guess it might require some time
for me to do it correctly, but probably I could try if there are no
objections.

Vadim



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


Re: [Mesa-dev] [PATCH 5/8] st/mesa: pass the configuration options to st_init_extensions

2012-04-10 Thread Vadim Girlin
On Tue, 2012-04-10 at 09:53 +0200, Michel Dänzer wrote:
 On Mon, 2012-04-09 at 19:32 +0400, Vadim Girlin wrote: 
  Signed-off-by: Vadim Girlin vadimgir...@gmail.com
  ---
   src/mesa/state_tracker/st_context.c|9 +
   src/mesa/state_tracker/st_context.h|3 ++-
   src/mesa/state_tracker/st_extensions.c |2 +-
   src/mesa/state_tracker/st_extensions.h |2 +-
   src/mesa/state_tracker/st_manager.c|2 +-
   5 files changed, 10 insertions(+), 8 deletions(-)
  
  diff --git a/src/mesa/state_tracker/st_context.c 
  b/src/mesa/state_tracker/st_context.c
  index a3fd4db..1e76501 100644
  --- a/src/mesa/state_tracker/st_context.c
  +++ b/src/mesa/state_tracker/st_context.c
  @@ -111,7 +111,7 @@ 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 driOptionCache * optionCache )
 
 This adds DRI specific code to the mesa state tracker, which is also
 used for non-DRI targets. I'm afraid there would have to be some kind of
 abstraction for this.

Probably we could pass a single boolean value for now
(force_glsl_extensions_warn), maybe in some struct. Does it make sense?

I guess it's better to move the configuration to mesa completely, as
proposed by Kenneth Graunke, but it will require more time for me to do
it.

Vadim



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


Re: [Mesa-dev] [PATCH 2/7] glsl: add support for ARB_blend_func_extended (v2)

2012-04-10 Thread Dave Airlie
On Mon, Apr 9, 2012 at 9:13 PM, Eric Anholt e...@anholt.net wrote:
 On Tue,  3 Apr 2012 14:16:52 +0100, Dave Airlie airl...@gmail.com wrote:
 From: Dave Airlie airl...@redhat.com

 This adds index support to the GLSL compiler.

 I'm not 100% sure of my approach here, esp without how output ordering
 happens wrt location, index pairs, in the mark function.

 Since current hw doesn't ever have a location  0 with an index  0,
 we don't have to work out if the output ordering the hw requires is
 location, index, location, index or location, location, index, index.
 But we have no hw to know, so punt on it for now.

 v2: index requires layout - catch and error
     setup explicit index properly.

 I don't like this magic 4 that's unexplained.  It seems like the second
 fragment output should have a totally separate ir_variable-location
 assigned.  Whether that's in a separate space like FRAG_RESULT_DUALSRC_0
 that comes after all the FRAG_RESULT_DATAn, or whether it's just
 FRAG_RESULT_DATA1 since we're not anticipating dual source max buffers
 going beyond 1, 4 doesn't seem like the right number.

Yeah the reason I left it all configurable was I wasn't sure how
flexible we should leave the GLSL compiler.

But I personally don't see hw with index  1 and location  0 unless
index gets re-purposed for something else.

I'll resend a smaller patch that just puts index after location.

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


[Mesa-dev] [PATCH] glsl: add support for ARB_blend_func_extended (v3)

2012-04-10 Thread Dave Airlie
From: Dave Airlie airl...@redhat.com

This adds index support to the GLSL compiler.

I'm not 100% sure of my approach here, esp without how output ordering
happens wrt location, index pairs, in the mark function.

Since current hw doesn't ever have a location  0 with an index  0,
we don't have to work out if the output ordering the hw requires is
location, index, location, index or location, location, index, index.
But we have no hw to know, so punt on it for now.

v2: index requires layout - catch and error
setup explicit index properly.

v3: drop idx_offset stuff, assume index follow location

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/glsl/ast.h |   12 
 src/glsl/ast_to_hir.cpp|9 -
 src/glsl/builtin_variables.cpp |1 +
 src/glsl/glsl_parser.yy|   20 
 src/glsl/ir.h  |1 +
 src/glsl/ir_clone.cpp  |4 
 src/glsl/ir_set_program_inouts.cpp |4 ++--
 src/glsl/linker.cpp|   13 +
 8 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 1f78af8..9a7b2a2 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -363,6 +363,11 @@ struct ast_type_qualifier {
  * qualifier is used.
  */
 unsigned explicit_location:1;
+/**
+ * Flag set if GL_ARB_explicit_attrib_location index layout
+ * qualifier is used.
+ */
+unsigned explicit_index:1;
 
  /** \name Layout qualifiers for GL_AMD_conservative_depth */
  /** \{ */
@@ -386,6 +391,13 @@ struct ast_type_qualifier {
 * This field is only valid if \c explicit_location is set.
 */
int location;
+   /**
+* Index specified via GL_ARB_explicit_attrib_location layout
+*
+* \note
+* This field is only valid if \c explicit_index is set.
+*/
+   int index;
 
/**
 * Return true if and only if an interpolation qualifier is present.
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 6210eb1..2841469 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2092,14 +2092,21 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
 } else {
var-location = qual-location;
 }
+if (qual-flags.q.explicit_index) {
+   var-explicit_index = true;
+   var-index = qual-index;
+}
   }
+   } else if (qual-flags.q.explicit_index) {
+_mesa_glsl_error(loc, state,
+ explicit index requires explicit location\n);
}
 
/* Does the declaration use the 'layout' keyword?
 */
const bool uses_layout = qual-flags.q.pixel_center_integer
   || qual-flags.q.origin_upper_left
-  || qual-flags.q.explicit_location;
+  || qual-flags.q.explicit_location; /* no need for index since it relies 
on location */
 
/* Does the declaration use the deprecated 'attribute' or 'varying'
 * keywords?
diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 516a69c..03b64c9 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -408,6 +408,7 @@ add_variable(exec_list *instructions, glsl_symbol_table 
*symtab,
 
var-location = slot;
var-explicit_location = (slot = 0);
+   var-explicit_index = 0;
 
/* Once the variable is created an initialized, add it to the symbol table
 * and add the declaration to the IR stream.
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 64506b6..e45089a 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1103,8 +1103,14 @@ layout_qualifier_id_list:
   if ($1.flags.q.explicit_location)
  $$.location = $1.location;
 
+  if ($1.flags.q.explicit_index)
+ $$.index = $1.index;
+
   if ($3.flags.q.explicit_location)
  $$.location = $3.location;
+
+  if ($3.flags.q.explicit_index)
+ $$.index = $3.index;
}
;
 
@@ -1191,6 +1197,20 @@ layout_qualifier_id:
YYERROR;
 }
  }
+
+ if (strcmp(index, $1) == 0) {
+got_one = true;
+
+$$.flags.q.explicit_index = 1;
+
+if ($3 = 0) {
+   $$.index = $3;
+} else {
+   _mesa_glsl_error( @3, state,
+invalid index %d specified\n, $3);
+YYERROR;
+ }
+  }
   }
 
   /* If the identifier didn't match any known layout identifiers,
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 9450e8f..d6c6a60 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -386,6 +386,7 @@ public:
 * no effect).
 */
unsigned explicit_location:1;
+   unsigned explicit_index:1;
 
/**
 * Does this variable have an initializer?
diff 

[Mesa-dev] [PATCH] Revert shared-glapi: Convert to automake

2012-04-10 Thread Chad Versace
This reverts commit ca760181b4420696c7e86aa2951d7203522ad1e8.

That commit broke the Android build.  The guilty change in that commit was
twofold. It first changed the pattern of some variable definitions, then
made a illegal change in Android.mk

src/mapi/mapi/sources.mak
- FOO_FILE := bar.c
+ FOO_FILE := $(TOP)/src/mapi/mapi/bar.c
src/mapi/Android.mk
-LOCAL_SRC_FILES := $(MAPI_GLAPI_FILES)
+LOCAL_SRC_FILES := $(addprefix mapi/, $(MAPI_GLAPI_SOURCES))

Source filepaths in Android makefiles must be relative to the makefile.

CC: Kristian Høgsberg k...@bitplanet.net
Signed-off-by: Chad Versace chad.vers...@linux.intel.com
---
 configure.ac  |2 -
 src/egl/main/Makefile.am  |1 +
 src/gbm/Makefile.am   |4 +-
 src/glx/Makefile.am   |2 +-
 src/mapi/Android.mk   |4 +-
 src/mapi/es1api/Makefile  |4 +-
 src/mapi/glapi/Makefile   |8 ++--
 src/mapi/mapi/sources.mak |   42 
 src/mapi/shared-glapi/Makefile|   65 +
 src/mapi/shared-glapi/Makefile.am |   27 ---
 src/mapi/vgapi/Makefile   |4 +-
 11 files changed, 100 insertions(+), 63 deletions(-)
 create mode 100644 src/mapi/shared-glapi/Makefile
 delete mode 100644 src/mapi/shared-glapi/Makefile.am

diff --git a/configure.ac b/configure.ac
index 21e4308..49b067d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -702,7 +702,6 @@ if test x$enable_shared_glapi = xyes; then
 # libGL will use libglapi for function lookups (IN_DRI_DRIVER means to use
 # the remap table)
 DEFINES=$DEFINES -DIN_DRI_DRIVER
-SRC_DIRS=$SRC_DIRS mapi/shared-glapi
 fi
 AC_SUBST([SHARED_GLAPI])
 AM_CONDITIONAL(HAVE_SHARED_GLAPI, test $SHARED_GLAPI = 1)
@@ -1998,7 +1997,6 @@ AC_CONFIG_FILES([configs/autoconf
src/egl/wayland/wayland-egl/wayland-egl.pc
src/egl/wayland/wayland-drm/Makefile
src/glx/Makefile
-   src/mapi/shared-glapi/Makefile
src/mesa/drivers/dri/dri.pc
src/mesa/drivers/dri/Makefile
src/mesa/drivers/dri/common/Makefile
diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am
index 9c3935b..a8072c1 100644
--- a/src/egl/main/Makefile.am
+++ b/src/egl/main/Makefile.am
@@ -93,6 +93,7 @@ endif
 if HAVE_EGL_PLATFORM_DRM
 AM_CFLAGS += -DHAVE_DRM_PLATFORM
 libEGL_la_LIBADD += ../../gbm/libgbm.la
+libEGL_la_LIBADD += ../../gbm/libgbm.la
 endif
 
 if HAVE_EGL_PLATFORM_FBDEV
diff --git a/src/gbm/Makefile.am b/src/gbm/Makefile.am
index dede5bc..1dbc9d1 100644
--- a/src/gbm/Makefile.am
+++ b/src/gbm/Makefile.am
@@ -31,8 +31,8 @@ libgbm_dri_la_CFLAGS = \
-DDEFAULT_DRIVER_DIR='$(DRI_DRIVER_SEARCH_DIR)' \
$(LIBDRM_CFLAGS)
 
-libgbm_la_LIBADD += \
-   libgbm_dri.la $(top_builddir)/src/mapi/shared-glapi/libglapi.la
+libgbm_la_LDFLAGS += -L$(top_builddir)/$(LIB_DIR)
+libgbm_la_LIBADD += libgbm_dri.la -lglapi
 endif
 
 all-local: libgbm.la
diff --git a/src/glx/Makefile.am b/src/glx/Makefile.am
index ec62faa..062ed9e 100644
--- a/src/glx/Makefile.am
+++ b/src/glx/Makefile.am
@@ -21,7 +21,7 @@
 
 if HAVE_SHARED_GLAPI
 SHARED_GLAPI_CFLAGS = -DGLX_SHARED_GLAPI
-SHARED_GLAPI_LIBS = $(top_builddir)/src/mapi/shared-glapi/libglapi.la
+SHARED_GLAPI_LIBS = -L$(top_builddir)/$(LIB_DIR) -lglapi
 endif
 
 GLAPI_LIB = ../mapi/glapi/libglapi.a
diff --git a/src/mapi/Android.mk b/src/mapi/Android.mk
index b75361f..fe9e40e 100644
--- a/src/mapi/Android.mk
+++ b/src/mapi/Android.mk
@@ -25,7 +25,7 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# get MAPI_GLAPI_FILES
+# get MAPI_GLAPI_SOURCES
 include $(LOCAL_PATH)/mapi/sources.mak
 
 mapi_abi_headers :=
@@ -38,7 +38,7 @@ include $(CLEAR_VARS)
 
 abi_header := shared-glapi/glapi_mapi_tmp.h
 
-LOCAL_SRC_FILES := $(MAPI_GLAPI_FILES)
+LOCAL_SRC_FILES := $(addprefix mapi/, $(MAPI_GLAPI_SOURCES))
 
 LOCAL_CFLAGS := \
-DMAPI_MODE_GLAPI \
diff --git a/src/mapi/es1api/Makefile b/src/mapi/es1api/Makefile
index a9c9123..0a0449b 100644
--- a/src/mapi/es1api/Makefile
+++ b/src/mapi/es1api/Makefile
@@ -41,8 +41,8 @@ esapi_CPPFLAGS := \
-DMAPI_ABI_HEADER=\$(ESAPI)/glapi_mapi_tmp.h\
 
 include $(MAPI)/sources.mak
-esapi_SOURCES := $(MAPI_BRIDGE_FILES)
-esapi_OBJECTS := $(notdir $(MAPI_BRIDGE_FILES:.c=.o))
+esapi_SOURCES := $(addprefix $(MAPI)/, $(MAPI_BRIDGE_SOURCES))
+esapi_OBJECTS := $(MAPI_BRIDGE_SOURCES:.c=.o)
 esapi_CPPFLAGS += -DMAPI_MODE_BRIDGE
 
 esapi_LIB_DEPS := -L$(TOP)/$(LIB_DIR) -l$(GLAPI_LIB) $(esapi_LIB_DEPS)
diff --git a/src/mapi/glapi/Makefile b/src/mapi/glapi/Makefile
index 211f384..bb4ed65 100644
--- a/src/mapi/glapi/Makefile
+++ b/src/mapi/glapi/Makefile
@@ -19,18 +19,18 @@ ifeq ($(SHARED_GLAPI),1)
 glapi_CPPFLAGS += \
-DMAPI_MODE_BRIDGE \
-DMAPI_ABI_HEADER=\glapi/glapi_mapi_tmp.h\
-glapi_SOURCES := $(MAPI_BRIDGE_FILES)
+glapi_SOURCES := $(addprefix $(MAPI)/, $(MAPI_BRIDGE_SOURCES))
 
 

Re: [Mesa-dev] [PATCH] Revert shared-glapi: Convert to automake

2012-04-10 Thread Chad Versace
On 04/10/2012 01:13 PM, Chad Versace wrote:
 This reverts commit ca760181b4420696c7e86aa2951d7203522ad1e8.
 
 That commit broke the Android build.  The guilty change in that commit was
 twofold. It first changed the pattern of some variable definitions, then
 made a illegal change in Android.mk
 
 src/mapi/mapi/sources.mak
 - FOO_FILE := bar.c
 + FOO_FILE := $(TOP)/src/mapi/mapi/bar.c
 src/mapi/Android.mk
 -LOCAL_SRC_FILES := $(MAPI_GLAPI_FILES)
 +LOCAL_SRC_FILES := $(addprefix mapi/, $(MAPI_GLAPI_SOURCES))
 
 Source filepaths in Android makefiles must be relative to the makefile.
 
 CC: Kristian Høgsberg k...@bitplanet.net
 Signed-off-by: Chad Versace chad.vers...@linux.intel.com

Nak this patch too. Kristian and I discussed this on IRC, and
he convinced me it was a bad idea.


Chad Versace
chad.vers...@linux.intel.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] egl_dri2: fix aux buffer leak in drm platform

2012-04-10 Thread mandeep . baines
From: Mandeep Singh Baines m...@chromium.org

Keep a reference to any newly allocated aux buffers to avoid
re-allocating for every st_framebuffer_validate() (i.e. leaking).

Signed-off-by: Mandeep Singh Baines m...@chromium.org
Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com
Cc: Benjamin Franzke benjaminfran...@googlemail.com
Cc: Kristian Hogsberg k...@bitplanet.net
Cc: David Reveman reve...@chromium.org
Cc: Stephane Marchesin marc...@chromium.org
---
 src/egl/drivers/dri2/platform_drm.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 18ecd17..54067ff 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf,
 {
struct dri2_egl_display *dri2_dpy =
   dri2_egl_display(dri2_surf-base.Resource.Display);
-   __DRIbuffer *b;
+   __DRIbuffer *b = dri2_surf-dri_buffers[attachment];
 
-   b = NULL;
-   if (dri2_surf-dri_buffers[attachment])
-  b = dri2_surf-dri_buffers[attachment];
-   if (b == NULL)
+   if (b == NULL) {
   b = dri2_dpy-dri2-allocateBuffer(dri2_dpy-dri_screen,
 attachment, format,
 dri2_surf-base.Width,
 dri2_surf-base.Height);
+  dri2_surf-dri_buffers[attachment] = b;
+   }
if (b == NULL)
   return -1;
 
-- 
1.7.3.4

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


Re: [Mesa-dev] [PATCH] egl_dri2: fix aux buffer leak in drm platform

2012-04-10 Thread Kristian Høgsberg
On Tue, Apr 10, 2012 at 6:30 PM, Mandeep Baines
mandeep.bai...@gmail.com wrote:
 Attached is the test case I've been using.

Nice, I've been meaning to update eglkms.c to also demonstrate
pageflipping.  Do you mind if I commit your version?

Kristian

 On Tue, Apr 10, 2012 at 3:26 PM,  mandeep.bai...@gmail.com wrote:
 From: Mandeep Singh Baines m...@chromium.org

 Keep a reference to any newly allocated aux buffers to avoid
 re-allocating for every st_framebuffer_validate() (i.e. leaking).

 Signed-off-by: Mandeep Singh Baines m...@chromium.org
 Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com
 Cc: Benjamin Franzke benjaminfran...@googlemail.com
 Cc: Kristian Hogsberg k...@bitplanet.net
 Cc: David Reveman reve...@chromium.org
 Cc: Stephane Marchesin marc...@chromium.org
 ---
  src/egl/drivers/dri2/platform_drm.c |    9 -
  1 files changed, 4 insertions(+), 5 deletions(-)

 diff --git a/src/egl/drivers/dri2/platform_drm.c 
 b/src/egl/drivers/dri2/platform_drm.c
 index 18ecd17..54067ff 100644
 --- a/src/egl/drivers/dri2/platform_drm.c
 +++ b/src/egl/drivers/dri2/platform_drm.c
 @@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf,
  {
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf-base.Resource.Display);
 -   __DRIbuffer *b;
 +   __DRIbuffer *b = dri2_surf-dri_buffers[attachment];

 -   b = NULL;
 -   if (dri2_surf-dri_buffers[attachment])
 -      b = dri2_surf-dri_buffers[attachment];
 -   if (b == NULL)
 +   if (b == NULL) {
       b = dri2_dpy-dri2-allocateBuffer(dri2_dpy-dri_screen,
                                         attachment, format,
                                         dri2_surf-base.Width,
                                         dri2_surf-base.Height);
 +      dri2_surf-dri_buffers[attachment] = b;
 +   }
    if (b == NULL)
       return -1;

 --
 1.7.3.4

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


Re: [Mesa-dev] [PATCH] egl_dri2: fix aux buffer leak in drm platform

2012-04-10 Thread Mandeep Singh Baines
On Tue, Apr 10, 2012 at 4:02 PM, Kristian Høgsberg k...@bitplanet.net wrote:
 On Tue, Apr 10, 2012 at 6:30 PM, Mandeep Baines
 mandeep.bai...@gmail.com wrote:
 Attached is the test case I've been using.

 Nice, I've been meaning to update eglkms.c to also demonstrate
 pageflipping.  Do you mind if I commit your version?


Sure.

Signed-off-by: Mandeep Singh Bainesm...@chromium.org

 Kristian

 On Tue, Apr 10, 2012 at 3:26 PM,  mandeep.bai...@gmail.com wrote:
 From: Mandeep Singh Baines m...@chromium.org

 Keep a reference to any newly allocated aux buffers to avoid
 re-allocating for every st_framebuffer_validate() (i.e. leaking).

 Signed-off-by: Mandeep Singh Baines m...@chromium.org
 Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com
 Cc: Benjamin Franzke benjaminfran...@googlemail.com
 Cc: Kristian Hogsberg k...@bitplanet.net
 Cc: David Reveman reve...@chromium.org
 Cc: Stephane Marchesin marc...@chromium.org
 ---
  src/egl/drivers/dri2/platform_drm.c |    9 -
  1 files changed, 4 insertions(+), 5 deletions(-)

 diff --git a/src/egl/drivers/dri2/platform_drm.c 
 b/src/egl/drivers/dri2/platform_drm.c
 index 18ecd17..54067ff 100644
 --- a/src/egl/drivers/dri2/platform_drm.c
 +++ b/src/egl/drivers/dri2/platform_drm.c
 @@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf,
  {
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf-base.Resource.Display);
 -   __DRIbuffer *b;
 +   __DRIbuffer *b = dri2_surf-dri_buffers[attachment];

 -   b = NULL;
 -   if (dri2_surf-dri_buffers[attachment])
 -      b = dri2_surf-dri_buffers[attachment];
 -   if (b == NULL)
 +   if (b == NULL) {
       b = dri2_dpy-dri2-allocateBuffer(dri2_dpy-dri_screen,
                                         attachment, format,
                                         dri2_surf-base.Width,
                                         dri2_surf-base.Height);
 +      dri2_surf-dri_buffers[attachment] = b;
 +   }
    if (b == NULL)
       return -1;

 --
 1.7.3.4

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


Re: [Mesa-dev] [PATCH] egl_dri2: fix aux buffer leak in drm platform

2012-04-10 Thread Kristian Høgsberg
On Tue, Apr 10, 2012 at 5:48 PM, Mandeep Singh Baines
mandeep.bai...@gmail.com wrote:
 Keep a reference to any newly allocated aux buffers to avoid
 re-allocating for every st_framebuffer_validate() (i.e. leaking).

Oops, yes, that's obviously how it was meant to work.  I never used a
depth buffer in any of the test cases I used, so I didn't trigger this
embarrassing leak.  And just for the record, while Ander wrote the
original patch, I introduced this bug when I refactored part of it.
Anyway, committed and pushed.

thanks,
Kristian

 Signed-off-by: Mandeep Singh Baines m...@chromium.org
 Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com
 Cc: Benjamin Franzke benjaminfran...@googlemail.com
 Cc: Kristian Hogsberg k...@bitplanet.net
 Cc: David Reveman reve...@chromium.org
 Cc: Stephane Marchesin marc...@chromium.org
 ---
  src/egl/drivers/dri2/platform_drm.c |    9 -
  1 files changed, 4 insertions(+), 5 deletions(-)

 diff --git a/src/egl/drivers/dri2/platform_drm.c 
 b/src/egl/drivers/dri2/platform_drm.c
 index 18ecd17..54067ff 100644
 --- a/src/egl/drivers/dri2/platform_drm.c
 +++ b/src/egl/drivers/dri2/platform_drm.c
 @@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf,
  {
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf-base.Resource.Display);
 -   __DRIbuffer *b;
 +   __DRIbuffer *b = dri2_surf-dri_buffers[attachment];

 -   b = NULL;
 -   if (dri2_surf-dri_buffers[attachment])
 -      b = dri2_surf-dri_buffers[attachment];
 -   if (b == NULL)
 +   if (b == NULL) {
       b = dri2_dpy-dri2-allocateBuffer(dri2_dpy-dri_screen,
                                         attachment, format,
                                         dri2_surf-base.Width,
                                         dri2_surf-base.Height);
 +      dri2_surf-dri_buffers[attachment] = b;
 +   }
    if (b == NULL)
       return -1;

 --
 1.7.3.4

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


Re: [Mesa-dev] [PATCH] egl_dri2: fix aux buffer leak in drm platform

2012-04-10 Thread Mandeep Singh Baines
On Tue, Apr 10, 2012 at 4:02 PM, Kristian Høgsberg k...@bitplanet.net wrote:
 On Tue, Apr 10, 2012 at 6:30 PM, Mandeep Baines
 mandeep.bai...@gmail.com wrote:
 Attached is the test case I've been using.

 Nice, I've been meaning to update eglkms.c to also demonstrate
 pageflipping.  Do you mind if I commit your version?


Attached is a cleaned up version with proper error handling.

 Kristian

 On Tue, Apr 10, 2012 at 3:26 PM,  mandeep.bai...@gmail.com wrote:
 From: Mandeep Singh Baines m...@chromium.org

 Keep a reference to any newly allocated aux buffers to avoid
 re-allocating for every st_framebuffer_validate() (i.e. leaking).

 Signed-off-by: Mandeep Singh Baines m...@chromium.org
 Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com
 Cc: Benjamin Franzke benjaminfran...@googlemail.com
 Cc: Kristian Hogsberg k...@bitplanet.net
 Cc: David Reveman reve...@chromium.org
 Cc: Stephane Marchesin marc...@chromium.org
 ---
  src/egl/drivers/dri2/platform_drm.c |    9 -
  1 files changed, 4 insertions(+), 5 deletions(-)

 diff --git a/src/egl/drivers/dri2/platform_drm.c 
 b/src/egl/drivers/dri2/platform_drm.c
 index 18ecd17..54067ff 100644
 --- a/src/egl/drivers/dri2/platform_drm.c
 +++ b/src/egl/drivers/dri2/platform_drm.c
 @@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf,
  {
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf-base.Resource.Display);
 -   __DRIbuffer *b;
 +   __DRIbuffer *b = dri2_surf-dri_buffers[attachment];

 -   b = NULL;
 -   if (dri2_surf-dri_buffers[attachment])
 -      b = dri2_surf-dri_buffers[attachment];
 -   if (b == NULL)
 +   if (b == NULL) {
       b = dri2_dpy-dri2-allocateBuffer(dri2_dpy-dri_screen,
                                         attachment, format,
                                         dri2_surf-base.Width,
                                         dri2_surf-base.Height);
 +      dri2_surf-dri_buffers[attachment] = b;
 +   }
    if (b == NULL)
       return -1;

 --
 1.7.3.4

/*
 * Copyright © 2011 Kristian Høgsberg
 * Copyright © 2011 Benjamin Franzke
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of the copyright holders not be used in advertising or
 * publicity pertaining to distribution of the software without specific,
 * written prior permission.  The copyright holders make no representations
 * about the suitability of this software for any purpose.  It is provided as
 * is without express or implied warranty.
 *
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THIS SOFTWARE.
 */

#include stdio.h
#include stdlib.h

#define EGL_EGLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES

#include gbm.h
#include GL/gl.h
#include EGL/egl.h
#include EGL/eglext.h
#include drm.h
#include xf86drm.h
#include xf86drmMode.h
#include fcntl.h
#include signal.h
#include unistd.h
#include string.h
#include time.h

#ifdef GL_OES_EGL_image
static PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES_func;
#endif

struct kms {
   drmModeConnector *connector;
   drmModeEncoder *encoder;
   drmModeModeInfo mode;
};

GLfloat x = 1.0;
GLfloat y = 1.0;
GLfloat xstep = 1.0f;
GLfloat ystep = 1.0f;
GLfloat rsize = 50;

int quit = 0;

static EGLBoolean
setup_kms(int fd, struct kms *kms)
{
   drmModeRes *resources;
   drmModeConnector *connector;
   drmModeEncoder *encoder;
   int i;

   resources = drmModeGetResources(fd);
   if (!resources) {
  fprintf(stderr, drmModeGetResources failed\n);
  return EGL_FALSE;
   }

   for (i = 0; i  resources-count_connectors; i++) {
  connector = drmModeGetConnector(fd, resources-connectors[i]);
  if (connector == NULL)
	 continue;

  if (connector-connection == DRM_MODE_CONNECTED 
	  connector-count_modes  0)
	 break;

  drmModeFreeConnector(connector);
   }

   if (i == resources-count_connectors) {
  fprintf(stderr, No currently active connector found.\n);
  return EGL_FALSE;
   }

   for (i = 0; i  resources-count_encoders; i++) {
  encoder = drmModeGetEncoder(fd, resources-encoders[i]);

  if (encoder == NULL)
	 continue;

  if (encoder-encoder_id == connector-encoder_id)
	 break;

  drmModeFreeEncoder(encoder);
   }

   kms-connector = connector;
   kms-encoder = encoder;
   kms-mode = connector-modes[0];