[Mesa-dev] [BUG] gallium-gbm-target requires drm-pipe-loader

2012-06-11 Thread David Herrmann
Hi

The recently added gbm gallium target
(./src/gallium/targets/gbm/gbm.c) requires HAVE_DRM_PIPE_LOADER for
pipe_loader_drm_probe(). Otherwise, the compiler fails with an
unresolved function-name.

However, HAVE_DRM_PIPE_LOADER is not defined when compiling i915 only,
so I need to compile gallium-nouveau, too, to get this symbol (or some
other driver that pulls in HAVE_DRM_PIPE_LOADER). It's
gallium_require_drm_loader() in configure.ac which defines this symbol
and I actually have no idea how to fix this bug but include this in
the xi915) case directly below the function definition.

Maybe you know a better fix.

Reproducable with current git and:
./autogen.sh --prefix=/usr --with-dri-driverdir=/usr/lib/xorg/modules/dri \
--with-dri-drivers=i915 \
--with-gallium-drivers=svga,swrast \
--with-egl-platforms=drm,x11,wayland \
--enable-gallium-llvm \
--enable-gallium-egl \
--enable-shared-dricore \
--enable-shared-glapi \
--enable-egl \
--enable-gles1 \
--enable-gles2 \
--enable-openvg \
--enable-glx-tls \
--enable-xcb \
--enable-texture-float

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


[Mesa-dev] [PATCH 00/21] ARB_sampler_object fixes and minor clean up

2012-06-11 Thread Pauli Nieminen
I noticed following issues when I was reading texture management code in
mesa core.

The first ycbcr unpack patch might be actually fixing deadcode. But I
don't know yet enough about unpack code to know for sure. But at least
glGetTexImage has special case get_tex_ycbcr.

I also noticed size check for indices omitting the offset paramater bassed
to glDrawElements call.

Following TexImage changes aim to make driver interfaces easier to
understand by removing duplicate information. For me that makes a lot more
clearer what is expected to happen inside driver hook.

Most of changes are fixes issues were sampler state is read from
texture object while bound sampler object should be shadowing the texture
state. Those changes changes mesa code to use _mesa_get_samplerobj to
select sampler state.

Also I changes meta code to use sampler state to avoid possible issues that
we would have sampler object shadowing texture state when running meta
code. For that I needed to make ARB_sampler_object mandator extension for
all mesa drivers.

I didn't check bugzilla if there is any bugs reported about sampler objects
that could be fixed with these patches.

I run regression test for i965 (ILK), llvm pipe and r200. Nouveau changes
would still need testing and check from Nouveau developers to verify that
sampler state gets uploaded when when a new sampler object is bound. Piglit
ARB_sampler_object test should be enough to verify that.


Pauli Nieminen (21):
  mesa/format_unpack: Fix YCBCR unpack
  mesa: Check index buffer offset in DrawElements
  mesa: Remove unnecessary parameters from TexImage
  mesa: Remove unnecessary parameters from AllocTextureImageBuffer
  mesa: Remove unnecessary parameters CompressedTexImage
  mesa: Move DepthMode to texture object
  mesa/macros: Add ARRAY_SIZE helper macro core mesa
  mesa/samplerobj: Support EXT_texture_sRGB_decode
  mesa/samplerobj: Avoid crash in sampler query if texture unit is
disabled
  nouveau: Add support for ARB_sampler_object
  radeon: Fix printf format not to warn in 64bit
  radeonr200: Add support for ARB_shader_object
  mesa/ff_shader: Fix sampler state reading
  mesa/program: Use sampler object state if present
  mesa: Make ARB_sampler_objects mandator
  swrast: Support sampler object for texture fetching state
  mesa/samplerobj: Allow meta module to call sampler functions
  meta: Use sampler object for mipmap generation
  meta: texture rectangle textures may not have mipmaps
  meta: Add sampler object to texture decompression
  meta: Use sampler object in framebuffer blit

 src/mesa/drivers/common/meta.c|  134 ++--
 src/mesa/drivers/dri/i915/i915_texstate.c |2 +-
 src/mesa/drivers/dri/i965/brw_wm.c|2 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  |2 +-
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |2 +-
 src/mesa/drivers/dri/intel/intel_context.h|3 +-
 src/mesa/drivers/dri/intel/intel_extensions.c |1 -
 src/mesa/drivers/dri/intel/intel_tex.c|   10 +-
 src/mesa/drivers/dri/intel/intel_tex_image.c  |   23 +-
 src/mesa/drivers/dri/nouveau/nouveau_texture.c|   23 +-
 src/mesa/drivers/dri/nouveau/nv04_state_tex.c |   22 +-
 src/mesa/drivers/dri/nouveau/nv10_state_tex.c |   23 +-
 src/mesa/drivers/dri/nouveau/nv20_state_tex.c |   25 +-
 src/mesa/drivers/dri/r200/r200_tex.c  |   41 +-
 src/mesa/drivers/dri/r200/r200_tex.h  |1 +
 src/mesa/drivers/dri/r200/r200_texstate.c |3 +-
 src/mesa/drivers/dri/radeon/radeon_blit.c |4 +-
 src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c  |   16 +-
 src/mesa/drivers/dri/radeon/radeon_screen.c   |2 -
 src/mesa/drivers/dri/radeon/radeon_span.c |4 +-
 src/mesa/drivers/dri/radeon/radeon_tex.c  |   27 +-
 src/mesa/drivers/dri/radeon/radeon_tex.h  |1 +
 src/mesa/drivers/dri/radeon/radeon_tex_copy.c |2 +-
 src/mesa/drivers/dri/radeon/radeon_texstate.c |4 +-
 src/mesa/drivers/dri/radeon/radeon_texture.c  |   38 +-
 src/mesa/drivers/dri/radeon/radeon_texture.h  |4 +-
 src/mesa/main/api_validate.c  |3 +-
 src/mesa/main/attrib.c|2 +-
 src/mesa/main/dd.h|9 +-
 src/mesa/main/extensions.c|2 +-
 src/mesa/main/ff_fragment_shader.cpp  |5 +-
 src/mesa/main/format_unpack.c |  102 +--
 src/mesa/main/get.c   |7 +-
 src/mesa/main/macros.h|3 +
 src/mesa/main/mipmap.c|3 +-
 src/mesa/main/mtypes.h|7 +-
 src/mesa/main/samplerobj.c|   66 +-
 src/mesa/main/samplerobj.h|   15 +-
 src/mesa/main/teximage.c  |   13 +-
 src/mesa/main/texobj.c|7 

[Mesa-dev] [PATCH 01/21] mesa/format_unpack: Fix YCBCR unpack

2012-06-11 Thread Pauli Nieminen
The YCBCR unpack was reading one RGBA value from 4 bytes of YCBCR
texture. But single pixel is only 2 bytes in the format. After
noticing that error Ville told me that second chroma sample has to
be average to match video requirements.

Looking at places where unpack to rgba is called it is possible to get
odd X coordinate and odd number of bytes. That makes unpack operation
complex problem. But I assume that source allocation is 4 byte aligned
always. That should hold for most of allocations but may fail.

Better solution would be threating YCBCR as compressed format
internally. But I suspect that I would break a lot of assumptions
everywhere with that changes.

But same time as I was checking call sites I started suspecting that we
can't ever hit these unpack functions for YCBCR. But I need to study the
code paths a lot more to be sure if that is true.

Changes to fix unpacking:
* Always start reading from the start of chroma pair.
* Always read to the end of chroma pair
* Unpack two RGB values in single iteration
* Read next chroma pair (if available) to calculate average for second
  sample.
* Refactor shared color space conversion code to separate function.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/main/format_unpack.c |  102 ++---
 1 file changed, 66 insertions(+), 36 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index c42bac1..feac558 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -468,52 +468,82 @@ unpack_I16(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
+YCBR_to_RGB(GLfloat dst[4], GLubyte y, GLubyte cb, GLubyte cr)
+{
+   GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
+   GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
+   GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
+   r *= (1.0F / 255.0F);
+   g *= (1.0F / 255.0F);
+   b *= (1.0F / 255.0F);
+   dst[RCOMP] = CLAMP(r, 0.0F, 1.0F);
+   dst[GCOMP] = CLAMP(g, 0.0F, 1.0F);
+   dst[BCOMP] = CLAMP(b, 0.0F, 1.0F);
+   dst[ACOMP] = 1.0F;
+}
+
+static void
 unpack_YCBCR(const void *src, GLfloat dst[][4], GLuint n)
 {
-   GLuint i;
-   for (i = 0; i  n; i++) {
-  const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */
+   GLuint i, ediff;
+   /* Align the start of reading to chroma pair */
+   uintptr_t sdiff = (uintptr_t)src % 4;
+   src = (const char *)src + sdiff;
+   /* Add extra length for the padding */
+   sdiff /= 2;
+   n += sdiff;
+   /* Align the end to the chroma pair */
+   ediff = n % 2;
+   n += ediff;
+
+   for (i = 0; i  n; i+=2) {
+  const GLushort *src0 = ((const GLushort *) src) + i; /* even */
   const GLushort *src1 = src0 + 1; /* odd */
-  const GLubyte y0 = (*src0  8)  0xff;  /* luminance */
-  const GLubyte cb = *src0  0xff; /* chroma U */
-  const GLubyte y1 = (*src1  8)  0xff;  /* luminance */
-  const GLubyte cr = *src1  0xff; /* chroma V */
-  const GLubyte y = (i  1) ? y1 : y0; /* choose even/odd luminance */
-  GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
-  GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 
128);
-  GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
-  r *= (1.0F / 255.0F);
-  g *= (1.0F / 255.0F);
-  b *= (1.0F / 255.0F);
-  dst[i][RCOMP] = CLAMP(r, 0.0F, 1.0F);
-  dst[i][GCOMP] = CLAMP(g, 0.0F, 1.0F);
-  dst[i][BCOMP] = CLAMP(b, 0.0F, 1.0F);
-  dst[i][ACOMP] = 1.0F;
+  /* Unpack next chroma pair for average if we know there is valid data */
+  const GLushort *src2 = i + 2  n ? src0 + 2 : src0;
+  const GLushort *src3 = i + 2  n ? src0 + 3 : src1;
+  const GLubyte y0  = (*src0  8)  0xff;  /* luminance */
+  const GLshort cb0 = *src0  0xff; /* chroma U */
+  const GLshort cb1 = *src2  0xff; /* chroma U */
+  const GLubyte y1  = (*src1  8)  0xff;  /* luminance */
+  const GLshort cr0 = *src1  0xff; /* chroma V */
+  const GLshort cr1 = *src3  0xff; /* chroma V */
+  if (i = sdiff)
+ YCBR_to_RGB(dst[i], y0, cb0, cr0);
+  if (i  n - ediff)
+ YCBR_to_RGB(dst[i+1], y1, (cb0 + cb1)/2, (cr0 + cr1)/2);
}
 }
 
 static void
 unpack_YCBCR_REV(const void *src, GLfloat dst[][4], GLuint n)
 {
-   GLuint i;
-   for (i = 0; i  n; i++) {
-  const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */
+   GLuint i, ediff;
+   /* Align the start of reading to chroma pair */
+   uintptr_t sdiff = (uintptr_t)src % 4;
+   src = (const char *)src + sdiff;
+   /* Add extra length for the padding */
+   n+=sdiff/2;
+   /* Align the end to the chroma pair */
+   ediff = n % 2;
+   n += ediff;
+
+   for (i = 0; i  n; i+=2) {
+  const GLushort *src0 = ((const GLushort *) src) + i; /* even */
   const GLushort *src1 = src0 + 1; /* odd */
-  const GLubyte y0 = *src0  

[Mesa-dev] [PATCH 02/21] mesa: Remove unnecessary parameters from TexImage

2012-06-11 Thread Pauli Nieminen
gl_texture_image structure always holds size and internal format before
TexImage driver hook is called. Those passing same information in
function parameters only duplicates information making the interface
harder to understand.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/intel/intel_tex_image.c   |   22 +++
 src/mesa/drivers/dri/nouveau/nouveau_texture.c |   21 ++-
 src/mesa/drivers/dri/radeon/radeon_texture.c   |   34 
 src/mesa/main/dd.h |2 --
 src/mesa/main/teximage.c   |7 +++--
 src/mesa/main/texobj.c |3 +--
 src/mesa/main/texstore.c   |9 +++
 src/mesa/main/texstore.h   |2 --
 src/mesa/state_tracker/st_cb_texture.c |   21 ++-
 9 files changed, 33 insertions(+), 88 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c 
b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 6e7e7018..f5cc721 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -133,8 +133,7 @@ static bool
 try_pbo_upload(struct gl_context *ctx,
struct gl_texture_image *image,
const struct gl_pixelstore_attrib *unpack,
-  GLenum format, GLenum type,
-   GLint width, GLint height, const void *pixels)
+  GLenum format, GLenum type, const void *pixels)
 {
struct intel_texture_image *intelImage = intel_texture_image(image);
struct intel_context *intel = intel_context(ctx);
@@ -162,7 +161,7 @@ try_pbo_upload(struct gl_context *ctx,
}
 
ctx-Driver.AllocTextureImageBuffer(ctx, image, image-TexFormat,
-   width, height, 1);
+   image-Width, image-Height, 1);
 
if (!intelImage-mt) {
   DBG(%s: no miptree\n, __FUNCTION__);
@@ -177,7 +176,7 @@ try_pbo_upload(struct gl_context *ctx,
if (unpack-RowLength  0)
   src_stride = unpack-RowLength;
else
-  src_stride = width;
+  src_stride = image-Width;
 
intel_miptree_get_image_offset(intelImage-mt, intelImage-base.Base.Level,
  intelImage-base.Base.Face, 0,
@@ -191,7 +190,7 @@ try_pbo_upload(struct gl_context *ctx,
  src_offset, false,
  dst_stride, dst_buffer, 0,
  intelImage-mt-region-tiling,
- 0, 0, dst_x, dst_y, width, height,
+ 0, 0, dst_x, dst_y, image-Width, image-Height,
  GL_COPY)) {
   DBG(%s: blit failed\n, __FUNCTION__);
   return false;
@@ -205,28 +204,25 @@ static void
 intelTexImage(struct gl_context * ctx,
   GLuint dims,
   struct gl_texture_image *texImage,
-  GLint internalFormat,
-  GLint width, GLint height, GLint depth, GLint border,
   GLenum format, GLenum type, const void *pixels,
   const struct gl_pixelstore_attrib *unpack)
 {
DBG(%s target %s level %d %dx%dx%d\n, __FUNCTION__,
_mesa_lookup_enum_by_nr(texImage-TexObject-Target),
-   texImage-Level, width, height, depth);
+   texImage-Level, texImage-Width, texImage-Height, texImage-Depth);
 
/* Attempt to use the blitter for PBO image uploads.
 */
if (dims = 2 
-   try_pbo_upload(ctx, texImage, unpack, format, type,
- width, height, pixels)) {
+   try_pbo_upload(ctx, texImage, unpack, format, type, pixels)) {
   return;
}
 
DBG(%s: upload image %dx%dx%d pixels %p\n,
-   __FUNCTION__, width, height, depth, pixels);
+   __FUNCTION__, texImage-Width, texImage-Height, texImage-Depth,
+   pixels);
 
-   _mesa_store_teximage(ctx, dims, texImage, internalFormat,
-width, height, depth, 0,
+   _mesa_store_teximage(ctx, dims, texImage,
 format, type, pixels, unpack);
 }
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c 
b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
index 0060f46..18dc9f7 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
@@ -481,8 +481,6 @@ get_teximage_placement(struct gl_texture_image *ti)
 static void
 nouveau_teximage(struct gl_context *ctx, GLint dims,
 struct gl_texture_image *ti,
-GLint internalFormat,
-GLint width, GLint height, GLint depth, GLint border,
 GLsizei imageSize,
 GLenum format, GLenum type, const GLvoid *pixels,
 const struct gl_pixelstore_attrib *packing,
@@ -493,10 +491,11 @@ nouveau_teximage(struct gl_context *ctx, GLint dims,
struct nouveau_surface *s = to_nouveau_teximage(ti)-surface;
struct nouveau_teximage *nti = 

[Mesa-dev] [PATCH 03/21] mesa: Remove unnecessary parameters from AllocTextureImageBuffer

2012-06-11 Thread Pauli Nieminen
Size and format information is always stored in gl_texture_image
structure. That makes it preferable to remove duplicate information from
parameters to make interface easier to understand.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/intel/intel_tex.c   |   10 +++
 src/mesa/drivers/dri/intel/intel_tex_image.c |3 +--
 src/mesa/drivers/dri/radeon/radeon_texture.c |4 +--
 src/mesa/main/dd.h   |4 +--
 src/mesa/main/mipmap.c   |3 +--
 src/mesa/main/texstore.c |7 ++---
 src/mesa/state_tracker/st_cb_texture.c   |   10 +++
 src/mesa/swrast/s_texture.c  |   37 +-
 src/mesa/swrast/swrast.h |7 ++---
 9 files changed, 29 insertions(+), 56 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex.c 
b/src/mesa/drivers/dri/intel/intel_tex.c
index b3ac226..92481b9 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -51,9 +51,7 @@ intelDeleteTextureObject(struct gl_context *ctx,
 
 static GLboolean
 intel_alloc_texture_image_buffer(struct gl_context *ctx,
-struct gl_texture_image *image,
-gl_format format, GLsizei width,
-GLsizei height, GLsizei depth)
+struct gl_texture_image *image)
 {
struct intel_context *intel = intel_context(ctx);
struct intel_texture_image *intel_image = intel_texture_image(image);
@@ -84,14 +82,14 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
assert(!intel_image-base.ImageOffsets);
intel_image-base.ImageOffsets = malloc(slices * sizeof(GLuint));
 
-   _swrast_init_texture_image(image, width, height, depth);
+   _swrast_init_texture_image(image);
 
if (intel_texobj-mt 
intel_miptree_match_image(intel_texobj-mt, image)) {
   intel_miptree_reference(intel_image-mt, intel_texobj-mt);
   DBG(%s: alloc obj %p level %d %dx%dx%d using object's miptree %p\n,
   __FUNCTION__, texobj, image-Level,
-  width, height, depth, intel_texobj-mt);
+  image-Width, image-Height, image-Depth, intel_texobj-mt);
} else {
   intel_image-mt = intel_miptree_create_for_teximage(intel, intel_texobj,
   intel_image,
@@ -106,7 +104,7 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
 
   DBG(%s: alloc obj %p level %d %dx%dx%d using new miptree %p\n,
   __FUNCTION__, texobj, image-Level,
-  width, height, depth, intel_image-mt);
+  image-Width, image-Height, image-Depth, intel_image-mt);
}
 
return true;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c 
b/src/mesa/drivers/dri/intel/intel_tex_image.c
index f5cc721..66ba80a 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -160,8 +160,7 @@ try_pbo_upload(struct gl_context *ctx,
   return false;
}
 
-   ctx-Driver.AllocTextureImageBuffer(ctx, image, image-TexFormat,
-   image-Width, image-Height, 1);
+   ctx-Driver.AllocTextureImageBuffer(ctx, image);
 
if (!intelImage-mt) {
   DBG(%s: no miptree\n, __FUNCTION__);
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c 
b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 04f3e23..157cc09 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -103,9 +103,7 @@ radeonDeleteTextureImage(struct gl_context *ctx, struct 
gl_texture_image *img)
 
 static GLboolean
 radeonAllocTextureImageBuffer(struct gl_context *ctx,
- struct gl_texture_image *timage,
- gl_format format, GLsizei width,
- GLsizei height, GLsizei depth)
+ struct gl_texture_image *timage)
 {
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
radeon_texture_image *image = get_radeon_texture_image(timage);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index d58305a..6f16ef7 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -327,9 +327,7 @@ struct dd_function_table {
 
/** Called to allocate memory for a single texture image */
GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx,
-struct gl_texture_image *texImage,
-gl_format format, GLsizei width,
-GLsizei height, GLsizei depth);
+struct gl_texture_image *texImage);
 
/** Free the memory for a single texture image */
void (*FreeTextureImageBuffer)(struct gl_context *ctx,
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 250d3c6..527873e 100644
--- 

[Mesa-dev] [PATCH 04/21] mesa: Remove unnecessary parameters CompressedTexImage

2012-06-11 Thread Pauli Nieminen
In tune with previous patches. Again there is duplication of information
in function parameters that is good to remove.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/nouveau/nouveau_texture.c |2 --
 src/mesa/main/dd.h |3 ---
 src/mesa/main/teximage.c   |6 ++
 src/mesa/main/texstore.c   |5 +
 src/mesa/main/texstore.h   |3 ---
 src/mesa/state_tracker/st_cb_texture.c |5 +
 6 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c 
b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
index 18dc9f7..0e42758 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
@@ -553,8 +553,6 @@ nouveau_teximage_123d(struct gl_context *ctx, GLuint dims,
 static void
 nouveau_compressed_teximage(struct gl_context *ctx, GLuint dims,
struct gl_texture_image *ti,
-   GLint internalFormat,
-   GLint width, GLint height, GLint depth, GLint border,
GLsizei imageSize, const GLvoid *data)
 {
nouveau_teximage(ctx, 2, ti, imageSize, 0, 0, data,
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 6f16ef7..dc1d8bb 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -271,9 +271,6 @@ struct dd_function_table {
 */
void (*CompressedTexImage)(struct gl_context *ctx, GLuint dims,
   struct gl_texture_image *texImage,
-  GLint internalFormat,
-  GLsizei width, GLsizei height, GLsizei depth,
-  GLint border,
   GLsizei imageSize, const GLvoid *data);
 
/**
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 84e84b5..d536e89 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3540,10 +3540,8 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
   width, height, depth,
   border, internalFormat, texFormat);
 
-   ctx-Driver.CompressedTexImage(ctx, dims, texImage,
-  internalFormat,
-  width, height, depth,
-  border, imageSize, data);
+   ctx-Driver.CompressedTexImage(ctx, dims, texImage, imageSize,
+  data);
 
check_gen_mipmap(ctx, target, texObj, level);
 
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 1700b26..7ab1b69 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4312,9 +4312,6 @@ _mesa_store_texsubimage(struct gl_context *ctx, GLuint 
dims,
 void
 _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
 struct gl_texture_image *texImage,
-GLint internalFormat,
-GLint width, GLint height, GLint depth,
-GLint border,
 GLsizei imageSize, const GLvoid *data)
 {
/* only 2D compressed images are supported at this time */
@@ -4340,7 +4337,7 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, 
GLuint dims,
 
_mesa_store_compressed_texsubimage(ctx, dims, texImage,
   0, 0, 0,
-  width, height, depth,
+  texImage-Width, texImage-Height, 
texImage-Depth,
   texImage-TexFormat,
   imageSize, data);
 }
diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h
index fbcb41b..7af532d 100644
--- a/src/mesa/main/texstore.h
+++ b/src/mesa/main/texstore.h
@@ -109,9 +109,6 @@ _mesa_store_texsubimage(struct gl_context *ctx, GLuint dims,
 extern void
 _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
 struct gl_texture_image *texImage,
-GLint internalFormat,
-GLint width, GLint height, GLint depth,
-GLint border,
 GLsizei imageSize, const GLvoid *data);
 
 
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 72dfd24..a9a3304 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -541,13 +541,10 @@ st_TexImage(struct gl_context * ctx, GLuint dims,
 static void
 st_CompressedTexImage(struct gl_context *ctx, GLuint dims,
   struct gl_texture_image *texImage,
-  GLint internalFormat,
-   

[Mesa-dev] [PATCH 07/21] mesa/macros: Add ARRAY_SIZE helper macro core mesa

2012-06-11 Thread Pauli Nieminen
The ARRAY_SIZE macro is usefull helper that is used already in many
parts of core. But mesa core was missing it. I decided to add it to the
macros.h when I wanted to use it in following patch.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/intel/intel_context.h  |3 +--
 src/mesa/drivers/dri/radeon/radeon_screen.c |2 --
 src/mesa/main/macros.h  |3 +++
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.h 
b/src/mesa/drivers/dri/intel/intel_context.h
index cc3ee0d..4dc98d6 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -33,6 +33,7 @@
 #include string.h
 #include main/mtypes.h
 #include main/mm.h
+#include main/macros.h
 
 #ifdef __cplusplus
 extern C {
@@ -341,8 +342,6 @@ extern char *__progname;
 #define SUBPIXEL_X 0.125
 #define SUBPIXEL_Y 0.125
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-
 /**
  * Align a value up to an alignment value
  *
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 85cfe17..b0545b5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -702,8 +702,6 @@ radeonDestroyBuffer(__DRIdrawable *driDrawPriv)
 _mesa_reference_framebuffer((struct gl_framebuffer 
**)((driDrawPriv-driverPrivate)), NULL);
 }
 
-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
-
 /**
  * This is the driver specific part of the createNewScreen entry point.
  * Called when using DRI2.
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index d1df2ce..e05fa14 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -679,5 +679,8 @@ do {\
 #define ENUM_TO_DOUBLE(E)  ((GLdouble)(GLint)(E))
 #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
 
 #endif
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 03/21] mesa: Remove unnecessary parameters from TexImage

2012-06-11 Thread Pauli Nieminen
gl_texture_image structure always holds size and internal format before
TexImage driver hook is called. Those passing same information in
function parameters only duplicates information making the interface
harder to understand.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/intel/intel_tex_image.c   |   22 +++
 src/mesa/drivers/dri/nouveau/nouveau_texture.c |   21 ++-
 src/mesa/drivers/dri/radeon/radeon_texture.c   |   34 
 src/mesa/main/dd.h |2 --
 src/mesa/main/teximage.c   |7 +++--
 src/mesa/main/texobj.c |3 +--
 src/mesa/main/texstore.c   |9 +++
 src/mesa/main/texstore.h   |2 --
 src/mesa/state_tracker/st_cb_texture.c |   21 ++-
 9 files changed, 33 insertions(+), 88 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c 
b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 6e7e7018..f5cc721 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -133,8 +133,7 @@ static bool
 try_pbo_upload(struct gl_context *ctx,
struct gl_texture_image *image,
const struct gl_pixelstore_attrib *unpack,
-  GLenum format, GLenum type,
-   GLint width, GLint height, const void *pixels)
+  GLenum format, GLenum type, const void *pixels)
 {
struct intel_texture_image *intelImage = intel_texture_image(image);
struct intel_context *intel = intel_context(ctx);
@@ -162,7 +161,7 @@ try_pbo_upload(struct gl_context *ctx,
}
 
ctx-Driver.AllocTextureImageBuffer(ctx, image, image-TexFormat,
-   width, height, 1);
+   image-Width, image-Height, 1);
 
if (!intelImage-mt) {
   DBG(%s: no miptree\n, __FUNCTION__);
@@ -177,7 +176,7 @@ try_pbo_upload(struct gl_context *ctx,
if (unpack-RowLength  0)
   src_stride = unpack-RowLength;
else
-  src_stride = width;
+  src_stride = image-Width;
 
intel_miptree_get_image_offset(intelImage-mt, intelImage-base.Base.Level,
  intelImage-base.Base.Face, 0,
@@ -191,7 +190,7 @@ try_pbo_upload(struct gl_context *ctx,
  src_offset, false,
  dst_stride, dst_buffer, 0,
  intelImage-mt-region-tiling,
- 0, 0, dst_x, dst_y, width, height,
+ 0, 0, dst_x, dst_y, image-Width, image-Height,
  GL_COPY)) {
   DBG(%s: blit failed\n, __FUNCTION__);
   return false;
@@ -205,28 +204,25 @@ static void
 intelTexImage(struct gl_context * ctx,
   GLuint dims,
   struct gl_texture_image *texImage,
-  GLint internalFormat,
-  GLint width, GLint height, GLint depth, GLint border,
   GLenum format, GLenum type, const void *pixels,
   const struct gl_pixelstore_attrib *unpack)
 {
DBG(%s target %s level %d %dx%dx%d\n, __FUNCTION__,
_mesa_lookup_enum_by_nr(texImage-TexObject-Target),
-   texImage-Level, width, height, depth);
+   texImage-Level, texImage-Width, texImage-Height, texImage-Depth);
 
/* Attempt to use the blitter for PBO image uploads.
 */
if (dims = 2 
-   try_pbo_upload(ctx, texImage, unpack, format, type,
- width, height, pixels)) {
+   try_pbo_upload(ctx, texImage, unpack, format, type, pixels)) {
   return;
}
 
DBG(%s: upload image %dx%dx%d pixels %p\n,
-   __FUNCTION__, width, height, depth, pixels);
+   __FUNCTION__, texImage-Width, texImage-Height, texImage-Depth,
+   pixels);
 
-   _mesa_store_teximage(ctx, dims, texImage, internalFormat,
-width, height, depth, 0,
+   _mesa_store_teximage(ctx, dims, texImage,
 format, type, pixels, unpack);
 }
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c 
b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
index 0060f46..18dc9f7 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
@@ -481,8 +481,6 @@ get_teximage_placement(struct gl_texture_image *ti)
 static void
 nouveau_teximage(struct gl_context *ctx, GLint dims,
 struct gl_texture_image *ti,
-GLint internalFormat,
-GLint width, GLint height, GLint depth, GLint border,
 GLsizei imageSize,
 GLenum format, GLenum type, const GLvoid *pixels,
 const struct gl_pixelstore_attrib *packing,
@@ -493,10 +491,11 @@ nouveau_teximage(struct gl_context *ctx, GLint dims,
struct nouveau_surface *s = to_nouveau_teximage(ti)-surface;
struct nouveau_teximage *nti = 

[Mesa-dev] [PATCH 06/21] mesa/macros: Add ARRAY_SIZE helper macro core mesa

2012-06-11 Thread Pauli Nieminen
The ARRAY_SIZE macro is usefull helper that is used already in many
parts of core. But mesa core was missing it. I decided to add it to the
macros.h when I wanted to use it in following patch.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/intel/intel_context.h  |3 +--
 src/mesa/drivers/dri/radeon/radeon_screen.c |2 --
 src/mesa/main/macros.h  |3 +++
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.h 
b/src/mesa/drivers/dri/intel/intel_context.h
index cc3ee0d..4dc98d6 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -33,6 +33,7 @@
 #include string.h
 #include main/mtypes.h
 #include main/mm.h
+#include main/macros.h
 
 #ifdef __cplusplus
 extern C {
@@ -341,8 +342,6 @@ extern char *__progname;
 #define SUBPIXEL_X 0.125
 #define SUBPIXEL_Y 0.125
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-
 /**
  * Align a value up to an alignment value
  *
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 85cfe17..b0545b5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -702,8 +702,6 @@ radeonDestroyBuffer(__DRIdrawable *driDrawPriv)
 _mesa_reference_framebuffer((struct gl_framebuffer 
**)((driDrawPriv-driverPrivate)), NULL);
 }
 
-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
-
 /**
  * This is the driver specific part of the createNewScreen entry point.
  * Called when using DRI2.
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index d1df2ce..e05fa14 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -679,5 +679,8 @@ do {\
 #define ENUM_TO_DOUBLE(E)  ((GLdouble)(GLint)(E))
 #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
 
 #endif
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 05/21] mesa: Remove unnecessary parameters CompressedTexImage

2012-06-11 Thread Pauli Nieminen
In tune with previous patches. Again there is duplication of information
in function parameters that is good to remove.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/nouveau/nouveau_texture.c |2 --
 src/mesa/main/dd.h |3 ---
 src/mesa/main/teximage.c   |6 ++
 src/mesa/main/texstore.c   |5 +
 src/mesa/main/texstore.h   |3 ---
 src/mesa/state_tracker/st_cb_texture.c |5 +
 6 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c 
b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
index 18dc9f7..0e42758 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
@@ -553,8 +553,6 @@ nouveau_teximage_123d(struct gl_context *ctx, GLuint dims,
 static void
 nouveau_compressed_teximage(struct gl_context *ctx, GLuint dims,
struct gl_texture_image *ti,
-   GLint internalFormat,
-   GLint width, GLint height, GLint depth, GLint border,
GLsizei imageSize, const GLvoid *data)
 {
nouveau_teximage(ctx, 2, ti, imageSize, 0, 0, data,
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 6f16ef7..dc1d8bb 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -271,9 +271,6 @@ struct dd_function_table {
 */
void (*CompressedTexImage)(struct gl_context *ctx, GLuint dims,
   struct gl_texture_image *texImage,
-  GLint internalFormat,
-  GLsizei width, GLsizei height, GLsizei depth,
-  GLint border,
   GLsizei imageSize, const GLvoid *data);
 
/**
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 84e84b5..d536e89 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3540,10 +3540,8 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
   width, height, depth,
   border, internalFormat, texFormat);
 
-   ctx-Driver.CompressedTexImage(ctx, dims, texImage,
-  internalFormat,
-  width, height, depth,
-  border, imageSize, data);
+   ctx-Driver.CompressedTexImage(ctx, dims, texImage, imageSize,
+  data);
 
check_gen_mipmap(ctx, target, texObj, level);
 
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 1700b26..7ab1b69 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4312,9 +4312,6 @@ _mesa_store_texsubimage(struct gl_context *ctx, GLuint 
dims,
 void
 _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
 struct gl_texture_image *texImage,
-GLint internalFormat,
-GLint width, GLint height, GLint depth,
-GLint border,
 GLsizei imageSize, const GLvoid *data)
 {
/* only 2D compressed images are supported at this time */
@@ -4340,7 +4337,7 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, 
GLuint dims,
 
_mesa_store_compressed_texsubimage(ctx, dims, texImage,
   0, 0, 0,
-  width, height, depth,
+  texImage-Width, texImage-Height, 
texImage-Depth,
   texImage-TexFormat,
   imageSize, data);
 }
diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h
index fbcb41b..7af532d 100644
--- a/src/mesa/main/texstore.h
+++ b/src/mesa/main/texstore.h
@@ -109,9 +109,6 @@ _mesa_store_texsubimage(struct gl_context *ctx, GLuint dims,
 extern void
 _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
 struct gl_texture_image *texImage,
-GLint internalFormat,
-GLint width, GLint height, GLint depth,
-GLint border,
 GLsizei imageSize, const GLvoid *data);
 
 
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 72dfd24..a9a3304 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -541,13 +541,10 @@ st_TexImage(struct gl_context * ctx, GLuint dims,
 static void
 st_CompressedTexImage(struct gl_context *ctx, GLuint dims,
   struct gl_texture_image *texImage,
-  GLint internalFormat,
-   

[Mesa-dev] [PATCH 08/21] mesa/samplerobj: Avoid crash in sampler query if texture unit is disabled

2012-06-11 Thread Pauli Nieminen
Sampler queries are so far made only for enabled texture unit. But if
any code would query sampler before checking texture unit state that
would result to NULL deference.

Making the inline helper easier to use with NULL check makes a lot sense
because compiler is likely to combine the checks for the current texture.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/main/samplerobj.h |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index 0bfda43..33da894 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -33,8 +33,10 @@ _mesa_get_samplerobj(struct gl_context *ctx, GLuint unit)
 {
if (ctx-Texture.Unit[unit].Sampler)
   return ctx-Texture.Unit[unit].Sampler;
-   else
+   else if (ctx-Texture.Unit[unit]._Current)
   return ctx-Texture.Unit[unit]._Current-Sampler;
+   else
+  return NULL;
 }
 
 
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 07/21] mesa/samplerobj: Support EXT_texture_sRGB_decode

2012-06-11 Thread Pauli Nieminen
sRGBDecode state is part of sampler object state but mesa was missing
handlers to access the state. This patch adds the support for required
state changes and queries.

GL_EXT_texture_sRGB_decode issue 4:
4) Should we add forward-looking support for ARB_sampler_objects?

RESOLVED: YES

If ARB_sampler_objects exists in the implementation, the sampler
objects should also include this parameter per sampler.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/main/samplerobj.c |   56 
 1 file changed, 56 insertions(+)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 8c54c9a..f276296 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -582,6 +582,24 @@ set_sampler_cube_map_seamless(struct gl_context *ctx,
return GL_TRUE;
 }
 
+static GLuint
+set_sampler_srgb_decode(struct gl_context *ctx,
+  struct gl_sampler_object *samp, GLenum param)
+{
+   if (!ctx-Extensions.EXT_texture_sRGB_decode)
+  return INVALID_PNAME;
+
+   if (samp-sRGBDecode == param)
+  return GL_FALSE;
+
+   if (param != GL_DECODE_EXT  param != GL_SKIP_DECODE_EXT)
+  return INVALID_VALUE;
+
+   flush(ctx);
+   samp-sRGBDecode = param;
+   return GL_TRUE;
+}
+
 
 static void GLAPIENTRY
 _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
@@ -634,6 +652,9 @@ _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint 
param)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, param);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, param);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   /* fall-through */
default:
@@ -718,6 +739,9 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum pname, 
GLfloat param)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) param);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) param);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   /* fall-through */
default:
@@ -799,6 +823,9 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, 
const GLint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, params[0]);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   {
  GLfloat c[4];
@@ -890,6 +917,9 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, 
const GLfloat *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) params[0]);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   res = set_sampler_border_colorf(ctx, sampObj, params);
   break;
@@ -972,6 +1002,9 @@ _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, 
const GLint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   res = set_sampler_border_colori(ctx, sampObj, params);
   break;
@@ -1055,6 +1088,9 @@ _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, 
const GLuint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   res = set_sampler_border_colorui(ctx, sampObj, params);
   break;
@@ -1149,6 +1185,11 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum 
pname, GLint *params)
  goto invalid_pname;
   *params = sampObj-CubeMapSeamless;
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  if (!ctx-Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+  *params = (GLenum) sampObj-sRGBDecode;
+  break;
default:
   goto invalid_pname;
}
@@ -1222,6 +1263,11 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum 
pname, GLfloat *params)
  goto invalid_pname;
   *params = (GLfloat) sampObj-CubeMapSeamless;
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  if (!ctx-Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+  *params = (GLfloat) sampObj-sRGBDecode;
+  break;
default:
   goto invalid_pname;
}
@@ -1296,6 +1342,11 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum 
pname, GLint *params)
  goto invalid_pname;
   *params = sampObj-CubeMapSeamless;
   

[Mesa-dev] [PATCH 06/21] mesa: Move DepthMode to texture object

2012-06-11 Thread Pauli Nieminen
GL_DEPTH_TEXTURE_MODE isn't meant to be part of sampler state based on
compatibility profile specifications.

OpenGL specification 4.1 compatibility 20100725 3.9.2:
... The values accepted in the pname parameter
are TEXTURE_WRAP_S, TEXTURE_WRAP_T, TEXTURE_WRAP_R, TEXTURE_MIN_-
FILTER, TEXTURE_MAG_FILTER, TEXTURE_BORDER_COLOR, TEXTURE_MIN_-
LOD, TEXTURE_MAX_LOD, TEXTURE_LOD_BIAS, TEXTURE_COMPARE_MODE, and
TEXTURE_COMPARE_FUNC. Texture state listed in table 6.25 but not listed here and
in the sampler state in table 6.26 is not part of the sampler state, and 
remains in the
texture object.

Same can be found from 3.3 compatibility specification.

That makes me think that moving DepthMode from sampler state makes sense
to avoid bugs if DepthMode happens to be used with sampler objects.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/i915/i915_texstate.c |2 +-
 src/mesa/drivers/dri/i965/brw_wm.c|2 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  |2 +-
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |2 +-
 src/mesa/main/attrib.c|2 +-
 src/mesa/main/mtypes.h|6 +++---
 src/mesa/main/samplerobj.c|2 --
 src/mesa/main/texobj.c|4 ++--
 src/mesa/main/texparam.c  |8 
 src/mesa/main/texstate.c  |2 +-
 src/mesa/state_tracker/st_atom_texture.c  |4 ++--
 src/mesa/swrast/s_texfilter.c |4 ++--
 12 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c 
b/src/mesa/drivers/dri/i915/i915_texstate.c
index fd63a69..590d5fa 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -168,7 +168,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint 
unit, GLuint ss3)
i915-state.tex_offset[unit] = 0; /* Always the origin of the miptree */
 
format = translate_texture_format(firstImage-TexFormat,
-sampler-DepthMode);
+tObj-DepthMode);
pitch = intelObj-mt-region-pitch * intelObj-mt-cpp;
 
