Mesa (master): draw: Make copy of the TGSI tokens.

2011-09-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: fc31f9a3f255c5565ce2a3e9c73415bc17199e28
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc31f9a3f255c5565ce2a3e9c73415bc17199e28

Author: José Fonseca jfons...@vmware.com
Date:   Fri Sep 23 16:32:31 2011 +0100

draw: Make copy of the TGSI tokens.

There is no guarantee that the tokens TGSI will persist beyond the
create_fs_state. The pipe driver (and therefore the draw module) is
responsible for making copies of the TGSI tokens when it needs them.

Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/auxiliary/draw/draw_pipe_aaline.c  |4 +++-
 src/gallium/auxiliary/draw/draw_pipe_aapoint.c |4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c 
b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 458f85d..7ecd2aa 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -848,7 +848,7 @@ aaline_create_fs_state(struct pipe_context *pipe,
if (aafs == NULL)
   return NULL;
 
-   aafs-state = *fs;
+   aafs-state.tokens = tgsi_dup_tokens(fs-tokens);
 
/* pass-through */
aafs-driver_fs = aaline-driver_create_fs_state(pipe, fs);
@@ -882,6 +882,8 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
if (aafs-aaline_fs)
   aaline-driver_delete_fs_state(pipe, aafs-aaline_fs);
 
+   FREE((void*)aafs-state.tokens);
+
FREE(aafs);
 }
 
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c 
b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index 9265c37..698ab13 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -834,7 +834,7 @@ aapoint_create_fs_state(struct pipe_context *pipe,
if (aafs == NULL) 
   return NULL;
 
-   aafs-state = *fs;
+   aafs-state.tokens = tgsi_dup_tokens(fs-tokens);
 
/* pass-through */
aafs-driver_fs = aapoint-driver_create_fs_state(pipe, fs);
@@ -868,6 +868,8 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs)
if (aafs-aapoint_fs)
   aapoint-driver_delete_fs_state(pipe, aafs-aapoint_fs);
 
+   FREE((void*)aafs-state.tokens);
+
FREE(aafs);
 }
 

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


Mesa (master): draw: Never allocate duplicate extra vertex attribs.

2011-09-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 102bf6e2a70f565f03d5e9c4995b29d61c0aa165
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=102bf6e2a70f565f03d5e9c4995b29d61c0aa165

Author: José Fonseca jfons...@vmware.com
Date:   Fri Sep 23 19:55:47 2011 +0100

draw: Never allocate duplicate extra vertex attribs.

