Re: [Mesa-dev] [PATCH 2/2] egl: update headers

2011-12-20 Thread Chia-I Wu
On Tue, Dec 20, 2011 at 5:28 AM, Ian Romanick  wrote:
> On 12/19/2011 02:05 AM, Chia-I Wu wrote:
>>
>> From: Chia-I Wu
>>
>> Update to revision 15052.
>>
>> EGL_MESA_drm_image is now official.  But apparently we have our own
>> extension
>> to it and we need this in eglmesaext.h:
>>
>>   #ifdef EGL_MESA_drm_image
>>   /* Mesa's extension to EGL_MESA_drm_image... */
>>   #ifndef EGL_DRM_BUFFER_USE_CURSOR_MESA
>>   #define EGL_DRM_BUFFER_USE_CURSOR_MESA               0x0004
>>   #endif
>>   #endif
> Where is this actually from?  Is it in the extension?  A layered extension?
>  Outer space? :)  It sounds like we need to propagate and update back to the
> Khronos registry.
Outer space it is :)

I am not sure if this extension (and mesa's own addition) is used
anywhere.  It was added for wayland, which seems to migrate away a
while ago.
>
>> ---
>>  include/EGL/eglext.h      |   65
>> +++-
>>  include/EGL/eglmesaext.h  |   23 ++--
>>  include/EGL/eglplatform.h |    9 +-
>>  3 files changed, 73 insertions(+), 24 deletions(-)
>>
>> diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
>> index 800a23d..a7ea2ea 100644
>> --- a/include/EGL/eglext.h
>> +++ b/include/EGL/eglext.h
>> @@ -34,8 +34,8 @@ extern "C" {
>>
>>  /* Header file version number */
>>  /* Current version at http://www.khronos.org/registry/egl/ */
>> -/* $Revision: 12124 $ on $Date: 2010-07-27 20:12:35 -0700 (Tue, 27 Jul
>> 2010) $ */
>> -#define EGL_EGLEXT_VERSION 7
>> +/* $Revision: 15052 $ on $Date: 2011-07-06 17:43:46 -0700 (Wed, 06 Jul
>> 2011) $ */
>> +#define EGL_EGLEXT_VERSION 10
>>
>>  #ifndef EGL_KHR_config_attribs
>>  #define EGL_KHR_config_attribs 1
>> @@ -267,6 +267,67 @@ typedef EGLSurface (EGLAPIENTRYP
>> PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dp
>>  #define EGL_COLOR_ARGB_HI                     0x8F73
>>  #endif /* EGL_HI_colorformats */
>>
>> +#ifndef EGL_MESA_drm_image
>> +#define EGL_MESA_drm_image 1
>> +#define EGL_DRM_BUFFER_FORMAT_MESA             0x31D0      /*
>> CreateDRMImageMESA attribute */
>> +#define EGL_DRM_BUFFER_USE_MESA                        0x31D1      /*
>> CreateDRMImageMESA attribute */
>> +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA      0x31D2      /*
>> EGL_IMAGE_FORMAT_MESA attribute value */
>> +#define EGL_DRM_BUFFER_MESA                    0x31D3      /*
>> eglCreateImageKHR target */
>> +#define EGL_DRM_BUFFER_STRIDE_MESA             0x31D4
>> +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA                0x0001  /*
>> EGL_DRM_BUFFER_USE_MESA bits */
>> +#define EGL_DRM_BUFFER_USE_SHARE_MESA          0x0002  /*
>> EGL_DRM_BUFFER_USE_MESA bits */
>> +#ifdef EGL_EGLEXT_PROTOTYPES
>> +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy,
>> const EGLint *attrib_list);
>> +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy,
>> EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
>> +#endif /* EGL_EGLEXT_PROTOTYPES */
>> +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC)
>> (EGLDisplay dpy, const EGLint *attrib_list);
>> +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC)
>> (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint
>> *stride);
>> +#endif
>> +
>> +#ifndef EGL_NV_post_sub_buffer
>> +#define EGL_NV_post_sub_buffer 1
>> +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV       0x30BE
>> +#ifdef EGL_EGLEXT_PROTOTYPES
>> +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy,
>> EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
>> +#endif /* EGL_EGLEXT_PROTOTYPES */
>> +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay
>> dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
>> +#endif
>> +
>> +#ifndef EGL_ANGLE_query_surface_pointer
>> +#define EGL_ANGLE_query_surface_pointer 1
>> +#ifdef EGL_EGLEXT_PROTOTYPES
>> +EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface
>> surface, EGLint attribute, void **value);
>> +#endif
>> +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC)
>> (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
>> +#endif
>> +
>> +#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
>> +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
>> +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE  0x3200
>> +#endif
>> +
>> +#ifndef EGL_NV_coverage_sample_resolve
>> +#define EGL_NV_coverage_sample_resolve 1
>> +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV         0x3131
>> +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
>> +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV    0x3133
>> +#endif
>> +
>> +#if KHRONOS_SUPPORT_INT64   /* EGLTimeKHR requires 64-bit uint support */
>> +#ifndef EGL_NV_system_time
>> +#define EGL_NV_system_time 1
>> +
>> +typedef khronos_utime_nanoseconds_t EGLuint64NV;
>> +
>> +#ifdef EGL_EGLEXT_PROTOTYPES
>> +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
>> +EGLAPI EGLuint64

Re: [Mesa-dev] [PATCH 1/2] linker: fix strdup memory leak

2011-12-20 Thread Pekka Paalanen
On Mon, 19 Dec 2011 13:24:20 -0800
Ian Romanick  wrote:

> On 12/19/2011 05:23 AM, Pekka Paalanen wrote:
> > On Fri, 16 Dec 2011 10:46:11 -0800
> > Ian Romanick  wrote:
> >
> >> On 12/14/2011 11:26 PM, Pekka Paalanen wrote:
> >>> string_to_uint_map::put() already does a strdup() for the key
> >>> argument, so we leak the memory allocated by strdup() in
> >>> link_uniforms.cpp.
> >>>
> >>> Remove the extra strdup(), fixes a few Valgrind detected leaks.
> >>
> >> Have you run piglit on this?  I seem to recall adding the extra
> >> strdup for a reason.  The hash table keeps a copy of the key
> >> pointer passed to it, and the underlying object may be deleted
> >> before the hash table is deleted.  This can happen if the back-end
> >> optimizes some uniforms away after the linker has generated the
> >> list of "active" uniforms.  I'm pretty sure there were one or two
> >> test cases that hit this on i965.
> >
> > Sorry, I didn't. Finally got piglit running, though readPixSanity
> > failed on stencil values. Anyway it's running all.tests now for the
> > upstream Mesa master, and then I'll run it with my patches.
> >
> > Oh, this is Sandybridge, btw.
> >
> >>> --- a/src/glsl/link_uniforms.cpp
> >>> +++ b/src/glsl/link_uniforms.cpp
> >>> @@ -174,8 +174,7 @@ private:
> >>>  if (this->map->get(id, name))
> >>>return;
> >>>
> >>> -  char *key = strdup(name);
> >>> -  this->map->put(this->num_active_uniforms, key);
> >>> +  this->map->put(this->num_active_uniforms, name);
> >>>
> >>>  /* Each leaf uniform occupies one entry in the list of
> >>> active
> >>>   * uniforms.
> >
> > The whole visit_field() function is this:
> >
> > virtual void visit_field(const glsl_type *type, const char
> > *name) {
> >assert(!type->is_record());
> >assert(!(type->is_array()&&
> > type->fields.array->is_record()));
> >
> >/* Count the number of samplers regardless of whether the
> > uniform is
> > * already in the hash table.  The hash table prevents
> > adding the same
> > * uniform for multiple shader targets, but in this case we
> > want to
> > * count it for each shader target.
> > */
> >const unsigned values = values_for_type(type);
> >if (type->contains_sampler()) {
> >  this->num_shader_samplers +=
> > type->is_array() ? type->array_size() : 1;
> >} else {
> >  /* Accumulate the total number of uniform slots used by
> > this shader.
> >   * Note that samplers do not count against this limit
> > because they
> >   * don't use any storage on current hardware.
> >   */
> >  this->num_shader_uniform_components += values;
> >}
> >
> >/* If the uniform is already in the map, there's nothing
> > more to do. */
> >unsigned id;
> >if (this->map->get(id, name))
> >  return;
> >
> >char *key = strdup(name);
> >this->map->put(this->num_active_uniforms, key);
> >
> >/* Each leaf uniform occupies one entry in the list of active
> > * uniforms.
> > */
> >this->num_active_uniforms++;
> >this->num_values += values;
> > }
> >
> > The variable 'key' is not used anywhere else but passed to
> > string_to_uint_map::put(). That function in its whole is:
> >
> > void put(unsigned value, const char *key)
> > {
> >/* The low-level hash table structure returns NULL if key is
> > not in the
> > * hash table.  However, users of this map might want to
> > store zero as a
> > * valid value in the table.  Bias the value by +1 so that a
> > * user-specified zero is stored as 1.  This enables ::get
> > to tell the
> > * difference between a user-specified zero (returned as 1 by
> > * hash_table_find) and the key not in the table (returned
> > as 0 by
> > * hash_table_find).
> > *
> > * The net effect is that we can't store UINT_MAX in the
> > table.  This is
> > * because UINT_MAX+1 = 0.
> > */
> >assert(value != UINT_MAX);
> >hash_table_replace(this->ht,
> >  (void *) (intptr_t) (value + 1),
> >  strdup(key));
> > }
> >
> > Therefore, as far as I see, 'key' is not used for anything else than
> > passed again through strdup(), which would effectively be:
> 
> Ah yes, I forgot that I added that in string_to_uint_map::put.  You
> are quite correct.
> 
> Okay, the original patch is:
> 
> Reviewed-by: Ian Romanick 

You were right, it does regress in piglit.

This particular patch causes varray-disabled to fail in quick.tests.
>From 4 runs of rebuilt Mesa, 3 fail in varray-disabled, and the
remaining one fails in EXT_TIMER_QUERY:time-elapsed instead.

Some of the rebuilds were from clean checkout (git clean -dxf), some
simply by adding the patch on top of a previous build that produced the
reference piglit results.

Unfortunately I have to move on for now, 

Re: [Mesa-dev] [PATCH] mesa: fix a leak in _mesa_delete_texture_image()

2011-12-20 Thread Pekka Paalanen
On Fri, 16 Dec 2011 08:42:01 -0700
Brian Paul  wrote:

> On 12/16/2011 07:17 AM, Pekka Paalanen wrote:
> > Valgrind complains about a definitely lost block allocated in
> > intelNewTextureImage(). This leak was apparently created by
> > 6e0f9001fe3fb191c2928bd09aa9e9d05ddf4ea9, "mesa: move
> > gl_texture_image::Data, RowStride, ImageOffsets to swrast", as it
> > removes the free() from _mesa_delete_texture_image().
> >
> > Put the free() back, fixes a Valgrind error.
> >
> > Signed-off-by: Pekka Paalanen
> > Cc: Brian Paul
> > ---
> >   src/mesa/main/teximage.c |1 +
> >   1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> > index 8a002b6..6318cb1 100644
> > --- a/src/mesa/main/teximage.c
> > +++ b/src/mesa/main/teximage.c
> > @@ -604,6 +604,7 @@ _mesa_delete_texture_image(struct gl_context
> > *ctx, */
> >  ASSERT(ctx->Driver.FreeTextureImageBuffer);
> >  ctx->Driver.FreeTextureImageBuffer( ctx, texImage );
> > +   free(texImage);
> >   }
> >
> >
> 
> Reviewed-by: Brian Paul 
> 
> Can you commit this?

Verified with piglit quick.tests to be regression-free.
Pushed, thanks.

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


Re: [Mesa-dev] [PATCH] Fix build with LLVM >= r145623.

2011-12-20 Thread Michel Dänzer
On Mon, 2011-12-19 at 23:11 +0100, Johannes Obermayr wrote: 
> This is a workaround for https://bugs.freedesktop.org/show_bug.cgi?id=43861.
> 
> Actually the issue which makes -pedantic failing should be solved.

Maybe it should, but that's not for LLVM to enforce on its users.