state[I915_TEXREG_MS3] =
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 63c74ad..ff70d2b 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -352,7 +352,7 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
  * overrides because shadow comparison always returns the result of
  * the comparison in all channels anyway.
  */
-switch (sampler-DepthMode) {
+switch (unit-_Current-DepthMode) {
 case GL_ALPHA:
swizzles[0] = SWIZZLE_ZERO;
swizzles[1] = SWIZZLE_ZERO;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 4718337..2506cf0 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -724,7 +724,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint 
unit )
  BRW_SURFACE_CUBEFACE_ENABLES |
  (translate_tex_format(mt-format,
firstImage-InternalFormat,
-   sampler-DepthMode,
+   tObj-DepthMode,
sampler-sRGBDecode) 
   BRW_SURFACE_FORMAT_SHIFT));
 
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index d34bf53..1e7fd2e 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -251,7 +251,7 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint 
unit)
surf-ss0.surface_type = translate_tex_target(tObj-Target);
surf-ss0.surface_format = translate_tex_format(mt-format,
firstImage-InternalFormat,
-   sampler-DepthMode,
+   tObj-DepthMode,
sampler-sRGBDecode);
if (tObj-Target == GL_TEXTURE_CUBE_MAP) {
   surf-ss0.cube_pos_x = 1;
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 318d576..8bc7c34 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -806,7 +806,7 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
 samp-CompareFunc);
  }
  if (ctx-Extensions.ARB_depth_texture)
-_mesa_TexParameteri(target, GL_DEPTH_TEXTURE_MODE, 
samp-DepthMode);
+_mesa_TexParameteri(target, GL_DEPTH_TEXTURE_MODE, obj-DepthMode);
   }
 

[Mesa-dev] [PATCH 12/21] mesa: Check index buffer offset in DrawElements

2012-06-11 Thread Pauli Nieminen
DrawElements checks for cound beeing larger than index buffer object.
But application can specify offset to buffer leading to buffer overflow
again. ARB_vertex_buffer_object leaves the case undefined but allows
program termination.

But if we do check the index buffer size it makes sense to check it
correctly.

   What happens when an attempt is made to access data outside the
bounds of the buffer object with a command that dereferences the
arrays?

RESOLVED: ALLOW PROGRAM TERMINATION.  In the event of a
software fallback, bounds checking can become impractical. Since
applications don't know the actual address of the buffer object
and only provide an offset, they can't ever guarantee that
out-of-bounds offsets will fall on valid memory.  So it's hard to
do any better than this.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/main/api_validate.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 02495a1..add65f8 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -299,7 +299,8 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
if (_mesa_is_bufferobj(ctx-Array.ArrayObj-ElementArrayBufferObj)) {
   /* use indices in the buffer object */
   /* make sure count doesn't go outside buffer bounds */
-  if (index_bytes(type, count)  
ctx-Array.ArrayObj-ElementArrayBufferObj-Size) {
+  if (index_bytes(type, count) + (uintptr_t)indices 
+  ctx-Array.ArrayObj-ElementArrayBufferObj-Size) {
  _mesa_warning(ctx, glDrawElements index out of buffer bounds);
  return GL_FALSE;
   }
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 04/21] mesa: Remove unnecessary parameters from AllocTextureImageBuffer

2012-06-11 Thread Pauli Nieminen
Size and format information is always stored in gl_texture_image
structure. That makes it preferable to remove duplicate information from
parameters to make interface easier to understand.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/intel/intel_tex.c   |   10 +++
 src/mesa/drivers/dri/intel/intel_tex_image.c |3 +--
 src/mesa/drivers/dri/radeon/radeon_texture.c |4 +--
 src/mesa/main/dd.h   |4 +--
 src/mesa/main/mipmap.c   |3 +--
 src/mesa/main/texstore.c |7 ++---
 src/mesa/state_tracker/st_cb_texture.c   |   10 +++
 src/mesa/swrast/s_texture.c  |   37 +-
 src/mesa/swrast/swrast.h |7 ++---
 9 files changed, 29 insertions(+), 56 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex.c 
b/src/mesa/drivers/dri/intel/intel_tex.c
index b3ac226..92481b9 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -51,9 +51,7 @@ intelDeleteTextureObject(struct gl_context *ctx,
 
 static GLboolean
 intel_alloc_texture_image_buffer(struct gl_context *ctx,
-struct gl_texture_image *image,
-gl_format format, GLsizei width,
-GLsizei height, GLsizei depth)
+struct gl_texture_image *image)
 {
struct intel_context *intel = intel_context(ctx);
struct intel_texture_image *intel_image = intel_texture_image(image);
@@ -84,14 +82,14 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
assert(!intel_image-base.ImageOffsets);
intel_image-base.ImageOffsets = malloc(slices * sizeof(GLuint));
 
-   _swrast_init_texture_image(image, width, height, depth);
+   _swrast_init_texture_image(image);
 
if (intel_texobj-mt 
intel_miptree_match_image(intel_texobj-mt, image)) {
   intel_miptree_reference(intel_image-mt, intel_texobj-mt);
   DBG(%s: alloc obj %p level %d %dx%dx%d using object's miptree %p\n,
   __FUNCTION__, texobj, image-Level,
-  width, height, depth, intel_texobj-mt);
+  image-Width, image-Height, image-Depth, intel_texobj-mt);
} else {
   intel_image-mt = intel_miptree_create_for_teximage(intel, intel_texobj,
   intel_image,
@@ -106,7 +104,7 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
 
   DBG(%s: alloc obj %p level %d %dx%dx%d using new miptree %p\n,
   __FUNCTION__, texobj, image-Level,
-  width, height, depth, intel_image-mt);
+  image-Width, image-Height, image-Depth, intel_image-mt);
}
 
return true;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c 
b/src/mesa/drivers/dri/intel/intel_tex_image.c
index f5cc721..66ba80a 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -160,8 +160,7 @@ try_pbo_upload(struct gl_context *ctx,
   return false;
}
 
-   ctx-Driver.AllocTextureImageBuffer(ctx, image, image-TexFormat,
-   image-Width, image-Height, 1);
+   ctx-Driver.AllocTextureImageBuffer(ctx, image);
 
if (!intelImage-mt) {
   DBG(%s: no miptree\n, __FUNCTION__);
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c 
b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 04f3e23..157cc09 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -103,9 +103,7 @@ radeonDeleteTextureImage(struct gl_context *ctx, struct 
gl_texture_image *img)
 
 static GLboolean
 radeonAllocTextureImageBuffer(struct gl_context *ctx,
- struct gl_texture_image *timage,
- gl_format format, GLsizei width,
- GLsizei height, GLsizei depth)
+ struct gl_texture_image *timage)
 {
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
radeon_texture_image *image = get_radeon_texture_image(timage);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index d58305a..6f16ef7 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -327,9 +327,7 @@ struct dd_function_table {
 
/** Called to allocate memory for a single texture image */
GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx,
-struct gl_texture_image *texImage,
-gl_format format, GLsizei width,
-GLsizei height, GLsizei depth);
+struct gl_texture_image *texImage);
 
/** Free the memory for a single texture image */
void (*FreeTextureImageBuffer)(struct gl_context *ctx,
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 250d3c6..527873e 100644
--- 

[Mesa-dev] [PATCH 08/21] mesa/samplerobj: Support EXT_texture_sRGB_decode

2012-06-11 Thread Pauli Nieminen
sRGBDecode state is part of sampler object state but mesa was missing
handlers to access the state. This patch adds the support for required
state changes and queries.

GL_EXT_texture_sRGB_decode issue 4:
4) Should we add forward-looking support for ARB_sampler_objects?

RESOLVED: YES

If ARB_sampler_objects exists in the implementation, the sampler
objects should also include this parameter per sampler.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/main/samplerobj.c |   56 
 1 file changed, 56 insertions(+)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 8c54c9a..f276296 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -582,6 +582,24 @@ set_sampler_cube_map_seamless(struct gl_context *ctx,
return GL_TRUE;
 }
 
+static GLuint
+set_sampler_srgb_decode(struct gl_context *ctx,
+  struct gl_sampler_object *samp, GLenum param)
+{
+   if (!ctx-Extensions.EXT_texture_sRGB_decode)
+  return INVALID_PNAME;
+
+   if (samp-sRGBDecode == param)
+  return GL_FALSE;
+
+   if (param != GL_DECODE_EXT  param != GL_SKIP_DECODE_EXT)
+  return INVALID_VALUE;
+
+   flush(ctx);
+   samp-sRGBDecode = param;
+   return GL_TRUE;
+}
+
 
 static void GLAPIENTRY
 _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
@@ -634,6 +652,9 @@ _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint 
param)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, param);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, param);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   /* fall-through */
default:
@@ -718,6 +739,9 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum pname, 
GLfloat param)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) param);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) param);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   /* fall-through */
default:
@@ -799,6 +823,9 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, 
const GLint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, params[0]);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   {
  GLfloat c[4];
@@ -890,6 +917,9 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, 
const GLfloat *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) params[0]);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   res = set_sampler_border_colorf(ctx, sampObj, params);
   break;