Prevents mismatches when the VS outputs generic attributes not used by
the FS.

Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/auxiliary/draw/draw_context.c |   50 ++---
 src/gallium/auxiliary/draw/draw_context.h |3 +
 src/gallium/auxiliary/draw/draw_pipe_aaline.c |8 ++-
 src/gallium/auxiliary/draw/draw_pipe_aapoint.c|   21 -
 src/gallium/auxiliary/draw/draw_pipe_wide_point.c |   18 +--
 5 files changed, 54 insertions(+), 46 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index b8f8623..6a85b79 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -450,7 +450,9 @@ draw_set_force_passthrough( struct draw_context *draw, 
boolean enable )
 
 
 /**
- * Allocate an extra vertex/geometry shader vertex attribute.
+ * Allocate an extra vertex/geometry shader vertex attribute, if it doesn't
+ * exist already.
+ *
  * This is used by some of the optional draw module stages such
  * as wide_point which may need to allocate additional generic/texcoord
  * attributes.
@@ -459,8 +461,17 @@ int
 draw_alloc_extra_vertex_attrib(struct draw_context *draw,
uint semantic_name, uint semantic_index)
 {
-   const int num_outputs = draw_current_shader_outputs(draw);
-   const int n = draw-extra_shader_outputs.num;
+   int slot;
+   uint num_outputs;
+   uint n;
+
+   slot = draw_find_shader_output(draw, semantic_name, semantic_index);
+   if (slot  0) {
+  return slot;
+   }
+
+   num_outputs = draw_current_shader_outputs(draw);
+   n = draw-extra_shader_outputs.num;
 
assert(n  Elements(draw-extra_shader_outputs.semantic_name));
 
@@ -485,6 +496,22 @@ draw_remove_extra_vertex_attribs(struct draw_context *draw)
 
 
 /**
+ * If a geometry shader is present, return its info, else the vertex shader's
+ * info.
+ */
+struct tgsi_shader_info *
+draw_get_shader_info(const struct draw_context *draw)
+{
+
+   if (draw-gs.geometry_shader) {
+  return draw-gs.geometry_shader-info;
+   } else {
+  return draw-vs.vertex_shader-info;
+   }
+}
+
+
+/**
  * Ask the draw module for the location/slot of the given vertex attribute in
  * a post-transformed vertex.
  *
@@ -503,13 +530,8 @@ int
 draw_find_shader_output(const struct draw_context *draw,
 uint semantic_name, uint semantic_index)
 {
-   const struct draw_vertex_shader *vs = draw-vs.vertex_shader;
-   const struct draw_geometry_shader *gs = draw-gs.geometry_shader;
+   const struct tgsi_shader_info *info = draw_get_shader_info(draw);
uint i;
-   const struct tgsi_shader_info *info = vs-info;
-
-   if (gs)
-  info = gs-info;
 
for (i = 0; i  info-num_outputs; i++) {
   if (info-output_semantic_name[i] == semantic_name 
@@ -541,16 +563,10 @@ draw_find_shader_output(const struct draw_context *draw,
 uint
 draw_num_shader_outputs(const struct draw_context *draw)
 {
+   const struct tgsi_shader_info *info = draw_get_shader_info(draw);
uint count;
 
-   /* If a geometry shader is present, its outputs go to the
-* driver, else the vertex shader's outputs.
-*/
-   if (draw-gs.geometry_shader)
-  count = draw-gs.geometry_shader-info.num_outputs;
-   else
-  count = draw-vs.vertex_shader-info.num_outputs;
-
+   count = info-num_outputs;
count += draw-extra_shader_outputs.num;
 
return count;
diff --git a/src/gallium/auxiliary/draw/draw_context.h 
b/src/gallium/auxiliary/draw/draw_context.h
index 9a7bf36..799eb94 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -96,6 +96,9 @@ boolean
 draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context 
*pipe);
 
 
+struct tgsi_shader_info *
+draw_get_shader_info(const struct draw_context *draw);
+
 int
 draw_find_shader_output(const struct draw_context *draw,
 uint semantic_name, uint semantic_index);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c 
b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 7ecd2aa..0b368da 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -374,7 +374,9 @@ generate_aaline_fs(struct aaline_stage *aaline)
  newLen, transform.base);
 
 #if 0 /* DEBUG */
+   debug_printf(draw_aaline, orig shader:\n);
tgsi_dump(orig_fs-tokens, 0);
+   debug_printf(draw_aaline, new shader:\n);
tgsi_dump(aaline_fs.tokens, 0);
 #endif
 
@@ -692,12 +694,12 @@ aaline_first_line(struct draw_stage *stage, struct 
prim_header *header)
}
 