> ---
>  configure.ac |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index a4943e1..8e809b9 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1753,7 +1753,7 @@ if test "x$enable_gallium_llvm" = xyes; then
>  
>  if test "x$LLVM_CONFIG" != xno; then
>   LLVM_VERSION=`$LLVM_CONFIG --version`
> - LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed 's/-DNDEBUG\>//g'`
> + LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed -e 's/-DNDEBUG\>//g' -e 
> 's/-pedantic//g'`
>   LLVM_LIBS="`$LLVM_CONFIG --libs`"
>  
>   LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`

Might want to update configs/linux-llvm as well, but otherwise

Reviewed-by: Michel Dänzer 


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


[Mesa-dev] [PATCH] xvmc: Remove unused variable

2011-12-20 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 

---

 src/gallium/state_trackers/xorg/xvmc/attributes.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)


diff --git a/src/gallium/state_trackers/xorg/xvmc/attributes.c 
b/src/gallium/state_trackers/xorg/xvmc/attributes.c
index b115d52..d40a7b1 100644
--- a/src/gallium/state_trackers/xorg/xvmc/attributes.c
+++ b/src/gallium/state_trackers/xorg/xvmc/attributes.c
@@ -53,7 +53,6 @@ static const XvAttribute attributes[] = {
 PUBLIC
 XvAttribute* XvMCQueryAttributes(Display *dpy, XvMCContext *context, int 
*number)
 {
-   XvMCContextPrivate *context_priv;
XvAttribute *result;
 
assert(dpy && number);
@@ -61,8 +60,6 @@ XvAttribute* XvMCQueryAttributes(Display *dpy, XvMCContext 
*context, int *number
if (!context || !context->privData)
   return NULL;
 
-   context_priv = context->privData;
-
result = malloc(sizeof(attributes));
if (!result)
   return NULL;


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


[Mesa-dev] [PATCH] vl: Remove unused declaration

2011-12-20 Thread Maarten Lankhorst
csc is not used for rgba and gives a warning.

Signed-off-by: Maarten Lankhorst 

---

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


diff --git a/src/gallium/auxiliary/vl/vl_compositor.c 
b/src/gallium/auxiliary/vl/vl_compositor.c
index 98cb616..630cf02 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -132,7 +132,7 @@ create_frag_shader_palette(struct vl_compositor *c, bool 
include_cc)
if (!shader)
   return false;
 
-   for (i = 0; i < 3; ++i)
+   for (i = 0; include_cc && i < 3; ++i)
   csc[i] = ureg_DECL_constant(shader, i);
 
tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, 1, 
TGSI_INTERPOLATE_LINEAR);


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


[Mesa-dev] [PATCH 1/3] vl: Only initialize vlc once

2011-12-20 Thread Maarten Lankhorst
And add more sanity checks to stream. This shouldn't break things beyond those 
that aren't broken already.

Signed-off-by: Maarten Lankhorst 

---
And yes Andy, I mean that I haven't found a good video yet to fix the playback 
parts that are still broken..

 src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c |   56 +++-
 src/gallium/auxiliary/vl/vl_vlc.h  |   33 +-
 2 files changed, 47 insertions(+), 42 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
index 936cf2c..62d08d7 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
@@ -787,7 +787,7 @@ entry:
 }
 
 static INLINE bool
-decode_slice(struct vl_mpg12_bs *bs)
+decode_slice(struct vl_mpg12_bs *bs, unsigned code)
 {
struct pipe_mpeg12_macroblock mb;
short dct_blocks[64*6];
@@ -796,24 +796,29 @@ decode_slice(struct vl_mpg12_bs *bs)
 
memset(&mb, 0, sizeof(mb));
mb.base.codec = PIPE_VIDEO_CODEC_MPEG12;
-   mb.y = vl_vlc_get_uimsbf(&bs->vlc, 8) - 1;
+   mb.y = code - 1;
mb.blocks = dct_blocks;
 
reset_predictor(bs);
+   vl_vlc_fillbits(&bs->vlc);
dct_scale = quant_scale[bs->desc.q_scale_type][vl_vlc_get_uimsbf(&bs->vlc, 
5)];
 
-   if (vl_vlc_get_uimsbf(&bs->vlc, 1))
+   if (vl_vlc_get_uimsbf(&bs->vlc, 1)) {
+  vl_vlc_fillbits(&bs->vlc);
   while (vl_vlc_get_uimsbf(&bs->vlc, 9) & 1)
  vl_vlc_fillbits(&bs->vlc);
+   }
 
vl_vlc_fillbits(&bs->vlc);
+   assert(vl_vlc_bits_left(&bs->vlc) > 23 && vl_vlc_peekbits(&bs->vlc, 23));
do {
   int inc = 0;
 
-  while (vl_vlc_peekbits(&bs->vlc, 11) == 15) {
- vl_vlc_eatbits(&bs->vlc, 11);
- vl_vlc_fillbits(&bs->vlc);
-  }
+  if (bs->decoder->profile == PIPE_VIDEO_PROFILE_MPEG1)
+ while (vl_vlc_peekbits(&bs->vlc, 11) == 15) {
+vl_vlc_eatbits(&bs->vlc, 11);
+vl_vlc_fillbits(&bs->vlc);
+ }
 
   while (vl_vlc_peekbits(&bs->vlc, 11) == 8) {
  vl_vlc_eatbits(&bs->vlc, 11);
@@ -959,32 +964,23 @@ void
 vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const uint8_t 
*buffer)
 {
assert(bs);
-   assert(buffer && num_bytes);
-
-   while(num_bytes > 2) {
-  if (buffer[0] == 0x00 && buffer[1] == 0x00 && buffer[2] == 0x01 &&
-   buffer[3] >= 0x01 && buffer[3] < 0xAF) {
- unsigned consumed;
 
- buffer += 3;
- num_bytes -= 3;
+   vl_vlc_init(&bs->vlc, 1, num_bytes, (void const * const *)&buffer, 
&num_bytes);
 
- vl_vlc_init(&bs->vlc, buffer, num_bytes);
-
- if (!decode_slice(bs))
+   while (vl_vlc_bits_left(&bs->vlc) >= 32) {
+  vl_vlc_fillbits(&bs->vlc);
+  if (vl_vlc_peekbits(&bs->vlc, 24) == 0x01) {
+ unsigned code;
+ vl_vlc_eatbits(&bs->vlc, 24);
+ code = vl_vlc_get_uimsbf(&bs->vlc, 8);
+ if (!code || code > 0xaf)
+continue;
+ if (!decode_slice(bs, code))
 return;
-
- consumed = num_bytes - vl_vlc_bits_left(&bs->vlc) / 8;
-
- /* crap, this is a bug we have consumed more bytes than left in the 
buffer */
- assert(consumed <= num_bytes);
-
- num_bytes -= consumed;
- buffer += consumed;
-
+ vl_vlc_bitalign(&bs->vlc);
   } else {
- ++buffer;
- --num_bytes;
+ vl_vlc_eatbits(&bs->vlc, 8);
+ continue;
   }
}
 }
diff --git a/src/gallium/auxiliary/vl/vl_vlc.h 
b/src/gallium/auxiliary/vl/vl_vlc.h
index dc4faed..a4ded70 100644
--- a/src/gallium/auxiliary/vl/vl_vlc.h
+++ b/src/gallium/auxiliary/vl/vl_vlc.h
@@ -38,7 +38,7 @@
 struct vl_vlc
 {
uint64_t buffer;
-   unsigned valid_bits;
+   uint32_t valid_bits;
uint32_t *data;
uint32_t *end;
 };
@@ -74,11 +74,9 @@ vl_vlc_init_table(struct vl_vlc_entry *dst, unsigned 
dst_size, const struct vl_v
 static INLINE void
 vl_vlc_fillbits(struct vl_vlc *vlc)
 {
-   if (vlc->valid_bits < 32) {
+   if (vlc->valid_bits < 32 && vlc->data < vlc->end) {
   uint32_t value = *vlc->data;
 
-  //assert(vlc->data <= vlc->end);
-
 #ifndef PIPE_ARCH_BIG_ENDIAN
   value = util_bswap32(value);
 #endif
@@ -90,10 +88,14 @@ vl_vlc_fillbits(struct vl_vlc *vlc)
 }
 
 static INLINE void
-vl_vlc_init(struct vl_vlc *vlc, const uint8_t *data, unsigned len)
+vl_vlc_init(struct vl_vlc *vlc,
+const unsigned array_size, unsigned total_len,
+const const void *const *datas, const unsigned *lens)
 {
+   const uint8_t *data = datas[0];
assert(vlc);
-   assert(data && len);
+   assert(array_size == 1); // TODO
+   assert(datas[0] && lens[0]);
 
vlc->buffer = 0;
vlc->valid_bits = 0;
@@ -102,11 +104,11 @@ vl_vlc_init(struct vl_vlc *vlc, const uint8_t *data, 
unsigned len)
while (pointer_to_uintptr(data) & 3) {
   vlc->buffer |= (uint64_t)*data << (56 - vlc->valid_bits);
   ++data;
-  --len;
+  --total_len;
   vlc->valid_bi

[Mesa-dev] [PATCH 2/3] vl: Remove decode buffers

2011-12-20 Thread Maarten Lankhorst
It's something for vl_mpeg12_bitstream internally, so treat it as such.

Signed-off-by: Maarten Lankhorst 

---
v1: Split up from previous patch and with performance restored..


 src/gallium/auxiliary/vl/vl_decoder.c  |   13 
 src/gallium/auxiliary/vl/vl_decoder.h  |6 --
 src/gallium/auxiliary/vl/vl_idct.c |   14 ++--
 src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c |7 ++
 src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h |4 +
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c   |   64 +---
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.h   |   45 +++---
 src/gallium/drivers/nouveau/nouveau_video.c|2 -
 src/gallium/drivers/nvfx/nvfx_screen.c |2 -
 src/gallium/drivers/r300/r300_screen.c |2 -
 src/gallium/drivers/r600/r600_pipe.c   |2 -
 src/gallium/drivers/softpipe/sp_screen.c   |2 -
 src/gallium/include/pipe/p_video_decoder.h |   18 +-
 src/gallium/include/pipe/p_video_enums.h   |3 -
 src/gallium/state_trackers/vdpau/decode.c  |   62 +--
 src/gallium/state_trackers/vdpau/vdpau_private.h   |3 -
 src/gallium/state_trackers/xorg/xvmc/surface.c |6 --
 .../state_trackers/xorg/xvmc/xvmc_private.h|1 
 18 files changed, 87 insertions(+), 169 deletions(-)


diff --git a/src/gallium/auxiliary/vl/vl_decoder.c 
b/src/gallium/auxiliary/vl/vl_decoder.c
index 383e02d..da905a6 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_decoder.c
@@ -44,19 +44,6 @@ vl_profile_supported(struct pipe_screen *screen, enum 
pipe_video_profile profile
}
 }
 
-unsigned
-vl_num_buffers_desired(struct pipe_screen *screen, enum pipe_video_profile 
profile)
-{
-   assert(screen);
-   switch (u_reduce_video_profile(profile)) {
-  case PIPE_VIDEO_CODEC_MPEG12:
- return 4;
-
-  default:
- return 1;
-   }
-}
-
 struct pipe_video_decoder *
 vl_create_decoder(struct pipe_context *pipe,
   enum pipe_video_profile profile,
diff --git a/src/gallium/auxiliary/vl/vl_decoder.h 
b/src/gallium/auxiliary/vl/vl_decoder.h
index a997516..a7abe9c 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.h
+++ b/src/gallium/auxiliary/vl/vl_decoder.h
@@ -38,12 +38,6 @@ bool
 vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile 
profile);
 
 /**
- * the desired number of buffers for optimal operation
- */
-unsigned
-vl_num_buffers_desired(struct pipe_screen *screen, enum pipe_video_profile 
profile);
-
-/**
  * standard implementation of pipe->create_video_decoder
  */
 struct pipe_video_decoder *
diff --git a/src/gallium/auxiliary/vl/vl_idct.c 
b/src/gallium/auxiliary/vl/vl_idct.c
index a2b3537..8394542 100644
--- a/src/gallium/auxiliary/vl/vl_idct.c
+++ b/src/gallium/auxiliary/vl/vl_idct.c
@@ -614,9 +614,9 @@ init_source(struct vl_idct *idct, struct vl_idct_buffer 
*buffer)
 }
 
 static void
-cleanup_source(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+cleanup_source(struct vl_idct_buffer *buffer)
 {
-   assert(idct && buffer);
+   assert(buffer);
 
pipe_surface_reference(&buffer->fb_state_mismatch.cbufs[0], NULL);
 
@@ -665,13 +665,13 @@ error_surfaces:
 }
 
 static void
-cleanup_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+cleanup_intermediate(struct vl_idct_buffer *buffer)
 {
unsigned i;
 
-   assert(idct && buffer);
+   assert(buffer);
 
-   for(i = 0; i < idct->nr_of_render_targets; ++i)
+   for(i = 0; i < buffer->fb_state.nr_cbufs; ++i)
   pipe_surface_reference(&buffer->fb_state.cbufs[i], NULL);
 
pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, 
NULL);
@@ -823,8 +823,8 @@ vl_idct_cleanup_buffer(struct vl_idct_buffer *buffer)
 {
assert(buffer);
 
-   cleanup_source(buffer->idct, buffer);
-   cleanup_intermediate(buffer->idct, buffer);
+   cleanup_source(buffer);
+   cleanup_intermediate(buffer);
 
pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, NULL);
pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, 
NULL);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
index 62d08d7..330ddd9 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
@@ -961,11 +961,14 @@ vl_mpg12_bs_set_picture_desc(struct vl_mpg12_bs *bs, 
struct pipe_mpeg12_picture_
 }
 
 void
-vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const uint8_t 
*buffer)
+vl_mpg12_bs_decode(struct vl_mpg12_bs *bs,
+   unsigned n, unsigned len,
+   const unsigned *lens, const void* const*buffer)
 {
assert(bs);
+   assert(buffer && n && len);
 
-   vl_vlc_init(&bs->vlc, 1, num_bytes, (void const * const *)&buffer, 
&num_bytes);
+   vl_vlc_init(&bs->vlc, n, len, buffer, lens);
 
while (vl_vlc_bits_left

[Mesa-dev] [PATCH 3/3] vl: And remove remaining unnecessary members

2011-12-20 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 

---
begin_frame and end_frame are implied for bitstream acceleration, and a frame 
can be explicitly
ended with the flush call, so there's no need for the extra calls.

Only reason patch is big is because I unified set_picture_parameters and 
various calls
that should be part of it. This is necessary for the followup h.264 patch which 
needs
to submit more information about each reference frame.

 src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c |4 
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c   |   99 --
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.h   |3 
 src/gallium/drivers/nouveau/nouveau_video.c|   57 +-
 src/gallium/include/pipe/p_video_decoder.h |   40 
 src/gallium/include/pipe/p_video_state.h   |   15 --
 src/gallium/state_trackers/vdpau/decode.c  |  239 +++-
 src/gallium/state_trackers/xorg/xvmc/surface.c |  102 +-
 8 files changed, 185 insertions(+), 374 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
index 330ddd9..b9c50ab 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
@@ -828,7 +828,7 @@ decode_slice(struct vl_mpg12_bs *bs, unsigned code)
   inc += vl_vlc_get_vlclbf(&bs->vlc, tbl_B1, 11);
   if (x != -1) {
  mb.num_skipped_macroblocks = inc - 1;
- bs->decoder->decode_macroblock(bs->decoder, &mb.base, 1);
+ bs->decoder->decode_macroblock(bs->decoder, NULL, NULL, &mb.base, 1);
   }
   mb.x = x += inc;
 
@@ -932,7 +932,7 @@ decode_slice(struct vl_mpg12_bs *bs, unsigned code)
} while (vl_vlc_peekbits(&bs->vlc, 23));
 
mb.num_skipped_macroblocks = 0;
-   bs->decoder->decode_macroblock(bs->decoder, &mb.base, 1);
+   bs->decoder->decode_macroblock(bs->decoder, NULL, NULL, &mb.base, 1);
return true;
 }
 
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index 6d99611..d346509 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -497,24 +497,31 @@ vl_mpeg12_set_picture_parameters(struct 
pipe_video_decoder *decoder,
 {
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct pipe_mpeg12_picture_desc *pic = (struct pipe_mpeg12_picture_desc 
*)picture;
+   struct pipe_sampler_view **sv;
+   unsigned j;
 
assert(dec && pic);
 
dec->picture_desc = *pic;
-}
-
-static void
-vl_mpeg12_set_quant_matrix(struct pipe_video_decoder *decoder,
-   const struct pipe_quant_matrix *matrix)
-{
-   struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
-   const struct pipe_mpeg12_quant_matrix *m = (const struct 
pipe_mpeg12_quant_matrix *)matrix;
-
-   assert(dec);
-   assert(matrix->codec == PIPE_VIDEO_CODEC_MPEG12);
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
+  memcpy(dec->intra_matrix, pic->intra_matrix, 64);
+  memcpy(dec->non_intra_matrix, pic->non_intra_matrix, 64);
+   }
+   if (pic->ref_forward) {
+  sv = pic->ref_forward->get_sampler_view_planes(pic->ref_forward);
+  for (j = 0; j < VL_MAX_PLANES; ++j)
+ pipe_sampler_view_reference(&dec->ref_frames[0][j], sv[j]);
+   } else
+  for (j = 0; j < VL_MAX_PLANES; ++j)
+ pipe_sampler_view_reference(&dec->ref_frames[0][j], NULL);
 
-   memcpy(dec->intra_matrix, m->intra_matrix, 64);
-   memcpy(dec->non_intra_matrix, m->non_intra_matrix, 64);
+   if (pic->ref_backward) {
+  sv = pic->ref_backward->get_sampler_view_planes(pic->ref_backward);
+  for (j = 0; j < VL_MAX_PLANES; ++j)
+ pipe_sampler_view_reference(&dec->ref_frames[1][j], sv[j]);
+   } else
+  for (j = 0; j < VL_MAX_PLANES; ++j)
+ pipe_sampler_view_reference(&dec->ref_frames[1][j], NULL);
 }
 
 static void
@@ -530,29 +537,7 @@ vl_mpeg12_set_decode_target(struct pipe_video_decoder 
*decoder,
surfaces = target->get_surfaces(target);
for (i = 0; i < VL_MAX_PLANES; ++i)
   pipe_surface_reference(&dec->target_surfaces[i], surfaces[i]);
-}
-
-static void
-vl_mpeg12_set_reference_frames(struct pipe_video_decoder *decoder,
-   struct pipe_video_buffer **ref_frames,
-   unsigned num_ref_frames)
-{
-   struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
-   struct pipe_sampler_view **sv;
-   unsigned i,j;
-
-   assert(dec);
-   assert(num_ref_frames <= VL_MAX_REF_FRAMES);
-
-   for (i = 0; i < num_ref_frames; ++i) {
-  sv = ref_frames[i]->get_sampler_view_planes(ref_frames[i]);
-  for (j = 0; j < VL_MAX_PLANES; ++j)
- pipe_sampler_view_reference(&dec->ref_frames[i][j], sv[j]);
-   }
-
-   for (; i < VL_MAX_REF_FRAMES; ++i)
-  for (j = 0; j < VL_MAX_PLANES; ++j)
- pipe_sampler_view_reference(&dec->ref_frames[i][j], NULL);
+   dec->last_target = (str

Re: [Mesa-dev] [PATCH 1/3] vl: Only initialize vlc once

2011-12-20 Thread Christian König

On 20.12.2011 12:43, Maarten Lankhorst wrote:

And add more sanity checks to stream. This shouldn't break things beyond those 
that aren't broken already.

Signed-off-by: Maarten Lankhorst

---
And yes Andy, I mean that I haven't found a good video yet to fix the playback 
parts that are still broken..

Why do you want to change that anyway?

The search for start codes was especially split out of the VLC stuff, 
because start codes start are byte aligned anyway and it doesn't make 
much sense to search for them using the slower peekbits & fillbits 
functions.


Se below for some further comments.

  src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c |   56 +++-
  src/gallium/auxiliary/vl/vl_vlc.h  |   33 +-
  2 files changed, 47 insertions(+), 42 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
index 936cf2c..62d08d7 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
@@ -787,7 +787,7 @@ entry:
  }

  static INLINE bool
-decode_slice(struct vl_mpg12_bs *bs)
+decode_slice(struct vl_mpg12_bs *bs, unsigned code)
  {
 struct pipe_mpeg12_macroblock mb;
 short dct_blocks[64*6];
@@ -796,24 +796,29 @@ decode_slice(struct vl_mpg12_bs *bs)

 memset(&mb, 0, sizeof(mb));
 mb.base.codec = PIPE_VIDEO_CODEC_MPEG12;
-   mb.y = vl_vlc_get_uimsbf(&bs->vlc, 8) - 1;
+   mb.y = code - 1;
 mb.blocks = dct_blocks;

 reset_predictor(bs);
+   vl_vlc_fillbits(&bs->vlc);
 dct_scale = quant_scale[bs->desc.q_scale_type][vl_vlc_get_uimsbf(&bs->vlc, 
5)];

-   if (vl_vlc_get_uimsbf(&bs->vlc, 1))
+   if (vl_vlc_get_uimsbf(&bs->vlc, 1)) {
+  vl_vlc_fillbits(&bs->vlc);
while (vl_vlc_get_uimsbf(&bs->vlc, 9)&  1)
   vl_vlc_fillbits(&bs->vlc);
+   }

 vl_vlc_fillbits(&bs->vlc);
+   assert(vl_vlc_bits_left(&bs->vlc)>  23&&  vl_vlc_peekbits(&bs->vlc, 23));
 do {
int inc = 0;

-  while (vl_vlc_peekbits(&bs->vlc, 11) == 15) {
- vl_vlc_eatbits(&bs->vlc, 11);
- vl_vlc_fillbits(&bs->vlc);
-  }
+  if (bs->decoder->profile == PIPE_VIDEO_PROFILE_MPEG1)
+ while (vl_vlc_peekbits(&bs->vlc, 11) == 15) {
+vl_vlc_eatbits(&bs->vlc, 11);
+vl_vlc_fillbits(&bs->vlc);
+ }

while (vl_vlc_peekbits(&bs->vlc, 11) == 8) {
   vl_vlc_eatbits(&bs->vlc, 11);
@@ -959,32 +964,23 @@ void
  vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const uint8_t 
*buffer)
  {
 assert(bs);
-   assert(buffer&&  num_bytes);
-
-   while(num_bytes>  2) {
-  if (buffer[0] == 0x00&&  buffer[1] == 0x00&&  buffer[2] == 0x01&&
-   buffer[3]>= 0x01&&  buffer[3]<  0xAF) {
- unsigned consumed;

- buffer += 3;
- num_bytes -= 3;
+   vl_vlc_init(&bs->vlc, 1, num_bytes, (void const * const 
*)&buffer,&num_bytes);

- vl_vlc_init(&bs->vlc, buffer, num_bytes);
-
- if (!decode_slice(bs))
+   while (vl_vlc_bits_left(&bs->vlc)>= 32) {
+  vl_vlc_fillbits(&bs->vlc);
+  if (vl_vlc_peekbits(&bs->vlc, 24) == 0x01) {
+ unsigned code;
+ vl_vlc_eatbits(&bs->vlc, 24);
+ code = vl_vlc_get_uimsbf(&bs->vlc, 8);
+ if (!code || code>  0xaf)
+continue;
+ if (!decode_slice(bs, code))
  return;
-
- consumed = num_bytes - vl_vlc_bits_left(&bs->vlc) / 8;
-
- /* crap, this is a bug we have consumed more bytes than left in the 
buffer */
- assert(consumed<= num_bytes);
-
- num_bytes -= consumed;
- buffer += consumed;
-
+ vl_vlc_bitalign(&bs->vlc);
} else {
- ++buffer;
- --num_bytes;
+ vl_vlc_eatbits(&bs->vlc, 8);
+ continue;
}
 }
  }
diff --git a/src/gallium/auxiliary/vl/vl_vlc.h 
b/src/gallium/auxiliary/vl/vl_vlc.h
index dc4faed..a4ded70 100644
--- a/src/gallium/auxiliary/vl/vl_vlc.h
+++ b/src/gallium/auxiliary/vl/vl_vlc.h
@@ -38,7 +38,7 @@
  struct vl_vlc
  {
 uint64_t buffer;
-   unsigned valid_bits;
+   uint32_t valid_bits;
 uint32_t *data;
 uint32_t *end;
  };
@@ -74,11 +74,9 @@ vl_vlc_init_table(struct vl_vlc_entry *dst, unsigned 
dst_size, const struct vl_v
  static INLINE void
  vl_vlc_fillbits(struct vl_vlc *vlc)
  {
-   if (vlc->valid_bits<  32) {
+   if (vlc->valid_bits<  32&&  vlc->data<  vlc->end) {
uint32_t value = *vlc->data;
The correct sollution would be to let fillbits return a boolean 
signaling that the buffer(s) are depleted.




-  //assert(vlc->data<= vlc->end);
-
  #ifndef PIPE_ARCH_BIG_ENDIAN
value = util_bswap32(value);
  #endif
@@ -90,10 +88,14 @@ vl_vlc_fillbits(struct vl_vlc *vlc)
  }

  static INLINE void
-vl_vlc_init(struct vl_vlc *vlc, const uint8_t *data, unsigned len)
+vl_vlc_init(struct vl_vlc *vlc,
+const unsigned array_size, unsigned total_len,
+const const void *const *datas, cons

Re: [Mesa-dev] Willing to take Haiku support Patches? (Was: DEATH to old drivers!)

2011-12-20 Thread Alexander von Gluck

On Mon, 19 Dec 2011 11:44:51 -0700, Brian Paul wrote:

On Mon, Dec 19, 2011 at 11:18 AM, Alexander von Gluck
 wrote:

Good afternoon!

The Haiku OS project (not-for-profit organization, founded in 2001) 
has

found ourselves in a weird spot, we have a working Mesa software
render library based on a *heavily* modified Mesa 7.4.4.

http://cgit.haiku-os.org/haiku/tree/src/libs/mesa

However as you can imagine, updating that is going to be a *big*
pain point.  As Haiku is looking to get some basic 3D rendering
going on it's cards, we need to do upgrade to a newer version of
Mesa.

If we produced well thought out Haiku OS support patches, would
Mesa as a project be interested in accepting them upstream? I think
a better direction may be to move away from the heavily custom
integrated mesa library and move to stock version.

These patches would likely start as run-of-the-mill #ifdef __HAIKU__
macros.


In general I'm happy to take patches for Haiku.  But I wouldn't want
to see #ifdef __HAIKU__ lines scattered all over the code.  
Hopefully,

that can be limited to header files as with other platforms.


My first work is here:
http://pub.haikufire.com/mesa/haiku-mesa-patch1.5.diff

This gets glsl, mapi/glapi, mesa, glu compiling with very few changes 
in

Mesa

At this point I don't think using DRI2 is do-able as it is very Linux
oriented, however I think we may be able to get things working 
(software at

least for now) by using our own external GLView within
http://cgit.haiku-os.org/haiku/tree/src/kits/opengl which simply links 
to

some key Mesa libraries.


 -- Alex

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


[Mesa-dev] [Bug 43879] (xorg-server 1.11.2-2, xf86-video-ati 6.14.3-1 or git, qt 4.7.4) black pixels instead of transparency from PNGs

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

Michel Dänzer  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||NOTOURBUG

--- Comment #5 from Michel Dänzer  2011-12-20 08:21:16 PST 
---
(In reply to comment #3)
> What the.. I can not reproduce the display bug any more after replacing
> catalyst with xf86-video-ati again.

According to glxinfo you're not using hardware acceleration anymore but the
llvmpipe software rasterizer. Though I was seeing the problem with that as
well.


Anyway, as described before, the problem basically looks like the game creates
the GLXPixmaps for the characters without an alpha channel, and then tries to
use them as textures with alpha blending. This can't work.

Feel free to reopen this report if the problem persists after the above issue
has been addressed in the game.

-- 
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 1/3] vl: Only initialize vlc once

2011-12-20 Thread Maarten Lankhorst
Hey Christian,

On 12/20/2011 02:16 PM, Christian König wrote:
> On 20.12.2011 12:43, Maarten Lankhorst wrote:
>> And add more sanity checks to stream. This shouldn't break things beyond 
>> those that aren't broken already.
>>
>> Signed-off-by: Maarten Lankhorst
>>
>> ---
>> And yes Andy, I mean that I haven't found a good video yet to fix the 
>> playback parts that are still broken..
> Why do you want to change that anyway?
>
> The search for start codes was especially split out of the VLC stuff, because 
> start codes start are byte aligned anyway and it doesn't make much sense to 
> search for them using the slower peekbits & fillbits functions.
Since 4 bytes are loaded at a time and bit aligning is fast enough, it's not 
that much slower, the reason I want this is to be able to add support for when 
the array size is > 1, currently and even with that patch its not handled, but 
if a slice is split between multiple buffers you can at least pick up where you 
left.. for example with mplayer I have observed that the start code 
0x00,0x00,0x01 and the actual value are in separate buffers for some codecs, 
and for wmv the following is said:

 * Some VC-1 advanced profile streams do not contain slice start codes; again,
 * the container format must indicate where picture data begins and ends. In
 * this case, pictures are assumed to be progressive and to contain a single
 * slice. It is highly recommended that applications detect this condition,
 * and add the missing start codes to the bitstream passed to VDPAU. However,
 * VDPAU implementations must allow bitstreams with missing start codes, and
 * act as if a 0x010D (frame) start code had been present.

Since mplayer can chop up the start code and the 0x0d, you'd need a parser to 
handle this.
I planned on using vlc to detect the lack of start code.

> Se below for some further comments.
>>   src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c |   56 
>> +++-
>>   src/gallium/auxiliary/vl/vl_vlc.h  |   33 +-
>>   2 files changed, 47 insertions(+), 42 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c 
>> b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
>> index 936cf2c..62d08d7 100644
>> --- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
>> +++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
>> @@ -787,7 +787,7 @@ entry:
>>   }
>>
>>   static INLINE bool
>> -decode_slice(struct vl_mpg12_bs *bs)
>> +decode_slice(struct vl_mpg12_bs *bs, unsigned code)
>>   {
>>  struct pipe_mpeg12_macroblock mb;
>>  short dct_blocks[64*6];
>> @@ -796,24 +796,29 @@ decode_slice(struct vl_mpg12_bs *bs)
>>
>>  memset(&mb, 0, sizeof(mb));
>>  mb.base.codec = PIPE_VIDEO_CODEC_MPEG12;
>> -   mb.y = vl_vlc_get_uimsbf(&bs->vlc, 8) - 1;
>> +   mb.y = code - 1;
>>  mb.blocks = dct_blocks;
>>
>>  reset_predictor(bs);
>> +   vl_vlc_fillbits(&bs->vlc);
>>  dct_scale = 
>> quant_scale[bs->desc.q_scale_type][vl_vlc_get_uimsbf(&bs->vlc, 5)];
>>
>> -   if (vl_vlc_get_uimsbf(&bs->vlc, 1))
>> +   if (vl_vlc_get_uimsbf(&bs->vlc, 1)) {
>> +  vl_vlc_fillbits(&bs->vlc);
>> while (vl_vlc_get_uimsbf(&bs->vlc, 9)&  1)
>>vl_vlc_fillbits(&bs->vlc);
>> +   }
>>
>>  vl_vlc_fillbits(&bs->vlc);
>> +   assert(vl_vlc_bits_left(&bs->vlc)>  23&&  vl_vlc_peekbits(&bs->vlc, 23));
>>  do {
>> int inc = 0;
>>
>> -  while (vl_vlc_peekbits(&bs->vlc, 11) == 15) {
>> - vl_vlc_eatbits(&bs->vlc, 11);
>> - vl_vlc_fillbits(&bs->vlc);
>> -  }
>> +  if (bs->decoder->profile == PIPE_VIDEO_PROFILE_MPEG1)
>> + while (vl_vlc_peekbits(&bs->vlc, 11) == 15) {
>> +vl_vlc_eatbits(&bs->vlc, 11);
>> +vl_vlc_fillbits(&bs->vlc);
>> + }
>>
>> while (vl_vlc_peekbits(&bs->vlc, 11) == 8) {
>>vl_vlc_eatbits(&bs->vlc, 11);
>> @@ -959,32 +964,23 @@ void
>>   vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const 
>> uint8_t *buffer)
>>   {
>>  assert(bs);
>> -   assert(buffer&&  num_bytes);
>> -
>> -   while(num_bytes>  2) {
>> -  if (buffer[0] == 0x00&&  buffer[1] == 0x00&&  buffer[2] == 0x01&&
>> -buffer[3]>= 0x01&&  buffer[3]<  0xAF) {
>> - unsigned consumed;
>>
>> - buffer += 3;
>> - num_bytes -= 3;
>> +   vl_vlc_init(&bs->vlc, 1, num_bytes, (void const * const 
>> *)&buffer,&num_bytes);
>>
>> - vl_vlc_init(&bs->vlc, buffer, num_bytes);
>> -
>> - if (!decode_slice(bs))
>> +   while (vl_vlc_bits_left(&bs->vlc)>= 32) {
>> +  vl_vlc_fillbits(&bs->vlc);
>> +  if (vl_vlc_peekbits(&bs->vlc, 24) == 0x01) {
>> + unsigned code;
>> + vl_vlc_eatbits(&bs->vlc, 24);
>> + code = vl_vlc_get_uimsbf(&bs->vlc, 8);
>> + if (!code || code>  0xaf)
>> +continue;
>> + if (!decode_slice(bs, code))
>>   return;
>> -
>> - consumed = num_bytes - vl_vlc_bits_left(&bs->vlc) / 8;
>> -
>> -

Re: [Mesa-dev] [PATCH 1/3] vl: Only initialize vlc once

2011-12-20 Thread Lucas Stach
Hi all!
Just jumping in with regard to the assert.

Am Dienstag, den 20.12.2011, 19:20 +0100 schrieb Maarten Lankhorst:
[snip]
> >
> >>
> >>  return vlc->buffer>>  (64 - num_bits);
> >>   }
> >> @@ -130,7 +132,7 @@ vl_vlc_peekbits(struct vl_vlc *vlc, unsigned num_bits)
> >>   static INLINE void
> >>   vl_vlc_eatbits(struct vl_vlc *vlc, unsigned num_bits)
> >>   {
> >> -   //assert(vlc->valid_bits>  num_bits);
> >> +   assert(vlc->valid_bits>= num_bits);
> > Just commenting in all checks isn't such a good idea, since that affect 
> > performance very badly, a define which enables all assertions at once at 
> > the beginning of the file seems the better idea.
> Sure.

Please don't define your own semantic for this checks. Assert is only
used in debug builds and there it shouldn't matter how it affects
performance. In release builds assert is typically a no-op and therefore
optimized away, but it could also be used to help the compiler optimize
for the asserted conditions.
Asserts should be never deactivated with code defines.

-- Lucas


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


[Mesa-dev] [PATCH 00/20] Implement GLX_ARB_create_context and friends

2011-12-20 Thread Ian Romanick
This giant series of patches implements GLX_ARB_create_context,
GLX_ARB_create_context_profile, and GLX_EXT_create_context_es2_profile.

One of the difficulties with this patch series is that I had to rework
some of the Gallium context creation plumbing.  In order for the xserver
to generate the correct GLX protocol errors, the driver has to
communicate back the reason context creation failed.  I *think* I got
everything, but I may have missed some bits.

In any case, this series with the xserver patches (to be sent out soon)
passes all of the GLX_ARB_create_context patches that I recently sent to
the piglit list.  GLX_ARB_create_context_profile (and obviously
GLX_EXT_create_context_es2_profile) are not yet implemented in the
xserver.  These aren't necessary for OpenGL 3.0, so I de-prioritized
this work.

This should be the last bit of new functionality necessary for OpenGL
3.0.  I'd like to get this reviewed and committed as soon as possible so
that we can advertise 3.0 and cut a Mesa 8.0 release branch.

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


[Mesa-dev] [PATCH 01/20] st-api: Clean-up OpenGL profile handling

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

There seems to have been two different ways to communicate the
profile.  There were flags and there were profiles.  I've opted to
remove the profile flags and use ST_PROFILE_DEFAULT (compatibility
profile) and ST_PROFILE_OPENGL_CORE (core profile) consistently
instead.

Also change the values of the ST_CONTEXT_FLAG_DEBUG and
ST_CONTEXT_FLAG_FORWARD_COMPATIBLE flags to match the WGL and GLX
values.

Signed-off-by: Ian Romanick 
---
 src/gallium/include/state_tracker/st_api.h   |   19 ++-
 src/gallium/state_trackers/glx/xlib/xm_api.c |   22 +-
 src/gallium/state_trackers/wgl/stw_context.c |   22 +-
 3 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h 
b/src/gallium/include/state_tracker/st_api.h
index f7cc243..3267cb2 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -57,10 +57,10 @@ enum st_api_type {
  */
 enum st_profile_type
 {
-   ST_PROFILE_DEFAULT,
-   ST_PROFILE_OPENGL_CORE,
-   ST_PROFILE_OPENGL_ES1,
-   ST_PROFILE_OPENGL_ES2
+   ST_PROFILE_DEFAULT, /**< OpenGL compatibility profile */
+   ST_PROFILE_OPENGL_CORE, /**< OpenGL 3.2+ core profile */
+   ST_PROFILE_OPENGL_ES1,  /**< OpenGL ES 1.x */
+   ST_PROFILE_OPENGL_ES2   /**< OpenGL ES 2.0 */
 };
 
 /* for profile_mask in st_api */
@@ -71,12 +71,13 @@ enum st_profile_type
 
 /**
  * New context flags for GL 3.0 and beyond.
+ *
+ * Profile information (core vs. compatibilty for OpenGL 3.2+) is communicated
+ * through the \c st_profile_type, not through flags.
  */
-#define ST_CONTEXT_FLAG_CORE_PROFILE(1 << 0)
-#define ST_CONTEXT_FLAG_COMPATIBLE_PROFILE  (1 << 1)
-#define ST_CONTEXT_FLAG_FORWARD_COMPATIBLE  (1 << 2)
-#define ST_CONTEXT_FLAG_DEBUG   (1 << 3)
-#define ST_CONTEXT_FLAG_ROBUST_ACCESS   (1 << 4)
+#define ST_CONTEXT_FLAG_DEBUG   (1 << 0)
+#define ST_CONTEXT_FLAG_FORWARD_COMPATIBLE  (1 << 1)
+#define ST_CONTEXT_FLAG_ROBUST_ACCESS   (1 << 2)
 
 /**
  * Used in st_context_iface->teximage.
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c 
b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 75e9e11..5d99e5f 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -878,7 +878,6 @@ XMesaContext XMesaCreateContext( XMesaVisual v, 
XMesaContext share_list,
c->xm_read_buffer = NULL;
 
memset(&attribs, 0, sizeof(attribs));
-   attribs.profile = ST_PROFILE_DEFAULT;
attribs.visual = v->stvis;
attribs.major = major;
attribs.minor = minor;
@@ -888,10 +887,23 @@ XMesaContext XMesaCreateContext( XMesaVisual v, 
XMesaContext share_list,
   attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
if (contextFlags & GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB)
   attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS;
-   if (profileMask & GLX_CONTEXT_CORE_PROFILE_BIT_ARB)
-  attribs.flags |= ST_CONTEXT_FLAG_CORE_PROFILE;
-   if (profileMask & GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
-  attribs.flags |= ST_CONTEXT_FLAG_COMPATIBLE_PROFILE;
+
+   /* There are no profiles before OpenGL 3.2.  The
+* GLX_ARB_create_context_profile spec says:
+*
+* "If the requested OpenGL version is less than 3.2,
+* GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality of the
+* context is determined solely by the requested version."
+*
+* The spec also says:
+*
+* "The default value for GLX_CONTEXT_PROFILE_MASK_ARB is
+* GLX_CONTEXT_CORE_PROFILE_BIT_ARB."
+*/
+   attribs.profile = ST_PROFILE_DEFAULT;
+   if ((major > 3 || (major == 3 && minor >= 2))
+   && ((profileMask & GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0))
+  attribs.profile = ST_PROFILE_OPENGL_CORE;
 
c->st = stapi->create_context(stapi, xmdpy->smapi,
  &attribs, (share_list) ? share_list->st : NULL);
diff --git a/src/gallium/state_trackers/wgl/stw_context.c 
b/src/gallium/state_trackers/wgl/stw_context.c
index 6cc8a83..2c4fb0e 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -169,7 +169,6 @@ stw_create_context_attribs(
ctx->iPixelFormat = iPixelFormat;
 
memset(&attribs, 0, sizeof(attribs));
-   attribs.profile = ST_PROFILE_DEFAULT;
attribs.visual = pfi->stvis;
attribs.major = majorVersion;
attribs.minor = minorVersion;
@@ -177,10 +176,23 @@ stw_create_context_attribs(
   attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
if (contextFlags & WGL_CONTEXT_DEBUG_BIT_ARB)
   attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
-   if (profileMask & WGL_CONTEXT_CORE_PROFILE_BIT_ARB)
-  attribs.flags |= ST_CONTEXT_FLAG_CORE_PROFILE;
-   if (profileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
-  attribs.flags |= ST_CONTEXT_FLAG_COMPATIBLE_PROFILE;
+
+   /* There are no profiles before O

[Mesa-dev] [PATCH 02/20] st-api: Have context_create explain why creation failed

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

This won't be used in the client-side libGL, but the xserver has to
generate a different protocol error depending on the reason context
creation failed.

Signed-off-by: Ian Romanick 
---
 src/gallium/include/state_tracker/st_api.h |   14 ++
 .../state_trackers/dri/common/dri_context.c|4 +++-
 src/gallium/state_trackers/vega/vg_manager.c   |   14 +++---
 src/mesa/state_tracker/st_manager.c|9 -
 4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h 
b/src/gallium/include/state_tracker/st_api.h
index 3267cb2..da49dc8 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -80,6 +80,19 @@ enum st_profile_type
 #define ST_CONTEXT_FLAG_ROBUST_ACCESS   (1 << 2)
 
 /**
+ * Reasons that context creation might fail.
+ */
+enum st_context_error {
+   ST_CONTEXT_SUCCESS = 0,
+   ST_CONTEXT_ERROR_NO_MEMORY,
+   ST_CONTEXT_ERROR_BAD_API,
+   ST_CONTEXT_ERROR_BAD_VERSION,
+   ST_CONTEXT_ERROR_BAD_FLAG,
+   ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE,
+   ST_CONTEXT_ERROR_UNKNOWN_FLAG
+};
+
+/**
  * Used in st_context_iface->teximage.
  */
 enum st_texture_type {
@@ -434,6 +447,7 @@ struct st_api
struct st_context_iface *(*create_context)(struct st_api *stapi,
   struct st_manager *smapi,
   const struct st_context_attribs 
*attribs,
+  enum st_context_error *error,
   struct st_context_iface 
*stsharei);
 
/**
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c 
b/src/gallium/state_trackers/dri/common/dri_context.c
index e9e0049..3e5a040 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -58,6 +58,7 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
struct dri_context *ctx = NULL;
struct st_context_iface *st_share = NULL;
struct st_context_attribs attribs;
+   enum st_context_error ctx_err = 0;
 
memset(&attribs, 0, sizeof(attribs));
switch (api) {
@@ -88,7 +89,8 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
   &screen->optionCache, sPriv->myNum, "dri");
 
dri_fill_st_visual(&attribs.visual, screen, visual);
-   ctx->st = stapi->create_context(stapi, &screen->base, &attribs, st_share);
+   ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
+  st_share);
if (ctx->st == NULL)
   goto fail;
ctx->st->st_manager_private = (void *) ctx;
diff --git a/src/gallium/state_trackers/vega/vg_manager.c 
b/src/gallium/state_trackers/vega/vg_manager.c
index dec1581..e88f5f1 100644
--- a/src/gallium/state_trackers/vega/vg_manager.c
+++ b/src/gallium/state_trackers/vega/vg_manager.c
@@ -163,28 +163,36 @@ vg_context_destroy(struct st_context_iface *stctxi)
 static struct st_context_iface *
 vg_api_create_context(struct st_api *stapi, struct st_manager *smapi,
   const struct st_context_attribs *attribs,
+  enum st_context_error *error,
   struct st_context_iface *shared_stctxi)
 {
struct vg_context *shared_ctx = (struct vg_context *) shared_stctxi;
struct vg_context *ctx;
struct pipe_context *pipe;
 
-   if (!(stapi->profile_mask & (1 << attribs->profile)))
+   if (!(stapi->profile_mask & (1 << attribs->profile))) {
+  *error = ST_CONTEXT_ERROR_BAD_API;
   return NULL;
+   }
 
/* only 1.0 is supported */
-   if (attribs->major > 1 || (attribs->major == 1 && attribs->minor > 0))
+   if (attribs->major > 1 || (attribs->major == 1 && attribs->minor > 0)) {
+  *error = ST_CONTEXT_ERROR_BAD_VERSION;
   return NULL;
+   }
 
/* for VGHandle / pointer lookups */
init_handles();
 
pipe = smapi->screen->context_create(smapi->screen, NULL);
-   if (!pipe)
+   if (!pipe) {
+  *error = ST_CONTEXT_ERROR_NO_MEMORY;
   return NULL;
+   }
ctx = vg_create_context(pipe, NULL, shared_ctx);
if (!ctx) {
   pipe->destroy(pipe);
+  *error = ST_CONTEXT_ERROR_NO_MEMORY;
   return NULL;
}
 
diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index 55699e7..828f0d8 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -600,6 +600,7 @@ st_context_destroy(struct st_context_iface *stctxi)
 static struct st_context_iface *
 st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
   const struct st_context_attribs *attribs,
+  enum st_context_error *error,
   struct st_context_iface *shared_stctxi)
 {
struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
@@ -623,17 +624,

[Mesa-dev] [PATCH 03/20] glx: Add __glX_send_client_info super function

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

This function picks the correct client-info protocol (based on the
server's GLX version and set of extensions) and sends it to the
server.

Signed-off-by: Ian Romanick 
---
 src/glx/Makefile |1 +
 src/glx/clientinfo.c |  156 ++
 src/glx/glxclient.h  |3 +
 3 files changed, 160 insertions(+), 0 deletions(-)
 create mode 100644 src/glx/clientinfo.c

diff --git a/src/glx/Makefile b/src/glx/Makefile
index 183ffb1..69d7c7c 100644
--- a/src/glx/Makefile
+++ b/src/glx/Makefile
@@ -10,6 +10,7 @@ EXTRA_DEFINES = $(EXTRA_DEFINES_XF86VIDMODE) -D_REENTRANT \
 
 SOURCES = \
  clientattrib.c \
+ clientinfo.c \
  compsize.c \
  eval.c \
  glxconfig.c \
diff --git a/src/glx/clientinfo.c b/src/glx/clientinfo.c
new file mode 100644
index 000..429e9a3
--- /dev/null
+++ b/src/glx/clientinfo.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+
+#include "glxclient.h"
+#include 
+#include 
+
+_X_HIDDEN void
+__glX_send_client_info(struct glx_display *glx_dpy)
+{
+   const unsigned ext_length = strlen("GLX_ARB_create_context");
+   const unsigned prof_length = strlen("_profile");
+   char *gl_extension_string;
+   int gl_extension_length;
+   xcb_connection_t *c;
+   Bool any_screen_has_ARB_create_context = False;
+   Bool any_screen_has_ARB_create_context_profile = False;
+   unsigned i;
+   static const uint32_t gl_versions[] = {
+  1, 4,
+   };
+   static const uint32_t gl_versions_profiles[] = {
+  1, 4, 0x,
+   };
+   static const char glx_extensions[] =
+  "GLX_ARB_create_context GLX_ARB_create_context_profile";
+
+   /* There are three possible flavors of the client info structure that the
+* client could send to the server.  The version sent depends on the
+* combination of GLX versions and extensions supported by the client and
+* the server.
+*
+* Server supports  Client sends
+* --
+* GLX version = 1.0Nothing.
+*
+* GLX version >= 1.1   struct GLXClientInfo
+*
+* GLX version >= 1.4 and
+* GLX_ARB_create_context   struct glXSetClientInfoARB
+*
+* GLX version >= 1.4 and
+* GLX_ARB_create_context_profile   struct glXSetClientInfo2ARB
+*
+* GLX_ARB_create_context and GLX_ARB_create_context_profile use FBConfigs,
+* and these only exist in GLX 1.4 or with GLX_SGIX_fbconfig.  I can't
+* imagine an implementation that supports GLX_SGIX_fbconfig and
+* GLX_ARB_create_context but not GLX 1.4.  Making GLX 1.4 a hard
+* requirement in this case does not seem like a limitation.
+*
+* This library currently only supports struct GLXClientInfo.
+*/
+
+   if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 0)
+  return;
+
+   /* Determine whether any screen on the server supports either of the
+* create-context extensions.
+*/
+   for (i = 0; i < ScreenCount(glx_dpy->dpy); i++) {
+  struct glx_screen *src = glx_dpy->screens[i];
+
+  const char *haystack = src->serverGLXexts;
+  while (haystack != NULL) {
+char *match = strstr(haystack, "GLX_ARB_create_context");
+
+if (match == NULL)
+   break;
+
+match += ext_length;
+
+switch (match[0]) {
+case '\0':
+case ' ':
+   any_screen_has_ARB_create_context = True;
+   break;
+
+case '_':
+   if (strncmp(match, "_profile", prof_length) == 0
+   && (match[prof_length] == '\0'
+   || match[prof_length] == ' ')) {
+  any_screen_has_ARB_create_context_profile = True;
+  match += prof_length;
+   }
+   b

[Mesa-dev] [PATCH 04/20] glx: Use __glX_send_client_info with XCB

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

__glX_send_client_info only supports XCB, so use that instead of
__glXClientInfo when USE_XCB is defined.

Signed-off-by: Ian Romanick 
---
 src/glx/glxext.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/glx/glxext.c b/src/glx/glxext.c
index baa2489..12fff22 100644
--- a/src/glx/glxext.c
+++ b/src/glx/glxext.c
@@ -887,7 +887,11 @@ __glXInitialize(Display * dpy)
   return NULL;
}
 
+#ifdef USE_XCB
+   __glX_send_client_info(dpyPriv);
+#else
__glXClientInfo(dpy, dpyPriv->majorOpcode);
+#endif
 
/* Grab the lock again and add the dispay private, unless somebody
 * beat us to initializing on this display in the meantime. */
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 05/20] dri2: Add createContextAttribs entry point for DRI2 version 3

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 include/GL/internal/dri_interface.h |   52 +-
 1 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 4f768f0..add03c7 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -781,11 +781,45 @@ struct __DRIdri2LoaderExtensionRec {
  * constructors for DRI2.
  */
 #define __DRI_DRI2 "DRI_DRI2"
-#define __DRI_DRI2_VERSION 2
+#define __DRI_DRI2_VERSION 3
 
-#define __DRI_API_OPENGL   0
+#define __DRI_API_OPENGL   0   /**< OpenGL compatibility profile */
 #define __DRI_API_GLES 1
 #define __DRI_API_GLES22
+#define __DRI_API_OPENGL_CORE  3   /**< OpenGL 3.2+ core profile */
+
+#define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
+#define __DRI_CTX_ATTRIB_MINOR_VERSION 1
+#define __DRI_CTX_ATTRIB_FLAGS 2
+
+#define __DRI_CTX_FLAG_DEBUG   0x0001
+#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE  0x0002
+
+/**
+ * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
+ */
+/*@{*/
+/** Success! */
+#define __DRI_CTX_ERROR_SUCCESS0
+
+/** Memory allocation failure */
+#define __DRI_CTX_ERROR_NO_MEMORY  1
+
+/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
+#define __DRI_CTX_ERROR_BAD_API2
+
+/** Client requested an API version that the driver can't do. */
+#define __DRI_CTX_ERROR_BAD_VERSION3
+
+/** Client requested a flag or combination of flags the driver can't do. */
+#define __DRI_CTX_ERROR_BAD_FLAG   4
+
+/** Client requested an attribute the driver doesn't understand. */
+#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE  5
+
+/** Client requested a flag the driver doesn't understand. */
+#define __DRI_CTX_ERROR_UNKNOWN_FLAG   6
+/*@}*/
 
 struct __DRIdri2ExtensionRec {
 __DRIextension base;
@@ -820,6 +854,20 @@ struct __DRIdri2ExtensionRec {
  int height);
void (*releaseBuffer)(__DRIscreen *screen,
 __DRIbuffer *buffer);
+
+   /**
+* Create a context for a particular API with a set of attributes
+*
+* \since version 3
+*/
+   __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
+int api,
+const __DRIconfig *config,
+__DRIcontext *shared,
+unsigned num_attribs,
+const uint32_t *attribs,
+unsigned *error,
+void *loaderPrivate);
 };
 
 
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 06/20] glx: Add glx_screen_vtable::create_context_attribs

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/glx/dri2_glx.c |3 ++-
 src/glx/dri_glx.c  |3 ++-
 src/glx/glxclient.h|8 
 src/glx/indirect_glx.c |3 ++-
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index a9bcebf..3c1212c 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -857,7 +857,8 @@ dri2BindExtensions(struct dri2_screen *psc, const 
__DRIextension **extensions)
 }
 
 static const struct glx_screen_vtable dri2_screen_vtable = {
-   dri2_create_context
+   dri2_create_context,
+   NULL
 };
 
 static struct glx_screen *
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index 3c14ef0..0cd7cca 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -836,7 +836,8 @@ driBindExtensions(struct dri_screen *psc, const 
__DRIextension **extensions)
 }
 
 static const struct glx_screen_vtable dri_screen_vtable = {
-   dri_create_context
+   dri_create_context,
+   NULL
 };
 
 static struct glx_screen *
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 0011d39..ecfd823 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -468,6 +468,14 @@ struct glx_screen_vtable {
 struct glx_config *config,
 struct glx_context *shareList,
 int renderType);
+
+   struct glx_context *(*create_context_attribs)(struct glx_screen *psc,
+struct glx_config *config,
+struct glx_context *shareList,
+unsigned num_attrib,
+const uint32_t *attribs,
+unsigned *error);
+
 };
 
 struct glx_screen
diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c
index 17689d4..b628688 100644
--- a/src/glx/indirect_glx.c
+++ b/src/glx/indirect_glx.c
@@ -437,7 +437,8 @@ indirect_create_context(struct glx_screen *psc,
 }
 
 struct glx_screen_vtable indirect_screen_vtable = {
-   indirect_create_context
+   indirect_create_context,
+   NULL
 };
 
 _X_HIDDEN struct glx_screen *
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 07/20] glx: Implement glx_screen_vtable::create_context_attribs for indirect contexts

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/glx/indirect_glx.c |   24 +++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c
index b628688..2399375 100644
--- a/src/glx/indirect_glx.c
+++ b/src/glx/indirect_glx.c
@@ -436,9 +436,31 @@ indirect_create_context(struct glx_screen *psc,
return gc;
 }
 
+static struct glx_context *
+indirect_create_context_attribs(struct glx_screen *base,
+   struct glx_config *config_base,
+   struct glx_context *shareList,
+   unsigned num_attribs,
+   const uint32_t *attribs,
+   unsigned *error)
+{
+   /* All of the attribute validation for indirect contexts is handled on the
+* server, so there's not much to do here.
+*/
+   (void) num_attribs;
+   (void) attribs;
+
+   /* The error parameter is only used on the server so that correct GLX
+* protocol errors can be generated.  On the client, it can be ignored.
+*/
+   (void) error;
+
+   return indirect_create_context(base, config_base, shareList, 0);
+}
+
 struct glx_screen_vtable indirect_screen_vtable = {
indirect_create_context,
-   NULL
+   indirect_create_context_attribs
 };
 
 _X_HIDDEN struct glx_screen *
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 08/20] glx/dri2: Implement glx_screen_vtable::create_context_attribs for DRI2 contexts

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

This also enables GLX_ARB_create_context and
GLX_ARB_create_context_profile if the driver supports DRI_DRI2 version
3 or greater.

Signed-off-by: Ian Romanick 
---
 src/glx/dri2_glx.c |   92 +++-
 1 files changed, 91 insertions(+), 1 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 3c1212c..54fea6f 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -217,6 +217,91 @@ dri2_create_context(struct glx_screen *base,
return &pcp->base;
 }
 
+static struct glx_context *
+dri2_create_context_attribs(struct glx_screen *base,
+   struct glx_config *config_base,
+   struct glx_context *shareList,
+   unsigned num_attribs,
+   const uint32_t *attribs,
+   unsigned *error)
+{
+   struct dri2_context *pcp = NULL;
+   struct dri2_context *pcp_shared = NULL;
+   struct dri2_screen *psc = (struct dri2_screen *) base;
+   __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
+   __DRIcontext *shared = NULL;
+
+   uint32_t minor_ver = 1;
+   uint32_t major_ver = 2;
+   uint32_t flags = 0;
+   unsigned api;
+   uint32_t ctx_attribs[2 * 4];
+   unsigned num_ctx_attribs = 0;
+
+   if (psc->dri2->base.version < 3) {
+  *error = __DRI_CTX_ERROR_NO_MEMORY;
+  goto error_exit;
+   }
+
+   /* Remap the GLX tokens to DRI2 tokens.
+*/
+   if (!dri2_convert_glx_attribs(num_attribs, attribs,
+&major_ver, &minor_ver, &flags, &api, error))
+  goto error_exit;
+
+   if (shareList) {
+  pcp_shared = (struct dri2_context *) shareList;
+  shared = pcp_shared->driContext;
+   }
+
+   pcp = Xmalloc(sizeof *pcp);
+   if (pcp == NULL) {
+  *error = __DRI_CTX_ERROR_NO_MEMORY;
+  goto error_exit;
+   }
+
+   memset(pcp, 0, sizeof *pcp);
+   if (!glx_context_init(&pcp->base, &psc->base, &config->base))
+  goto error_exit;
+
+   ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION;
+   ctx_attribs[num_ctx_attribs++] = major_ver;
+   ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MINOR_VERSION;
+   ctx_attribs[num_ctx_attribs++] = minor_ver;
+
+   if (flags != 0) {
+  ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS;
+
+  /* The current __DRI_CTX_FLAG_* values are identical to the
+   * GLX_CONTEXT_*_BIT values.
+   */
+  ctx_attribs[num_ctx_attribs++] = flags;
+   }
+
+   pcp->driContext =
+  (*psc->dri2->createContextAttribs) (psc->driScreen,
+ api,
+ config->driConfig,
+ shared,
+ num_ctx_attribs / 2,
+ ctx_attribs,
+ error,
+ pcp);
+
+   if (pcp->driContext == NULL)
+  goto error_exit;
+
+   pcp->base.vtable = &dri2_context_vtable;
+
+   return &pcp->base;
+
+error_exit:
+   if (pcp != NULL)
+  Xfree(pcp);
+
+   return NULL;
+}
+
 static void
 dri2DestroyDrawable(__GLXDRIdrawable *base)
 {
@@ -837,6 +922,11 @@ dri2BindExtensions(struct dri2_screen *psc, const 
__DRIextension **extensions)
/* FIXME: if DRI2 version supports it... */
__glXEnableDirectExtension(&psc->base, "INTEL_swap_event");
 
+   if (psc->dri2->base.version >= 3) {
+  __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
+  __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
+   }
+
for (i = 0; extensions[i]; i++) {
   if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
 psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
@@ -858,7 +948,7 @@ dri2BindExtensions(struct dri2_screen *psc, const 
__DRIextension **extensions)
 
 static const struct glx_screen_vtable dri2_screen_vtable = {
dri2_create_context,
-   NULL
+   dri2_create_context_attribs
 };
 
 static struct glx_screen *
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 09/20] glx: Initial implementation of glXCreateContextAttribsARB

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/glx/Makefile |1 +
 src/glx/create_context.c |  117 ++
 src/glx/glxclient.h  |2 +
 src/glx/glxcmds.c|2 +-
 4 files changed, 121 insertions(+), 1 deletions(-)
 create mode 100644 src/glx/create_context.c

diff --git a/src/glx/Makefile b/src/glx/Makefile
index 69d7c7c..67d03bc 100644
--- a/src/glx/Makefile
+++ b/src/glx/Makefile
@@ -12,6 +12,7 @@ SOURCES = \
  clientattrib.c \
  clientinfo.c \
  compsize.c \
+ create_context.c \
  eval.c \
  glxconfig.c \
  glxcmds.c \
diff --git a/src/glx/create_context.c b/src/glx/create_context.c
new file mode 100644
index 000..41f0805
--- /dev/null
+++ b/src/glx/create_context.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include "glxclient.h"
+#include "glx_error.h"
+#include 
+#include 
+
+#include 
+
+#if INT_MAX != 2147483647
+#error This code requires sizeof(uint32_t) == sizeof(int).
+#endif
+
+_X_HIDDEN GLXContext
+glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
+  GLXContext share_context, Bool direct,
+  const int *attrib_list)
+{
+   xcb_connection_t *const c = XGetXCBConnection(dpy);
+   struct glx_config *const cfg = (struct glx_config *) config;
+   struct glx_context *const share = (struct glx_context *) share_context;
+   struct glx_context *gc = NULL;
+   unsigned num_attribs = 0;
+   struct glx_screen *psc;
+   xcb_generic_error_t *err;
+   xcb_void_cookie_t cookie;
+   unsigned dummy_err = 0;
+
+
+   if (dpy == NULL || cfg == NULL)
+  return NULL;
+
+   /* This means that either the caller passed the wrong display pointer or
+* one of the internal GLX data structures (probably the fbconfig) has an
+* error.  There is nothing sensible to do, so return an error.
+*/
+   psc = GetGLXScreenConfigs(dpy, cfg->screen);
+   if (psc == NULL)
+  return NULL;
+
+   assert(cfg->screen == psc->scr);
+
+   /* Count the number of attributes specified by the application.  All
+* attributes appear in pairs, except the terminating None.
+*/
+   if (attrib_list != NULL) {
+  for (/* empty */; attrib_list[num_attribs * 2] != 0; num_attribs++)
+/* empty */ ;
+   }
+
+   if (direct && psc->vtable->create_context_attribs) {
+  /* GLX drops the error returned by the driver.  The expectation is that
+   * an error will also be returned by the server.  The server's error
+   * will be delivered to the application.
+   */
+  gc = psc->vtable->create_context_attribs(psc, cfg, share, num_attribs,
+  (const uint32_t *) attrib_list,
+  &dummy_err);
+   }
+
+   if (gc == NULL)
+  gc = indirect_create_context(psc, cfg, share, 0);
+
+   gc->xid = xcb_generate_id(c);
+   gc->share_xid = (share != NULL) ? share->xid : 0;
+
+   /* The manual pages for glXCreateContext and glXCreateNewContext say:
+*
+* "NULL is returned if execution fails on the client side."
+*
+* If the server generates an error, the application is supposed to catch
+* the protocol error and handle it.  Part of handling the error is freeing
+* the possibly non-NULL value returned by this function.
+*/
+   cookie =
+  xcb_glx_create_context_attribs_arb_checked(c,
+gc->xid,
+cfg->fbconfigID,
+cfg->screen,
+gc->share_xid,
+gc->isDirect,
+num_attribs,
+ 

[Mesa-dev] [PATCH 10/20] glx: Connect glXCreateContextAttribsARB to glXGetProcAddress

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/glx/glxcmds.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index f7cbf2f..37c0933 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -2603,6 +2603,9 @@ static const struct name_address_pair GLX_functions[] = {
GLX_FUNCTION(glXGetDriverConfig),
 #endif
 
+   /*** GLX_ARB_create_context and GLX_ARB_create_context_profile ***/
+   GLX_FUNCTION(glXCreateContextAttribsARB),
+
{NULL, NULL} /* end of list */
 };
 
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 11/20] glx: Add extension strings for GLX_ARB_create_context and GLX_ARB_create_context_profile

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Note that these extensions are not automatically enabled for screens
capable of direct-rendering.

Signed-off-by: Ian Romanick 
---
 src/glx/glxextensions.c |2 ++
 src/glx/glxextensions.h |4 +++-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
index 819fffc..df5ef5c 100644
--- a/src/glx/glxextensions.c
+++ b/src/glx/glxextensions.c
@@ -71,6 +71,8 @@ struct extension_info
 
 /* *INDENT-OFF* */
 static const struct extension_info known_glx_extensions[] = {
+   { GLX(ARB_create_context),  VER(0,0), Y, N, N, N },
+   { GLX(ARB_create_context_profile),  VER(0,0), Y, N, N, N },
{ GLX(ARB_get_proc_address),VER(1,4), Y, N, Y, N },
{ GLX(ARB_multisample), VER(1,4), Y, Y, N, N },
{ GLX(ATI_pixel_format_float),  VER(0,0), N, N, N, N },
diff --git a/src/glx/glxextensions.h b/src/glx/glxextensions.h
index fe0e12f..f432fdb 100644
--- a/src/glx/glxextensions.h
+++ b/src/glx/glxextensions.h
@@ -33,7 +33,9 @@
 
 enum
 {
-   ARB_get_proc_address_bit = 0,
+   ARB_create_context_bit = 0,
+   ARB_create_context_profile_bit,
+   ARB_get_proc_address_bit,
ARB_multisample_bit,
ATI_pixel_format_float_bit,
EXT_visual_info_bit,
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 12/20] dri_util: Mostly stub implementation of dri2CreateContextAttribs

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

This adds the function and modifies dri2CreateNewContextForAPI to call
it.  At this point only version 2 of the DRI2 API is advertised to the
loader.

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/dri/common/dri_util.c |   97 +++
 1 files changed, 84 insertions(+), 13 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 1640c14..7751167 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -134,35 +134,91 @@ static const __DRIextension 
**driGetExtensions(__DRIscreen *psp)
 /*@{*/
 
 static __DRIcontext *
-dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
-  const __DRIconfig *config,
-  __DRIcontext *shared, void *data)
+dri2CreateContextAttribs(__DRIscreen *screen, int api,
+const __DRIconfig *config,
+__DRIcontext *shared,
+unsigned num_attribs,
+const uint32_t *attribs,
+unsigned *error,
+void *data)
 {
 __DRIcontext *context;
 const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
 void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
 gl_api mesa_api;
+unsigned major_version = 1;
+unsigned minor_version = 0;
+uint32_t flags = 0;
+
+assert((num_attribs == 0) || (attribs != NULL));
 
-if (!(screen->api_mask & (1 << api)))
+if (!(screen->api_mask & (1 << api))) {
+   *error = __DRI_CTX_ERROR_BAD_API;
return NULL;
+}
 
 switch (api) {
 case __DRI_API_OPENGL:
-   mesa_api = API_OPENGL;
-   break;
+   mesa_api = API_OPENGL;
+   break;
 case __DRI_API_GLES:
-   mesa_api = API_OPENGLES;
-   break;
+   mesa_api = API_OPENGLES;
+   break;
 case __DRI_API_GLES2:
-   mesa_api = API_OPENGLES2;
-   break;
+   mesa_api = API_OPENGLES2;
+   break;
+case __DRI_API_OPENGL_CORE:
 default:
+   *error = __DRI_CTX_ERROR_BAD_API;
+   return NULL;
+}
+
+if (mesa_api != API_OPENGL && num_attribs != 0) {
+   *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+   assert(!"Should not get here.");
+   return NULL;
+}
+
+for (unsigned i = 0; i < num_attribs; i++) {
+   switch (attribs[i * 2]) {
+   case __DRI_CTX_ATTRIB_MAJOR_VERSION:
+   major_version = attribs[i * 2 + 1];
+   break;
+   case __DRI_CTX_ATTRIB_MINOR_VERSION:
+   minor_version = attribs[i * 2 + 1];
+   break;
+   case __DRI_CTX_ATTRIB_FLAGS:
+   flags = attribs[i * 2 + 1];
+   break;
+   default:
+   /* We can't create a context that satisfies the requirements of an
+* attribute that we don't understand.  Return failure.
+*/
+   return NULL;
+   }
+}
+
+/* There are no forward-compatible contexts before OpenGL 3.0.  The
+ * GLX_ARB_create_context spec says:
+ *
+ * "Forward-compatible contexts are defined only for OpenGL versions
+ * 3.0 and later."
+ *
+ * Moreover, Mesa can't fulfill the requirements of a forward-looking
+ * context.  Return failure if a forward-looking context is requested.
+ *
+ * In Mesa, a debug context is the same as a regular context.
+ */
+if (major_version >= 3) {
+   if ((flags & ~__DRI_CTX_FLAG_DEBUG) != 0)
return NULL;
 }
 
 context = malloc(sizeof *context);
-if (!context)
+if (!context) {
+   *error = __DRI_CTX_ERROR_NO_MEMORY;
return NULL;
+}
 
 context->loaderPrivate = data;
 
@@ -175,9 +231,20 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
 return NULL;
 }
 
+*error = __DRI_CTX_ERROR_SUCCESS;
 return context;
 }
 
+static __DRIcontext *
+dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
+  const __DRIconfig *config,
+  __DRIcontext *shared, void *data)
+{
+unsigned error;
+
+return dri2CreateContextAttribs(screen, api, config, shared, 0, NULL,
+   data, &error);
+}
 
 static __DRIcontext *
 dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
@@ -454,14 +521,18 @@ const __DRIcoreExtension driCoreExtension = {
 
 /** DRI2 interface */
 const __DRIdri2Extension driDRI2Extension = {
-{ __DRI_DRI2, __DRI_DRI2_VERSION },
+/* Force the version to 2 because the underlying drivers don't (can't!)
+ * support the extra requirements of CreateContextAttribs.
+ */
+{ __DRI_DRI2, 2 },
 dri2CreateNewScreen,
 dri2CreateNewDrawable,
 dri2CreateNewContext,
 dri2GetAPIMask,
 dri2CreateNewContextForAPI,
 dri2AllocateBuffer,
-dri2ReleaseBuffer
+dri2ReleaseBuffer,
+dri2Creat

[Mesa-dev] [PATCH 13/20] st/mesa: Reject forward-looking contexts

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/mesa/state_tracker/st_manager.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index 828f0d8..1cee312 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -647,9 +647,13 @@ st_api_create_context(struct st_api *stapi, struct 
st_manager *smapi,
if (attribs->major > 1 || attribs->minor > 0) {
   _mesa_compute_version(st->ctx);
 
-  /* is the actual version less than the requested version? */
+  /* Is the actual version less than the requested version?  Mesa can't
+   * yet enforce the added restrictions of a forward-looking context, so
+   * fail that too.
+   */
   if (st->ctx->VersionMajor * 10 + st->ctx->VersionMinor <
-  attribs->major * 10 + attribs->minor) {
+  attribs->major * 10 + attribs->minor
+ || (attribs->flags & ~ST_CONTEXT_FLAG_DEBUG) != 0) {
 *error = ST_CONTEXT_ERROR_BAD_VERSION;
  st_destroy_context(st);
  return NULL;
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 14/20] glx/dri: Add utility function dri2_convert_glx_attribs

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

This converts all of the GLX data from glXCreateContextAttribsARB to
the values expected by the DRI driver interfaces.

Signed-off-by: Ian Romanick 
---
 src/glx/dri_common.c |  102 ++
 src/glx/dri_common.h |6 +++
 2 files changed, 108 insertions(+), 0 deletions(-)

diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 1482b88..5d50aa9 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -419,4 +419,106 @@ driReleaseDrawables(struct glx_context *gc)
 
 }
 
+_X_HIDDEN bool
+dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
+unsigned *major_ver, unsigned *minor_ver,
+uint32_t *flags, unsigned *api, unsigned *error)
+{
+   unsigned i;
+   bool got_profile = false;
+   uint32_t profile;
+   int render_type = GLX_RGBA_TYPE;
+
+   if (num_attribs == 0)
+  return true;
+
+   /* This is actually an internal error, but what the heck.
+*/
+   if (attribs == NULL) {
+  *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+  return false;
+   }
+
+   *major_ver = 1;
+   *minor_ver = 0;
+
+   for (i = 0; i < num_attribs; i++) {
+  switch (attribs[i * 2]) {
+  case GLX_CONTEXT_MAJOR_VERSION_ARB:
+*major_ver = attribs[i * 2 + 1];
+break;
+  case GLX_CONTEXT_MINOR_VERSION_ARB:
+*minor_ver = attribs[i * 2 + 1];
+break;
+  case GLX_CONTEXT_FLAGS_ARB:
+*flags = attribs[i * 2 + 1];
+break;
+  case GLX_CONTEXT_PROFILE_MASK_ARB:
+profile = attribs[i * 2 + 1];
+got_profile = true;
+break;
+  case GLX_RENDER_TYPE:
+render_type = attribs[i * 2 + 1];
+break;
+  default:
+/* If an unknown attribute is received, fail.
+ */
+*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+return false;
+  }
+   }
+
+   *api = __DRI_API_OPENGL;
+   if (!got_profile) {
+  if (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2))
+*api = __DRI_API_OPENGL_CORE;
+   } else {
+  switch (profile) {
+  case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
+/* There are no profiles before OpenGL 3.2.  The
+ * GLX_ARB_create_context_profile spec says:
+ *
+ * "If the requested OpenGL version is less than 3.2,
+ * GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality
+ * of the context is determined solely by the requested version."
+ */
+*api = (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2))
+   ? __DRI_API_OPENGL_CORE : __DRI_API_OPENGL;
+break;
+  case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
+*api = __DRI_API_OPENGL;
+break;
+  default:
+*error = __DRI_CTX_ERROR_BAD_API;
+return false;
+  }
+   }
+
+   /* Unknown flag value.
+*/
+   if (*flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) {
+  *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+  return false;
+   }
+
+   /* There are no forward-compatible contexts before OpenGL 3.0.  The
+* GLX_ARB_create_context spec says:
+*
+* "Forward-compatible contexts are defined only for OpenGL versions
+* 3.0 and later."
+*/
+   if (*major_ver < 3 && (*flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
+  *error = __DRI_CTX_ERROR_BAD_FLAG;
+  return false;
+   }
+
+   if (*major_ver >= 3 && render_type == GLX_COLOR_INDEX_TYPE) {
+  *error = __DRI_CTX_ERROR_BAD_FLAG;
+  return false;
+   }
+
+   *error = __DRI_CTX_ERROR_SUCCESS;
+   return true;
+}
+
 #endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h
index 13b5ae4..3bcdebc 100644
--- a/src/glx/dri_common.h
+++ b/src/glx/dri_common.h
@@ -37,6 +37,7 @@
 #define _DRI_COMMON_H
 
 #include 
+#include 
 
 typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate;
 
@@ -66,4 +67,9 @@ extern void ErrorMessageF(const char *f, ...);
 
 extern void *driOpenDriver(const char *driverName);
 
+extern bool
+dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
+unsigned *major_ver, unsigned *minor_ver,
+uint32_t *flags, unsigned *api, unsigned *error);
+
 #endif /* _DRI_COMMON_H */
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 15/20] dri2: Add createContextAttribs entry point for DRISW version 3

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 include/GL/internal/dri_interface.h |   20 +++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index add03c7..b21445f 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -679,7 +679,7 @@ struct __DRIlegacyExtensionRec {
  * conjunction with the core extension.
  */
 #define __DRI_SWRAST "DRI_SWRast"
-#define __DRI_SWRAST_VERSION 2
+#define __DRI_SWRAST_VERSION 3
 
 struct __DRIswrastExtensionRec {
 __DRIextension base;
@@ -699,6 +699,22 @@ struct __DRIswrastExtensionRec {
const __DRIconfig *config,
__DRIcontext *shared,
void *data);
+
+   /**
+* Create a context for a particular API with a set of attributes
+*
+* \since version 3
+*
+* \sa __DRIdri2ExtensionRec::createContextAttribs
+*/
+   __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
+int api,
+const __DRIconfig *config,
+__DRIcontext *shared,
+unsigned num_attribs,
+const uint32_t *attribs,
+unsigned *error,
+void *loaderPrivate);
 };
 
 /**
@@ -859,6 +875,8 @@ struct __DRIdri2ExtensionRec {
 * Create a context for a particular API with a set of attributes
 *
 * \since version 3
+*
+* \sa __DRIswrastExtensionRec::createContextAttribs
 */
__DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
 int api,
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 16/20] glx/dri2: Implement glx_screen_vtable::create_context_attribs for DRISW contexts

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

This also enables GLX_ARB_create_context and
GLX_ARB_create_context_profile if the driver supports DRI_DRISW
version 3 or greater.

Signed-off-by: Ian Romanick 
---
 src/glx/drisw_glx.c |   89 ++-
 1 files changed, 88 insertions(+), 1 deletions(-)

diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index 204879e..cb7f79c 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -414,6 +414,87 @@ drisw_create_context(struct glx_screen *base,
return &pcp->base;
 }
 
+static struct glx_context *
+drisw_create_context_attribs(struct glx_screen *base,
+struct glx_config *config_base,
+struct glx_context *shareList,
+unsigned num_attribs,
+const uint32_t *attribs,
+unsigned *error)
+{
+   struct drisw_context *pcp, *pcp_shared;
+   __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
+   struct drisw_screen *psc = (struct drisw_screen *) base;
+   __DRIcontext *shared = NULL;
+
+   uint32_t minor_ver = 1;
+   uint32_t major_ver = 0;
+   uint32_t flags = 0;
+   unsigned api;
+   uint32_t ctx_attribs[2 * 4];
+   unsigned num_ctx_attribs = 0;
+
+   if (!psc->base.driScreen)
+  return NULL;
+
+   if (psc->swrast->base.version < 3)
+  return NULL;
+
+   /* Remap the GLX tokens to DRI2 tokens.
+*/
+   if (!dri2_convert_glx_attribs(num_attribs, attribs,
+&major_ver, &minor_ver, &flags, &api,
+error))
+  return NULL;
+
+   if (shareList) {
+  pcp_shared = (struct drisw_context *) shareList;
+  shared = pcp_shared->driContext;
+   }
+
+   pcp = Xmalloc(sizeof *pcp);
+   if (pcp == NULL)
+  return NULL;
+
+   memset(pcp, 0, sizeof *pcp);
+   if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
+  Xfree(pcp);
+  return NULL;
+   }
+
+   ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION;
+   ctx_attribs[num_ctx_attribs++] = major_ver;
+   ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MINOR_VERSION;
+   ctx_attribs[num_ctx_attribs++] = minor_ver;
+
+   if (flags != 0) {
+  ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS;
+
+  /* The current __DRI_CTX_FLAG_* values are identical to the
+   * GLX_CONTEXT_*_BIT values.
+   */
+  ctx_attribs[num_ctx_attribs++] = flags;
+   }
+
+   pcp->driContext =
+  (*psc->swrast->createContextAttribs) (psc->driScreen,
+   api,
+   config->driConfig,
+   shared,
+   num_ctx_attribs / 2,
+   ctx_attribs,
+   error,
+   pcp);
+   if (pcp->driContext == NULL) {
+  Xfree(pcp);
+  return NULL;
+   }
+
+   pcp->base.vtable = &drisw_context_vtable;
+
+   return &pcp->base;
+}
+
 static void
 driswDestroyDrawable(__GLXDRIdrawable * pdraw)
 {
@@ -503,7 +584,8 @@ driOpenSwrast(void)
 }
 
 static const struct glx_screen_vtable drisw_screen_vtable = {
-   drisw_create_context
+   drisw_create_context,
+   drisw_create_context_attribs
 };
 
 static void
@@ -513,6 +595,11 @@ driswBindExtensions(struct drisw_screen *psc, const 
__DRIextension **extensions)
 
__glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read");
 
+   if (psc->swrast->base.version >= 3) {
+  __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
+  __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
+   }
+
/* FIXME: Figure out what other extensions can be ported here from dri2. */
for (i = 0; extensions[i]; i++) {
   if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 17/20] dri2: Add plumbing to get context version requirements and flags to drivers

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

This adds support for DRI_DRI2 version 3 to all of the DRI2 drivers.

Signed-off-by: Ian Romanick 
---
 .../state_trackers/dri/common/dri_context.c|   51 -
 .../state_trackers/dri/common/dri_context.h|4 +
 src/mesa/drivers/dri/common/dri_util.c |   22 --
 src/mesa/drivers/dri/common/dri_util.h |4 +
 src/mesa/drivers/dri/common/drisw_util.c   |   74 ++--
 src/mesa/drivers/dri/intel/intel_screen.c  |   37 --
 src/mesa/drivers/dri/nouveau/nouveau_context.c |   24 ++-
 src/mesa/drivers/dri/nouveau/nouveau_context.h |3 +-
 src/mesa/drivers/dri/r200/r200_context.c   |   25 ++-
 src/mesa/drivers/dri/r200/r200_context.h   |4 +
 src/mesa/drivers/dri/radeon/radeon_context.c   |   26 +++-
 src/mesa/drivers/dri/radeon/radeon_context.h   |4 +
 src/mesa/drivers/dri/swrast/swrast.c   |   24 ++-
 13 files changed, 272 insertions(+), 30 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_context.c 
b/src/gallium/state_trackers/dri/common/dri_context.c
index 3e5a040..b47d8d9 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -50,7 +50,12 @@ dri_pp_query(struct dri_context *ctx)
 
 GLboolean
 dri_create_context(gl_api api, const struct gl_config * visual,
-  __DRIcontext * cPriv, void *sharedContextPrivate)
+  __DRIcontext * cPriv,
+  unsigned major_version,
+  unsigned minor_version,
+  uint32_t flags,
+  unsigned *error,
+  void *sharedContextPrivate)
 {
__DRIscreen *sPriv = cPriv->driScreenPriv;
struct dri_screen *screen = dri_screen(sPriv);
@@ -68,9 +73,20 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
case API_OPENGLES2:
   attribs.profile = ST_PROFILE_OPENGL_ES2;
   break;
-   default:
+   case API_OPENGL:
   attribs.profile = ST_PROFILE_DEFAULT;
+  attribs.major = major_version;
+  attribs.minor = minor_version;
+
+  if ((flags & __DRI_CTX_FLAG_DEBUG) != 0)
+attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
+
+  if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
+attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
   break;
+   default:
+  *error = __DRI_CTX_ERROR_BAD_API;
+  goto fail;
}
 
if (sharedContextPrivate) {
@@ -78,8 +94,10 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
}
 
ctx = CALLOC_STRUCT(dri_context);
-   if (ctx == NULL)
+   if (ctx == NULL) {
+  *error = __DRI_CTX_ERROR_NO_MEMORY;
   goto fail;
+   }
 
cPriv->driverPrivate = ctx;
ctx->cPriv = cPriv;
@@ -91,8 +109,32 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
dri_fill_st_visual(&attribs.visual, screen, visual);
ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
   st_share);
-   if (ctx->st == NULL)
+   if (ctx->st == NULL) {
+  switch (ctx_err) {
+  case ST_CONTEXT_SUCCESS:
+*error = __DRI_CTX_ERROR_SUCCESS;
+break;
+  case ST_CONTEXT_ERROR_NO_MEMORY:
+*error = __DRI_CTX_ERROR_NO_MEMORY;
+break;
+  case ST_CONTEXT_ERROR_BAD_API:
+*error = __DRI_CTX_ERROR_BAD_API;
+break;
+  case ST_CONTEXT_ERROR_BAD_VERSION:
+*error = __DRI_CTX_ERROR_BAD_VERSION;
+break;
+  case ST_CONTEXT_ERROR_BAD_FLAG:
+*error = __DRI_CTX_ERROR_BAD_FLAG;
+break;
+  case ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE:
+*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+break;
+  case ST_CONTEXT_ERROR_UNKNOWN_FLAG:
+*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+break;
+  }
   goto fail;
+   }
ctx->st->st_manager_private = (void *) ctx;
ctx->stapi = stapi;
 
@@ -101,6 +143,7 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
 
ctx->pp = pp_init(screen->base.screen, ctx->pp_enabled);
 
+   *error = __DRI_CTX_ERROR_SUCCESS;
return GL_TRUE;
 
  fail:
diff --git a/src/gallium/state_trackers/dri/common/dri_context.h 
b/src/gallium/state_trackers/dri/common/dri_context.h
index 5fc8119..484b756 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.h
+++ b/src/gallium/state_trackers/dri/common/dri_context.h
@@ -88,6 +88,10 @@ boolean
 dri_create_context(gl_api api,
   const struct gl_config * visual,
   __DRIcontext * driContextPriv,
+  unsigned major_version,
+  unsigned minor_version,
+  uint32_t flags,
+  unsigned *error,
   void *sharedContextPrivate);
 
 #endif
diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 7751167..948eb07 100644
--- a/src/mesa

[Mesa-dev] [PATCH 18/20] glx: Enable GLX_EXT_create_context_es2_profile

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

This extension is only enabled if the underlying driver advertises
support for OpenGL ES 2.0.  This happens either through the getAPIMask
function in version 2 of the DRI2 extension or implicity through
version 2 of the DRISW extension.

Since there is no OpenGL ES 2.0 protocol, this extension is marked as
only available with direct-rendering.

Signed-off-by: Ian Romanick 
---
 src/glx/dri2_glx.c  |6 ++
 src/glx/dri_common.c|   16 
 src/glx/drisw_glx.c |5 +
 src/glx/glxextensions.c |   11 +++
 src/glx/glxextensions.h |1 +
 5 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 54fea6f..51d45c9 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -923,8 +923,14 @@ dri2BindExtensions(struct dri2_screen *psc, const 
__DRIextension **extensions)
__glXEnableDirectExtension(&psc->base, "INTEL_swap_event");
 
if (psc->dri2->base.version >= 3) {
+  const unsigned mask = psc->dri2->getAPIMask(psc->driScreen);
+
   __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
   __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
+
+  if ((mask & (1 << __DRI_API_GLES2)) != 0)
+__glXEnableDirectExtension(&psc->base,
+   "GLX_EXT_create_context_es2_profile");
}
 
for (i = 0; extensions[i]; i++) {
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 5d50aa9..8feb587 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -488,6 +488,9 @@ dri2_convert_glx_attribs(unsigned num_attribs, const 
uint32_t *attribs,
   case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
 *api = __DRI_API_OPENGL;
 break;
+  case GLX_CONTEXT_ES2_PROFILE_BIT_EXT:
+*api = __DRI_API_GLES2;
+break;
   default:
 *error = __DRI_CTX_ERROR_BAD_API;
 return false;
@@ -517,6 +520,19 @@ dri2_convert_glx_attribs(unsigned num_attribs, const 
uint32_t *attribs,
   return false;
}
 
+   /* The GLX_EXT_create_context_es2_profile spec says:
+*
+* "... If the version requested is 2.0, and the
+* GLX_CONTEXT_ES2_PROFILE_BIT_EXT bit is set in the
+* GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the context
+* returned will implement OpenGL ES 2.0. This is the only way in which
+* an implementation may request an OpenGL ES 2.0 context."
+*/
+   if (*api == __DRI_API_GLES2 && (*major_ver != 2 || *minor_ver != 0)) {
+  *error = __DRI_CTX_ERROR_BAD_API;
+  return false;
+   }
+
*error = __DRI_CTX_ERROR_SUCCESS;
return true;
 }
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index cb7f79c..2d83a50 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -598,6 +598,11 @@ driswBindExtensions(struct drisw_screen *psc, const 
__DRIextension **extensions)
if (psc->swrast->base.version >= 3) {
   __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
   __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
+
+  /* DRISW version >= 2 implies support for OpenGL ES 2.0.
+   */
+  __glXEnableDirectExtension(&psc->base,
+"GLX_EXT_create_context_es2_profile");
}
 
/* FIXME: Figure out what other extensions can be ported here from dri2. */
diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
index df5ef5c..73b84dc 100644
--- a/src/glx/glxextensions.c
+++ b/src/glx/glxextensions.c
@@ -80,6 +80,7 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(EXT_visual_info), VER(0,0), Y, Y, N, N },
{ GLX(EXT_visual_rating),   VER(0,0), Y, Y, N, N },
{ GLX(EXT_framebuffer_sRGB),VER(0,0), Y, Y, N, N },
+   { GLX(EXT_create_context_es2_profile), VER(0,0), Y, N, N, Y },
{ GLX(MESA_copy_sub_buffer),VER(0,0), Y, N, N, N },
{ GLX(MESA_multithread_makecurrent),VER(0,0), Y, N, Y, N },
{ GLX(MESA_swap_control),   VER(0,0), Y, N, N, Y },
@@ -620,6 +621,16 @@ __glXCalculateUsableExtensions(struct glx_screen * psc,
   }
}
 
+   /* This hack is necessary because GLX_ARB_create_context_profile depends on
+* server support, but GLX_EXT_create_context_es2_profile is direct-only.
+* Without this hack, it would be possible to advertise
+* GLX_EXT_create_context_es2_profile without
+* GLX_ARB_create_context_profile.  That would be a problem.
+*/
+   if (!IS_SET(server_support, ARB_create_context_profile_bit)) {
+  CLR_BIT(usable, EXT_create_context_es2_profile_bit);
+   }
+
psc->effectiveGLXexts = __glXGetStringFromTable(known_glx_extensions,
usable);
 }
diff --git a/src/glx/glxextensions.h b/src/glx/glxextensions.h
index f432fdb..cad69a8 100644
--- a/src/glx/glxextensions.h
+++ b/src/glx/glxextensions.h
@@ -42,6 +42,7 @@ enum
EXT_visu

[Mesa-dev] [PATCH 19/20] glx: Don't use 'new' as a function parameter name

2011-12-20 Thread Ian Romanick
From: Ian Romanick 

Using 'new' as a function parameter name prevents including
glxclient.h the unit tests (future patch) that use the Google C++
Testing Framework.

Signed-off-by: Ian Romanick 
---
 src/glx/glxclient.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 13cd939..f8ae450 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -215,7 +215,7 @@ struct glx_context_vtable {
void (*destroy)(struct glx_context *ctx);
int (*bind)(struct glx_context *context, struct glx_context *old,
   GLXDrawable draw, GLXDrawable read);
-   void (*unbind)(struct glx_context *context, struct glx_context *new);
+   void (*unbind)(struct glx_context *context, struct glx_context *new_ctx);
void (*wait_gl)(struct glx_context *ctx);
void (*wait_x)(struct glx_context *ctx);
void (*use_x_font)(struct glx_context *ctx,
-- 
1.7.6.4

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


Re: [Mesa-dev] [PATCH 1/2] mesa: Set the correct ctx->NewState bitfield for rasterizer discard.

2011-12-20 Thread Paul Berry
On 19 December 2011 19:07, Marek Olšák  wrote:

> On Thu, Dec 15, 2011 at 7:21 PM, Paul Berry 
> wrote:
> > On 15 December 2011 08:02, Eric Anholt  wrote:
> >>
> >> On Thu, 15 Dec 2011 00:00:49 +0100, Marek Olšák 
> wrote:
> >> > On Wed, Dec 14, 2011 at 11:25 PM, Paul Berry  >
> >> > wrote:
> >> > > (c) Do nothing, and rely on programmers to remember that
> RasterDiscard
> >> > > is an
> >> > > exception to the usual correspondence between dirty bits and
> >> > > substructures
> >> > > of gl_context.
> >> > >
> >> > > I'm really not comfortable with (c) because of the risk of future
> >> > > bugs.  I
> >> > > suppose I could be talked into (b) if there's popular support for
> it,
> >> > > but
> >> > > it's not my favourite, because as I said earlier, I think there are
> >> > > actually
> >> > > a lot of good reasons to think of rasterizer discard as related to
> >> > > transform
> >> > > feedback.  My preference is to do (a).
> >> >
> >> > (d) Rework the _NEW_* flags such that they roughly match hardware
> >> > state groups, not OpenGL state groups. Direct3D 11 and Gallium are two
> >> > examples of how it could be done.
> >>
> >> The problem is that everyone disagrees on what "hardware state group" a
> >> piece of state is in.  On i965, rasterizer discard is really in the
> >> transform feedback state -- the SOL (transform feedback) unit on gen7,
> >> and the GS on gen6.
> >
> >
> > I have been thinking about this more this morning, and I have an idea for
> > how to accomplish (d) that I think would address this problem.  It's not
> a
> > trivial change, but it's something we could implement incrementally, so
> we
> > apply it to rasterizer discard now, and over time extend it to cover
> other
> > pieces of state.  Here's the idea:
> >
> > The key problem is that there are so many distinct pieces of state that
> we
> > could never possibly assign a separate bit to each one--we would run out
> of
> > space in the bitfield.  So instead of having core Mesa decide how they
> are
> > grouped (and, inevitably, wind up grouping them in a way that doesn't
> work
> > well for some drivers), let each driver decide how they are grouped.  The
> > drivers communicate this grouping to core Mesa by populating a new data
> > structure (at initialization time) called ctx->StateFlags.
> ctx->StateFlags
> > has an entry for each distinct piece of state, which tells which bits in
> > ctx->NewState should be set when that state changes.
> >
> > So, for example, in BeginTransformFeedback() and EndTransformFeedback(),
> > instead of doing this:
> >
> > FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
> >
> > We would do this:
> >
> > FLUSH_VERTICES(ctx, ctx->StateFlags->TransformFeedback_Active);
> >
> > In PauseTransformFeedback() and ResumeTransformFeedback() we would do:
> >
> > FLUSH_VERTICES(ctx, ctx->StateFlags->TransformFeedback_Paused);
> >
> > And in enable.c, when rasterizer discard is turned on or off, we would
> do:
> >
> > FLUSH_VERTICES(ctx, ctx->StateFlags->RasterizerDiscard);
> >
> > In the i965 driver, where all of these features map to the GS stage of
> the
> > pipeline, we would initialize TransformFeedback_Active,
> > TransformFeedback_Paused, and RasterizerDiscard all to the same value.
> In
> > the r600 driver, where rasterizer discard is implemented using face
> culling,
> > StateFlags->RasterizerDiscard would indicate a totally different bit than
> > those used for transform feedback.
> >
> > In the short term, we could implement this technique just for rasterizer
> > discard, to address the differences between r600 and i965 that we're
> > discussing in this email thread.  In the long term, our goal would be to
> > replace all of the _NEW_* constants with a fine-grained set of values in
> > StateFlags.  Once we've done that, each driver can set up StateFlags in a
> > way that precisely matches how state is grouped for that particular
> piece of
> > hardware.
> >
> > What do y'all think?  If there's support for this idea I'd be glad to
> make
> > an RFC patch.
>
> I like this idea very much. However, there is a catch that some _NEW
> flags are used for core Mesa, others are used for the vbo module,
> others are used for generating fixed function programs, others just
> notify about a change in constant buffers (e.g. the gl_* variables in
> GLSL) and so on, and finally, most are consumed by drivers to generate
> states. I am sure we can do this incrementally though and doing the
> easy stuff first.
>
> Marek
>

Oh wow, I knew that some of the _NEW flags were used in core mesa, but I
had no idea how many of them were affected until I did some grepping this
morning.  It looks like the only _NEW flags that *aren't* used by core
mesa, vbo, or some such are _NEW_POLYGONSTIPPLE and
_NEW_TRANSFORM_FEEDBACK.  And since ctx->NewState is only 32 bits wide and
has 31 bits assigned, this leaves us with almost zero wiggle room for
driver-specific state flags.

I just spent a bunch of time talking with Ian and Kenneth abou

Re: [Mesa-dev] [PATCH 00/20] Implement GLX_ARB_create_context and friends

2011-12-20 Thread Ian Romanick

On 12/20/2011 12:31 PM, Ian Romanick wrote:

This giant series of patches implements GLX_ARB_create_context,
GLX_ARB_create_context_profile, and GLX_EXT_create_context_es2_profile.

One of the difficulties with this patch series is that I had to rework
some of the Gallium context creation plumbing.  In order for the xserver
to generate the correct GLX protocol errors, the driver has to
communicate back the reason context creation failed.  I *think* I got
everything, but I may have missed some bits.

In any case, this series with the xserver patches (to be sent out soon)
passes all of the GLX_ARB_create_context patches that I recently sent to
the piglit list.  GLX_ARB_create_context_profile (and obviously
GLX_EXT_create_context_es2_profile) are not yet implemented in the
xserver.  These aren't necessary for OpenGL 3.0, so I de-prioritized
this work.

This should be the last bit of new functionality necessary for OpenGL
3.0.  I'd like to get this reviewed and committed as soon as possible so
that we can advertise 3.0 and cut a Mesa 8.0 release branch.


I should have also said that this series requires my previous 2 GLX 
fixes patches (posted yesterday).  The whole thing is available at:


  git://anongit.freedesktop.org/~idr/mesa GLX_ARB_create_context

As soon as patches 05/20 and 15/20 reviewed and committed, I will send 
the xserver patches out for review.  These are the patches that add the 
new entry-points in dri_interface.h for DRI2 and DRISW.

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


[Mesa-dev] [PATCH] glsl: Add additionnal type alias for convenience.

2011-12-20 Thread Vincent Lejeune
ivec2, ivec3, bvec2, bvec3 and bvec4 have now a "_type" suffixed alias
to identify them easily. These types are currently not widely used
inside glsl, however they are refered in UBO spec. It's an opportunity
to add them.
---
 src/glsl/builtin_types.h |5 +
 src/glsl/glsl_types.h|5 +
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h
index cc99b1b..65b62c3 100644
--- a/src/glsl/builtin_types.h
+++ b/src/glsl/builtin_types.h
@@ -63,7 +63,12 @@ const glsl_type glsl_type::builtin_core_types[] = {
 };
 
 const glsl_type *const glsl_type::bool_type  = & builtin_core_types[0];
+const glsl_type *const glsl_type::bvec2_type = & builtin_core_types[1];
+const glsl_type *const glsl_type::bvec3_type = & builtin_core_types[2];
+const glsl_type *const glsl_type::bvec4_type = & builtin_core_types[3];
 const glsl_type *const glsl_type::int_type   = & builtin_core_types[4];
+const glsl_type *const glsl_type::ivec2_type = & builtin_core_types[5];
+const glsl_type *const glsl_type::ivec3_type = & builtin_core_types[6];
 const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7];
 const glsl_type *const glsl_type::float_type = & builtin_core_types[8];
 const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9];
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 4ac9011..8518e9d 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -151,6 +151,8 @@ struct glsl_type {
static const glsl_type *const error_type;
static const glsl_type *const void_type;
static const glsl_type *const int_type;
+   static const glsl_type *const ivec2_type;
+   static const glsl_type *const ivec3_type;
static const glsl_type *const ivec4_type;
static const glsl_type *const uint_type;
static const glsl_type *const uvec2_type;
@@ -161,6 +163,9 @@ struct glsl_type {
static const glsl_type *const vec3_type;
static const glsl_type *const vec4_type;
static const glsl_type *const bool_type;
+   static const glsl_type *const bvec2_type;
+   static const glsl_type *const bvec3_type;
+   static const glsl_type *const bvec4_type;
static const glsl_type *const mat2_type;
static const glsl_type *const mat2x3_type;
static const glsl_type *const mat2x4_type;
-- 
1.7.7

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


Re: [Mesa-dev] [PATCH 01/20] st-api: Clean-up OpenGL profile handling

2011-12-20 Thread Brian Paul

On 12/20/2011 01:31 PM, Ian Romanick wrote:

From: Ian Romanick

There seems to have been two different ways to communicate the
profile.  There were flags and there were profiles.  I've opted to
remove the profile flags and use ST_PROFILE_DEFAULT (compatibility
profile) and ST_PROFILE_OPENGL_CORE (core profile) consistently
instead.

Also change the values of the ST_CONTEXT_FLAG_DEBUG and
ST_CONTEXT_FLAG_FORWARD_COMPATIBLE flags to match the WGL and GLX
values.

Signed-off-by: Ian Romanick
---
  src/gallium/include/state_tracker/st_api.h   |   19 ++-
  src/gallium/state_trackers/glx/xlib/xm_api.c |   22 +-
  src/gallium/state_trackers/wgl/stw_context.c |   22 +-
  3 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h 
b/src/gallium/include/state_tracker/st_api.h
index f7cc243..3267cb2 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -57,10 +57,10 @@ enum st_api_type {
   */
  enum st_profile_type
  {
-   ST_PROFILE_DEFAULT,
-   ST_PROFILE_OPENGL_CORE,
-   ST_PROFILE_OPENGL_ES1,
-   ST_PROFILE_OPENGL_ES2
+   ST_PROFILE_DEFAULT, /**<  OpenGL compatibility profile */
+   ST_PROFILE_OPENGL_CORE, /**<  OpenGL 3.2+ core profile */
+   ST_PROFILE_OPENGL_ES1,  /**<  OpenGL ES 1.x */
+   ST_PROFILE_OPENGL_ES2   /**<  OpenGL ES 2.0 */
  };

  /* for profile_mask in st_api */
@@ -71,12 +71,13 @@ enum st_profile_type

  /**
   * New context flags for GL 3.0 and beyond.
+ *
+ * Profile information (core vs. compatibilty for OpenGL 3.2+) is communicated
+ * through the \c st_profile_type, not through flags.
   */
-#define ST_CONTEXT_FLAG_CORE_PROFILE(1<<  0)
-#define ST_CONTEXT_FLAG_COMPATIBLE_PROFILE  (1<<  1)
-#define ST_CONTEXT_FLAG_FORWARD_COMPATIBLE  (1<<  2)
-#define ST_CONTEXT_FLAG_DEBUG   (1<<  3)
-#define ST_CONTEXT_FLAG_ROBUST_ACCESS   (1<<  4)
+#define ST_CONTEXT_FLAG_DEBUG   (1<<  0)
+#define ST_CONTEXT_FLAG_FORWARD_COMPATIBLE  (1<<  1)
+#define ST_CONTEXT_FLAG_ROBUST_ACCESS   (1<<  2)

  /**
   * Used in st_context_iface->teximage.
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c 
b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 75e9e11..5d99e5f 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -878,7 +878,6 @@ XMesaContext XMesaCreateContext( XMesaVisual v, 
XMesaContext share_list,
 c->xm_read_buffer = NULL;

 memset(&attribs, 0, sizeof(attribs));
-   attribs.profile = ST_PROFILE_DEFAULT;
 attribs.visual = v->stvis;
 attribs.major = major;
 attribs.minor = minor;
@@ -888,10 +887,23 @@ XMesaContext XMesaCreateContext( XMesaVisual v, 
XMesaContext share_list,
attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
 if (contextFlags&  GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB)
attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS;
-   if (profileMask&  GLX_CONTEXT_CORE_PROFILE_BIT_ARB)
-  attribs.flags |= ST_CONTEXT_FLAG_CORE_PROFILE;
-   if (profileMask&  GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
-  attribs.flags |= ST_CONTEXT_FLAG_COMPATIBLE_PROFILE;
+
+   /* There are no profiles before OpenGL 3.2.  The
+* GLX_ARB_create_context_profile spec says:
+*
+* "If the requested OpenGL version is less than 3.2,
+* GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality of the
+* context is determined solely by the requested version."
+*
+* The spec also says:
+*
+* "The default value for GLX_CONTEXT_PROFILE_MASK_ARB is
+* GLX_CONTEXT_CORE_PROFILE_BIT_ARB."
+*/
+   attribs.profile = ST_PROFILE_DEFAULT;
+   if ((major>  3 || (major == 3&&  minor>= 2))
+&&  ((profileMask&  GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0))
+  attribs.profile = ST_PROFILE_OPENGL_CORE;

 c->st = stapi->create_context(stapi, xmdpy->smapi,
   &attribs, (share_list) ? share_list->st : NULL);
diff --git a/src/gallium/state_trackers/wgl/stw_context.c 
b/src/gallium/state_trackers/wgl/stw_context.c
index 6cc8a83..2c4fb0e 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -169,7 +169,6 @@ stw_create_context_attribs(
 ctx->iPixelFormat = iPixelFormat;

 memset(&attribs, 0, sizeof(attribs));
-   attribs.profile = ST_PROFILE_DEFAULT;
 attribs.visual = pfi->stvis;
 attribs.major = majorVersion;
 attribs.minor = minorVersion;
@@ -177,10 +176,23 @@ stw_create_context_attribs(
attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
 if (contextFlags&  WGL_CONTEXT_DEBUG_BIT_ARB)
attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
-   if (profileMask&  WGL_CONTEXT_CORE_PROFILE_BIT_ARB)
-  attribs.flags |= ST_CONTEXT_FLAG_CORE_PROFILE;
-   if (profileMask&  WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
-  attribs.flags |= ST_CONTE

Re: [Mesa-dev] [PATCH 02/20] st-api: Have context_create explain why creation failed

2011-12-20 Thread Brian Paul

On 12/20/2011 01:31 PM, Ian Romanick wrote:

From: Ian Romanick

This won't be used in the client-side libGL, but the xserver has to
generate a different protocol error depending on the reason context
creation failed.

Signed-off-by: Ian Romanick
---
  src/gallium/include/state_tracker/st_api.h |   14 ++
  .../state_trackers/dri/common/dri_context.c|4 +++-
  src/gallium/state_trackers/vega/vg_manager.c   |   14 +++---
  src/mesa/state_tracker/st_manager.c|9 -
  4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h 
b/src/gallium/include/state_tracker/st_api.h
index 3267cb2..da49dc8 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -80,6 +80,19 @@ enum st_profile_type
  #define ST_CONTEXT_FLAG_ROBUST_ACCESS   (1<<  2)

  /**
+ * Reasons that context creation might fail.
+ */
+enum st_context_error {
+   ST_CONTEXT_SUCCESS = 0,
+   ST_CONTEXT_ERROR_NO_MEMORY,
+   ST_CONTEXT_ERROR_BAD_API,
+   ST_CONTEXT_ERROR_BAD_VERSION,
+   ST_CONTEXT_ERROR_BAD_FLAG,
+   ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE,
+   ST_CONTEXT_ERROR_UNKNOWN_FLAG
+};
+
+/**
   * Used in st_context_iface->teximage.
   */
  enum st_texture_type {
@@ -434,6 +447,7 @@ struct st_api
 struct st_context_iface *(*create_context)(struct st_api *stapi,
struct st_manager *smapi,
const struct st_context_attribs 
*attribs,
+  enum st_context_error *error,
struct st_context_iface 
*stsharei);

 /**
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c 
b/src/gallium/state_trackers/dri/common/dri_context.c
index e9e0049..3e5a040 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -58,6 +58,7 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
 struct dri_context *ctx = NULL;
 struct st_context_iface *st_share = NULL;
 struct st_context_attribs attribs;
+   enum st_context_error ctx_err = 0;

 memset(&attribs, 0, sizeof(attribs));
 switch (api) {
@@ -88,7 +89,8 @@ dri_create_context(gl_api api, const struct gl_config * 
visual,
&screen->optionCache, sPriv->myNum, "dri");

 dri_fill_st_visual(&attribs.visual, screen, visual);
-   ctx->st = stapi->create_context(stapi,&screen->base,&attribs, st_share);
+   ctx->st = stapi->create_context(stapi,&screen->base,&attribs,&ctx_err,
+  st_share);
 if (ctx->st == NULL)
goto fail;
 ctx->st->st_manager_private = (void *) ctx;
diff --git a/src/gallium/state_trackers/vega/vg_manager.c 
b/src/gallium/state_trackers/vega/vg_manager.c
index dec1581..e88f5f1 100644
--- a/src/gallium/state_trackers/vega/vg_manager.c
+++ b/src/gallium/state_trackers/vega/vg_manager.c
@@ -163,28 +163,36 @@ vg_context_destroy(struct st_context_iface *stctxi)
  static struct st_context_iface *
  vg_api_create_context(struct st_api *stapi, struct st_manager *smapi,
const struct st_context_attribs *attribs,
+  enum st_context_error *error,
struct st_context_iface *shared_stctxi)
  {
 struct vg_context *shared_ctx = (struct vg_context *) shared_stctxi;
 struct vg_context *ctx;
 struct pipe_context *pipe;

-   if (!(stapi->profile_mask&  (1<<  attribs->profile)))
+   if (!(stapi->profile_mask&  (1<<  attribs->profile))) {
+  *error = ST_CONTEXT_ERROR_BAD_API;
return NULL;
+   }

 /* only 1.0 is supported */
-   if (attribs->major>  1 || (attribs->major == 1&&  attribs->minor>  0))
+   if (attribs->major>  1 || (attribs->major == 1&&  attribs->minor>  0)) {
+  *error = ST_CONTEXT_ERROR_BAD_VERSION;
return NULL;
+   }

 /* for VGHandle / pointer lookups */
 init_handles();

 pipe = smapi->screen->context_create(smapi->screen, NULL);
-   if (!pipe)
+   if (!pipe) {
+  *error = ST_CONTEXT_ERROR_NO_MEMORY;
return NULL;
+   }
 ctx = vg_create_context(pipe, NULL, shared_ctx);
 if (!ctx) {
pipe->destroy(pipe);
+  *error = ST_CONTEXT_ERROR_NO_MEMORY;
return NULL;
 }

diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index 55699e7..828f0d8 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -600,6 +600,7 @@ st_context_destroy(struct st_context_iface *stctxi)
  static struct st_context_iface *
  st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
const struct st_context_attribs *attribs,
+  enum st_context_error *error,
struct st_context_iface *shared_stctxi)
  {
 struct st_co

[Mesa-dev] [PATCH 1/2] mesa: Move RasterDiscard to toplevel of gl_context.

2011-12-20 Thread Paul Berry
Previously we were storing the RasterDiscard flag (for
GL_RASTERIZER_DISCARD) in gl_context::TransformFeedback.  This was
confusing, because we use the _NEW_TRANSFORM flag (not
_NEW_TRANSFORM_FEEDBACK) to track state updates to it, and because
rasterizer discard has effects even when transform feedback is not in
use.

This patch makes RasterDiscard a toplevel element in gl_context rather
than a subfield of gl_context::TransformFeedback.

Note: We can't put RasterDiscard inside gl_context::Transform, since
all items inside gl_context::Transform need to be pieces of state that
are saved and restored using PushAttrib and PopAttrib.
---
 src/mesa/drivers/dri/i965/brw_gs.c  |2 +-
 src/mesa/main/accum.c   |2 +-
 src/mesa/main/clear.c   |   14 +++---
 src/mesa/main/drawpix.c |6 +++---
 src/mesa/main/enable.c  |6 +++---
 src/mesa/main/get.c |2 +-
 src/mesa/main/mtypes.h  |4 ++--
 src/mesa/state_tracker/st_atom_rasterizer.c |2 +-
 8 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index ee3f94c..2495ad5 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -210,7 +210,7 @@ static void populate_key( struct brw_context *brw,
   }
   /* On Gen6, GS is also used for rasterizer discard. */
   /* _NEW_TRANSFORM_FEEDBACK */
-  if (ctx->TransformFeedback.RasterDiscard) {
+  if (ctx->RasterDiscard) {
  key->need_gs_prog = true;
  key->rasterizer_discard = true;
   }
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index eb06bbb..a8c30c2 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -100,7 +100,7 @@ _mesa_Accum( GLenum op, GLfloat value )
   return;
}
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
   return;
 
if (ctx->RenderMode == GL_RENDER) {
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 2e27c95..bd5c012 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -200,7 +200,7 @@ _mesa_Clear( GLbitfield mask )
ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax)
   return;
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
   return;
 
if (ctx->RenderMode == GL_RENDER) {
@@ -338,7 +338,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
  drawbuffer);
  return;
   }
-  else if (!ctx->TransformFeedback.RasterDiscard) {
+  else if (!ctx->RasterDiscard) {
  /* Save current stencil clear value, set to 'value', do the
   * stencil clear and restore the clear value.
   * XXX in the future we may have a new ctx->Driver.ClearBuffer()
@@ -362,7 +362,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
 drawbuffer);
 return;
  }
- else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask && !ctx->RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -432,7 +432,7 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const 
GLuint *value)
 drawbuffer);
 return;
  }
- else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask && !ctx->RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -513,7 +513,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
  drawbuffer);
  return;
   }
-  else if (!ctx->TransformFeedback.RasterDiscard) {
+  else if (!ctx->RasterDiscard) {
  /* Save current depth clear value, set to 'value', do the
   * depth clear and restore the clear value.
   * XXX in the future we may have a new ctx->Driver.ClearBuffer()
@@ -538,7 +538,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
 drawbuffer);
 return;
  }
- else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask && !ctx->RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -615,7 +615,7 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
   return;
}
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
   return;
 
if (ctx->NewState) {
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index c9e714b..9f5b0b3 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -98,7 +98,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
   goto end;  /* the error code was recorded */
}
 
-   if (ctx->TransformFeedback.RasterDiscard) {
+ 

[Mesa-dev] [PATCH 2/2] mesa: Add _NEW_RASTERIZER_DISCARD as synonym for _NEW_TRANSFORM.

2011-12-20 Thread Paul Berry
This makes it easier to keep track of which dirty bits correspond to
which pieces of context, since it makes _NEW_RASTERIZER_DISCARD
correspond with ctx->RasterDiscard.
---
 src/mesa/drivers/dri/i965/brw_gs.c  |5 +++--
 src/mesa/main/enable.c  |2 +-
 src/mesa/main/mtypes.h  |6 ++
 src/mesa/state_tracker/st_atom_rasterizer.c |4 ++--
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index 2495ad5..886bf98 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -209,7 +209,7 @@ static void populate_key( struct brw_context *brw,
  }
   }
   /* On Gen6, GS is also used for rasterizer discard. */
-  /* _NEW_TRANSFORM_FEEDBACK */
+  /* _NEW_RASTERIZER_DISCARD */
   if (ctx->RasterDiscard) {
  key->need_gs_prog = true;
  key->rasterizer_discard = true;
@@ -258,7 +258,8 @@ const struct brw_tracked_state brw_gs_prog = {
.dirty = {
   .mesa  = (_NEW_LIGHT |
 _NEW_TRANSFORM |
-_NEW_TRANSFORM_FEEDBACK),
+_NEW_TRANSFORM_FEEDBACK |
+_NEW_RASTERIZER_DISCARD),
   .brw   = BRW_NEW_PRIMITIVE,
   .cache = CACHE_NEW_VS_PROG
},
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 749ae98..270b240 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -890,7 +890,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
   case GL_RASTERIZER_DISCARD:
 CHECK_EXTENSION(EXT_transform_feedback, cap);
  if (ctx->RasterDiscard != state) {
-FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+FLUSH_VERTICES(ctx, _NEW_RASTERIZER_DISCARD);
 ctx->RasterDiscard = state;
  }
  break;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ff97ea9..3d3b006 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3073,6 +3073,12 @@ struct gl_matrix_stack
 #define _NEW_FRAG_CLAMP(1 << 29)
 #define _NEW_TRANSFORM_FEEDBACK (1 << 30) /**< gl_context::TransformFeedback */
 #define _NEW_ALL ~0
+
+/**
+ * We use _NEW_TRANSFORM for GL_RASTERIZER_DISCARD.  This #define is for
+ * clarity.
+ */
+#define _NEW_RASTERIZER_DISCARD _NEW_TRANSFORM
 /*@}*/
 
 
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c 
b/src/mesa/state_tracker/st_atom_rasterizer.c
index 7ebc872..2d6ad45 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -258,7 +258,7 @@ static void update_raster_state( struct st_context *st )
raster->clamp_fragment_color = ctx->Color._ClampFragmentColor;
raster->gl_rasterization_rules = 1;
 
-   /* _NEW_TRANSFORM */
+   /* _NEW_RASTERIZER_DISCARD */
raster->rasterizer_discard = ctx->RasterDiscard;
 
cso_set_rasterizer(st->cso_context, raster);
@@ -276,7 +276,7 @@ const struct st_tracked_state st_update_rasterizer = {
_NEW_PROGRAM |
_NEW_SCISSOR |
_NEW_FRAG_CLAMP |
-   _NEW_TRANSFORM),  /* mesa state dependencies*/
+   _NEW_RASTERIZER_DISCARD),  /* mesa state dependencies*/
   ST_NEW_VERTEX_PROGRAM,  /* state tracker dependencies */
},
update_raster_state /* update function */
-- 
1.7.6.4

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


Re: [Mesa-dev] vertex array regression

2011-12-20 Thread Brian Paul

On 12/19/2011 01:12 PM, Mathias Fröhlich wrote:


Brian,

On Monday, December 19, 2011 17:01:07 you wrote:

I still don't get what the purpose of the special mapping of the last
four/five elements is all about.  Can you explain that?


As far as I can see the last ones should not map to anything.
The map is used only in fixed function mode. And there these arrays should not
show up as inputs to any fixed function shader. I think that the purpose of the
previous mapping was just to fill in anything. The changes I did serve exactly
this purpose.

But I agree that here should not be any mapping of these attributes in this
mode. Attached is a small change that is probably a more clean solution to
this mapping problem.

The change passes a quick r600g piglit test.


Yeah, I see how the incorrect varying_inputs values was causing
_NEW_ARRAY to get set, thus hiding the problem.  The solution looks
correct, but I'm a little worried about performance, as is mentioned
in the comment.

Marek, made that change back in March.  Maybe he can take a look at
this too.

I cannot comment on this, since I do not see a performance regression on my
use cases.
Marek?


I dug a bit deeper into this.  When the isosurface corruption is 
visible it's basically because the glVertex and glNormal values are 
transposed.


With glBegin/End we're sending interleaved (normal3f, vertex3f) 
values.  But with glDrawArrays we're sending interleaved (vertex3f, 
normal3f) values.  If we don't signal _NEW_ARRAY when switching from 
one method to the other, the state tracker is skipping array 
validation and we're drawing with normals and positions transposed.


The glBegin/End code is building vertex arrays but never directly sets 
_NEW_ARRAY as a side-effect.


I've implemented a solution to this that simply sets _NEW_ARRAY 
whenever we transition between glBegin/End and glDrawArrays drawing.


This fixes the isosurf bug and removes all occurances of NewState |= 
_NEW_ARRAY in the recalculate_input_bindings() function to avoid a 
performance regression.


I think this fixes the regression while preserving Marek's performance 
fix.


I'll post a patch.

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


[Mesa-dev] [PATCH] vbo: signal _NEW_ARRAY when transitioning between glBegin/End, glDrawArrays

2011-12-20 Thread Brian Paul
This fixes a regression seen with the isosurf demo when switching between
glBegin/End and glDrawArrays (do it several times).  The problem was the
driver wasn't getting _NEW_ARRAY when the arrays were subtly changed:
(vertex3f, normal3f) vs. (normal3f, vertex3f).

This patch fixes that by signaling _NEW_ARRAY whenever we transition
between glBegin/End and glDrawArrays mode.

The patch also fixes up the initialization of the map_vp_none[] array
to stop putting strange values in the last five elements of the array.
---
 src/mesa/vbo/vbo_context.c|   11 ---
 src/mesa/vbo/vbo_exec.h   |   33 +
 src/mesa/vbo/vbo_exec_api.c   |2 ++
 src/mesa/vbo/vbo_exec_array.c |4 
 4 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index b2e6bbc..d83f2fd 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -176,17 +176,14 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx )
{
   GLuint i;
 
-  /* When no vertex program, pull in the material attributes in
-   * the generic range.
-   */
-  for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) 
+  /* identity mapping */
+  for (i = 0; i < Elements(vbo->map_vp_none); i++) 
 vbo->map_vp_none[i] = i;
+  /* map material attribs to generic slots */
   for (i = 0; i < NR_MAT_ATTRIBS; i++) 
 vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)]
 = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
-  for (i = NR_MAT_ATTRIBS; i < VERT_ATTRIB_GENERIC_MAX; i++)
-vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] = i;
-  
+
   for (i = 0; i < Elements(vbo->map_vp_arb); i++)
 vbo->map_vp_arb[i] = i;
}
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index cfed8e8..339461d 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -78,12 +78,23 @@ struct vbo_exec_copied_vtx {
 };
 
 
+enum draw_method
+{
+   DRAW_NONE,
+   DRAW_BEGIN_END,
+   DRAW_ELEMENTS,
+   DRAW_ARRAYS
+};
+
+
 struct vbo_exec_context
 {
struct gl_context *ctx;   
GLvertexformat vtxfmt;
GLvertexformat vtxfmt_noop;
 
+   enum draw_method last_draw_method;
+
struct {
   struct gl_buffer_object *bufferobj;
 
@@ -164,6 +175,28 @@ void vbo_exec_array_destroy( struct vbo_exec_context *exec 
);
 void vbo_exec_vtx_init( struct vbo_exec_context *exec );
 void vbo_exec_vtx_destroy( struct vbo_exec_context *exec );
 
+
+/**
+ * This is called by glBegin, glDrawArrays and glDrawElements (and
+ * variations of those calls).  When we transition from immediate mode
+ * drawing to array drawing we need to invalidate the array state.
+ *
+ * glBegin/End builds vertex arrays.  Those arrays may look identical
+ * to glDrawArrays arrays except that the position of the elements may
+ * be different.  For example, arrays of (position3v, normal3f) vs. arrays
+ * of (normal3f, position3f).  So we need to make sure we notify drivers
+ * that arrays may be changing.
+ */
+static inline void
+vbo_draw_method(struct vbo_exec_context *exec, enum draw_method method)
+{
+   if (exec->last_draw_method != method) {
+  exec->ctx->NewState |= _NEW_ARRAY;
+  exec->last_draw_method = method;
+   }
+}
+
+
 #if FEATURE_beginend
 
 void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap );
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 4be0169..cb5f9ae 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -701,6 +701,8 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
  return;
   }
 
+  vbo_draw_method(exec, DRAW_BEGIN_END);
+
   if (ctx->Driver.PrepareExecBegin)
 ctx->Driver.PrepareExecBegin(ctx);
 
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index a6e41e9..e84c0f3 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -558,6 +558,8 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint 
start,
 
vbo_bind_arrays(ctx);
 
+   vbo_draw_method(exec, DRAW_ARRAYS);
+
/* Again... because we may have changed the bitmask of per-vertex varying
 * attributes.  If we regenerate the fixed-function vertex program now
 * we may be able to prune down the number of vertex attributes which we
@@ -773,6 +775,8 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, 
GLenum mode,
 
vbo_bind_arrays( ctx );
 
+   vbo_draw_method(exec, DRAW_ELEMENTS);
+
/* check for dirty state again */
if (ctx->NewState)
   _mesa_update_state( ctx );
-- 
1.7.3.4

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


Re: [Mesa-dev] [PATCH 1/2] mesa: Move RasterDiscard to toplevel of gl_context.

2011-12-20 Thread Brian Paul

On 12/20/2011 05:41 PM, Paul Berry wrote:

Previously we were storing the RasterDiscard flag (for
GL_RASTERIZER_DISCARD) in gl_context::TransformFeedback.  This was
confusing, because we use the _NEW_TRANSFORM flag (not
_NEW_TRANSFORM_FEEDBACK) to track state updates to it, and because
rasterizer discard has effects even when transform feedback is not in
use.

This patch makes RasterDiscard a toplevel element in gl_context rather
than a subfield of gl_context::TransformFeedback.

Note: We can't put RasterDiscard inside gl_context::Transform, since
all items inside gl_context::Transform need to be pieces of state that
are saved and restored using PushAttrib and PopAttrib.


I don't have a strong opinion about where this state is put.  But with 
respect to glPush/PopAttrib() you could simply ignore the 
RasterDiscard state in the glPopAttrib() code.  There's probably other 
pieces of state that live in a gl_foo_attrib structure that isn't 
pushed/popped.


-Brian



---
  src/mesa/drivers/dri/i965/brw_gs.c  |2 +-
  src/mesa/main/accum.c   |2 +-
  src/mesa/main/clear.c   |   14 +++---
  src/mesa/main/drawpix.c |6 +++---
  src/mesa/main/enable.c  |6 +++---
  src/mesa/main/get.c |2 +-
  src/mesa/main/mtypes.h  |4 ++--
  src/mesa/state_tracker/st_atom_rasterizer.c |2 +-
  8 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index ee3f94c..2495ad5 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -210,7 +210,7 @@ static void populate_key( struct brw_context *brw,
}
/* On Gen6, GS is also used for rasterizer discard. */
/* _NEW_TRANSFORM_FEEDBACK */
-  if (ctx->TransformFeedback.RasterDiscard) {
+  if (ctx->RasterDiscard) {
   key->need_gs_prog = true;
   key->rasterizer_discard = true;
}
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index eb06bbb..a8c30c2 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -100,7 +100,7 @@ _mesa_Accum( GLenum op, GLfloat value )
return;
 }

-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
return;

 if (ctx->RenderMode == GL_RENDER) {
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 2e27c95..bd5c012 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -200,7 +200,7 @@ _mesa_Clear( GLbitfield mask )
 ctx->DrawBuffer->_Ymin>= ctx->DrawBuffer->_Ymax)
return;

-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
return;

 if (ctx->RenderMode == GL_RENDER) {
@@ -338,7 +338,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
   drawbuffer);
   return;
}
-  else if (!ctx->TransformFeedback.RasterDiscard) {
+  else if (!ctx->RasterDiscard) {
   /* Save current stencil clear value, set to 'value', do the
* stencil clear and restore the clear value.
* XXX in the future we may have a new ctx->Driver.ClearBuffer()
@@ -362,7 +362,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
  drawbuffer);
  return;
   }
- else if (mask&&  !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask&&  !ctx->RasterDiscard) {
  union gl_color_union clearSave;

  /* save color */
@@ -432,7 +432,7 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const 
GLuint *value)
  drawbuffer);
  return;
   }
- else if (mask&&  !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask&&  !ctx->RasterDiscard) {
  union gl_color_union clearSave;

  /* save color */
@@ -513,7 +513,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
   drawbuffer);
   return;
}
-  else if (!ctx->TransformFeedback.RasterDiscard) {
+  else if (!ctx->RasterDiscard) {
   /* Save current depth clear value, set to 'value', do the
* depth clear and restore the clear value.
* XXX in the future we may have a new ctx->Driver.ClearBuffer()
@@ -538,7 +538,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
  drawbuffer);
  return;
   }
- else if (mask&&  !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask&&  !ctx->RasterDiscard) {
  union gl_color_union clearSave;

  /* save color */
@@ -615,7 +615,7 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
return;
 }

-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->Raste

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

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

--- Comment #6 from Ryan C. Gordon  2011-12-20 19:25:49 
PST ---

Brian is correct, this is my bug in MojoShader; that code is goofy, and I'll
fix it soon (and push out an updated Super Meat Boy).

My apologies for this generating traffic on your bug tracker.

--ryan.

-- 
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 2/2] mesa: Add _NEW_RASTERIZER_DISCARD as synonym for _NEW_TRANSFORM.

2011-12-20 Thread Kenneth Graunke
On 12/20/2011 04:41 PM, Paul Berry wrote:
> This makes it easier to keep track of which dirty bits correspond to
> which pieces of context, since it makes _NEW_RASTERIZER_DISCARD
> correspond with ctx->RasterDiscard.
> ---
>  src/mesa/drivers/dri/i965/brw_gs.c  |5 +++--
>  src/mesa/main/enable.c  |2 +-
>  src/mesa/main/mtypes.h  |6 ++
>  src/mesa/state_tracker/st_atom_rasterizer.c |4 ++--
>  4 files changed, 12 insertions(+), 5 deletions(-)

This looks good to me.  I found this in the GL 3.0 spec (page 130 in the
PDF) today: "RASTERIZER_DISCARD also affects the DrawPixels, CopyPixels,
Bitmap, Clear, and Accum commands."

This tells me that it's not transform feedback specific, so I think it
shouldn't be in the gl_context::TransformFeedback struct.  Yet, there's
no better struct to put it in.  So, a lone field in gl_context, like
you've done here.

For both patches:
Reviewed-by: Kenneth Graunke 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Don't use BRW_DEPTHFORMAT_D24_UNORM_X8_UINT on Gen4.

2011-12-20 Thread Kenneth Graunke
X8 depth formats weren't supported until Ironlake (Gen 5).

Fixes GPU hangs introduced in d84a180417d1eabd680554970f1eaaa93abcd41e.
One example test case was "fbo-missing-attachment-blit from".

Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/dri/i965/brw_misc_state.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

I tested this by comparing full piglit runs on GM45 between d84a180417d~1
and d84a180417d with this patch applied on top of it.  No changes, no hangs.

diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c 
b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 8a6ee70..21885a6 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -218,7 +218,9 @@ brw_depthbuffer_format(struct brw_context *brw)
case MESA_FORMAT_Z32_FLOAT:
   return BRW_DEPTHFORMAT_D32_FLOAT;
case MESA_FORMAT_X8_Z24:
-  return BRW_DEPTHFORMAT_D24_UNORM_X8_UINT;
+  if (intel->gen >= 5)
+return BRW_DEPTHFORMAT_D24_UNORM_X8_UINT;
+  /* Gen4 doesn't support X8; use S8 instead. */
case MESA_FORMAT_S8_Z24:
   return BRW_DEPTHFORMAT_D24_UNORM_S8_UINT;
default:
-- 
1.7.7.3

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