Mesa (master): galahad: Make it obvious on stderr that Galahad's active.

2010-08-20 Thread Corbin Simpson
Module: Mesa
Branch: master
Commit: 11fde173c21039fdab18439641ffeb74bddaca9b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=11fde173c21039fdab18439641ffeb74bddaca9b

Author: Corbin Simpson mostawesomed...@gmail.com
Date:   Thu Aug 19 23:34:39 2010 -0700

galahad: Make it obvious on stderr that Galahad's active.

---

 src/gallium/drivers/galahad/glhd_context.c |2 ++
 src/gallium/drivers/galahad/glhd_screen.c  |2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/galahad/glhd_context.c 
b/src/gallium/drivers/galahad/glhd_context.c
index fe14a28..ddf3886 100644
--- a/src/gallium/drivers/galahad/glhd_context.c
+++ b/src/gallium/drivers/galahad/glhd_context.c
@@ -972,5 +972,7 @@ galahad_context_create(struct pipe_screen *_screen, struct 
pipe_context *pipe)
 
glhd_pipe-pipe = pipe;
 
+   glhd_warn(Created context %p, glhd_pipe);
+
return glhd_pipe-base;
 }
diff --git a/src/gallium/drivers/galahad/glhd_screen.c 
b/src/gallium/drivers/galahad/glhd_screen.c
index 4117485..e1a1b59 100644
--- a/src/gallium/drivers/galahad/glhd_screen.c
+++ b/src/gallium/drivers/galahad/glhd_screen.c
@@ -330,5 +330,7 @@ galahad_screen_create(struct pipe_screen *screen)
 
glhd_screen-screen = screen;
 
+   glhd_warn(Created screen %p, glhd_screen);
+
return glhd_screen-base;
 }

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


Mesa (master): galahad, i915g: Move over a few state asserts.

2010-08-20 Thread Corbin Simpson
Module: Mesa
Branch: master
Commit: cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0

Author: Corbin Simpson mostawesomed...@gmail.com
Date:   Fri Aug 20 00:00:40 2010 -0700

galahad, i915g: Move over a few state asserts.

---

 src/gallium/drivers/galahad/glhd_context.c |   16 
 src/gallium/drivers/i915/i915_state.c  |3 ---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/galahad/glhd_context.c 