/* 

Mesa (master): g3dvl: Don't use SCALED types for iDCT

2011-09-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 86f97f7dc015092aa7fa1b0bdc4fe0a9f696d418
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=86f97f7dc015092aa7fa1b0bdc4fe0a9f696d418

Author: Christian König deathsim...@vodafone.de
Date:   Fri Sep 16 18:43:44 2011 +0200

g3dvl: Don't use SCALED types for iDCT

This should bring g3dvl back to work until we figured out
how SCALED types should really work.

Signed-off-by: Christian König deathsim...@vodafone.de

---

 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index f370669..7e7fa99 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -49,8 +49,8 @@ struct format_config {
 };
 
 static const struct format_config bitstream_format_config[] = {
-   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 
PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SSCALED },
-   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 
PIPE_FORMAT_R16G16B16A16_SSCALED, 1.0f, SCALE_FACTOR_SSCALED },
+//   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 
PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SSCALED },
+//   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 
PIPE_FORMAT_R16G16B16A16_SSCALED, 1.0f, SCALE_FACTOR_SSCALED },
{ PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, 
PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SNORM },
{ PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, 
PIPE_FORMAT_R16G16B16A16_SNORM, 1.0f, SCALE_FACTOR_SNORM }
 };
@@ -59,8 +59,8 @@ static const unsigned num_bitstream_format_configs =
sizeof(bitstream_format_config) / sizeof(struct format_config);
 
 static const struct format_config idct_format_config[] = {
-   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 
PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SSCALED },
-   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 
PIPE_FORMAT_R16G16B16A16_SSCALED, 1.0f, SCALE_FACTOR_SSCALED },
+//   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 
PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SSCALED },
+//   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 
PIPE_FORMAT_R16G16B16A16_SSCALED, 1.0f, SCALE_FACTOR_SSCALED },
{ PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, 
PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SNORM },
{ PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, 
PIPE_FORMAT_R16G16B16A16_SNORM, 1.0f, SCALE_FACTOR_SNORM }
 };

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


Mesa (master): st/vdpau: Link vdpau targets with librt to avoid unresolved symbols error related to the use of the clock_gettime () function

2011-09-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 1f23ac8082b51bc22000933919256e5a03fd073f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1f23ac8082b51bc22000933919256e5a03fd073f

Author: Emeric Grange emeric.gra...@gmail.com
Date:   Thu Sep 22 21:03:43 2011 +0200

st/vdpau: Link vdpau targets with librt to avoid unresolved symbols error 
related to the use of the clock_gettime() function

This patch fix a Unresolved Symbols run time error when using G3DVL
through the VDPAU state tracker, by linking the vdpau targets with librt.
Reported by Arkadiusz Miśkiewicz.

Caused by this commit :
commit e911dbb56374edf9f3b7c4cec0cf9a22738bb198
Author: Emeric Grange emeric.gra...@gmail.com
Date:   Mon Sep 12 23:39:33 2011 +0200

Signed-off-by: Emeric Grange emeric.gra...@gmail.com

---

 src/gallium/targets/Makefile.vdpau |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/targets/Makefile.vdpau 
b/src/gallium/targets/Makefile.vdpau
index c0937ff..c634915 100644
--- a/src/gallium/targets/Makefile.vdpau
+++ b/src/gallium/targets/Makefile.vdpau
@@ -11,7 +11,7 @@ INCLUDES = -I$(TOP)/src/gallium/include \
   -I$(TOP)/src/gallium/winsys/g3dvl \
   $(DRIVER_INCLUDES)
 DEFINES = -DGALLIUM_TRACE -DVER_MAJOR=$(VDPAU_MAJOR) 
-DVER_MINOR=$(VDPAU_MINOR) $(DRIVER_DEFINES)
-LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lvdpau -lXext -lX11 -lm
+LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lvdpau -lXext -lX11 -lm -lrt
 STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/vdpau/libvdpautracker.a
 
 ifeq ($(MESA_LLVM),1)

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


Mesa (master): softpipe: Use memory allocation macros.

2011-09-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: f32c9c210875b2ce4878f97b84bdd4739bd489f9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f32c9c210875b2ce4878f97b84bdd4739bd489f9

Author: José Fonseca jose.r.fons...@gmail.com
Date:   Sun Sep 25 11:46:49 2011 +0100

softpipe: Use memory allocation macros.

Fixes segfault with memory debugging on.

---

 src/gallium/drivers/softpipe/sp_state_shader.c |4 ++--
 src/gallium/drivers/softpipe/sp_tex_sample.c   |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c 
b/src/gallium/drivers/softpipe/sp_state_shader.c
index da89527..d7d0599 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -93,8 +93,8 @@ create_fs_variant(struct softpipe_context *softpipe,
}
 
if (stipple_fs) {
-  free((void *) stipple_fs-tokens);
-  free(stipple_fs);
+  FREE((void *) stipple_fs-tokens);
+  FREE(stipple_fs);
}
 
return var;
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c 
b/src/gallium/drivers/softpipe/sp_tex_sample.c
index dd33a10..2e91a70 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -1722,7 +1722,7 @@ create_filter_table(void)
 {
unsigned i;
if (!weightLut) {
-  weightLut = (float *) malloc(WEIGHT_LUT_SIZE * sizeof(float));
+  weightLut = (float *) MALLOC(WEIGHT_LUT_SIZE * sizeof(float));
 
   for (i = 0; i  WEIGHT_LUT_SIZE; ++i) {
  float alpha = 2;

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


Mesa (master): llvmpipe: Always use memory allocation macros.

2011-09-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 6921d4cd57927da779b4ff773ba85cfb67c7f7f1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6921d4cd57927da779b4ff773ba85cfb67c7f7f1

Author: José Fonseca jose.r.fons...@gmail.com
Date:   Sun Sep 25 11:48:00 2011 +0100

llvmpipe: Always use memory allocation macros.

---

 src/gallium/drivers/llvmpipe/lp_tile_image.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c 
b/src/gallium/drivers/llvmpipe/lp_tile_image.c
index 0938f7a..4d53cde 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_image.c
+++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c
@@ -33,6 +33,7 @@
 
 
 #include util/u_format.h
+#include util/u_memory.h
 #include lp_tile_soa.h
 #include lp_tile_image.h
 
@@ -313,7 +314,7 @@ test_tiled_linear_conversion(void *data,
unsigned wt = (width + TILE_SIZE - 1) / TILE_SIZE;
unsigned ht = (height + TILE_SIZE - 1) / TILE_SIZE;
 
-   uint8_t *tiled = malloc(wt * ht * TILE_SIZE * TILE_SIZE * 4);
+   uint8_t *tiled = MALLOC(wt * ht * TILE_SIZE * TILE_SIZE * 4);
 
/*unsigned tiled_stride = wt * TILE_SIZE * TILE_SIZE * 4;*/
 
@@ -323,6 +324,6 @@ test_tiled_linear_conversion(void *data,
lp_tiled_to_linear(tiled, data, 0, 0, width, height, format,
   stride, wt);
 
-   free(tiled);
+   FREE(tiled);
 }
 

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


Mesa (master): noop: Always use memory allocation macros.

2011-09-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 785b9e7c780d8e436ef557a22cf916f7869f7390
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=785b9e7c780d8e436ef557a22cf916f7869f7390

Author: José Fonseca jose.r.fons...@gmail.com
Date:   Sun Sep 25 11:48:17 2011 +0100

noop: Always use memory allocation macros.

---

 src/gallium/drivers/noop/noop_pipe.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/noop/noop_pipe.c 
b/src/gallium/drivers/noop/noop_pipe.c
index ead97df..baa4255 100644
--- a/src/gallium/drivers/noop/noop_pipe.c
+++ b/src/gallium/drivers/noop/noop_pipe.c
@@ -101,7 +101,7 @@ static struct pipe_resource *noop_resource_create(struct 
pipe_screen *screen,
nresource-base = *templ;
nresource-base.screen = screen;
nresource-size = stride * templ-height0 * templ-depth0;
-   nresource-data = malloc(nresource-size);
+   nresource-data = MALLOC(nresource-size);
pipe_reference_init(nresource-base.reference, 1);
if (nresource-data == NULL) {
FREE(nresource);
@@ -137,7 +137,7 @@ static void noop_resource_destroy(struct pipe_screen 
*screen,
 {
struct noop_resource *nresource = (struct noop_resource *)resource;
 
-   free(nresource-data);
+   FREE(nresource-data);
FREE(resource);
 }
 

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


Mesa (master): postprocess: Portability fixes.

2011-09-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 4703f50e96fe3a9db039f59e154e15c06c3f8367
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4703f50e96fe3a9db039f59e154e15c06c3f8367

Author: José Fonseca jose.r.fons...@gmail.com
Date:   Sun Sep 25 11:56:12 2011 +0100

postprocess: Portability fixes.

---

 src/gallium/auxiliary/postprocess/pp_init.c|   32 
 src/gallium/auxiliary/postprocess/pp_mlaa.c|   16 ++-
 src/gallium/auxiliary/postprocess/pp_program.c |3 +-
 3 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/src/gallium/auxiliary/postprocess/pp_init.c 
b/src/gallium/auxiliary/postprocess/pp_init.c
index 7541799..fd9eb22 100644
--- a/src/gallium/auxiliary/postprocess/pp_init.c
+++ b/src/gallium/auxiliary/postprocess/pp_init.c
@@ -25,9 +25,7 @@
  *
  **/
 
-#include stdio.h
-#include stdlib.h
-#include stdarg.h
+#include pipe/p_compiler.h
 
 #include postprocess/filters.h
 
@@ -35,6 +33,8 @@
 #include util/u_inlines.h
 #include util/u_blit.h
 #include util/u_math.h
+#include util/u_debug.h
+#include util/u_memory.h
 #include cso_cache/cso_context.h
 
 /** Initialize the post-processing queue. */
@@ -56,10 +56,10 @@ pp_init(struct pipe_screen *pscreen, const unsigned int 
*enabled)
if (!curpos)
   return NULL;
 
-   ppq = calloc(1, sizeof(struct pp_queue_t));
-   tmp_q = calloc(curpos, sizeof(pp_func));
-   ppq-shaders = calloc(curpos, sizeof(void *));
-   ppq-verts = calloc(curpos, sizeof(unsigned int));
+   ppq = CALLOC(1, sizeof(struct pp_queue_t));
+   tmp_q = CALLOC(curpos, sizeof(pp_func));
+   ppq-shaders = CALLOC(curpos, sizeof(void *));
+   ppq-verts = CALLOC(curpos, sizeof(unsigned int));
 
if (!tmp_q || !ppq || !ppq-shaders || !ppq-verts)
   goto error;
@@ -78,7 +78,7 @@ pp_init(struct pipe_screen *pscreen, const unsigned int 
*enabled)
 
  if (pp_filters[i].shaders) {
 ppq-shaders[curpos] =
-   calloc(pp_filters[i].shaders + 1, sizeof(void *));
+   CALLOC(pp_filters[i].shaders + 1, sizeof(void *));
 ppq-verts[curpos] = pp_filters[i].verts;
 if (!ppq-shaders[curpos])
goto error;
@@ -110,9 +110,9 @@ pp_init(struct pipe_screen *pscreen, const unsigned int 
*enabled)
pp_debug(Error setting up pp\n);
 
if (ppq)
-  free(ppq-p);
-   free(ppq);
-   free(tmp_q);
+  FREE(ppq-p);
+   FREE(ppq);
+   FREE(tmp_q);
 
return NULL;
 }
@@ -171,9 +171,9 @@ pp_free(struct pp_queue_t *ppq)
cso_destroy_context(ppq-p-cso);
ppq-p-pipe-destroy(ppq-p-pipe);
 
-   free(ppq-p);
-   free(ppq-pp_queue);
-   free(ppq);
+   FREE(ppq-p);
+   FREE(ppq-pp_queue);
+   FREE(ppq);
 
pp_debug(Queue taken down.\n);
 }
@@ -184,11 +184,11 @@ pp_debug(const char *fmt, ...)
 {
va_list ap;
 
-   if (!getenv(PP_DEBUG))
+   if (!debug_get_bool_option(PP_DEBUG, FALSE))
   return;
 
va_start(ap, fmt);
-   vfprintf(stderr, fmt, ap);
+   _debug_vprintf(fmt, ap);
va_end(ap);
 }
 
diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c 
b/src/gallium/auxiliary/postprocess/pp_mlaa.c
index 5708687..f514e69 100644
--- a/src/gallium/auxiliary/postprocess/pp_mlaa.c
+++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c
@@ -38,8 +38,8 @@
  * policies, either expressed or implied, of the copyright holders.
  */
 
-#include stdio.h
-#include string.h
+#include pipe/p_compiler.h
+
 #include postprocess/postprocess.h
 #include postprocess/pp_mlaa.h
 #include postprocess/pp_filters.h
@@ -47,6 +47,8 @@
 #include util/u_box.h
 #include util/u_sampler.h
 #include util/u_inlines.h
+#include util/u_memory.h
+#include util/u_string.h
 #include pipe/p_screen.h
 
 #define IMM_SPACE 80
@@ -211,7 +213,7 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned 
int n,
struct pipe_box box;
struct pipe_resource res;
 
-   char *tmp_text = calloc(sizeof(blend2fs_1) + sizeof(blend2fs_2) +
+   char *tmp_text = CALLOC(sizeof(blend2fs_1) + sizeof(blend2fs_2) +
IMM_SPACE, sizeof(char));
 
constbuf = pipe_buffer_create(ppq-p-screen, PIPE_BIND_CONSTANT_BUFFER,
@@ -228,9 +230,9 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned 
int n,
   pp_debug(Failed to allocate shader space\n);
   return;
}
-   sprintf(tmp_text, %s
-   IMM FLT32 {%.8f, 0., 0., 0.}\n
-   %s\n, blend2fs_1, (float) val, blend2fs_2);
+   util_sprintf(tmp_text, %s
+IMM FLT32 {%.8f, 0., 0., 0.}\n
+%s\n, blend2fs_1, (float) val, blend2fs_2);
 
memset(res, 0, sizeof(res));
 
@@ -267,7 +269,7 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned 
int n,
ppq-shaders[n][4] = pp_tgsi_to_state(ppq-p-pipe, neigh3fs, false,
  neigh3fs);
 
-   free(tmp_text);
+   FREE(tmp_text);
 }
 
 /** Short wrapper to init the depth version. */
diff 

Mesa (master): mesa: Also set the remaining draw buffers to GL_NONE when updating just the first buffer in _mesa_drawbuffers ().

2011-09-25 Thread Henri Verbeet
Module: Mesa
Branch: master
Commit: a4d72189b271664501338cc93107845f3d40ae54
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a4d72189b271664501338cc93107845f3d40ae54

Author: Henri Verbeet hverb...@gmail.com
Date:   Thu Sep 22 23:46:34 2011 +0200

mesa: Also set the remaining draw buffers to GL_NONE when updating just the 
first buffer in _mesa_drawbuffers().

Without this we'd miss the last update in a sequence like {COLOR0, COLOR1},
{COLOR0}, {COLOR0, COLOR1}. I originally had a patch for this that called
updated_drawbuffers() when the buffer count changed, but later realized that
was wrong. The ARB_draw_buffers spec explicitly says The draw buffer for
output colors beyond n is set to NONE., and this is queryable state.
This fixes piglit arb_draw_buffers-state_change.

NOTE: This is a candidate for the 7.11 branch.

Signed-off-by: Henri Verbeet hverb...@gmail.com
Reviewed-by: Brian Paul bri...@vmware.com
Reviewed-by: Eric Anholt e...@anholt.net

---

 src/mesa/main/buffers.c |   29 ++---
 1 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index a75c9c2..adea0f5 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -381,6 +381,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const 
GLenum *buffers,
 {
struct gl_framebuffer *fb = ctx-DrawBuffer;
GLbitfield mask[MAX_DRAW_BUFFERS];
+   GLuint buf;
 
if (!destMask) {
   /* compute destMask values now */
@@ -410,13 +411,10 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const 
GLenum *buffers,
  destMask0 = ~(1  bufIndex);
   }
   fb-ColorDrawBuffer[0] = buffers[0];
-  if (fb-_NumColorDrawBuffers != count) {
-updated_drawbuffers(ctx);
- fb-_NumColorDrawBuffers = count;
-  }
+  fb-_NumColorDrawBuffers = count;
}
else {
-  GLuint buf, count = 0;
+  GLuint count = 0;
   for (buf = 0; buf  n; buf++ ) {
  if (destMask[buf]) {
 GLint bufIndex = _mesa_ffs(destMask[buf]) - 1;
@@ -436,21 +434,22 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const 
GLenum *buffers,
  }
  fb-ColorDrawBuffer[buf] = buffers[buf];
   }
-  /* set remaining outputs to -1 (GL_NONE) */
-  while (buf  ctx-Const.MaxDrawBuffers) {
- if (fb-_ColorDrawBufferIndexes[buf] != -1) {
-   updated_drawbuffers(ctx);
-fb-_ColorDrawBufferIndexes[buf] = -1;
- }
- fb-ColorDrawBuffer[buf] = GL_NONE;
- buf++;
-  }
   fb-_NumColorDrawBuffers = count;
}
 
+   /* set remaining outputs to -1 (GL_NONE) */
+   for (buf = fb-_NumColorDrawBuffers; buf  ctx-Const.MaxDrawBuffers; 
buf++) {
+  if (fb-_ColorDrawBufferIndexes[buf] != -1) {
+ updated_drawbuffers(ctx);
+ fb-_ColorDrawBufferIndexes[buf] = -1;
+  }
+   }
+   for (buf = n; buf  ctx-Const.MaxDrawBuffers; buf++) {
+  fb-ColorDrawBuffer[buf] = GL_NONE;
+   }
+
if (fb-Name == 0) {
   /* also set context drawbuffer state */
-  GLuint buf;
   for (buf = 0; buf  ctx-Const.MaxDrawBuffers; buf++) {
  if (ctx-Color.DrawBuffer[buf] != fb-ColorDrawBuffer[buf]) {
updated_drawbuffers(ctx);

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


Mesa (master): nouveau: fix crash during fence emission

2011-09-25 Thread Marcin Ślusarz
Module: Mesa
Branch: master
Commit: 65b8eea0644fdb7e9150d0e98c06d7f8ba6d5302
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=65b8eea0644fdb7e9150d0e98c06d7f8ba6d5302

Author: Marcin Slusarz marcin.slus...@gmail.com
Date:   Sun Sep 25 16:01:19 2011 +0200

nouveau: fix crash during fence emission

Fence emission can flush the push buffer, which through flush_notify
unreferences recently emitted fence. If ref count is increased after
fence emission, unreference deletes the fence, which causes SIGSEGV.

Backtrace:
nouveau_fence_del
nouveau_fence_ref
nouveau_fence_next
nouveau_pushbuf_flush
MARK_RING
nv50_screen_fence_emit
nouveau_fence_emit
nv50_flush

This bug manifested as an assertion failure in nouveau_fence.c, because
SIGSEGV handler tried to shutdown the application and used messed up
fence.

This issue was reported by Maxim Levitsky.

Note: This is a candidate for the 7.11 branch.

---

 src/gallium/drivers/nouveau/nouveau_fence.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_fence.c 
b/src/gallium/drivers/nouveau/nouveau_fence.c
index ea2038c..26e4775 100644
--- a/src/gallium/drivers/nouveau/nouveau_fence.c
+++ b/src/gallium/drivers/nouveau/nouveau_fence.c
@@ -93,8 +93,6 @@ nouveau_fence_emit(struct nouveau_fence *fence)
/* set this now, so that if fence.emit triggers a flush we don't recurse */
fence-state = NOUVEAU_FENCE_STATE_EMITTED;
 
-   screen-fence.emit(screen-base, fence-sequence);
-
++fence-ref;
 
if (screen-fence.tail)
@@ -103,6 +101,8 @@ nouveau_fence_emit(struct nouveau_fence *fence)
   screen-fence.head = fence;
 
screen-fence.tail = fence;
+
+   screen-fence.emit(screen-base, fence-sequence);
 }
 
 void

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


Mesa (master): intel: fix potential segfault error at intel_(un) map_texture_image

2011-09-25 Thread Yuanhan Liu
Module: Mesa
Branch: master
Commit: 455a19b1b3d7ca0a40c65d89e45209dbd8ac7b35
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=455a19b1b3d7ca0a40c65d89e45209dbd8ac7b35

Author: Yuanhan Liu yuanhan@linux.intel.com
Date:   Mon Sep 26 09:23:06 2011 +0800

intel: fix potential segfault error at intel_(un)map_texture_image

intel_image-mt might be NULL, say with border width set. It then would
trigger a segfault at intel_map/unmap_texture_image function.

This would fix the oglc misctest(basic.textureBorderIgnore) fail.

Signed-off-by: Yuanhan Liu yuanhan@linux.intel.com

---

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

diff --git a/src/mesa/drivers/dri/intel/intel_tex.c 
b/src/mesa/drivers/dri/intel/intel_tex.c
index 8d3cbd6..f8c3f77 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -113,7 +113,7 @@ intel_map_texture_image(struct gl_context *ctx,
 * row of blocks.  intel_miptree_get_image_offset() already does
 * the divide.
 */
-   _mesa_get_format_block_size(mt-format, bw, bh);
+   _mesa_get_format_block_size(tex_image-TexFormat, bw, bh);
assert(y % bh == 0);
y /= bh;
 
@@ -150,7 +150,8 @@ intel_unmap_texture_image(struct gl_context *ctx,
struct intel_context *intel = intel_context(ctx);
struct intel_texture_image *intel_image = intel_texture_image(tex_image);
 
-   intel_region_unmap(intel, intel_image-mt-region);
+   if (intel_image-mt)
+  intel_region_unmap(intel, intel_image-mt-region);
 
if (intel_image-stencil_rb) {
   /*

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