@@ -972,6 +1002,9 @@ _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, 
const GLint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   res = set_sampler_border_colori(ctx, sampObj, params);
   break;
@@ -1055,6 +1088,9 @@ _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, 
const GLuint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
   res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
case GL_TEXTURE_BORDER_COLOR:
   res = set_sampler_border_colorui(ctx, sampObj, params);
   break;
@@ -1149,6 +1185,11 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum 
pname, GLint *params)
  goto invalid_pname;
   *params = sampObj-CubeMapSeamless;
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  if (!ctx-Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+  *params = (GLenum) sampObj-sRGBDecode;
+  break;
default:
   goto invalid_pname;
}
@@ -1222,6 +1263,11 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum 
pname, GLfloat *params)
  goto invalid_pname;
   *params = (GLfloat) sampObj-CubeMapSeamless;
   break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  if (!ctx-Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+  *params = (GLfloat) sampObj-sRGBDecode;
+  break;
default:
   goto invalid_pname;
}
@@ -1296,6 +1342,11 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum 
pname, GLint *params)
  goto invalid_pname;
   *params = sampObj-CubeMapSeamless;
   

[Mesa-dev] [PATCH 05/21] mesa: Move DepthMode to texture object

2012-06-11 Thread Pauli Nieminen
GL_DEPTH_TEXTURE_MODE isn't meant to be part of sampler state based on
compatibility profile specifications.

OpenGL specification 4.1 compatibility 20100725 3.9.2:
... The values accepted in the pname parameter
are TEXTURE_WRAP_S, TEXTURE_WRAP_T, TEXTURE_WRAP_R, TEXTURE_MIN_-
FILTER, TEXTURE_MAG_FILTER, TEXTURE_BORDER_COLOR, TEXTURE_MIN_-
LOD, TEXTURE_MAX_LOD, TEXTURE_LOD_BIAS, TEXTURE_COMPARE_MODE, and
TEXTURE_COMPARE_FUNC. Texture state listed in table 6.25 but not listed here and
in the sampler state in table 6.26 is not part of the sampler state, and 
remains in the
texture object.

Same can be found from 3.3 compatibility specification.

That makes me think that moving DepthMode from sampler state makes sense
to avoid bugs if DepthMode happens to be used with sampler objects.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/i915/i915_texstate.c |2 +-
 src/mesa/drivers/dri/i965/brw_wm.c|2 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  |2 +-
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |2 +-
 src/mesa/main/attrib.c|2 +-
 src/mesa/main/mtypes.h|6 +++---
 src/mesa/main/samplerobj.c|2 --
 src/mesa/main/texobj.c|4 ++--
 src/mesa/main/texparam.c  |8 
 src/mesa/main/texstate.c  |2 +-
 src/mesa/state_tracker/st_atom_texture.c  |4 ++--
 src/mesa/swrast/s_texfilter.c |4 ++--
 12 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c 
b/src/mesa/drivers/dri/i915/i915_texstate.c
index fd63a69..590d5fa 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -168,7 +168,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint 
unit, GLuint ss3)
i915-state.tex_offset[unit] = 0; /* Always the origin of the miptree */
 
format = translate_texture_format(firstImage-TexFormat,
-sampler-DepthMode);
+tObj-DepthMode);
pitch = intelObj-mt-region-pitch * intelObj-mt-cpp;
 
state[I915_TEXREG_MS3] =
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 63c74ad..ff70d2b 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -352,7 +352,7 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
  * overrides because shadow comparison always returns the result of
  * the comparison in all channels anyway.
  */
-switch (sampler-DepthMode) {
+switch (unit-_Current-DepthMode) {
 case GL_ALPHA:
swizzles[0] = SWIZZLE_ZERO;
swizzles[1] = SWIZZLE_ZERO;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 4718337..2506cf0 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -724,7 +724,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint 
unit )
  BRW_SURFACE_CUBEFACE_ENABLES |
  (translate_tex_format(mt-format,
firstImage-InternalFormat,
-   sampler-DepthMode,
+   tObj-DepthMode,
sampler-sRGBDecode) 
   BRW_SURFACE_FORMAT_SHIFT));
 
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index d34bf53..1e7fd2e 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -251,7 +251,7 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint 
unit)
surf-ss0.surface_type = translate_tex_target(tObj-Target);
surf-ss0.surface_format = translate_tex_format(mt-format,
firstImage-InternalFormat,
-   sampler-DepthMode,
+   tObj-DepthMode,
sampler-sRGBDecode);
if (tObj-Target == GL_TEXTURE_CUBE_MAP) {
   surf-ss0.cube_pos_x = 1;
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 318d576..8bc7c34 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -806,7 +806,7 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
 samp-CompareFunc);
  }
  if (ctx-Extensions.ARB_depth_texture)
-_mesa_TexParameteri(target, GL_DEPTH_TEXTURE_MODE, 
samp-DepthMode);
+_mesa_TexParameteri(target, GL_DEPTH_TEXTURE_MODE, obj-DepthMode);
   }
 

[Mesa-dev] [PATCH 10/21] radeon: Fix printf format not to warn in 64bit

2012-06-11 Thread Pauli Nieminen
When I build tested radeon changes I noticed two warnings about format
size missmatch in 64bit. I decided to clean them to make relevant
compiler warnings easier to spot.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/radeon/radeon_blit.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c 
b/src/mesa/drivers/dri/radeon/radeon_blit.c
index 4233221..80b5346 100644
--- a/src/mesa/drivers/dri/radeon/radeon_blit.c
+++ b/src/mesa/drivers/dri/radeon/radeon_blit.c
@@ -390,13 +390,13 @@ unsigned r100_blit(struct gl_context *ctx,
 }
 
 if (0) {
-fprintf(stderr, src: size [%d x %d], pitch %d, offset %d 
+fprintf(stderr, src: size [%d x %d], pitch %d, offset %zd 
 offset [%d x %d], format %s, bo %p\n,
 src_width, src_height, src_pitch, src_offset,
 src_x_offset, src_y_offset,
 _mesa_get_format_name(src_mesaformat),
 src_bo);
-fprintf(stderr, dst: pitch %d offset %d, offset[%d x %d], format %s, 
bo %p\n,
+fprintf(stderr, dst: pitch %d offset %zd, offset[%d x %d], format %s, 
bo %p\n,
 dst_pitch, dst_offset,  dst_x_offset, dst_y_offset,
 _mesa_get_format_name(dst_mesaformat), dst_bo);
 fprintf(stderr, region: %d x %d\n, reg_width, reg_height);
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 09/21] mesa/samplerobj: Avoid crash in sampler query if texture unit is disabled

2012-06-11 Thread Pauli Nieminen
Sampler queries are so far made only for enabled texture unit. But if
any code would query sampler before checking texture unit state that
would result to NULL deference.

Making the inline helper easier to use with NULL check makes a lot sense
because compiler is likely to combine the checks for the current texture.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/main/samplerobj.h |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index 0bfda43..33da894 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -33,8 +33,10 @@ _mesa_get_samplerobj(struct gl_context *ctx, GLuint unit)
 {
if (ctx-Texture.Unit[unit].Sampler)
   return ctx-Texture.Unit[unit].Sampler;
-   else
+   else if (ctx-Texture.Unit[unit]._Current)
   return ctx-Texture.Unit[unit]._Current-Sampler;
+   else
+  return NULL;
 }
 
 
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 19/21] meta: texture rectangle textures may not have mipmaps

2012-06-11 Thread Pauli Nieminen
Avoid INVALID_OPERATION error if decompressing rectangle texture.
Setting mipmap level limits for those textures is error that must not be
hit by meta code to mislead user.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/common/meta.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index c8dd80a..6fe1fac 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3323,8 +3323,10 @@ decompress_texture_image(struct gl_context *ctx,
   const GLenum srgbSave = texObj-Sampler.sRGBDecode;
 
   /* restrict sampling to the texture level of interest */
-  _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, texImage-Level);
-  _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, texImage-Level);
+  if (target != GL_TEXTURE_RECTANGLE_ARB) {
+ _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, texImage-Level);
+ _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, texImage-Level);
+  }
   /* nearest filtering */
   _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 12/21] radeonr200: Add support for ARB_shader_object

2012-06-11 Thread Pauli Nieminen
Preparation for the mandator support of ARB_shader_object. I have tested
this patch with rv280 only. While only compile testing radeon changes.

Does someone want to run piglit tests for radeon too?

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
CC: xorg-driver-...@lists.x.org
---
 src/mesa/drivers/dri/r200/r200_tex.c |   41 --
 src/mesa/drivers/dri/r200/r200_tex.h |1 +
 src/mesa/drivers/dri/r200/r200_texstate.c|3 +-
 src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c |   16 +
 src/mesa/drivers/dri/radeon/radeon_span.c|4 ++-
 src/mesa/drivers/dri/radeon/radeon_tex.c |   27 ++
 src/mesa/drivers/dri/radeon/radeon_tex.h |1 +
 src/mesa/drivers/dri/radeon/radeon_tex_copy.c|2 +-
 src/mesa/drivers/dri/radeon/radeon_texstate.c|4 ++-
 src/mesa/drivers/dri/radeon/radeon_texture.h |4 ++-
 10 files changed, 57 insertions(+), 46 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_tex.c 
b/src/mesa/drivers/dri/r200/r200_tex.c
index fe7c977..f72cad3 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -41,6 +41,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
 #include main/simple_list.h
 #include main/teximage.h
 #include main/texobj.h
+#include main/samplerobj.h
 
 #include radeon_mipmap_tree.h
 #include r200_context.h
@@ -360,12 +361,21 @@ static void r200TexEnv( struct gl_context *ctx, GLenum 
target,
}
 }
 
+void r200TexUpdateParameters(struct gl_context *ctx, GLuint unit)
+{
+   struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
+   radeonTexObj* t = radeon_tex_obj(ctx-Texture.Unit[unit]._Current);
+
+   r200SetTexMaxAnisotropy(t , samp-MaxAnisotropy);
+   r200SetTexFilter( t, samp-MinFilter, samp-MagFilter );
+   r200SetTexWrap( t, samp-WrapS, samp-WrapT, samp-WrapR );
+   r200SetTexBorderColor( t, samp-BorderColor.f );
+}
 
 /**
  * Changes variables and flags for a state update, which will happen at the
  * next UpdateTextureState
  */
-
 static void r200TexParameter( struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj,
GLenum pname, const GLfloat *params )
@@ -379,23 +389,6 @@ static void r200TexParameter( struct gl_context *ctx, 
GLenum target,
   _mesa_lookup_enum_by_nr( pname ) );
 
switch ( pname ) {
-   case GL_TEXTURE_MIN_FILTER:
-   case GL_TEXTURE_MAG_FILTER:
-   case GL_TEXTURE_MAX_ANISOTROPY_EXT:
-  r200SetTexMaxAnisotropy( t, texObj-Sampler.MaxAnisotropy );
-  r200SetTexFilter( t, texObj-Sampler.MinFilter, 
texObj-Sampler.MagFilter );
-  break;
-
-   case GL_TEXTURE_WRAP_S:
-   case GL_TEXTURE_WRAP_T:
-   case GL_TEXTURE_WRAP_R:
-  r200SetTexWrap( t, texObj-Sampler.WrapS, texObj-Sampler.WrapT, 
texObj-Sampler.WrapR );
-  break;
-
-   case GL_TEXTURE_BORDER_COLOR:
-  r200SetTexBorderColor( t, texObj-Sampler.BorderColor.f );
-  break;
-
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_MIN_LOD:
@@ -489,6 +482,17 @@ static struct gl_texture_object 
*r200NewTextureObject(struct gl_context * ctx,
return t-base;
 }
 
+static struct gl_sampler_object *
+r200NewSamplerObject(struct gl_context *ctx, GLuint name)
+{
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);
+   struct gl_sampler_object *samp = _mesa_new_sampler_object(ctx, name);
+   if (samp) {
+  samp-MaxAnisotropy = rmesa-radeon.initialMaxAnisotropy;
+   }
+   return samp;
+}
+
 
 
 void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table 
*functions )
@@ -506,4 +510,5 @@ void r200InitTextureFuncs( radeonContextPtr radeon, struct 
dd_function_table *fu
functions-TexEnv   = r200TexEnv;
functions-TexParameter = r200TexParameter;
functions-TexGen   = r200TexGen;
+   functions-NewSamplerObject = r200NewSamplerObject;
 }
diff --git a/src/mesa/drivers/dri/r200/r200_tex.h 
b/src/mesa/drivers/dri/r200/r200_tex.h
index 756a128..725b45d 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.h
+++ b/src/mesa/drivers/dri/r200/r200_tex.h
@@ -48,6 +48,7 @@ extern void r200DestroyTexObj( r200ContextPtr rmesa, 
radeonTexObjPtr t );
 extern void r200InitTextureFuncs( radeonContextPtr radeon, struct 
dd_function_table *functions );
 
 extern void r200UpdateFragmentShader( struct gl_context *ctx );
+extern void r200TexUpdateParameters(struct gl_context *ctx, GLuint unit);
 
 extern void set_re_cntl_d3d( struct gl_context *ctx, int unit, GLboolean 
use_d3d );
 
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c 
b/src/mesa/drivers/dri/r200/r200_texstate.c
index 19e77c5..b25c611 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -1500,7 +1500,7 @@ static GLboolean r200_validate_texture(struct gl_context 
*ctx, struct gl_texture

[Mesa-dev] [PATCH 13/21] mesa/ff_shader: Fix sampler state reading

2012-06-11 Thread Pauli Nieminen
Fixed function fragment shader generator was incorrectly read texture
sampling state directly from texture object. To make sure that
ARB_sampler_object works correctly shader generator has to use the
bound sampler if one exist

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/main/ff_fragment_shader.cpp |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/ff_fragment_shader.cpp 
b/src/mesa/main/ff_fragment_shader.cpp
index 0233f38..f743ce1 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -33,6 +33,7 @@ extern C {
 #include mtypes.h
 #include main/uniforms.h
 #include main/macros.h
+#include main/samplerobj.h
 #include program/program.h
 #include program/prog_parameter.h
 #include program/prog_cache.h
@@ -428,11 +429,13 @@ static GLuint make_state_key( struct gl_context *ctx,  
struct state_key *key )
   const struct gl_texture_unit *texUnit = ctx-Texture.Unit[i];
   const struct gl_texture_object *texObj = texUnit-_Current;
   const struct gl_tex_env_combine_state *comb = texUnit-_CurrentCombine;
+  const struct gl_sampler_object *samp;
   GLenum format;
 
   if (!texUnit-_ReallyEnabled || !texUnit-Enabled)
  continue;
 
+  samp = _mesa_get_samplerobj(ctx, i);
   format = texObj-Image[0][texObj-BaseLevel]-_BaseFormat;
 
   key-unit[i].enabled = 1;
@@ -444,7 +447,7 @@ static GLuint make_state_key( struct gl_context *ctx,  
struct state_key *key )
  translate_tex_src_bit(texUnit-_ReallyEnabled);
 
   key-unit[i].shadow =
- ((texObj-Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE) 
+ ((samp-CompareMode == GL_COMPARE_R_TO_TEXTURE) 
   ((format == GL_DEPTH_COMPONENT) || 
(format == GL_DEPTH_STENCIL_EXT)));
 
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 10/21] nouveau: Add support for ARB_sampler_object

2012-06-11 Thread Pauli Nieminen
ARB_sampler_object is very simple software only extension to support.
I want to make it mandator extension for Mesa drivers to allow meta
module to use it.

This patch add support for the extension to nouveau. It is completely
untested search and replace patch. I hope someone with old NV hardware
could give a try that there is no regressions and ARB_sampler_object
tests passes.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
CC: nouv...@lists.freedesktop.org
---
 src/mesa/drivers/dri/nouveau/nv04_state_tex.c |   22 --
 src/mesa/drivers/dri/nouveau/nv10_state_tex.c |   23 +--
 src/mesa/drivers/dri/nouveau/nv20_state_tex.c |   25 ++---
 3 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c 
b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
index 807e2f3..e4d695a 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
@@ -32,6 +32,7 @@
 #include nv_object.xml.h
 #include nv04_3d.xml.h
 #include nv04_driver.h
+#include main/samplerobj.h
 
 static uint32_t
 get_tex_format(struct gl_texture_image *ti)
@@ -67,6 +68,7 @@ nv04_emit_tex_obj(struct gl_context *ctx, int emit)
if (ctx-Texture.Unit[i]._ReallyEnabled) {
struct gl_texture_object *t = ctx-Texture.Unit[i]._Current;
struct gl_texture_image *ti = t-Image[0][t-BaseLevel];
+   const struct gl_sampler_object *sa = _mesa_get_samplerobj(ctx, 
i);
int lod_max = 1, lod_bias = 0;
 
if (!nouveau_texture_validate(ctx, t))
@@ -74,26 +76,26 @@ nv04_emit_tex_obj(struct gl_context *ctx, int emit)
 
s = to_nouveau_texture(t)-surfaces[t-BaseLevel];
 
-   if (t-Sampler.MinFilter != GL_NEAREST 
-   t-Sampler.MinFilter != GL_LINEAR) {
-   lod_max = CLAMP(MIN2(t-Sampler.MaxLod, t-_MaxLambda),
+   if (sa-MinFilter != GL_NEAREST 
+   sa-MinFilter != GL_LINEAR) {
+   lod_max = CLAMP(MIN2(sa-MaxLod, t-_MaxLambda),
0, 15) + 1;
 
lod_bias = CLAMP(ctx-Texture.Unit[i].LodBias +
-t-Sampler.LodBias, -16, 15) * 8;
+sa-LodBias, -16, 15) * 8;
}
 
-   format |= nvgl_wrap_mode(t-Sampler.WrapT)  28 |
-   nvgl_wrap_mode(t-Sampler.WrapS)  24 |
+   format |= nvgl_wrap_mode(sa-WrapT)  28 |
+   nvgl_wrap_mode(sa-WrapS)  24 |
ti-HeightLog2  20 |
ti-WidthLog2  16 |
lod_max  12 |
get_tex_format(ti);
 
-   filter |= log2i(t-Sampler.MaxAnisotropy)  31 |
-   nvgl_filter_mode(t-Sampler.MagFilter)  28 |
-   log2i(t-Sampler.MaxAnisotropy)  27 |
-   nvgl_filter_mode(t-Sampler.MinFilter)  24 |
+   filter |= log2i(sa-MaxAnisotropy)  31 |
+   nvgl_filter_mode(sa-MagFilter)  28 |
+   log2i(sa-MaxAnisotropy)  27 |
+   nvgl_filter_mode(sa-MinFilter)  24 |
(lod_bias  0xff)  16;
 
} else {
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c 
b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
index b467bb3..3b76d66 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
@@ -31,6 +31,7 @@
 #include nv10_3d.xml.h
 #include nouveau_util.h
 #include nv10_driver.h
+#include main/samplerobj.h
 
 void
 nv10_emit_tex_gen(struct gl_context *ctx, int emit)
@@ -159,6 +160,7 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit)
struct gl_texture_object *t;
struct nouveau_surface *s;
struct gl_texture_image *ti;
+   const struct gl_sampler_object *sa;
uint32_t tx_format, tx_filter, tx_enable;
 
PUSH_RESET(push, BUFCTX_TEX(i));
@@ -172,22 +174,23 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit)
t = ctx-Texture.Unit[i]._Current;
s = to_nouveau_texture(t)-surfaces[t-BaseLevel];
ti = t-Image[0][t-BaseLevel];
+   sa = _mesa_get_samplerobj(ctx, i);
 
if (!nouveau_texture_validate(ctx, t))
return;
 
/* Recompute the texturing registers. */
-   tx_format = nvgl_wrap_mode(t-Sampler.WrapT)  28
-   | nvgl_wrap_mode(t-Sampler.WrapS)  24
+   tx_format = nvgl_wrap_mode(sa-WrapT)  28
+   | nvgl_wrap_mode(sa-WrapS)  24
| ti-HeightLog2  20
| ti-WidthLog2  16
| 5  4 | 1  12;
 
-   tx_filter = nvgl_filter_mode(t-Sampler.MagFilter)  28
-   | nvgl_filter_mode(t-Sampler.MinFilter)  24;
+   tx_filter = 

[Mesa-dev] [PATCH 11/21] radeonr200: Add support for ARB_shader_object

2012-06-11 Thread Pauli Nieminen
Preparation for the mandator support of ARB_shader_object.

I have tested this patch with rv280 only. While only compile testing
radeon changes.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/r200/r200_tex.c |   41 --
 src/mesa/drivers/dri/r200/r200_tex.h |1 +
 src/mesa/drivers/dri/r200/r200_texstate.c|3 +-
 src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c |   16 +
 src/mesa/drivers/dri/radeon/radeon_span.c|4 ++-
 src/mesa/drivers/dri/radeon/radeon_tex.c |   27 ++
 src/mesa/drivers/dri/radeon/radeon_tex.h |1 +
 src/mesa/drivers/dri/radeon/radeon_tex_copy.c|2 +-
 src/mesa/drivers/dri/radeon/radeon_texstate.c|4 ++-
 src/mesa/drivers/dri/radeon/radeon_texture.h |4 ++-
 10 files changed, 57 insertions(+), 46 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_tex.c 
b/src/mesa/drivers/dri/r200/r200_tex.c
index fe7c977..f72cad3 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -41,6 +41,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
 #include main/simple_list.h
 #include main/teximage.h
 #include main/texobj.h
+#include main/samplerobj.h
 
 #include radeon_mipmap_tree.h
 #include r200_context.h
@@ -360,12 +361,21 @@ static void r200TexEnv( struct gl_context *ctx, GLenum 
target,
}
 }
 
+void r200TexUpdateParameters(struct gl_context *ctx, GLuint unit)
+{
+   struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
+   radeonTexObj* t = radeon_tex_obj(ctx-Texture.Unit[unit]._Current);
+
+   r200SetTexMaxAnisotropy(t , samp-MaxAnisotropy);
+   r200SetTexFilter( t, samp-MinFilter, samp-MagFilter );
+   r200SetTexWrap( t, samp-WrapS, samp-WrapT, samp-WrapR );
+   r200SetTexBorderColor( t, samp-BorderColor.f );
+}
 
 /**
  * Changes variables and flags for a state update, which will happen at the
  * next UpdateTextureState
  */
-
 static void r200TexParameter( struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj,
GLenum pname, const GLfloat *params )
@@ -379,23 +389,6 @@ static void r200TexParameter( struct gl_context *ctx, 
GLenum target,
   _mesa_lookup_enum_by_nr( pname ) );
 
switch ( pname ) {
-   case GL_TEXTURE_MIN_FILTER:
-   case GL_TEXTURE_MAG_FILTER:
-   case GL_TEXTURE_MAX_ANISOTROPY_EXT:
-  r200SetTexMaxAnisotropy( t, texObj-Sampler.MaxAnisotropy );
-  r200SetTexFilter( t, texObj-Sampler.MinFilter, 
texObj-Sampler.MagFilter );
-  break;
-
-   case GL_TEXTURE_WRAP_S:
-   case GL_TEXTURE_WRAP_T:
-   case GL_TEXTURE_WRAP_R:
-  r200SetTexWrap( t, texObj-Sampler.WrapS, texObj-Sampler.WrapT, 
texObj-Sampler.WrapR );
-  break;
-
-   case GL_TEXTURE_BORDER_COLOR:
-  r200SetTexBorderColor( t, texObj-Sampler.BorderColor.f );
-  break;
-
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_MIN_LOD:
@@ -489,6 +482,17 @@ static struct gl_texture_object 
*r200NewTextureObject(struct gl_context * ctx,
return t-base;
 }
 
+static struct gl_sampler_object *
+r200NewSamplerObject(struct gl_context *ctx, GLuint name)
+{
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);
+   struct gl_sampler_object *samp = _mesa_new_sampler_object(ctx, name);
+   if (samp) {
+  samp-MaxAnisotropy = rmesa-radeon.initialMaxAnisotropy;
+   }
+   return samp;
+}
+
 
 
 void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table 
*functions )
@@ -506,4 +510,5 @@ void r200InitTextureFuncs( radeonContextPtr radeon, struct 
dd_function_table *fu
functions-TexEnv   = r200TexEnv;
functions-TexParameter = r200TexParameter;
functions-TexGen   = r200TexGen;
+   functions-NewSamplerObject = r200NewSamplerObject;
 }
diff --git a/src/mesa/drivers/dri/r200/r200_tex.h 
b/src/mesa/drivers/dri/r200/r200_tex.h
index 756a128..725b45d 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.h
+++ b/src/mesa/drivers/dri/r200/r200_tex.h
@@ -48,6 +48,7 @@ extern void r200DestroyTexObj( r200ContextPtr rmesa, 
radeonTexObjPtr t );
 extern void r200InitTextureFuncs( radeonContextPtr radeon, struct 
dd_function_table *functions );
 
 extern void r200UpdateFragmentShader( struct gl_context *ctx );
+extern void r200TexUpdateParameters(struct gl_context *ctx, GLuint unit);
 
 extern void set_re_cntl_d3d( struct gl_context *ctx, int unit, GLboolean 
use_d3d );
 
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c 
b/src/mesa/drivers/dri/r200/r200_texstate.c
index 19e77c5..b25c611 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -1500,7 +1500,7 @@ static GLboolean r200_validate_texture(struct gl_context 
*ctx, struct gl_texture
r200ContextPtr rmesa = R200_CONTEXT(ctx);
radeonTexObj *t = radeon_tex_obj(texObj);
 
-   

[Mesa-dev] [PATCH 11/21] radeon: Fix printf format not to warn in 64bit

2012-06-11 Thread Pauli Nieminen
When I build tested radeon changes I noticed two warnings about format
size missmatch in 64bit. I decided to clean them to make relevant
compiler warnings easier to spot.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
CC: xorg-driver-...@lists.x.org
---
 src/mesa/drivers/dri/radeon/radeon_blit.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c 
b/src/mesa/drivers/dri/radeon/radeon_blit.c
index 4233221..80b5346 100644
--- a/src/mesa/drivers/dri/radeon/radeon_blit.c
+++ b/src/mesa/drivers/dri/radeon/radeon_blit.c
@@ -390,13 +390,13 @@ unsigned r100_blit(struct gl_context *ctx,
 }
 
 if (0) {
-fprintf(stderr, src: size [%d x %d], pitch %d, offset %d 
+fprintf(stderr, src: size [%d x %d], pitch %d, offset %zd 
 offset [%d x %d], format %s, bo %p\n,
 src_width, src_height, src_pitch, src_offset,
 src_x_offset, src_y_offset,
 _mesa_get_format_name(src_mesaformat),
 src_bo);
-fprintf(stderr, dst: pitch %d offset %d, offset[%d x %d], format %s, 
bo %p\n,
+fprintf(stderr, dst: pitch %d offset %zd, offset[%d x %d], format %s, 
bo %p\n,
 dst_pitch, dst_offset,  dst_x_offset, dst_y_offset,
 _mesa_get_format_name(dst_mesaformat), dst_bo);
 fprintf(stderr, region: %d x %d\n, reg_width, reg_height);
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 14/21] mesa/program: Use sampler object state if present

2012-06-11 Thread Pauli Nieminen
CompareFailValue is part of Sampler state that needs to be read from
bound sampler object if present.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/program/prog_statevars.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/program/prog_statevars.c 
b/src/mesa/program/prog_statevars.c
index 98ab9d0..7ab5773 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -36,6 +36,7 @@
 #include main/mtypes.h
 #include prog_statevars.h
 #include prog_parameter.h
+#include main/samplerobj.h
 
 
 /**
@@ -555,11 +556,13 @@ _mesa_fetch_state(struct gl_context *ctx, const 
gl_state_index state[],
 const int unit = (int) state[2];
 const struct gl_texture_object *texObj
= ctx-Texture.Unit[unit]._Current;
+const struct gl_sampler_object *samp =
+   _mesa_get_samplerobj(ctx, unit);
 if (texObj) {
value[0] =
value[1] =
value[2] =
-   value[3] = texObj-Sampler.CompareFailValue;
+   value[3] = samp-CompareFailValue;
 }
  }
  return;
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 17/21] mesa/samplerobj: Allow meta module to call sampler functions

2012-06-11 Thread Pauli Nieminen
To allow meta module to use sample objects mesa GL functions need to be
visible and linkable for meta module.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/main/samplerobj.c |8 
 src/mesa/main/samplerobj.h |   11 +++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index f276296..f2d99a0 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -160,7 +160,7 @@ _mesa_delete_sampler_object(struct gl_context *ctx,
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_GenSamplers(GLsizei count, GLuint *samplers)
 {
GET_CURRENT_CONTEXT(ctx);
@@ -192,7 +192,7 @@ _mesa_GenSamplers(GLsizei count, GLuint *samplers)
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_DeleteSamplers(GLsizei count, const GLuint *samplers)
 {
GET_CURRENT_CONTEXT(ctx);
@@ -242,7 +242,7 @@ _mesa_IsSampler(GLuint sampler)
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_BindSampler(GLuint unit, GLuint sampler)
 {
struct gl_sampler_object *sampObj;
@@ -601,7 +601,7 @@ set_sampler_srgb_decode(struct gl_context *ctx,
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
 {
struct gl_sampler_object *sampObj;
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index 33da894..e70ee48 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -79,5 +79,16 @@ _mesa_init_sampler_object_functions(struct dd_function_table 
*driver);
 extern void
 _mesa_init_sampler_object_dispatch(struct _glapi_table *disp);
 
+extern void GLAPIENTRY
+_mesa_BindSampler(GLuint unit, GLuint sampler);
+
+extern void GLAPIENTRY
+_mesa_GenSamplers(GLsizei count, GLuint *samplers);
+
+extern void GLAPIENTRY
+_mesa_DeleteSamplers(GLsizei count, const GLuint *samplers);
+
+extern void GLAPIENTRY
+_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param);
 
 #endif /* SAMPLEROBJ_H */
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 15/21] mesa: Make ARB_sampler_objects mandator

2012-06-11 Thread Pauli Nieminen
To allow meta acceleration operations to use sampler objects the
ARB_sampler_objects extension needs to be mandator for all drivers.
Because the extension doesn't have any hardware dependencies it is
trivial to implement.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/dri/intel/intel_extensions.c |1 -
 src/mesa/main/extensions.c|2 +-
 src/mesa/main/get.c   |7 +--
 src/mesa/main/mtypes.h|1 -
 src/mesa/main/version.c   |2 +-
 src/mesa/state_tracker/st_extensions.c|1 -
 6 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c 
b/src/mesa/drivers/dri/intel/intel_extensions.c
index 29da36c..7c9d9a8 100755
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -49,7 +49,6 @@ intelInitExtensions(struct gl_context *ctx)
ctx-Extensions.ARB_half_float_pixel = true;
ctx-Extensions.ARB_map_buffer_range = true;
ctx-Extensions.ARB_point_sprite = true;
-   ctx-Extensions.ARB_sampler_objects = true;
ctx-Extensions.ARB_shader_objects = true;
ctx-Extensions.ARB_shading_language_100 = true;
ctx-Extensions.ARB_sync = true;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 2688f7a..485782f 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -110,7 +110,7 @@ static const struct extension extension_table[] = {
{ GL_ARB_point_sprite,o(ARB_point_sprite),
GL, 2003 },
{ GL_ARB_provoking_vertex,o(EXT_provoking_vertex),
GL, 2009 },
{ GL_ARB_robustness,  o(dummy_true),  
GL, 2010 },
-   { GL_ARB_sampler_objects, o(ARB_sampler_objects), 
GL, 2009 },
+   { GL_ARB_sampler_objects, o(dummy_true),  
GL, 2009 },
{ GL_ARB_seamless_cube_map,   o(ARB_seamless_cube_map),   
GL, 2009 },
{ GL_ARB_shader_bit_encoding, o(ARB_shader_bit_encoding), 
GL, 2010 },
{ GL_ARB_shader_objects,  o(ARB_shader_objects),  
GL, 2002 },
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 55dc205..f9f18fb 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -283,11 +283,6 @@ static const int extra_GLSL_130[] = {
EXTRA_END
 };
 
-static const int extra_ARB_sampler_objects[] = {
-   EXT(ARB_sampler_objects),
-   EXTRA_END
-};
-
 
 EXTRA_EXT(ARB_ES2_compatibility);
 EXTRA_EXT(ARB_texture_cube_map);
@@ -1270,7 +1265,7 @@ static const struct value_desc values[] = {
 
/* GL_ARB_sampler_objects / GL 3.3 */
{ GL_SAMPLER_BINDING,
- LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, extra_ARB_sampler_objects },
+ LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, NO_EXTRA },
 
/* GL 3.0 */
{ GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 },
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a08a214..e95cb29 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2893,7 +2893,6 @@ struct gl_extensions
GLboolean ARB_occlusion_query;
GLboolean ARB_occlusion_query2;
GLboolean ARB_point_sprite;
-   GLboolean ARB_sampler_objects;
GLboolean ARB_seamless_cube_map;
GLboolean ARB_shader_bit_encoding;
GLboolean ARB_shader_objects;
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index efaaf58..8aa5a64 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -170,12 +170,12 @@ compute_version(struct gl_context *ctx)
   ctx-Extensions.ARB_explicit_attrib_location 
   ctx-Extensions.ARB_instanced_arrays 
   ctx-Extensions.ARB_occlusion_query2 
-  ctx-Extensions.ARB_sampler_objects 
   ctx-Extensions.ARB_shader_bit_encoding 
   ctx-Extensions.ARB_texture_rgb10_a2ui 
   ctx-Extensions.ARB_timer_query 
   ctx-Extensions.ARB_vertex_type_2_10_10_10_rev 
   ctx-Extensions.EXT_texture_swizzle);
+  /* ARB_sampler_objects is always enabled in mesa 
*/
 
if (ver_3_3) {
   major = 3;
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index a9071f5..2428085 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -483,7 +483,6 @@ void st_init_extensions(struct st_context *st)
ctx-Extensions.ARB_half_float_pixel = GL_TRUE;

[Mesa-dev] [PATCH 09/21] nouveau: Add support for ARB_sampler_object

2012-06-11 Thread Pauli Nieminen
ARB_sampler_object is very simple software only extension to support.
I want to make it mandator extension for Mesa drivers to allow meta
module to use it.

This patch add support for the extension to nouveau. It is completely
untested search and replace patch. I hope someone with old NV hardware
could give a try that there is no regressions and ARB_sampler_object
tests passes.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
CC: nouv...@lists.freedesktop.org
---
 src/mesa/drivers/dri/nouveau/nv04_state_tex.c |   22 --
 src/mesa/drivers/dri/nouveau/nv10_state_tex.c |   23 +--
 src/mesa/drivers/dri/nouveau/nv20_state_tex.c |   25 ++---
 3 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c 
b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
index 807e2f3..e4d695a 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
@@ -32,6 +32,7 @@
 #include nv_object.xml.h
 #include nv04_3d.xml.h
 #include nv04_driver.h
+#include main/samplerobj.h
 
 static uint32_t
 get_tex_format(struct gl_texture_image *ti)
@@ -67,6 +68,7 @@ nv04_emit_tex_obj(struct gl_context *ctx, int emit)
if (ctx-Texture.Unit[i]._ReallyEnabled) {
struct gl_texture_object *t = ctx-Texture.Unit[i]._Current;
struct gl_texture_image *ti = t-Image[0][t-BaseLevel];
+   const struct gl_sampler_object *sa = _mesa_get_samplerobj(ctx, 
i);
int lod_max = 1, lod_bias = 0;
 
if (!nouveau_texture_validate(ctx, t))
@@ -74,26 +76,26 @@ nv04_emit_tex_obj(struct gl_context *ctx, int emit)
 
s = to_nouveau_texture(t)-surfaces[t-BaseLevel];
 
-   if (t-Sampler.MinFilter != GL_NEAREST 
-   t-Sampler.MinFilter != GL_LINEAR) {
-   lod_max = CLAMP(MIN2(t-Sampler.MaxLod, t-_MaxLambda),
+   if (sa-MinFilter != GL_NEAREST 
+   sa-MinFilter != GL_LINEAR) {
+   lod_max = CLAMP(MIN2(sa-MaxLod, t-_MaxLambda),
0, 15) + 1;
 
lod_bias = CLAMP(ctx-Texture.Unit[i].LodBias +
-t-Sampler.LodBias, -16, 15) * 8;
+sa-LodBias, -16, 15) * 8;
}
 
-   format |= nvgl_wrap_mode(t-Sampler.WrapT)  28 |
-   nvgl_wrap_mode(t-Sampler.WrapS)  24 |
+   format |= nvgl_wrap_mode(sa-WrapT)  28 |
+   nvgl_wrap_mode(sa-WrapS)  24 |
ti-HeightLog2  20 |
ti-WidthLog2  16 |
lod_max  12 |
get_tex_format(ti);
 
-   filter |= log2i(t-Sampler.MaxAnisotropy)  31 |
-   nvgl_filter_mode(t-Sampler.MagFilter)  28 |
-   log2i(t-Sampler.MaxAnisotropy)  27 |
-   nvgl_filter_mode(t-Sampler.MinFilter)  24 |
+   filter |= log2i(sa-MaxAnisotropy)  31 |
+   nvgl_filter_mode(sa-MagFilter)  28 |
+   log2i(sa-MaxAnisotropy)  27 |
+   nvgl_filter_mode(sa-MinFilter)  24 |
(lod_bias  0xff)  16;
 
} else {
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c 
b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
index b467bb3..3b76d66 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
@@ -31,6 +31,7 @@
 #include nv10_3d.xml.h
 #include nouveau_util.h
 #include nv10_driver.h
+#include main/samplerobj.h
 
 void
 nv10_emit_tex_gen(struct gl_context *ctx, int emit)
@@ -159,6 +160,7 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit)
struct gl_texture_object *t;
struct nouveau_surface *s;
struct gl_texture_image *ti;
+   const struct gl_sampler_object *sa;
uint32_t tx_format, tx_filter, tx_enable;
 
PUSH_RESET(push, BUFCTX_TEX(i));
@@ -172,22 +174,23 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit)
t = ctx-Texture.Unit[i]._Current;
s = to_nouveau_texture(t)-surfaces[t-BaseLevel];
ti = t-Image[0][t-BaseLevel];
+   sa = _mesa_get_samplerobj(ctx, i);
 
if (!nouveau_texture_validate(ctx, t))
return;
 
/* Recompute the texturing registers. */
-   tx_format = nvgl_wrap_mode(t-Sampler.WrapT)  28
-   | nvgl_wrap_mode(t-Sampler.WrapS)  24
+   tx_format = nvgl_wrap_mode(sa-WrapT)  28
+   | nvgl_wrap_mode(sa-WrapS)  24
| ti-HeightLog2  20
| ti-WidthLog2  16
| 5  4 | 1  12;
 
-   tx_filter = nvgl_filter_mode(t-Sampler.MagFilter)  28
-   | nvgl_filter_mode(t-Sampler.MinFilter)  24;
+   tx_filter = 

[Mesa-dev] [PATCH 21/21] meta: Use sampler object in framebuffer blit

2012-06-11 Thread Pauli Nieminen
Framebuffer blit needs to setup texture sampling to match application
requested blit operation. Sampler object can be used to avoid changes to
texture object. But caching sampler object doesn't make much sense when
we need to synamically change it based on filtering parameters.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/common/meta.c |   31 ++-
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 83ae3d9..14e177b 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1314,15 +1314,13 @@ blitframebuffer_texture(struct gl_context *ctx,
   if (readAtt  readAtt-Texture) {
  const struct gl_texture_object *texObj = readAtt-Texture;
  const GLuint srcLevel = readAtt-TextureLevel;
- const GLenum minFilterSave = texObj-Sampler.MinFilter;
- const GLenum magFilterSave = texObj-Sampler.MagFilter;
  const GLint baseLevelSave = texObj-BaseLevel;
  const GLint maxLevelSave = texObj-MaxLevel;
- const GLenum wrapSSave = texObj-Sampler.WrapS;
- const GLenum wrapTSave = texObj-Sampler.WrapT;
- const GLenum srgbSave = texObj-Sampler.sRGBDecode;
  const GLenum fbo_srgb_save = ctx-Color.sRGBEnabled;
  const GLenum target = texObj-Target;
+ GLuint sampler, samplerSave =
+ctx-Texture.Unit[ctx-Texture.CurrentUnit].Sampler ?
+ctx-Texture.Unit[ctx-Texture.CurrentUnit].Sampler-Name : 0;
 
  if (drawAtt-Texture == readAtt-Texture) {
 /* Can't use same texture as both the source and dest.  We need
@@ -1337,6 +1335,9 @@ blitframebuffer_texture(struct gl_context *ctx,
 return mask;
  }
 
+ _mesa_GenSamplers(1, sampler);
+ _mesa_BindSampler(ctx-Texture.CurrentUnit, sampler);
+
  /*
  printf(Blit from texture!\n);
  printf(  srcAtt %p  dstAtt %p\n, readAtt, drawAtt);
@@ -1345,18 +1346,18 @@ blitframebuffer_texture(struct gl_context *ctx,
 
  /* Prepare src texture state */
  _mesa_BindTexture(target, texObj-Name);
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, filter);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, filter);
  if (target != GL_TEXTURE_RECTANGLE_ARB) {
 _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
 _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
  }
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
 /* Always do our blits with no sRGB decode or encode.*/
 if (ctx-Extensions.EXT_texture_sRGB_decode) {
-   _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
+   _mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
GL_SKIP_DECODE_EXT);
 }
  if (ctx-Extensions.EXT_framebuffer_sRGB) {
@@ -1416,21 +1417,17 @@ blitframebuffer_texture(struct gl_context *ctx,
  /* Restore texture object state, the texture binding will
   * be restored by _mesa_meta_end().
   */
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
  if (target != GL_TEXTURE_RECTANGLE_ARB) {
 _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
 _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
  }
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
-if (ctx-Extensions.EXT_texture_sRGB_decode) {
-   _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave);
-}
 if (ctx-Extensions.EXT_framebuffer_sRGB  fbo_srgb_save) {
_mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_TRUE);
 }
 
+ _mesa_BindSampler(ctx-Texture.CurrentUnit, samplerSave);
+ _mesa_DeleteSamplers(1, sampler);
+
  /* Done with color buffer */
  mask = ~GL_COLOR_BUFFER_BIT;
   }
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 00/21] ARB_sampler_object fixes and minor clean up

2012-06-11 Thread Pauli Nieminen
I noticed following issues when I was reading texture management code in
mesa core.

The first ycbcr unpack patch might be actually fixing deadcode. But I
don't know yet enough about unpack code to know for sure. But at least
glGetTexImage has special case get_tex_ycbcr.

Following TexImage changes aim to make driver interfaces easier to
understand by removing duplicate information. For me that makes a lot more
clearer what is expected to happen inside driver hook.

Most of changes are fixes issues were sampler state is read from
texture object while bound sampler object should be shadowing the texture
state. Those changes changes mesa code to use _mesa_get_samplerobj to
select sampler state.

Also I changes meta code to use sampler state to avoid possible issues that
we would have sampler object shadowing texture state when running meta
code. For that I needed to make ARB_sampler_object mandator extension for
all mesa drivers.

I didn't check bugzilla if there is any bugs reported about sampler objects
that could be fixed with these patches.

I run regression test for i965 (ILK), llvm pipe and r200. Nouveau changes
would still need testing and check from Nouveau developers to verify that
sampler state gets uploaded when when a new sampler object is bound. Piglit
ARB_sampler_object test should be enough to verify that.

Pauli Nieminen (21):
  mesa/format_unpack: Fix YCBCR unpack
  mesa: Remove unnecessary parameters from TexImage
  mesa: Remove unnecessary parameters from AllocTextureImageBuffer
  mesa: Remove unnecessary parameters CompressedTexImage
  mesa: Move DepthMode to texture object
  mesa/macros: Add ARRAY_SIZE helper macro core mesa
  mesa/samplerobj: Support EXT_texture_sRGB_decode
  mesa/samplerobj: Avoid crash in sampler query if texture unit is
disabled
  nouveau: Add support for ARB_sampler_object
  radeon: Fix printf format not to warn in 64bit
  radeonr200: Add support for ARB_shader_object
  mesa: Check index buffer offset in DrawElements
  mesa/ff_shader: Fix sampler state reading
  mesa/program: Use sampler object state if present
  mesa: Make ARB_sampler_objects mandator
  swrast: Support sampler object for texture fetching state
  mesa/samplerobj: Allow meta module to call sampler functions
  meta: Use sampler object for mipmap generation
  meta: texture rectangle textures may not have mipmaps
  meta: Add sampler object to texture decompression
  meta: Use sampler object in framebuffer blit

 src/mesa/drivers/common/meta.c|  134 ++--
 src/mesa/drivers/dri/i915/i915_texstate.c |2 +-
 src/mesa/drivers/dri/i965/brw_wm.c|2 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  |2 +-
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |2 +-
 src/mesa/drivers/dri/intel/intel_context.h|3 +-
 src/mesa/drivers/dri/intel/intel_extensions.c |1 -
 src/mesa/drivers/dri/intel/intel_tex.c|   10 +-
 src/mesa/drivers/dri/intel/intel_tex_image.c  |   23 +-
 src/mesa/drivers/dri/nouveau/nouveau_texture.c|   23 +-
 src/mesa/drivers/dri/nouveau/nv04_state_tex.c |   22 +-
 src/mesa/drivers/dri/nouveau/nv10_state_tex.c |   23 +-
 src/mesa/drivers/dri/nouveau/nv20_state_tex.c |   25 +-
 src/mesa/drivers/dri/r200/r200_tex.c  |   41 +-
 src/mesa/drivers/dri/r200/r200_tex.h  |1 +
 src/mesa/drivers/dri/r200/r200_texstate.c |3 +-
 src/mesa/drivers/dri/radeon/radeon_blit.c |4 +-
 src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c  |   16 +-
 src/mesa/drivers/dri/radeon/radeon_screen.c   |2 -
 src/mesa/drivers/dri/radeon/radeon_span.c |4 +-
 src/mesa/drivers/dri/radeon/radeon_tex.c  |   27 +-
 src/mesa/drivers/dri/radeon/radeon_tex.h  |1 +
 src/mesa/drivers/dri/radeon/radeon_tex_copy.c |2 +-
 src/mesa/drivers/dri/radeon/radeon_texstate.c |4 +-
 src/mesa/drivers/dri/radeon/radeon_texture.c  |   38 +-
 src/mesa/drivers/dri/radeon/radeon_texture.h  |4 +-
 src/mesa/main/api_validate.c  |3 +-
 src/mesa/main/attrib.c|2 +-
 src/mesa/main/dd.h|9 +-
 src/mesa/main/extensions.c|2 +-
 src/mesa/main/ff_fragment_shader.cpp  |5 +-
 src/mesa/main/format_unpack.c |  102 +--
 src/mesa/main/get.c   |7 +-
 src/mesa/main/macros.h|3 +
 src/mesa/main/mipmap.c|3 +-
 src/mesa/main/mtypes.h|7 +-
 src/mesa/main/samplerobj.c|   66 +-
 src/mesa/main/samplerobj.h|   15 +-
 src/mesa/main/teximage.c  |   13 +-
 src/mesa/main/texobj.c|7 +-
 src/mesa/main/texparam.c  |8 +-
 src/mesa/main/texstate.c 

[Mesa-dev] [PATCH 20/21] meta: Add sampler object to texture decompression

2012-06-11 Thread Pauli Nieminen
Sampler objects can be used to shadow texture object state without
modifying original application state. Decompression path feels a bit
like path where caching shouldn't happen. But as everything else is
cached already I decided to cache sampler state too.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/common/meta.c |   45 +---
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 6fe1fac..83ae3d9 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -285,7 +285,7 @@ struct gen_mipmap_state
 struct decompress_state
 {
GLuint ArrayObj;
-   GLuint VBO, FBO, RBO;
+   GLuint VBO, FBO, RBO, Sampler;
GLint Width, Height;
 };
 
@@ -3222,6 +3222,7 @@ decompress_texture_image(struct gl_context *ctx,
struct vertex verts[4];
GLuint fboDrawSave, fboReadSave;
GLuint rbSave;
+   GLuint samplerSave;
 
if (slice  0) {
   assert(target == GL_TEXTURE_3D ||
@@ -3242,6 +3243,9 @@ decompress_texture_image(struct gl_context *ctx,
 
_mesa_meta_begin(ctx, MESA_META_ALL  ~MESA_META_PIXEL_STORE);
 
+   samplerSave = ctx-Texture.Unit[ctx-Texture.CurrentUnit].Sampler ?
+ ctx-Texture.Unit[ctx-Texture.CurrentUnit].Sampler-Name : 0;
+
/* Create/bind FBO/renderbuffer */
if (decompress-FBO == 0) {
   _mesa_GenFramebuffersEXT(1, decompress-FBO);
@@ -3289,6 +3293,22 @@ decompress_texture_image(struct gl_context *ctx,
   _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, decompress-VBO);
}
 
+   if (!decompress-Sampler) {
+  _mesa_GenSamplers(1, decompress-Sampler);
+  _mesa_BindSampler(ctx-Texture.CurrentUnit, decompress-Sampler);
+  /* nearest filtering */
+  _mesa_SamplerParameteri(decompress-Sampler, GL_TEXTURE_MIN_FILTER, 
GL_NEAREST);
+  _mesa_SamplerParameteri(decompress-Sampler, GL_TEXTURE_MAG_FILTER, 
GL_NEAREST);
+  /* No sRGB decode or encode.*/
+  if (ctx-Extensions.EXT_texture_sRGB_decode) {
+ _mesa_SamplerParameteri(decompress-Sampler, 
GL_TEXTURE_SRGB_DECODE_EXT,
+ GL_SKIP_DECODE_EXT);
+  }
+
+   } else {
+  _mesa_BindSampler(ctx-Texture.CurrentUnit, decompress-Sampler);
+   }
+
setup_texture_coords(faceTarget, slice, width, height,
 verts[0].tex,
 verts[1].tex,
@@ -3314,28 +3334,15 @@ decompress_texture_image(struct gl_context *ctx,
 
{
   /* save texture object state */
-  const GLenum minFilterSave = texObj-Sampler.MinFilter;
-  const GLenum magFilterSave = texObj-Sampler.MagFilter;
   const GLint baseLevelSave = texObj-BaseLevel;
   const GLint maxLevelSave = texObj-MaxLevel;
-  const GLenum wrapSSave = texObj-Sampler.WrapS;
-  const GLenum wrapTSave = texObj-Sampler.WrapT;
-  const GLenum srgbSave = texObj-Sampler.sRGBDecode;
 
   /* restrict sampling to the texture level of interest */
   if (target != GL_TEXTURE_RECTANGLE_ARB) {
  _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, texImage-Level);
  _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, texImage-Level);
   }
-  /* nearest filtering */
-  _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-  _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
-  /* No sRGB decode or encode.*/
-  if (ctx-Extensions.EXT_texture_sRGB_decode) {
- _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
- GL_SKIP_DECODE_EXT);
-  }
   if (ctx-Extensions.EXT_framebuffer_sRGB) {
  _mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE);
   }
@@ -3346,17 +3353,11 @@ decompress_texture_image(struct gl_context *ctx,
   /* Restore texture object state, the texture binding will
* be restored by _mesa_meta_end().
*/
-  _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
-  _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
   if (target != GL_TEXTURE_RECTANGLE_ARB) {
  _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
  _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
   }
-  _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
-  _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
-  if (ctx-Extensions.EXT_texture_sRGB_decode) {
- _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave);
-  }
+
}
 
/* read pixels from renderbuffer */
@@ -3384,6 +3385,8 @@ decompress_texture_image(struct gl_context *ctx,
/* disable texture unit */
_mesa_set_enable(ctx, target, GL_FALSE);
 
+   _mesa_BindSampler(ctx-Texture.CurrentUnit, samplerSave);
+
_mesa_meta_end(ctx);
 
/* restore fbo bindings */
-- 
1.7.9.5

___
mesa-dev mailing list

[Mesa-dev] [PATCH 18/21] meta: Use sampler object for mipmap generation

2012-06-11 Thread Pauli Nieminen
Sampler objects are perfect for meta operations.Sampler object
is separate state object that shadows the sampling state in texture
object. With sampler object mipmap can maintain same sampling state for
all subsequent generation requests.

Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
---
 src/mesa/drivers/common/meta.c |   52 +---
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 8d7e901..c8dd80a 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -69,6 +69,7 @@
 #include main/uniforms.h
 #include main/varray.h
 #include main/viewport.h
+#include main/samplerobj.h
 #include program/program.h
 #include swrast/swrast.h
 #include drivers/common/meta.h
@@ -274,6 +275,7 @@ struct gen_mipmap_state
GLuint ArrayObj;
GLuint VBO;
GLuint FBO;
+   GLuint Sampler;
 };
 
 
@@ -2853,14 +2855,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum 
target,
struct vertex verts[4];
const GLuint baseLevel = texObj-BaseLevel;
const GLuint maxLevel = texObj-MaxLevel;
-   const GLenum minFilterSave = texObj-Sampler.MinFilter;
-   const GLenum magFilterSave = texObj-Sampler.MagFilter;
const GLint maxLevelSave = texObj-MaxLevel;
const GLboolean genMipmapSave = texObj-GenerateMipmap;
-   const GLenum wrapSSave = texObj-Sampler.WrapS;
-   const GLenum wrapTSave = texObj-Sampler.WrapT;
-   const GLenum wrapRSave = texObj-Sampler.WrapR;
-   const GLenum srgbDecodeSave = texObj-Sampler.sRGBDecode;
const GLenum srgbBufferSave = ctx-Color.sRGBEnabled;
const GLuint fboSave = ctx-DrawBuffer-Name;
const GLuint original_active_unit = ctx-Texture.CurrentUnit;
@@ -2868,6 +2864,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum 
target,
GLuint dstLevel;
const GLuint border = 0;
const GLint slice = 0;
+   GLuint samplerSave;
 
if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, texObj)) {
   _mesa_generate_mipmap(ctx, target, texObj);
@@ -2885,6 +2882,9 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum 
target,
 
_mesa_meta_begin(ctx, MESA_META_ALL);
 
+   samplerSave = ctx-Texture.Unit[ctx-Texture.CurrentUnit].Sampler ?
+  ctx-Texture.Unit[ctx-Texture.CurrentUnit].Sampler-Name : 0;
+
if (original_active_unit != 0)
   _mesa_BindTexture(target, texObj-Name);
 
@@ -2915,20 +2915,29 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, 
GLenum target,
if (!mipmap-FBO) {
   _mesa_GenFramebuffersEXT(1, mipmap-FBO);
}
+
+   if (!mipmap-Sampler) {
+  _mesa_GenSamplers(1, mipmap-Sampler);
+  _mesa_BindSampler(ctx-Texture.CurrentUnit, mipmap-Sampler);
+  _mesa_SamplerParameteri(mipmap-Sampler, GL_TEXTURE_MIN_FILTER, 
GL_LINEAR_MIPMAP_LINEAR);
+  _mesa_SamplerParameteri(mipmap-Sampler, GL_TEXTURE_MAG_FILTER, 
GL_LINEAR);
+  _mesa_SamplerParameteri(mipmap-Sampler, GL_TEXTURE_WRAP_S, 
GL_CLAMP_TO_EDGE);
+  _mesa_SamplerParameteri(mipmap-Sampler, GL_TEXTURE_WRAP_T, 
GL_CLAMP_TO_EDGE);
+  _mesa_SamplerParameteri(mipmap-Sampler, GL_TEXTURE_WRAP_R, 
GL_CLAMP_TO_EDGE);
+  /* We don't want to encode or decode sRGB values; treat them as linear */
+  if (ctx-Extensions.EXT_texture_sRGB_decode) {
+ _mesa_SamplerParameteri(mipmap-Sampler, GL_TEXTURE_SRGB_DECODE_EXT,
+   GL_SKIP_DECODE_EXT);
+  }
+
+   } else {
+  _mesa_BindSampler(ctx-Texture.CurrentUnit, mipmap-Sampler);
+   }
+
_mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap-FBO);
 
-   _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
-   _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
_mesa_TexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);
-   _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-   _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-   _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
 
-   /* We don't want to encode or decode sRGB values; treat them as linear */
-   if (ctx-Extensions.EXT_texture_sRGB_decode) {
-  _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
-  GL_SKIP_DECODE_EXT);
-   }
if (ctx-Extensions.EXT_framebuffer_sRGB) {
   _mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE);
}
@@ -3055,25 +3064,18 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, 
GLenum target,
   _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
 
-   if (ctx-Extensions.EXT_texture_sRGB_decode) {
-  _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
-  srgbDecodeSave);
-   }
if (ctx-Extensions.EXT_framebuffer_sRGB  srgbBufferSave) {
   _mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_TRUE);
}
 
_mesa_lock_texture(ctx, texObj); /* relock */
 
+   _mesa_BindSampler(ctx-Texture.CurrentUnit, samplerSave);
+
_mesa_meta_end(ctx);
 
-   

Re: [Mesa-dev] [PATCH 0/2] Add vertex id to llvmpipe.

2012-06-11 Thread Jose Fonseca


- Original Message -
 On Fri, Jun 08, 2012 at 09:01:42AM -0700, Jose Fonseca wrote:
  Oliver,
  
  There will be other system values in the future, so instead of
  passing every value as a different parameter, please define a
  structure in src/gallium/auxiliary/gallivm/lp_bld_tgsi.h as
  
  struct lp_bld_tgsi_system_values {
LLVMValueRef facing;
LLVMValueRef instance_id;
LLVMValueRef vertex_id;
...
  }
  
  which is then passed to lp_build_tgsi_soa and all other functions.
  
  Otherwise the change looks good overall.
 
 Something like that for the second part?

Yep, that looks good to me. Thanks.

Jose

 
   OG.
 
 Author: Olivier Galibert galib...@pobox.com
 Date:   Fri Jun 1 22:58:58 2012 +0200
 
 llvmpipe: Add vertex id support.
 
 Signed-off-by: Olivier Galibert galib...@pobox.com
 
 diff --git a/src/gallium/auxiliary/draw/draw_llvm.c
 b/src/gallium/auxiliary/draw/draw_llvm.c
 index d5eb727..de495cf 100644
 --- a/src/gallium/auxiliary/draw/draw_llvm.c
 +++ b/src/gallium/auxiliary/draw/draw_llvm.c
 @@ -456,7 +456,7 @@ generate_vs(struct draw_llvm *llvm,
  LLVMBuilderRef builder,
  LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS],
  const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS],
 -LLVMValueRef instance_id,
 +const struct lp_bld_tgsi_system_values *system_values,
  LLVMValueRef context_ptr,
  struct lp_build_sampler_soa *draw_sampler,
  boolean clamp_vertex_color)
 @@ -488,7 +488,7 @@ generate_vs(struct draw_llvm *llvm,
   vs_type,
   NULL /*struct lp_build_mask_context *mask*/,
   consts_ptr,
 - instance_id,
 + system_values,
   NULL /*pos*/,
   inputs,
   outputs,
 @@ -1245,7 +1245,6 @@ draw_llvm_generate(struct draw_llvm *llvm,
 struct draw_llvm_variant *variant,
 LLVMValueRef count, fetch_elts, fetch_count;
 LLVMValueRef stride, step, io_itr;
 LLVMValueRef io_ptr, vbuffers_ptr, vb_ptr;
 -   LLVMValueRef instance_id;
 LLVMValueRef zero = lp_build_const_int32(gallivm, 0);
 LLVMValueRef one = lp_build_const_int32(gallivm, 1);
 struct draw_context *draw = llvm-draw;
 @@ -1267,6 +1266,9 @@ draw_llvm_generate(struct draw_llvm *llvm,
 struct draw_llvm_variant *variant,
 const unsigned pos =
 draw_current_shader_position_output(llvm-draw);
 const unsigned cv =
 draw_current_shader_clipvertex_output(llvm-draw);
 boolean have_clipdist = FALSE;
 +   struct lp_bld_tgsi_system_values system_values;
 +
 +   memset(system_values, 0, sizeof(system_values));
  
 arg_types[0] = get_context_ptr_type(llvm);   /* context */
 arg_types[1] = get_vertex_header_ptr_type(llvm); /* vertex_header
 */
 @@ -1297,19 +1299,19 @@ draw_llvm_generate(struct draw_llvm *llvm,
 struct draw_llvm_variant *variant,
   LLVMAddAttribute(LLVMGetParam(variant_func, i),
LLVMNoAliasAttribute);
  
 -   context_ptr  = LLVMGetParam(variant_func, 0);
 -   io_ptr   = LLVMGetParam(variant_func, 1);
 -   vbuffers_ptr = LLVMGetParam(variant_func, 2);
 -   stride   = LLVMGetParam(variant_func, 5);
 -   vb_ptr   = LLVMGetParam(variant_func, 6);
 -   instance_id  = LLVMGetParam(variant_func, 7);
 +   context_ptr   = LLVMGetParam(variant_func, 0);
 +   io_ptr= LLVMGetParam(variant_func, 1);
 +   vbuffers_ptr  = LLVMGetParam(variant_func, 2);
 +   stride= LLVMGetParam(variant_func, 5);
 +   vb_ptr= LLVMGetParam(variant_func, 6);
 +   system_values.instance_id = LLVMGetParam(variant_func, 7);
  
 lp_build_name(context_ptr, context);
 lp_build_name(io_ptr, io);
 lp_build_name(vbuffers_ptr, vbuffers);
 lp_build_name(stride, stride);
 lp_build_name(vb_ptr, vb);
 -   lp_build_name(instance_id, instance_id);
 +   lp_build_name(system_values.instance_id, instance_id);
  
 if (elts) {
fetch_elts   = LLVMGetParam(variant_func, 3);
 @@ -1375,6 +1377,7 @@ draw_llvm_generate(struct draw_llvm *llvm,
 struct draw_llvm_variant *variant,
lp_build_printf(builder,  --- io %d = %p, loop counter %d\n,
io_itr, io, lp_loop.counter);
  #endif
 +  system_values.vertex_id = lp_build_zero(gallivm,
 lp_type_uint_vec(32));
for (i = 0; i  TGSI_NUM_CHANNELS; ++i) {
   LLVMValueRef true_index =
  LLVMBuildAdd(builder,
 @@ -1392,7 +1395,10 @@ draw_llvm_generate(struct draw_llvm *llvm,
 struct draw_llvm_variant *variant,
   true_index, 1, );
  true_index = LLVMBuildLoad(builder, fetch_ptr,
  fetch_elt);
   }
 -
 +
 + system_values.vertex_id =
 LLVMBuildInsertElement(gallivm-builder,
 +
  
 

Re: [Mesa-dev] [PATCH] configure.ac: Add --with-(gl|glu|osmesa)-lib-name options

2012-06-11 Thread Brad King
On 06/05/2012 02:03 PM, Kenneth Graunke wrote:
 On 06/05/2012 10:59 AM, Brad King wrote:
 ./autogen.sh --with-gl-lib-name=GL --with-glu-lib-name=GLU
 --with-osmesa-lib-name=OSMesa ...

 That looks cleaner to me.  Here is a patch for it.
 
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org
 
 If there are no objections, I'll push this tomorrow.  Thanks!

I haven't seen this appear in any origin branch yet.  No rush,
I just want to make sure it isn't accidentally forgotten.

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


Re: [Mesa-dev] [PATCH 16/21] swrast: Support sampler object for texture fetching state

2012-06-11 Thread Marek Olšák
On Mon, Jun 11, 2012 at 8:59 AM, Pauli Nieminen
pauli.niemi...@linux.intel.com wrote:
 swrast needs to pass sampler object into all texture fetching functions
 to use correct sampling state when sampler object is bound to the unit.
 The changes were made using half manual regular expression replace.

 With the patch llvmpipe didn't get any regressions.

Hi Pauli,

llvmpipe doesn't use the classic swrast code, only the original
Software Rasterizer driver does.

Marek


 Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
 ---
  src/mesa/swrast/s_atifragshader.c |    6 +-
  src/mesa/swrast/s_context.c       |    4 +-
  src/mesa/swrast/s_context.h       |    1 +
  src/mesa/swrast/s_fragprog.c      |   17 +-
  src/mesa/swrast/s_span.c          |    8 +-
  src/mesa/swrast/s_texcombine.c    |   42 ++-
  src/mesa/swrast/s_texfetch.c      |   20 +-
  src/mesa/swrast/s_texfetch.h      |    2 +-
  src/mesa/swrast/s_texfilter.c     |  692 
 -
  src/mesa/tnl/t_vb_program.c       |    4 +-
  10 files changed, 438 insertions(+), 358 deletions(-)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/21] mesa/format_unpack: Fix YCBCR unpack

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

The YCBCR unpack was reading one RGBA value from 4 bytes of YCBCR
texture. But single pixel is only 2 bytes in the format. After
noticing that error Ville told me that second chroma sample has to
be average to match video requirements.

Looking at places where unpack to rgba is called it is possible to get
odd X coordinate and odd number of bytes. That makes unpack operation
complex problem. But I assume that source allocation is 4 byte aligned
always. That should hold for most of allocations but may fail.

Better solution would be threating YCBCR as compressed format
internally. But I suspect that I would break a lot of assumptions
everywhere with that changes.

But same time as I was checking call sites I started suspecting that we
can't ever hit these unpack functions for YCBCR. But I need to study the
code paths a lot more to be sure if that is true.

Changes to fix unpacking:
* Always start reading from the start of chroma pair.
* Always read to the end of chroma pair
* Unpack two RGB values in single iteration
* Read next chroma pair (if available) to calculate average for second
   sample.
* Refactor shared color space conversion code to separate function.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com


This unpack code isn't used during texture sampling by swrast.  I 
think the only way it would be hit is if one did a glReadPixels from 
ycbcr texture attached to a FBO.  But we should probably disallow that 
(attaching ycbcr textures to FBOs) in the first place.


Have you found another path that hits this code?

The changes look OK in any case.

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

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


Re: [Mesa-dev] [PATCH 02/21] mesa: Check index buffer offset in DrawElements

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

DrawElements checks for cound beeing larger than index buffer object.


count being



But application can specify offset to buffer leading to buffer overflow
again. ARB_vertex_buffer_object leaves the case undefined but allows
program termination.

But indirect glx needs to check to avoid crashing X.

   What happens when an attempt is made to access data outside the
 bounds of the buffer object with a command that dereferences the
 arrays?

 RESOLVED: ALLOW PROGRAM TERMINATION.  In the event of a
 software fallback, bounds checking can become impractical. Since
 applications don't know the actual address of the buffer object
 and only provide an offset, they can't ever guarantee that
 out-of-bounds offsets will fall on valid memory.  So it's hard to
 do any better than this.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/main/api_validate.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 02495a1..4382dc9 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -299,7 +299,8 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
 if (_mesa_is_bufferobj(ctx-Array.ArrayObj-ElementArrayBufferObj)) {
/* use indices in the buffer object */
/* make sure count doesn't go outside buffer bounds */
-  if (index_bytes(type, count)  
ctx-Array.ArrayObj-ElementArrayBufferObj-Size) {
+  if (index_bytes(type, count) + (GLsizei)indices
+  ctx-Array.ArrayObj-ElementArrayBufferObj-Size) {
   _mesa_warning(ctx, glDrawElements index out of buffer bounds);
   return GL_FALSE;
}


Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/21] mesa: Remove unnecessary parameters from TexImage

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

gl_texture_image structure always holds size and internal format before
TexImage driver hook is called. Those passing same information in
function parameters only duplicates information making the interface
harder to understand.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/drivers/dri/intel/intel_tex_image.c   |   22 +++
  src/mesa/drivers/dri/nouveau/nouveau_texture.c |   21 ++-
  src/mesa/drivers/dri/radeon/radeon_texture.c   |   34 
  src/mesa/main/dd.h |2 --
  src/mesa/main/teximage.c   |7 +++--
  src/mesa/main/texobj.c |3 +--
  src/mesa/main/texstore.c   |9 +++
  src/mesa/main/texstore.h   |2 --
  src/mesa/state_tracker/st_cb_texture.c |   21 ++-
  9 files changed, 33 insertions(+), 88 deletions(-)


I was planning on doing this too someday.  Looks good.

For patches 2,3,4: Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 05/21] mesa: Move DepthMode to texture object

2012-06-11 Thread Brian Paul

One comment below.

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

GL_DEPTH_TEXTURE_MODE isn't meant to be part of sampler state based on
compatibility profile specifications.

OpenGL specification 4.1 compatibility 20100725 3.9.2:
... The values accepted in the pname parameter
are TEXTURE_WRAP_S, TEXTURE_WRAP_T, TEXTURE_WRAP_R, TEXTURE_MIN_-
FILTER, TEXTURE_MAG_FILTER, TEXTURE_BORDER_COLOR, TEXTURE_MIN_-
LOD, TEXTURE_MAX_LOD, TEXTURE_LOD_BIAS, TEXTURE_COMPARE_MODE, and
TEXTURE_COMPARE_FUNC. Texture state listed in table 6.25 but not listed here and
in the sampler state in table 6.26 is not part of the sampler state, and 
remains in the
texture object.

Same can be found from 3.3 compatibility specification.

That makes me think that moving DepthMode from sampler state makes sense
to avoid bugs if DepthMode happens to be used with sampler objects.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/drivers/dri/i915/i915_texstate.c |2 +-
  src/mesa/drivers/dri/i965/brw_wm.c|2 +-
  src/mesa/drivers/dri/i965/brw_wm_surface_state.c  |2 +-
  src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |2 +-
  src/mesa/main/attrib.c|2 +-
  src/mesa/main/mtypes.h|6 +++---
  src/mesa/main/samplerobj.c|2 --
  src/mesa/main/texobj.c|4 ++--
  src/mesa/main/texparam.c  |8 
  src/mesa/main/texstate.c  |2 +-
  src/mesa/state_tracker/st_atom_texture.c  |4 ++--
  src/mesa/swrast/s_texfilter.c |4 ++--
  12 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c 
b/src/mesa/drivers/dri/i915/i915_texstate.c
index fd63a69..590d5fa 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -168,7 +168,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint 
unit, GLuint ss3)
 i915-state.tex_offset[unit] = 0; /* Always the origin of the miptree */

 format = translate_texture_format(firstImage-TexFormat,
-sampler-DepthMode);
+tObj-DepthMode);
 pitch = intelObj-mt-region-pitch * intelObj-mt-cpp;

 state[I915_TEXREG_MS3] =
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 63c74ad..ff70d2b 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -352,7 +352,7 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
  * overrides because shadow comparison always returns the result of
  * the comparison in all channels anyway.
  */
-switch (sampler-DepthMode) {
+switch (unit-_Current-DepthMode) {
 case GL_ALPHA:
swizzles[0] = SWIZZLE_ZERO;
swizzles[1] = SWIZZLE_ZERO;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 4718337..2506cf0 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -724,7 +724,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint 
unit )
  BRW_SURFACE_CUBEFACE_ENABLES |
  (translate_tex_format(mt-format,
firstImage-InternalFormat,
-   sampler-DepthMode,
+   tObj-DepthMode,
sampler-sRGBDecode)
BRW_SURFACE_FORMAT_SHIFT));

diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index d34bf53..1e7fd2e 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -251,7 +251,7 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint 
unit)
 surf-ss0.surface_type = translate_tex_target(tObj-Target);
 surf-ss0.surface_format = translate_tex_format(mt-format,
 firstImage-InternalFormat,
-   sampler-DepthMode,
+   tObj-DepthMode,
 sampler-sRGBDecode);
 if (tObj-Target == GL_TEXTURE_CUBE_MAP) {
surf-ss0.cube_pos_x = 1;
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 318d576..8bc7c34 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -806,7 +806,7 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
  samp-CompareFunc);
   }
   if (ctx-Extensions.ARB_depth_texture)
-_mesa_TexParameteri(target, GL_DEPTH_TEXTURE_MODE, 
samp-DepthMode);
+

Re: [Mesa-dev] [PATCH 06/21] mesa/macros: Add ARRAY_SIZE helper macro core mesa

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

The ARRAY_SIZE macro is usefull helper that is used already in many
parts of core. But mesa core was missing it. I decided to add it to the
macros.h when I wanted to use it in following patch.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/drivers/dri/intel/intel_context.h  |3 +--
  src/mesa/drivers/dri/radeon/radeon_screen.c |2 --
  src/mesa/main/macros.h  |3 +++
  3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.h 
b/src/mesa/drivers/dri/intel/intel_context.h
index cc3ee0d..4dc98d6 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -33,6 +33,7 @@
  #includestring.h
  #include main/mtypes.h
  #include main/mm.h
+#include main/macros.h

  #ifdef __cplusplus
  extern C {
@@ -341,8 +342,6 @@ extern char *__progname;
  #define SUBPIXEL_X 0.125
  #define SUBPIXEL_Y 0.125

-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-
  /**
   * Align a value up to an alignment value
   *
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 85cfe17..b0545b5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -702,8 +702,6 @@ radeonDestroyBuffer(__DRIdrawable *driDrawPriv)
  _mesa_reference_framebuffer((struct gl_framebuffer 
**)((driDrawPriv-driverPrivate)), NULL);
  }

-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
-
  /**
   * This is the driver specific part of the createNewScreen entry point.
   * Called when using DRI2.
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index d1df2ce..e05fa14 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -679,5 +679,8 @@ do {\
  #define ENUM_TO_DOUBLE(E)  ((GLdouble)(GLint)(E))
  #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)

+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif

  #endif



Core Mesa uses the Element() macro for this, defined in compiler.h. 
We should just use one or the other.  I'd go with just using Element() 
everywhere for now to avoid churn.


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


Re: [Mesa-dev] [PATCH] mesa: Unbind GL_TEXTURE_BUFFER on DeleteBuffers.

2012-06-11 Thread Brian Paul

On 06/09/2012 10:48 PM, Kenneth Graunke wrote:

Fixes oglconform's tbo/basic.buffer.delete test.

Signed-off-by: Kenneth Graunkekenn...@whitecape.org
---
  src/mesa/main/bufferobj.c |4 
  1 file changed, 4 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 846260d..332af3d 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -848,6 +848,10 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
  _mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 );
   }

+ if (ctx-Texture.BufferObject == bufObj) {
+_mesa_BindBufferARB( GL_TEXTURE_BUFFER, 0 );
+ }
+
   /* The ID is immediately freed for re-use */
   _mesa_HashRemove(ctx-Shared-BufferObjects, ids[i]);
   /* Make sure we do not run into the classic ABA problem on bind.


Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Mesa (master): mesa: Fix glCopyBuffserSubData typos in error messages and comments.

2012-06-11 Thread Brian Paul

On 06/08/2012 11:07 PM, Kenneth Graunke wrote:

Module: Mesa
Branch: master
Commit: 306c9f0c5762ad75e340d22b2405ac11e74d3378
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=306c9f0c5762ad75e340d22b2405ac11e74d3378

Author: Kenneth Graunkekenn...@whitecape.org
Date:   Fri Jun  8 22:03:50 2012 -0700

mesa: Fix glCopyBuffserSubData typos in error messages and comments.

Signed-off-by: Kenneth Graunkekenn...@whitecape.org

---

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

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 36a7619..5415665 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -546,7 +546,7 @@ _mesa_buffer_unmap( struct gl_context *ctx, struct 
gl_buffer_object *bufObj )

  /**
   * Default fallback for \c dd_function_table::CopyBufferSubData().
- * Called via glCopyBuffserSubData().
+ * Called via glCopyBufferSubData().
   */
  static void
  _mesa_copy_buffer_subdata(struct gl_context *ctx,
@@ -1328,48 +1328,48 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum 
writeTarget,
 struct gl_buffer_object *src, *dst;
 ASSERT_OUTSIDE_BEGIN_END(ctx);

-   src = get_buffer(ctx, glCopyBuffserSubData, readTarget);
+   src = get_buffer(ctx, glCopyBufferSubData, readTarget);
 if (!src)
return;

-   dst = get_buffer(ctx, glCopyBuffserSubData, writeTarget);
+   dst = get_buffer(ctx, glCopyBufferSubData, writeTarget);
 if (!dst)
return;

 if (_mesa_bufferobj_mapped(src)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
-  glCopyBuffserSubData(readBuffer is mapped));
+  glCopyBufferSubData(readBuffer is mapped));
return;
 }

 if (_mesa_bufferobj_mapped(dst)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
-  glCopyBuffserSubData(writeBuffer is mapped));
+  glCopyBufferSubData(writeBuffer is mapped));
return;
 }

 if (readOffset  0) {
_mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBuffserSubData(readOffset = %d), (int) readOffset);
+  glCopyBufferSubData(readOffset = %d), (int) readOffset);
return;
 }

 if (writeOffset  0) {
_mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBuffserSubData(writeOffset = %d), (int) writeOffset);
+  glCopyBufferSubData(writeOffset = %d), (int) writeOffset);
return;
 }

 if (readOffset + size  src-Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBuffserSubData(readOffset + size = %d),
+  glCopyBufferSubData(readOffset + size = %d),
(int) (readOffset + size));
return;
 }

 if (writeOffset + size  dst-Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBuffserSubData(writeOffset + size = %d),
+  glCopyBufferSubData(writeOffset + size = %d),
(int) (writeOffset + size));
return;
 }
@@ -1384,7 +1384,7 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum 
writeTarget,
else {
   /* overlapping src/dst is illegal */
   _mesa_error(ctx, GL_INVALID_VALUE,
- glCopyBuffserSubData(overlapping src/dst));
+ glCopyBufferSubData(overlapping src/dst));
   return;
}
 }



Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08/21] mesa/samplerobj: Avoid crash in sampler query if texture unit is disabled

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

Sampler queries are so far made only for enabled texture unit. But if
any code would query sampler before checking texture unit state that
would result to NULL deference.

Making the inline helper easier to use with NULL check makes a lot sense
because compiler is likely to combine the checks for the current texture.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/main/samplerobj.h |4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index 0bfda43..33da894 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -33,8 +33,10 @@ _mesa_get_samplerobj(struct gl_context *ctx, GLuint unit)
  {
 if (ctx-Texture.Unit[unit].Sampler)
return ctx-Texture.Unit[unit].Sampler;
-   else
+   else if (ctx-Texture.Unit[unit]._Current)
returnctx-Texture.Unit[unit]._Current-Sampler;
+   else
+  return NULL;
  }




Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 09/21] nouveau: Add support for ARB_sampler_object

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

ARB_sampler_object is very simple software only extension to support.
I want to make it mandator extension for Mesa drivers to allow meta
module to use it.

This patch add support for the extension to nouveau. It is completely
untested search and replace patch. I hope someone with old NV hardware
could give a try that there is no regressions and ARB_sampler_object
tests passes.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
CC: nouv...@lists.freedesktop.org


Looks OK to me.

Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/21] radeon: Fix printf format not to warn in 64bit

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

When I build tested radeon changes I noticed two warnings about format
size missmatch in 64bit. I decided to clean them to make relevant
compiler warnings easier to spot.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/drivers/dri/radeon/radeon_blit.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c 
b/src/mesa/drivers/dri/radeon/radeon_blit.c
index 4233221..80b5346 100644
--- a/src/mesa/drivers/dri/radeon/radeon_blit.c
+++ b/src/mesa/drivers/dri/radeon/radeon_blit.c
@@ -390,13 +390,13 @@ unsigned r100_blit(struct gl_context *ctx,
  }

  if (0) {
-fprintf(stderr, src: size [%d x %d], pitch %d, offset %d 
+fprintf(stderr, src: size [%d x %d], pitch %d, offset %zd 
  offset [%d x %d], format %s, bo %p\n,
  src_width, src_height, src_pitch, src_offset,
  src_x_offset, src_y_offset,
  _mesa_get_format_name(src_mesaformat),
  src_bo);
-fprintf(stderr, dst: pitch %d offset %d, offset[%d x %d], format %s, bo 
%p\n,
+fprintf(stderr, dst: pitch %d offset %zd, offset[%d x %d], format %s, bo 
%p\n,
  dst_pitch, dst_offset,  dst_x_offset, dst_y_offset,
  _mesa_get_format_name(dst_mesaformat), dst_bo);
  fprintf(stderr, region: %d x %d\n, reg_width, reg_height);



Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: Make glPrimitiveRestartIndex execute immediately in display lists.

2012-06-11 Thread Eric Anholt
On Sat,  9 Jun 2012 18:12:34 -0700, Kenneth Graunke kenn...@whitecape.org 
wrote:
 From the GL_NV_primitive_restart spec:
 PrimitiveRestartIndexNV is not compiled into display lists, but is
  executed immediately.
 
 Prior to this patch, calls to glPrimitiveRestartIndex would hit the noop
 dispatch stub.

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


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


Re: [Mesa-dev] [PATCH 11/21] radeonr200: Add support for ARB_shader_object

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

Preparation for the mandator support of ARB_shader_object.

I have tested this patch with rv280 only. While only compile testing
radeon changes.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/drivers/dri/r200/r200_tex.c |   41 --
  src/mesa/drivers/dri/r200/r200_tex.h |1 +
  src/mesa/drivers/dri/r200/r200_texstate.c|3 +-
  src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c |   16 +
  src/mesa/drivers/dri/radeon/radeon_span.c|4 ++-
  src/mesa/drivers/dri/radeon/radeon_tex.c |   27 ++
  src/mesa/drivers/dri/radeon/radeon_tex.h |1 +
  src/mesa/drivers/dri/radeon/radeon_tex_copy.c|2 +-
  src/mesa/drivers/dri/radeon/radeon_texstate.c|4 ++-
  src/mesa/drivers/dri/radeon/radeon_texture.h |4 ++-
  10 files changed, 57 insertions(+), 46 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_tex.c 
b/src/mesa/drivers/dri/r200/r200_tex.c
index fe7c977..f72cad3 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -41,6 +41,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
  #include main/simple_list.h
  #include main/teximage.h
  #include main/texobj.h
+#include main/samplerobj.h

  #include radeon_mipmap_tree.h
  #include r200_context.h
@@ -360,12 +361,21 @@ static void r200TexEnv( struct gl_context *ctx, GLenum 
target,
 }
  }

+void r200TexUpdateParameters(struct gl_context *ctx, GLuint unit)
+{
+   struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
+   radeonTexObj* t = radeon_tex_obj(ctx-Texture.Unit[unit]._Current);
+
+   r200SetTexMaxAnisotropy(t , samp-MaxAnisotropy);
+   r200SetTexFilter( t, samp-MinFilter, samp-MagFilter );
+   r200SetTexWrap( t, samp-WrapS, samp-WrapT, samp-WrapR );
+   r200SetTexBorderColor( t, samp-BorderColor.f );
+}


The whitespace is bit inconsistent in that function.  I'd write all 
the function calls as foo(a, b) without extra space before/after the 
parens.





  /**
   * Changes variables and flags for a state update, which will happen at the
   * next UpdateTextureState
   */
-
  static void r200TexParameter( struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj,
GLenum pname, const GLfloat *params )
@@ -379,23 +389,6 @@ static void r200TexParameter( struct gl_context *ctx, 
GLenum target,
   _mesa_lookup_enum_by_nr( pname ) );

 switch ( pname ) {
-   case GL_TEXTURE_MIN_FILTER:
-   case GL_TEXTURE_MAG_FILTER:
-   case GL_TEXTURE_MAX_ANISOTROPY_EXT:
-  r200SetTexMaxAnisotropy( t, texObj-Sampler.MaxAnisotropy );
-  r200SetTexFilter( t, texObj-Sampler.MinFilter, 
texObj-Sampler.MagFilter );
-  break;
-
-   case GL_TEXTURE_WRAP_S:
-   case GL_TEXTURE_WRAP_T:
-   case GL_TEXTURE_WRAP_R:
-  r200SetTexWrap( t, texObj-Sampler.WrapS, texObj-Sampler.WrapT, 
texObj-Sampler.WrapR );
-  break;
-
-   case GL_TEXTURE_BORDER_COLOR:
-  r200SetTexBorderColor( t, texObj-Sampler.BorderColor.f );
-  break;
-
 case GL_TEXTURE_BASE_LEVEL:
 case GL_TEXTURE_MAX_LEVEL:
 case GL_TEXTURE_MIN_LOD:
@@ -489,6 +482,17 @@ static struct gl_texture_object 
*r200NewTextureObject(struct gl_context * ctx,
 returnt-base;
  }

+static struct gl_sampler_object *
+r200NewSamplerObject(struct gl_context *ctx, GLuint name)
+{
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);
+   struct gl_sampler_object *samp = _mesa_new_sampler_object(ctx, name);
+   if (samp) {
+  samp-MaxAnisotropy = rmesa-radeon.initialMaxAnisotropy;
+   }
+   return samp;
+}
+


  void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table 
*functions )
@@ -506,4 +510,5 @@ void r200InitTextureFuncs( radeonContextPtr radeon, struct 
dd_function_table *fu
 functions-TexEnv   = r200TexEnv;
 functions-TexParameter = r200TexParameter;
 functions-TexGen   = r200TexGen;
+   functions-NewSamplerObject  = r200NewSamplerObject;
  }
diff --git a/src/mesa/drivers/dri/r200/r200_tex.h 
b/src/mesa/drivers/dri/r200/r200_tex.h
index 756a128..725b45d 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.h
+++ b/src/mesa/drivers/dri/r200/r200_tex.h
@@ -48,6 +48,7 @@ extern void r200DestroyTexObj( r200ContextPtr rmesa, 
radeonTexObjPtr t );
  extern void r200InitTextureFuncs( radeonContextPtr radeon, struct 
dd_function_table *functions );

  extern void r200UpdateFragmentShader( struct gl_context *ctx );
+extern void r200TexUpdateParameters(struct gl_context *ctx, GLuint unit);

  extern void set_re_cntl_d3d( struct gl_context *ctx, int unit, GLboolean 
use_d3d );

diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c 
b/src/mesa/drivers/dri/r200/r200_texstate.c
index 19e77c5..b25c611 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ 

Re: [Mesa-dev] [PATCH 13/21] mesa/ff_shader: Fix sampler state reading

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

Fixed function fragment shader generator was incorrectly read texture
sampling state directly from texture object. To make sure that
ARB_sampler_object works correctly shader generator has to use the
bound sampler if one exist

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/main/ff_fragment_shader.cpp |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/ff_fragment_shader.cpp 
b/src/mesa/main/ff_fragment_shader.cpp
index 0233f38..f743ce1 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -33,6 +33,7 @@ extern C {
  #include mtypes.h
  #include main/uniforms.h
  #include main/macros.h
+#include main/samplerobj.h
  #include program/program.h
  #include program/prog_parameter.h
  #include program/prog_cache.h
@@ -428,11 +429,13 @@ static GLuint make_state_key( struct gl_context *ctx,  
struct state_key *key )
const struct gl_texture_unit *texUnit =ctx-Texture.Unit[i];
const struct gl_texture_object *texObj = texUnit-_Current;
const struct gl_tex_env_combine_state *comb = texUnit-_CurrentCombine;
+  const struct gl_sampler_object *samp;
GLenum format;

if (!texUnit-_ReallyEnabled || !texUnit-Enabled)
   continue;

+  samp = _mesa_get_samplerobj(ctx, i);
format = texObj-Image[0][texObj-BaseLevel]-_BaseFormat;

key-unit[i].enabled = 1;
@@ -444,7 +447,7 @@ static GLuint make_state_key( struct gl_context *ctx,  
struct state_key *key )
   translate_tex_src_bit(texUnit-_ReallyEnabled);

key-unit[i].shadow =
- ((texObj-Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE)
+ ((samp-CompareMode == GL_COMPARE_R_TO_TEXTURE)
((format == GL_DEPTH_COMPONENT) ||
 (format == GL_DEPTH_STENCIL_EXT)));



Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 14/21] mesa/program: Use sampler object state if present

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

CompareFailValue is part of Sampler state that needs to be read from
bound sampler object if present.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/program/prog_statevars.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/program/prog_statevars.c 
b/src/mesa/program/prog_statevars.c
index 98ab9d0..7ab5773 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -36,6 +36,7 @@
  #include main/mtypes.h
  #include prog_statevars.h
  #include prog_parameter.h
+#include main/samplerobj.h


  /**
@@ -555,11 +556,13 @@ _mesa_fetch_state(struct gl_context *ctx, const 
gl_state_index state[],
  const int unit = (int) state[2];
  const struct gl_texture_object *texObj
 = ctx-Texture.Unit[unit]._Current;
+const struct gl_sampler_object *samp =
+   _mesa_get_samplerobj(ctx, unit);
  if (texObj) {
 value[0] =
 value[1] =
 value[2] =
-   value[3] = texObj-Sampler.CompareFailValue;
+   value[3] = samp-CompareFailValue;
  }
   }
   return;


Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 07/21] mesa/samplerobj: Support EXT_texture_sRGB_decode

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

sRGBDecode state is part of sampler object state but mesa was missing
handlers to access the state. This patch adds the support for required
state changes and queries.

GL_EXT_texture_sRGB_decode issue 4:
4) Should we add forward-looking support for ARB_sampler_objects?

 RESOLVED: YES

 If ARB_sampler_objects exists in the implementation, the sampler
 objects should also include this parameter per sampler.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/main/samplerobj.c |   56 
  1 file changed, 56 insertions(+)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 8c54c9a..f276296 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -582,6 +582,24 @@ set_sampler_cube_map_seamless(struct gl_context *ctx,
 return GL_TRUE;
  }

+static GLuint
+set_sampler_srgb_decode(struct gl_context *ctx,
+  struct gl_sampler_object *samp, GLenum param)
+{
+   if (!ctx-Extensions.EXT_texture_sRGB_decode)
+  return INVALID_PNAME;
+
+   if (samp-sRGBDecode == param)
+  return GL_FALSE;
+
+   if (param != GL_DECODE_EXT  param != GL_SKIP_DECODE_EXT)
+  return INVALID_VALUE;
+
+   flush(ctx);
+   samp-sRGBDecode = param;
+   return GL_TRUE;
+}
+

  static void GLAPIENTRY
  _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
@@ -634,6 +652,9 @@ _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint 
param)
 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, param);
break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, param);
+  break;
 case GL_TEXTURE_BORDER_COLOR:
/* fall-through */
 default:
@@ -718,6 +739,9 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum pname, 
GLfloat param)
 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) param);
break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) param);
+  break;
 case GL_TEXTURE_BORDER_COLOR:
/* fall-through */
 default:
@@ -799,6 +823,9 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, 
const GLint *params)
 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, params[0]);
+  break;
 case GL_TEXTURE_BORDER_COLOR:
{
   GLfloat c[4];
@@ -890,6 +917,9 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, 
const GLfloat *params)
 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) 
params[0]);
break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
 case GL_TEXTURE_BORDER_COLOR:
res = set_sampler_border_colorf(ctx, sampObj, params);
break;
@@ -972,6 +1002,9 @@ _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, 
const GLint *params)
 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
 case GL_TEXTURE_BORDER_COLOR:
res = set_sampler_border_colori(ctx, sampObj, params);
break;
@@ -1055,6 +1088,9 @@ _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, 
const GLuint *params)
 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+  break;
 case GL_TEXTURE_BORDER_COLOR:
res = set_sampler_border_colorui(ctx, sampObj, params);
break;
@@ -1149,6 +1185,11 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum 
pname, GLint *params)
   goto invalid_pname;
*params = sampObj-CubeMapSeamless;
break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  if (!ctx-Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+  *params = (GLenum) sampObj-sRGBDecode;
+  break;
 default:
goto invalid_pname;
 }
@@ -1222,6 +1263,11 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum 
pname, GLfloat *params)
   goto invalid_pname;
*params = (GLfloat) sampObj-CubeMapSeamless;
break;
+   case GL_TEXTURE_SRGB_DECODE_EXT:
+  if (!ctx-Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+  *params = (GLfloat) sampObj-sRGBDecode;
+  break;
 default:
goto invalid_pname;
 }
@@ -1296,6 +1342,11 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, 

Re: [Mesa-dev] [PATCH] mesa: Unbind GL_TEXTURE_BUFFER on DeleteBuffers.

2012-06-11 Thread Eric Anholt
On Sat,  9 Jun 2012 21:48:26 -0700, Kenneth Graunke kenn...@whitecape.org 
wrote:
 Fixes oglconform's tbo/basic.buffer.delete test.

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


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


Re: [Mesa-dev] [PATCH 15/21] mesa: Make ARB_sampler_objects mandator

2012-06-11 Thread Brian Paul

s/mandator/mandatory/

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


On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

To allow meta acceleration operations to use sampler objects the
ARB_sampler_objects extension needs to be mandator for all drivers.
Because the extension doesn't have any hardware dependencies it is
trivial to implement.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/drivers/dri/intel/intel_extensions.c |1 -
  src/mesa/main/extensions.c|2 +-
  src/mesa/main/get.c   |7 +--
  src/mesa/main/mtypes.h|1 -
  src/mesa/main/version.c   |2 +-
  src/mesa/state_tracker/st_extensions.c|1 -
  6 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c 
b/src/mesa/drivers/dri/intel/intel_extensions.c
index 29da36c..7c9d9a8 100755
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -49,7 +49,6 @@ intelInitExtensions(struct gl_context *ctx)
 ctx-Extensions.ARB_half_float_pixel = true;
 ctx-Extensions.ARB_map_buffer_range = true;
 ctx-Extensions.ARB_point_sprite = true;
-   ctx-Extensions.ARB_sampler_objects = true;
 ctx-Extensions.ARB_shader_objects = true;
 ctx-Extensions.ARB_shading_language_100 = true;
 ctx-Extensions.ARB_sync = true;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 2688f7a..485782f 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -110,7 +110,7 @@ static const struct extension extension_table[] = {
 { GL_ARB_point_sprite,o(ARB_point_sprite),   
 GL, 2003 },
 { GL_ARB_provoking_vertex,o(EXT_provoking_vertex),   
 GL, 2009 },
 { GL_ARB_robustness,  o(dummy_true), 
 GL, 2010 },
-   { GL_ARB_sampler_objects, o(ARB_sampler_objects), 
GL, 2009 },
+   { GL_ARB_sampler_objects, o(dummy_true),  
GL, 2009 },
 { GL_ARB_seamless_cube_map,   o(ARB_seamless_cube_map),  
 GL, 2009 },
 { GL_ARB_shader_bit_encoding, 
o(ARB_shader_bit_encoding), GL, 2010 },
 { GL_ARB_shader_objects,  o(ARB_shader_objects), 
 GL, 2002 },
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 55dc205..f9f18fb 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -283,11 +283,6 @@ static const int extra_GLSL_130[] = {
 EXTRA_END
  };

-static const int extra_ARB_sampler_objects[] = {
-   EXT(ARB_sampler_objects),
-   EXTRA_END
-};
-

  EXTRA_EXT(ARB_ES2_compatibility);
  EXTRA_EXT(ARB_texture_cube_map);
@@ -1270,7 +1265,7 @@ static const struct value_desc values[] = {

 /* GL_ARB_sampler_objects / GL 3.3 */
 { GL_SAMPLER_BINDING,
- LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, extra_ARB_sampler_objects },
+ LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, NO_EXTRA },

 /* GL 3.0 */
 { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 },
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a08a214..e95cb29 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2893,7 +2893,6 @@ struct gl_extensions
 GLboolean ARB_occlusion_query;
 GLboolean ARB_occlusion_query2;
 GLboolean ARB_point_sprite;
-   GLboolean ARB_sampler_objects;
 GLboolean ARB_seamless_cube_map;
 GLboolean ARB_shader_bit_encoding;
 GLboolean ARB_shader_objects;
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index efaaf58..8aa5a64 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -170,12 +170,12 @@ compute_version(struct gl_context *ctx)
ctx-Extensions.ARB_explicit_attrib_location
ctx-Extensions.ARB_instanced_arrays
ctx-Extensions.ARB_occlusion_query2
-  ctx-Extensions.ARB_sampler_objects
ctx-Extensions.ARB_shader_bit_encoding
ctx-Extensions.ARB_texture_rgb10_a2ui
ctx-Extensions.ARB_timer_query
ctx-Extensions.ARB_vertex_type_2_10_10_10_rev
ctx-Extensions.EXT_texture_swizzle);
+  /* ARB_sampler_objects is always enabled in mesa 
*/

 if (ver_3_3) {
major = 3;
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index a9071f5..2428085 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ 

Re: [Mesa-dev] [PATCH 16/21] swrast: Support sampler object for texture fetching state

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

swrast needs to pass sampler object into all texture fetching functions
to use correct sampling state when sampler object is bound to the unit.
The changes were made using half manual regular expression replace.

With the patch llvmpipe didn't get any regressions.


As Marek said, this code has no connection to llvmpipe.

When you see Mesa X11 or Software Rasterizer in the GL_RENDERER 
string you're using the swrast code/driver.


In any case, the changes look OK to me.
Reviewed-by: Brian Paul bri...@vmware.com

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


Re: [Mesa-dev] [PATCH 3/3] i965: Support MESA_FORMAT_SIGNED_RGBA_16.

2012-06-11 Thread Eric Anholt
On Sat,  9 Jun 2012 02:33:22 -0700, Kenneth Graunke kenn...@whitecape.org 
wrote:
 The hardware supports this format with no known quirks, so we may as
 well enable it.
 
 Alpha blending is not supported until Sandybridge, but as far as I can
 tell, OpenGL doesn't require alpha blending on SNORM formats.  Plus, we
 already expose R8G8B8A8_SNORM which has a similar restriction.
 
 +10 oglconform snorm-textures subcases
 
 Cc: Eric Anholt e...@anholt.net
 Signed-off-by: Kenneth Graunke kenn...@whitecape.org

Right, GL 3.1 core spec page 119 says that the snorms are required only
for texturing, not for rendering, and the EXT_texture_snorm spec doesn't
expect them to be necessarily supported for rendering in the issues.
The brw_wm_surface_state.c table should prevent rendering to both of
these due to the blending limitation when appropriate.

This patch is

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


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


Re: [Mesa-dev] [PATCH 17/21] mesa/samplerobj: Allow meta module to call sampler functions

2012-06-11 Thread Brian Paul

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

To allow meta module to use sample objects mesa GL functions need to be
visible and linkable for meta module.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com
---
  src/mesa/main/samplerobj.c |8 
  src/mesa/main/samplerobj.h |   11 +++
  2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index f276296..f2d99a0 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -160,7 +160,7 @@ _mesa_delete_sampler_object(struct gl_context *ctx,
  }


-static void GLAPIENTRY
+void GLAPIENTRY
  _mesa_GenSamplers(GLsizei count, GLuint *samplers)
  {
 GET_CURRENT_CONTEXT(ctx);
@@ -192,7 +192,7 @@ _mesa_GenSamplers(GLsizei count, GLuint *samplers)
  }


-static void GLAPIENTRY
+void GLAPIENTRY
  _mesa_DeleteSamplers(GLsizei count, const GLuint *samplers)
  {
 GET_CURRENT_CONTEXT(ctx);
@@ -242,7 +242,7 @@ _mesa_IsSampler(GLuint sampler)
  }


-static void GLAPIENTRY
+void GLAPIENTRY
  _mesa_BindSampler(GLuint unit, GLuint sampler)
  {
 struct gl_sampler_object *sampObj;
@@ -601,7 +601,7 @@ set_sampler_srgb_decode(struct gl_context *ctx,
  }


-static void GLAPIENTRY
+void GLAPIENTRY
  _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
  {
 struct gl_sampler_object *sampObj;
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index 33da894..e70ee48 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -79,5 +79,16 @@ _mesa_init_sampler_object_functions(struct dd_function_table 
*driver);
  extern void
  _mesa_init_sampler_object_dispatch(struct _glapi_table *disp);

+extern void GLAPIENTRY
+_mesa_BindSampler(GLuint unit, GLuint sampler);
+
+extern void GLAPIENTRY
+_mesa_GenSamplers(GLsizei count, GLuint *samplers);
+
+extern void GLAPIENTRY
+_mesa_DeleteSamplers(GLsizei count, const GLuint *samplers);
+
+extern void GLAPIENTRY
+_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param);

  #endif /* SAMPLEROBJ_H */



This and the rest of the meta-related changes look good too.

Nice work!

Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] meta: Don't alter fragment color clamp in DrawPixels().

2012-06-11 Thread Eric Anholt
On Sat,  9 Jun 2012 02:33:20 -0700, Kenneth Graunke kenn...@whitecape.org 
wrote:
 DrawPixels uses the MESA_META_CLAMP_FRAGMENT_COLOR flag to save/restore
 the fragment color clamp mode.  This is unnecessary since it never
 alters it.  It's also harmful: when the clamp mode is GL_FIXED_ONLY,
 setting this flag causes _mesa_meta_begin to force it to GL_FALSE,
 breaking clamping on SNORM formats.
 
 DrawPixels should use the user-specified clamp mode and not change it.
 
 Fixes Piglit's spec/ARB_color_buffer_float/GL_RGBA8_SNORM-drawpixels
 test on i965/Sandybridge (with SNORM render targets re-enabled).
 
 Cc: Eric Anholt e...@anholt.net
 Signed-off-by: Kenneth Graunke kenn...@whitecape.org

This makes sense, since our meta drawpixels code is fixed function for
color rendering, so we should leave GL_FIXED_ONLY in place and allow it
to clamp.  If we ever make shaders for it, we'd have to revisit this
anyway.

These two are:

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


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


Re: [Mesa-dev] [PATCH] mesa: implement glTexImage as glTexSubImage when possible

2012-06-11 Thread Brian Paul

On 06/10/2012 11:42 PM, Eric Anholt wrote:

On Fri,  8 Jun 2012 14:31:52 -0600, Brian Paulbri...@vmware.com  wrote:

I've now seen a couple apps that replace a whole texture image with a
glTexImage() call instead of glTexSubImage().  The later is better
because we can skip freeing/allocating texture memory.

This patch checks if the new glTexImage's format and size matches the
current image.  If so, use the TexSubImage path.


This only makes sense if drivers consistently do blit uploads for
texsubimage -- otherwise, teximage (which does) is better.  Right now
i965 only manages to do so for non-depth, GL_TEXTURE_2D textures,
pre-gen6.  Hopefully that will get fixed now that we've got the 3d blit
code, so that wouldn't block this patch for us.

For hardware drivers, I expect this to be no change or a loss, though.
Do you have any numbers for any driver, including software?


Most apps that want to replace a whole texture image will be using 
glTexSubImage() already.  I've seen many apps, examples and texts that 
use/recommend this approach.  So it seems to me that using this path 
in an infrequent/corner case shouldn't have any downside (in principle 
at least).


This change lets of skip some texture state validation and memory 
free/alloc so it should be a win, modulo the blit issue.


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


Re: [Mesa-dev] [PATCH 00/11] docs: html cleanup

2012-06-11 Thread Brian Paul

On 06/10/2012 04:57 AM, Andreas Boll wrote:

Hi,

the following patch series is the first part of cleaning up docs/.

Please review and commit.


I'm not an HTML expert but these look ok to me.  Can you commit/push 
or should I?



Q: are lower-case html tags recommended or the usual convention or 
just your personal preference?  Just wondering.





The next steps are:
- finish html cleanup (more well-formed html)
 Tools I'm using:
 * http://validator.w3.org/
 * http://tidy.sourceforge.net/
- update docs content
- drop obsolete docs


OK.




@ release manager
Is there a script for converting the git shortlog into html in relnotes-*.html 
or are they converted by hand?
The reason I'm asking is that not all html special chars are correctly escaped 
and the changes are not well-formed.


I'm not sure how Ian's been doing that.  If any sort of git/sh script 
is used, it should probably be checked into the tree or documented 
with the rest of the new-release instructions.


Ian?

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


Re: [Mesa-dev] Mesa (master): automake: Add a prefix variable for libglsl sources.

2012-06-11 Thread Jose Fonseca
This breaks the SCons build, which parses src/glsl/Makefile.sources, and can't 
understand $(GLSL_SRCDIR)/ as it only supports a simple subset of Make syntax.

Is there some other way to achieve this effect, without changing 
src/glsl/Makefile.sources?

Jose

- Original Message -
 Module: Mesa
 Branch: master
 Commit: 446faee094ae6f0a4914b59a9eb87077a1f7b3c5
 URL:

 http://cgit.freedesktop.org/mesa/mesa/commit/?id=446faee094ae6f0a4914b59a9eb87077a1f7b3c5
 
 Author: Eric Anholt e...@anholt.net
 Date:   Tue May 29 14:45:10 2012 -0700
 
 automake: Add a prefix variable for libglsl sources.
 
 See e86c40a84d241b954594f5ae7df9b9c3fc797a4e for reasoning.  In the
 process I did s/:=/=/ to shut up automake about nonportable make
 syntax.
 
 ---
 
  src/glsl/Android.mk   |1 +
  src/glsl/Makefile |1 +
  src/glsl/Makefile.sources |  172
  ++--
  3 files changed, 88 insertions(+), 86 deletions(-)
 
 diff --git a/src/glsl/Android.mk b/src/glsl/Android.mk
 index cf793d6..66c8bec 100644
 --- a/src/glsl/Android.mk
 +++ b/src/glsl/Android.mk
 @@ -25,6 +25,7 @@
  
  LOCAL_PATH := $(call my-dir)
  
 +GLSL_SRCDIR = .
  include $(LOCAL_PATH)/Makefile.sources
  
  # ---
 diff --git a/src/glsl/Makefile b/src/glsl/Makefile
 index 7c80c95..2ae46d1 100644
 --- a/src/glsl/Makefile
 +++ b/src/glsl/Makefile
 @@ -7,6 +7,7 @@ include $(TOP)/configs/current
  
  LIBNAME = glsl
  
 +GLSL_SRCDIR=.
  include Makefile.sources
  
  GLCPP_SOURCES = \
 diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
 index caa8ad5..b58de17 100644
 --- a/src/glsl/Makefile.sources
 +++ b/src/glsl/Makefile.sources
 @@ -2,92 +2,92 @@
  
  # libglcpp
  
 -LIBGLCPP_FILES := \
 - glcpp/pp.c
 +LIBGLCPP_FILES = \
 + $(GLSL_SRCDIR)/glcpp/pp.c
  
 -LIBGLCPP_GENERATED_FILES := \
 - glcpp/glcpp-lex.c \
 - glcpp/glcpp-parse.c
 +LIBGLCPP_GENERATED_FILES = \
 + $(GLSL_SRCDIR)/glcpp/glcpp-lex.c \
 + $(GLSL_SRCDIR)/glcpp/glcpp-parse.c
  
  # libglsl
  
 -LIBGLSL_FILES := \
 - strtod.c \
 - ralloc.c
 +LIBGLSL_FILES = \
 + $(GLSL_SRCDIR)/strtod.c \
 + $(GLSL_SRCDIR)/ralloc.c
  
 -LIBGLSL_CXX_FILES := \
 - ast_expr.cpp \
 - ast_function.cpp \
 - ast_to_hir.cpp \
 - ast_type.cpp \
 - builtin_variables.cpp \
 - glsl_parser_extras.cpp \
 - glsl_types.cpp \
 - glsl_symbol_table.cpp \
 - hir_field_selection.cpp \
 - ir_basic_block.cpp \
 - ir_builder.cpp \
 - ir_clone.cpp \
 - ir_constant_expression.cpp \
 - ir.cpp \
 - ir_expression_flattening.cpp \
 - ir_function_can_inline.cpp \
 - ir_function_detect_recursion.cpp \
 - ir_function.cpp \
 - ir_hierarchical_visitor.cpp \
 - ir_hv_accept.cpp \
 - ir_import_prototypes.cpp \
 - ir_print_visitor.cpp \
 - ir_reader.cpp \
 - ir_rvalue_visitor.cpp \
 - ir_set_program_inouts.cpp \
 - ir_validate.cpp \
 - ir_variable_refcount.cpp \
 - linker.cpp \
 - link_functions.cpp \
 - link_uniforms.cpp \
 - link_uniform_initializers.cpp \
 - loop_analysis.cpp \
 - loop_controls.cpp \
 - loop_unroll.cpp \
 - lower_clip_distance.cpp \
 - lower_discard.cpp \
 - lower_discard_flow.cpp \
 - lower_if_to_cond_assign.cpp \
 - lower_instructions.cpp \
 - lower_jumps.cpp \
 - lower_mat_op_to_vec.cpp \
 - lower_noise.cpp \
 - lower_texture_projection.cpp \
 - lower_variable_index_to_cond_assign.cpp \
 - lower_vec_index_to_cond_assign.cpp \
 - lower_vec_index_to_swizzle.cpp \
 - lower_vector.cpp \
 - lower_output_reads.cpp \
 - opt_algebraic.cpp \
 - opt_array_splitting.cpp \
 - opt_constant_folding.cpp \
 - opt_constant_propagation.cpp \
 - opt_constant_variable.cpp \
 - opt_copy_propagation.cpp \
 - opt_copy_propagation_elements.cpp \
 - opt_dead_code.cpp \
 - opt_dead_code_local.cpp \
 - opt_dead_functions.cpp \
 - opt_function_inlining.cpp \
 - opt_if_simplification.cpp \
 - opt_noop_swizzle.cpp \
 - opt_redundant_jumps.cpp \
 - opt_structure_splitting.cpp \
 - opt_swizzle_swizzle.cpp \
 - opt_tree_grafting.cpp \
 - s_expression.cpp
 +LIBGLSL_CXX_FILES = \
 + $(GLSL_SRCDIR)/ast_expr.cpp \
 + $(GLSL_SRCDIR)/ast_function.cpp \
 + $(GLSL_SRCDIR)/ast_to_hir.cpp \
 + $(GLSL_SRCDIR)/ast_type.cpp \
 + $(GLSL_SRCDIR)/builtin_variables.cpp \
 + $(GLSL_SRCDIR)/glsl_parser_extras.cpp \
 + $(GLSL_SRCDIR)/glsl_types.cpp \
 + $(GLSL_SRCDIR)/glsl_symbol_table.cpp \
 + $(GLSL_SRCDIR)/hir_field_selection.cpp \
 + $(GLSL_SRCDIR)/ir_basic_block.cpp \
 + $(GLSL_SRCDIR)/ir_builder.cpp \
 + $(GLSL_SRCDIR)/ir_clone.cpp \
 + $(GLSL_SRCDIR)/ir_constant_expression.cpp \
 + $(GLSL_SRCDIR)/ir.cpp \
 + $(GLSL_SRCDIR)/ir_expression_flattening.cpp \
 + $(GLSL_SRCDIR)/ir_function_can_inline.cpp \
 + 

Re: [Mesa-dev] [PATCH] mesa: Check for a negative size parameter in glCopyBufferSubData().

2012-06-11 Thread Ian Romanick

On 06/08/2012 10:18 PM, Kenneth Graunke wrote:

 From the GL_ARB_copy_buffer spec:
An INVALID_VALUE error is generated if any of readoffset, writeoffset,
  or size are negative [...]

Fixes oglconform's copybuffer/negative.CNNegativeValues test.

Signed-off-by: Kenneth Graunkekenn...@whitecape.org


Reviewed-by: Ian Romanick ian.d.roman...@intel.com

You should cherry pick this to 8.0 right away.


---
  src/mesa/main/bufferobj.c |6 ++
  1 file changed, 6 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 5415665..846260d 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1360,6 +1360,12 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum 
writeTarget,
return;
 }

+   if (size  0) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  glCopyBufferSubData(writeOffset = %d), (int) size);
+  return;
+   }
+
 if (readOffset + size  src-Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
glCopyBufferSubData(readOffset + size = %d),


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


Re: [Mesa-dev] Mesa (master): automake: Add a prefix variable for libglsl sources.

2012-06-11 Thread Jose Fonseca
- Original Message -
 This breaks the SCons build, which parses src/glsl/Makefile.sources,
 and can't understand $(GLSL_SRCDIR)/ as it only supports a simple
 subset of Make syntax.
 
 Is there some other way to achieve this effect, without changing
 src/glsl/Makefile.sources?

Actually, the scons' makefile parser handles $(GLSL_SRCDIR)/ just fine. The 
problem is merely that GLSL_SRCDIR is not defined.

The patch below would fix it, and should (hopefully) not affect automake, but 
I'm not sure.

Would this be ok?


Jose


diff --git a/scons/source_list.py b/scons/source_list.py
index 1d5166b..8111f43 100644
--- a/scons/source_list.py
+++ b/scons/source_list.py
@@ -63,7 +63,7 @@ class SourceListParser(object):
 self._error('not a variable definition')
 
 if op_pos  0:
-if line[op_pos - 1] in [':', '+']:
+if line[op_pos - 1] in [':', '+', '?']:
 op_pos -= 1
 else:
 self._error('only =, :=, and += are supported')
@@ -77,6 +77,9 @@ class SourceListParser(object):
 self.symbol_table[sym] = val
 elif op == '+=':
 self.symbol_table[sym] += ' ' + val
+elif op == '?=':
+if sym not in self.symbol_table:
+self.symbol_table[sym] = val
 
 def _parse_line(self, line):
 Parse a source list line.
diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index b58de17..0425fa3 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -1,5 +1,7 @@
 # shared source lists for Makefile, SConscript, and Android.mk
 
+GLSL_SRCDIR ?= .
+
 # libglcpp
 
 LIBGLCPP_FILES = \
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index 63fbf58..608aa79 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -1,5 +1,7 @@
 ### Lists of source files, included by Makefiles
 
+SRCDIR ?= .
+
 # this is part of MAIN_FILES
 MAIN_ES_FILES = \
$(SRCDIR)/main/api_exec_es1.c \
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 50976] New: Fails to build with error: git_sha1.h: No such file or directory

2012-06-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50976

 Bug #: 50976
   Summary: Fails to build with error: git_sha1.h: No such file or
directory
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: Other
OS/Version: Linux (All)
Status: NEW
  Severity: blocker
  Priority: medium
 Component: Other
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: dar...@chaosreigns.com
CC: e...@anholt.net


First bad commit:

07abd913b654a1a04a90db6203a92a14e4ae795a is the first bad commit
Author: Eric Anholt e...@anholt.net
automake: Move top-level makefile to automake.

Last good commit (just before it):  743e505315b6be851618caed61981d7c1617bf45

I'm building with:  ./autogen.sh --prefix=$WLD --enable-gles2
--disable-gallium-egl --with-egl-platforms=wayland,x11,drm --enable-gbm
--enable-shared-glapi --with-gallium-drivers=r300,r600,swrast,nouveau

Need to git clean or something to reproduce this, otherwise it works with a
previously generated git_sha1.h.

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


[Mesa-dev] [Bug 50976] Fails to build with error: git_sha1.h: No such file or directory

2012-06-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50976

Darxus dar...@chaosreigns.com changed:

   What|Removed |Added

 CC||dar...@chaosreigns.com

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


Re: [Mesa-dev] [PATCH 00/11] docs: html cleanup

2012-06-11 Thread Andreas Boll
2012/6/11 Brian Paul bri...@vmware.com:
 On 06/10/2012 04:57 AM, Andreas Boll wrote:

 Hi,

 the following patch series is the first part of cleaning up docs/.

 Please review and commit.


Please commit/push. I don't have commit access.


 I'm not an HTML expert but these look ok to me.  Can you commit/push or
 should I?


 Q: are lower-case html tags recommended or the usual convention or just your
 personal preference?  Just wondering.


Lower-case is recommended, because it's more future-proof wrt. XHTML
where lower-case tags are required.
I think nowadays it's the usual convention.

You should either use upper- or lower-case tags to be consistent.
So I'm tending to write lower-case only
and it's definitly less use of the shift key ;)



 The next steps are:
 - finish html cleanup (more well-formed html)
     Tools I'm using:
     * http://validator.w3.org/
     * http://tidy.sourceforge.net/
 - update docs content
 - drop obsolete docs


 OK.




 @ release manager
 Is there a script for converting the git shortlog into html in
 relnotes-*.html or are they converted by hand?
 The reason I'm asking is that not all html special chars are correctly
 escaped and the changes are not well-formed.


 I'm not sure how Ian's been doing that.  If any sort of git/sh script is
 used, it should probably be checked into the tree or documented with the
 rest of the new-release instructions.

 Ian?

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


Re: [Mesa-dev] Mesa (master): automake: Add a prefix variable for libglsl sources.

2012-06-11 Thread Jose Fonseca
- Original Message -
 - Original Message -
  This breaks the SCons build, which parses
  src/glsl/Makefile.sources,
  and can't understand $(GLSL_SRCDIR)/ as it only supports a simple
  subset of Make syntax.
  
  Is there some other way to achieve this effect, without changing
  src/glsl/Makefile.sources?
 
 Actually, the scons' makefile parser handles $(GLSL_SRCDIR)/ just
 fine. The problem is merely that GLSL_SRCDIR is not defined.
 
 The patch below would fix it, and should (hopefully) not affect
 automake, but I'm not sure.
 
 Would this be ok?

I tried to build with automake and my change and it seems to work fine, so I'll 
go ahead and commit it, as all scons builds are totally busted without it.

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


[Mesa-dev] [Bug 50976] Fails to build with error: git_sha1.h: No such file or directory

2012-06-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50976

U. Artie Eoff ullysses.a.e...@intel.com changed:

   What|Removed |Added

 CC||ullysses.a.e...@intel.com

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


Re: [Mesa-dev] [PATCH] scons: Fix Haiku binary compatibility

2012-06-11 Thread Jakob Bornecrantz
On Thu, Jun 7, 2012 at 5:20 PM, Alexander von Gluck IV
kallis...@unixzen.com wrote:
 From 44fa55d3f49884c824306504943ca2a1382601f0 Mon Sep 17 00:00:00 2001

 * Our binary compatibility is targeted to Pentimum or higher,
  these changes ensure we keep proper optimizations
 * Fixes strange if statement
  '! windows or debug or True'

Looks good, or at least it doesn't seem to break anything else can't
really comment on
the Haiku specific parts of this.

Reviewed-by: Jakob Bornecrantz ja...@vmware.com

Lets get you commit access, so these patches doesn't root on the ML for to long.

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


Re: [Mesa-dev] [PATCH] scons: Fix Haiku binary compatibility

2012-06-11 Thread Jose Fonseca


- Original Message -
 From 44fa55d3f49884c824306504943ca2a1382601f0 Mon Sep 17 00:00:00
 2001
 
 * Our binary compatibility is targeted to Pentimum or higher,
   these changes ensure we keep proper optimizations
 * Fixes strange if statement
   '! windows or debug or True'
 ---
  scons/gallium.py |9 -
  1 files changed, 8 insertions(+), 1 deletions(-)
 
 diff --git a/scons/gallium.py b/scons/gallium.py
 index 2fa80db..f60c2d4 100755
 --- a/scons/gallium.py
 +++ b/scons/gallium.py
 @@ -327,7 +327,7 @@ def generate(env):
  #'-march=pentium4',
  ]
  if distutils.version.LooseVersion(ccversion) =
  distutils.version.LooseVersion('4.2') \
 -   and (platform != 'windows' or env['build'] == 'debug'
 or True):
 +   and platform not in ['windows', 'haiku']:

This doesn't look correct. I don't remember the story of True here, but to 
avoid chaning windows behavior, it should be 

  and platform != 'haiku'

  # NOTE: We need to ensure stack is realigned given
  that we
  # produce shared objects, and have no control over
  the stack
  # alignment policy of the application. Therefore we
  need
 @@ -346,6 +346,13 @@ def generate(env):
  if platform in ['windows', 'darwin']:
  # Workaround
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
  ccflags += ['-fno-common']
 +if platform in ['haiku']:
 +ccflags += [
 +'-mstackrealign', # ensure stack is aligned
 +'-march=i586', # Haiku target is Pentium
 +'-mtune=i686', # Use i686 where we can
 +'-mmmx', # Use mmx math where we can

Any reason not to set -msse and -msse2 ?

 +]
  if env['machine'] == 'x86_64':
  ccflags += ['-m64']
  if platform == 'darwin':
 --
 1.7.7.2
 
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 50979] New: Request an fdo account

2012-06-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50979

 Bug #: 50979
   Summary: Request an fdo account
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: All
OS/Version: other
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: kallis...@unixzen.com


Alexander von Gluck
kallis...@unixzen.com

Reason for request:
 Upkeep of Haiku Mesa build target and other related tasks.

 My goal for Mesa is to keep stock Mesa (and Gallium3D) functioning on Haiku.
So far the design policy has been to do minimal Haiku references in the Mesa
codebase to ensure as little strain as possible occurs on the Mesa team. (not
needing to rewrite large chunks of Haiku centric code for changes, etc)

 Stock Mesa on Haiku.. that's our goal.

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


[Mesa-dev] [Bug 50979] Request an fdo account

2012-06-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50979

--- Comment #1 from Alexander von Gluck kallis...@unixzen.com 2012-06-11 
12:07:58 PDT ---
Created attachment 62898
  -- https://bugs.freedesktop.org/attachment.cgi?id=62898
kallisti5 public ssh key

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


[Mesa-dev] [Bug 50979] Request an fdo account

2012-06-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50979

--- Comment #2 from Alexander von Gluck kallis...@unixzen.com 2012-06-11 
12:15:04 PDT ---
Created attachment 62900
  -- https://bugs.freedesktop.org/attachment.cgi?id=62900
kallisti5 public gpg key

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


[Mesa-dev] [Bug 50979] Request an fdo account

2012-06-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50979

--- Comment #3 from Alexander von Gluck kallis...@unixzen.com 2012-06-11 
12:19:31 PDT ---
Little additional information:

 * xorg foundation member since Jan 2012
 * frequent commiter to Haiku project (MIT licensed)
   http://cgit.haiku-os.org/haiku/log/?qt=authorq=kallisti5
 * wrote Haiku radeon_hd driver
 * got stock Mesa 8.0 swrast running under Haiku (moving away from Haiku's
forked Mesa)

-- 
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] scons: Fix Haiku binary compatibility

2012-06-11 Thread Alexander von Gluck

On 11.06.2012 14:04, Jose Fonseca wrote:

- Original Message -

From 44fa55d3f49884c824306504943ca2a1382601f0 Mon Sep 17 00:00:00
2001

* Our binary compatibility is targeted to Pentimum or higher,
  these changes ensure we keep proper optimizations
* Fixes strange if statement
  '! windows or debug or True'
---
 scons/gallium.py |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/scons/gallium.py b/scons/gallium.py
index 2fa80db..f60c2d4 100755
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -327,7 +327,7 @@ def generate(env):
 #'-march=pentium4',
 ]
 if distutils.version.LooseVersion(ccversion) =
 distutils.version.LooseVersion('4.2') \
-   and (platform != 'windows' or env['build'] == 'debug'
or True):
+   and platform not in ['windows', 'haiku']:


This doesn't look correct. I don't remember the story of True here, but to 
avoid chaning windows behavior, it should

be
  and platform != 'haiku'


Good point. The problem is I thought that solution was messy so I decided 
the more correct way would be to clean it up.


Does anyone remember why the True was there? Looks like it may of been an 
accident (or just bad logic)



 # NOTE: We need to ensure stack is realigned given
 that we
 # produce shared objects, and have no control over
 the stack
 # alignment policy of the application. Therefore we
 need
@@ -346,6 +346,13 @@ def generate(env):
 if platform in ['windows', 'darwin']:
 # Workaround
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
 ccflags += ['-fno-common']
+if platform in ['haiku']:
+ccflags += [
+'-mstackrealign', # ensure stack is aligned
+'-march=i586', # Haiku target is Pentium
+'-mtune=i686', # Use i686 where we can
+'-mmmx', # Use mmx math where we can


Any reason not to set -msse and -msse2 ?


Haiku targets code to run on Pentimum and above. SSE was introduced on 
Pentimum III :)


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


Re: [Mesa-dev] Mesa (master): automake: Add a prefix variable for libglsl sources.

2012-06-11 Thread Eric Anholt
On Mon, 11 Jun 2012 10:02:34 -0700 (PDT), Jose Fonseca jfons...@vmware.com 
wrote:
 This breaks the SCons build, which parses src/glsl/Makefile.sources,
 and can't understand $(GLSL_SRCDIR)/ as it only supports a simple
 subset of Make syntax.
 
 Is there some other way to achieve this effect, without changing
 src/glsl/Makefile.sources?

Thanks for pushing the fix -- looks fine.

It turns out that while working on my next series of automaking, I've
found that there's a knob to tell automake to stfu about use of gmake
features, so this dance may not actually be required.


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


Re: [Mesa-dev] [PATCH 06/21] mesa/macros: Add ARRAY_SIZE helper macro core mesa

2012-06-11 Thread Eric Anholt
On Mon, 11 Jun 2012 09:07:19 -0600, Brian Paul bri...@vmware.com wrote:
 On 06/11/2012 12:59 AM, Pauli Nieminen wrote:
  diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
  index d1df2ce..e05fa14 100644
  --- a/src/mesa/main/macros.h
  +++ b/src/mesa/main/macros.h
  @@ -679,5 +679,8 @@ do {\
#define ENUM_TO_DOUBLE(E)  ((GLdouble)(GLint)(E))
#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
 
  +#ifndef ARRAY_SIZE
  +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
  +#endif
 
#endif
 
 
 Core Mesa uses the Element() macro for this, defined in compiler.h. 
 We should just use one or the other.  I'd go with just using Element() 
 everywhere for now to avoid churn.

On the other hand, ARRAY_SIZE is the macro from the linux kernel, which
we also use in libdrm and the 2d driver and most of piglit.  It's nice
to be able to type the same thing across the driver project.  It's also
very clear what it does, unlike a macro named Elements in vbo-related
code which makes me think of vertex elements.

But I'm fine with Mesa core continuing with Elements to avoid churn.


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


Re: [Mesa-dev] [PATCH] configure.ac: Add --with-(gl|glu|osmesa)-lib-name options

2012-06-11 Thread Kenneth Graunke
On 06/11/2012 05:58 AM, Brad King wrote:
 On 06/05/2012 02:03 PM, Kenneth Graunke wrote:
 On 06/05/2012 10:59 AM, Brad King wrote:
 ./autogen.sh --with-gl-lib-name=GL --with-glu-lib-name=GLU
 --with-osmesa-lib-name=OSMesa ...

 That looks cleaner to me.  Here is a patch for it.

 Reviewed-by: Kenneth Graunke kenn...@whitecape.org

 If there are no objections, I'll push this tomorrow.  Thanks!
 
 I haven't seen this appear in any origin branch yet.  No rush,
 I just want to make sure it isn't accidentally forgotten.
 
 Thanks,
 -Brad

Oh, sorry!  Lost track of this.  It looks like Eric's pushed it now.

Thanks again.

--Ken


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


Re: [Mesa-dev] [PATCH 06/21] mesa: Move DepthMode to texture object

2012-06-11 Thread Eric Anholt
On Mon, 11 Jun 2012 09:59:21 +0300, Pauli Nieminen 
pauli.niemi...@linux.intel.com wrote:
 GL_DEPTH_TEXTURE_MODE isn't meant to be part of sampler state based on
 compatibility profile specifications.
 
 OpenGL specification 4.1 compatibility 20100725 3.9.2:
 ... The values accepted in the pname parameter
 are TEXTURE_WRAP_S, TEXTURE_WRAP_T, TEXTURE_WRAP_R, TEXTURE_MIN_-
 FILTER, TEXTURE_MAG_FILTER, TEXTURE_BORDER_COLOR, TEXTURE_MIN_-
 LOD, TEXTURE_MAX_LOD, TEXTURE_LOD_BIAS, TEXTURE_COMPARE_MODE, and
 TEXTURE_COMPARE_FUNC. Texture state listed in table 6.25 but not listed here 
 and
 in the sampler state in table 6.26 is not part of the sampler state, and 
 remains in the
 texture object.
 
 Same can be found from 3.3 compatibility specification.
 
 That makes me think that moving DepthMode from sampler state makes sense
 to avoid bugs if DepthMode happens to be used with sampler objects.

Specifically, it's in Table 6.24. Textures (state per texture object),
so that seems pretty clear.

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


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


Re: [Mesa-dev] [PATCH 01/21] mesa/format_unpack: Fix YCBCR unpack

2012-06-11 Thread Ian Romanick

On 06/11/2012 07:41 AM, Brian Paul wrote:

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

The YCBCR unpack was reading one RGBA value from 4 bytes of YCBCR
texture. But single pixel is only 2 bytes in the format. After
noticing that error Ville told me that second chroma sample has to
be average to match video requirements.

Looking at places where unpack to rgba is called it is possible to get
odd X coordinate and odd number of bytes. That makes unpack operation
complex problem. But I assume that source allocation is 4 byte aligned
always. That should hold for most of allocations but may fail.

Better solution would be threating YCBCR as compressed format
internally. But I suspect that I would break a lot of assumptions
everywhere with that changes.

But same time as I was checking call sites I started suspecting that we
can't ever hit these unpack functions for YCBCR. But I need to study the
code paths a lot more to be sure if that is true.

Changes to fix unpacking:
* Always start reading from the start of chroma pair.
* Always read to the end of chroma pair
* Unpack two RGB values in single iteration
* Read next chroma pair (if available) to calculate average for second
sample.
* Refactor shared color space conversion code to separate function.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com


This unpack code isn't used during texture sampling by swrast. I think
the only way it would be hit is if one did a glReadPixels from ycbcr
texture attached to a FBO. But we should probably disallow that
(attaching ycbcr textures to FBOs) in the first place.


Either that, or glGetTexImage(GL_RGB) of a GL_YCBCR_MESA texture.  I 
don't think we're permitted to disallow that.


I think we need a test case for this.


Have you found another path that hits this code?

The changes look OK in any case.

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

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



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


Re: [Mesa-dev] [PATCH 01/21] mesa/format_unpack: Fix YCBCR unpack

2012-06-11 Thread Brian Paul

On 06/11/2012 03:15 PM, Ian Romanick wrote:

On 06/11/2012 07:41 AM, Brian Paul wrote:

On 06/11/2012 12:59 AM, Pauli Nieminen wrote:

The YCBCR unpack was reading one RGBA value from 4 bytes of YCBCR
texture. But single pixel is only 2 bytes in the format. After
noticing that error Ville told me that second chroma sample has to
be average to match video requirements.

Looking at places where unpack to rgba is called it is possible to get
odd X coordinate and odd number of bytes. That makes unpack operation
complex problem. But I assume that source allocation is 4 byte aligned
always. That should hold for most of allocations but may fail.

Better solution would be threating YCBCR as compressed format
internally. But I suspect that I would break a lot of assumptions
everywhere with that changes.

But same time as I was checking call sites I started suspecting
that we
can't ever hit these unpack functions for YCBCR. But I need to
study the
code paths a lot more to be sure if that is true.

Changes to fix unpacking:
* Always start reading from the start of chroma pair.
* Always read to the end of chroma pair
* Unpack two RGB values in single iteration
* Read next chroma pair (if available) to calculate average for second
sample.
* Refactor shared color space conversion code to separate function.

Signed-off-by: Pauli Nieminenpauli.niemi...@linux.intel.com


This unpack code isn't used during texture sampling by swrast. I think
the only way it would be hit is if one did a glReadPixels from ycbcr
texture attached to a FBO. But we should probably disallow that
(attaching ycbcr textures to FBOs) in the first place.


Either that, or glGetTexImage(GL_RGB) of a GL_YCBCR_MESA texture. I
don't think we're permitted to disallow that.

I think we need a test case for this.


Looks like I never spec'd the behaviour for glGetTexImage().  Reading 
the code, it appears that getting ycbcr as RGB would work and Pauli's 
fix would be relevant for that.


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


[Mesa-dev] [Bug 50979] Request an fdo account

2012-06-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50979

Brian Paul bri...@vmware.com changed:

   What|Removed |Added

 AssignedTo|mesa-dev@lists.freedesktop. |sitewranglers@lists.freedes
   |org |ktop.org
Product|Mesa|freedesktop.org
Version|git |unspecified
  Component|Mesa core   |New Accounts

--- Comment #4 from Brian Paul bri...@vmware.com 2012-06-11 14:37:51 PDT ---
Approved.

-- 
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] scons: Fix Haiku binary compatibility

2012-06-11 Thread Alexander von Gluck

On 11.06.2012 14:32, Alexander von Gluck wrote:

On 11.06.2012 14:04, Jose Fonseca wrote:

- Original Message -

From 44fa55d3f49884c824306504943ca2a1382601f0 Mon Sep 17 00:00:00
2001

* Our binary compatibility is targeted to Pentimum or higher,
  these changes ensure we keep proper optimizations
* Fixes strange if statement
  '! windows or debug or True'
---
 scons/gallium.py |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/scons/gallium.py b/scons/gallium.py
index 2fa80db..f60c2d4 100755
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -327,7 +327,7 @@ def generate(env):
 #'-march=pentium4',
 ]
 if distutils.version.LooseVersion(ccversion) =
 distutils.version.LooseVersion('4.2') \
-   and (platform != 'windows' or env['build'] == 'debug'
or True):
+   and platform not in ['windows', 'haiku']:


This doesn't look correct. I don't remember the story of True here, but 
to avoid chaning windows behavior, it should

be
  and platform != 'haiku'


Good point. The problem is I thought that solution was messy so I decided 
the more correct way would be to clean it

up.

Does anyone remember why the True was there? Looks like it may of been an 
accident (or just bad logic)


Eh, I'll just change it to and platform != 'haiku' as you said to be safe.
Someone more knowledgeable of the Windows build can fix it later if it is a 
typo.



 # NOTE: We need to ensure stack is realigned given
 that we
 # produce shared objects, and have no control over
 the stack
 # alignment policy of the application. Therefore we
 need
@@ -346,6 +346,13 @@ def generate(env):
 if platform in ['windows', 'darwin']:
 # Workaround
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
 ccflags += ['-fno-common']
+if platform in ['haiku']:
+ccflags += [
+'-mstackrealign', # ensure stack is aligned
+'-march=i586', # Haiku target is Pentium
+'-mtune=i686', # Use i686 where we can
+'-mmmx', # Use mmx math where we can


Any reason not to set -msse and -msse2 ?


Haiku targets code to run on Pentimum and above. SSE was introduced on 
Pentimum III :)


Cough. *Pentium*. Not sure where the mum came from.

 Thanks!
  -- Alex

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


Re: [Mesa-dev] Mesa (master): automake: Add a prefix variable for libglsl sources.

2012-06-11 Thread Kenneth Graunke
On 06/11/2012 01:14 PM, Eric Anholt wrote:
 On Mon, 11 Jun 2012 10:02:34 -0700 (PDT), Jose Fonseca jfons...@vmware.com 
 wrote:
 This breaks the SCons build, which parses src/glsl/Makefile.sources,
 and can't understand $(GLSL_SRCDIR)/ as it only supports a simple
 subset of Make syntax.

 Is there some other way to achieve this effect, without changing
 src/glsl/Makefile.sources?
 
 Thanks for pushing the fix -- looks fine.

Thanks for fixing this, Jose.

 It turns out that while working on my next series of automaking, I've
 found that there's a knob to tell automake to stfu about use of gmake
 features, so this dance may not actually be required.

That sounds like a good plan to me, Eric.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/21] nouveau: Add support for ARB_sampler_object

2012-06-11 Thread Francisco Jerez
Pauli Nieminen pauli.niemi...@linux.intel.com writes:

 ARB_sampler_object is very simple software only extension to support.
 I want to make it mandator extension for Mesa drivers to allow meta
 module to use it.

 This patch add support for the extension to nouveau. It is completely
 untested search and replace patch. I hope someone with old NV hardware
 could give a try that there is no regressions and ARB_sampler_object
 tests passes.


Hey,

I don't think this patch is enough to get ARB_sampler_objects working.
First you need some way to find out that the current sampler has changed
so the nvXX_emit_tex_obj() hooks are re-executed before rendering.

Ideally it would be done using some kind of driver hook that would be
called when a new sampler is bound (the implementation would be a
one-liner, see nouveau_tex_parameter() in nouveau_state.c).  Apparently
glBindSampler() already sets the _NEW_TEXTURE flag so I guess another
option could be to re-validate all the texture context for all texture
units anytime it's seen set, though I'm not sure that would be a good
idea.

 Signed-off-by: Pauli Nieminen pauli.niemi...@linux.intel.com
 CC: nouv...@lists.freedesktop.org
 ---
  src/mesa/drivers/dri/nouveau/nv04_state_tex.c |   22 --
  src/mesa/drivers/dri/nouveau/nv10_state_tex.c |   23 +--
  src/mesa/drivers/dri/nouveau/nv20_state_tex.c |   25 
 ++---
  3 files changed, 39 insertions(+), 31 deletions(-)

 diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c 
 b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
 index 807e2f3..e4d695a 100644
 --- a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
 +++ b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
 @@ -32,6 +32,7 @@
  #include nv_object.xml.h
  #include nv04_3d.xml.h
  #include nv04_driver.h
 +#include main/samplerobj.h
  
  static uint32_t
  get_tex_format(struct gl_texture_image *ti)
 @@ -67,6 +68,7 @@ nv04_emit_tex_obj(struct gl_context *ctx, int emit)
   if (ctx-Texture.Unit[i]._ReallyEnabled) {
   struct gl_texture_object *t = ctx-Texture.Unit[i]._Current;
   struct gl_texture_image *ti = t-Image[0][t-BaseLevel];
 + const struct gl_sampler_object *sa = _mesa_get_samplerobj(ctx, 
 i);
   int lod_max = 1, lod_bias = 0;
  
   if (!nouveau_texture_validate(ctx, t))
 @@ -74,26 +76,26 @@ nv04_emit_tex_obj(struct gl_context *ctx, int emit)
  
   s = to_nouveau_texture(t)-surfaces[t-BaseLevel];
  
 - if (t-Sampler.MinFilter != GL_NEAREST 
 - t-Sampler.MinFilter != GL_LINEAR) {
 - lod_max = CLAMP(MIN2(t-Sampler.MaxLod, t-_MaxLambda),
 + if (sa-MinFilter != GL_NEAREST 
 + sa-MinFilter != GL_LINEAR) {
 + lod_max = CLAMP(MIN2(sa-MaxLod, t-_MaxLambda),
   0, 15) + 1;
  
   lod_bias = CLAMP(ctx-Texture.Unit[i].LodBias +
 -  t-Sampler.LodBias, -16, 15) * 8;
 +  sa-LodBias, -16, 15) * 8;
   }
  
 - format |= nvgl_wrap_mode(t-Sampler.WrapT)  28 |
 - nvgl_wrap_mode(t-Sampler.WrapS)  24 |
 + format |= nvgl_wrap_mode(sa-WrapT)  28 |
 + nvgl_wrap_mode(sa-WrapS)  24 |
   ti-HeightLog2  20 |
   ti-WidthLog2  16 |
   lod_max  12 |
   get_tex_format(ti);
  
 - filter |= log2i(t-Sampler.MaxAnisotropy)  31 |
 - nvgl_filter_mode(t-Sampler.MagFilter)  28 |
 - log2i(t-Sampler.MaxAnisotropy)  27 |
 - nvgl_filter_mode(t-Sampler.MinFilter)  24 |
 + filter |= log2i(sa-MaxAnisotropy)  31 |
 + nvgl_filter_mode(sa-MagFilter)  28 |
 + log2i(sa-MaxAnisotropy)  27 |
 + nvgl_filter_mode(sa-MinFilter)  24 |
   (lod_bias  0xff)  16;
  
   } else {
 diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c 
 b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
 index b467bb3..3b76d66 100644
 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
 +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
 @@ -31,6 +31,7 @@
  #include nv10_3d.xml.h
  #include nouveau_util.h
  #include nv10_driver.h
 +#include main/samplerobj.h
  
  void
  nv10_emit_tex_gen(struct gl_context *ctx, int emit)
 @@ -159,6 +160,7 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit)
   struct gl_texture_object *t;
   struct nouveau_surface *s;
   struct gl_texture_image *ti;
 + const struct gl_sampler_object *sa;
   uint32_t tx_format, tx_filter, tx_enable;
  
   PUSH_RESET(push, BUFCTX_TEX(i));
 @@ -172,22 +174,23 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit)
   t = ctx-Texture.Unit[i]._Current;
   s = 

[Mesa-dev] [PATCH] mesa: Build git_sha1.h before computing dependencies.

2012-06-11 Thread Eric Anholt
Otherwise, version.c doesn't get a dependency on it in a clean build,
and then it doesn't necessarily get generated before version.c is
compiled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50976
---
 src/mesa/Makefile |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/Makefile b/src/mesa/Makefile
index 845b524..b0b461f 100644
--- a/src/mesa/Makefile
+++ b/src/mesa/Makefile
@@ -135,7 +135,7 @@ asm_subdirs:
 ##
 # Dependency generation
 
-depend: $(ALL_FILES)
+depend: $(ALL_FILES) main/git_sha1.h
@ echo running $(MKDEP)
@ touch depend
@$(MKDEP) $(MKDEP_OPTIONS) $(MESA_CPPFLAGS) \
-- 
1.7.10

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


Re: [Mesa-dev] [PATCH] mesa: Build git_sha1.h before computing dependencies.

2012-06-11 Thread Jakob Bornecrantz
- Original Message -
 Otherwise, version.c doesn't get a dependency on it in a clean build,
 and then it doesn't necessarily get generated before version.c is
 compiled.
 
 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50976

Thanks for fixing this.

Reviewed-by: Jakob Bornecrantz ja...@vmware.com

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