b/src/gallium/drivers/galahad/glhd_context.c
index ddf3886..10e4679 100644
--- a/src/gallium/drivers/galahad/glhd_context.c
+++ b/src/gallium/drivers/galahad/glhd_context.c
@@ -185,6 +185,12 @@ galahad_bind_fragment_sampler_states(struct pipe_context 
*_pipe,
struct galahad_context *glhd_pipe = galahad_context(_pipe);
struct pipe_context *pipe = glhd_pipe-pipe;
 
+   if (num_samplers  PIPE_MAX_SAMPLERS) {
+  glhd_error(%u fragment samplers requested, 
+ but only %u are permitted by API,
+ num_samplers, PIPE_MAX_SAMPLERS);
+   }
+
pipe-bind_fragment_sampler_states(pipe,
   num_samplers,
   samplers);
@@ -198,6 +204,12 @@ galahad_bind_vertex_sampler_states(struct pipe_context 
*_pipe,
struct galahad_context *glhd_pipe = galahad_context(_pipe);
struct pipe_context *pipe = glhd_pipe-pipe;
 
+   if (num_samplers  PIPE_MAX_VERTEX_SAMPLERS) {
+  glhd_error(%u vertex samplers requested, 
+ but only %u are permitted by API,
+ num_samplers, PIPE_MAX_VERTEX_SAMPLERS);
+   }
+
pipe-bind_vertex_sampler_states(pipe,
 num_samplers,
 samplers);
@@ -447,6 +459,10 @@ galahad_set_constant_buffer(struct pipe_context *_pipe,
struct pipe_resource *unwrapped_resource;
struct pipe_resource *resource = NULL;
 
+   if (shader = PIPE_SHADER_TYPES) {
+  glhd_error(Unknown shader type %u, shader);
+   }
+
/* XXX hmm? unwrap the input state */
if (_resource) {
   unwrapped_resource = galahad_resource_unwrap(_resource);
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 385c3b2..cbddb21 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -294,8 +294,6 @@ static void i915_bind_sampler_states(struct pipe_context 
*pipe,
struct i915_context *i915 = i915_context(pipe);
unsigned i;
 
-   assert(num = PIPE_MAX_SAMPLERS);
-
/* Check for no-op */
if (num == i915-num_samplers 
!memcmp(i915-sampler, sampler, num * sizeof(void *)))
@@ -529,7 +527,6 @@ static void i915_set_constant_buffer(struct pipe_context 
*pipe,
struct i915_context *i915 = i915_context(pipe);
draw_flush(i915-draw);
 
-   assert(shader  PIPE_SHADER_TYPES);
assert(index == 0);
 
/* Make a copy of shader constants.

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


Mesa (master): galahad, i915g: Copy over constant buffer index check.

2010-08-20 Thread Corbin Simpson
Module: Mesa
Branch: master
Commit: e0ef4800f5deb81ed57dccf8ba39e01c12f4beff
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e0ef4800f5deb81ed57dccf8ba39e01c12f4beff

Author: Corbin Simpson mostawesomed...@gmail.com
Date:   Fri Aug 20 00:18:30 2010 -0700

galahad, i915g: Copy over constant buffer index check.

---

 src/gallium/drivers/galahad/glhd_context.c |9 +
 src/gallium/drivers/i915/i915_state.c  |2 --
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/galahad/glhd_context.c 
b/src/gallium/drivers/galahad/glhd_context.c
index 10e4679..383c448 100644
--- a/src/gallium/drivers/galahad/glhd_context.c
+++ b/src/gallium/drivers/galahad/glhd_context.c
@@ -463,6 +463,15 @@ galahad_set_constant_buffer(struct pipe_context *_pipe,
   glhd_error(Unknown shader type %u, shader);
}
 
+   if (index 
+  index =
+ pipe-screen-get_param(pipe-screen, PIPE_CAP_MAX_CONST_BUFFERS)) {
+  glhd_error(Access to constant buffer %u requested, 
+ but only %d are supported,
+ index,
+ pipe-screen-get_param(pipe-screen, PIPE_CAP_MAX_CONST_BUFFERS));
+   }
+
/* XXX hmm? unwrap the input state */
if (_resource) {
   unwrapped_resource = galahad_resource_unwrap(_resource);
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index cbddb21..8c53b06 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -527,8 +527,6 @@ static void i915_set_constant_buffer(struct pipe_context 
*pipe,
struct i915_context *i915 = i915_context(pipe);
draw_flush(i915-draw);
 
-   assert(index == 0);
-
/* Make a copy of shader constants.
 * During fragment program translation we may add additional
 * constants to the array.

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


Mesa (gallium-rect-textures): gallium: add PIPE_TEXTURE_RECT target

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: 6b035e67a108dda524e7aeabc5cfa9be4088e0d6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b035e67a108dda524e7aeabc5cfa9be4088e0d6

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Apr 15 09:02:29 2010 +0200

gallium: add PIPE_TEXTURE_RECT target

This allows to properly support OpenGL rectangle textures in a well
defined way, especially on drivers that don't expose
PIPE_CAP_NPOT_TEXTURES.

---

 src/gallium/docs/source/index.rst |1 +
 src/gallium/docs/source/resources.rst |   41 +
 src/gallium/include/pipe/p_defines.h  |4 ++-
 3 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/src/gallium/docs/source/index.rst 
b/src/gallium/docs/source/index.rst
index 6c19842..2a73e3a 100644
--- a/src/gallium/docs/source/index.rst
+++ b/src/gallium/docs/source/index.rst
@@ -15,6 +15,7 @@ Contents:
debugging
tgsi
screen
+   resources
context
cso
distro
diff --git a/src/gallium/docs/source/resources.rst 
b/src/gallium/docs/source/resources.rst
new file mode 100644
index 000..a380e50
--- /dev/null
+++ b/src/gallium/docs/source/resources.rst
@@ -0,0 +1,41 @@
+Resources
+=
+
+Resources represent objects that hold data: textures and buffers.
+
+They are mostly modelled after the resources in Direct3D 10/11, but with a
+different transfer/update mechanism, and more features for OpenGL support.
+
+Resource targets
+
+
+Resource targets determine the type of a resource.
+
+Note that drivers may not actually have the restrictions listed regarding
+coordinate normalization and wrap modes, and in fact efficient OpenCL
+support will probably require drivers that don't have any of them, which
+will probably be advertised with an appropriate cap.
+
+TODO: document all targets. Note that both 3D and cube have restrictions
+that depend on the hardware generation.
+
+TODO: can buffers have a non-R8 format?
+
+PIPE_TEXTURE_RECT
+^
+2D surface with OpenGL GL_TEXTURE_RECTANGLE semantics.
+
+depth must be 1
+- last_level must be 0
+- Must use unnormalized coordinates
+- Must use a clamp wrap mode
+
+PIPE_TEXTURE_2D
+^^^
+2D surface accessed with normalized coordinates.
+
+- If PIPE_CAP_NPOT_TEXTURES is not supported,
+  width and height must be powers of two
+- Mipmaps can be used
+- Must use normalized coordinates
+- No special restrictions on wrap modes
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 00aa207..35eccf1 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -135,13 +135,15 @@ enum pipe_error {
 #define PIPE_STENCIL_OP_DECR_WRAP  6
 #define PIPE_STENCIL_OP_INVERT 7
 
-/** Texture types */
+/** Texture types.
+ * See the documentation for info on PIPE_TEXTURE_RECT vs PIPE_TEXTURE_2D */
 enum pipe_texture_target {
PIPE_BUFFER   = 0,
PIPE_TEXTURE_1D   = 1,
PIPE_TEXTURE_2D   = 2,
PIPE_TEXTURE_3D   = 3,
PIPE_TEXTURE_CUBE = 4,
+   PIPE_TEXTURE_RECT = 5,
PIPE_MAX_TEXTURE_TYPES
 };
 

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


Mesa (gallium-rect-textures): gallium: make all checks for PIPE_TEXTURE_2D check for PIPE_TEXTURE_RECT too

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: 752f7a5c775b78b3111f40982e87c88bbb7b56a4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=752f7a5c775b78b3111f40982e87c88bbb7b56a4

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 17:28:08 2010 +0200

gallium: make all checks for PIPE_TEXTURE_2D check for PIPE_TEXTURE_RECT too

Searched for them with:
git grep -E 
'[!=]=.*PIPE_TEXTURE_2D|PIPE_TEXTURE_2D.*[!=]=|case.*PIPE_TEXTURE_2D'

Behavior hasn't been changed.

---

 src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |7 +--
 src/gallium/auxiliary/util/u_blit.c   |3 ++-
 src/gallium/auxiliary/util/u_blitter.c|3 +++
 src/gallium/auxiliary/util/u_gen_mipmap.c |1 +
 src/gallium/auxiliary/util/u_surfaces.h   |4 ++--
 src/gallium/drivers/i915/i915_resource_texture.c  |5 -
 src/gallium/drivers/i965/brw_resource_texture.c   |4 +++-
 src/gallium/drivers/llvmpipe/lp_screen.c  |1 +
 src/gallium/drivers/llvmpipe/lp_texture.c |1 +
 src/gallium/drivers/nv50/nv50_miptree.c   |3 ++-
 src/gallium/drivers/nv50/nv50_tex.c   |1 +
 src/gallium/drivers/nvfx/nv30_fragtex.c   |1 +
 src/gallium/drivers/nvfx/nv40_fragtex.c   |1 +
 src/gallium/drivers/nvfx/nvfx_miptree.c   |3 ++-
 src/gallium/drivers/r300/r300_hyperz.c|3 ++-
 src/gallium/drivers/r300/r300_texture.c   |6 --
 src/gallium/drivers/r300/r300_texture_desc.c  |6 --
 src/gallium/drivers/r600/r600_state.c |1 +
 src/gallium/drivers/r600/r600_texture.c   |3 ++-
 src/gallium/drivers/softpipe/sp_screen.c  |1 +
 src/gallium/drivers/softpipe/sp_tex_sample.c  |2 ++
 src/gallium/drivers/svga/svga_resource_texture.c  |3 ++-
 src/gallium/drivers/svga/svga_tgsi_emit.h |1 +
 src/gallium/tests/python/tests/texture_blit.py|2 +-
 src/mesa/state_tracker/st_cb_bitmap.c |2 +-
 25 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 806c7d5..f6b6162 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -176,6 +176,7 @@ texture_dims(enum pipe_texture_target tex)
case PIPE_TEXTURE_1D:
   return 1;
case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
case PIPE_TEXTURE_CUBE:
   return 2;
case PIPE_TEXTURE_3D:
@@ -1749,7 +1750,8 @@ lp_build_sample_2d_linear_aos(struct 
lp_build_sample_context *bld,
LLVMValueRef unswizzled[4];
LLVMValueRef stride;
 
-   assert(bld-static_state-target == PIPE_TEXTURE_2D);
+   assert(bld-static_state-target == PIPE_TEXTURE_2D
+ || bld-static_state-target == PIPE_TEXTURE_RECT);
assert(bld-static_state-min_img_filter == PIPE_TEX_FILTER_LINEAR);
assert(bld-static_state-mag_img_filter == PIPE_TEX_FILTER_LINEAR);
assert(bld-static_state-min_mip_filter == PIPE_TEX_MIPFILTER_NONE);
@@ -2077,7 +2079,8 @@ lp_build_sample_soa(LLVMBuilderRef builder,
}
else if (util_format_fits_8unorm(bld.format_desc) 
 bld.format_desc-nr_channels  1 
-static_state-target == PIPE_TEXTURE_2D 
+(static_state-target == PIPE_TEXTURE_2D ||
+  static_state-target == PIPE_TEXTURE_RECT) 
 static_state-min_img_filter == PIPE_TEX_FILTER_LINEAR 
 static_state-mag_img_filter == PIPE_TEX_FILTER_LINEAR 
 static_state-min_mip_filter == PIPE_TEX_MIPFILTER_NONE 
diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 97fa99e..30c7a96 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -347,7 +347,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
dst-face == srcsub.face 
dst-level == srcsub.level 
dst-zslice == srcZ0) ||
-   src_tex-target != PIPE_TEXTURE_2D)
+   (src_tex-target != PIPE_TEXTURE_2D 
+   src_tex-target != PIPE_TEXTURE_RECT))
{
   struct pipe_resource texTemp;
   struct pipe_resource *tex;
diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index b5b86b7..1d95280 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -568,6 +568,8 @@ pipe_tex_to_tgsi_tex(enum pipe_texture_target 
pipe_tex_target)
   return TGSI_TEXTURE_1D;
case PIPE_TEXTURE_2D:
   return TGSI_TEXTURE_2D;
+   case PIPE_TEXTURE_RECT:
+  return TGSI_TEXTURE_2D;
case PIPE_TEXTURE_3D:
   return TGSI_TEXTURE_3D;
case PIPE_TEXTURE_CUBE:
@@ -806,6 +808,7 @@ void util_blitter_copy_region(struct blitter_context 
*blitter,
   /* Draw the quad with the draw_rectangle callback. */
   case PIPE_TEXTURE_1D:
   case PIPE_TEXTURE_2D:
+  case 

Mesa (gallium-rect-textures): u_blitter: use TGSI_TEXTURE_RECT

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: 27911994dadf9c1fbbdaf0a78ba37e02a00eb672
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=27911994dadf9c1fbbdaf0a78ba37e02a00eb672

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 17:30:20 2010 +0200

u_blitter: use TGSI_TEXTURE_RECT

This seems to make sense, although I suspect the semantics of
TGSI_TEXTURE_RECT need to be closely reviewed.

---

 src/gallium/auxiliary/util/u_blitter.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index 1d95280..163f3d6 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -569,7 +569,7 @@ pipe_tex_to_tgsi_tex(enum pipe_texture_target 
pipe_tex_target)
case PIPE_TEXTURE_2D:
   return TGSI_TEXTURE_2D;
case PIPE_TEXTURE_RECT:
-  return TGSI_TEXTURE_2D;
+  return TGSI_TEXTURE_RECT;
case PIPE_TEXTURE_3D:
   return TGSI_TEXTURE_3D;
case PIPE_TEXTURE_CUBE:

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


Mesa (gallium-rect-textures): u_staging: use PIPE_TEXTURE_RECT

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: 1d640e4770427a6aec4d3dbf1e12c2d9b84effe5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d640e4770427a6aec4d3dbf1e12c2d9b84effe5

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 22:57:02 2010 +0200

u_staging: use PIPE_TEXTURE_RECT

---

 src/gallium/auxiliary/util/u_staging.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_staging.c 
b/src/gallium/auxiliary/util/u_staging.c
index 607c31f..e2dc696 100644
--- a/src/gallium/auxiliary/util/u_staging.c
+++ b/src/gallium/auxiliary/util/u_staging.c
@@ -8,7 +8,7 @@ util_staging_resource_template(struct pipe_resource *pt, 
unsigned width, unsigne
 {
memset(template, 0, sizeof(struct pipe_resource));
if(pt-target != PIPE_BUFFER  depth = 1)
-  template-target = PIPE_TEXTURE_2D;
+  template-target = PIPE_TEXTURE_RECT;
else
   template-target = pt-target;
template-format = pt-format;

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


Mesa (gallium-rect-textures): mesa/st: support using PIPE_TEXTURE_RECT internally

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: 03f2330be75239d8c0f0d1ec0337107e643d9a2a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=03f2330be75239d8c0f0d1ec0337107e643d9a2a

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug  6 07:39:21 2010 +0200

mesa/st: support using PIPE_TEXTURE_RECT internally

Currently Gallium internals always use PIPE_TEXTURE_2D and normalized
coordinates to access textures.

However, PIPE_TEXTURE_2D is not always supported for NPOT textures,
and PIPE_TEXTURE_RECT requires unnormalized coordinates.

Hence, this change adds support for both kinds of normalization.

---

 src/mesa/state_tracker/st_cb_bitmap.c |   23 ++-
 src/mesa/state_tracker/st_cb_drawpixels.c |   42 ++--
 src/mesa/state_tracker/st_cb_fbo.c|2 +-
 src/mesa/state_tracker/st_context.c   |5 +++
 src/mesa/state_tracker/st_context.h   |3 +-
 5 files changed, 32 insertions(+), 43 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bitmap.c 
b/src/mesa/state_tracker/st_cb_bitmap.c
index 91037ab..d40e413 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -275,7 +275,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei 
height,
/**
 * Create texture to hold bitmap pattern.
 */
-   pt = st_texture_create(st, PIPE_TEXTURE_2D, st-bitmap.tex_format,
+   pt = st_texture_create(st, st-internal_target, st-bitmap.tex_format,
   0, width, height, 1,
   PIPE_BIND_SAMPLER_VIEW);
if (!pt) {
@@ -304,7 +304,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei 
height,
 }
 
 static GLuint
-setup_bitmap_vertex_data(struct st_context *st,
+setup_bitmap_vertex_data(struct st_context *st, bool normalized,
  int x, int y, int width, int height,
  float z, const float color[4])
 {
@@ -316,13 +316,19 @@ setup_bitmap_vertex_data(struct st_context *st,
const GLfloat x1 = (GLfloat)(x + width);
const GLfloat y0 = (GLfloat)y;
const GLfloat y1 = (GLfloat)(y + height);
-   const GLfloat sLeft = (GLfloat)0.0, sRight = (GLfloat)1.0;
-   const GLfloat tTop = (GLfloat)0.0, tBot = (GLfloat)1.0 - tTop;
+   GLfloat sLeft = (GLfloat)0.0, sRight = (GLfloat)1.0;
+   GLfloat tTop = (GLfloat)0.0, tBot = (GLfloat)1.0 - tTop;
const GLfloat clip_x0 = (GLfloat)(x0 / fb_width * 2.0 - 1.0);
const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0);
const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0);
const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0);
 
+   if(!normalized)
+   {
+  sRight = width;
+  tBot = height;
+   }
+
/* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
 * no_flush) updates to buffers where we know there is no conflict
 * with previous data.  Currently using max_slots  1 will cause
@@ -462,7 +468,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat 
z,
   for (i = 0; i  st-state.num_samplers; i++) {
  samplers[i] = st-state.samplers[i];
   }
-  samplers[stfp-bitmap_sampler] = st-bitmap.sampler;
+  samplers[stfp-bitmap_sampler] = 
st-bitmap.samplers[sv-texture-target != PIPE_TEXTURE_RECT];
   cso_set_samplers(cso, num, (const struct pipe_sampler_state **) 
samplers);
}
 
@@ -499,7 +505,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat 
z,
z = z * 2.0 - 1.0;
 
/* draw textured quad */
-   offset = setup_bitmap_vertex_data(st, x, y, width, height, z, color);
+   offset = setup_bitmap_vertex_data(st, sv-texture-target != 
PIPE_TEXTURE_RECT, x, y, width, height, z, color);
 
util_draw_vertex_buffer(pipe, st-bitmap.vbuf, offset,
PIPE_PRIM_TRIANGLE_FAN,
@@ -789,7 +795,7 @@ st_init_bitmap_functions(struct dd_function_table 
*functions)
 void
 st_init_bitmap(struct st_context *st)
 {
-   struct pipe_sampler_state *sampler = st-bitmap.sampler;
+   struct pipe_sampler_state *sampler = st-bitmap.samplers[0];
struct pipe_context *pipe = st-pipe;
struct pipe_screen *screen = pipe-screen;
 
@@ -801,7 +807,8 @@ st_init_bitmap(struct st_context *st)
sampler-min_img_filter = PIPE_TEX_FILTER_NEAREST;
sampler-min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
sampler-mag_img_filter = PIPE_TEX_FILTER_NEAREST;
-   sampler-normalized_coords = 1;
+   st-bitmap.samplers[1] = *sampler;
+   st-bitmap.samplers[1].normalized_coords = 1;
 
/* init baseline rasterizer state once */
memset(st-bitmap.rasterizer, 0, sizeof(st-bitmap.rasterizer));
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 69a3dd4..d934fdc 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -304,34 +304,9 @@ alloc_texture(struct st_context *st, GLsizei width, 
GLsizei height,
struct pipe_context *pipe = st-pipe;
struct 

Mesa (gallium-rect-textures): auxiliary: support using PIPE_TEXTURE_RECT internally

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: 38ab166b6fe4a5024b8d67272a992b51f8f796ac
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=38ab166b6fe4a5024b8d67272a992b51f8f796ac

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug  6 07:39:21 2010 +0200

auxiliary: support using PIPE_TEXTURE_RECT internally

Currently Gallium internals always use PIPE_TEXTURE_2D and normalized
coordinates to access textures.

However, PIPE_TEXTURE_2D is not always supported for NPOT textures,
and PIPE_TEXTURE_RECT requires unnormalized coordinates.

Hence, this change adds support for both kinds of normalization.

---

 src/gallium/auxiliary/util/u_blit.c|   67 
 src/gallium/auxiliary/util/u_blitter.c |   48 +++
 2 files changed, 81 insertions(+), 34 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 30c7a96..6fb341e 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -62,6 +62,7 @@ struct blit_state
struct pipe_viewport_state viewport;
struct pipe_clip_state clip;
struct pipe_vertex_element velem[2];
+   enum pipe_texture_target internal_target;
 
void *vs;
void *fs[TGSI_WRITEMASK_XYZW + 1];
@@ -110,7 +111,6 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
ctx-sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
ctx-sampler.min_img_filter = 0; /* set later */
ctx-sampler.mag_img_filter = 0; /* set later */
-   ctx-sampler.normalized_coords = 1;
 
/* vertex elements state */
memset(ctx-velem[0], 0, sizeof(ctx-velem[0]) * 2);
@@ -145,6 +145,11 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
   ctx-vertices[i][1][3] = 1.0f; /* q */
}
 
+   if(pipe-screen-get_param(pipe-screen, PIPE_CAP_NPOT_TEXTURES))
+  ctx-internal_target = PIPE_TEXTURE_2D;
+   else
+  ctx-internal_target = PIPE_TEXTURE_RECT;
+
return ctx;
 }
 
@@ -296,6 +301,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
unsigned offset;
boolean overlap;
float s0, t0, s1, t1;
+   boolean normalized;
 
assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
   filter == PIPE_TEX_MIPFILTER_LINEAR);
@@ -335,7 +341,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
   return;
}
 
-
/* Create a temporary texture when src and dest alias or when src
 * is anything other than a 2d texture.
 * XXX should just use appropriate shader to access 1d / 3d slice / cube 
face,
@@ -373,7 +378,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
 
   /* create temp texture */
   memset(texTemp, 0, sizeof(texTemp));
-  texTemp.target = PIPE_TEXTURE_2D;
+  texTemp.target = ctx-internal_target;
   texTemp.format = src_tex-format;
   texTemp.last_level = 0;
   texTemp.width0 = srcW;
@@ -393,10 +398,19 @@ util_blit_pixels_writemask(struct blit_state *ctx,
  src_tex, srcsub, srcLeft, srcTop, srcZ0, /* 
src */
  srcW, srcH); /* size */
 
-  s0 = 0.0f; 
-  s1 = 1.0f;
-  t0 = 0.0f;
-  t1 = 1.0f;
+  normalized = tex-target != PIPE_TEXTURE_RECT;
+  if(normalized) {
+ s0 = 0.0f;
+ s1 = 1.0f;
+ t0 = 0.0f;
+ t1 = 1.0f;
+  }
+  else {
+ s0 = 0;
+ s1 = srcW;
+ t0 = 0;
+ t1 = srcH;
+  }
 
   u_sampler_view_default_template(sv_templ, tex, tex-format);
   sampler_view = pipe-create_sampler_view(pipe, tex, sv_templ);
@@ -416,17 +430,25 @@ util_blit_pixels_writemask(struct blit_state *ctx,
  return;
   }
 
-  s0 = srcX0 / (float)(u_minify(sampler_view-texture-width0, 
srcsub.level));
-  s1 = srcX1 / (float)(u_minify(sampler_view-texture-width0, 
srcsub.level));
-  t0 = srcY0 / (float)(u_minify(sampler_view-texture-height0, 
srcsub.level));
-  t1 = srcY1 / (float)(u_minify(sampler_view-texture-height0, 
srcsub.level));
+  s0 = srcX0;
+  s1 = srcX1;
+  t0 = srcY0;
+  t1 = srcY1;
+  normalized = sampler_view-texture-target != PIPE_TEXTURE_RECT;
+  if(normalized)
+  {
+ s0 /= (float)(u_minify(sampler_view-texture-width0, srcsub.level));
+ s1 /= (float)(u_minify(sampler_view-texture-width0, srcsub.level));
+ t0 /= (float)(u_minify(sampler_view-texture-height0, srcsub.level));
+ t1 /= (float)(u_minify(sampler_view-texture-height0, srcsub.level));
+  }
}
 
 
-   assert(screen-is_format_supported(screen, sampler_view-format, 
PIPE_TEXTURE_2D,
+   assert(screen-is_format_supported(screen, sampler_view-format, 
ctx-internal_target,
   sampler_view-texture-nr_samples,
   PIPE_BIND_SAMPLER_VIEW, 0));
-   assert(screen-is_format_supported(screen, dst-format, PIPE_TEXTURE_2D,
+   assert(screen-is_format_supported(screen, 

Mesa (gallium-rect-textures): winsys/sw: use PIPE_TEXTURE_RECT if appropriate

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: 710ee13e281aeee971c623325ed3671d16dfd6fe
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=710ee13e281aeee971c623325ed3671d16dfd6fe

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Aug 19 01:44:02 2010 +0200

winsys/sw: use PIPE_TEXTURE_RECT if appropriate

---

 src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c 
b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index b997abd..3a76098 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -52,6 +52,7 @@ struct wrapper_sw_winsys
struct sw_winsys base;
struct pipe_screen *screen;
struct pipe_context *pipe;
+   enum pipe_texture_target target;
 };
 
 struct wrapper_sw_displaytarget
@@ -145,7 +146,7 @@ wsw_dt_create(struct sw_winsys *ws,
 * XXX Why don't we just get the template.
 */
memset(templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = wsw-target;
templ.width0 = width;
templ.height0 = height;
templ.format = format;
@@ -291,6 +292,11 @@ wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen 
*screen)
if (!wsw-pipe)
   goto err_free;
 
+   if(screen-get_param(screen, PIPE_CAP_NPOT_TEXTURES))
+  wsw-target = PIPE_TEXTURE_2D;
+   else
+  wsw-target = PIPE_TEXTURE_RECT;
+
return wsw-base;
 
 err_free:

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


Mesa (gallium-rect-textures): st/glx: use PIPE_TEXTURE_RECT if appropriate

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: 6df47e1f1c87cd0c3b8ae9c2fb8abdf05531ab5c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6df47e1f1c87cd0c3b8ae9c2fb8abdf05531ab5c

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Aug 19 00:55:13 2010 +0200

st/glx: use PIPE_TEXTURE_RECT if appropriate

---

 src/gallium/state_trackers/glx/xlib/xm_st.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c 
b/src/gallium/state_trackers/glx/xlib/xm_st.c
index c62eb8b..9cd744c 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_st.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
@@ -38,6 +38,7 @@ struct xmesa_st_framebuffer {
struct pipe_screen *screen;
 
struct st_visual stvis;
+   enum pipe_texture_target target;
 
unsigned texture_width, texture_height, texture_mask;
struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
@@ -139,7 +140,7 @@ xmesa_st_framebuffer_validate_textures(struct 
st_framebuffer_iface *stfbi,
}
 
memset(templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = xstfb-target;
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
@@ -279,6 +280,10 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, 
XMesaBuffer b)
xstfb-buffer = b;
xstfb-screen = xmdpy-screen;
xstfb-stvis = b-xm_visual-stvis;
+   if(xstfb-screen-get_param(xstfb-screen, PIPE_CAP_NPOT_TEXTURES))
+  xstfb-target = PIPE_TEXTURE_2D;
+   else
+  xstfb-target = PIPE_TEXTURE_RECT;
 
stfbi-visual = xstfb-stvis;
stfbi-flush_front = xmesa_st_framebuffer_flush_front;

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


Mesa (gallium-rect-textures): galahad: check resource_create template

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: bd6b02e1140462aa2d15674f0c8ccbccb732f0ca
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd6b02e1140462aa2d15674f0c8ccbccb732f0ca

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Aug 19 01:38:33 2010 +0200

galahad: check resource_create template

---

 src/gallium/drivers/galahad/glhd_screen.c |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/galahad/glhd_screen.c 
b/src/gallium/drivers/galahad/glhd_screen.c
index 4117485..1bb5f7b 100644
--- a/src/gallium/drivers/galahad/glhd_screen.c
+++ b/src/gallium/drivers/galahad/glhd_screen.c
@@ -30,6 +30,7 @@
 #include pipe/p_screen.h
 #include pipe/p_state.h
 #include util/u_memory.h
+#include util/u_math.h
 
 #include glhd_public.h
 #include glhd_screen.h
@@ -134,6 +135,34 @@ galahad_screen_resource_create(struct pipe_screen *_screen,
struct pipe_screen *screen = glhd_screen-screen;
struct pipe_resource *result;
 
+   if (templat-target = PIPE_MAX_TEXTURE_TYPES)
+  glhd_warn(Received bogus resource target %d, templat-target);
+
+   if(templat-target != PIPE_TEXTURE_RECT  templat-target != PIPE_BUFFER 
 !screen-get_param(screen, PIPE_CAP_NPOT_TEXTURES))
+   {
+  if(!util_is_pot(templat-width0) || !util_is_pot(templat-height0))
+ glhd_warn(Requested NPOT (%ux%u) non-rectangle texture without NPOT 
support, templat-width0, templat-height0);
+   }
+
+   /* TODO: allow this for OpenCL flexible sampling */
+   if(templat-target == PIPE_TEXTURE_RECT  templat-last_level)
+  glhd_warn(Rectangle textures cannot have mipmaps, but last_level = %u, 
templat-last_level);
+
+   if(templat-target == PIPE_BUFFER  templat-last_level)
+  glhd_warn(Buffers cannot have mipmaps, but last_level = %u, 
templat-last_level);
+
+   if(templat-target != PIPE_TEXTURE_3D  templat-depth0 != 1)
+  glhd_warn(Only 3D textures can have depth != 1, but received target %u 
and depth %u, templat-target, templat-depth0);
+
+   if(templat-target == PIPE_TEXTURE_1D  templat-height0 != 1)
+ glhd_warn(1D textures must have height 1 but got asked for height %u, 
templat-height0);
+
+   if(templat-target == PIPE_BUFFER  templat-height0 != 1)
+ glhd_warn(Buffers must have height 1 but got asked for height %u, 
templat-height0);
+
+   if(templat-target == PIPE_TEXTURE_CUBE  templat-width0 != 
templat-height0)
+  glhd_warn(Cube maps must be square, but got asked for %ux%u, 
templat-width0, templat-height0);
+
result = screen-resource_create(screen,
 templat);
 

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


Mesa (gallium-rect-textures): mesa/st: use PIPE_TEXTURE_RECT for GL_TEXTURE_RECTANGLE

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: bcd41b03e0744d1697266adf8489623f84d0746d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bcd41b03e0744d1697266adf8489623f84d0746d

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Apr 15 09:04:20 2010 +0200

mesa/st: use PIPE_TEXTURE_RECT for GL_TEXTURE_RECTANGLE

---

 src/mesa/state_tracker/st_cb_texture.c |6 --
 src/mesa/state_tracker/st_texture.c|2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 4c3e368..a41c780 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -74,9 +74,11 @@ gl_target_to_pipe(GLenum target)
   return PIPE_TEXTURE_1D;
 
case GL_TEXTURE_2D:
-   case GL_TEXTURE_RECTANGLE_NV:
   return PIPE_TEXTURE_2D;
 
+   case GL_TEXTURE_RECTANGLE_NV:
+  return PIPE_TEXTURE_RECT;
+
case GL_TEXTURE_3D:
   return PIPE_TEXTURE_3D;
 
@@ -449,7 +451,7 @@ compress_with_blit(GLcontext * ctx,
/* Create the temporary source texture
 */
memset(templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = st-internal_target;
templ.format = st_mesa_format_to_pipe_format(mesa_format);
templ.width0 = width;
templ.height0 = height;
diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index add6e94..c6cf2ba 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -64,7 +64,7 @@ st_texture_create(struct st_context *st,
struct pipe_resource pt, *newtex;
struct pipe_screen *screen = st-pipe-screen;
 
-   assert(target = PIPE_TEXTURE_CUBE);
+   assert(target  PIPE_MAX_TEXTURE_TYPES);
assert(width0  0);
assert(height0  0);
assert(depth0  0);

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


Mesa (gallium-rect-textures): nv50: use NV50TIC_0_2_TARGET_RECT

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: gallium-rect-textures
Commit: b69e3a5329c2b1b6cb40a8635a1045f767beae4e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b69e3a5329c2b1b6cb40a8635a1045f767beae4e

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 17:29:59 2010 +0200

nv50: use NV50TIC_0_2_TARGET_RECT

---

 src/gallium/drivers/nv50/nv50_tex.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_tex.c 
b/src/gallium/drivers/nv50/nv50_tex.c
index 4db53f7..d41d9c5 100644
--- a/src/gallium/drivers/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nv50/nv50_tex.c
@@ -131,9 +131,11 @@ nv50_tex_construct(struct nv50_sampler_view *view)
tic[2] |= NV50TIC_0_2_TARGET_1D;
break;
case PIPE_TEXTURE_2D:
-   case PIPE_TEXTURE_RECT:
tic[2] |= NV50TIC_0_2_TARGET_2D;
break;
+   case PIPE_TEXTURE_RECT:
+   tic[2] |= NV50TIC_0_2_TARGET_RECT;
+   break;
case PIPE_TEXTURE_3D:
tic[2] |= NV50TIC_0_2_TARGET_3D;
break;

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


Mesa (master): ast_to_hir: Reject function names that start with gl_.

2010-08-20 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: edd180f03216d2fcb2771aeea34e7015fb2b83c3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=edd180f03216d2fcb2771aeea34e7015fb2b83c3

Author: Kenneth Graunke kenn...@whitecape.org
Date:   Fri Aug 20 02:14:35 2010 -0700

ast_to_hir: Reject function names that start with gl_.

Fixes piglit test redeclaration-03.vert.

---

 src/glsl/ast_to_hir.cpp |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 0d2c471..4188348 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2099,6 +2099,18 @@ ast_function::hir(exec_list *instructions,
 
const char *const name = identifier;
 
+   /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec,
+*
+*   Identifiers starting with gl_ are reserved for use by
+*   OpenGL, and may not be declared in a shader as either a
+*   variable or a function.
+*/
+   if (strncmp(name, gl_, 3) == 0) {
+  YYLTYPE loc = this-get_location();
+  _mesa_glsl_error(loc, state,
+  identifier `%s' uses reserved `gl_' prefix, name);
+   }
+
/* Convert the list of function parameters to HIR now so that they can be
 * used below to compare this function's signature with previously seen
 * signatures for functions with the same name.

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


Mesa (master): ast_to_hir: Fix crash when a function shadows a variable.

2010-08-20 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 826a39cb14244820e8539a2328bb52447348f184
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=826a39cb14244820e8539a2328bb52447348f184

Author: Kenneth Graunke kenn...@whitecape.org
Date:   Fri Aug 20 02:04:52 2010 -0700

ast_to_hir: Fix crash when a function shadows a variable.

The code would attempt to add a new signature to the ir_function, which
didn't exist.  Simply bailing out/returning early seems reasonable.

Fixes piglit test redeclaration-02.vert, and fixes a crash in
redeclaration-03.vert (the test still fails).

---

 src/glsl/ast_to_hir.cpp |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index bd1ab78..0d2c471 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2149,7 +2149,6 @@ ast_function::hir(exec_list *instructions,
YYLTYPE loc = this-get_location();
 
_mesa_glsl_error( loc, state, function `%s' redefined, name);
-   sig = NULL;
 }
   }
} else if (state-symbols-name_declared_this_scope(name)) {
@@ -2159,7 +2158,7 @@ ast_function::hir(exec_list *instructions,
 
   _mesa_glsl_error( loc, state, function name `%s' conflicts with 
   non-function, name);
-  sig = NULL;
+  return NULL;
} else {
   f = new(ctx) ir_function(name);
   state-symbols-add_function(f-name, f);
@@ -2207,6 +2206,8 @@ ast_function_definition::hir(exec_list *instructions,
prototype-hir(instructions, state);
 
ir_function_signature *signature = prototype-signature;
+   if (signature == NULL)
+  return NULL;
 
assert(state-current_function == NULL);
state-current_function = signature;

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


Mesa (master): i965: Fix compile warnings on 64-bit Linux.

2010-08-20 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 9b3362932df0ec27efd605dfd0838c76111bb23e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b3362932df0ec27efd605dfd0838c76111bb23e

Author: Kenneth Graunke kenn...@whitecape.org
Date:   Fri Aug 20 02:41:42 2010 -0700

i965: Fix compile warnings on 64-bit Linux.

format ‘%d’ expects type ‘int’, but argument 2 has type ‘long int’

---

 src/mesa/drivers/dri/i965/brw_wm_debug.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_debug.c 
b/src/mesa/drivers/dri/i965/brw_wm_debug.c
index a78cc8b..191670d 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_debug.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_debug.c
@@ -44,16 +44,16 @@ void brw_wm_print_value( struct brw_wm_compile *c,
   printf(undef);
else if( value - c-vreg = 0 
value - c-vreg  BRW_WM_MAX_VREG)
-  printf(r%d, value - c-vreg);
+  printf(r%ld, value - c-vreg);
else if (value - c-creg = 0 
value - c-creg  BRW_WM_MAX_PARAM)
-  printf(c%d, value - c-creg);
+  printf(c%ld, value - c-creg);
else if (value - c-payload.input_interp = 0 
value - c-payload.input_interp  FRAG_ATTRIB_MAX)
-  printf(i%d, value - c-payload.input_interp);
+  printf(i%ld, value - c-payload.input_interp);
else if (value - c-payload.depth = 0 
value - c-payload.depth  FRAG_ATTRIB_MAX)
-  printf(d%d, value - c-payload.depth);
+  printf(d%ld, value - c-payload.depth);
else 
   printf(?);
 }

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


Mesa (debug-refcnt-2): gallium: hook up reference count debugging code

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: debug-refcnt-2
Commit: 7aaad202bdab46be88ccc87226927e01b65482ee
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7aaad202bdab46be88ccc87226927e01b65482ee

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:41:10 2010 +0200

gallium: hook up reference count debugging code

This commit adds the ability to produce a log file containing all
reference count changes, and object creation/destruction, on Gallium
objects.

The data allows to answer these crucial questions:
1. This app is exhausting all my memory due to a resource leak: where
   is the bug?
2. Which resources is this app using at a given moment? Which parts of
   the code created them?
3. What kinds of resources does this app use?
4. How fast does this app create and destroy resources? Which parts of
   the code create resources fast?

The output is compatible with the one produced by the similar facility
in Mozilla Firefox, allowing to use Mozilla's tools to analyze the data.

To get the log file:
export GALLIUM_REFCNT_LOG=file

To get function names and source lines in the log file:
tools/addr2line.sh file

To process the log file, see:
http://www.mozilla.org/performance/refcnt-balancer.html

---

 src/gallium/auxiliary/util/u_inlines.h |   19 +--
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_inlines.h 
b/src/gallium/auxiliary/util/u_inlines.h
index 540305c..90b0903 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -33,6 +33,8 @@
 #include pipe/p_state.h
 #include pipe/p_screen.h
 #include util/u_debug.h
+#include util/u_debug_describe.h
+#include util/u_debug_refcnt.h
 #include util/u_atomic.h
 #include util/u_box.h
 #include util/u_math.h
@@ -67,7 +69,7 @@ pipe_is_referenced(struct pipe_reference *reference)
  * \return TRUE if the object's refcount hits zero and should be destroyed.
  */
 static INLINE boolean
-pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
+pipe_reference_described(struct pipe_reference *ptr, struct pipe_reference 
*reference, void* get_desc)
 {
boolean destroy = FALSE;
 
@@ -76,6 +78,7 @@ pipe_reference(struct pipe_reference *ptr, struct 
pipe_reference *reference)
   if (reference) {
  assert(pipe_is_referenced(reference));
  p_atomic_inc(reference-count);
+ debug_reference(reference, get_desc, 1);
   }
 
   if (ptr) {
@@ -83,41 +86,45 @@ pipe_reference(struct pipe_reference *ptr, struct 
pipe_reference *reference)
  if (p_atomic_dec_zero(ptr-count)) {
 destroy = TRUE;
  }
+ debug_reference(ptr, get_desc, -1);
   }
}
 
return destroy;
 }
 
+static INLINE boolean
+pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
+{
+   return pipe_reference_described(ptr, reference, debug_describe_reference);
+}
 
 static INLINE void
 pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
 {
struct pipe_surface *old_surf = *ptr;
 
-   if (pipe_reference((*ptr)-reference, surf-reference))
+   if (pipe_reference_described((*ptr)-reference, surf-reference, 
debug_describe_surface))
   old_surf-texture-screen-tex_surface_destroy(old_surf);
*ptr = surf;
 }
 
-
 static INLINE void
 pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
 {
struct pipe_resource *old_tex = *ptr;
 
-   if (pipe_reference((*ptr)-reference, tex-reference))
+   if (pipe_reference_described((*ptr)-reference, tex-reference, 
debug_describe_resource))
   old_tex-screen-resource_destroy(old_tex-screen, old_tex);
*ptr = tex;
 }
 
-
 static INLINE void
 pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct 
pipe_sampler_view *view)
 {
struct pipe_sampler_view *old_view = *ptr;
 
-   if (pipe_reference((*ptr)-reference, view-reference))
+   if (pipe_reference_described((*ptr)-reference, view-reference, 
debug_describe_sampler_view))
   old_view-context-sampler_view_destroy(old_view-context, old_view);
*ptr = view;
 }

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


Mesa (master): gallium: add PIPE_TEXTURE_RECT target

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 72b3e3fee37413fefe205fa03a111a0180ed19c1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=72b3e3fee37413fefe205fa03a111a0180ed19c1

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Apr 15 09:02:29 2010 +0200

gallium: add PIPE_TEXTURE_RECT target

This allows to properly support OpenGL rectangle textures in a well
defined way, especially on drivers that don't expose
PIPE_CAP_NPOT_TEXTURES.

---

 src/gallium/docs/source/index.rst |1 +
 src/gallium/docs/source/resources.rst |   41 +
 src/gallium/include/pipe/p_defines.h  |4 ++-
 3 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/src/gallium/docs/source/index.rst 
b/src/gallium/docs/source/index.rst
index 6c19842..2a73e3a 100644
--- a/src/gallium/docs/source/index.rst
+++ b/src/gallium/docs/source/index.rst
@@ -15,6 +15,7 @@ Contents:
debugging
tgsi
screen
+   resources
context
cso
distro
diff --git a/src/gallium/docs/source/resources.rst 
b/src/gallium/docs/source/resources.rst
new file mode 100644
index 000..a380e50
--- /dev/null
+++ b/src/gallium/docs/source/resources.rst
@@ -0,0 +1,41 @@
+Resources
+=
+
+Resources represent objects that hold data: textures and buffers.
+
+They are mostly modelled after the resources in Direct3D 10/11, but with a
+different transfer/update mechanism, and more features for OpenGL support.
+
+Resource targets
+
+
+Resource targets determine the type of a resource.
+
+Note that drivers may not actually have the restrictions listed regarding
+coordinate normalization and wrap modes, and in fact efficient OpenCL
+support will probably require drivers that don't have any of them, which
+will probably be advertised with an appropriate cap.
+
+TODO: document all targets. Note that both 3D and cube have restrictions
+that depend on the hardware generation.
+
+TODO: can buffers have a non-R8 format?
+
+PIPE_TEXTURE_RECT
+^
+2D surface with OpenGL GL_TEXTURE_RECTANGLE semantics.
+
+depth must be 1
+- last_level must be 0
+- Must use unnormalized coordinates
+- Must use a clamp wrap mode
+
+PIPE_TEXTURE_2D
+^^^
+2D surface accessed with normalized coordinates.
+
+- If PIPE_CAP_NPOT_TEXTURES is not supported,
+  width and height must be powers of two
+- Mipmaps can be used
+- Must use normalized coordinates
+- No special restrictions on wrap modes
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 00aa207..35eccf1 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -135,13 +135,15 @@ enum pipe_error {
 #define PIPE_STENCIL_OP_DECR_WRAP  6
 #define PIPE_STENCIL_OP_INVERT 7
 
-/** Texture types */
+/** Texture types.
+ * See the documentation for info on PIPE_TEXTURE_RECT vs PIPE_TEXTURE_2D */
 enum pipe_texture_target {
PIPE_BUFFER   = 0,
PIPE_TEXTURE_1D   = 1,
PIPE_TEXTURE_2D   = 2,
PIPE_TEXTURE_3D   = 3,
PIPE_TEXTURE_CUBE = 4,
+   PIPE_TEXTURE_RECT = 5,
PIPE_MAX_TEXTURE_TYPES
 };
 

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


Mesa (master): gallium: make all checks for PIPE_TEXTURE_2D check for PIPE_TEXTURE_RECT too

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: ae0ef6f69f351cacdc7eaa9b21097a7c1b414e44
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ae0ef6f69f351cacdc7eaa9b21097a7c1b414e44

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 17:28:08 2010 +0200

gallium: make all checks for PIPE_TEXTURE_2D check for PIPE_TEXTURE_RECT too

Searched for them with:
git grep -E 
'[!=]=.*PIPE_TEXTURE_2D|PIPE_TEXTURE_2D.*[!=]=|case.*PIPE_TEXTURE_2D'

Behavior hasn't been changed.

---

 src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |7 +--
 src/gallium/auxiliary/util/u_blit.c   |3 ++-
 src/gallium/auxiliary/util/u_blitter.c|3 +++
 src/gallium/auxiliary/util/u_gen_mipmap.c |1 +
 src/gallium/auxiliary/util/u_surfaces.h   |4 ++--
 src/gallium/drivers/i915/i915_resource_texture.c  |5 -
 src/gallium/drivers/i965/brw_resource_texture.c   |4 +++-
 src/gallium/drivers/llvmpipe/lp_screen.c  |1 +
 src/gallium/drivers/llvmpipe/lp_texture.c |1 +
 src/gallium/drivers/nv50/nv50_miptree.c   |3 ++-
 src/gallium/drivers/nv50/nv50_tex.c   |1 +
 src/gallium/drivers/nvfx/nv30_fragtex.c   |1 +
 src/gallium/drivers/nvfx/nv40_fragtex.c   |1 +
 src/gallium/drivers/nvfx/nvfx_miptree.c   |3 ++-
 src/gallium/drivers/r300/r300_hyperz.c|3 ++-
 src/gallium/drivers/r300/r300_texture.c   |6 --
 src/gallium/drivers/r300/r300_texture_desc.c  |6 --
 src/gallium/drivers/r600/r600_state.c |1 +
 src/gallium/drivers/r600/r600_texture.c   |3 ++-
 src/gallium/drivers/softpipe/sp_screen.c  |1 +
 src/gallium/drivers/softpipe/sp_tex_sample.c  |2 ++
 src/gallium/drivers/svga/svga_resource_texture.c  |3 ++-
 src/gallium/drivers/svga/svga_tgsi_emit.h |1 +
 src/gallium/tests/python/tests/texture_blit.py|2 +-
 src/mesa/state_tracker/st_cb_bitmap.c |2 +-
 25 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 806c7d5..f6b6162 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -176,6 +176,7 @@ texture_dims(enum pipe_texture_target tex)
case PIPE_TEXTURE_1D:
   return 1;
case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
case PIPE_TEXTURE_CUBE:
   return 2;
case PIPE_TEXTURE_3D:
@@ -1749,7 +1750,8 @@ lp_build_sample_2d_linear_aos(struct 
lp_build_sample_context *bld,
LLVMValueRef unswizzled[4];
LLVMValueRef stride;
 
-   assert(bld-static_state-target == PIPE_TEXTURE_2D);
+   assert(bld-static_state-target == PIPE_TEXTURE_2D
+ || bld-static_state-target == PIPE_TEXTURE_RECT);
assert(bld-static_state-min_img_filter == PIPE_TEX_FILTER_LINEAR);
assert(bld-static_state-mag_img_filter == PIPE_TEX_FILTER_LINEAR);
assert(bld-static_state-min_mip_filter == PIPE_TEX_MIPFILTER_NONE);
@@ -2077,7 +2079,8 @@ lp_build_sample_soa(LLVMBuilderRef builder,
}
else if (util_format_fits_8unorm(bld.format_desc) 
 bld.format_desc-nr_channels  1 
-static_state-target == PIPE_TEXTURE_2D 
+(static_state-target == PIPE_TEXTURE_2D ||
+  static_state-target == PIPE_TEXTURE_RECT) 
 static_state-min_img_filter == PIPE_TEX_FILTER_LINEAR 
 static_state-mag_img_filter == PIPE_TEX_FILTER_LINEAR 
 static_state-min_mip_filter == PIPE_TEX_MIPFILTER_NONE 
diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 97fa99e..30c7a96 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -347,7 +347,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
dst-face == srcsub.face 
dst-level == srcsub.level 
dst-zslice == srcZ0) ||
-   src_tex-target != PIPE_TEXTURE_2D)
+   (src_tex-target != PIPE_TEXTURE_2D 
+   src_tex-target != PIPE_TEXTURE_RECT))
{
   struct pipe_resource texTemp;
   struct pipe_resource *tex;
diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index 49ee7bb..4b69a7f 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -569,6 +569,8 @@ pipe_tex_to_tgsi_tex(enum pipe_texture_target 
pipe_tex_target)
   return TGSI_TEXTURE_1D;
case PIPE_TEXTURE_2D:
   return TGSI_TEXTURE_2D;
+   case PIPE_TEXTURE_RECT:
+  return TGSI_TEXTURE_2D;
case PIPE_TEXTURE_3D:
   return TGSI_TEXTURE_3D;
case PIPE_TEXTURE_CUBE:
@@ -807,6 +809,7 @@ void util_blitter_copy_region(struct blitter_context 
*blitter,
   /* Draw the quad with the draw_rectangle callback. */
   case PIPE_TEXTURE_1D:
   case PIPE_TEXTURE_2D:
+  case PIPE_TEXTURE_RECT:
 

Mesa (master): u_blitter: use TGSI_TEXTURE_RECT

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: cbe367227959a32ff20e146106162a81d2be02c3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbe367227959a32ff20e146106162a81d2be02c3

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 17:30:20 2010 +0200

u_blitter: use TGSI_TEXTURE_RECT

This seems to make sense, although I suspect the semantics of
TGSI_TEXTURE_RECT need to be closely reviewed.

---

 src/gallium/auxiliary/util/u_blitter.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index 4b69a7f..9c6887b 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -570,7 +570,7 @@ pipe_tex_to_tgsi_tex(enum pipe_texture_target 
pipe_tex_target)
case PIPE_TEXTURE_2D:
   return TGSI_TEXTURE_2D;
case PIPE_TEXTURE_RECT:
-  return TGSI_TEXTURE_2D;
+  return TGSI_TEXTURE_RECT;
case PIPE_TEXTURE_3D:
   return TGSI_TEXTURE_3D;
case PIPE_TEXTURE_CUBE:

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


Mesa (master): u_staging: use PIPE_TEXTURE_RECT

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 4a9bfb24eb907080b2e3e49215ad9912758d56c6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a9bfb24eb907080b2e3e49215ad9912758d56c6

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 22:57:02 2010 +0200

u_staging: use PIPE_TEXTURE_RECT

---

 src/gallium/auxiliary/util/u_staging.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_staging.c 
b/src/gallium/auxiliary/util/u_staging.c
index 607c31f..e2dc696 100644
--- a/src/gallium/auxiliary/util/u_staging.c
+++ b/src/gallium/auxiliary/util/u_staging.c
@@ -8,7 +8,7 @@ util_staging_resource_template(struct pipe_resource *pt, 
unsigned width, unsigne
 {
memset(template, 0, sizeof(struct pipe_resource));
if(pt-target != PIPE_BUFFER  depth = 1)
-  template-target = PIPE_TEXTURE_2D;
+  template-target = PIPE_TEXTURE_RECT;
else
   template-target = pt-target;
template-format = pt-format;

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


Mesa (master): mesa/st: support using PIPE_TEXTURE_RECT internally

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 3070e0ea41ab4aa24804e8fd26895924a8583830
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3070e0ea41ab4aa24804e8fd26895924a8583830

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug  6 07:39:21 2010 +0200

mesa/st: support using PIPE_TEXTURE_RECT internally

Currently Gallium internals always use PIPE_TEXTURE_2D and normalized
coordinates to access textures.

However, PIPE_TEXTURE_2D is not always supported for NPOT textures,
and PIPE_TEXTURE_RECT requires unnormalized coordinates.

Hence, this change adds support for both kinds of normalization.

---

 src/mesa/state_tracker/st_cb_bitmap.c |   23 ++-
 src/mesa/state_tracker/st_cb_drawpixels.c |   42 ++--
 src/mesa/state_tracker/st_cb_fbo.c|2 +-
 src/mesa/state_tracker/st_context.c   |5 +++
 src/mesa/state_tracker/st_context.h   |3 +-
 5 files changed, 32 insertions(+), 43 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bitmap.c 
b/src/mesa/state_tracker/st_cb_bitmap.c
index 91037ab..d40e413 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -275,7 +275,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei 
height,
/**
 * Create texture to hold bitmap pattern.
 */
-   pt = st_texture_create(st, PIPE_TEXTURE_2D, st-bitmap.tex_format,
+   pt = st_texture_create(st, st-internal_target, st-bitmap.tex_format,
   0, width, height, 1,
   PIPE_BIND_SAMPLER_VIEW);
if (!pt) {
@@ -304,7 +304,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei 
height,
 }
 
 static GLuint
-setup_bitmap_vertex_data(struct st_context *st,
+setup_bitmap_vertex_data(struct st_context *st, bool normalized,
  int x, int y, int width, int height,
  float z, const float color[4])
 {
@@ -316,13 +316,19 @@ setup_bitmap_vertex_data(struct st_context *st,
const GLfloat x1 = (GLfloat)(x + width);
const GLfloat y0 = (GLfloat)y;
const GLfloat y1 = (GLfloat)(y + height);
-   const GLfloat sLeft = (GLfloat)0.0, sRight = (GLfloat)1.0;
-   const GLfloat tTop = (GLfloat)0.0, tBot = (GLfloat)1.0 - tTop;
+   GLfloat sLeft = (GLfloat)0.0, sRight = (GLfloat)1.0;
+   GLfloat tTop = (GLfloat)0.0, tBot = (GLfloat)1.0 - tTop;
const GLfloat clip_x0 = (GLfloat)(x0 / fb_width * 2.0 - 1.0);
const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0);
const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0);
const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0);
 
+   if(!normalized)
+   {
+  sRight = width;
+  tBot = height;
+   }
+
/* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
 * no_flush) updates to buffers where we know there is no conflict
 * with previous data.  Currently using max_slots  1 will cause
@@ -462,7 +468,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat 
z,
   for (i = 0; i  st-state.num_samplers; i++) {
  samplers[i] = st-state.samplers[i];
   }
-  samplers[stfp-bitmap_sampler] = st-bitmap.sampler;
+  samplers[stfp-bitmap_sampler] = 
st-bitmap.samplers[sv-texture-target != PIPE_TEXTURE_RECT];
   cso_set_samplers(cso, num, (const struct pipe_sampler_state **) 
samplers);
}
 
@@ -499,7 +505,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat 
z,
z = z * 2.0 - 1.0;
 
/* draw textured quad */
-   offset = setup_bitmap_vertex_data(st, x, y, width, height, z, color);
+   offset = setup_bitmap_vertex_data(st, sv-texture-target != 
PIPE_TEXTURE_RECT, x, y, width, height, z, color);
 
util_draw_vertex_buffer(pipe, st-bitmap.vbuf, offset,
PIPE_PRIM_TRIANGLE_FAN,
@@ -789,7 +795,7 @@ st_init_bitmap_functions(struct dd_function_table 
*functions)
 void
 st_init_bitmap(struct st_context *st)
 {
-   struct pipe_sampler_state *sampler = st-bitmap.sampler;
+   struct pipe_sampler_state *sampler = st-bitmap.samplers[0];
struct pipe_context *pipe = st-pipe;
struct pipe_screen *screen = pipe-screen;
 
@@ -801,7 +807,8 @@ st_init_bitmap(struct st_context *st)
sampler-min_img_filter = PIPE_TEX_FILTER_NEAREST;
sampler-min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
sampler-mag_img_filter = PIPE_TEX_FILTER_NEAREST;
-   sampler-normalized_coords = 1;
+   st-bitmap.samplers[1] = *sampler;
+   st-bitmap.samplers[1].normalized_coords = 1;
 
/* init baseline rasterizer state once */
memset(st-bitmap.rasterizer, 0, sizeof(st-bitmap.rasterizer));
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 69a3dd4..d934fdc 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -304,34 +304,9 @@ alloc_texture(struct st_context *st, GLsizei width, 
GLsizei height,
struct pipe_context *pipe = st-pipe;
struct pipe_screen 

Mesa (master): auxiliary: support using PIPE_TEXTURE_RECT internally

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: d4ec85e62423336d3cddc45f26bef6764f435a18
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4ec85e62423336d3cddc45f26bef6764f435a18

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug  6 07:39:21 2010 +0200

auxiliary: support using PIPE_TEXTURE_RECT internally

Currently Gallium internals always use PIPE_TEXTURE_2D and normalized
coordinates to access textures.

However, PIPE_TEXTURE_2D is not always supported for NPOT textures,
and PIPE_TEXTURE_RECT requires unnormalized coordinates.

Hence, this change adds support for both kinds of normalization.

---

 src/gallium/auxiliary/util/u_blit.c|   67 
 src/gallium/auxiliary/util/u_blitter.c |   48 +++
 2 files changed, 81 insertions(+), 34 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 30c7a96..6fb341e 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -62,6 +62,7 @@ struct blit_state
struct pipe_viewport_state viewport;
struct pipe_clip_state clip;
struct pipe_vertex_element velem[2];
+   enum pipe_texture_target internal_target;
 
void *vs;
void *fs[TGSI_WRITEMASK_XYZW + 1];
@@ -110,7 +111,6 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
ctx-sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
ctx-sampler.min_img_filter = 0; /* set later */
ctx-sampler.mag_img_filter = 0; /* set later */
-   ctx-sampler.normalized_coords = 1;
 
/* vertex elements state */
memset(ctx-velem[0], 0, sizeof(ctx-velem[0]) * 2);
@@ -145,6 +145,11 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
   ctx-vertices[i][1][3] = 1.0f; /* q */
}
 
+   if(pipe-screen-get_param(pipe-screen, PIPE_CAP_NPOT_TEXTURES))
+  ctx-internal_target = PIPE_TEXTURE_2D;
+   else
+  ctx-internal_target = PIPE_TEXTURE_RECT;
+
return ctx;
 }
 
@@ -296,6 +301,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
unsigned offset;
boolean overlap;
float s0, t0, s1, t1;
+   boolean normalized;
 
assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
   filter == PIPE_TEX_MIPFILTER_LINEAR);
@@ -335,7 +341,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
   return;
}
 
-
/* Create a temporary texture when src and dest alias or when src
 * is anything other than a 2d texture.
 * XXX should just use appropriate shader to access 1d / 3d slice / cube 
face,
@@ -373,7 +378,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
 
   /* create temp texture */
   memset(texTemp, 0, sizeof(texTemp));
-  texTemp.target = PIPE_TEXTURE_2D;
+  texTemp.target = ctx-internal_target;
   texTemp.format = src_tex-format;
   texTemp.last_level = 0;
   texTemp.width0 = srcW;
@@ -393,10 +398,19 @@ util_blit_pixels_writemask(struct blit_state *ctx,
  src_tex, srcsub, srcLeft, srcTop, srcZ0, /* 
src */
  srcW, srcH); /* size */
 
-  s0 = 0.0f; 
-  s1 = 1.0f;
-  t0 = 0.0f;
-  t1 = 1.0f;
+  normalized = tex-target != PIPE_TEXTURE_RECT;
+  if(normalized) {
+ s0 = 0.0f;
+ s1 = 1.0f;
+ t0 = 0.0f;
+ t1 = 1.0f;
+  }
+  else {
+ s0 = 0;
+ s1 = srcW;
+ t0 = 0;
+ t1 = srcH;
+  }
 
   u_sampler_view_default_template(sv_templ, tex, tex-format);
   sampler_view = pipe-create_sampler_view(pipe, tex, sv_templ);
@@ -416,17 +430,25 @@ util_blit_pixels_writemask(struct blit_state *ctx,
  return;
   }
 
-  s0 = srcX0 / (float)(u_minify(sampler_view-texture-width0, 
srcsub.level));
-  s1 = srcX1 / (float)(u_minify(sampler_view-texture-width0, 
srcsub.level));
-  t0 = srcY0 / (float)(u_minify(sampler_view-texture-height0, 
srcsub.level));
-  t1 = srcY1 / (float)(u_minify(sampler_view-texture-height0, 
srcsub.level));
+  s0 = srcX0;
+  s1 = srcX1;
+  t0 = srcY0;
+  t1 = srcY1;
+  normalized = sampler_view-texture-target != PIPE_TEXTURE_RECT;
+  if(normalized)
+  {
+ s0 /= (float)(u_minify(sampler_view-texture-width0, srcsub.level));
+ s1 /= (float)(u_minify(sampler_view-texture-width0, srcsub.level));
+ t0 /= (float)(u_minify(sampler_view-texture-height0, srcsub.level));
+ t1 /= (float)(u_minify(sampler_view-texture-height0, srcsub.level));
+  }
}
 
 
-   assert(screen-is_format_supported(screen, sampler_view-format, 
PIPE_TEXTURE_2D,
+   assert(screen-is_format_supported(screen, sampler_view-format, 
ctx-internal_target,
   sampler_view-texture-nr_samples,
   PIPE_BIND_SAMPLER_VIEW, 0));
-   assert(screen-is_format_supported(screen, dst-format, PIPE_TEXTURE_2D,
+   assert(screen-is_format_supported(screen, dst-format, 

Mesa (master): st/dri: use PIPE_TEXTURE_RECT if appropriate

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 4a5acc0ec7d6d94ea2a73b3d8ee498f75e929a1c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a5acc0ec7d6d94ea2a73b3d8ee498f75e929a1c

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 22:57:22 2010 +0200

st/dri: use PIPE_TEXTURE_RECT if appropriate

---

 src/gallium/state_trackers/dri/common/dri_screen.c |5 +
 src/gallium/state_trackers/dri/common/dri_screen.h |1 +
 src/gallium/state_trackers/dri/drm/dri2.c  |4 ++--
 src/gallium/state_trackers/dri/sw/drisw.c  |2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c 
b/src/gallium/state_trackers/dri/common/dri_screen.c
index 6ad2c7d..0ab4dd1 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.c
+++ b/src/gallium/state_trackers/dri/common/dri_screen.c
@@ -383,6 +383,11 @@ dri_init_screen_helper(struct dri_screen *screen,
if (!screen-st_api)
   return NULL;
 
+   if(pscreen-get_param(pscreen, PIPE_CAP_NPOT_TEXTURES))
+  screen-target = PIPE_TEXTURE_2D;
+   else
+  screen-target = PIPE_TEXTURE_RECT;
+
driParseOptionInfo(screen-optionCache,
   __driConfigOptions, __driNConfigOptions);
 
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h 
b/src/gallium/state_trackers/dri/common/dri_screen.h
index 53ccce1..849f399 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.h
+++ b/src/gallium/state_trackers/dri/common/dri_screen.h
@@ -68,6 +68,7 @@ struct dri_screen
boolean d_depth_bits_last;
boolean sd_depth_bits_last;
boolean auto_fake_front;
+   enum pipe_texture_target target;
 };
 
 /** cast wrapper */
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 47005c1..93f910a 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -195,7 +195,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
   pipe_resource_reference(drawable-textures[i], NULL);
 
memset(templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = screen-target;
templ.last_level = 0;
templ.width0 = dri_drawable-w;
templ.height0 = dri_drawable-h;
@@ -342,7 +342,7 @@ dri2_create_image_from_name(__DRIcontext *context,
memset(templ, 0, sizeof(templ));
templ.bind = tex_usage;
templ.format = pf;
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = screen-target;
templ.last_level = 0;
templ.width0 = width;
templ.height0 = height;
diff --git a/src/gallium/state_trackers/dri/sw/drisw.c 
b/src/gallium/state_trackers/dri/sw/drisw.c
index 249ccd7..04bba63 100644
--- a/src/gallium/state_trackers/dri/sw/drisw.c
+++ b/src/gallium/state_trackers/dri/sw/drisw.c
@@ -216,7 +216,7 @@ drisw_allocate_textures(struct dri_drawable *drawable,
}
 
memset(templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = screen-target;
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;

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


Mesa (master): st/glx: use PIPE_TEXTURE_RECT if appropriate

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: d34f6e9db15a1fa3a7e3b68e47ac4eef2706b8cd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d34f6e9db15a1fa3a7e3b68e47ac4eef2706b8cd

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Aug 19 00:55:13 2010 +0200

st/glx: use PIPE_TEXTURE_RECT if appropriate

---

 src/gallium/state_trackers/glx/xlib/xm_st.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c 
b/src/gallium/state_trackers/glx/xlib/xm_st.c
index c62eb8b..9cd744c 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_st.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
@@ -38,6 +38,7 @@ struct xmesa_st_framebuffer {
struct pipe_screen *screen;
 
struct st_visual stvis;
+   enum pipe_texture_target target;
 
unsigned texture_width, texture_height, texture_mask;
struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
@@ -139,7 +140,7 @@ xmesa_st_framebuffer_validate_textures(struct 
st_framebuffer_iface *stfbi,
}
 
memset(templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = xstfb-target;
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
@@ -279,6 +280,10 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, 
XMesaBuffer b)
xstfb-buffer = b;
xstfb-screen = xmdpy-screen;
xstfb-stvis = b-xm_visual-stvis;
+   if(xstfb-screen-get_param(xstfb-screen, PIPE_CAP_NPOT_TEXTURES))
+  xstfb-target = PIPE_TEXTURE_2D;
+   else
+  xstfb-target = PIPE_TEXTURE_RECT;
 
stfbi-visual = xstfb-stvis;
stfbi-flush_front = xmesa_st_framebuffer_flush_front;

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


Mesa (master): winsys/sw: use PIPE_TEXTURE_RECT if appropriate

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 96a82cc314667542b7e046311595f58b01704205
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=96a82cc314667542b7e046311595f58b01704205

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Aug 19 01:44:02 2010 +0200

winsys/sw: use PIPE_TEXTURE_RECT if appropriate

---

 src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c 
b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index b997abd..3a76098 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -52,6 +52,7 @@ struct wrapper_sw_winsys
struct sw_winsys base;
struct pipe_screen *screen;
struct pipe_context *pipe;
+   enum pipe_texture_target target;
 };
 
 struct wrapper_sw_displaytarget
@@ -145,7 +146,7 @@ wsw_dt_create(struct sw_winsys *ws,
 * XXX Why don't we just get the template.
 */
memset(templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = wsw-target;
templ.width0 = width;
templ.height0 = height;
templ.format = format;
@@ -291,6 +292,11 @@ wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen 
*screen)
if (!wsw-pipe)
   goto err_free;
 
+   if(screen-get_param(screen, PIPE_CAP_NPOT_TEXTURES))
+  wsw-target = PIPE_TEXTURE_2D;
+   else
+  wsw-target = PIPE_TEXTURE_RECT;
+
return wsw-base;
 
 err_free:

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


Mesa (master): mesa/st: use PIPE_TEXTURE_RECT for GL_TEXTURE_RECTANGLE

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 7f15dca6d963b0a69131e8761c477064dba49307
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f15dca6d963b0a69131e8761c477064dba49307

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Apr 15 09:04:20 2010 +0200

mesa/st: use PIPE_TEXTURE_RECT for GL_TEXTURE_RECTANGLE

---

 src/mesa/state_tracker/st_cb_texture.c |6 --
 src/mesa/state_tracker/st_texture.c|2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 4c3e368..a41c780 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -74,9 +74,11 @@ gl_target_to_pipe(GLenum target)
   return PIPE_TEXTURE_1D;
 
case GL_TEXTURE_2D:
-   case GL_TEXTURE_RECTANGLE_NV:
   return PIPE_TEXTURE_2D;
 
+   case GL_TEXTURE_RECTANGLE_NV:
+  return PIPE_TEXTURE_RECT;
+
case GL_TEXTURE_3D:
   return PIPE_TEXTURE_3D;
 
@@ -449,7 +451,7 @@ compress_with_blit(GLcontext * ctx,
/* Create the temporary source texture
 */
memset(templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
+   templ.target = st-internal_target;
templ.format = st_mesa_format_to_pipe_format(mesa_format);
templ.width0 = width;
templ.height0 = height;
diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index add6e94..c6cf2ba 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -64,7 +64,7 @@ st_texture_create(struct st_context *st,
struct pipe_resource pt, *newtex;
struct pipe_screen *screen = st-pipe-screen;
 
-   assert(target = PIPE_TEXTURE_CUBE);
+   assert(target  PIPE_MAX_TEXTURE_TYPES);
assert(width0  0);
assert(height0  0);
assert(depth0  0);

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


Mesa (master): nv50: use NV50TIC_0_2_TARGET_RECT

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 09bf09cf92c3958c3b8268f38387804084ca30e2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=09bf09cf92c3958c3b8268f38387804084ca30e2

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 17:29:59 2010 +0200

nv50: use NV50TIC_0_2_TARGET_RECT

---

 src/gallium/drivers/nv50/nv50_tex.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_tex.c 
b/src/gallium/drivers/nv50/nv50_tex.c
index 4db53f7..d41d9c5 100644
--- a/src/gallium/drivers/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nv50/nv50_tex.c
@@ -131,9 +131,11 @@ nv50_tex_construct(struct nv50_sampler_view *view)
tic[2] |= NV50TIC_0_2_TARGET_1D;
break;
case PIPE_TEXTURE_2D:
-   case PIPE_TEXTURE_RECT:
tic[2] |= NV50TIC_0_2_TARGET_2D;
break;
+   case PIPE_TEXTURE_RECT:
+   tic[2] |= NV50TIC_0_2_TARGET_RECT;
+   break;
case PIPE_TEXTURE_3D:
tic[2] |= NV50TIC_0_2_TARGET_3D;
break;

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


Mesa (master): galahad: check resource_create template

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: ccd08643577988d416b339b84fe7bfda6fb77ef6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ccd08643577988d416b339b84fe7bfda6fb77ef6

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Aug 19 01:38:33 2010 +0200

galahad: check resource_create template

---

 src/gallium/drivers/galahad/glhd_screen.c |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/galahad/glhd_screen.c 
b/src/gallium/drivers/galahad/glhd_screen.c
index e1a1b59..2d7383a 100644
--- a/src/gallium/drivers/galahad/glhd_screen.c
+++ b/src/gallium/drivers/galahad/glhd_screen.c
@@ -30,6 +30,7 @@
 #include pipe/p_screen.h
 #include pipe/p_state.h
 #include util/u_memory.h
+#include util/u_math.h
 
 #include glhd_public.h
 #include glhd_screen.h
@@ -134,6 +135,34 @@ galahad_screen_resource_create(struct pipe_screen *_screen,
struct pipe_screen *screen = glhd_screen-screen;
struct pipe_resource *result;
 
+   if (templat-target = PIPE_MAX_TEXTURE_TYPES)
+  glhd_warn(Received bogus resource target %d, templat-target);
+
+   if(templat-target != PIPE_TEXTURE_RECT  templat-target != PIPE_BUFFER 
 !screen-get_param(screen, PIPE_CAP_NPOT_TEXTURES))
+   {
+  if(!util_is_pot(templat-width0) || !util_is_pot(templat-height0))
+ glhd_warn(Requested NPOT (%ux%u) non-rectangle texture without NPOT 
support, templat-width0, templat-height0);
+   }
+
+   /* TODO: allow this for OpenCL flexible sampling */
+   if(templat-target == PIPE_TEXTURE_RECT  templat-last_level)
+  glhd_warn(Rectangle textures cannot have mipmaps, but last_level = %u, 
templat-last_level);
+
+   if(templat-target == PIPE_BUFFER  templat-last_level)
+  glhd_warn(Buffers cannot have mipmaps, but last_level = %u, 
templat-last_level);
+
+   if(templat-target != PIPE_TEXTURE_3D  templat-depth0 != 1)
+  glhd_warn(Only 3D textures can have depth != 1, but received target %u 
and depth %u, templat-target, templat-depth0);
+
+   if(templat-target == PIPE_TEXTURE_1D  templat-height0 != 1)
+ glhd_warn(1D textures must have height 1 but got asked for height %u, 
templat-height0);
+
+   if(templat-target == PIPE_BUFFER  templat-height0 != 1)
+ glhd_warn(Buffers must have height 1 but got asked for height %u, 
templat-height0);
+
+   if(templat-target == PIPE_TEXTURE_CUBE  templat-width0 != 
templat-height0)
+  glhd_warn(Cube maps must be square, but got asked for %ux%u, 
templat-width0, templat-height0);
+
result = screen-resource_create(screen,
 templat);
 

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


Mesa (master): galahad: remove incorrect comment just added

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 7344e6d9b50e39960713503681d6b37299ce2ccf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7344e6d9b50e39960713503681d6b37299ce2ccf

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug 20 12:06:44 2010 +0200

galahad: remove incorrect comment just added

---

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

diff --git a/src/gallium/drivers/galahad/glhd_screen.c 
b/src/gallium/drivers/galahad/glhd_screen.c
index 2d7383a..a4eac11 100644
--- a/src/gallium/drivers/galahad/glhd_screen.c
+++ b/src/gallium/drivers/galahad/glhd_screen.c
@@ -144,7 +144,6 @@ galahad_screen_resource_create(struct pipe_screen *_screen,
  glhd_warn(Requested NPOT (%ux%u) non-rectangle texture without NPOT 
support, templat-width0, templat-height0);
}
 
-   /* TODO: allow this for OpenCL flexible sampling */
if(templat-target == PIPE_TEXTURE_RECT  templat-last_level)
   glhd_warn(Rectangle textures cannot have mipmaps, but last_level = %u, 
templat-last_level);
 

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


Mesa (master): st/mesa: fix code/declaration mixing

2010-08-20 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 4df17f9dfea527b83a896aabd9944e3563cb4a0e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4df17f9dfea527b83a896aabd9944e3563cb4a0e

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Aug 20 11:52:01 2010 +0100

st/mesa: fix code/declaration mixing

---

 src/mesa/state_tracker/st_cb_bitmap.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bitmap.c 
b/src/mesa/state_tracker/st_cb_bitmap.c
index d40e413..8da5cbb 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -322,6 +322,8 @@ setup_bitmap_vertex_data(struct st_context *st, bool 
normalized,
const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0);
const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0);
const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0);
+   const GLuint max_slots = 1; /* 4096 / sizeof(st-bitmap.vertices); */
+   GLuint i;
 
if(!normalized)
{
@@ -339,9 +341,6 @@ setup_bitmap_vertex_data(struct st_context *st, bool 
normalized,
 * price of allocating a new buffer for each bitmap cache-flush to
 * avoid synchronous rendering.
 */
-   const GLuint max_slots = 1; /* 4096 / sizeof(st-bitmap.vertices); */
-   GLuint i;
-
if (st-bitmap.vbuf_slot = max_slots) {
   pipe_resource_reference(st-bitmap.vbuf, NULL);
   st-bitmap.vbuf_slot = 0;

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


Mesa (master): egl: Allow core functions to be queried.

2010-08-20 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: f508c0c09702a5ea53dcb58721f3674605594c6e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f508c0c09702a5ea53dcb58721f3674605594c6e

Author: Chia-I Wu o...@lunarg.com
Date:   Fri Aug 20 12:35:02 2010 +0800

egl: Allow core functions to be queried.

When _EGL_GET_CORE_ADDRESSES is defined, eglGetProcAddress can be used to query
core functions.  This is non-standard, but some apps expect it.

---

 src/egl/main/SConscript |1 +
 src/egl/main/eglapi.c   |   39 ++-
 2 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript
index c7ba45c..1e4d4f3 100644
--- a/src/egl/main/SConscript
+++ b/src/egl/main/SConscript
@@ -12,6 +12,7 @@ if env['platform'] != 'winddk':
'_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_WINDOWS',
'_EGL_DRIVER_SEARCH_DIR=',
'_EGL_OS_WINDOWS',
+   '_EGL_GET_CORE_ADDRESSES',
'KHRONOS_DLL_EXPORTS',
])
 
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 53a5f6e..c62459e 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -832,7 +832,44 @@ eglGetProcAddress(const char *procname)
   const char *name;
   _EGLProc function;
} egl_functions[] = {
-  /* extensions only */
+  /* core functions should not be queryable, but, well... */
+#ifdef _EGL_GET_CORE_ADDRESSES
+  /* alphabetical order */
+  { eglBindAPI, (_EGLProc) eglBindAPI },
+  { eglBindTexImage, (_EGLProc) eglBindTexImage },
+  { eglChooseConfig, (_EGLProc) eglChooseConfig },
+  { eglCopyBuffers, (_EGLProc) eglCopyBuffers },
+  { eglCreateContext, (_EGLProc) eglCreateContext },
+  { eglCreatePbufferFromClientBuffer, (_EGLProc) 
eglCreatePbufferFromClientBuffer },
+  { eglCreatePbufferSurface, (_EGLProc) eglCreatePbufferSurface },
+  { eglCreatePixmapSurface, (_EGLProc) eglCreatePixmapSurface },
+  { eglCreateWindowSurface, (_EGLProc) eglCreateWindowSurface },
+  { eglDestroyContext, (_EGLProc) eglDestroyContext },
+  { eglDestroySurface, (_EGLProc) eglDestroySurface },
+  { eglGetConfigAttrib, (_EGLProc) eglGetConfigAttrib },
+  { eglGetConfigs, (_EGLProc) eglGetConfigs },
+  { eglGetCurrentContext, (_EGLProc) eglGetCurrentContext },
+  { eglGetCurrentDisplay, (_EGLProc) eglGetCurrentDisplay },
+  { eglGetCurrentSurface, (_EGLProc) eglGetCurrentSurface },
+  { eglGetDisplay, (_EGLProc) eglGetDisplay },
+  { eglGetError, (_EGLProc) eglGetError },
+  { eglGetProcAddress, (_EGLProc) eglGetProcAddress },
+  { eglInitialize, (_EGLProc) eglInitialize },
+  { eglMakeCurrent, (_EGLProc) eglMakeCurrent },
+  { eglQueryAPI, (_EGLProc) eglQueryAPI },
+  { eglQueryContext, (_EGLProc) eglQueryContext },
+  { eglQueryString, (_EGLProc) eglQueryString },
+  { eglQuerySurface, (_EGLProc) eglQuerySurface },
+  { eglReleaseTexImage, (_EGLProc) eglReleaseTexImage },
+  { eglReleaseThread, (_EGLProc) eglReleaseThread },
+  { eglSurfaceAttrib, (_EGLProc) eglSurfaceAttrib },
+  { eglSwapBuffers, (_EGLProc) eglSwapBuffers },
+  { eglSwapInterval, (_EGLProc) eglSwapInterval },
+  { eglTerminate, (_EGLProc) eglTerminate },
+  { eglWaitClient, (_EGLProc) eglWaitClient },
+  { eglWaitGL, (_EGLProc) eglWaitGL },
+  { eglWaitNative, (_EGLProc) eglWaitNative },
+#endif /* _EGL_GET_CORE_ADDRESSES */
 #ifdef EGL_MESA_screen_surface
   { eglChooseModeMESA, (_EGLProc) eglChooseModeMESA },
   { eglGetModesMESA, (_EGLProc) eglGetModesMESA },

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


Mesa (master): egl: Add egl.def for win32 build.

2010-08-20 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: ce2cae4130548872a0205097b0b5dbe0f4f57d5f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce2cae4130548872a0205097b0b5dbe0f4f57d5f

Author: Chia-I Wu o...@lunarg.com
Date:   Fri Aug 20 12:41:46 2010 +0800

egl: Add egl.def for win32 build.

Without the .def file, function names are decorated and cannot be
queried by GetProcAddress easily.

---

 src/egl/main/SConscript |2 +-
 src/egl/main/egl.def|   35 +++
 2 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript
index 1e4d4f3..0684647 100644
--- a/src/egl/main/SConscript
+++ b/src/egl/main/SConscript
@@ -42,7 +42,7 @@ if env['platform'] != 'winddk':
 
egl = env.SharedLibrary(
target = 'libEGL',
-   source = egl_sources,
+   source = egl_sources + ['egl.def'],
)
 
env.InstallSharedLibrary(egl, version=(1, 4, 0))
diff --git a/src/egl/main/egl.def b/src/egl/main/egl.def
new file mode 100644
index 000..0cfe920
--- /dev/null
+++ b/src/egl/main/egl.def
@@ -0,0 +1,35 @@
+EXPORTS
+   eglBindAPI
+   eglBindTexImage
+   eglChooseConfig
+   eglCopyBuffers
+   eglCreateContext
+   eglCreatePbufferFromClientBuffer
+   eglCreatePbufferSurface
+   eglCreatePixmapSurface
+   eglCreateWindowSurface
+   eglDestroyContext
+   eglDestroySurface
+   eglGetConfigAttrib
+   eglGetConfigs
+   eglGetCurrentContext
+   eglGetCurrentDisplay
+   eglGetCurrentSurface
+   eglGetDisplay
+   eglGetError
+   eglGetProcAddress
+   eglInitialize
+   eglMakeCurrent
+   eglQueryAPI
+   eglQueryContext
+   eglQueryString
+   eglQuerySurface
+   eglReleaseTexImage
+   eglReleaseThread
+   eglSurfaceAttrib
+   eglSwapBuffers
+   eglSwapInterval
+   eglTerminate
+   eglWaitClient
+   eglWaitGL
+   eglWaitNative

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


Mesa (master): targets/egl-gdi: Implement guess_gl_api.

2010-08-20 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 5004f823ad3c82ec0b50822a4889798c81ce1cfc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5004f823ad3c82ec0b50822a4889798c81ce1cfc

Author: Chia-I Wu o...@lunarg.com
Date:   Fri Aug 20 12:58:52 2010 +0800

targets/egl-gdi: Implement guess_gl_api.

It is needed to support calling eglGetProcAddress before eglInitialize.

---

 src/gallium/targets/egl-gdi/egl-static.c |   39 -
 1 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/gallium/targets/egl-gdi/egl-static.c 
b/src/gallium/targets/egl-gdi/egl-static.c
index ec2f865..4655d79 100644
--- a/src/gallium/targets/egl-gdi/egl-static.c
+++ b/src/gallium/targets/egl-gdi/egl-static.c
@@ -33,6 +33,8 @@
 #include target-helpers/inline_debug_helper.h
 #include egldriver.h
 
+static struct st_api *stapis[ST_API_COUNT];
+
 static uint
 get_api_mask(void)
 {
@@ -57,7 +59,11 @@ get_api_mask(void)
 static struct st_api *
 get_st_api(enum st_api_type api)
 {
-   struct st_api *stapi = NULL;
+   struct st_api *stapi;
+
+   stapi = stapis[api];
+   if (stapi)
+  return stapi;
 
switch (api) {
 #if FEATURE_GL
@@ -84,13 +90,33 @@ get_st_api(enum st_api_type api)
  break;
}
 
+   stapis[api] = stapi;
+
return stapi;
 }
 
 static struct st_api *
 guess_gl_api(void)
 {
-   return NULL;
+   struct st_api *stapi = NULL;
+
+#if FEATURE_GL
+   stapi = get_st_api(ST_API_OPENGL);
+   if (stapi)
+  return stapi;
+#endif
+#if FEATURE_ES1
+   stapi = get_st_api(ST_API_OPENGL_ES1);
+   if (stapi)
+  return stapi;
+#endif
+#if FEATURE_ES2
+   stapi = get_st_api(ST_API_OPENGL_ES2);
+   if (stapi)
+  return stapi;
+#endif
+
+   return stapi;
 }
 
 static struct pipe_screen *
@@ -127,7 +153,16 @@ init_loader(struct egl_g3d_loader *loader)
 static void
 egl_g3d_unload(_EGLDriver *drv)
 {
+   int i;
+
egl_g3d_destroy_driver(drv);
+
+   for (i = 0; i  ST_API_COUNT; i++) {
+  if (stapis[i]) {
+ stapis[i]-destroy(stapis[i]);
+ stapis[i] = NULL;
+  }
+   }
 }
 
 static struct egl_g3d_loader loader;

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


Mesa (master): egl: Fix context API check and be verbose.

2010-08-20 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 5eb33596a0db26586957365ab27fc6afdebfe057
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5eb33596a0db26586957365ab27fc6afdebfe057

Author: Chia-I Wu o...@lunarg.com
Date:   Fri Aug 20 13:19:10 2010 +0800

egl: Fix context API check and be verbose.

The API of the context was not checked against EGL_RENDERABLE_TYPE when there
was no attribute list.  Move the check to _eglInitContext, and be verbose about
common mistakes (EGL_RENDERABLE_TYPE not set, EGL_CONTEXT_CLIENT_VERSION not
set, or eglBindAPI not called).

---

 src/egl/main/eglconfig.c  |7 +--
 src/egl/main/eglcontext.c |   20 +++-
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index ea8e47d..01e7144 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -460,11 +460,14 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig 
*criteria)
   }
 
   if (!matched) {
-#ifdef DEBUG
+#ifndef DEBUG
+ /* only print the common errors when DEBUG is not defined */
+ if (attr != EGL_RENDERABLE_TYPE)
+break;
+#endif
  _eglLog(_EGL_DEBUG,
the value (0x%x) of attribute 0x%04x did not meet the criteria 
(0x%x),
val, attr, cmp);
-#endif
  break;
   }
}
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index 9fc5296..e72664c 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -83,15 +83,6 @@ _eglParseContextAttribList(_EGLContext *ctx, const EGLint 
*attrib_list)
   }
}
 
-   if (err == EGL_SUCCESS  ctx-Config) {
-  EGLint renderable_type, api_bit;
-
-  renderable_type = GET_CONFIG_ATTRIB(ctx-Config, EGL_RENDERABLE_TYPE);
-  api_bit = _eglGetContextAPIBit(ctx);
-  if (!(renderable_type  api_bit))
- err = EGL_BAD_CONFIG;
-   }
-
return err;
 }
 
@@ -121,6 +112,17 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, 
_EGLConfig *conf,
ctx-ClientVersion = 1; /* the default, per EGL spec */
 
err = _eglParseContextAttribList(ctx, attrib_list);
+   if (err == EGL_SUCCESS  ctx-Config) {
+  EGLint renderable_type, api_bit;
+
+  renderable_type = GET_CONFIG_ATTRIB(ctx-Config, EGL_RENDERABLE_TYPE);
+  api_bit = _eglGetContextAPIBit(ctx);
+  if (!(renderable_type  api_bit)) {
+ _eglLog(_EGL_DEBUG, context api is 0x%x while config supports 0x%x,
+   api_bit, renderable_type);
+ err = EGL_BAD_CONFIG;
+  }
+   }
if (err != EGL_SUCCESS)
   return _eglError(err, eglCreateContext);
 

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


Mesa (master): mesa: Include compiler.h for ASSERT.

2010-08-20 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 8043bf555e14cf20826753d59d66d0cef7a5e5a0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8043bf555e14cf20826753d59d66d0cef7a5e5a0

Author: Chia-I Wu o...@lunarg.com
Date:   Fri Aug 20 10:27:26 2010 +0800

mesa: Include compiler.h for ASSERT.

mfeatures.h defines ASSERT_NO_FEATURE to ASSERT, which is defined in
compiler.h.  Header files using the macro should include compiler.h.

---

 src/mesa/main/accum.h|2 ++
 src/mesa/main/attrib.h   |2 ++
 src/mesa/main/colortab.h |2 ++
 src/mesa/main/convolve.h |2 ++
 src/mesa/main/dlist.h|2 ++
 src/mesa/main/feedback.h |2 ++
 src/mesa/state_tracker/st_cb_accum.h |2 ++
 7 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/accum.h b/src/mesa/main/accum.h
index 63740f0..c2b74b2 100644
--- a/src/mesa/main/accum.h
+++ b/src/mesa/main/accum.h
@@ -55,6 +55,8 @@ _mesa_init_accum_dispatch(struct _glapi_table *disp);
 
 #else /* FEATURE_accum */
 
+#include main/compiler.h
+
 #define _MESA_INIT_ACCUM_FUNCTIONS(driver, impl) do { } while (0)
 
 static INLINE void
diff --git a/src/mesa/main/attrib.h b/src/mesa/main/attrib.h
index 6b48a17..83b28a6 100644
--- a/src/mesa/main/attrib.h
+++ b/src/mesa/main/attrib.h
@@ -48,6 +48,8 @@ _mesa_init_attrib_dispatch(struct _glapi_table *disp);
 
 #else /* FEATURE_attrib_stack */
 
+#include main/compiler.h
+
 static INLINE void
 _mesa_PushClientAttrib( GLbitfield mask )
 {
diff --git a/src/mesa/main/colortab.h b/src/mesa/main/colortab.h
index 652fb58..744f092 100644
--- a/src/mesa/main/colortab.h
+++ b/src/mesa/main/colortab.h
@@ -53,6 +53,8 @@ _mesa_init_colortable_dispatch(struct _glapi_table *disp);
 
 #else /* FEATURE_colortable */
 
+#include main/compiler.h
+
 #define _MESA_INIT_COLORTABLE_FUNCTIONS(driver, impl) do { } while (0)
 
 static INLINE void GLAPIENTRY
diff --git a/src/mesa/main/convolve.h b/src/mesa/main/convolve.h
index 59492bc..d140188 100644
--- a/src/mesa/main/convolve.h
+++ b/src/mesa/main/convolve.h
@@ -70,6 +70,8 @@ _mesa_init_convolve_dispatch(struct _glapi_table *disp);
 
 #else /* FEATURE_convolve */
 
+#include main/compiler.h
+
 #define _MESA_INIT_CONVOLVE_FUNCTIONS(driver, impl) do { } while (0)
 
 static INLINE void GLAPIENTRY
diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h
index f8255fa..d3f5c5c 100644
--- a/src/mesa/main/dlist.h
+++ b/src/mesa/main/dlist.h
@@ -81,6 +81,8 @@ extern void _mesa_init_dlist_dispatch(struct _glapi_table 
*disp);
 
 #else /* FEATURE_dlist */
 
+#include main/compiler.h
+
 #define _MESA_INIT_DLIST_FUNCTIONS(driver, impl) do { } while (0)
 #define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) do { } while (0)
 
diff --git a/src/mesa/main/feedback.h b/src/mesa/main/feedback.h
index 3e8283e..0762930 100644
--- a/src/mesa/main/feedback.h
+++ b/src/mesa/main/feedback.h
@@ -63,6 +63,8 @@ _mesa_init_feedback_dispatch(struct _glapi_table *disp);
 
 #else /* FEATURE_feedback */
 
+#include main/compiler.h
+
 #define _MESA_INIT_FEEDBACK_FUNCTIONS(driver, impl) do { } while (0)
 
 static INLINE void
diff --git a/src/mesa/state_tracker/st_cb_accum.h 
b/src/mesa/state_tracker/st_cb_accum.h
index 7d52481..06425dc 100644
--- a/src/mesa/state_tracker/st_cb_accum.h
+++ b/src/mesa/state_tracker/st_cb_accum.h
@@ -41,6 +41,8 @@ extern void st_init_accum_functions(struct dd_function_table 
*functions);
 
 #else
 
+#include main/compiler.h
+
 static INLINE void
 st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
 {

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


Mesa (master): mesa: Decorate functions with GL_APIENTRY in es_generator.py .

2010-08-20 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: ae2ace64f49a39e72eff393b8569653647b8b94f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ae2ace64f49a39e72eff393b8569653647b8b94f

Author: Chia-I Wu o...@lunarg.com
Date:   Thu Aug 19 21:20:01 2010 +0800

mesa: Decorate functions with GL_APIENTRY in es_generator.py.

Note that GLES headers use GL_APIENTRY, not GLAPIENTRY.

---

 src/mesa/main/es_generator.py |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/es_generator.py b/src/mesa/main/es_generator.py
index 9a8f5a6..c1fe240 100644
--- a/src/mesa/main/es_generator.py
+++ b/src/mesa/main/es_generator.py
@@ -609,7 +609,7 @@ for funcName in keys:
 # is to create them ourselves.
 if funcName in allSpecials:
 print /* this function is special and is defined elsewhere */
-print extern %s GLAPIENTRY %s(%s); % (returnType, passthroughFuncName, 
passthroughDeclarationString)
+print extern %s GL_APIENTRY %s(%s); % (returnType, passthroughFuncName, 
passthroughDeclarationString)
 
 # A function may be a core function (i.e. it exists in
 # the core specification), a core addition (extension
@@ -662,7 +662,7 @@ for funcName in keys:
 print
 continue
 
-print static %s %s(%s) % (returnType, fullFuncName, 
declarationString)
+print static %s GL_APIENTRY %s(%s) % (returnType, fullFuncName, 
declarationString)
 print {
 
 # Start printing our code pieces.  Start with any local

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


Mesa (master): mesa: Add missing ES sources to SConscript.

2010-08-20 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: cfc00817407932346d1b977d2f3c24394b4a3336
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cfc00817407932346d1b977d2f3c24394b4a3336

Author: Chia-I Wu o...@lunarg.com
Date:   Thu Aug 19 20:42:10 2010 +0800

mesa: Add missing ES sources to SConscript.

These sources compile to nothing when FEATURE_ES is not defined and thus
were overlooked.  Note that api_exec_es[12].c are still missing on the
list.  They should be added when they can be generated on the fly.

---

 src/mesa/SConscript |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 5c02abc..41fa064 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -53,6 +53,7 @@ if env['platform'] != 'winddk':
'main/dlist.c',
'main/dlopen.c',
'main/drawpix.c',
+   'main/drawtex.c',
'main/enable.c',
'main/enums.c',
'main/eval.c',
@@ -106,6 +107,7 @@ if env['platform'] != 'winddk':
'main/texgetimage.c',
'main/teximage.c',
'main/texobj.c',
+   'main/texpal.c',
'main/texparam.c',
'main/texrender.c',
'main/texstate.c',
@@ -176,6 +178,7 @@ if env['platform'] != 'winddk':
'state_tracker/st_cb_condrender.c',
'state_tracker/st_cb_flush.c',
'state_tracker/st_cb_drawpixels.c',
+   'state_tracker/st_cb_drawtex.c',
'state_tracker/st_cb_eglimage.c',
'state_tracker/st_cb_fbo.c',
'state_tracker/st_cb_feedback.c',

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


Mesa (debug-refcnt-2): auxiliary: add functions to describe gallium objects

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: debug-refcnt-2
Commit: 3ad31b3f6797620b4d44d5d88d10d33451ea12b8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ad31b3f6797620b4d44d5d88d10d33451ea12b8

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:36:14 2010 +0200

auxiliary: add functions to describe gallium objects

---

 src/gallium/auxiliary/Makefile|1 +
 src/gallium/auxiliary/SConscript  |1 +
 src/gallium/auxiliary/util/u_debug_describe.c |   43 +
 src/gallium/auxiliary/util/u_debug_describe.h |   10 ++
 4 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index eb2a40c..2dae479 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -92,6 +92,7 @@ C_SOURCES = \
translate/translate.c \
translate/translate_cache.c \
util/u_debug.c \
+   util/u_debug_describe.c \
util/u_debug_symbol.c \
util/u_debug_stack.c \
util/u_dump_defines.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 30e5d02..43774e3 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -146,6 +146,7 @@ source = [
 'util/u_caps.c',
 'util/u_cpu_detect.c',
 'util/u_debug.c',
+'util/u_debug_describe.c',
 'util/u_debug_memory.c',
 'util/u_debug_stack.c',
 'util/u_debug_symbol.c',
diff --git a/src/gallium/auxiliary/util/u_debug_describe.c 
b/src/gallium/auxiliary/util/u_debug_describe.c
new file mode 100644
index 000..5c7808f
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_debug_describe.c
@@ -0,0 +1,43 @@
+#include pipe/p_state.h
+#include util/u_format.h
+#include util/u_debug_describe.h
+#include util/u_string.h
+
+void
+debug_describe_reference(char* buf, const struct pipe_reference*ptr)
+{
+   strcpy(buf, pipe_object);
+}
+
+void
+debug_describe_resource(char* buf, const struct pipe_resource *ptr)
+{
+   if(ptr-target == PIPE_BUFFER)
+  util_sprintf(buf, pipe_buffer%u, util_format_get_stride(ptr-format, 
ptr-width0));
+   else if(ptr-target == PIPE_TEXTURE_1D)
+  util_sprintf(buf, pipe_texture1d%u,%s,%u, ptr-width0, 
util_format_short_name(ptr-format), ptr-last_level);
+   else if(ptr-target == PIPE_TEXTURE_2D)
+  util_sprintf(buf, pipe_texture2d%u,%u,%s,%u, ptr-width0, 
ptr-height0, util_format_short_name(ptr-format), ptr-last_level);
+   else if(ptr-target == PIPE_TEXTURE_CUBE)
+  util_sprintf(buf, pipe_texture_cube%u,%u,%s,%u, ptr-width0, 
ptr-height0, util_format_short_name(ptr-format), ptr-last_level);
+   else if(ptr-target == PIPE_TEXTURE_3D)
+  util_sprintf(buf, pipe_texture3d%u,%u,%u,%s,%u, ptr-width0, 
ptr-height0, ptr-depth0, util_format_short_name(ptr-format), 
ptr-last_level);
+   else
+  util_sprintf(buf, pipe_martian_resource%u, ptr-target);
+}
+
+void
+debug_describe_surface(char* buf, const struct pipe_surface *ptr)
+{
+   char res[128];
+   debug_describe_resource(res, ptr-texture);
+   util_sprintf(buf, pipe_surface%s,%u,%u,%u, res, ptr-face, ptr-level, 
ptr-zslice);
+}
+
+void
+debug_describe_sampler_view(char* buf, const struct pipe_sampler_view *ptr)
+{
+   char res[128];
+   debug_describe_resource(res, ptr-texture);
+   util_sprintf(buf, pipe_sampler_view%s,%s, res, 
util_format_short_name(ptr-format));
+}
diff --git a/src/gallium/auxiliary/util/u_debug_describe.h 
b/src/gallium/auxiliary/util/u_debug_describe.h
new file mode 100644
index 000..cab614b
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_debug_describe.h
@@ -0,0 +1,10 @@
+#ifndef U_DEBUG_DESCRIBE_H_
+#define U_DEBUG_DESCRIBE_H_
+
+/* a 256-byte buffer is necessary and sufficient */
+void debug_describe_reference(char* buf, const struct pipe_reference*ptr);
+void debug_describe_resource(char* buf, const struct pipe_resource *ptr);
+void debug_describe_surface(char* buf, const struct pipe_surface *ptr);
+void debug_describe_sampler_view(char* buf, const struct pipe_sampler_view 
*ptr);
+
+#endif /* U_DEBUG_DESCRIBE_H_ */

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


Mesa (debug-refcnt-2): u_debug_symbol: support getting a string without output

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: debug-refcnt-2
Commit: 9b907e118acf20bf7bfbab9692f8de5bf7de98fa
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b907e118acf20bf7bfbab9692f8de5bf7de98fa

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:38:19 2010 +0200

u_debug_symbol: support getting a string without output

---

 src/gallium/auxiliary/util/u_debug_symbol.c |   36 +-
 src/gallium/auxiliary/util/u_debug_symbol.h |3 ++
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c 
b/src/gallium/auxiliary/util/u_debug_symbol.c
index 6e25057..1f71c1d 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -33,6 +33,7 @@
  */
 
 #include pipe/p_compiler.h
+#include u_string.h
 
 #include u_debug.h
 #include u_debug_symbol.h
@@ -113,8 +114,8 @@ BOOL WINAPI j_SymGetSymFromAddr(HANDLE hProcess, DWORD 
Address, PDWORD Displacem
 }
 
 
-static INLINE boolean
-debug_symbol_print_imagehlp(const void *addr)
+static INLINE void
+debug_symbol_name_imagehlp(const void *addr, char* buf, unsigned size)
 {
HANDLE hProcess;
BYTE symbolBuffer[1024];
@@ -133,23 +134,32 @@ debug_symbol_print_imagehlp(const void *addr)
}
   
if(!j_SymGetSymFromAddr(hProcess, (DWORD)addr, dwDisplacement, pSymbol))
-  return FALSE;
-
-   debug_printf(\t%s\n, pSymbol-Name);
-
-   return TRUE;
-   
+  buf[0] = 0;
+   else
+   {
+  strncpy(buf, pSymbol-Name, size);
+  buf[size - 1] = 0;
+   }
 }
 #endif
 
-
 void
-debug_symbol_print(const void *addr)
+debug_symbol_name(const void *addr, char* buf, unsigned size)
 {
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)  defined(PIPE_ARCH_X86)
-   if(debug_symbol_print_imagehlp(addr))
+   debug_symbol_name_imagehlp(addr, buf, size);
+   if(buf[0])
   return;
 #endif
-   
-   debug_printf(\t%p\n, addr);
+
+   util_snprintf(buf, size, %p, addr);
+   buf[size - 1] = 0;
+}
+
+void
+debug_symbol_print(const void *addr)
+{
+   char buf[1024];
+   debug_symbol_name(addr, buf, sizeof(buf));
+   debug_printf(\t%s\n, buf);
 }
diff --git a/src/gallium/auxiliary/util/u_debug_symbol.h 
b/src/gallium/auxiliary/util/u_debug_symbol.h
index 0215869..5e283e5 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.h
+++ b/src/gallium/auxiliary/util/u_debug_symbol.h
@@ -43,6 +43,9 @@ extern C {
 
 
 void
+debug_symbol_name(const void *addr, char* buf, unsigned size);
+
+void
 debug_symbol_print(const void *addr);
 
 

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


Mesa (debug-refcnt-2): u_debug_symbol: add support for getting symbol names from glibc

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: debug-refcnt-2
Commit: 382b022619d9d2b21226f1f59c57c095e7e4f1ac
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=382b022619d9d2b21226f1f59c57c095e7e4f1ac

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:39:49 2010 +0200

u_debug_symbol: add support for getting symbol names from glibc

---

 src/gallium/auxiliary/util/u_debug_symbol.c |   23 +++
 src/gallium/tools/addr2line.sh  |   26 ++
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c 
b/src/gallium/auxiliary/util/u_debug_symbol.c
index 1f71c1d..61f4e6f 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -143,6 +143,23 @@ debug_symbol_name_imagehlp(const void *addr, char* buf, 
unsigned size)
 }
 #endif
 
+#ifdef __GLIBC__
+#include execinfo.h
+
+/* This can only provide dynamic symbols, or binary offsets into a file.
+ *
+ * To fix this, post-process the output with tools/addr2line.sh
+ */
+static INLINE void
+debug_symbol_name_glibc(const void *addr, char* buf, unsigned size)
+{
+   char** syms = backtrace_symbols((void**)addr, 1);
+   strncpy(buf, syms[0], size);
+   buf[size - 1] = 0;
+   free(syms);
+}
+#endif
+
 void
 debug_symbol_name(const void *addr, char* buf, unsigned size)
 {
@@ -152,6 +169,12 @@ debug_symbol_name(const void *addr, char* buf, unsigned 
size)
   return;
 #endif
 
+#ifdef __GLIBC__
+   debug_symbol_name_glibc(addr, buf, size);
+   if(buf[0])
+  return;
+#endif
+
util_snprintf(buf, size, %p, addr);
buf[size - 1] = 0;
 }
diff --git a/src/gallium/tools/addr2line.sh b/src/gallium/tools/addr2line.sh
new file mode 100755
index 000..34dec14
--- /dev/null
+++ b/src/gallium/tools/addr2line.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+# This script processes symbols output by Gallium using glibc to 
human-readable function names
+
+lastbin=
+i=-1
+dir=$(mktemp -d)
+input=$1
+
+# Gather all unique addresses for each binary
+sed -nre 's|([^ ]*/[^ ]*)\(\+0x([^)]*).*|\1 \2|p' $input|sort|uniq|while 
read bin addr; do
+   if test $lastbin != $bin; then
+   ((++i))
+   lastbin=$bin
+   echo $bin  $dir/$i.addrs.bin
+   fi
+   echo $addr  $dir/$i.addrs
+done
+
+# Construct a sed script to convert hex address to human readable form, and 
apply it
+for i in $dir/*.addrs; do
+   bin=$($i.bin)
+   addr2line -p -e $bin -a -f  $i|sed -nre 's...@^0x0*([^:]*): 
([^?]*)$...@s|'$bin'(+0x\1)|\2|g...@gp'
+   rm -f $i $i.bin
+done|sed -f - $input
+
+rmdir $dir

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


Mesa (debug-refcnt-2): u_debug_symbol: add symbol name caching

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: debug-refcnt-2
Commit: aff62489d8d5618720dba26086567eab29db90b3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aff62489d8d5618720dba26086567eab29db90b3

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 16:38:17 2010 +0200

u_debug_symbol: add symbol name caching

Without this, any form of logging that dumps stack traces continuously
will spend a lot of time resolving symbol names.

---

 src/gallium/auxiliary/util/u_debug_symbol.c |   40 +++
 src/gallium/auxiliary/util/u_debug_symbol.h |4 ++-
 2 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c 
b/src/gallium/auxiliary/util/u_debug_symbol.c
index 61f4e6f..92c5eab 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -33,10 +33,12 @@
  */
 
 #include pipe/p_compiler.h
+#include os/os_thread.h
 #include u_string.h
 
 #include u_debug.h
 #include u_debug_symbol.h
+#include u_hash_table.h
 
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)  defined(PIPE_ARCH_X86)

@@ -186,3 +188,41 @@ debug_symbol_print(const void *addr)
debug_symbol_name(addr, buf, sizeof(buf));
debug_printf(\t%s\n, buf);
 }
+
+struct util_hash_table* symbols_hash;
+pipe_mutex symbols_mutex;
+
+static unsigned hash_ptr(void* p)
+{
+   return (unsigned)(uintptr_t)p;
+}
+
+static int compare_ptr(void* a, void* b)
+{
+   if(a == b)
+  return 0;
+   else if(a  b)
+  return -1;
+   else
+  return 1;
+}
+
+const char*
+debug_symbol_name_cached(const void *addr)
+{
+   const char* name;
+   pipe_mutex_lock(symbols_mutex);
+   if(!symbols_hash)
+  symbols_hash = util_hash_table_create(hash_ptr, compare_ptr);
+   name = util_hash_table_get(symbols_hash, (void*)addr);
+   if(!name)
+   {
+  char buf[1024];
+  debug_symbol_name(addr, buf, sizeof(buf));
+  name = strdup(buf);
+
+  util_hash_table_set(symbols_hash, addr, name);
+   }
+   pipe_mutex_unlock(symbols_mutex);
+   return name;
+}
diff --git a/src/gallium/auxiliary/util/u_debug_symbol.h 
b/src/gallium/auxiliary/util/u_debug_symbol.h
index 5e283e5..b247706 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.h
+++ b/src/gallium/auxiliary/util/u_debug_symbol.h
@@ -45,10 +45,12 @@ extern C {
 void
 debug_symbol_name(const void *addr, char* buf, unsigned size);
 
+const char*
+debug_symbol_name_cached(const void *addr);
+
 void
 debug_symbol_print(const void *addr);
 
-
 #ifdef __cplusplus
 }
 #endif

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


Mesa (debug-refcnt-2): os_stream: add printf facility

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: debug-refcnt-2
Commit: 45bd7891956235a642f37b189afcafa1ddba10c6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=45bd7891956235a642f37b189afcafa1ddba10c6

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug 20 11:31:24 2010 +0200

os_stream: add printf facility

---

 src/gallium/auxiliary/Makefile|1 +
 src/gallium/auxiliary/SConscript  |1 +
 src/gallium/auxiliary/os/os_stream.c  |   40 +
 src/gallium/auxiliary/os/os_stream.h  |   25 +-
 src/gallium/auxiliary/os/os_stream_log.c  |3 +-
 src/gallium/auxiliary/os/os_stream_null.c |8 +-
 src/gallium/auxiliary/os/os_stream_stdc.c |9 ++
 src/gallium/auxiliary/os/os_stream_str.c  |1 +
 8 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 2dae479..7bd6a33 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -47,6 +47,7 @@ C_SOURCES = \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
os/os_misc.c \
+   os/os_stream.c \
os/os_stream_log.c \
os/os_stream_stdc.c \
os/os_stream_str.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 43774e3..0ece469 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -95,6 +95,7 @@ source = [
 'indices/u_indices_gen.c',
 'indices/u_unfilled_gen.c',
 'os/os_misc.c',
+'os/os_stream.c',
 'os/os_stream_log.c',
 'os/os_stream_stdc.c',
 'os/os_stream_str.c',
diff --git a/src/gallium/auxiliary/os/os_stream.c 
b/src/gallium/auxiliary/os/os_stream.c
new file mode 100644
index 000..2d4e185
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_stream.c
@@ -0,0 +1,40 @@
+#include pipe/p_config.h
+
+#include os_stream.h
+#include util/u_memory.h
+#include util/u_string.h
+
+int
+os_default_stream_vprintf (struct os_stream* stream, const char *format, 
va_list ap)
+{
+   char buf[1024];
+   int retval;
+
+   retval = util_vsnprintf(buf, sizeof(buf), format, ap);
+   if(retval = 0)
+   {}
+   else if(retval  sizeof(buf))
+  stream-write(stream, buf, retval);
+   else
+   {
+  int alloc = sizeof(buf);
+  char* str = NULL;
+  for(;;)
+  {
+ alloc += alloc;
+ if(str)
+FREE(str);
+ str = MALLOC(alloc);
+ if(!str)
+return -1;
+
+ retval = util_vsnprintf(str, alloc, format, ap);
+  } while(retval = alloc);
+
+  if(retval  0)
+ stream-write(stream, str, retval);
+  FREE(str);
+   }
+
+   return retval;
+}
diff --git a/src/gallium/auxiliary/os/os_stream.h 
b/src/gallium/auxiliary/os/os_stream.h
index 693a062..6c6050b 100644
--- a/src/gallium/auxiliary/os/os_stream.h
+++ b/src/gallium/auxiliary/os/os_stream.h
@@ -50,6 +50,9 @@ struct os_stream
 
void
(*flush)(struct os_stream *stream);
+
+   int
+   (*vprintf)(struct os_stream *stream, const char* format, va_list ap);
 };
 
 
@@ -90,6 +93,27 @@ os_stream_flush(struct os_stream *stream)
stream-flush(stream);
 }
 
+int
+os_default_stream_vprintf (struct os_stream* stream, const char *format, 
va_list ap);
+
+static INLINE int
+os_stream_vprintf (struct os_stream* stream, const char *format, va_list ap)
+{
+   return stream-vprintf(stream, format, ap);
+}
+
+static INLINE int
+os_stream_printf (struct os_stream* stream, const char *format, ...)
+{
+   int retval;
+   va_list args;
+
+   va_start (args, format);
+   retval = stream-vprintf(stream, format, args);
+   va_end (args);
+
+   return retval;
+}
 
 struct os_stream *
 os_file_stream_create(const char *filename);
@@ -118,5 +142,4 @@ os_str_stream_get_and_close(struct os_stream *stream);
 #define os_file_stream_create(_filename) os_null_stream_create()
 #endif
 
-
 #endif /* _OS_STREAM_H_ */
diff --git a/src/gallium/auxiliary/os/os_stream_log.c 
b/src/gallium/auxiliary/os/os_stream_log.c
index 7cc2028..b01377c 100644
--- a/src/gallium/auxiliary/os/os_stream_log.c
+++ b/src/gallium/auxiliary/os/os_stream_log.c
@@ -73,7 +73,8 @@ static struct os_stream
 os_log_stream_struct = {
os_log_stream_close,
os_log_stream_write,
-   os_log_stream_flush
+   os_log_stream_flush,
+   os_default_stream_vprintf,
 };
 
 
diff --git a/src/gallium/auxiliary/os/os_stream_null.c 
b/src/gallium/auxiliary/os/os_stream_null.c
index 128c4e8..34a0a34 100644
--- a/src/gallium/auxiliary/os/os_stream_null.c
+++ b/src/gallium/auxiliary/os/os_stream_null.c
@@ -56,12 +56,18 @@ os_null_stream_flush(struct os_stream *stream)
(void)stream;
 }
 
+int
+os_null_stream_vprintf (struct os_stream* stream, const char *format, va_list 
ap)
+{
+   return 0;
+}
 
 static struct os_stream
 os_null_stream = {
os_null_stream_close,
os_null_stream_write,
-   os_null_stream_flush
+   os_null_stream_flush,
+   os_null_stream_vprintf
 };
 
 
diff --git 

Mesa (debug-refcnt-2): auxiliary: add reference count debugging code

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: debug-refcnt-2
Commit: 0a0ffa36ee2de0521f4ed305c6e60dff94bfec6c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a0ffa36ee2de0521f4ed305c6e60dff94bfec6c

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:40:33 2010 +0200

auxiliary: add reference count debugging code

---

 src/gallium/auxiliary/Makefile  |1 +
 src/gallium/auxiliary/SConscript|1 +
 src/gallium/auxiliary/util/u_debug_refcnt.c |  156 +++
 src/gallium/auxiliary/util/u_debug_refcnt.h |   29 +
 4 files changed, 187 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 7bd6a33..287ee8c 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -94,6 +94,7 @@ C_SOURCES = \
translate/translate_cache.c \
util/u_debug.c \
util/u_debug_describe.c \
+   util/u_debug_refcnt.c \
util/u_debug_symbol.c \
util/u_debug_stack.c \
util/u_dump_defines.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 0ece469..93bfe9f 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -149,6 +149,7 @@ source = [
 'util/u_debug.c',
 'util/u_debug_describe.c',
 'util/u_debug_memory.c',
+'util/u_debug_refcnt.c',
 'util/u_debug_stack.c',
 'util/u_debug_symbol.c',
 'util/u_dump_defines.c',
diff --git a/src/gallium/auxiliary/util/u_debug_refcnt.c 
b/src/gallium/auxiliary/util/u_debug_refcnt.c
new file mode 100644
index 000..ab6e564
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_debug_refcnt.c
@@ -0,0 +1,156 @@
+#if defined(DEBUG)  (!defined(PIPE_OS_WINDOWS) || 
defined(PIPE_SUBSYSTEM_WINDOWS_USER))
+
+/* see http://www.mozilla.org/performance/refcnt-balancer.html for what do 
with the output
+ * on Linux, use tools/addr2line.sh to postprocess it before anything else
+ **/
+#include util/u_debug.h
+#include util/u_debug_refcnt.h
+#include util/u_debug_stack.h
+#include util/u_debug_symbol.h
+#include util/u_string.h
+#include util/u_hash_table.h
+#include os/os_thread.h
+#include os/os_stream.h
+
+int debug_refcnt_state;
+
+struct os_stream* stream;
+
+/* TODO: maybe move this serial machinery to a stand-alone module and expose 
it? */
+static pipe_mutex serials_mutex;
+static struct util_hash_table* serials_hash;
+static unsigned serials_last;
+
+static unsigned hash_ptr(void* p)
+{
+   return (unsigned)(uintptr_t)p;
+}
+
+static int compare_ptr(void* a, void* b)
+{
+   if(a == b)
+  return 0;
+   else if(a  b)
+  return -1;
+   else
+  return 1;
+}
+
+static boolean debug_serial(void* p, unsigned* pserial)
+{
+   unsigned serial;
+   boolean found = TRUE;
+   pipe_mutex_lock(serials_mutex);
+   if(!serials_hash)
+  serials_hash = util_hash_table_create(hash_ptr, compare_ptr);
+   serial = (unsigned)(uintptr_t)util_hash_table_get(serials_hash, p);
+   if(!serial)
+   {
+  /* time to stop logging... (you'll have a 100 GB logfile at least at 
this point)
+   * TODO: avoid this
+   */
+  serial = ++serials_last;
+  if(!serial)
+  {
+ debug_error(More than 2^32 objects detected, aborting.\n);
+ os_abort();
+  }
+
+  util_hash_table_set(serials_hash, p, (void*)(uintptr_t)serial);
+  found = FALSE;
+   }
+   pipe_mutex_unlock(serials_mutex);
+   *pserial = serial;
+   return found;
+}
+
+static void debug_serial_delete(void* p)
+{
+   pipe_mutex_lock(serials_mutex);
+   util_hash_table_remove(serials_hash, p);
+   pipe_mutex_unlock(serials_mutex);
+}
+
+#define STACK_LEN 64
+
+static void dump_stack(char* symbols[STACK_LEN])
+{
+   unsigned i;
+   for(i = 0; i  STACK_LEN; ++i)
+   {
+  if(symbols[i])
+ os_stream_printf(stream, %s\n, symbols[i]);
+   }
+   os_stream_write(stream, \n, 1);
+}
+
+void debug_reference_slowpath(const struct pipe_reference* p, void* pget_desc, 
int change)
+{
+   if(debug_refcnt_state  0)
+  return;
+
+   if(!debug_refcnt_state)
+   {
+  const char* filename = debug_get_option(GALLIUM_REFCNT_LOG, NULL);
+  if(filename  filename[0])
+ stream = os_file_stream_create(filename);
+
+  if(stream)
+ debug_refcnt_state = 1;
+  else
+ debug_refcnt_state = -1;
+   }
+
+   if(debug_refcnt_state  0)
+   {
+  struct debug_stack_frame frames[STACK_LEN];
+  char* symbols[STACK_LEN];
+  char buf[1024];
+
+  void (*get_desc)(char*, const struct pipe_reference*) = pget_desc;
+  unsigned i;
+  unsigned refcnt = p-count;
+  unsigned serial;
+  boolean existing = debug_serial((void*)p, serial);
+
+  debug_backtrace_capture(frames, 1, STACK_LEN);
+  for(i = 0; i  STACK_LEN; ++i)
+  {
+ if(frames[i].function)
+symbols[i] = debug_symbol_name_cached(frames[i].function);
+ else
+symbols[i] = 0;
+  }
+
+  get_desc(buf, p);
+
+ 

Mesa (debug-refcnt-2): gallium: hook up reference count debugging code

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: debug-refcnt-2
Commit: da8f92b640681c68f32b3c6cab1db029a7193081
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=da8f92b640681c68f32b3c6cab1db029a7193081

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:41:10 2010 +0200

gallium: hook up reference count debugging code

This commit adds the ability to produce a log file containing all
reference count changes, and object creation/destruction, on Gallium
objects.

The data allows to answer these crucial questions:
1. This app is exhausting all my memory due to a resource leak: where
   is the bug?
2. Which resources is this app using at a given moment? Which parts of
   the code created them?
3. What kinds of resources does this app use?
4. How fast does this app create and destroy resources? Which parts of
   the code create resources fast?

The output is compatible with the one produced by the similar facility
in Mozilla Firefox, allowing to use Mozilla's tools to analyze the data.

To get the log file:
export GALLIUM_REFCNT_LOG=file

To get function names and source lines in the log file:
tools/addr2line.sh file

To process the log file, see:
http://www.mozilla.org/performance/refcnt-balancer.html

---

 src/gallium/auxiliary/util/u_inlines.h |   19 +--
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_inlines.h 
b/src/gallium/auxiliary/util/u_inlines.h
index 540305c..90b0903 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -33,6 +33,8 @@
 #include pipe/p_state.h
 #include pipe/p_screen.h
 #include util/u_debug.h
+#include util/u_debug_describe.h
+#include util/u_debug_refcnt.h
 #include util/u_atomic.h
 #include util/u_box.h
 #include util/u_math.h
@@ -67,7 +69,7 @@ pipe_is_referenced(struct pipe_reference *reference)
  * \return TRUE if the object's refcount hits zero and should be destroyed.
  */
 static INLINE boolean
-pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
+pipe_reference_described(struct pipe_reference *ptr, struct pipe_reference 
*reference, void* get_desc)
 {
boolean destroy = FALSE;
 
@@ -76,6 +78,7 @@ pipe_reference(struct pipe_reference *ptr, struct 
pipe_reference *reference)
   if (reference) {
  assert(pipe_is_referenced(reference));
  p_atomic_inc(reference-count);
+ debug_reference(reference, get_desc, 1);
   }
 
   if (ptr) {
@@ -83,41 +86,45 @@ pipe_reference(struct pipe_reference *ptr, struct 
pipe_reference *reference)
  if (p_atomic_dec_zero(ptr-count)) {
 destroy = TRUE;
  }
+ debug_reference(ptr, get_desc, -1);
   }
}
 
return destroy;
 }
 
+static INLINE boolean
+pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
+{
+   return pipe_reference_described(ptr, reference, debug_describe_reference);
+}
 
 static INLINE void
 pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
 {
struct pipe_surface *old_surf = *ptr;
 
-   if (pipe_reference((*ptr)-reference, surf-reference))
+   if (pipe_reference_described((*ptr)-reference, surf-reference, 
debug_describe_surface))
   old_surf-texture-screen-tex_surface_destroy(old_surf);
*ptr = surf;
 }
 
-
 static INLINE void
 pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
 {
struct pipe_resource *old_tex = *ptr;
 
-   if (pipe_reference((*ptr)-reference, tex-reference))
+   if (pipe_reference_described((*ptr)-reference, tex-reference, 
debug_describe_resource))
   old_tex-screen-resource_destroy(old_tex-screen, old_tex);
*ptr = tex;
 }
 
-
 static INLINE void
 pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct 
pipe_sampler_view *view)
 {
struct pipe_sampler_view *old_view = *ptr;
 
-   if (pipe_reference((*ptr)-reference, view-reference))
+   if (pipe_reference_described((*ptr)-reference, view-reference, 
debug_describe_sampler_view))
   old_view-context-sampler_view_destroy(old_view-context, old_view);
*ptr = view;
 }

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


Mesa (master): gallium/docs: improve documentation for resources

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: c843a60e6319f38991a3519c11a6525416593c04
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c843a60e6319f38991a3519c11a6525416593c04

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug 20 13:11:58 2010 +0200

gallium/docs: improve documentation for resources

---

 src/gallium/docs/source/resources.rst |  160 -
 1 files changed, 157 insertions(+), 3 deletions(-)

diff --git a/src/gallium/docs/source/resources.rst 
b/src/gallium/docs/source/resources.rst
index a380e50..c8a5766 100644
--- a/src/gallium/docs/source/resources.rst
+++ b/src/gallium/docs/source/resources.rst
@@ -1,11 +1,26 @@
-Resources
-=
+Resources and derived objects
+=
 
 Resources represent objects that hold data: textures and buffers.
 
 They are mostly modelled after the resources in Direct3D 10/11, but with a
 different transfer/update mechanism, and more features for OpenGL support.
 
+Resources can be used in several ways, and it is required to specify all 
planned uses through an appropriate set of bind flags.
+
+TODO: write much more on resources
+
+Transfers
+-
+
+Transfers are the mechanism used to access resources with the CPU.
+
+OpenGL: OpenGL supports mapping buffers and has inline transfer functions for 
both buffers and textures
+
+D3D11: D3D11 lacks transfers, but has special resource types that are mappable 
to the CPU address space
+
+TODO: write much more on transfers
+
 Resource targets
 
 
@@ -21,21 +36,160 @@ that depend on the hardware generation.
 
 TODO: can buffers have a non-R8 format?
 
+PIPE_BUFFER
+^^^
+
+Buffer resource: can be used as a vertex, index, constant buffer (appropriate 
bind flags must be requested).
+
+They can be bound to stream output if supported.
+TODO: what about the restrictions lifted by the several later GL transform 
feedback extensions? How does one advertise that in Gallium?
+
+They can be also be bound to a shader stage as usual.
+TODO: are all drivers supposed to support this? how does this work exactly? 
are there size limits?
+
+They can be also be bound to the framebuffer as usual.
+TODO: are all drivers supposed to support this? how does this work exactly? 
are there size limits?
+TODO: is there any chance of supporting GL pixel buffer object acceleration 
with this?
+
+- depth0 must be 1
+- last_level must be 0
+- TODO: what about normalization?
+- TODO: wrap modes/other sampling state?
+- TODO: are arbitrary formats supported? in which cases?
+
+OpenGL: vertex buffers in GL 1.5 or GL_ARB_vertex_buffer_object
+
+- Binding to stream out requires GL 3.0 or GL_NV_transform_feedback
+- Binding as constant buffers requires GL 3.1 or GL_ARB_uniform_buffer_object
+- Binding to a sampling stage requires GL 3.1 or GL_ARB_texture_buffer_object
+- TODO: can they be bound to an FBO?
+
+D3D11: buffer resources
+- Binding to a render target requires D3D_FEATURE_LEVEL_10_0
+
+PIPE_TEXTURE_1D
+^^^
+1D surface accessed with normalized coordinates.
+
+UNIMPLEMENTED: 1D texture arrays not supported
+
+- If PIPE_CAP_NPOT_TEXTURES is not supported,
+  width must be a power of two
+- height0 must be 1
+- depth0 must be 1
+- Mipmaps can be used
+- Must use normalized coordinates
+
+OpenGL: GL_TEXTURE_1D in GL 1.0
+
+- PIPE_CAP_NPOT_TEXTURES is equivalent to GL 2.0 or 
GL_ARB_texture_non_power_of_two
+
+D3D11: 1D textures in D3D_FEATURE_LEVEL_10_0
+
 PIPE_TEXTURE_RECT
 ^
 2D surface with OpenGL GL_TEXTURE_RECTANGLE semantics.
 
-depth must be 1
+- depth0 must be 1
 - last_level must be 0
 - Must use unnormalized coordinates
 - Must use a clamp wrap mode
 
+OpenGL: GL_TEXTURE_RECTANGLE in GL 3.1 or GL_ARB_texture_rectangle or 
GL_NV_texture_rectangle
+
+OpenCL: can create OpenCL images based on this, that can then be sampled 
arbitrarily
+
+D3D11: not supported (only PIPE_TEXTURE_2D with normalized coordinates is 
supported)
+
 PIPE_TEXTURE_2D
 ^^^
 2D surface accessed with normalized coordinates.
 
+UNIMPLEMENTED: 2D texture arrays not supported
+
 - If PIPE_CAP_NPOT_TEXTURES is not supported,
   width and height must be powers of two
+- depth0 must be 1
 - Mipmaps can be used
 - Must use normalized coordinates
 - No special restrictions on wrap modes
+
+OpenGL: GL_TEXTURE_2D in GL 1.0
+
+- PIPE_CAP_NPOT_TEXTURES is equivalent to GL 2.0 or 
GL_ARB_texture_non_power_of_two
+
+OpenCL: can create OpenCL images based on this, that can then be sampled 
arbitrarily
+
+D3D11: 2D textures
+
+- PIPE_CAP_NPOT_TEXTURES is equivalent to D3D_FEATURE_LEVEL_9_3
+
+PIPE_TEXTURE_3D
+^^^
+
+3-dimensional array of texels.
+Mipmap dimensions are reduced in all 3 coordinates.
+
+- If PIPE_CAP_NPOT_TEXTURES is not supported,
+  width, height and depth must be powers of two
+- Must use normalized coordinates
+
+OpenGL: GL_TEXTURE_3D in GL 1.2 or GL_EXT_texture3D
+
+- PIPE_CAP_NPOT_TEXTURES is equivalent to GL 

Mesa (master): u_staging: improve interface

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 3aaec4750d6fda39b3bb4fc0a159fba1655feede
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3aaec4750d6fda39b3bb4fc0a159fba1655feede

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug 20 16:35:34 2010 +0200

u_staging: improve interface

---

 src/gallium/auxiliary/util/u_staging.c |   10 +++---
 src/gallium/auxiliary/util/u_staging.h |8 
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_staging.c 
b/src/gallium/auxiliary/util/u_staging.c
index e2dc696..363e1c8 100644
--- a/src/gallium/auxiliary/util/u_staging.c
+++ b/src/gallium/auxiliary/util/u_staging.c
@@ -23,20 +23,16 @@ util_staging_resource_template(struct pipe_resource *pt, 
unsigned width, unsigne
 }
 
 struct util_staging_transfer *
-util_staging_transfer_new(struct pipe_context *pipe,
+util_staging_transfer_init(struct pipe_context *pipe,
struct pipe_resource *pt,
struct pipe_subresource sr,
unsigned usage,
const struct pipe_box *box,
-   bool direct)
+   bool direct, struct util_staging_transfer *tx)
 {
struct pipe_screen *pscreen = pipe-screen;
-   struct util_staging_transfer *tx;
-   struct pipe_resource staging_resource_template;
 
-   tx = CALLOC_STRUCT(util_staging_transfer);
-   if (!tx)
-  return NULL;
+   struct pipe_resource staging_resource_template;
 
pipe_resource_reference(tx-base.resource, pt);
tx-base.sr = sr;
diff --git a/src/gallium/auxiliary/util/u_staging.h 
b/src/gallium/auxiliary/util/u_staging.h
index 602faa2..3a9da9b 100644
--- a/src/gallium/auxiliary/util/u_staging.h
+++ b/src/gallium/auxiliary/util/u_staging.h
@@ -21,15 +21,15 @@ struct util_staging_transfer {
 };
 
 /* user must be stride, slice_stride and offset */
-/* pt-usage == PIPE_USAGE_DYNAMIC should be a good value to pass for direct */
-/* staging resource is currently created with PIPE_USAGE_DYNAMIC */
+/* pt-usage == PIPE_USAGE_DYNAMIC || pt-usage == PIPE_USAGE_STAGING should 
be a good value to pass for direct */
+/* staging resource is currently created with PIPE_USAGE_STAGING */
 struct util_staging_transfer *
-util_staging_transfer_new(struct pipe_context *pipe,
+util_staging_transfer_init(struct pipe_context *pipe,
struct pipe_resource *pt,
struct pipe_subresource sr,
unsigned usage,
const struct pipe_box *box,
-   bool direct);
+   bool direct, struct util_staging_transfer *tx);
 
 void
 util_staging_transfer_destroy(struct pipe_context *pipe, struct pipe_transfer 
*ptx);

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


Mesa (master): r600g: add occlusion query support

2010-08-20 Thread Jerome Glisse
Module: Mesa
Branch: master
Commit: 63d010115c7972d854e0583f8f74e8d0c3407fcd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=63d010115c7972d854e0583f8f74e8d0c3407fcd

Author: Dave Airlie airl...@redhat.com
Date:   Tue Aug 17 16:07:23 2010 +1000

r600g: add occlusion query support

Signed-off-by: Dave Airlie airl...@redhat.com
Signed-off-by: Jerome Glisse jgli...@redhat.com

---

 src/gallium/drivers/r600/r600_blit.c  |   34 +++--
 src/gallium/drivers/r600/r600_context.c   |   13 ++-
 src/gallium/drivers/r600/r600_context.h   |   37 +-
 src/gallium/drivers/r600/r600_query.c |  208 -
 src/gallium/drivers/r600/r600_state.c |1 -
 src/gallium/drivers/r600/radeon.h |   30 +++--
 src/gallium/winsys/r600/drm/r600_state.c  |   36 +
 src/gallium/winsys/r600/drm/r600_states.h |   25 +++--
 src/gallium/winsys/r600/drm/r600d.h   |1 +
 src/gallium/winsys/r600/drm/radeon_ctx.c  |   36 +-
 10 files changed, 379 insertions(+), 42 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index db7aef7..aef4fbd 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -32,8 +32,10 @@
 #include r600_screen.h
 #include r600_context.h
 
-static void r600_blitter_save_states(struct r600_context *rctx)
+static void r600_blitter_save_states(struct pipe_context *ctx)
 {
+   struct r600_context *rctx = r600_context(ctx);
+
util_blitter_save_blend(rctx-blitter, rctx-blend);
util_blitter_save_depth_stencil_alpha(rctx-blitter, rctx-dsa);
if (rctx-stencil_ref) {
@@ -47,8 +49,9 @@ static void r600_blitter_save_states(struct r600_context 
*rctx)
if (rctx-viewport) {
util_blitter_save_viewport(rctx-blitter, 
rctx-viewport-state.viewport);
}
-   if (rctx-clip)
-   util_blitter_save_clip(rctx-blitter, rctx-clip-state.clip);
+   if (rctx-clip) {
+   util_blitter_save_clip(rctx-blitter, rctx-clip-state.clip);
+   }
util_blitter_save_vertex_buffers(rctx-blitter, rctx-nvertex_buffer,
rctx-vertex_buffer);
 
@@ -60,37 +63,44 @@ static void r600_blitter_save_states(struct r600_context 
*rctx)
rctx-rasterizer = NULL;
rctx-dsa = NULL;
rctx-vertex_elements = NULL;
+
+   /* suspend queries */
+   r600_queries_suspend(ctx);
 }
 
 static void r600_clear(struct pipe_context *ctx, unsigned buffers,
-  const float *rgba, double depth, unsigned stencil)
+   const float *rgba, double depth, unsigned stencil)
 {
struct r600_context *rctx = r600_context(ctx);
struct pipe_framebuffer_state *fb = 
rctx-framebuffer-state.framebuffer;
 
-   r600_blitter_save_states(rctx);
+   r600_blitter_save_states(ctx);
util_blitter_clear(rctx-blitter, fb-width, fb-height,
fb-nr_cbufs, buffers, rgba, depth,
stencil);
+   /* resume queries */
+   r600_queries_resume(ctx);
 }
 
-static void r600_clear_render_target(struct pipe_context *pipe,
+static void r600_clear_render_target(struct pipe_context *ctx,
 struct pipe_surface *dst,
 const float *rgba,
 unsigned dstx, unsigned dsty,
 unsigned width, unsigned height)
 {
-   struct r600_context *rctx = r600_context(pipe);
+   struct r600_context *rctx = r600_context(ctx);
struct pipe_framebuffer_state *fb = 
rctx-framebuffer-state.framebuffer;
 
-   r600_blitter_save_states(rctx);
+   r600_blitter_save_states(ctx);
util_blitter_save_framebuffer(rctx-blitter, fb);
 
util_blitter_clear_render_target(rctx-blitter, dst, rgba,
 dstx, dsty, width, height);
+   /* resume queries */
+   r600_queries_resume(ctx);
 }
 
-static void r600_clear_depth_stencil(struct pipe_context *pipe,
+static void r600_clear_depth_stencil(struct pipe_context *ctx,
 struct pipe_surface *dst,
 unsigned clear_flags,
 double depth,
@@ -98,14 +108,16 @@ static void r600_clear_depth_stencil(struct pipe_context 
*pipe,
 unsigned dstx, unsigned dsty,
 unsigned width, unsigned height)
 {
-   struct r600_context *rctx = r600_context(pipe);
+   struct r600_context *rctx = r600_context(ctx);
struct pipe_framebuffer_state *fb = 
rctx-framebuffer-state.framebuffer;
 
-   r600_blitter_save_states(rctx);
+   r600_blitter_save_states(ctx);
util_blitter_save_framebuffer(rctx-blitter, fb);
 
util_blitter_clear_depth_stencil(rctx-blitter, dst, clear_flags, 
depth, 

Mesa (master): auxiliary: add functions to describe gallium objects

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: d46f91af68e4930b84dd066687c4d865cb54c9b3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d46f91af68e4930b84dd066687c4d865cb54c9b3

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:36:14 2010 +0200

auxiliary: add functions to describe gallium objects

---

 src/gallium/auxiliary/Makefile|1 +
 src/gallium/auxiliary/SConscript  |1 +
 src/gallium/auxiliary/util/u_debug_describe.c |   43 +
 src/gallium/auxiliary/util/u_debug_describe.h |   10 ++
 4 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index eb2a40c..2dae479 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -92,6 +92,7 @@ C_SOURCES = \
translate/translate.c \
translate/translate_cache.c \
util/u_debug.c \
+   util/u_debug_describe.c \
util/u_debug_symbol.c \
util/u_debug_stack.c \
util/u_dump_defines.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 30e5d02..43774e3 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -146,6 +146,7 @@ source = [
 'util/u_caps.c',
 'util/u_cpu_detect.c',
 'util/u_debug.c',
+'util/u_debug_describe.c',
 'util/u_debug_memory.c',
 'util/u_debug_stack.c',
 'util/u_debug_symbol.c',
diff --git a/src/gallium/auxiliary/util/u_debug_describe.c 
b/src/gallium/auxiliary/util/u_debug_describe.c
new file mode 100644
index 000..5c7808f
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_debug_describe.c
@@ -0,0 +1,43 @@
+#include pipe/p_state.h
+#include util/u_format.h
+#include util/u_debug_describe.h
+#include util/u_string.h
+
+void
+debug_describe_reference(char* buf, const struct pipe_reference*ptr)
+{
+   strcpy(buf, pipe_object);
+}
+
+void
+debug_describe_resource(char* buf, const struct pipe_resource *ptr)
+{
+   if(ptr-target == PIPE_BUFFER)
+  util_sprintf(buf, pipe_buffer%u, util_format_get_stride(ptr-format, 
ptr-width0));
+   else if(ptr-target == PIPE_TEXTURE_1D)
+  util_sprintf(buf, pipe_texture1d%u,%s,%u, ptr-width0, 
util_format_short_name(ptr-format), ptr-last_level);
+   else if(ptr-target == PIPE_TEXTURE_2D)
+  util_sprintf(buf, pipe_texture2d%u,%u,%s,%u, ptr-width0, 
ptr-height0, util_format_short_name(ptr-format), ptr-last_level);
+   else if(ptr-target == PIPE_TEXTURE_CUBE)
+  util_sprintf(buf, pipe_texture_cube%u,%u,%s,%u, ptr-width0, 
ptr-height0, util_format_short_name(ptr-format), ptr-last_level);
+   else if(ptr-target == PIPE_TEXTURE_3D)
+  util_sprintf(buf, pipe_texture3d%u,%u,%u,%s,%u, ptr-width0, 
ptr-height0, ptr-depth0, util_format_short_name(ptr-format), 
ptr-last_level);
+   else
+  util_sprintf(buf, pipe_martian_resource%u, ptr-target);
+}
+
+void
+debug_describe_surface(char* buf, const struct pipe_surface *ptr)
+{
+   char res[128];
+   debug_describe_resource(res, ptr-texture);
+   util_sprintf(buf, pipe_surface%s,%u,%u,%u, res, ptr-face, ptr-level, 
ptr-zslice);
+}
+
+void
+debug_describe_sampler_view(char* buf, const struct pipe_sampler_view *ptr)
+{
+   char res[128];
+   debug_describe_resource(res, ptr-texture);
+   util_sprintf(buf, pipe_sampler_view%s,%s, res, 
util_format_short_name(ptr-format));
+}
diff --git a/src/gallium/auxiliary/util/u_debug_describe.h 
b/src/gallium/auxiliary/util/u_debug_describe.h
new file mode 100644
index 000..cab614b
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_debug_describe.h
@@ -0,0 +1,10 @@
+#ifndef U_DEBUG_DESCRIBE_H_
+#define U_DEBUG_DESCRIBE_H_
+
+/* a 256-byte buffer is necessary and sufficient */
+void debug_describe_reference(char* buf, const struct pipe_reference*ptr);
+void debug_describe_resource(char* buf, const struct pipe_resource *ptr);
+void debug_describe_surface(char* buf, const struct pipe_surface *ptr);
+void debug_describe_sampler_view(char* buf, const struct pipe_sampler_view 
*ptr);
+
+#endif /* U_DEBUG_DESCRIBE_H_ */

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


Mesa (master): u_debug_symbol: support getting a string without output

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 64c4f9c56645768aa3cc4a9a60b266a20acca0c2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=64c4f9c56645768aa3cc4a9a60b266a20acca0c2

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:38:19 2010 +0200

u_debug_symbol: support getting a string without output

---

 src/gallium/auxiliary/util/u_debug_symbol.c |   38 +--
 src/gallium/auxiliary/util/u_debug_symbol.h |3 ++
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c 
b/src/gallium/auxiliary/util/u_debug_symbol.c
index 6e25057..7147bbc 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -33,6 +33,7 @@
  */
 
 #include pipe/p_compiler.h
+#include u_string.h
 
 #include u_debug.h
 #include u_debug_symbol.h
@@ -113,8 +114,8 @@ BOOL WINAPI j_SymGetSymFromAddr(HANDLE hProcess, DWORD 
Address, PDWORD Displacem
 }
 
 
-static INLINE boolean
-debug_symbol_print_imagehlp(const void *addr)
+static INLINE void
+debug_symbol_name_imagehlp(const void *addr, char* buf, unsigned size)
 {
HANDLE hProcess;
BYTE symbolBuffer[1024];
@@ -131,25 +132,34 @@ debug_symbol_print_imagehlp(const void *addr)
   if(j_SymInitialize(hProcess, NULL, TRUE))
  bSymInitialized = TRUE;
}
-  
-   if(!j_SymGetSymFromAddr(hProcess, (DWORD)addr, dwDisplacement, pSymbol))
-  return FALSE;
 
-   debug_printf(\t%s\n, pSymbol-Name);
-
-   return TRUE;
-   
+   if(!j_SymGetSymFromAddr(hProcess, (DWORD)addr, dwDisplacement, pSymbol))
+  buf[0] = 0;
+   else
+   {
+  strncpy(buf, pSymbol-Name, size);
+  buf[size - 1] = 0;
+   }
 }
 #endif
 
-
 void
-debug_symbol_print(const void *addr)
+debug_symbol_name(const void *addr, char* buf, unsigned size)
 {
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)  defined(PIPE_ARCH_X86)
-   if(debug_symbol_print_imagehlp(addr))
+   debug_symbol_name_imagehlp(addr, buf, size);
+   if(buf[0])
   return;
 #endif
-   
-   debug_printf(\t%p\n, addr);
+
+   util_snprintf(buf, size, %p, addr);
+   buf[size - 1] = 0;
+}
+
+void
+debug_symbol_print(const void *addr)
+{
+   char buf[1024];
+   debug_symbol_name(addr, buf, sizeof(buf));
+   debug_printf(\t%s\n, buf);
 }
diff --git a/src/gallium/auxiliary/util/u_debug_symbol.h 
b/src/gallium/auxiliary/util/u_debug_symbol.h
index 0215869..5e283e5 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.h
+++ b/src/gallium/auxiliary/util/u_debug_symbol.h
@@ -43,6 +43,9 @@ extern C {
 
 
 void
+debug_symbol_name(const void *addr, char* buf, unsigned size);
+
+void
 debug_symbol_print(const void *addr);
 
 

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


Mesa (master): u_debug_symbol: add support for getting symbol names from glibc

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: b3e57fc8685af44dcf35a7f429b7410e63a9a571
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b3e57fc8685af44dcf35a7f429b7410e63a9a571

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:39:49 2010 +0200

u_debug_symbol: add support for getting symbol names from glibc

---

 src/gallium/auxiliary/util/u_debug_symbol.c |   23 +++
 src/gallium/tools/addr2line.sh  |   26 ++
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c 
b/src/gallium/auxiliary/util/u_debug_symbol.c
index 7147bbc..ebea517 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -143,6 +143,23 @@ debug_symbol_name_imagehlp(const void *addr, char* buf, 
unsigned size)
 }
 #endif
 
+#ifdef __GLIBC__
+#include execinfo.h
+
+/* This can only provide dynamic symbols, or binary offsets into a file.
+ *
+ * To fix this, post-process the output with tools/addr2line.sh
+ */
+static INLINE void
+debug_symbol_name_glibc(const void *addr, char* buf, unsigned size)
+{
+   char** syms = backtrace_symbols((void**)addr, 1);
+   strncpy(buf, syms[0], size);
+   buf[size - 1] = 0;
+   free(syms);
+}
+#endif
+
 void
 debug_symbol_name(const void *addr, char* buf, unsigned size)
 {
@@ -152,6 +169,12 @@ debug_symbol_name(const void *addr, char* buf, unsigned 
size)
   return;
 #endif
 
+#ifdef __GLIBC__
+   debug_symbol_name_glibc(addr, buf, size);
+   if(buf[0])
+  return;
+#endif
+
util_snprintf(buf, size, %p, addr);
buf[size - 1] = 0;
 }
diff --git a/src/gallium/tools/addr2line.sh b/src/gallium/tools/addr2line.sh
new file mode 100755
index 000..34dec14
--- /dev/null
+++ b/src/gallium/tools/addr2line.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+# This script processes symbols output by Gallium using glibc to 
human-readable function names
+
+lastbin=
+i=-1
+dir=$(mktemp -d)
+input=$1
+
+# Gather all unique addresses for each binary
+sed -nre 's|([^ ]*/[^ ]*)\(\+0x([^)]*).*|\1 \2|p' $input|sort|uniq|while 
read bin addr; do
+   if test $lastbin != $bin; then
+   ((++i))
+   lastbin=$bin
+   echo $bin  $dir/$i.addrs.bin
+   fi
+   echo $addr  $dir/$i.addrs
+done
+
+# Construct a sed script to convert hex address to human readable form, and 
apply it
+for i in $dir/*.addrs; do
+   bin=$($i.bin)
+   addr2line -p -e $bin -a -f  $i|sed -nre 's...@^0x0*([^:]*): 
([^?]*)$...@s|'$bin'(+0x\1)|\2|g...@gp'
+   rm -f $i $i.bin
+done|sed -f - $input
+
+rmdir $dir

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


Mesa (master): u_debug_symbol: add symbol name caching

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 40eef4c20cc0b4500a0d8c8538872ed4b473d737
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=40eef4c20cc0b4500a0d8c8538872ed4b473d737

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 16:38:17 2010 +0200

u_debug_symbol: add symbol name caching

Without this, any form of logging that dumps stack traces continuously
will spend a lot of time resolving symbol names.

---

 src/gallium/auxiliary/util/u_debug_symbol.c |   40 +++
 src/gallium/auxiliary/util/u_debug_symbol.h |4 ++-
 2 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c 
b/src/gallium/auxiliary/util/u_debug_symbol.c
index ebea517..332952a 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -33,10 +33,12 @@
  */
 
 #include pipe/p_compiler.h
+#include os/os_thread.h
 #include u_string.h
 
 #include u_debug.h
 #include u_debug_symbol.h
+#include u_hash_table.h
 
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)  defined(PIPE_ARCH_X86)

@@ -186,3 +188,41 @@ debug_symbol_print(const void *addr)
debug_symbol_name(addr, buf, sizeof(buf));
debug_printf(\t%s\n, buf);
 }
+
+struct util_hash_table* symbols_hash;
+pipe_mutex symbols_mutex;
+
+static unsigned hash_ptr(void* p)
+{
+   return (unsigned)(uintptr_t)p;
+}
+
+static int compare_ptr(void* a, void* b)
+{
+   if(a == b)
+  return 0;
+   else if(a  b)
+  return -1;
+   else
+  return 1;
+}
+
+const char*
+debug_symbol_name_cached(const void *addr)
+{
+   const char* name;
+   pipe_mutex_lock(symbols_mutex);
+   if(!symbols_hash)
+  symbols_hash = util_hash_table_create(hash_ptr, compare_ptr);
+   name = util_hash_table_get(symbols_hash, (void*)addr);
+   if(!name)
+   {
+  char buf[1024];
+  debug_symbol_name(addr, buf, sizeof(buf));
+  name = strdup(buf);
+
+  util_hash_table_set(symbols_hash, (void*)addr, (void*)name);
+   }
+   pipe_mutex_unlock(symbols_mutex);
+   return name;
+}
diff --git a/src/gallium/auxiliary/util/u_debug_symbol.h 
b/src/gallium/auxiliary/util/u_debug_symbol.h
index 5e283e5..b247706 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.h
+++ b/src/gallium/auxiliary/util/u_debug_symbol.h
@@ -45,10 +45,12 @@ extern C {
 void
 debug_symbol_name(const void *addr, char* buf, unsigned size);
 
+const char*
+debug_symbol_name_cached(const void *addr);
+
 void
 debug_symbol_print(const void *addr);
 
-
 #ifdef __cplusplus
 }
 #endif

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


Mesa (master): os_stream: add printf facility

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: b1fa352db8a69883f97dd579d892291f414a67f5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1fa352db8a69883f97dd579d892291f414a67f5

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Fri Aug 20 11:31:24 2010 +0200

os_stream: add printf facility

---

 src/gallium/auxiliary/Makefile|1 +
 src/gallium/auxiliary/SConscript  |1 +
 src/gallium/auxiliary/os/os_stream.c  |   40 +
 src/gallium/auxiliary/os/os_stream.h  |   25 +-
 src/gallium/auxiliary/os/os_stream_log.c  |3 +-
 src/gallium/auxiliary/os/os_stream_null.c |8 +-
 src/gallium/auxiliary/os/os_stream_stdc.c |9 ++
 src/gallium/auxiliary/os/os_stream_str.c  |1 +
 8 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 2dae479..7bd6a33 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -47,6 +47,7 @@ C_SOURCES = \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
os/os_misc.c \
+   os/os_stream.c \
os/os_stream_log.c \
os/os_stream_stdc.c \
os/os_stream_str.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 43774e3..0ece469 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -95,6 +95,7 @@ source = [
 'indices/u_indices_gen.c',
 'indices/u_unfilled_gen.c',
 'os/os_misc.c',
+'os/os_stream.c',
 'os/os_stream_log.c',
 'os/os_stream_stdc.c',
 'os/os_stream_str.c',
diff --git a/src/gallium/auxiliary/os/os_stream.c 
b/src/gallium/auxiliary/os/os_stream.c
new file mode 100644
index 000..2d4e185
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_stream.c
@@ -0,0 +1,40 @@
+#include pipe/p_config.h
+
+#include os_stream.h
+#include util/u_memory.h
+#include util/u_string.h
+
+int
+os_default_stream_vprintf (struct os_stream* stream, const char *format, 
va_list ap)
+{
+   char buf[1024];
+   int retval;
+
+   retval = util_vsnprintf(buf, sizeof(buf), format, ap);
+   if(retval = 0)
+   {}
+   else if(retval  sizeof(buf))
+  stream-write(stream, buf, retval);
+   else
+   {
+  int alloc = sizeof(buf);
+  char* str = NULL;
+  for(;;)
+  {
+ alloc += alloc;
+ if(str)
+FREE(str);
+ str = MALLOC(alloc);
+ if(!str)
+return -1;
+
+ retval = util_vsnprintf(str, alloc, format, ap);
+  } while(retval = alloc);
+
+  if(retval  0)
+ stream-write(stream, str, retval);
+  FREE(str);
+   }
+
+   return retval;
+}
diff --git a/src/gallium/auxiliary/os/os_stream.h 
b/src/gallium/auxiliary/os/os_stream.h
index 693a062..6c6050b 100644
--- a/src/gallium/auxiliary/os/os_stream.h
+++ b/src/gallium/auxiliary/os/os_stream.h
@@ -50,6 +50,9 @@ struct os_stream
 
void
(*flush)(struct os_stream *stream);
+
+   int
+   (*vprintf)(struct os_stream *stream, const char* format, va_list ap);
 };
 
 
@@ -90,6 +93,27 @@ os_stream_flush(struct os_stream *stream)
stream-flush(stream);
 }
 
+int
+os_default_stream_vprintf (struct os_stream* stream, const char *format, 
va_list ap);
+
+static INLINE int
+os_stream_vprintf (struct os_stream* stream, const char *format, va_list ap)
+{
+   return stream-vprintf(stream, format, ap);
+}
+
+static INLINE int
+os_stream_printf (struct os_stream* stream, const char *format, ...)
+{
+   int retval;
+   va_list args;
+
+   va_start (args, format);
+   retval = stream-vprintf(stream, format, args);
+   va_end (args);
+
+   return retval;
+}
 
 struct os_stream *
 os_file_stream_create(const char *filename);
@@ -118,5 +142,4 @@ os_str_stream_get_and_close(struct os_stream *stream);
 #define os_file_stream_create(_filename) os_null_stream_create()
 #endif
 
-
 #endif /* _OS_STREAM_H_ */
diff --git a/src/gallium/auxiliary/os/os_stream_log.c 
b/src/gallium/auxiliary/os/os_stream_log.c
index 7cc2028..b01377c 100644
--- a/src/gallium/auxiliary/os/os_stream_log.c
+++ b/src/gallium/auxiliary/os/os_stream_log.c
@@ -73,7 +73,8 @@ static struct os_stream
 os_log_stream_struct = {
os_log_stream_close,
os_log_stream_write,
-   os_log_stream_flush
+   os_log_stream_flush,
+   os_default_stream_vprintf,
 };
 
 
diff --git a/src/gallium/auxiliary/os/os_stream_null.c 
b/src/gallium/auxiliary/os/os_stream_null.c
index 128c4e8..a549a78 100644
--- a/src/gallium/auxiliary/os/os_stream_null.c
+++ b/src/gallium/auxiliary/os/os_stream_null.c
@@ -56,12 +56,18 @@ os_null_stream_flush(struct os_stream *stream)
(void)stream;
 }
 
+static int
+os_null_stream_vprintf (struct os_stream* stream, const char *format, va_list 
ap)
+{
+   return 0;
+}
 
 static struct os_stream
 os_null_stream = {
os_null_stream_close,
os_null_stream_write,
-   os_null_stream_flush
+   os_null_stream_flush,
+   os_null_stream_vprintf
 };
 
 
diff --git 

Mesa (master): auxiliary: add reference count debugging code

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 2ff13fe89e8f0b372512f16bb64d5a703e9bf891
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ff13fe89e8f0b372512f16bb64d5a703e9bf891

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:40:33 2010 +0200

auxiliary: add reference count debugging code

---

 src/gallium/auxiliary/Makefile  |1 +
 src/gallium/auxiliary/SConscript|1 +
 src/gallium/auxiliary/util/u_debug_refcnt.c |  156 +++
 src/gallium/auxiliary/util/u_debug_refcnt.h |   29 +
 4 files changed, 187 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 7bd6a33..287ee8c 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -94,6 +94,7 @@ C_SOURCES = \
translate/translate_cache.c \
util/u_debug.c \
util/u_debug_describe.c \
+   util/u_debug_refcnt.c \
util/u_debug_symbol.c \
util/u_debug_stack.c \
util/u_dump_defines.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 0ece469..93bfe9f 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -149,6 +149,7 @@ source = [
 'util/u_debug.c',
 'util/u_debug_describe.c',
 'util/u_debug_memory.c',
+'util/u_debug_refcnt.c',
 'util/u_debug_stack.c',
 'util/u_debug_symbol.c',
 'util/u_dump_defines.c',
diff --git a/src/gallium/auxiliary/util/u_debug_refcnt.c 
b/src/gallium/auxiliary/util/u_debug_refcnt.c
new file mode 100644
index 000..9d6fca5
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_debug_refcnt.c
@@ -0,0 +1,156 @@
+#if defined(DEBUG)  (!defined(PIPE_OS_WINDOWS) || 
defined(PIPE_SUBSYSTEM_WINDOWS_USER))
+
+/* see http://www.mozilla.org/performance/refcnt-balancer.html for what do 
with the output
+ * on Linux, use tools/addr2line.sh to postprocess it before anything else
+ **/
+#include util/u_debug.h
+#include util/u_debug_refcnt.h
+#include util/u_debug_stack.h
+#include util/u_debug_symbol.h
+#include util/u_string.h
+#include util/u_hash_table.h
+#include os/os_thread.h
+#include os/os_stream.h
+
+int debug_refcnt_state;
+
+struct os_stream* stream;
+
+/* TODO: maybe move this serial machinery to a stand-alone module and expose 
it? */
+static pipe_mutex serials_mutex;
+static struct util_hash_table* serials_hash;
+static unsigned serials_last;
+
+static unsigned hash_ptr(void* p)
+{
+   return (unsigned)(uintptr_t)p;
+}
+
+static int compare_ptr(void* a, void* b)
+{
+   if(a == b)
+  return 0;
+   else if(a  b)
+  return -1;
+   else
+  return 1;
+}
+
+static boolean debug_serial(void* p, unsigned* pserial)
+{
+   unsigned serial;
+   boolean found = TRUE;
+   pipe_mutex_lock(serials_mutex);
+   if(!serials_hash)
+  serials_hash = util_hash_table_create(hash_ptr, compare_ptr);
+   serial = (unsigned)(uintptr_t)util_hash_table_get(serials_hash, p);
+   if(!serial)
+   {
+  /* time to stop logging... (you'll have a 100 GB logfile at least at 
this point)
+   * TODO: avoid this
+   */
+  serial = ++serials_last;
+  if(!serial)
+  {
+ debug_error(More than 2^32 objects detected, aborting.\n);
+ os_abort();
+  }
+
+  util_hash_table_set(serials_hash, p, (void*)(uintptr_t)serial);
+  found = FALSE;
+   }
+   pipe_mutex_unlock(serials_mutex);
+   *pserial = serial;
+   return found;
+}
+
+static void debug_serial_delete(void* p)
+{
+   pipe_mutex_lock(serials_mutex);
+   util_hash_table_remove(serials_hash, p);
+   pipe_mutex_unlock(serials_mutex);
+}
+
+#define STACK_LEN 64
+
+static void dump_stack(const char* symbols[STACK_LEN])
+{
+   unsigned i;
+   for(i = 0; i  STACK_LEN; ++i)
+   {
+  if(symbols[i])
+ os_stream_printf(stream, %s\n, symbols[i]);
+   }
+   os_stream_write(stream, \n, 1);
+}
+
+void debug_reference_slowpath(const struct pipe_reference* p, void* pget_desc, 
int change)
+{
+   if(debug_refcnt_state  0)
+  return;
+
+   if(!debug_refcnt_state)
+   {
+  const char* filename = debug_get_option(GALLIUM_REFCNT_LOG, NULL);
+  if(filename  filename[0])
+ stream = os_file_stream_create(filename);
+
+  if(stream)
+ debug_refcnt_state = 1;
+  else
+ debug_refcnt_state = -1;
+   }
+
+   if(debug_refcnt_state  0)
+   {
+  struct debug_stack_frame frames[STACK_LEN];
+  const char* symbols[STACK_LEN];
+  char buf[1024];
+
+  void (*get_desc)(char*, const struct pipe_reference*) = pget_desc;
+  unsigned i;
+  unsigned refcnt = p-count;
+  unsigned serial;
+  boolean existing = debug_serial((void*)p, serial);
+
+  debug_backtrace_capture(frames, 1, STACK_LEN);
+  for(i = 0; i  STACK_LEN; ++i)
+  {
+ if(frames[i].function)
+symbols[i] = debug_symbol_name_cached(frames[i].function);
+ else
+symbols[i] = 0;
+  }
+
+  get_desc(buf, p);

Mesa (master): gallium: hook up reference count debugging code

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: c806a40277bb5d2dab07908ef79078b0fcc56336
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c806a40277bb5d2dab07908ef79078b0fcc56336

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 00:41:10 2010 +0200

gallium: hook up reference count debugging code

This commit adds the ability to produce a log file containing all
reference count changes, and object creation/destruction, on Gallium
objects.

The data allows to answer these crucial questions:
1. This app is exhausting all my memory due to a resource leak: where
   is the bug?
2. Which resources is this app using at a given moment? Which parts of
   the code created them?
3. What kinds of resources does this app use?
4. How fast does this app create and destroy resources? Which parts of
   the code create resources fast?

The output is compatible with the one produced by the similar facility
in Mozilla Firefox, allowing to use Mozilla's tools to analyze the data.

To get the log file:
export GALLIUM_REFCNT_LOG=file

To get function names and source lines in the log file:
tools/addr2line.sh file

To process the log file, see:
http://www.mozilla.org/performance/refcnt-balancer.html

---

 src/gallium/auxiliary/util/u_inlines.h |   19 +--
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_inlines.h 
b/src/gallium/auxiliary/util/u_inlines.h
index 540305c..90b0903 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -33,6 +33,8 @@
 #include pipe/p_state.h
 #include pipe/p_screen.h
 #include util/u_debug.h
+#include util/u_debug_describe.h
+#include util/u_debug_refcnt.h
 #include util/u_atomic.h
 #include util/u_box.h
 #include util/u_math.h
@@ -67,7 +69,7 @@ pipe_is_referenced(struct pipe_reference *reference)
  * \return TRUE if the object's refcount hits zero and should be destroyed.
  */
 static INLINE boolean
-pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
+pipe_reference_described(struct pipe_reference *ptr, struct pipe_reference 
*reference, void* get_desc)
 {
boolean destroy = FALSE;
 
@@ -76,6 +78,7 @@ pipe_reference(struct pipe_reference *ptr, struct 
pipe_reference *reference)
   if (reference) {
  assert(pipe_is_referenced(reference));
  p_atomic_inc(reference-count);
+ debug_reference(reference, get_desc, 1);
   }
 
   if (ptr) {
@@ -83,41 +86,45 @@ pipe_reference(struct pipe_reference *ptr, struct 
pipe_reference *reference)
  if (p_atomic_dec_zero(ptr-count)) {
 destroy = TRUE;
  }
+ debug_reference(ptr, get_desc, -1);
   }
}
 
return destroy;
 }
 
+static INLINE boolean
+pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
+{
+   return pipe_reference_described(ptr, reference, debug_describe_reference);
+}
 
 static INLINE void
 pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
 {
struct pipe_surface *old_surf = *ptr;
 
-   if (pipe_reference((*ptr)-reference, surf-reference))
+   if (pipe_reference_described((*ptr)-reference, surf-reference, 
debug_describe_surface))
   old_surf-texture-screen-tex_surface_destroy(old_surf);
*ptr = surf;
 }
 
-
 static INLINE void
 pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
 {
struct pipe_resource *old_tex = *ptr;
 
-   if (pipe_reference((*ptr)-reference, tex-reference))
+   if (pipe_reference_described((*ptr)-reference, tex-reference, 
debug_describe_resource))
   old_tex-screen-resource_destroy(old_tex-screen, old_tex);
*ptr = tex;
 }
 
-
 static INLINE void
 pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct 
pipe_sampler_view *view)
 {
struct pipe_sampler_view *old_view = *ptr;
 
-   if (pipe_reference((*ptr)-reference, view-reference))
+   if (pipe_reference_described((*ptr)-reference, view-reference, 
debug_describe_sampler_view))
   old_view-context-sampler_view_destroy(old_view-context, old_view);
*ptr = view;
 }

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


Mesa (master): util: Fix build for C++ compilers.

2010-08-20 Thread Michał Król
Module: Mesa
Branch: master
Commit: a43a2f0662c4aa33b50882411181252198819942
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a43a2f0662c4aa33b50882411181252198819942

Author: Michal Krol mic...@vmware.com
Date:   Fri Aug 20 18:51:22 2010 +0200

util: Fix build for C++ compilers.

---

 src/gallium/auxiliary/util/u_debug_describe.h |8 
 src/gallium/auxiliary/util/u_debug_refcnt.h   |8 
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug_describe.h 
b/src/gallium/auxiliary/util/u_debug_describe.h
index cab614b..8c32f02 100644
--- a/src/gallium/auxiliary/util/u_debug_describe.h
+++ b/src/gallium/auxiliary/util/u_debug_describe.h
@@ -1,10 +1,18 @@
 #ifndef U_DEBUG_DESCRIBE_H_
 #define U_DEBUG_DESCRIBE_H_
 
+#ifdef __cplusplus
+extern C {
+#endif
+
 /* a 256-byte buffer is necessary and sufficient */
 void debug_describe_reference(char* buf, const struct pipe_reference*ptr);
 void debug_describe_resource(char* buf, const struct pipe_resource *ptr);
 void debug_describe_surface(char* buf, const struct pipe_surface *ptr);
 void debug_describe_sampler_view(char* buf, const struct pipe_sampler_view 
*ptr);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* U_DEBUG_DESCRIBE_H_ */
diff --git a/src/gallium/auxiliary/util/u_debug_refcnt.h 
b/src/gallium/auxiliary/util/u_debug_refcnt.h
index e48a2a6..ba40999 100644
--- a/src/gallium/auxiliary/util/u_debug_refcnt.h
+++ b/src/gallium/auxiliary/util/u_debug_refcnt.h
@@ -11,6 +11,10 @@
 #include pipe/p_config.h
 #include pipe/p_state.h
 
+#ifdef __cplusplus
+extern C {
+#endif
+
 #if defined(DEBUG)  (!defined(PIPE_OS_WINDOWS) || 
defined(PIPE_SUBSYSTEM_WINDOWS_USER))
 extern int debug_refcnt_state;
 
@@ -26,4 +30,8 @@ static INLINE void debug_reference(const struct 
pipe_reference* p, void* get_des
 {}
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* U_DEBUG_REFCNT_H_ */

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


Mesa (master): r600g: add POW instruction

2010-08-20 Thread Jerome Glisse
Module: Mesa
Branch: master
Commit: a4b10a56145ea253def4cf958410d770d0640bc9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a4b10a56145ea253def4cf958410d770d0640bc9

Author: Jerome Glisse jgli...@redhat.com
Date:   Fri Aug 20 18:53:29 2010 +0200

r600g: add POW instruction

Signed-off-by: Jerome Glisse jgli...@redhat.com

---

 src/gallium/drivers/r600/r600_shader.c |   91 +--
 1 files changed, 73 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index 62cd8f5..da1af67 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -1006,27 +1006,12 @@ static int tgsi_trans(struct r600_shader_ctx *ctx)
return 0;
 }
 
-static int tgsi_trans_srcx_replicate(struct r600_shader_ctx *ctx)
+static int tgsi_helper_tempx_replicate(struct r600_shader_ctx *ctx)
 {
struct tgsi_full_instruction *inst = 
ctx-parse.FullToken.FullInstruction;
struct r600_bc_alu alu;
-   int i, j, r;
+   int i, r;
 
-   memset(alu, 0, sizeof(struct r600_bc_alu));
-   alu.inst = ctx-inst_info-r600_opcode;
-   for (j = 0; j  inst-Instruction.NumSrcRegs; j++) {
-   r = tgsi_src(ctx, inst-Src[j], alu.src[j]);
-   if (r)
-   return r;
-   alu.src[j].chan = tgsi_chan(inst-Src[j], 0);
-   }
-   alu.dst.sel = ctx-temp_reg;
-   alu.dst.write = 1;
-   alu.last = 1;
-   r = r600_bc_add_alu(ctx-bc, alu);
-   if (r)
-   return r;
-   /* replicate result */
for (i = 0; i  4; i++) {
memset(alu, 0, sizeof(struct r600_bc_alu));
alu.src[0].sel = ctx-temp_reg;
@@ -1045,6 +1030,76 @@ static int tgsi_trans_srcx_replicate(struct 
r600_shader_ctx *ctx)
return 0;
 }
 
+static int tgsi_trans_srcx_replicate(struct r600_shader_ctx *ctx)
+{
+   struct tgsi_full_instruction *inst = 
ctx-parse.FullToken.FullInstruction;
+   struct r600_bc_alu alu;
+   int i, r;
+
+   memset(alu, 0, sizeof(struct r600_bc_alu));
+   alu.inst = ctx-inst_info-r600_opcode;
+   for (i = 0; i  inst-Instruction.NumSrcRegs; i++) {
+   r = tgsi_src(ctx, inst-Src[i], alu.src[i]);
+   if (r)
+   return r;
+   alu.src[i].chan = tgsi_chan(inst-Src[i], 0);
+   }
+   alu.dst.sel = ctx-temp_reg;
+   alu.dst.write = 1;
+   alu.last = 1;
+   r = r600_bc_add_alu(ctx-bc, alu);
+   if (r)
+   return r;
+   /* replicate result */
+   return tgsi_helper_tempx_replicate(ctx);
+}
+
+static int tgsi_pow(struct r600_shader_ctx *ctx)
+{
+   struct tgsi_full_instruction *inst = 
ctx-parse.FullToken.FullInstruction;
+   struct r600_bc_alu alu;
+   int r;
+
+   /* LOG2(a) */
+   memset(alu, 0, sizeof(struct r600_bc_alu));
+   alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE;
+   r = tgsi_src(ctx, inst-Src[0], alu.src[0]);
+   if (r)
+   return r;
+   alu.src[0].chan = tgsi_chan(inst-Src[0], 0);
+   alu.dst.sel = ctx-temp_reg;
+   alu.dst.write = 1;
+   alu.last = 1;
+   r = r600_bc_add_alu(ctx-bc, alu);
+   if (r)
+   return r;
+   /* b * LOG2(a) */
+   memset(alu, 0, sizeof(struct r600_bc_alu));
+   alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE;
+   r = tgsi_src(ctx, inst-Src[1], alu.src[0]);
+   if (r)
+   return r;
+   alu.src[0].chan = tgsi_chan(inst-Src[1], 0);
+   alu.src[1].sel = ctx-temp_reg;
+   alu.dst.sel = ctx-temp_reg;
+   alu.dst.write = 1;
+   alu.last = 1;
+   r = r600_bc_add_alu(ctx-bc, alu);
+   if (r)
+   return r;
+   /* POW(a,b) = EXP2(b * LOG2(a))*/
+   memset(alu, 0, sizeof(struct r600_bc_alu));
+   alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE;
+   alu.src[0].sel = ctx-temp_reg;
+   alu.dst.sel = ctx-temp_reg;
+   alu.dst.write = 1;
+   alu.last = 1;
+   r = r600_bc_add_alu(ctx-bc, alu);
+   if (r)
+   return r;
+   return tgsi_helper_tempx_replicate(ctx);
+}
+
 static int tgsi_ssg(struct r600_shader_ctx *ctx)
 {
struct tgsi_full_instruction *inst = 
ctx-parse.FullToken.FullInstruction;
@@ -1419,7 +1474,7 @@ static struct r600_shader_tgsi_instruction 
r600_shader_tgsi_instruction[] = {
{TGSI_OPCODE_ROUND, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},
{TGSI_OPCODE_EX2,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE, 
tgsi_trans_srcx_replicate},
{TGSI_OPCODE_LG2,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE, 
tgsi_trans_srcx_replicate},
-   {TGSI_OPCODE_POW,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},
+   {TGSI_OPCODE_POW,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_pow},
{TGSI_OPCODE_XPD,   0, 

Mesa (nvfx-next-7k): mesa/st: turn on EmitNoIfs is control flow unsupported

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: nvfx-next-7k
Commit: 765c053a47dbf84b7fe3e689448870597e9d3e1d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=765c053a47dbf84b7fe3e689448870597e9d3e1d

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Aug 19 23:48:54 2010 +0200

mesa/st: turn on EmitNoIfs is control flow unsupported

r300g is changed to falsely claim it always has control flow to
not change its behavior.

---

 src/gallium/drivers/nvfx/nvfx_screen.c |6 +++---
 src/gallium/drivers/r300/r300_screen.c |6 --
 src/mesa/state_tracker/st_extensions.c |5 +
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c 
b/src/gallium/drivers/nvfx/nvfx_screen.c
index 72cb523..1dd7b48 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.c
+++ b/src/gallium/drivers/nvfx/nvfx_screen.c
@@ -99,7 +99,7 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH:
/* FIXME: is it the dynamic (nv30:0/nv40:24) or the static
   value (nv30:0/nv40:4) ? */
-   return screen-is_nv4x ? 4 : 0;
+   return 0; //screen-is_nv4x ? 4 : 0;
case PIPE_CAP_MAX_FS_INPUTS:
return 10;
case PIPE_CAP_MAX_FS_CONSTS:
@@ -119,7 +119,7 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH:
/* FIXME: is it the dynamic (nv30:24/nv40:24) or the static
   value (nv30:1/nv40:4) ? */
-   return screen-is_nv4x ? 4 : 1;
+   return 0; //return screen-is_nv4x ? 4 : 1;
case PIPE_CAP_MAX_VS_INPUTS:
return 16;
case PIPE_CAP_MAX_VS_CONSTS:
@@ -155,7 +155,7 @@ nvfx_screen_get_paramf(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
return screen-is_nv4x ? 16.0 : 8.0;
case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
-   return screen-is_nv4x ? 16.0 : 4.0;
+   return 15.0;
default:
NOUVEAU_ERR(Unknown PIPE_CAP %d\n, param);
return 0.0;
diff --git a/src/gallium/drivers/r300/r300_screen.c 
b/src/gallium/drivers/r300/r300_screen.c
index 1e4edcd..66f426c 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -169,7 +169,8 @@ static int r300_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
 case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS:
 return is_r500 ? 511 : 4;
 case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH:
-return is_r500 ? 64 : 0; /* Actually unlimited on r500. */
+/* it is actually 0, but we for now don't enable the GLSL2 
if-to-cond pass */
+return is_r500 ? 64 : 1; /* Actually unlimited on r500. */
 case PIPE_CAP_MAX_FS_INPUTS:
 /* 2 colors + 8 texcoords are always supported
  * (minus fog and wpos).
@@ -195,7 +196,8 @@ static int r300_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
 case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS:
 return 0;
 case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH:
-return is_r500 ? 4 : 0; /* For loops; not sure about conditionals. 
*/
+/* it is actually 0, but we for now don't enable the GLSL2 
if-to-cond pass */
+return is_r500 ? 4 : 1; /* For loops; not sure about conditionals. 
*/
 case PIPE_CAP_MAX_VS_INPUTS:
 return 16;
 case PIPE_CAP_MAX_VS_CONSTS:
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 90e7867..72c457b 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -139,6 +139,11 @@ void st_init_limits(struct st_context *st)
st-ctx-Shader.EmitContReturn =
   screen-get_param(screen, PIPE_CAP_TGSI_CONT_SUPPORTED);
 
+   /* XXX this should differ for VS and FS! */
+   st-ctx-Shader.EmitNoIfs =
+  !screen-get_param(screen, PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH)
+  || !screen-get_param(screen, PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH);
+
/* Quads always follow GL provoking rules. */
c-QuadsFollowProvokingVertexConvention = GL_FALSE;
 

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


Mesa (master): Remove remnants of the old glsl compiler.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 284ce20901b0c2cfab1d952cc129b8f3cd068f12
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=284ce20901b0c2cfab1d952cc129b8f3cd068f12

Author: Eric Anholt e...@anholt.net
Date:   Fri Aug 20 10:52:14 2010 -0700

Remove remnants of the old glsl compiler.

---

 Makefile   |   12 +-
 src/glsl/cl/Makefile   |   13 -
 src/glsl/cl/sl_cl_parse.c  | 3027 ---
 src/glsl/cl/sl_cl_parse.h  |   42 -
 src/glsl/pp/Makefile   |   27 -
 src/glsl/pp/sl_pp_context.c|  183 -
 src/glsl/pp/sl_pp_context.h|   99 -
 src/glsl/pp/sl_pp_define.c |  240 -
 src/glsl/pp/sl_pp_dict.c   |   85 -
 src/glsl/pp/sl_pp_dict.h   |   77 -
 src/glsl/pp/sl_pp_error.c  |  271 -
 src/glsl/pp/sl_pp_expression.c |  413 --
 src/glsl/pp/sl_pp_expression.h |   40 -
 src/glsl/pp/sl_pp_extension.c  |  180 -
 src/glsl/pp/sl_pp_if.c |  343 --
 src/glsl/pp/sl_pp_line.c   |  129 -
 src/glsl/pp/sl_pp_macro.c  |  415 --
 src/glsl/pp/sl_pp_macro.h  |   70 -
 src/glsl/pp/sl_pp_pragma.c |  110 -
 src/glsl/pp/sl_pp_process.c|  331 --
 src/glsl/pp/sl_pp_process.h|  113 -
 src/glsl/pp/sl_pp_public.h |   79 -
 src/glsl/pp/sl_pp_purify.c |  302 --
 src/glsl/pp/sl_pp_purify.h |   63 -
 src/glsl/pp/sl_pp_token.c  |  854 ---
 src/glsl/pp/sl_pp_token.h  |  133 -
 src/glsl/pp/sl_pp_token_util.c |  183 -
 src/glsl/pp/sl_pp_token_util.h |   98 -
 src/glsl/pp/sl_pp_version.c|  162 -
 src/mesa/drivers/glslcompiler/Makefile |   43 -
 src/mesa/drivers/glslcompiler/glslcompiler.c   |  436 --
 src/mesa/slang/descrip.mms |   67 -
 src/mesa/slang/library/.gitignore  |1 -
 src/mesa/slang/library/Makefile|   54 -
 src/mesa/slang/library/SConscript  |   62 -
 src/mesa/slang/library/slang_120_core.gc   | 1978 ---
 src/mesa/slang/library/slang_builtin_120_common.gc |  200 -
 .../slang/library/slang_builtin_120_fragment.gc|   30 -
 src/mesa/slang/library/slang_common_builtin.gc | 1887 ---
 src/mesa/slang/library/slang_core.gc   | 2619 --
 src/mesa/slang/library/slang_fragment_builtin.gc   |  299 --
 src/mesa/slang/library/slang_geometry_builtin.gc   |   55 -
 src/mesa/slang/library/slang_vertex_builtin.gc |  210 -
 src/mesa/slang/slang_builtin.c | 1020 
 src/mesa/slang/slang_builtin.h |   68 -
 src/mesa/slang/slang_codegen.c | 5410 
 src/mesa/slang/slang_codegen.h |   78 -
 src/mesa/slang/slang_compile.c | 3103 ---
 src/mesa/slang/slang_compile.h |  103 -
 src/mesa/slang/slang_compile_function.c|  262 -
 src/mesa/slang/slang_compile_function.h|  100 -
 src/mesa/slang/slang_compile_operation.c   |  334 --
 src/mesa/slang/slang_compile_operation.h   |  230 -
 src/mesa/slang/slang_compile_struct.c  |  174 -
 src/mesa/slang/slang_compile_struct.h  |   69 -
 src/mesa/slang/slang_compile_variable.c|  247 -
 src/mesa/slang/slang_compile_variable.h|   92 -
 src/mesa/slang/slang_emit.c| 2686 --
 src/mesa/slang/slang_emit.h|   49 -
 src/mesa/slang/slang_ir.c  |  534 --
 src/mesa/slang/slang_ir.h  |  293 --
 src/mesa/slang/slang_label.c   |  107 -
 src/mesa/slang/slang_label.h   |   44 -
 src/mesa/slang/slang_link.c| 1288 -
 src/mesa/slang/slang_link.h|   37 -
 src/mesa/slang/slang_log.c |  133 -
 src/mesa/slang/slang_log.h |   59 -
 src/mesa/slang/slang_mem.c |  243 -
 src/mesa/slang/slang_mem.h |   55 -
 src/mesa/slang/slang_print.c   |  883 
 src/mesa/slang/slang_print.h   |   35 -
 src/mesa/slang/slang_simplify.c|  527 --
 src/mesa/slang/slang_simplify.h|   57 -
 src/mesa/slang/slang_storage.c |  321 --
 src/mesa/slang/slang_storage.h |  144 -
 

Mesa (master): mesa: Fix GetUniformLocation while compiling display lists.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 5482eaba6ecd4a581377336b6409019adf67869e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5482eaba6ecd4a581377336b6409019adf67869e

Author: Nick Bowler nbow...@draconx.ca
Date:   Thu Aug 19 12:19:55 2010 -0400

mesa: Fix GetUniformLocation while compiling display lists.

This function was apparently missing from the display list dispatch
table, causing the generic no-op function to be called instead.  To make
matters worse, the no-op function is indistinguishable from a successful
call to GetUniformLocation.  GL specifies that GetUniformLocation is
executed immediately when compiling display lists.

Fixes fdo bug 29622.

Signed-off-by: Nick Bowler nbow...@draconx.ca

---

 src/mesa/main/dlist.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 727414d..5042e14 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -6070,8 +6070,15 @@ exec_GetAttribLocationARB(GLuint program, const GLchar 
*name)
FLUSH_VERTICES(ctx, 0);
return CALL_GetAttribLocationARB(ctx-Exec, (program, name));
 }
-/* XXX more shader functions needed here */
 
+static GLint GLAPIENTRY
+exec_GetUniformLocationARB(GLuint program, const GLchar *name)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   return CALL_GetUniformLocationARB(ctx-Exec, (program, name));
+}
+/* XXX more shader functions needed here */
 
 
 #if FEATURE_EXT_framebuffer_blit
@@ -9491,6 +9498,7 @@ _mesa_create_save_table(void)
/* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
SET_BindAttribLocationARB(table, exec_BindAttribLocationARB);
SET_GetAttribLocationARB(table, exec_GetAttribLocationARB);
+   SET_GetUniformLocationARB(table, exec_GetUniformLocationARB);
/* XXX additional functions need to be implemented here! */
 
/* 299. GL_EXT_blend_equation_separate */

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


Mesa (nvfx-merge-candidate): nvfx: fix lodbias

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: nvfx-merge-candidate
Commit: fc3862a5b343615a33979717edffc5d5ef1f607d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc3862a5b343615a33979717edffc5d5ef1f607d

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Thu Aug 19 22:47:03 2010 +0200

nvfx: fix lodbias

---

 src/gallium/drivers/nvfx/nv30_fragtex.c |2 +-
 src/gallium/drivers/nvfx/nv40_fragtex.c |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nvfx/nv30_fragtex.c 
b/src/gallium/drivers/nvfx/nv30_fragtex.c
index db8a8fc..0c3d43f 100644
--- a/src/gallium/drivers/nvfx/nv30_fragtex.c
+++ b/src/gallium/drivers/nvfx/nv30_fragtex.c
@@ -21,7 +21,7 @@ nv30_sampler_state_init(struct pipe_context *pipe,
ps-en |= NV34TCL_TX_ENABLE_ANISO_2X;
}
 
-   limit = CLAMP(cso-lod_bias, -16.0, 15.0);
+   limit = CLAMP(cso-lod_bias, -16.0, 15.0 + (255.0 / 256.0));
ps-filt |= (int)(cso-lod_bias * 256.0)  0x1fff;
 
ps-max_lod = (int)CLAMP(cso-max_lod, 0.0, 15.0);
diff --git a/src/gallium/drivers/nvfx/nv40_fragtex.c 
b/src/gallium/drivers/nvfx/nv40_fragtex.c
index 5fe742f..106ce71 100644
--- a/src/gallium/drivers/nvfx/nv40_fragtex.c
+++ b/src/gallium/drivers/nvfx/nv40_fragtex.c
@@ -29,11 +29,11 @@ nv40_sampler_state_init(struct pipe_context *pipe,
ps-en |= NV40TCL_TEX_ENABLE_ANISO_2X;
}
 
-   limit = CLAMP(cso-lod_bias, -16.0, 15.0);
+   limit = CLAMP(cso-lod_bias, -16.0, 15.0 + (255.0 / 256.0));
ps-filt |= (int)(cso-lod_bias * 256.0)  0x1fff;
 
-   ps-max_lod = (int)(CLAMP(cso-max_lod, 0.0, 15.0) * 256.0);
-   ps-min_lod = (int)(CLAMP(cso-min_lod, 0.0, 15.0) * 256.0);
+   ps-max_lod = (int)(CLAMP(cso-max_lod, 0.0, 15.0 + (255.0 / 256.0)) * 
256.0);
+   ps-min_lod = (int)(CLAMP(cso-min_lod, 0.0, 15.0 + (255.0 / 256.0)) * 
256.0);
 
ps-en |= NV40TCL_TEX_ENABLE_ENABLE;
 }

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


Mesa (master): intel: Don' t try to do work for BufferSubData with a size of 0.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 27e6552a8fb0fd49be84fbaf9504e8371033db23
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=27e6552a8fb0fd49be84fbaf9504e8371033db23

Author: Eric Anholt e...@anholt.net
Date:   Fri Aug 20 12:36:34 2010 -0700

intel: Don't try to do work for BufferSubData with a size of 0.

If we hit the linear blit path, we'd come up with a pitch of 0, then
divide by zero.

Fixes vbo-subdata-zero, made for bug #28931 (warsow).

---

 src/mesa/drivers/dri/intel/intel_buffer_objects.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c 
b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index 8ab41f8..117d4da 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -202,6 +202,9 @@ intel_bufferobj_subdata(GLcontext * ctx,
struct intel_context *intel = intel_context(ctx);
struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
 
+   if (size == 0)
+  return;
+
assert(intel_obj);
 
if (intel_obj-region)
@@ -426,6 +429,9 @@ intel_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum 
target,
if (intel_obj-range_map_buffer == NULL)
   return;
 
+   if (length == 0)
+  return;
+
temp_bo = drm_intel_bo_alloc(intel-bufmgr, range map flush, length, 64);
 
drm_intel_bo_subdata(temp_bo, 0, length, intel_obj-range_map_buffer);

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


Mesa (master): glsl: add missing sceneColor field to gl_{Front, Back}LightModelProduct

2010-08-20 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: c108a7927d1dad9e0f641a0ec5a7387fb2626156
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c108a7927d1dad9e0f641a0ec5a7387fb2626156

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 12:52:55 2010 +0200

glsl: add missing sceneColor field to gl_{Front, Back}LightModelProduct

According to both GLSL 1.20 and 4.0, these are a struct with one field
called sceneColor.

Fixes a crash on loading in FlightGear.

---

 src/mesa/program/ir_to_mesa.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index fafc620..1fbf574 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1079,9 +1079,9 @@ static const struct {
{gl_LightModel, NULL,
 {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW, false},
 
-   {gl_FrontLightModelProduct, NULL,
+   {gl_FrontLightModelProduct, sceneColor,
 {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW, false},
-   {gl_BackLightModelProduct, NULL,
+   {gl_BackLightModelProduct, sceneColor,
 {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW, false},
 
{gl_FrontLightProduct, ambient,

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


Mesa (master): glsl: don' t crash if a field is specified for a non-struct uniform

2010-08-20 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: fc76d7276393a4617f9898214bc397bb65634b02
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc76d7276393a4617f9898214bc397bb65634b02

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 12:52:56 2010 +0200

glsl: don't crash if a field is specified for a non-struct uniform

This was triggered by the previous bug, but is a separate problem
in the general sense.

---

 src/mesa/program/ir_to_mesa.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 1fbf574..fe2d898 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1145,7 +1145,7 @@ get_builtin_uniform_reg(struct gl_program *prog,
   if (!field  statevars[i].field) {
 assert(!FINISHME: whole-structure state var dereference);
   }
-  if (field  strcmp(statevars[i].field, field) != 0)
+  if (field  (!statevars[i].field || strcmp(statevars[i].field, field) 
!= 0))
 continue;
   break;
}

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


Mesa (master): glsl: add missing ambient field to gl_LightModel

2010-08-20 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: c3e3793c325e36366165a5d1403a8c406ff200db
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3e3793c325e36366165a5d1403a8c406ff200db

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Wed Aug 18 12:52:57 2010 +0200

glsl: add missing ambient field to gl_LightModel

Again, this is a one-element struct that was incorrectly missing the
field.

---

 src/mesa/program/ir_to_mesa.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index fe2d898..5832494 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1076,7 +1076,7 @@ static const struct {
{gl_LightSource, quadraticAttenuation,
 {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_, true},
 
-   {gl_LightModel, NULL,
+   {gl_LightModel, ambient,
 {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW, false},
 
{gl_FrontLightModelProduct, sceneColor,

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


Mesa (master): glsl: Remove bogus ambient field from vec4 gl_TextureEnvColor.

2010-08-20 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: d6cc7191daa249463b20e2965dc1006288539b1e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d6cc7191daa249463b20e2965dc1006288539b1e

Author: Kenneth Graunke kenn...@whitecape.org
Date:   Fri Aug 20 12:57:21 2010 -0700

glsl: Remove bogus ambient field from vec4 gl_TextureEnvColor.

---

 src/mesa/program/ir_to_mesa.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 5832494..9fdeaa9 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1098,7 +1098,7 @@ static const struct {
{gl_BackLightProduct, specular,
 {STATE_LIGHTPROD, 0, 1, STATE_SPECULAR}, SWIZZLE_XYZW, true},
 
-   {gl_TextureEnvColor, ambient,
+   {gl_TextureEnvColor, NULL,
 {STATE_TEXENV_COLOR, 0}, SWIZZLE_XYZW, true},
 
{gl_EyePlaneS, NULL,

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


Mesa (master): Delete more vestiges of the old shader compiler.

2010-08-20 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 7f80041efae5be95ef53b8164e67027d234f9574
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f80041efae5be95ef53b8164e67027d234f9574

Author: Kenneth Graunke kenn...@whitecape.org
Date:   Fri Aug 20 13:06:02 2010 -0700

Delete more vestiges of the old shader compiler.

---

 src/glsl/apps/.gitignore |5 -
 src/glsl/apps/Makefile   |   43 -
 src/glsl/apps/compile.c  |  198 ---
 src/glsl/apps/process.c  |  388 --
 src/glsl/apps/purify.c   |  112 -
 src/glsl/apps/tokenise.c |  340 
 src/glsl/apps/version.c  |  121 --
 src/mesa/SConscript  |   24 ---
 src/mesa/sources.mak |   21 ---
 9 files changed, 0 insertions(+), 1252 deletions(-)

diff --git a/src/glsl/apps/.gitignore b/src/glsl/apps/.gitignore
deleted file mode 100644
index 7e011ce..000
--- a/src/glsl/apps/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-compile
-process
-purify
-tokenise
-version
diff --git a/src/glsl/apps/Makefile b/src/glsl/apps/Makefile
deleted file mode 100644
index 39a0df7..000
--- a/src/glsl/apps/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-# src/glsl/apps/Makefile
-
-TOP = ../../..
-
-include $(TOP)/configs/current
-
-LIBS = \
-   $(TOP)/src/glsl/pp/libglslpp.a \
-   $(TOP)/src/glsl/cl/libglslcl.a
-
-SOURCES = \
-   compile.c \
-   process.c \
-   purify.c \
-   tokenise.c \
-   version.c
-
-APPS = $(SOURCES:%.c=%)
-
-INCLUDES = -I.
-
-
-# RULES #
-
-.SUFFIXES:
-.SUFFIXES: .c
-
-.c:
-   $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $ $(LIBS) -o $@
-
-.c.o:
-   $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $ -o $@
-
-
-# TARGETS #
-
-default: $(APPS)
-
-install:
-
-clean:
-   -rm -f $(APPS)
-   -rm -f *.o
diff --git a/src/glsl/apps/compile.c b/src/glsl/apps/compile.c
deleted file mode 100644
index 5114fc9..000
--- a/src/glsl/apps/compile.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * 
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- * 
- * 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, sub license, 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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 stdio.h
-#include stdlib.h
-#include string.h
-#include assert.h
-#include ../pp/sl_pp_public.h
-#include ../pp/sl_pp_purify.h
-#include ../cl/sl_cl_parse.h
-
-
-static void
-usage(void)
-{
-   printf(Usage:\n);
-   printf(  compile fragment|vertex|geometry source output\n);
-}
-
-int
-main(int argc,
- char *argv[])
-{
-   FILE *in;
-   long size;
-   char *inbuf;
-   struct sl_pp_purify_options options;
-   char errmsg[100] = ;
-   struct sl_pp_context *context;
-   unsigned int version;
-   FILE *out;
-   unsigned char *outbytes;
-   unsigned int cboutbytes;
-   unsigned int shader_type;
-
-   if (argc != 4) {
-  usage();
-  return 1;
-   }
-
-   if (!strcmp(argv[1], fragment)) {
-  shader_type = 1;
-   } else if (!strcmp(argv[1], vertex)) {
-  shader_type = 2;
-   } else if (!strcmp(argv[1], geometry)) {
-  shader_type = 3;
-   } else {
-  usage();
-  return 1;
-   }
-
-   in = fopen(argv[2], rb);
-   if (!in) {
-  printf(Could not open `%s' for read.\n, argv[2]);
-  usage();
-  return 1;
-   }
-
-   fseek(in, 0, SEEK_END);
-   size = ftell(in);
-   assert(size != -1);
-   if (size == -1) {
-  return 1;
-   }
-   fseek(in, 0, SEEK_SET);
-
-   out = fopen(argv[3], w);
-   if (!out) {
-  fclose(in);
-  printf(Could not open `%s' for write.\n, argv[3]);
-  usage();
-  return 1;
-   }
-
-   inbuf = malloc(size + 1);
-   if (!inbuf) {
-  fprintf(out, $OOMERROR\n);
-
-  fclose(out);
-  fclose(in);
-  printf(Out of memory.\n);
-  return 0;
-   }
-
-   if (fread(inbuf, 1, size, in) != size) {
-  

Mesa (master): p_compiler: add replacement va_copy

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 9960200d5eef97e38d5565cfc1775e3d8f7800a2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9960200d5eef97e38d5565cfc1775e3d8f7800a2

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Sat Aug 21 00:39:31 2010 +0200

p_compiler: add replacement va_copy

This might technically not always be correct, because va_copy might
be a function, or a system might not have va_copy, and not work with
assignment.

Hopefully this is never the case.
Without configure tests, it doesn't seem possible to do better.

---

 src/gallium/include/pipe/p_compiler.h |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/gallium/include/pipe/p_compiler.h 
b/src/gallium/include/pipe/p_compiler.h
index 1fa3ec8..0a5be43 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -79,6 +79,14 @@ typedef unsigned char boolean;
 #define FALSE false
 #endif
 
+#ifndef va_copy
+#ifdef __va_copy
+#define va_copy(dest, src) __va_copy((dest), (src))
+#else
+#define va_copy(dest, src) (dest) = (src)
+#endif
+#endif
+
 /* Function inlining */
 #ifndef INLINE
 #  ifdef __cplusplus

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


Mesa (master): os_stream: fix bugs in allocation path

2010-08-20 Thread Luca Barbieri
Module: Mesa
Branch: master
Commit: 132b9439e287f1febbb49362671743a5b90e303c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=132b9439e287f1febbb49362671743a5b90e303c

Author: Luca Barbieri l...@luca-barbieri.com
Date:   Sat Aug 21 00:39:48 2010 +0200

os_stream: fix bugs in allocation path

---

 src/gallium/auxiliary/os/os_stream.c |   24 
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/gallium/auxiliary/os/os_stream.c 
b/src/gallium/auxiliary/os/os_stream.c
index 2d4e185..7b9c17c 100644
--- a/src/gallium/auxiliary/os/os_stream.c
+++ b/src/gallium/auxiliary/os/os_stream.c
@@ -9,28 +9,20 @@ os_default_stream_vprintf (struct os_stream* stream, const 
char *format, va_list
 {
char buf[1024];
int retval;
-
-   retval = util_vsnprintf(buf, sizeof(buf), format, ap);
+   va_list ap2;
+   va_copy(ap2, ap);
+   retval = util_vsnprintf(buf, sizeof(buf), format, ap2);
+   va_end(ap2);
if(retval = 0)
{}
else if(retval  sizeof(buf))
   stream-write(stream, buf, retval);
else
{
-  int alloc = sizeof(buf);
-  char* str = NULL;
-  for(;;)
-  {
- alloc += alloc;
- if(str)
-FREE(str);
- str = MALLOC(alloc);
- if(!str)
-return -1;
-
- retval = util_vsnprintf(str, alloc, format, ap);
-  } while(retval = alloc);
-
+  char* str = MALLOC(retval + 1);
+  if(!str)
+ return -1;
+  retval = util_vsnprintf(str, retval + 1, format, ap);
   if(retval  0)
  stream-write(stream, str, retval);
   FREE(str);

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


Mesa (master): i965: Sandybridge doesn't have Compr4 mode, since it' s not needed any more.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: da1502494b63fcd65bc60f50e59241164481f8b3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=da1502494b63fcd65bc60f50e59241164481f8b3

Author: Zhenyu Wang zhen...@linux.intel.com
Date:   Fri Aug 20 14:32:44 2010 -0700

i965: Sandybridge doesn't have Compr4 mode, since it's not needed any more.

---

 src/mesa/drivers/dri/i965/brw_context.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 6d064b8..408fa0a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -144,7 +144,8 @@ GLboolean brwCreateContext( int api,
   brw-CMD_VF_STATISTICS = CMD_VF_STATISTICS_GM45;
   brw-CMD_PIPELINE_SELECT = CMD_PIPELINE_SELECT_GM45;
   brw-has_surface_tile_offset = GL_TRUE;
-  brw-has_compr4 = GL_TRUE;
+  if (intel-gen  6)
+ brw-has_compr4 = GL_TRUE;
   brw-has_aa_line_parameters = GL_TRUE;
   brw-has_pln = GL_TRUE;
   } else {

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


Mesa (master): i965: Adjust disasm of subreg numbers to be in units of the register type.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 0e2d0cc577270f86691d6bb84a50d11e3a6d0754
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e2d0cc577270f86691d6bb84a50d11e3a6d0754

Author: Zhenyu Wang zhen...@linux.intel.com
Date:   Fri Aug 20 14:28:39 2010 -0700

i965: Adjust disasm of subreg numbers to be in units of the register type.

This makes reading the code easier when matching up to the specs,
which also use this format.

---

 src/mesa/drivers/dri/i965/brw_disasm.c |   26 --
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c 
b/src/mesa/drivers/dri/i965/brw_disasm.c
index c148dbc..6a87bab 100644
--- a/src/mesa/drivers/dri/i965/brw_disasm.c
+++ b/src/mesa/drivers/dri/i965/brw_disasm.c
@@ -236,6 +236,16 @@ char *reg_encoding[8] = {
 [7] = F
 };
 
+int reg_type_size[8] = {
+[0] = 4,
+[1] = 4,
+[2] = 2,
+[3] = 2,
+[4] = 1,
+[5] = 1,
+[7] = 4
+};
+
 char *imm_encoding[8] = {
 [0] = UD,
 [1] = D,
@@ -482,7 +492,8 @@ static int dest (FILE *file, struct brw_instruction *inst)
if (err == -1)
return 0;
if (inst-bits1.da1.dest_subreg_nr)
-   format (file, .%d, inst-bits1.da1.dest_subreg_nr);
+   format (file, .%d, inst-bits1.da1.dest_subreg_nr /
+
reg_type_size[inst-bits1.da1.dest_reg_type]);
format (file, %d, inst-bits1.da1.dest_horiz_stride);
err |= control (file, dest reg encoding, reg_encoding, 
inst-bits1.da1.dest_reg_type, NULL);
}
@@ -490,7 +501,8 @@ static int dest (FILE *file, struct brw_instruction *inst)
{
string (file, g[a0);
if (inst-bits1.ia1.dest_subreg_nr)
-   format (file, .%d, inst-bits1.ia1.dest_subreg_nr);
+   format (file, .%d, inst-bits1.ia1.dest_subreg_nr /
+   
reg_type_size[inst-bits1.ia1.dest_reg_type]);
if (inst-bits1.ia1.dest_indirect_offset)
format (file,  %d, inst-bits1.ia1.dest_indirect_offset);
string (file, ]);
@@ -506,7 +518,8 @@ static int dest (FILE *file, struct brw_instruction *inst)
if (err == -1)
return 0;
if (inst-bits1.da16.dest_subreg_nr)
-   format (file, .%d, inst-bits1.da16.dest_subreg_nr);
+   format (file, .%d, inst-bits1.da16.dest_subreg_nr /
+
reg_type_size[inst-bits1.da16.dest_reg_type]);
string (file, 1);
err |= control (file, writemask, writemask, 
inst-bits1.da16.dest_writemask, NULL);
err |= control (file, dest reg encoding, reg_encoding, 
inst-bits1.da16.dest_reg_type, NULL);
@@ -547,7 +560,7 @@ static int src_da1 (FILE *file, GLuint type, GLuint 
_reg_file,
 if (err == -1)
return 0;
 if (sub_reg_num)
-   format (file, .%d, sub_reg_num);
+   format (file, .%d, sub_reg_num / reg_type_size[type]); /* use formal 
style like spec */
 src_align1_region (file, _vert_stride, _width, _horiz_stride);
 err |= control (file, src reg encoding, reg_encoding, type, NULL);
 return err;
@@ -601,11 +614,12 @@ static int src_da16 (FILE *file,
 if (err == -1)
return 0;
 if (_subreg_nr)
-   format (file, .%d, _subreg_nr);
+   /* bit4 for subreg number byte addressing. Make this same meaning as
+  in da1 case, so output looks consistent. */
+   format (file, .%d, 16 / reg_type_size[_reg_type]);
 string (file, );
 err |= control (file, vert stride, vert_stride, _vert_stride, NULL);
 string (file, ,4,1);
-err |= control (file, src da16 reg type, reg_encoding, _reg_type, NULL);
 /*
  * Three kinds of swizzle display:
  *  identity - nothing printed

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


Mesa (master): i965: Mention the mlen and rlen for URB reads.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: ffb5095d56c0f58a35e12d40bb4ffc869e4071bd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffb5095d56c0f58a35e12d40bb4ffc869e4071bd

Author: Zhenyu Wang zhen...@linux.intel.com
Date:   Fri Aug 20 14:36:46 2010 -0700

i965: Mention the mlen and rlen for URB reads.

---

 src/mesa/drivers/dri/i965/brw_disasm.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c 
b/src/mesa/drivers/dri/i965/brw_disasm.c
index 6a87bab..5e5db32 100644
--- a/src/mesa/drivers/dri/i965/brw_disasm.c
+++ b/src/mesa/drivers/dri/i965/brw_disasm.c
@@ -949,6 +949,11 @@ int brw_disasm (FILE *file, struct brw_instruction *inst, 
int gen)
inst-bits3.urb.used, space);
err |= control (file, urb complete, urb_complete,
inst-bits3.urb.complete, space);
+   if (gen = 5) {
+   format (file,  mlen %d, rlen %d\n,
+   inst-bits3.urb_gen5.msg_length,
+   inst-bits3.urb_gen5.response_length);
+   }
break;
case BRW_MESSAGE_TARGET_THREAD_SPAWNER:
break;

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


Mesa (master): i965: Add AccWrCtl support on Sandybridge.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 93ba0055c325007656c14ba38302e21be3dc599f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=93ba0055c325007656c14ba38302e21be3dc599f

Author: Zhenyu Wang zhen...@linux.intel.com
Date:   Fri Aug 20 14:37:19 2010 -0700

i965: Add AccWrCtl support on Sandybridge.

Whenever the accumulator results are needed, this bit must be set.

---

 src/mesa/drivers/dri/i965/brw_disasm.c  |7 +++
 src/mesa/drivers/dri/i965/brw_eu.c  |6 ++
 src/mesa/drivers/dri/i965/brw_eu.h  |1 +
 src/mesa/drivers/dri/i965/brw_structs.h |5 +++--
 src/mesa/drivers/dri/i965/brw_vs_emit.c |3 +++
 5 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c 
b/src/mesa/drivers/dri/i965/brw_disasm.c
index 5e5db32..b546380 100644
--- a/src/mesa/drivers/dri/i965/brw_disasm.c
+++ b/src/mesa/drivers/dri/i965/brw_disasm.c
@@ -159,6 +159,11 @@ char *saturate[2] = {
 [1] = .sat
 };
 
+char *accwr[2] = {
+[0] = ,
+[1] = AccWrEnable
+};
+
 char *exec_size[8] = {
 [0] = 1,
 [1] = 2,
@@ -993,6 +998,8 @@ int brw_disasm (FILE *file, struct brw_instruction *inst, 
int gen)
   inst-header.compression_control, space);
}
err |= control (file, thread control, thread_ctrl, 
inst-header.thread_control, space);
+   if (gen = 6)
+   err |= control (file, acc write control, accwr, 
inst-header.acc_wr_control, space);
if (inst-header.opcode == BRW_OPCODE_SEND)
err |= control (file, end of thread, end_of_thread,
inst-bits3.generic.end_of_thread, space);
diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
b/src/mesa/drivers/dri/i965/brw_eu.c
index 4e7c122..2ff39e8 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -85,6 +85,12 @@ void brw_set_saturate( struct brw_compile *p, GLuint value )
p-current-header.saturate = value;
 }
 
+void brw_set_acc_write_control(struct brw_compile *p, GLuint value)
+{
+   if (p-brw-intel.gen = 6)
+  p-current-header.acc_wr_control = value;
+}
+
 void brw_push_insn_state( struct brw_compile *p )
 {
assert(p-current != p-stack[BRW_EU_MAX_INSN_STACK-1]);
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index d15a8f9..1ead445 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -770,6 +770,7 @@ void brw_set_compression_control( struct brw_compile *p, 
GLboolean control );
 void brw_set_predicate_control_flag_value( struct brw_compile *p, GLuint value 
);
 void brw_set_predicate_control( struct brw_compile *p, GLuint pc );
 void brw_set_conditionalmod( struct brw_compile *p, GLuint conditional );
+void brw_set_acc_write_control(struct brw_compile *p, GLuint value);
 
 void brw_init_compile( struct brw_context *, struct brw_compile *p );
 const GLuint *brw_get_program( struct brw_compile *p, GLuint *sz );
diff --git a/src/mesa/drivers/dri/i965/brw_structs.h 
b/src/mesa/drivers/dri/i965/brw_structs.h
index 2fde42a..1d6018f 100644
--- a/src/mesa/drivers/dri/i965/brw_structs.h
+++ b/src/mesa/drivers/dri/i965/brw_structs.h
@@ -1305,13 +1305,14 @@ struct brw_instruction
   GLuint access_mode:1;
   GLuint mask_control:1;
   GLuint dependency_control:2;
-  GLuint compression_control:2;
+  GLuint compression_control:2; /* gen6: quater control */
   GLuint thread_control:2;
   GLuint predicate_control:4;
   GLuint predicate_inverse:1;
   GLuint execution_size:3;
   GLuint destreg__conditionalmod:4; /* destreg - send, conditionalmod - 
others */
-  GLuint pad0:2;
+  GLuint acc_wr_control:1;
+  GLuint cmpt_control:1;
   GLuint debug_control:1;
   GLuint saturate:1;
} header;
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c 
b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index 18eb845..2f4653f 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -1397,6 +1397,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
 * of zeros followed by two sets of NDC coordinates:
 */
brw_set_access_mode(p, BRW_ALIGN_1);
+   brw_set_acc_write_control(p, 0);
 
/* The VUE layout is documented in Volume 2a. */
if (intel-gen = 6) {
@@ -1578,6 +1579,8 @@ void brw_vs_emit(struct brw_vs_compile *c )
brw_set_access_mode(p, BRW_ALIGN_16);
if_depth_in_loop[loop_depth] = 0;
 
+   brw_set_acc_write_control(p, 1);
+
for (insn = 0; insn  nr_insns; insn++) {
GLuint i;
struct prog_instruction *inst = c-vp-program.Base.Instructions[insn];

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


Mesa (master): i965: Set the maximum number of threads on Sandybridge.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 35c127362f7b0c186923934f34148de319093cbf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=35c127362f7b0c186923934f34148de319093cbf

Author: Zhenyu Wang zhen...@linux.intel.com
Date:   Fri Aug 20 14:38:56 2010 -0700

i965: Set the maximum number of threads on Sandybridge.

---

 src/mesa/drivers/dri/i965/brw_context.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 408fa0a..d2b2016 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -154,7 +154,11 @@ GLboolean brwCreateContext( int api,
}
 
/* WM maximum threads is number of EUs times number of threads per EU. */
-   if (intel-gen == 5) {
+   if (intel-gen = 6) {
+  brw-urb.size = 1024;
+  brw-vs_max_threads = 60;
+  brw-wm_max_threads = 80;
+   } else if (intel-gen == 5) {
   brw-urb.size = 1024;
   brw-vs_max_threads = 72;
   brw-wm_max_threads = 12 * 6;

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


Mesa (master): i965: Set the destination horiz stride even for da16, as SNB seems to need it.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 3ce2eccbfb925a3af0b91a89a9f7a3603fa45d2d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ce2eccbfb925a3af0b91a89a9f7a3603fa45d2d

Author: Zhenyu Wang zhen...@linux.intel.com
Date:   Fri Aug 20 15:01:11 2010 -0700

i965: Set the destination horiz stride even for da16, as SNB seems to need it.

---

 src/mesa/drivers/dri/i965/brw_eu_emit.c |4 
 src/mesa/drivers/dri/i965/brw_structs.h |4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 0d5d17f..523f119 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -75,6 +75,8 @@ static void brw_set_dest( struct brw_instruction *insn,
   else {
 insn-bits1.da16.dest_subreg_nr = dest.subnr / 16;
 insn-bits1.da16.dest_writemask = dest.dw1.bits.writemask;
+/* even ignored in da16, still need to set as '01' */
+insn-bits1.da16.dest_horiz_stride = 1;
   }
}
else {
@@ -90,6 +92,8 @@ static void brw_set_dest( struct brw_instruction *insn,
   }
   else {
 insn-bits1.ia16.dest_indirect_offset = dest.dw1.bits.indirect_offset;
+/* even ignored in da16, still need to set as '01' */
+insn-bits1.ia16.dest_horiz_stride = 1;
   }
}
 
diff --git a/src/mesa/drivers/dri/i965/brw_structs.h 
b/src/mesa/drivers/dri/i965/brw_structs.h
index 1d6018f..cdd2998 100644
--- a/src/mesa/drivers/dri/i965/brw_structs.h
+++ b/src/mesa/drivers/dri/i965/brw_structs.h
@@ -1360,7 +1360,7 @@ struct brw_instruction
 GLuint dest_writemask:4;
 GLuint dest_subreg_nr:1;
 GLuint dest_reg_nr:8;
-GLuint pad1:2;
+GLuint dest_horiz_stride:2;
 GLuint dest_address_mode:1;
   } da16;
 
@@ -1374,7 +1374,7 @@ struct brw_instruction
 GLuint dest_writemask:4;
 GLint dest_indirect_offset:6;
 GLuint dest_subreg_nr:3;
-GLuint pad1:2;
+GLuint dest_horiz_stride:2;
 GLuint dest_address_mode:1;
   } ia16;
} bits1;

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


Mesa (master): i965: Also use the SIMD8 FB writes for SIMD8 mode on non-SNB .

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: e6ec500e19f455237828f4f3955f888ad0b56382
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6ec500e19f455237828f4f3955f888ad0b56382

Author: Eric Anholt e...@anholt.net
Date:   Fri Aug 20 15:32:17 2010 -0700

i965: Also use the SIMD8 FB writes for SIMD8 mode on non-SNB.

---

 src/mesa/drivers/dri/i965/brw_eu.h  |1 +
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   13 +++--
 src/mesa/drivers/dri/i965/brw_wm_emit.c |   21 ++---
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index 1ead445..6e9e210 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -845,6 +845,7 @@ void brw_ff_sync(struct brw_compile *p,
   GLboolean eot);
 
 void brw_fb_WRITE(struct brw_compile *p,
+ int dispatch_width,
   struct brw_reg dest,
   GLuint msg_reg_nr,
   struct brw_reg src0,
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index c9b4770..a6ca030 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -1350,6 +1350,7 @@ void brw_dp_READ_4_vs_relative(struct brw_compile *p,
 
 
 void brw_fb_WRITE(struct brw_compile *p,
+ int dispatch_width,
   struct brw_reg dest,
   GLuint msg_reg_nr,
   struct brw_reg src0,
@@ -1370,18 +1371,18 @@ void brw_fb_WRITE(struct brw_compile *p,
/* headerless version, just submit color payload */
src0 = brw_message_reg(msg_reg_nr);
 
-   if (msg_length = 8)
- msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;
-   else
- msg_control = 
BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01;
msg_type = BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE_GEN6;
} else {
   insn-header.destreg__conditionalmod = msg_reg_nr;
 
-  msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;
-   msg_type = BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE;
+  msg_type = BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE;
}
 
+   if (dispatch_width == 16)
+  msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;
+   else
+  msg_control = 
BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01;
+
brw_set_dest(insn, dest);
brw_set_src0(insn, src0);
brw_set_dp_write_message(p-brw,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c 
b/src/mesa/drivers/dri/i965/brw_wm_emit.c
index 78de2ce..5c07108 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c
@@ -1255,6 +1255,7 @@ static void fire_fb_write( struct brw_wm_compile *c,
/* Send framebuffer write message: */
 /*  send (16) null.01:uw m0   r0.08;8,1:uw   0x85a04000:ud
{ Align1 EOT } */
brw_fb_WRITE(p,
+   c-dispatch_width,
dst,
base_reg,
retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW),
@@ -1376,17 +1377,10 @@ void emit_fb_write(struct brw_wm_compile *c,
}
/* skip over the regs populated above:
 */
-   if (intel-gen  6) {
-  nr += 8; /* XXX: always uses SIMD16 write currently. */
-   } else {
-  if (c-dispatch_width == 16)
-nr += 8;
-  else
-nr += 4;
-
-  /* Subtract off the message header, since we send headerless. */
-  nr -= 2;
-   }
+   if (c-dispatch_width == 16)
+  nr += 8;
+   else
+  nr += 4;
 
brw_pop_insn_state(p);
 
@@ -1420,6 +1414,11 @@ void emit_fb_write(struct brw_wm_compile *c,
   nr += 2;
}
 
+   if (intel-gen = 6) {
+  /* Subtract off the message header, since we send headerless. */
+  nr -= 2;
+   }
+
if (!c-key.runtime_check_aads_emit) {
   if (c-key.aa_dest_stencil_reg)
 emit_aa(c, arg1, 2);

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


Mesa (master): i965: Add support for FB writes on Sandybridge.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 5266c0a0c82de625ccac57e7559f57399f761e9e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5266c0a0c82de625ccac57e7559f57399f761e9e

Author: Zhenyu Wang zhen...@linux.intel.com
Date:   Fri Aug 20 15:02:19 2010 -0700

i965: Add support for FB writes on Sandybridge.

---

 src/mesa/drivers/dri/i965/brw_eu_emit.c |   52 +--
 src/mesa/drivers/dri/i965/brw_wm_emit.c |   34 +++-
 2 files changed, 74 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 523f119..c9b4770 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -372,9 +372,23 @@ static void brw_set_dp_write_message( struct brw_context 
*brw,
  GLuint send_commit_msg)
 {
struct intel_context *intel = brw-intel;
-   brw_set_src1(insn, brw_imm_d(0));
+   brw_set_src1(insn, brw_imm_ud(0));
 
-   if (intel-gen == 5) {
+   if (intel-gen = 6) {
+   insn-bits3.dp_render_cache.binding_table_index = binding_table_index;
+   insn-bits3.dp_render_cache.msg_control = msg_control;
+   insn-bits3.dp_render_cache.pixel_scoreboard_clear = 
pixel_scoreboard_clear;
+   insn-bits3.dp_render_cache.msg_type = msg_type;
+   insn-bits3.dp_render_cache.send_commit_msg = send_commit_msg;
+   insn-bits3.dp_render_cache.header_present = 0; /* XXX */
+   insn-bits3.dp_render_cache.response_length = response_length;
+   insn-bits3.dp_render_cache.msg_length = msg_length;
+   insn-bits3.dp_render_cache.end_of_thread = end_of_thread;
+   insn-header.destreg__conditionalmod = 
BRW_MESSAGE_TARGET_DATAPORT_WRITE;
+   /* XXX really need below? */
+   insn-bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_DATAPORT_WRITE;
+   insn-bits2.send_gen5.end_of_thread = end_of_thread;
+   } else if (intel-gen == 5) {
insn-bits3.dp_write_gen5.binding_table_index = binding_table_index;
insn-bits3.dp_write_gen5.msg_control = msg_control;
insn-bits3.dp_write_gen5.pixel_scoreboard_clear = 
pixel_scoreboard_clear;
@@ -1344,22 +1358,40 @@ void brw_fb_WRITE(struct brw_compile *p,
   GLuint response_length,
   GLboolean eot)
 {
-   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
-   
+   struct intel_context *intel = p-brw-intel;
+   struct brw_instruction *insn;
+   GLuint msg_control, msg_type;
+
+   insn = next_insn(p, BRW_OPCODE_SEND);
insn-header.predicate_control = 0; /* XXX */
-   insn-header.compression_control = BRW_COMPRESSION_NONE; 
-   insn-header.destreg__conditionalmod = msg_reg_nr;
-  
+   insn-header.compression_control = BRW_COMPRESSION_NONE;
+
+   if (intel-gen = 6) {
+   /* headerless version, just submit color payload */
+   src0 = brw_message_reg(msg_reg_nr);
+
+   if (msg_length = 8)
+ msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;
+   else
+ msg_control = 
BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01;
+   msg_type = BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE_GEN6;
+   } else {
+  insn-header.destreg__conditionalmod = msg_reg_nr;
+
+  msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;
+   msg_type = BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE;
+   }
+
brw_set_dest(insn, dest);
brw_set_src0(insn, src0);
brw_set_dp_write_message(p-brw,
insn,
binding_table_index,
-   
BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE, /* msg_control */
-   BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE, /* 
msg_type */
+   msg_control,
+   msg_type,
msg_length,
1,  /* pixel scoreboard */
-   response_length, 
+   response_length,
eot,
0 /* send_commit_msg */);
 }
diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c 
b/src/mesa/drivers/dri/i965/brw_wm_emit.c
index f2ace7d..78de2ce 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c
@@ -1230,6 +1230,7 @@ static void fire_fb_write( struct brw_wm_compile *c,
   GLuint eot )
 {
struct brw_compile *p = c-func;
+   struct intel_context *intel = p-brw-intel;
struct brw_reg dst;
 
if (c-dispatch_width == 16)
@@ -1240,6 +1241,7 @@ static void fire_fb_write( struct brw_wm_compile *c,
/* Pass through control information:
 */
 /*  mov (8) m1.01:ud   r1.08;8,1:ud   { Align1 NoMask } */
+   if (intel-gen  6) /* gen6, use headerless for fb write */
{
   brw_push_insn_state(p);
   brw_set_mask_control(p, BRW_MASK_DISABLE); /* ? */
@@ -1297,6 +1299,8 @@ void 

Mesa (master): i965: Rename nr_depth_regs to nr_payload_regs.

2010-08-20 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 501c9dc62774a73c080d500a1eab773b0da9577e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=501c9dc62774a73c080d500a1eab773b0da9577e

Author: Eric Anholt e...@anholt.net
Date:   Mon Aug 16 18:35:04 2010 -0700

i965: Rename nr_depth_regs to nr_payload_regs.

Only 8 out of the up to 13 regs are for source/dest depth, so the name
wasn't particularly appropriate.  Note that this doesn't count the
constant or URB payload regs.  Also, don't pre-divide by 2, so it's
actually a number of registers.

---

 src/mesa/drivers/dri/i965/brw_wm.h   |2 +-
 src/mesa/drivers/dri/i965/brw_wm_glsl.c  |6 +++---
 src/mesa/drivers/dri/i965/brw_wm_iz.c|2 +-
 src/mesa/drivers/dri/i965/brw_wm_pass0.c |2 +-
 src/mesa/drivers/dri/i965/brw_wm_pass2.c |4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm.h 
b/src/mesa/drivers/dri/i965/brw_wm.h
index 40f51c2..34f2d0c 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -61,7 +61,7 @@ struct brw_wm_prog_key {
GLuint source_depth_reg:3;
GLuint aa_dest_stencil_reg:3;
GLuint dest_depth_reg:3;
-   GLuint nr_depth_regs:3;
+   GLuint nr_payload_regs:4;
GLuint computes_depth:1;/* could be derived from program string */
GLuint source_depth_to_render_target:1;
GLuint flat_shade:1;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c 
b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
index f13b0aa..7a31b9a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
@@ -303,13 +303,13 @@ static void prealloc_reg(struct brw_wm_compile *c)
 c-first_free_grf = 0;
 
 for (i = 0; i  4; i++) {
-if (i  c-key.nr_depth_regs) 
+   if (i  (c-key.nr_payload_regs + 1) / 2)
 reg = brw_vec8_grf(i * 2, 0);
 else
 reg = brw_vec8_grf(0, 0);
set_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH, i, reg);
 }
-reg_index += 2 * c-key.nr_depth_regs;
+reg_index += c-key.nr_payload_regs;
 
 /* constants */
 {
@@ -380,7 +380,7 @@ static void prealloc_reg(struct brw_wm_compile *c)
}
 }
 
-c-prog_data.first_curbe_grf = c-key.nr_depth_regs * 2;
+c-prog_data.first_curbe_grf = c-key.nr_payload_regs;
 c-prog_data.urb_read_length = urb_read_length;
 c-prog_data.curb_read_length = c-nr_creg;
 c-emit_mask_reg = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, reg_index, 0);
diff --git a/src/mesa/drivers/dri/i965/brw_wm_iz.c 
b/src/mesa/drivers/dri/i965/brw_wm_iz.c
index 5e399ac..8505ef1 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_iz.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_iz.c
@@ -152,6 +152,6 @@ void brw_wm_lookup_iz( GLuint line_aa,
   reg+=2;
}
 
-   key-nr_depth_regs = (reg+1)/2;
+   key-nr_payload_regs = reg;
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass0.c 
b/src/mesa/drivers/dri/i965/brw_wm_pass0.c
index 05de85a..8fc960b 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_pass0.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_pass0.c
@@ -379,7 +379,7 @@ static void pass0_init_payload( struct brw_wm_compile *c )
GLuint i;
 
for (i = 0; i  4; i++) {
-  GLuint j = i = c-key.nr_depth_regs ? 0 : i;
+  GLuint j = i = (c-key.nr_payload_regs + 1) / 2 ? 0 : i;
   pass0_set_fpreg_value( c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH, i, 
 c-payload.depth[j] );
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass2.c 
b/src/mesa/drivers/dri/i965/brw_wm_pass2.c
index 31303fe..0499506 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_pass2.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_pass2.c
@@ -76,7 +76,7 @@ static void init_registers( struct brw_wm_compile *c )
for (j = 0; j  c-grf_limit; j++) 
   c-pass2_grf[j].nextuse = BRW_WM_MAX_INSN;
 
-   for (j = 0; j  c-key.nr_depth_regs; j++) 
+   for (j = 0; j  (c-key.nr_payload_regs + 1) / 2; j++)
   prealloc_reg(c, c-payload.depth[j], i++);
 
for (j = 0; j  c-nr_creg; j++) 
@@ -101,7 +101,7 @@ static void init_registers( struct brw_wm_compile *c )
 
assert(nr_interp_regs = 1);
 
-   c-prog_data.first_curbe_grf = c-key.nr_depth_regs * 2;
+   c-prog_data.first_curbe_grf = c-key.nr_payload_regs;
c-prog_data.urb_read_length = nr_interp_regs * 2;
c-prog_data.curb_read_length = c-nr_creg * 2;
 

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


Mesa (master): evergreen : initial support driver code.

2010-08-20 Thread Alex Deucher
Module: Mesa
Branch: master
Commit: 0eac4b8740d4434037677166f2339e894d4ebac4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0eac4b8740d4434037677166f2339e894d4ebac4

Author: richard rich...@richard-desktop3.(none)
Date:   Fri Aug 20 19:09:25 2010 -0400

evergreen : initial support driver code.

---

 src/mesa/drivers/dri/r600/Makefile |9 +
 src/mesa/drivers/dri/r600/evergreen_chip.c | 1290 ++
 src/mesa/drivers/dri/r600/evergreen_chip.h |  516 ++
 src/mesa/drivers/dri/r600/evergreen_context.c  |  109 ++
 src/mesa/drivers/dri/r600/evergreen_context.h  |   38 +
 src/mesa/drivers/dri/r600/evergreen_diff.h |  335 
 src/mesa/drivers/dri/r600/evergreen_fragprog.c |  808 +
 src/mesa/drivers/dri/r600/evergreen_fragprog.h |   75 +
 src/mesa/drivers/dri/r600/evergreen_ioctl.c|   53 +
 src/mesa/drivers/dri/r600/evergreen_ioctl.h|   36 +
 src/mesa/drivers/dri/r600/evergreen_off.h  |  881 +
 src/mesa/drivers/dri/r600/evergreen_oglprog.c  |  193 ++
 src/mesa/drivers/dri/r600/evergreen_oglprog.h  |   33 +
 src/mesa/drivers/dri/r600/evergreen_render.c   |  937 ++
 src/mesa/drivers/dri/r600/evergreen_sq.h   |  735 
 src/mesa/drivers/dri/r600/evergreen_state.c| 1879 
 src/mesa/drivers/dri/r600/evergreen_state.h|   47 +
 src/mesa/drivers/dri/r600/evergreen_tex.c  | 1551 
 src/mesa/drivers/dri/r600/evergreen_tex.h  |   38 +
 src/mesa/drivers/dri/r600/evergreen_vertprog.c |  729 
 src/mesa/drivers/dri/r600/evergreen_vertprog.h |  107 ++
 src/mesa/drivers/dri/r600/r600_cmdbuf.c|9 +-
 src/mesa/drivers/dri/r600/r600_cmdbuf.h|   40 +
 src/mesa/drivers/dri/r600/r600_context.c   |   89 +-
 src/mesa/drivers/dri/r600/r600_context.h   |   50 +
 src/mesa/drivers/dri/r600/r600_emit.c  |   66 +
 src/mesa/drivers/dri/r600/r600_emit.h  |   10 +
 src/mesa/drivers/dri/r600/r600_texstate.c  |   26 +
 src/mesa/drivers/dri/r600/r700_assembler.c | 1588 +++--
 src/mesa/drivers/dri/r600/r700_assembler.h |   28 +-
 src/mesa/drivers/dri/r600/r700_chip.c  |  122 +-
 src/mesa/drivers/dri/r600/r700_chip.h  |7 +
 src/mesa/drivers/dri/r600/r700_fragprog.c  |   33 +
 src/mesa/drivers/dri/r600/r700_fragprog.h  |5 +
 src/mesa/drivers/dri/r600/r700_oglprog.c   |   21 +
 src/mesa/drivers/dri/r600/r700_state.c |   16 +-
 src/mesa/drivers/dri/r600/r700_vertprog.c  |   55 +-
 src/mesa/drivers/dri/r600/r700_vertprog.h  |5 +
 src/mesa/drivers/dri/radeon/radeon_chipset.h   |   47 +
 .../drivers/dri/radeon/radeon_common_context.h |2 +
 src/mesa/drivers/dri/radeon/radeon_screen.c|   57 +-
 41 files changed, 12426 insertions(+), 249 deletions(-)

Diff:   
http://cgit.freedesktop.org/mesa/mesa/diff/?id=0eac4b8740d4434037677166f2339e894d4ebac4
___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit