[Mesa-dev] [Bug 43896] Mesa assembly breaks Super Meat Boy, Shank

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

--- Comment #1 from Vadim pt...@yandex.ru 2011-12-17 03:42:43 PST ---
Created attachment 54524
  -- https://bugs.freedesktop.org/attachment.cgi?id=54524
[PATCH] glapi: fix _glapi_get_proc_addresss

I'm not sure if the patch is completely correct, though there are no piglit
regressions.

There is a bug in the 32-bit mesa build, when asm is enabled -
glXGetProcAddress returns non-NULL for any string starting with gl.

In this case the app calls glXGetProcAddress with the incorrect function name,
e.g. glCreateShaderObject, mesa incorrectly returns non-NULL, the app calls
it.

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


[Mesa-dev] [Bug 43896] Mesa assembly breaks Super Meat Boy, Shank

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

--- Comment #2 from Henri Verbeet hverb...@gmail.com 2011-12-17 05:16:28 PST 
---
(In reply to comment #1)
 There is a bug in the 32-bit mesa build, when asm is enabled -
 glXGetProcAddress returns non-NULL for any string starting with gl.
 
 In this case the app calls glXGetProcAddress with the incorrect function name,
 e.g. glCreateShaderObject, mesa incorrectly returns non-NULL, the app calls
 it.
Sounds like a bug in the application to me. From the GLX 1.4 spec (though
that's certainly not new in 1.4):

A non-NULL return value for glXGetProcAddress does not guarantee that an
extension function is actually supported at runtime. The client must also query
glGetString() or glXQueryExtensionsString to determine if an extension is
supported by a particular context.

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


[Mesa-dev] [Bug 43896] Mesa assembly breaks Super Meat Boy, Shank

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

--- Comment #3 from Vadim pt...@yandex.ru 2011-12-17 05:40:34 PST ---
(In reply to comment #2)
 Sounds like a bug in the application to me. From the GLX 1.4 spec (though
 that's certainly not new in 1.4):
 
 A non-NULL return value for glXGetProcAddress does not guarantee that an
 extension function is actually supported at runtime. The client must also 
 query
 glGetString() or glXQueryExtensionsString to determine if an extension is
 supported by a particular context.

I'm not sure what behaviour is correct. I relied on the the description of
glXGetProcAddress:
http://www.opengl.org/sdk/docs/man/xhtml/glXGetProcAddress.xml

A NULL pointer is returned if function requested is not suported in the
implementation being queried.

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


[Mesa-dev] [PATCH] st/mesa: DrawTFB should use the vertex count from the last call of EndTFB

2011-12-17 Thread Marek Olšák
From ARB_transform_feedback2:
... the vertex count used for the rendering operation is
set by the previous EndTransformFeedback command.
---
 src/mesa/state_tracker/st_cb_xformfb.c |   53 +--
 1 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_xformfb.c 
b/src/mesa/state_tracker/st_cb_xformfb.c
index 2fc28dc..e699fb6 100644
--- a/src/mesa/state_tracker/st_cb_xformfb.c
+++ b/src/mesa/state_tracker/st_cb_xformfb.c
@@ -55,6 +55,11 @@ struct st_transform_feedback_object {
 
unsigned num_targets;
struct pipe_stream_output_target *targets[PIPE_MAX_SO_BUFFERS];
+
+   /* This encapsulates the count that can be used as a source for draw_vbo.
+* It contains a stream output target from the last call of
+* EndTransformFeedback. */
+   struct pipe_stream_output_target *draw_count;
 };
 
 
@@ -81,6 +86,8 @@ st_delete_transform_feedback(struct gl_context *ctx,
  (struct st_transform_feedback_object*)obj;
unsigned i;
 
+   pipe_so_target_reference(sobj-draw_count, NULL);
+
/* Unreference targets. */
for (i = 0; i  sobj-num_targets; i++) {
   pipe_so_target_reference(sobj-targets[i], NULL);
@@ -115,6 +122,7 @@ st_begin_transform_feedback(struct gl_context *ctx, GLenum 
mode,
   if (bo) {
  /* Check whether we need to recreate the target. */
  if (!sobj-targets[i] ||
+ sobj-targets[i] == sobj-draw_count ||
  sobj-targets[i]-buffer != bo-buffer ||
  sobj-targets[i]-buffer_offset != sobj-base.Offset[i] ||
  sobj-targets[i]-buffer_size != sobj-base.Size[i]) {
@@ -141,7 +149,7 @@ st_begin_transform_feedback(struct gl_context *ctx, GLenum 
mode,
 
 
 static void
-st_stop_transform_feedback(struct gl_context *ctx,
+st_pause_transform_feedback(struct gl_context *ctx,
struct gl_transform_feedback_object *obj)
 {
struct st_context *st = st_context(ctx);
@@ -161,11 +169,9 @@ st_resume_transform_feedback(struct gl_context *ctx,
   ~0);
 }
 
-/* Set count_from_stream_output to any stream output target
- * from the transform feedback object. */
-void
-st_transform_feedback_draw_init(struct gl_transform_feedback_object *obj,
-struct pipe_draw_info *out)
+
+static struct pipe_stream_output_target *
+st_transform_feedback_get_draw_target(struct gl_transform_feedback_object *obj)
 {
struct st_transform_feedback_object *sobj =
  (struct st_transform_feedback_object*)obj;
@@ -173,13 +179,38 @@ st_transform_feedback_draw_init(struct 
gl_transform_feedback_object *obj,
 
for (i = 0; i  Elements(sobj-targets); i++) {
   if (sobj-targets[i]) {
- out-count_from_stream_output = sobj-targets[i];
- return;
+ return sobj-targets[i];
   }
}
 
assert(0);
-   out-count_from_stream_output = NULL;
+   return NULL;
+}
+
+
+static void
+st_end_transform_feedback(struct gl_context *ctx,
+  struct gl_transform_feedback_object *obj)
+{
+   struct st_context *st = st_context(ctx);
+   struct st_transform_feedback_object *sobj =
+ (struct st_transform_feedback_object*)obj;
+
+   cso_set_stream_outputs(st-cso_context, 0, NULL, 0);
+
+   pipe_so_target_reference(sobj-draw_count,
+st_transform_feedback_get_draw_target(obj));
+}
+
+
+void
+st_transform_feedback_draw_init(struct gl_transform_feedback_object *obj,
+struct pipe_draw_info *out)
+{
+   struct st_transform_feedback_object *sobj =
+ (struct st_transform_feedback_object*)obj;
+
+   out-count_from_stream_output = sobj-draw_count;
 }
 
 
@@ -189,8 +220,8 @@ st_init_xformfb_functions(struct dd_function_table 
*functions)
functions-NewTransformFeedback = st_new_transform_feedback;
functions-DeleteTransformFeedback = st_delete_transform_feedback;
functions-BeginTransformFeedback = st_begin_transform_feedback;
-   functions-EndTransformFeedback = st_stop_transform_feedback;
-   functions-PauseTransformFeedback = st_stop_transform_feedback;
+   functions-EndTransformFeedback = st_end_transform_feedback;
+   functions-PauseTransformFeedback = st_pause_transform_feedback;
functions-ResumeTransformFeedback = st_resume_transform_feedback;
 }
 
-- 
1.7.5.4

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


[Mesa-dev] [Bug 43896] Mesa assembly breaks Super Meat Boy, Shank

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

--- Comment #4 from Vadim pt...@yandex.ru 2011-12-17 06:36:09 PST ---
(In reply to comment #2)
 (In reply to comment #1)
  There is a bug in the 32-bit mesa build, when asm is enabled -
  glXGetProcAddress returns non-NULL for any string starting with gl.
  
  In this case the app calls glXGetProcAddress with the incorrect function 
  name,
  e.g. glCreateShaderObject, mesa incorrectly returns non-NULL, the app 
  calls
  it.
 Sounds like a bug in the application to me. From the GLX 1.4 spec (though
 that's certainly not new in 1.4):
 
 A non-NULL return value for glXGetProcAddress does not guarantee that an
 extension function is actually supported at runtime. The client must also 
 query
 glGetString() or glXQueryExtensionsString to determine if an extension is
 supported by a particular context.

AFAICS the problem is that extension is supported (ARB_shader_objects), but the
app tries glxGetProcAddress with the wrong name first (glCreateShaderObject),
and if it returns NULL, then the app tries the same name with the ARB suffix
and gets the correct pointer. When glXGetProcAddress returns non-NULL for the
wrong name, the app just uses the returned pointer, which leads to nowhere. You
can view the code here (see loadsym function) :

http://hg.icculus.org/icculus/mojoshader/file/12e1db42bf75/mojoshader_opengl.c

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


[Mesa-dev] [PROPOSAL] gallium: move state enable bits from clip_state to rasterizer_state

2011-12-17 Thread Marek Olšák
---

This was suggested by Keith Whitwell in this email addressed to me on 8/6/2010:
http://lists.freedesktop.org/archives/mesa-dev/2010-August/001810.html


 src/gallium/include/pipe/p_defines.h |2 +-
 src/gallium/include/pipe/p_state.h   |   14 --
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 800a04c..c441a1f 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -453,7 +453,7 @@ enum pipe_cap {
PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT = 38,
PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER = 39,
PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER = 40,
-   PIPE_CAP_DEPTH_CLAMP = 41,
+   PIPE_CAP_DEPTH_CLIP_DISABLE = 41,
PIPE_CAP_SHADER_STENCIL_EXPORT = 42,
PIPE_CAP_TGSI_INSTANCEID = 43,
PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR = 44,
diff --git a/src/gallium/include/pipe/p_state.h 
b/src/gallium/include/pipe/p_state.h
index f943ca5..3aedada 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -127,6 +127,18 @@ struct pipe_rasterizer_state
 */
unsigned rasterizer_discard:1;
 
+   /**
+* When false, depth clipping is disabled and the depth value will be
+* clamped later at the per-pixel level before depth testing.
+* This depends on PIPE_CAP_DEPTH_CLIP_DISABLE.
+*/
+   unsigned depth_clip:1;
+
+   /**
+* Enable bits for user clip planes.
+*/
+   unsigned user_clip_plane_enable:PIPE_MAX_CLIP_PLANES;
+
unsigned line_stipple_factor:8;  /** [1..256] actually */
unsigned line_stipple_pattern:16;
 
@@ -165,8 +177,6 @@ struct pipe_scissor_state
 struct pipe_clip_state
 {
float ucp[PIPE_MAX_CLIP_PLANES][4];
-   unsigned nr;
-   unsigned depth_clamp:1;
 };
 
 
-- 
1.7.5.4

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


Re: [Mesa-dev] [PROPOSAL] gallium: move state enable bits from clip_state to rasterizer_state

2011-12-17 Thread Christoph Bumiller
On 17.12.2011 15:45, Marek Olšák wrote:
 ---

 This was suggested by Keith Whitwell in this email addressed to me on 
 8/6/2010:
 http://lists.freedesktop.org/archives/mesa-dev/2010-August/001810.html


  src/gallium/include/pipe/p_defines.h |2 +-
  src/gallium/include/pipe/p_state.h   |   14 --
  2 files changed, 13 insertions(+), 3 deletions(-)

 diff --git a/src/gallium/include/pipe/p_defines.h 
 b/src/gallium/include/pipe/p_defines.h
 index 800a04c..c441a1f 100644
 --- a/src/gallium/include/pipe/p_defines.h
 +++ b/src/gallium/include/pipe/p_defines.h
 @@ -453,7 +453,7 @@ enum pipe_cap {
 PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT = 38,
 PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER = 39,
 PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER = 40,
 -   PIPE_CAP_DEPTH_CLAMP = 41,
 +   PIPE_CAP_DEPTH_CLIP_DISABLE = 41,
 PIPE_CAP_SHADER_STENCIL_EXPORT = 42,
 PIPE_CAP_TGSI_INSTANCEID = 43,
 PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR = 44,
 diff --git a/src/gallium/include/pipe/p_state.h 
 b/src/gallium/include/pipe/p_state.h
 index f943ca5..3aedada 100644
 --- a/src/gallium/include/pipe/p_state.h
 +++ b/src/gallium/include/pipe/p_state.h
 @@ -127,6 +127,18 @@ struct pipe_rasterizer_state
  */
 unsigned rasterizer_discard:1;
  
 +   /**
 +* When false, depth clipping is disabled and the depth value will be
 +* clamped later at the per-pixel level before depth testing.
 +* This depends on PIPE_CAP_DEPTH_CLIP_DISABLE.
 +*/
 +   unsigned depth_clip:1;
 +
 +   /**
 +* Enable bits for user clip planes.
 +*/
 +   unsigned user_clip_plane_enable:PIPE_MAX_CLIP_PLANES;
 +

The first is fine, but I don't like having user clip plane enables here,
can't make them part of a hardware state buffer since whether a clip
plane is enabled or not also depends on the vertex (or domain or
geometry) shader, using both UCPs and gl_ClipDistance at the same time
doesn't work.

The rasterizer cso is already so large ... if we keep going like this at
some point you have re-validate everything when the rasterizer CSO
changes, because of interdependencies, and we'll get larger and larger
numbers of rasterizer CSOs with slow lookup and hashing.

 unsigned line_stipple_factor:8;  /** [1..256] actually */
 unsigned line_stipple_pattern:16;
  
 @@ -165,8 +177,6 @@ struct pipe_scissor_state
  struct pipe_clip_state
  {
 float ucp[PIPE_MAX_CLIP_PLANES][4];
 -   unsigned nr;
 -   unsigned depth_clamp:1;
  };
  
  

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


[Mesa-dev] [PATCH 0/3] gbm extension patch set - v2

2011-12-17 Thread Zhigang Gong
According to Ian's comments, split the original patchset
to three. The last one is to add new API to create a gbm
bo from external name. Now I'm convinced that in one process
, it's better to use one bufmgr. Just for API completeness,
I still submit it here.

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


[Mesa-dev] [PATCH 1/3] gbm: Added new funtions to match dri format and usage.

2011-12-17 Thread Zhigang Gong
To map GBM format and usage to corresponding dri format
and usage are common functions. For the convinent of
future extension, pull out the code and create two
separated functions. Slightly change the sequence of
the gbm_bo creation, before allocate a buffer, we check
whether the input parameters are valid and if not, we
return NULL directly. And if we fail to create image,
we need to free the allocated buffer.

Signed-off-by: Zhigang Gong zhigang.g...@linux.intel.com
---
 src/gbm/backends/dri/gbm_dri.c |   64 +---
 src/gbm/main/gbm.h |4 ++
 2 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 9de8cb6..e44e5c6 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -215,20 +215,44 @@ free_screen:
 }
 
 static int
-gbm_dri_is_format_supported(struct gbm_device *gbm,
-enum gbm_bo_format format,
-uint32_t usage)
+gbm_dri_match_format(enum gbm_bo_format format, int *dri_format)
 {
switch (format) {
case GBM_BO_FORMAT_XRGB:
+  *dri_format = __DRI_IMAGE_FORMAT_XRGB;
   break;
case GBM_BO_FORMAT_ARGB:
-  if (usage  GBM_BO_USE_SCANOUT)
- return 0;
+  *dri_format = __DRI_IMAGE_FORMAT_ARGB;
   break;
default:
-  return 0;
+  return -1;
}
+  return 0;
+}
+
+static void
+gbm_dri_match_usage(enum  gbm_bo_flags usage, unsigned int *dri_use)
+{
+   if (usage  GBM_BO_USE_SCANOUT)
+  *dri_use |= __DRI_IMAGE_USE_SCANOUT;
+   if (usage  GBM_BO_USE_CURSOR_64X64)
+  *dri_use |= __DRI_IMAGE_USE_CURSOR;
+}
+
+static int
+gbm_dri_is_format_supported(struct gbm_device *gbm,
+enum gbm_bo_format format,
+uint32_t usage)
+{
+   int dri_format = 0;
+
+   if (gbm_dri_match_format(format, dri_format)
+   || (usage  ~GBM_BO_USE_VALID_FLAGS)
+   || ((usage  GBM_BO_USE_SCANOUT)
+ (format == GBM_BO_FORMAT_ARGB))
+   || ((usage  GBM_BO_USE_CURSOR_64X64)
+ (usage  GBM_BO_USE_RENDERING)))
+  return 0;
 
if (usage  GBM_BO_USE_CURSOR_64X64 
usage  GBM_BO_USE_RENDERING)
@@ -292,7 +316,12 @@ gbm_dri_bo_create(struct gbm_device *gbm,
struct gbm_dri_device *dri = gbm_dri_device(gbm);
struct gbm_dri_bo *bo;
int dri_format;
-   unsigned dri_use = 0;
+   unsigned int dri_use = 0;
+
+   if (gbm_dri_match_format(format, dri_format) != 0)
+  return NULL;
+   if (usage  ~GBM_BO_USE_VALID_FLAGS)
+  return NULL;
 
bo = calloc(1, sizeof *bo);
if (bo == NULL)
@@ -302,29 +331,16 @@ gbm_dri_bo_create(struct gbm_device *gbm,
bo-base.base.width = width;
bo-base.base.height = height;
 
-   switch (format) {
-   case GBM_BO_FORMAT_XRGB:
-  dri_format = __DRI_IMAGE_FORMAT_XRGB;
-  break;
-   case GBM_BO_FORMAT_ARGB:
-  dri_format = __DRI_IMAGE_FORMAT_ARGB;
-  break;
-   default:
-  return NULL;
-   }
-
-   if (usage  GBM_BO_USE_SCANOUT)
-  dri_use |= __DRI_IMAGE_USE_SCANOUT;
-   if (usage  GBM_BO_USE_CURSOR_64X64)
-  dri_use |= __DRI_IMAGE_USE_CURSOR;
-
+   gbm_dri_match_usage(usage, dri_use);
bo-image =
   dri-image-createImage(dri-screen,
   width, height,
   dri_format, dri_use,
   bo);
-   if (bo-image == NULL)
+   if (bo-image == NULL) {
+  free(bo);
   return NULL;
+   }
 
dri-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_HANDLE,
   bo-base.base.handle.s32);
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index 05d2292..a994451 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -59,6 +59,10 @@ enum gbm_bo_flags {
GBM_BO_USE_RENDERING= (1  2),
 };
 
+#define GBM_BO_USE_VALID_FLAGS (GBM_BO_USE_SCANOUT\
+| GBM_BO_USE_CURSOR_64X64 \
+| GBM_BO_USE_RENDERING)
+
 int
 gbm_device_get_fd(struct gbm_device *gbm);
 
-- 
1.7.3.1

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


[Mesa-dev] [PATCH 3/3] gbm: Add interface to create bo from name.

2011-12-17 Thread Zhigang Gong
Added a new interface to create a gbm_bo from external name.

Signed-off-by: Zhigang Gong zhigang.g...@linux.intel.com
---
 src/gbm/backends/dri/gbm_dri.c |   40 
 src/gbm/main/gbm.c |   12 
 src/gbm/main/gbm.h |6 ++
 src/gbm/main/gbmint.h  |4 
 4 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 7673953..c8f6196 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -356,6 +356,45 @@ gbm_dri_bo_create(struct gbm_device *gbm,
return bo-base.base;
 }
 
+static struct gbm_bo *
+gbm_dri_bo_create_from_name(struct gbm_device *gbm,
+uint32_t width, uint32_t height,
+enum gbm_bo_format format, int name,
+int pitch)
+{
+   struct gbm_dri_device *dri = gbm_dri_device(gbm);
+   struct gbm_dri_bo *bo;
+   int dri_format;
+
+   if (gbm_dri_match_format(format, dri_format) != 0)
+  return NULL;
+
+   bo = calloc(1, sizeof *bo);
+   if (bo == NULL)
+  return NULL;
+
+   bo-base.base.gbm = gbm;
+   bo-base.base.width = width;
+   bo-base.base.height = height;
+
+   bo-image =
+  dri-image-createImageFromName(dri-screen,
+  width, height,
+  dri_format, name, pitch,
+  bo);
+   if (bo-image == NULL) {
+  free(bo);
+  return NULL;
+   }
+
+   dri-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_HANDLE,
+  bo-base.base.handle.s32);
+   dri-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_STRIDE,
+  (int *) bo-base.base.pitch);
+
+   return bo-base.base;
+}
+
 static void
 dri_destroy(struct gbm_device *gbm)
 {
@@ -380,6 +419,7 @@ dri_device_create(int fd)
dri-base.base.fd = fd;
dri-base.base.bo_create = gbm_dri_bo_create;
dri-base.base.bo_create_from_egl_image = gbm_dri_bo_create_from_egl_image;
+   dri-base.base.bo_create_from_name = gbm_dri_bo_create_from_name;
dri-base.base.is_format_supported = gbm_dri_is_format_supported;
dri-base.base.bo_destroy = gbm_dri_bo_destroy;
dri-base.base.destroy = dri_destroy;
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
index 8440b2c..71c02a2 100644
--- a/src/gbm/main/gbm.c
+++ b/src/gbm/main/gbm.c
@@ -177,6 +177,18 @@ gbm_bo_create(struct gbm_device *gbm,
 }
 
 GBM_EXPORT struct gbm_bo *
+gbm_bo_create_from_name(struct gbm_device *gbm,
+uint32_t width, uint32_t height,
+enum gbm_bo_format format, int name,
+int pitch)
+{
+   if (width == 0 || height == 0)
+  return NULL;
+
+   return gbm-bo_create_from_name(gbm, width, height, format, name, pitch);
+}
+
+GBM_EXPORT struct gbm_bo *
 gbm_bo_create_from_egl_image(struct gbm_device *gbm,
  void *egl_dpy, void *egl_image,
  uint32_t width, uint32_t height,
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index e3cecb4..49ff2a8 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -88,6 +88,12 @@ gbm_bo_create(struct gbm_device *gbm,
   enum gbm_bo_format format, uint32_t flags);
 
 struct gbm_bo *
+gbm_bo_create_from_name(struct gbm_device *gbm,
+uint32_t width, uint32_t height,
+enum gbm_bo_format format, int name,
+int pitch);
+
+struct gbm_bo *
 gbm_bo_create_from_egl_image(struct gbm_device *gbm,
  void *egl_dpy, void *egl_img,
  uint32_t width, uint32_t height,
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h
index fb8db80..1aab789 100644
--- a/src/gbm/main/gbmint.h
+++ b/src/gbm/main/gbmint.h
@@ -60,6 +60,10 @@ struct gbm_device {
   void *egl_dpy, void *egl_img,
   uint32_t width, uint32_t height,
   uint32_t usage);
+   struct gbm_bo *(*bo_create_from_name)(struct gbm_device *gbm,
+ uint32_t width, uint32_t height,
+ enum gbm_bo_format format, int name,
+ int pitch);
void (*bo_destroy)(struct gbm_bo *bo);
 };
 
-- 
1.7.3.1

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


[Mesa-dev] [Bug 43629] mesa# gmake freebsd-dri-amd64 breaks

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

--- Comment #4 from zap...@berentweb.com 2011-12-17 10:26:00 PST ---
I corrected the expat error by setting:
# setenv LDFLAGS -L/usr/local/lib
# setenv CFLAGS -I/usr/local/include

Then, re-run mesa/autogen.sh gave me NOUVEAU error:
checking for NOUVEAU... no
configure: error: Package requirements (libdrm_nouveau = 0.6) were not met:
No package 'libdrm_nouveau' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables NOUVEAU_CFLAGS
and NOUVEAU_LIBS to avoid the need to call pkg-config.

Already have WITHOUT_NOUVEAU=yes in my /etc/make.conf

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


Re: [Mesa-dev] [PATCH 5/8] i965 gen6: Initial implementation of transform feedback.

2011-12-17 Thread Eric Anholt
On Tue, 13 Dec 2011 15:35:18 -0800, Paul Berry stereotype...@gmail.com wrote:
 diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
 b/src/mesa/drivers/dri/i965/brw_gs.c
 index f5d5898..c323a73 100644
 --- a/src/mesa/drivers/dri/i965/brw_gs.c
 +++ b/src/mesa/drivers/dri/i965/brw_gs.c
 @@ -183,7 +183,31 @@ static void populate_key( struct brw_context *brw,
 } else if (intel-gen == 6) {
/* On Gen6, GS is used for transform feedback. */
/* _NEW_TRANSFORM_FEEDBACK */
 -  key-need_gs_prog = ctx-TransformFeedback.CurrentObject-Active;
 +  if (ctx-TransformFeedback.CurrentObject-Active) {
 + const struct gl_shader_program *shaderprog =
 +ctx-Shader.CurrentVertexProgram;
 + const struct gl_transform_feedback_info *linked_xfb_info =
 +shaderprog-LinkedTransformFeedback;
 + int i;
 +
 + /* Make sure that the VUE slots won't overflow the unsigned chars in
 +  * key-transform_feedback_bindings[].
 +  */
 + assert (BRW_VERT_RESULT_MAX = 256);

We generally don't put a space between assert and the opening paren.

Also, this assert is really weird to me.  Neither of the two fields in
the key are related to 256 -- there's a 7-bit field, and a
BRW_MAX_SOL_BINDINGS field.  (Also, for compile-time checks like this,
we now have STATIC_ASSERT.  Hooray!)

 @@ -107,12 +119,27 @@ static void brw_gs_overwrite_header_dw2(struct 
 brw_gs_compile *c,
   * of DWORD 2.  URB_WRITE messages need the primitive type in bits 6:2 of
   * DWORD 2.  So this function extracts the primitive type field, bitshifts it
   * appropriately, and stores it in c-reg.header.
 + *
 + * Also, if num_verts is 3, it converts primitive type
 + * _3DPRIM_TRISTRIP_REVERSE to _3DPRIM_TRISTRIP, so that odd numbered
 + * triangles in a triangle strip will render correctly.
   */
 -static void brw_gs_overwrite_header_dw2_from_r0(struct brw_gs_compile *c)
 +static void brw_gs_overwrite_header_dw2_from_r0(struct brw_gs_compile *c,
 +unsigned num_verts)
  {
 struct brw_compile *p = c-func;
 brw_AND(p, get_element_ud(c-reg.header, 2), get_element_ud(c-reg.R0, 2),
 brw_imm_ud(0x1f));
 +   if (num_verts == 3) {
 +  brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ,
 +  get_element_ud(c-reg.header, 2),
 +  brw_imm_ud(_3DPRIM_TRISTRIP_REVERSE));
 +  {
 + brw_MOV(p, get_element_ud(c-reg.header, 2),
 + brw_imm_ud(_3DPRIM_TRISTRIP));
 + brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 +  }
 +   }

This doesn't mess up normal rendering of tristrips in any way?  It looks
like it could be a separate commit to me.

 diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
 b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
 index f9b0b71..4ec9ef5 100644
 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
 +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c

 +/**
 + * Set up a binding table entry for use by stream output logic (transform
 + * feedback).
 + *
 + * buffer_size_minus_1 must me less than BRW_MAX_NUM_BUFFER_ENTRIES.
 + */
 +static void
 +brw_update_sol_surface(struct brw_context *brw, drm_intel_bo *bo,
 +   uint32_t *out_offset, unsigned num_vector_components,
 +   unsigned stride_dwords, unsigned offset_dwords,
 +   uint32_t buffer_size_minus_1)
 +{
 +   uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, 6 * 4, 32,
 +out_offset);
 +   uint32_t width = buffer_size_minus_1  0x7f;
 +   uint32_t height = (buffer_size_minus_1  0xfff80)  7;
 +   uint32_t depth = (buffer_size_minus_1  0x7f0)  20;
 +   uint32_t pitch_minus_1 = 4*stride_dwords - 1;
 +   uint32_t surface_format;
 +   uint32_t offset_bytes = 4 * offset_dwords;

Could I get just a little more whitespace in your code?  Between the
declaration and the switch, after the switch, etc.?

 +   surf[1] = bo-offset + offset_bytes; /* reloc */
 +   surf[2] = (width  BRW_SURFACE_WIDTH_SHIFT |
 +   height  BRW_SURFACE_HEIGHT_SHIFT);
 +   surf[3] = (depth  BRW_SURFACE_DEPTH_SHIFT |
 +  pitch_minus_1  BRW_SURFACE_PITCH_SHIFT);

This looks to me like the hardware width/heigth/depth fields are ending
up programmed as 1 larger than you intend.  Compare to
brw_create_constant_surface().

 +   /* Emit relocation to surface contents.  Section 5.1.1 of the gen4
 +* bspec (Data Cache) says that the data cache does not exist as
 +* a separate cache and is just the sampler cache.
 +*/
 +   drm_intel_bo_emit_reloc(brw-intel.batch.bo,
 +*out_offset + 4,
 +bo, offset_bytes,
 +I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
 +}

If it's the sampler cache, that would be (I915_GEM_DOMAIN_SAMPLER, 0).
But it obviously isn't, since we're reading and writing.

 diff --git 

Re: [Mesa-dev] [PATCH 6/8] i965 gen6: Turn on transform feedback extension.

2011-12-17 Thread Eric Anholt
On Tue, 13 Dec 2011 15:35:19 -0800, Paul Berry stereotype...@gmail.com wrote:
 This patch advertises support for EXT_transform_feedback on Intel Gen6
 and higher.
 
 Since transform feedback support is not completely finished yet, for
 now we only advertise support for it when MESA_GL_VERSION_OVERRIDE is
 3.0 or greater (since transform feedback is required by GL version
 3.0).

Should be gen6-only for now.


pgpmau5ztQqt2.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/8] i965 gen6+: Make intel_batchbuffer_emit_mi_flush() actually flush.

2011-12-17 Thread Eric Anholt
On Tue, 13 Dec 2011 15:35:20 -0800, Paul Berry stereotype...@gmail.com wrote:
 Previous to this patch, the function intel_batchbuffer_emit_mi_flush()
 was a bit of a misnomer.  On Gen4+, when not using the blit engine, it
 didn't actually flush the pipeline--it simply generated a
 _3DSTATE_PIPE_CONTROL command with the necessary bits set to flush GPU
 caches.  This was usually sufficient, since in most situations where
 intel_batchbuffer_emit_mi_flush() wass called, all we really care
 about was ensuring cache coherency.

I think I've validated that the set of workarounds doesn't change when
adding the CS stall bit.

Reviewed-by: Eric Anholt e...@anholt.net


pgpqWk9GMd5jy.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 8/8] i965: Flush pipeline on EndTransformFeedback.

2011-12-17 Thread Eric Anholt
On Tue, 13 Dec 2011 15:35:21 -0800, Paul Berry stereotype...@gmail.com wrote:
 A common use case for transform feedback is to perform one draw
 operation that writes transform feedback output to a buffer, followed
 by a second draw operation that consumes that buffer as vertex input.
 Since vertex input is consumed at an earlier pipeline stage than
 writing transform feedback output, we need to flush the pipeline to
 ensure that the transform feedback output is completely written before
 the data is consumed.

Reviewed-by: Eric Anholt e...@anholt.net


pgpgS0xNM1pB2.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PROPOSAL] gallium: move state enable bits from clip_state to rasterizer_state

2011-12-17 Thread Marek Olšák
On Sat, Dec 17, 2011 at 4:45 PM, Christoph Bumiller
e0425...@student.tuwien.ac.at wrote:
 On 17.12.2011 15:45, Marek Olšák wrote:
 ---

 This was suggested by Keith Whitwell in this email addressed to me on 
 8/6/2010:
 http://lists.freedesktop.org/archives/mesa-dev/2010-August/001810.html


  src/gallium/include/pipe/p_defines.h |    2 +-
  src/gallium/include/pipe/p_state.h   |   14 --
  2 files changed, 13 insertions(+), 3 deletions(-)

 diff --git a/src/gallium/include/pipe/p_defines.h 
 b/src/gallium/include/pipe/p_defines.h
 index 800a04c..c441a1f 100644
 --- a/src/gallium/include/pipe/p_defines.h
 +++ b/src/gallium/include/pipe/p_defines.h
 @@ -453,7 +453,7 @@ enum pipe_cap {
     PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT = 38,
     PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER = 39,
     PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER = 40,
 -   PIPE_CAP_DEPTH_CLAMP = 41,
 +   PIPE_CAP_DEPTH_CLIP_DISABLE = 41,
     PIPE_CAP_SHADER_STENCIL_EXPORT = 42,
     PIPE_CAP_TGSI_INSTANCEID = 43,
     PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR = 44,
 diff --git a/src/gallium/include/pipe/p_state.h 
 b/src/gallium/include/pipe/p_state.h
 index f943ca5..3aedada 100644
 --- a/src/gallium/include/pipe/p_state.h
 +++ b/src/gallium/include/pipe/p_state.h
 @@ -127,6 +127,18 @@ struct pipe_rasterizer_state
      */
     unsigned rasterizer_discard:1;

 +   /**
 +    * When false, depth clipping is disabled and the depth value will be
 +    * clamped later at the per-pixel level before depth testing.
 +    * This depends on PIPE_CAP_DEPTH_CLIP_DISABLE.
 +    */
 +   unsigned depth_clip:1;
 +
 +   /**
 +    * Enable bits for user clip planes.
 +    */
 +   unsigned user_clip_plane_enable:PIPE_MAX_CLIP_PLANES;
 +

 The first is fine, but I don't like having user clip plane enables here,
 can't make them part of a hardware state buffer since whether a clip
 plane is enabled or not also depends on the vertex (or domain or
 geometry) shader, using both UCPs and gl_ClipDistance at the same time
 doesn't work.

I don't expect anyone to use both. Anyway, the user clip planes are
fixed-function and neither r300 nor r600 clip state has any dependency
on shaders. The UCP state is pretty much separate from everything
else. I'd like to keep depth_clip and UCP enables together, because
they are set via the same register on r600.

The problem with pipe_clip_state is that if I want to enable UCPs, I
must also set the clip planes = 32 floats at most. I can't re-use the
32 floats which were set last time.


 The rasterizer cso is already so large ... if we keep going like this at
 some point you have re-validate everything when the rasterizer CSO
 changes, because of interdependencies, and we'll get larger and larger
 numbers of rasterizer CSOs with slow lookup and hashing.

I double-checked and there should be no change in the size of
pipe_rasterizer_state with the patch. The state currently has 3 dwords
+ 5 floats. However, some or all of the floats could be put in its own
state struct, because they are changed at a pretty low frequency. For
example:

struct pipe_poly_offset_state {
   float offset_units;
   float offset_scale;
   float offset_clamp;
};

pipe-set_poly_offset_state(pipe, poly_offset_state);

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


[Mesa-dev] [PATCH] gallium: remove PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_ATTRIBS

2011-12-17 Thread Marek Olšák
It's the same as PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS.
---
 src/gallium/drivers/nvc0/nvc0_screen.c |2 --
 src/gallium/drivers/r300/r300_screen.c |1 -
 src/gallium/drivers/r600/r600_pipe.c   |1 -
 src/gallium/include/pipe/p_defines.h   |1 -
 src/mesa/state_tracker/st_extensions.c |2 +-
 5 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nvc0/nvc0_screen.c
index 67f9175..8c14f9e 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -108,8 +108,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
   return 1;
case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
   return 4;
-   case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_ATTRIBS:
-  return 4;
case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
   return 128;
diff --git a/src/gallium/drivers/r300/r300_screen.c 
b/src/gallium/drivers/r300/r300_screen.c
index d1b8031..eb75a53 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -132,7 +132,6 @@ static int r300_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
 case PIPE_CAP_MIN_TEXEL_OFFSET:
 case PIPE_CAP_MAX_TEXEL_OFFSET:
 case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
-case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_ATTRIBS:
 case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
 case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
 case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
diff --git a/src/gallium/drivers/r600/r600_pipe.c 
b/src/gallium/drivers/r600/r600_pipe.c
index 036f18f..7f62e0e 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -402,7 +402,6 @@ static int r600_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
 
/* Stream output. */
case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
-   case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_ATTRIBS:
return debug_get_bool_option(R600_STREAMOUT, FALSE) ? 4 : 0;
case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 800a04c..05aa1cd 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -466,7 +466,6 @@ enum pipe_cap {
PIPE_CAP_MAX_TEXEL_OFFSET = 51,
PIPE_CAP_CONDITIONAL_RENDER = 52,
PIPE_CAP_TEXTURE_BARRIER = 53,
-   PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_ATTRIBS = 54,
PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS = 55,
PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS = 56,
PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME = 57,
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index dc17d76..4c8c67f 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -222,7 +222,7 @@ void st_init_limits(struct st_context *st)
c-UniformBooleanTrue = ~0;
 
c-MaxTransformFeedbackSeparateAttribs =
-  screen-get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_ATTRIBS);
+  screen-get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS);
c-MaxTransformFeedbackSeparateComponents =
   screen-get_param(screen, 
PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS);
c-MaxTransformFeedbackInterleavedComponents =
-- 
1.7.5.4

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


Re: [Mesa-dev] More on lib paths

2011-12-17 Thread James Cloos
 AD == Alex Deucher alexdeuc...@gmail.com writes:

AD Both the r600 classic and the r600 gallium drivers produce the same
AD 3D driver: r600_dri.so.  There is no r600g_dri.so.

OK.  I see.  The build script does that to allow one to switch between
classic and gallium drivers w/o rebuilding.

I had eselected gallium, but somehow that got lost.

-JimC
-- 
James Cloos cl...@jhcloos.com OpenPGP: 1024D/ED7DAEA6
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] libvdpau_r600.so not found

2011-12-17 Thread James Cloos
 JJ == James Jones jajo...@nvidia.com writes:

JJ The correct dir is LIBDIR/vdpau.  From here:

So it /is/ installed where it is supposed to be.

JJ Do you have an older libvdpau.so?

x11-libs/libvdpau-0.4.1.

So this is a bug in the ebuild.  It configured module-dir to correctly
choose from /usr/lib{,32,64,x32} for each platform, but doesn't specify
the subdirectory when it does so.  The bugz is:

  https://bugs.gentoo.org/show_bug.cgi?id=389387

Thanks.

-JimC
-- 
James Cloos cl...@jhcloos.com OpenPGP: 1024D/ED7DAEA6
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] gallium: add support for clip distances

2011-12-17 Thread Bryan Cain
---
 src/gallium/auxiliary/tgsi/tgsi_dump.c |3 +-
 src/gallium/auxiliary/tgsi/tgsi_text.c |3 +-
 src/gallium/auxiliary/tgsi/tgsi_ureg.c |   36 +---
 src/gallium/auxiliary/tgsi/tgsi_ureg.h |6 
 src/gallium/include/pipe/p_shader_tokens.h |3 +-
 5 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c 
b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index e830aa5..bd299b0 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -129,7 +129,8 @@ static const char *semantic_names[] =
PRIM_ID,
INSTANCEID,
VERTEXID,
-   STENCIL
+   STENCIL,
+   CLIPDIST
 };
 
 static const char *immediate_type_names[] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c 
b/src/gallium/auxiliary/tgsi/tgsi_text.c
index eb9190c..f46ba19 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -1024,7 +1024,8 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
PRIM_ID,
INSTANCEID,
VERTEXID,
-   STENCIL
+   STENCIL,
+   CLIPDIST
 };
 
 static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 17f9ce2..56c4492 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -122,6 +122,7 @@ struct ureg_program
struct {
   unsigned semantic_name;
   unsigned semantic_index;
+  unsigned usage_mask;
} output[UREG_MAX_OUTPUT];
unsigned nr_outputs;
 
@@ -396,21 +397,25 @@ ureg_DECL_system_value(struct ureg_program *ureg,
 
 
 struct ureg_dst 
-ureg_DECL_output( struct ureg_program *ureg,
-  unsigned name,
-  unsigned index )
+ureg_DECL_output_masked( struct ureg_program *ureg,
+ unsigned name,
+ unsigned index,
+ unsigned usage_mask )
 {
unsigned i;
 
for (i = 0; i  ureg-nr_outputs; i++) {
   if (ureg-output[i].semantic_name == name 
-  ureg-output[i].semantic_index == index) 
+  ureg-output[i].semantic_index == index) { 
+ ureg-output[i].usage_mask |= usage_mask;
  goto out;
+  }
}
 
if (ureg-nr_outputs  UREG_MAX_OUTPUT) {
   ureg-output[i].semantic_name = name;
   ureg-output[i].semantic_index = index;
+  ureg-output[i].usage_mask = usage_mask;
   ureg-nr_outputs++;
}
else {
@@ -422,6 +427,15 @@ out:
 }
 
 
+struct ureg_dst 
+ureg_DECL_output( struct ureg_program *ureg,
+  unsigned name,
+  unsigned index )
+{
+   return ureg_DECL_output_masked(ureg, name, index, TGSI_WRITEMASK_XYZW);
+}
+
+
 /* Returns a new constant register.  Keep track of which have been
  * referred to so that we can emit decls later.
  *
@@ -1181,7 +1195,8 @@ emit_decl_semantic(struct ureg_program *ureg,
unsigned file,
unsigned index,
unsigned semantic_name,
-   unsigned semantic_index)
+   unsigned semantic_index,
+   unsigned usage_mask)
 {
union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3);
 
@@ -1189,7 +1204,7 @@ emit_decl_semantic(struct ureg_program *ureg,
out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
out[0].decl.NrTokens = 3;
out[0].decl.File = file;
-   out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; /* FIXME! */
+   out[0].decl.UsageMask = usage_mask;
out[0].decl.Semantic = 1;
 
out[1].value = 0;
@@ -1427,7 +1442,8 @@ static void emit_decls( struct ureg_program *ureg )
 TGSI_FILE_INPUT,
 ureg-gs_input[i].index,
 ureg-gs_input[i].semantic_name,
-ureg-gs_input[i].semantic_index);
+ureg-gs_input[i].semantic_index,
+TGSI_WRITEMASK_XYZW);
   }
}
 
@@ -1436,7 +1452,8 @@ static void emit_decls( struct ureg_program *ureg )
  TGSI_FILE_SYSTEM_VALUE,
  ureg-system_value[i].index,
  ureg-system_value[i].semantic_name,
- ureg-system_value[i].semantic_index);
+ ureg-system_value[i].semantic_index,
+ TGSI_WRITEMASK_XYZW);
}
 
for (i = 0; i  ureg-nr_outputs; i++) {
@@ -1444,7 +1461,8 @@ static void emit_decls( struct ureg_program *ureg )
  TGSI_FILE_OUTPUT,
  i,
  ureg-output[i].semantic_name,
- ureg-output[i].semantic_index);
+ ureg-output[i].semantic_index,
+ ureg-output[i].usage_mask);
}
 
for (i = 0; i  ureg-nr_samplers; i++) {
diff --git 

[Mesa-dev] [PATCH 2/2] st/mesa: add support for gl_ClipDistance

2011-12-17 Thread Bryan Cain
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   49 +---
 src/mesa/state_tracker/st_program.c|   18 ++
 2 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index b929806..3e8df78 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -304,6 +304,7 @@ public:
int samplers_used;
bool indirect_addr_temps;
bool indirect_addr_consts;
+   int num_clip_distances;

int glsl_version;
bool native_integers;
@@ -4618,9 +4619,16 @@ st_translate_program(
   }
 
   for (i = 0; i  numOutputs; i++) {
- t-outputs[i] = ureg_DECL_output(ureg,
-  outputSemanticName[i],
-  outputSemanticIndex[i]);
+ if (outputSemanticName[i] == TGSI_SEMANTIC_CLIPDIST) {
+int mask = ((1  (program-num_clip_distances - 
4*outputSemanticIndex[i])) - 1)  0xf;
+t-outputs[i] = ureg_DECL_output_masked(ureg,
+outputSemanticName[i],
+outputSemanticIndex[i],
+mask);
+ } else
+t-outputs[i] = ureg_DECL_output(ureg,
+ outputSemanticName[i],
+ outputSemanticIndex[i]);
  if ((outputSemanticName[i] == TGSI_SEMANTIC_PSIZE)  proginfo-Id) {
 /* Writing to the point size result register requires special
  * handling to implement clamping.
@@ -4797,7 +4805,8 @@ out:
 static struct gl_program *
 get_mesa_program(struct gl_context *ctx,
  struct gl_shader_program *shader_program,
-struct gl_shader *shader)
+ struct gl_shader *shader,
+ int num_clip_distances)
 {
glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor();
struct gl_program *prog;
@@ -4842,6 +4851,7 @@ get_mesa_program(struct gl_context *ctx,
v-options = options;
v-glsl_version = ctx-Const.GLSLVersion;
v-native_integers = ctx-Const.NativeIntegers;
+   v-num_clip_distances = num_clip_distances;
 
_mesa_generate_parameters_list_for_uniforms(shader_program, shader,
   prog-Parameters);
@@ -4971,6 +4981,27 @@ get_mesa_program(struct gl_context *ctx,
return prog;
 }
 
+/**
+ * Searches through the IR for a declaration of gl_ClipDistance and returns the
+ * declared size of the gl_ClipDistance array.  Returns 0 if gl_ClipDistance is
+ * not declared in the IR.
+ */
+int get_clip_distance_size(exec_list *ir)
+{
+   foreach_iter (exec_list_iterator, iter, *ir) {
+  ir_instruction *inst = (ir_instruction *)iter.get();
+  ir_variable *var = inst-as_variable();
+  if (var == NULL) continue;
+  if (!strcmp(var-name, gl_ClipDistance))
+  {
+ fprintf(stderr, gl_ClipDistance found with size %i\n, 
var-type-length);
+ return var-type-length;
+  }
+   }
+   
+   return 0;
+}
+
 extern C {
 
 struct gl_shader *
@@ -5009,6 +5040,7 @@ st_new_shader_program(struct gl_context *ctx, GLuint name)
 GLboolean
 st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 {
+   int num_clip_distances[MESA_SHADER_TYPES];
assert(prog-LinkStatus);
 
for (unsigned i = 0; i  MESA_SHADER_TYPES; i++) {
@@ -5020,6 +5052,11 @@ st_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
   const struct gl_shader_compiler_options *options =
 
ctx-ShaderCompilerOptions[_mesa_shader_type_to_index(prog-_LinkedShaders[i]-Type)];
 
+  /* We have to determine the length of the gl_ClipDistance array before
+   * the array is lowered to two vec4s by lower_clip_distance().
+   */
+  num_clip_distances[i] = get_clip_distance_size(ir);
+
   do {
  progress = false;
 
@@ -5036,6 +5073,7 @@ st_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
   || progress;
 
  progress = lower_quadop_vector(ir, false) || progress;
+ progress = lower_clip_distance(ir) || progress;
 
  if (options-MaxIfDepth == 0)
 progress = lower_discard(ir) || progress;
@@ -5070,7 +5108,8 @@ st_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
   if (prog-_LinkedShaders[i] == NULL)
  continue;
 
-  linked_prog = get_mesa_program(ctx, prog, prog-_LinkedShaders[i]);
+  linked_prog = get_mesa_program(ctx, prog, prog-_LinkedShaders[i],
+ num_clip_distances[i]);
 
   if (linked_prog) {
 static const GLenum targets[] = {
diff --git a/src/mesa/state_tracker/st_program.c 
b/src/mesa/state_tracker/st_program.c
index b83c561..b404503 100644
--- 

[Mesa-dev] [Bug 43916] New: platform_x11.c use undeclared identifier O_CLOEXEC

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

 Bug #: 43916
   Summary: platform_x11.c use undeclared identifier O_CLOEXEC
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: All
OS/Version: FreeBSD
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/X11
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: na...@gentoo.org


On FreeBSD 8.x, we don't have O_CLOEXC and it cause build failure like:

x86_64-gentoo-freebsd8.2-gcc -c -I../../../../include
-I../../../../src/egl/main -I../../../../src/mapi -I../../../../src/gbm/main
-I../../../../src/gbm/backends/dri -DDEFAULT_DRIVER_DIR=\/usr/lib64/dri\ 
-I/usr/include/libdrm   -DHAVE_X11_PLATFORM -D_THREAD_SAFE   -w -O2
-march=nocona -mtune=nocona -pipe -fno-ivopts -ffast-math -Wall
-Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing  -fPIC 
-DUSE_X86_64_ASM -DTEXTURE_FLOAT_ENABLED -DHAVE_POSIX_MEMALIGN -DUSE_XCB
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER -DHAVE_ALIAS
-DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DHAVE_XCB_DRI2
-DXCB_DRI2_CONNECT_DEVICE_NAME_BROKEN -fvisibility=hidden
-D_EGL_MAIN=_eglBuiltInDriverDRI2 -DHAVE_SHARED_GLAPI platform_x11.c -o
platform_x11.o
platform_x11.c: In function 'dri2_initialize_x11_dri2':
platform_x11.c:1000: error: 'O_CLOEXEC' undeclared (first use in this function)
platform_x11.c:1000: error: (Each undeclared identifier is reported only once
platform_x11.c:1000: error: for each function it appears in.)
gmake[4]: *** [platform_x11.o] Error 1
gmake[4]: *** Waiting for unfinished jobs
gmake[4]: Leaving directory
`/var/tmp/portage/media-libs/mesa-7.11/work/Mesa-7.11/src/egl/drivers/dri2'
gmake[3]: *** [subdirs] Error 1
gmake[3]: Leaving directory
`/var/tmp/portage/media-libs/mesa-7.11/work/Mesa-7.11/src/egl/drivers'
gmake[2]: *** [subdirs] Error 1
gmake[2]: Leaving directory
`/var/tmp/portage/media-libs/mesa-7.11/work/Mesa-7.11/src/egl'
gmake[1]: *** [subdirs] Error 1
gmake[1]: Leaving directory
`/var/tmp/portage/media-libs/mesa-7.11/work/Mesa-7.11/src'
gmake: *** [default] Error 1

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


[Mesa-dev] [Bug 43916] platform_x11.c use undeclared identifier O_CLOEXEC

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

Kristian Høgsberg k...@bitplanet.net changed:

   What|Removed |Added

 Resolution|NOTABUG |NOTOURBUG

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