Re: [Mesa-dev] gallium scaled types

2011-09-17 Thread Christian König
Am Freitag, den 16.09.2011, 12:58 -0700 schrieb Jose Fonseca:
[SNIP]
  This change would be best to describe a vertex and texture fetch as
  implemented by Radeons:
  
  diff --git a/src/gallium/auxiliary/util/u_format.h
  b/src/gallium/auxiliary/util/u_format.h
  index 2eb3e1b..8c4d67f 100644
  --- a/src/gallium/auxiliary/util/u_format.h
  +++ b/src/gallium/auxiliary/util/u_format.h
  @@ -91,10 +91,11 @@ struct util_format_block
  
   enum util_format_type {
  UTIL_FORMAT_TYPE_VOID = 0,
  -   UTIL_FORMAT_TYPE_UNSIGNED = 1,
  -   UTIL_FORMAT_TYPE_SIGNED = 2,
  -   UTIL_FORMAT_TYPE_FIXED = 3,
  -   UTIL_FORMAT_TYPE_FLOAT = 4
  +   UTIL_FORMAT_TYPE_FLOAT = 1,
  +   UTIL_FORMAT_TYPE_INT = 2, /* signed/unsigned */
  +   UTIL_FORMAT_TYPE_NORM = 3,/* signed/unsigned */
  +   UTIL_FORMAT_TYPE_SCALED = 4,  /* signed/unsigned */
  +   UTIL_FORMAT_TYPE_FIXED = 5,
   };
 
  @@ -121,7 +122,7 @@ enum util_format_colorspace {
   struct util_format_channel_description
   {
  unsigned type:6;/** UTIL_FORMAT_TYPE_x */
  -   unsigned normalized:1;
  +   unsigned is_signed:1;
  unsigned size:9;/** bits per channel */
   };
 
 Moving the sign out of util_format_type into util_format_channel_description 
 is fine.  
 Like NORM/FIXED can be done either way.  (For example, llvmpipe's struct 
 lp_type has them all in 1 bit flags).
 
 But fundamentally you're proposing introducing a new type, SCALED, into 
 util_format_type.
I don't think Mareks intention is to actually commit this patch, he just
wanted to describe how Radeon hardware works internally.

But yes, in the end we need something to distinct between SCALED and INT
types.

[SNIP]
  Now you can take a look at the function r600_vertex_data_type in
  r600_asm.c:2020. It's a good example of what is going on. At the end
  of the function, there is this piece of code:
  
  if (desc-channel[i].normalized) {
  *num_format = 0;
  } else {
  *num_format = 2;
  }
  
  0 means NORM, 2 means SCALED. And guess what... 1 means INT. I think
  num_format stands for numeric format. The function which is
  called
  in is_format_supported is r600_is_vertex_format_supported in
  r600_formats.h:84.
 
 I got the picture.
 
 I understand that having the INT vs SCALED flag in desc would be nice. On the 
 other hand, 
 it doesn't look like the as_float flag to r600_vertex_data_type as an 
 additional parameter would force a big rewrite.
At least it makes things allot more complicated, because how a value
ends up in a shader register is programmed in the same place
(register/opcode) as the bits per channel. So if we are going to have an
as_float flag in the fetch opcode or r600_vertex_data, then we would
need to delay compiling the shader until the actually bits per channel
is known, eventually even need to recompile a shader quite often.

  Note that r600 might be able to support SCALED textures too (I know I
  had said the opposite, but I am not sure now after I read the docs
  again). We only know SCALED doesn't work for 32 bits per channel,
  same
  as with vertices. 8 bits and 16 bits per-channel SCALED textures
  might
  work, but nobody tried that yet.
Oh, that's not true, I tried it for g3dvl iDCT transformation and it
worked flawlessly.

Actually the hardware part that does the load of a vertex element (and
with it the conversion from memory to shader register representation) is
the same hardware part that does the load from a texture, so both are
programmed very similar.

  So now we are back to the discussion about the convert-to-float flag
  in pipe_vertex_element and is_format_supported. I am not saying it's
  wrong, I am just saying it's not clean. Either way, I will respect
  the
  final decision of the implementers of this functionality.
 
 As I was playing out the changes that you suggest to u_format and llvmpipe in 
 my head, and realized one issue I hadn't till now.
 
 
 Imagine format conversion use cases like translate, u_blit, stretch blitters, 
 llvmpipe,
 where we generate complex state (x86 assembly, blit shaders, LLVM, IR) that 
 deal with ,
 and we put the source format in a key to a hash table to avoid regenerating 
 code.
 
   struct {
   enum pipe_format src_format;
   enum pipe_format dst_format;
   
   boolean stretch;
   int filtering_mode;
   ...
   };
 
 Having different enums for PIPE_xxx_INT and PIPE_xxx_SCALED will cause 
 unnecessary cache misses,
 because for these use cases INT/SCALED that are one and only.
 
 And the only solution to avoid this is to have a canonizing mapping function, 
 such as:
 
enum pipe_format
get_canonical_format(enum pipe_format) {
case PIPE_FORMAT_FOO_SINT:
case PIPE_FORMAT_FOO_SSCALED:
return PIPE_FORMAT_FOO_SINT
case PIPE_FORMAT_FOO_UINT:
case PIPE_FORMAT_FOO_USCALED:
return PIPE_FORMAT_FOO_UINT

}
 
 which is a bit painful.

Actually we have a bit of the same problem in the Radeon 

Re: [Mesa-dev] [PATCHES] enable GLX_EXT_texture_from_pixmap in software

2011-09-17 Thread Sylwester Wysocki
I'm trying to enable GLX_EXT_texture_from_pixmap in direct rendering
for swrast. After applying patches given in this thread glxinfo shows
TFP on GLX extensions string, but correlated functions don't work.

1) I found that GetGLXDRIDrawable() inside drisw_bind_tex_image()
   returns NULL, so function fails due to line:

   if (pdraw != NULL) {

   becouse there is no needed GLXDrawable key inside hash table

   if (__glxHashLookup(priv-drawHash, drawable, (void *) pdraw) == 0)
  return pdraw;

   return NULL;

2) I took a look at i915 dri2 driver and i found this hash is normally
   added inside CreateDRIDrawable() function in glx_pbuffer.c at lines:

   if (__glxHashInsert(priv-drawHash, glxdrawable, pdraw)) {
  (*pdraw-destroyDrawable) (pdraw);
  return; /* FIXME: Check what we're supposed to do here... */
   }

   but this function fails on swrast for me due to:

   pdraw = psc-driScreen-createDrawable(psc, drawable,
  glxdrawable, config);
   if (pdraw == NULL) {
  fprintf(stderr, failed to create drawable\n);
  return;
   }

   and finally due to condition inside driCreateDrawable() in
   drisw_glx.c:

   /* Old dri can't handle GLX 1.3+ drawable constructors. */
   if (xDrawable != drawable)
  return NULL;

3) I tried to comment out above condition, but then i get crash
   inside swrastGetImage() in drisw_glx.c.

Anybody can help?

/Sylwester

   

   

   



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


[Mesa-dev] [PATCH] meta: fix broken sRGB mipmap generation

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

If we're generating a mipmap for an sRGB texture we need to bypass
sRGB-linear conversion.  Otherwise the destination mipmap level
(drawn with a textured quad) will have the wrong colors.
If we can't turn of sRGB-linear conversion (GL_EXT_texture_sRGB_decode)
we need to use the software fallback for mipmap generation.

Note: This is a candidate for the 7.11 branch.
---
 src/mesa/drivers/common/meta.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 1b71aa1..82b072e 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2452,6 +2452,15 @@ _mesa_meta_check_generate_mipmap_fallback(struct 
gl_context *ctx, GLenum target,
   return GL_TRUE;
}
 
+   if (_mesa_get_format_color_encoding(baseImage-TexFormat) == GL_SRGB 
+   !ctx-Extensions.EXT_texture_sRGB_decode) {
+  /* The texture format is sRGB but we can't turn off sRGB-linear
+   * texture sample conversion.  So we won't be able to generate the
+   * right colors when rendering.  Need to use a fallback.
+   */
+  return GL_TRUE;
+   }
+
/*
 * Test that we can actually render in the texture's format.
 */
@@ -2669,6 +2678,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum 
target,
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;
GLenum faceTarget;
@@ -2731,6 +2742,15 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum 
target,
_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_Disable(GL_FRAMEBUFFER_SRGB_EXT);
+   }
+
_mesa_set_enable(ctx, target, GL_TRUE);
 
/* setup texcoords (XXX what about border?) */
@@ -2875,6 +2895,14 @@ _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_Enable(GL_FRAMEBUFFER_SRGB_EXT);
+   }
+
_mesa_lock_texture(ctx, texObj); /* relock */
 
_mesa_meta_end(ctx);
-- 
1.7.3.4

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


Re: [Mesa-dev] [PATCH] meta: fix broken sRGB mipmap generation

2011-09-17 Thread Henri Verbeet
On 17 September 2011 19:33, Brian Paul brian.e.p...@gmail.com wrote:
 From: Brian Paul bri...@vmware.com

 If we're generating a mipmap for an sRGB texture we need to bypass
 sRGB-linear conversion.  Otherwise the destination mipmap level
 (drawn with a textured quad) will have the wrong colors.
 If we can't turn of sRGB-linear conversion (GL_EXT_texture_sRGB_decode)
 we need to use the software fallback for mipmap generation.

Although not directly related to the issue this patch fixes, note that
issue 24 in EXT_texture_sRGB (and issue 10 in EXT_texture_sRGB_decode
is related to that) recommends to do filtering in linear space.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] meta: fix broken sRGB mipmap generation

2011-09-17 Thread Brian Paul

On 09/17/2011 11:52 AM, Henri Verbeet wrote:

On 17 September 2011 19:33, Brian Paulbrian.e.p...@gmail.com  wrote:

From: Brian Paulbri...@vmware.com

If we're generating a mipmap for an sRGB texture we need to bypass
sRGB-linear conversion.  Otherwise the destination mipmap level
(drawn with a textured quad) will have the wrong colors.
If we can't turn of sRGB-linear conversion (GL_EXT_texture_sRGB_decode)
we need to use the software fallback for mipmap generation.


Although not directly related to the issue this patch fixes, note that
issue 24 in EXT_texture_sRGB (and issue 10 in EXT_texture_sRGB_decode
is related to that) recommends to do filtering in linear space.


Right.  I wasn't concerned with that for now.  If 
GL_EXT_framebuffer_sRGB is supported, I believe we can do that with 
little effort, but I haven't tried it yet.


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


[Mesa-dev] [PATCH 1/2] gallium/util: observer sampler view's first_level in util_blit_pixels_tex()

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

This lets us blit from a non-zero source level.
---
 src/gallium/auxiliary/util/u_blit.c |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 421726b..87530e9 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -660,8 +660,8 @@ void util_blit_flush( struct blit_state *ctx )
 
 /**
  * Copy pixel block from src texture to dst surface.
- *
- * XXX Should support selection of level.
+ * The sampler view's first_level field indicates the source
+ * mipmap level to use.
  * XXX need some control over blitting Z and/or stencil.
  */
 void
@@ -694,10 +694,14 @@ util_blit_pixels_tex(struct blit_state *ctx,
 
if(normalized)
{
-  s0 /= (float)tex-width0;
-  s1 /= (float)tex-width0;
-  t0 /= (float)tex-height0;
-  t1 /= (float)tex-height0;
+  /* normalize according to the mipmap level's size */
+  int level = src_sampler_view-u.tex.first_level;
+  float w = (float) u_minify(tex-width0, level);
+  float h = (float) u_minify(tex-height0, level);
+  s0 /= w;
+  s1 /= w;
+  t0 /= h;
+  t1 /= h;
}
 
assert(ctx-pipe-screen-is_format_supported(ctx-pipe-screen, 
dst-format,
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 2/2] st/mesa: specify source mipmap level in decompress_with_blit()

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

This, along with the previous patch, fixes glGetTexImage() of compressed
textures for level  0.
---
 src/mesa/state_tracker/st_cb_texture.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index eab02fb..59a2e55 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -843,6 +843,9 @@ decompress_with_blit(struct gl_context * ctx, GLenum 
target, GLint level,
   pipe-render_condition(pipe, NULL, 0);
}
 
+   /* Choose the source mipmap level */
+   src_view-u.tex.first_level = src_view-u.tex.last_level = level;
+
/* blit/render/decompress */
util_blit_pixels_tex(st-blit,
 src_view,  /* pipe_resource (src) */
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 01/15] mesa: s/GLchan/GLubyte/ in mipmap generation code

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/mipmap.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index f170d23..5f18c71 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1986,7 +1986,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum 
target,
gl_format temp_format;
GLint components;
GLuint temp_src_stride, temp_dst_stride; /* in bytes */
-   GLchan *temp_src = NULL, *temp_dst = NULL;
+   GLubyte *temp_src = NULL, *temp_dst = NULL;
GLenum temp_datatype;
GLenum temp_base_format;
 
@@ -2101,7 +2101,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum 
target,
 
   /* swap src and dest pointers */
   {
-GLchan *temp = temp_src;
+GLubyte *temp = temp_src;
 temp_src = temp_dst;
 temp_dst = temp;
 
@@ -2109,7 +2109,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum 
target,
   }
} /* loop over mipmap levels */
 
-   free((void *) temp_src);
+   free(temp_src);
free(temp_dst);
 }
 
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 02/15] mesa: move _mesa_upscale_teximage2d() to texcompress_fxt1.c

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

Was used by no other code.
---
 src/mesa/main/mipmap.c   |   34 ---
 src/mesa/main/mipmap.h   |6 -
 src/mesa/main/texcompress_fxt1.c |   41 +++--
 3 files changed, 38 insertions(+), 43 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 5f18c71..1ead5ee 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -2218,37 +2218,3 @@ do { 
\
}
 }
 
-
-/**
- * Upscale an image by replication, not (typical) stretching.
- * We use this when the image width or height is less than a
- * certain size (4, 8) and we need to upscale an image.
- */
-void
-_mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight,
- GLsizei outWidth, GLsizei outHeight,
- GLint comps, const GLchan *src, GLint srcRowStride,
- GLchan *dest )
-{
-   GLint i, j, k;
-
-   ASSERT(outWidth = inWidth);
-   ASSERT(outHeight = inHeight);
-#if 0
-   ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2);
-   ASSERT((outWidth  3) == 0);
-   ASSERT((outHeight  3) == 0);
-#endif
-
-   for (i = 0; i  outHeight; i++) {
-  const GLint ii = i % inHeight;
-  for (j = 0; j  outWidth; j++) {
- const GLint jj = j % inWidth;
- for (k = 0; k  comps; k++) {
-dest[(i * outWidth + j) * comps + k]
-   = src[ii * srcRowStride + jj * comps + k];
- }
-  }
-   }
-}
-
diff --git a/src/mesa/main/mipmap.h b/src/mesa/main/mipmap.h
index 4c7ee63..4783950 100644
--- a/src/mesa/main/mipmap.h
+++ b/src/mesa/main/mipmap.h
@@ -54,11 +54,5 @@ _mesa_rescale_teximage2d(GLuint bytesPerPixel,
  GLint dstWidth, GLint dstHeight,
  const GLvoid *srcImage, GLvoid *dstImage);
 
-extern void
-_mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight,
- GLsizei outWidth, GLsizei outHeight,
- GLint comps, const GLchan *src, GLint srcRowStride,
- GLchan *dest);
-
 
 #endif /* MIPMAP_H */
diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c
index a75487c..1cbaba7 100644
--- a/src/mesa/main/texcompress_fxt1.c
+++ b/src/mesa/main/texcompress_fxt1.c
@@ -1289,6 +1289,41 @@ fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint 
comps)
 }
 
 
+
+/**
+ * Upscale an image by replication, not (typical) stretching.
+ * We use this when the image width or height is less than a
+ * certain size (4, 8) and we need to upscale an image.
+ */
+static void
+upscale_teximage2d(GLsizei inWidth, GLsizei inHeight,
+   GLsizei outWidth, GLsizei outHeight,
+   GLint comps, const GLchan *src, GLint srcRowStride,
+   GLchan *dest )
+{
+   GLint i, j, k;
+
+   ASSERT(outWidth = inWidth);
+   ASSERT(outHeight = inHeight);
+#if 0
+   ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2);
+   ASSERT((outWidth  3) == 0);
+   ASSERT((outHeight  3) == 0);
+#endif
+
+   for (i = 0; i  outHeight; i++) {
+  const GLint ii = i % inHeight;
+  for (j = 0; j  outWidth; j++) {
+ const GLint jj = j % inWidth;
+ for (k = 0; k  comps; k++) {
+dest[(i * outWidth + j) * comps + k]
+   = src[ii * srcRowStride + jj * comps + k];
+ }
+  }
+   }
+}
+
+
 static void
 fxt1_encode (GLuint width, GLuint height, GLint comps,
  const void *source, GLint srcRowStride,
@@ -1311,9 +1346,9 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
  _mesa_error(ctx, GL_OUT_OF_MEMORY, texture compression);
  goto cleanUp;
   }
-  _mesa_upscale_teximage2d(width, height, newWidth, newHeight,
-   comps, (const GLchan *) source,
-   srcRowStride, (GLchan *) newSource);
+  upscale_teximage2d(width, height, newWidth, newHeight,
+ comps, (const GLchan *) source,
+ srcRowStride, (GLchan *) newSource);
   source = newSource;
   width = newWidth;
   height = newHeight;
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 03/15] mesa: s/_mesa_make_temp_chan_image()/_mesa_make_temp_ubyte_image()

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

Another step toward eliminating the GLchan type.
---
 src/mesa/main/texcompress_fxt1.c |8 +-
 src/mesa/main/texcompress_rgtc.c |8 +-
 src/mesa/main/texcompress_s3tc.c |   16 ++--
 src/mesa/main/texstore.c |  210 +++---
 src/mesa/main/texstore.h |4 +-
 5 files changed, 123 insertions(+), 123 deletions(-)

diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c
index 1cbaba7..624c34b 100644
--- a/src/mesa/main/texcompress_fxt1.c
+++ b/src/mesa/main/texcompress_fxt1.c
@@ -65,7 +65,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
GLint srcRowStride;
GLubyte *dst;
const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
-   const GLchan *tempImage = NULL;
+   const GLubyte *tempImage = NULL;
 
ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1);
ASSERT(dstXoffset % 8 == 0);
@@ -79,7 +79,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
   /* convert image to RGB/GLchan */
-  tempImage = _mesa_make_temp_chan_image(ctx, dims,
+  tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
  srcWidth, srcHeight, srcDepth,
@@ -121,7 +121,7 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
GLint srcRowStride;
GLubyte *dst;
GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
-   const GLchan *tempImage = NULL;
+   const GLubyte *tempImage = NULL;
 
ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1);
ASSERT(dstXoffset % 8 == 0);
@@ -135,7 +135,7 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
   /* convert image to RGBA/GLchan */
-  tempImage = _mesa_make_temp_chan_image(ctx, dims,
+  tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
  srcWidth, srcHeight, srcDepth,
diff --git a/src/mesa/main/texcompress_rgtc.c b/src/mesa/main/texcompress_rgtc.c
index 7af3d67..f18a966 100644
--- a/src/mesa/main/texcompress_rgtc.c
+++ b/src/mesa/main/texcompress_rgtc.c
@@ -93,7 +93,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
 {
GLubyte *dst;
const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
-   const GLchan *tempImage = NULL;
+   const GLubyte *tempImage = NULL;
int i, j;
int numxpixels, numypixels;
const GLchan *srcaddr;
@@ -109,7 +109,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
(void) dstImageOffsets;
 
 
-   tempImage = _mesa_make_temp_chan_image(ctx, dims,
+   tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
  srcWidth, srcHeight, srcDepth,
@@ -204,7 +204,7 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
 {
GLubyte *dst;
const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
-   const GLchan *tempImage = NULL;
+   const GLubyte *tempImage = NULL;
int i, j;
int numxpixels, numypixels;
const GLchan *srcaddr;
@@ -220,7 +220,7 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
(void) dstZoffset;
(void) dstImageOffsets;
 
-   tempImage = _mesa_make_temp_chan_image(ctx, dims,
+   tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
  srcWidth, srcHeight, srcDepth,
diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
index 36a5644..161c453 100644
--- a/src/mesa/main/texcompress_s3tc.c
+++ b/src/mesa/main/texcompress_s3tc.c
@@ -166,7 +166,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
const GLchan *pixels;
GLubyte *dst;
const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
-   const GLchan *tempImage = NULL;
+   const GLubyte *tempImage = NULL;
 
ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 ||
   dstFormat == MESA_FORMAT_SRGB_DXT1);
@@ -181,7 +181,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
   /* convert image to RGB/GLchan */
-  tempImage = _mesa_make_temp_chan_image(ctx, dims,
+  tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
  srcWidth, srcHeight, srcDepth,
@@ -225,7 +225,7 @@ 

[Mesa-dev] [PATCH 04/15] mesa: remove GLchan in texcompress_fxt1.c

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/texcompress_fxt1.c |  127 --
 1 files changed, 53 insertions(+), 74 deletions(-)

diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c
index 624c34b..0437cfc 100644
--- a/src/mesa/main/texcompress_fxt1.c
+++ b/src/mesa/main/texcompress_fxt1.c
@@ -52,7 +52,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
 
 void
 fxt1_decode_1 (const void *texture, GLint stride,
-   GLint i, GLint j, GLchan *rgba);
+   GLint i, GLint j, GLubyte *rgba);
 
 
 /**
@@ -61,7 +61,7 @@ fxt1_decode_1 (const void *texture, GLint stride,
 GLboolean
 _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
 {
-   const GLchan *pixels;
+   const GLubyte *pixels;
GLint srcRowStride;
GLubyte *dst;
const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
@@ -75,10 +75,10 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
(void) dstImageOffsets;
 
if (srcFormat != GL_RGB ||
-   srcType != CHAN_TYPE ||
+   srcType != GL_UNSIGNED_BYTE ||
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
-  /* convert image to RGB/GLchan */
+  /* convert image to RGB/GLubyte */
   tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
@@ -92,9 +92,9 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
   srcFormat = GL_RGB;
}
else {
-  pixels = (const GLchan *) srcAddr;
+  pixels = (const GLubyte *) srcAddr;
   srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
-srcType) / sizeof(GLchan);
+srcType) / sizeof(GLubyte);
}
 
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
@@ -117,7 +117,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
 {
-   const GLchan *pixels;
+   const GLubyte *pixels;
GLint srcRowStride;
GLubyte *dst;
GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
@@ -131,10 +131,10 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
(void) dstImageOffsets;
 
if (srcFormat != GL_RGBA ||
-   srcType != CHAN_TYPE ||
+   srcType != GL_UNSIGNED_BYTE ||
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
-  /* convert image to RGBA/GLchan */
+  /* convert image to RGBA/GLubyte */
   tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
@@ -148,9 +148,9 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
   srcFormat = GL_RGBA;
}
else {
-  pixels = (const GLchan *) srcAddr;
+  pixels = (const GLubyte *) srcAddr;
   srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
-srcType) / sizeof(GLchan);
+srcType) / sizeof(GLubyte);
}
 
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
@@ -171,14 +171,14 @@ void
 _mesa_fetch_texel_2d_f_rgba_fxt1( const struct swrast_texture_image *texImage,
   GLint i, GLint j, GLint k, GLfloat *texel )
 {
-   /* just sample as GLchan and convert to float here */
-   GLchan rgba[4];
+   /* just sample as GLubyte and convert to float here */
+   GLubyte rgba[4];
(void) k;
fxt1_decode_1(texImage-Base.Data, texImage-Base.RowStride, i, j, rgba);
-   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
-   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
-   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
-   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
+   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
+   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
+   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
+   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
 }
 
 
@@ -186,13 +186,13 @@ void
 _mesa_fetch_texel_2d_f_rgb_fxt1( const struct swrast_texture_image *texImage,
  GLint i, GLint j, GLint k, GLfloat *texel )
 {
-   /* just sample as GLchan and convert to float here */
-   GLchan rgba[4];
+   /* just sample as GLubyte and convert to float here */
+   GLubyte rgba[4];
(void) k;
fxt1_decode_1(texImage-Base.Data, texImage-Base.RowStride, i, j, rgba);
-   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
-   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
-   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
+   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
+   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
texel[ACOMP] = 1.0F;
 }
 
@@ -1298,8 +1298,8 @@ fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint 
comps)
 static void
 upscale_teximage2d(GLsizei inWidth, GLsizei inHeight,

[Mesa-dev] [PATCH 05/15] mesa/gallium: remove GLchan from latc, rgtc code

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/gallium/auxiliary/util/u_format_latc.c |8 
 src/gallium/auxiliary/util/u_format_rgtc.c |   22 +++---
 src/mesa/main/texcompress_rgtc.c   |   28 ++--
 src/mesa/main/texcompress_rgtc_tmp.h   |2 +-
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format_latc.c 
b/src/gallium/auxiliary/util/u_format_latc.c
index e84c493..2b34c71 100644
--- a/src/gallium/auxiliary/util/u_format_latc.c
+++ b/src/gallium/auxiliary/util/u_format_latc.c
@@ -27,13 +27,13 @@
 #include u_format_rgtc.h
 #include u_format_latc.h
 
-static void u_format_unsigned_encode_rgtc_chan(uint8_t *blkaddr, uint8_t 
srccolors[4][4],
+static void u_format_unsigned_encode_rgtc_ubyte(uint8_t *blkaddr, uint8_t 
srccolors[4][4],
   int numxpixels, int numypixels);
 
 static void u_format_unsigned_fetch_texel_rgtc(unsigned srcRowStride, const 
uint8_t *pixdata,
   unsigned i, unsigned j, uint8_t 
*value, unsigned comps);
 
-static void u_format_signed_encode_rgtc_chan(int8_t *blkaddr, int8_t 
srccolors[4][4],
+static void u_format_signed_encode_rgtc_ubyte(int8_t *blkaddr, int8_t 
srccolors[4][4],
 int numxpixels, int numypixels);
 
 static void u_format_signed_fetch_texel_rgtc(unsigned srcRowStride, const 
int8_t *pixdata,
@@ -43,8 +43,8 @@ void
 util_format_latc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, 
unsigned i, unsigned j)
 {
/* Fix warnings here: */
-   (void) u_format_unsigned_encode_rgtc_chan;
-   (void) u_format_signed_encode_rgtc_chan;
+   (void) u_format_unsigned_encode_rgtc_ubyte;
+   (void) u_format_signed_encode_rgtc_ubyte;
 
u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
 }
diff --git a/src/gallium/auxiliary/util/u_format_rgtc.c 
b/src/gallium/auxiliary/util/u_format_rgtc.c
index c929fd4..2371bab 100644
--- a/src/gallium/auxiliary/util/u_format_rgtc.c
+++ b/src/gallium/auxiliary/util/u_format_rgtc.c
@@ -26,13 +26,13 @@
 #include u_format.h
 #include u_format_rgtc.h
 
-static void u_format_unsigned_encode_rgtc_chan(uint8_t *blkaddr, uint8_t 
srccolors[4][4],
+static void u_format_unsigned_encode_rgtc_ubyte(uint8_t *blkaddr, uint8_t 
srccolors[4][4],
   int numxpixels, int numypixels);
 
 static void u_format_unsigned_fetch_texel_rgtc(unsigned srcRowStride, const 
uint8_t *pixdata,
   unsigned i, unsigned j, uint8_t 
*value, unsigned comps);
 
-static void u_format_signed_encode_rgtc_chan(int8_t *blkaddr, int8_t 
srccolors[4][4],
+static void u_format_signed_encode_rgtc_ubyte(int8_t *blkaddr, int8_t 
srccolors[4][4],
 int numxpixels, int numypixels);
 
 static void u_format_signed_fetch_texel_rgtc(unsigned srcRowStride, const 
int8_t *pixdata,
@@ -82,7 +82,7 @@ util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, 
unsigned dst_stride,
   tmp[j][i] = src_row[(y + j)*src_stride/sizeof(*src_row) + (x + 
i)*4];
 }
  }
- u_format_unsigned_encode_rgtc_chan(dst, tmp, 4, 4);
+ u_format_unsigned_encode_rgtc_ubyte(dst, tmp, 4, 4);
  dst += bytes_per_block;
   }
   dst_row += dst_stride / sizeof(*dst_row);
@@ -129,7 +129,7 @@ util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, 
unsigned dst_stride, c
   tmp[j][i] = float_to_ubyte(src_row[(y + 
j)*src_stride/sizeof(*src_row) + (x + i)*4]);
 }
  }
- u_format_unsigned_encode_rgtc_chan(dst, tmp, 4, 4);
+ u_format_unsigned_encode_rgtc_ubyte(dst, tmp, 4, 4);
  dst += bytes_per_block;
   }
   dst_row += dst_stride / sizeof(*dst_row);
@@ -180,7 +180,7 @@ util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, 
unsigned dst_stride, c
   tmp[j][i] = float_to_byte_tex(src_row[(y + 
j)*src_stride/sizeof(*src_row) + (x + i)*4]);
 }
  }
- u_format_signed_encode_rgtc_chan(dst, tmp, 4, 4);
+ u_format_signed_encode_rgtc_ubyte(dst, tmp, 4, 4);
  dst += bytes_per_block;
   }
   dst_row += dst_stride / sizeof(*dst_row);
@@ -272,8 +272,8 @@ util_format_rgtc2_unorm_pack_rgba_8unorm(uint8_t *dst_row, 
unsigned dst_stride,
   tmp_g[j][i] = src_row[((y + j)*src_stride/sizeof(*src_row) + (x 
+ i)*4) + 1];
 }
  }
- u_format_unsigned_encode_rgtc_chan(dst, tmp_r, 4, 4);
- u_format_unsigned_encode_rgtc_chan(dst + 8, tmp_g, 4, 4);
+ u_format_unsigned_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
+ u_format_unsigned_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
  dst += bytes_per_block;
   }
   dst_row += dst_stride / sizeof(*dst_row);
@@ -297,8 +297,8 @@ util_format_rxtc2_unorm_pack_rgba_float(uint8_t *dst_row, 

[Mesa-dev] [PATCH 06/15] mesa: replace GLchan with GLubyte in texcompress_s3tc.c

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/texcompress_s3tc.c |  116 +++---
 1 files changed, 57 insertions(+), 59 deletions(-)

diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
index 161c453..04c5b44 100644
--- a/src/mesa/main/texcompress_s3tc.c
+++ b/src/mesa/main/texcompress_s3tc.c
@@ -97,7 +97,7 @@ dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL;
 dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL;
 
 typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width,
-  GLint height, const GLchan *srcPixData,
+  GLint height, const GLubyte *srcPixData,
   GLenum destformat, GLubyte *dest,
   GLint dstRowStride);
 
@@ -163,7 +163,7 @@ _mesa_init_texture_s3tc( struct gl_context *ctx )
 GLboolean
 _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
 {
-   const GLchan *pixels;
+   const GLubyte *pixels;
GLubyte *dst;
const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
const GLubyte *tempImage = NULL;
@@ -177,10 +177,10 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
(void) dstImageOffsets;
 
if (srcFormat != GL_RGB ||
-   srcType != CHAN_TYPE ||
+   srcType != GL_UNSIGNED_BYTE ||
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
-  /* convert image to RGB/GLchan */
+  /* convert image to RGB/GLubyte */
   tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
@@ -193,7 +193,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
   srcFormat = GL_RGB;
}
else {
-  pixels = (const GLchan *) srcAddr;
+  pixels = (const GLubyte *) srcAddr;
}
 
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
@@ -222,7 +222,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
 {
-   const GLchan *pixels;
+   const GLubyte *pixels;
GLubyte *dst;
const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
const GLubyte *tempImage = NULL;
@@ -236,10 +236,10 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
(void) dstImageOffsets;
 
if (srcFormat != GL_RGBA ||
-   srcType != CHAN_TYPE ||
+   srcType != GL_UNSIGNED_BYTE ||
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
-  /* convert image to RGBA/GLchan */
+  /* convert image to RGBA/GLubyte */
   tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
@@ -252,7 +252,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
   srcFormat = GL_RGBA;
}
else {
-  pixels = (const GLchan *) srcAddr;
+  pixels = (const GLubyte *) srcAddr;
}
 
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
@@ -280,7 +280,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
 {
-   const GLchan *pixels;
+   const GLubyte *pixels;
GLubyte *dst;
const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
const GLubyte *tempImage = NULL;
@@ -294,10 +294,10 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
(void) dstImageOffsets;
 
if (srcFormat != GL_RGBA ||
-   srcType != CHAN_TYPE ||
+   srcType != GL_UNSIGNED_BYTE ||
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
-  /* convert image to RGBA/GLchan */
+  /* convert image to RGBA/GLubyte */
   tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
  
_mesa_get_format_base_format(dstFormat),
@@ -309,7 +309,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
   pixels = tempImage;
}
else {
-  pixels = (const GLchan *) srcAddr;
+  pixels = (const GLubyte *) srcAddr;
}
 
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
@@ -337,7 +337,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
 {
-   const GLchan *pixels;
+   const GLubyte *pixels;
GLubyte *dst;
const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
const GLubyte *tempImage = NULL;
@@ -351,10 +351,10 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
(void) dstImageOffsets;
 
if (srcFormat != GL_RGBA ||
-   srcType != CHAN_TYPE ||
+   srcType != GL_UNSIGNED_BYTE ||
ctx-_ImageTransferState ||
srcPacking-SwapBytes) {
-  /* convert image to RGBA/GLchan */
+  /* convert image to RGBA/GLubyte */
   tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
  baseInternalFormat,
   

[Mesa-dev] [PATCH 07/15] mesa: convert _mesa_unpack_color_span_chan() to ubyte

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/pack.c |   98 ++---
 src/mesa/main/pack.h |4 +-
 src/mesa/main/texstore.c |6 +-
 3 files changed, 53 insertions(+), 55 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 8388708..6d6ae59 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -3437,7 +3437,7 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
 /*
  * Unpack a row of color image data from a client buffer according to
  * the pixel unpacking parameters.
- * Return GLchan values in the specified dest image format.
+ * Return GLubyte values in the specified dest image format.
  * This is used by glDrawPixels and glTexImage?D().
  * \param ctx - the context
  * n - number of pixels in the span
@@ -3452,8 +3452,8 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
  * XXX perhaps expand this to process whole images someday.
  */
 void
-_mesa_unpack_color_span_chan( struct gl_context *ctx,
-  GLuint n, GLenum dstFormat, GLchan dest[],
+_mesa_unpack_color_span_ubyte(struct gl_context *ctx,
+  GLuint n, GLenum dstFormat, GLubyte dest[],
   GLenum srcFormat, GLenum srcType,
   const GLvoid *source,
   const struct gl_pixelstore_attrib *srcPacking,
@@ -3517,21 +3517,21 @@ _mesa_unpack_color_span_chan( struct gl_context *ctx,
 
/* Try simple cases first */
if (transferOps == 0) {
-  if (srcType == CHAN_TYPE) {
+  if (srcType == GL_UNSIGNED_BYTE) {
  if (dstFormat == GL_RGBA) {
 if (srcFormat == GL_RGBA) {
-   memcpy( dest, source, n * 4 * sizeof(GLchan) );
+   memcpy( dest, source, n * 4 * sizeof(GLubyte) );
return;
 }
 else if (srcFormat == GL_RGB) {
GLuint i;
-   const GLchan *src = (const GLchan *) source;
-   GLchan *dst = dest;
+   const GLubyte *src = (const GLubyte *) source;
+   GLubyte *dst = dest;
for (i = 0; i  n; i++) {
   dst[0] = src[0];
   dst[1] = src[1];
   dst[2] = src[2];
-  dst[3] = CHAN_MAX;
+  dst[3] = 255;
   src += 3;
   dst += 4;
}
@@ -3540,13 +3540,13 @@ _mesa_unpack_color_span_chan( struct gl_context *ctx,
  }
  else if (dstFormat == GL_RGB) {
 if (srcFormat == GL_RGB) {
-   memcpy( dest, source, n * 3 * sizeof(GLchan) );
+   memcpy( dest, source, n * 3 * sizeof(GLubyte) );
return;
 }
 else if (srcFormat == GL_RGBA) {
GLuint i;
-   const GLchan *src = (const GLchan *) source;
-   GLchan *dst = dest;
+   const GLubyte *src = (const GLubyte *) source;
+   GLubyte *dst = dest;
for (i = 0; i  n; i++) {
   dst[0] = src[0];
   dst[1] = src[1];
@@ -3560,7 +3560,7 @@ _mesa_unpack_color_span_chan( struct gl_context *ctx,
  else if (dstFormat == srcFormat) {
 GLint comps = _mesa_components_in_format(srcFormat);
 assert(comps  0);
-memcpy( dest, source, n * comps * sizeof(GLchan) );
+memcpy( dest, source, n * comps * sizeof(GLubyte) );
 return;
  }
   }
@@ -3573,12 +3573,12 @@ _mesa_unpack_color_span_chan( struct gl_context *ctx,
 if (srcFormat == GL_RGB) {
GLuint i;
const GLubyte *src = (const GLubyte *) source;
-   GLchan *dst = dest;
+   GLubyte *dst = dest;
for (i = 0; i  n; i++) {
-  dst[0] = UBYTE_TO_CHAN(src[0]);
-  dst[1] = UBYTE_TO_CHAN(src[1]);
-  dst[2] = UBYTE_TO_CHAN(src[2]);
-  dst[3] = CHAN_MAX;
+  dst[0] = src[0];
+  dst[1] = src[1];
+  dst[2] = src[2];
+  dst[3] = 255;
   src += 3;
   dst += 4;
}
@@ -3587,12 +3587,12 @@ _mesa_unpack_color_span_chan( struct gl_context *ctx,
 else if (srcFormat == GL_RGBA) {
GLuint i;
const GLubyte *src = (const GLubyte *) source;
-   GLchan *dst = dest;
+   GLubyte *dst = dest;
for (i = 0; i  n; i++) {
-  dst[0] = UBYTE_TO_CHAN(src[0]);
-  dst[1] = UBYTE_TO_CHAN(src[1]);
-  dst[2] = UBYTE_TO_CHAN(src[2]);
-  dst[3] = UBYTE_TO_CHAN(src[3]);
+  dst[0] = src[0];
+  dst[1] = src[1];
+  dst[2] = src[2];
+  dst[3] = src[3];
   src += 4;
   

[Mesa-dev] [PATCH 08/15] mesa: remove unused type_TO_CHAN() macros

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/colormac.h |   40 
 1 files changed, 0 insertions(+), 40 deletions(-)

diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index 4b7c3b4..d64cc8d 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -38,24 +38,6 @@
 #include mtypes.h
 
 
-/** \def BYTE_TO_CHAN
- * Convert from GLbyte to GLchan */
-
-/** \def UBYTE_TO_CHAN
- * Convert from GLubyte to GLchan */
-
-/** \def SHORT_TO_CHAN
- * Convert from GLshort to GLchan */
-
-/** \def USHORT_TO_CHAN
- * Convert from GLushort to GLchan */
-
-/** \def INT_TO_CHAN
- * Convert from GLint to GLchan */
-
-/** \def UINT_TO_CHAN
- * Convert from GLuint to GLchan */
-
 /** \def CHAN_TO_UBYTE
  * Convert from GLchan to GLubyte */
 
@@ -73,13 +55,6 @@
 
 #if CHAN_BITS == 8
 
-#define BYTE_TO_CHAN(b)   ((b)  0 ? 0 : (GLchan) (b))
-#define UBYTE_TO_CHAN(b)  (b)
-#define SHORT_TO_CHAN(s)  ((s)  0 ? 0 : (GLchan) ((s)  7))
-#define USHORT_TO_CHAN(s) ((GLchan) ((s)  8))
-#define INT_TO_CHAN(i)((i)  0 ? 0 : (GLchan) ((i)  23))
-#define UINT_TO_CHAN(i)   ((GLchan) ((i)  24))
-
 #define CHAN_TO_UBYTE(c)  (c)
 #define CHAN_TO_USHORT(c) (((c)  8) | (c))
 #define CHAN_TO_SHORT(c)  (((c)  7) | ((c)  1))
@@ -92,13 +67,6 @@
 
 #elif CHAN_BITS == 16
 
-#define BYTE_TO_CHAN(b)   ((b)  0 ? 0 : (((GLchan) (b)) * 516))
-#define UBYTE_TO_CHAN(b)  GLchan) (b))  8) | ((GLchan) (b)))
-#define SHORT_TO_CHAN(s)  ((s)  0 ? 0 : (GLchan) (s))
-#define USHORT_TO_CHAN(s) (s)
-#define INT_TO_CHAN(i)((i)  0 ? 0 : (GLchan) ((i)  15))
-#define UINT_TO_CHAN(i)   ((GLchan) ((i)  16))
-
 #define CHAN_TO_UBYTE(c)  ((c)  8)
 #define CHAN_TO_USHORT(c) (c)
 #define CHAN_TO_SHORT(c)  ((c)  1)
@@ -111,14 +79,6 @@
 
 #elif CHAN_BITS == 32
 
-/* XXX floating-point color channels not fully thought-out */
-#define BYTE_TO_CHAN(b)   ((GLfloat) ((b) * (1.0F / 127.0F)))
-#define UBYTE_TO_CHAN(b)  ((GLfloat) ((b) * (1.0F / 255.0F)))
-#define SHORT_TO_CHAN(s)  ((GLfloat) ((s) * (1.0F / 32767.0F)))
-#define USHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 65535.0F)))
-#define INT_TO_CHAN(i)((GLfloat) ((i) * (1.0F / 2147483647.0F)))
-#define UINT_TO_CHAN(i)   ((GLfloat) ((i) * (1.0F / 4294967295.0F)))
-
 #define CHAN_TO_UBYTE(c)  FLOAT_TO_UBYTE(c)
 #define CHAN_TO_USHORT(c) ((GLushort) (CLAMP((c), 0.0f, 1.0f) * 65535.0))
 #define CHAN_TO_SHORT(c)  ((GLshort) (CLAMP((c), 0.0f, 1.0f) * 32767.0))
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 09/15] r200: use _mesa_unclamped_float_rgba_to_ubyte()

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/drivers/dri/r200/r200_state.c |4 ++--
 src/mesa/drivers/dri/r200/r200_tex.c   |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_state.c 
b/src/mesa/drivers/dri/r200/r200_state.c
index b3755d8..03b4cc1 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -414,7 +414,7 @@ static void r200Fogfv( struct gl_context *ctx, GLenum 
pname, const GLfloat *para
 {
r200ContextPtr rmesa = R200_CONTEXT(ctx);
union { int i; float f; } c, d;
-   GLchan col[4];
+   GLubyte col[4];
GLuint i;
 
c.i = rmesa-hw.fog.cmd[FOG_C];
@@ -480,7 +480,7 @@ static void r200Fogfv( struct gl_context *ctx, GLenum 
pname, const GLfloat *para
   break;
case GL_FOG_COLOR:
   R200_STATECHANGE( rmesa, ctx );
-  UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx-Fog.Color );
+  _mesa_unclamped_float_rgba_to_ubyte(col, ctx-Fog.Color );
   i = radeonPackColor( 4, col[0], col[1], col[2], 0 );
   rmesa-hw.ctx.cmd[CTX_PP_FOG_COLOR] = ~R200_FOG_COLOR_MASK;
   rmesa-hw.ctx.cmd[CTX_PP_FOG_COLOR] |= i;
diff --git a/src/mesa/drivers/dri/r200/r200_tex.c 
b/src/mesa/drivers/dri/r200/r200_tex.c
index 7f26bfa..27a7618 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -313,7 +313,7 @@ static void r200TexEnv( struct gl_context *ctx, GLenum 
target,
case GL_TEXTURE_ENV_COLOR: {
   GLubyte c[4];
   GLuint envColor;
-  UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit-EnvColor );
+  _mesa_unclamped_float_rgba_to_ubyte(c, texUnit-EnvColor);
   envColor = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
   if ( rmesa-hw.tf.cmd[TF_TFACTOR_0 + unit] != envColor ) {
 R200_STATECHANGE( rmesa, tf );
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 10/15] radeon: use _mesa_unclamped_float_rgba_to_ubyte()

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/drivers/dri/radeon/radeon_state.c |4 ++--
 src/mesa/drivers/dri/radeon/radeon_tex.c   |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c 
b/src/mesa/drivers/dri/radeon/radeon_state.c
index 979bb65..77a06df 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -331,7 +331,7 @@ static void radeonFogfv( struct gl_context *ctx, GLenum 
pname, const GLfloat *pa
 {
r100ContextPtr rmesa = R100_CONTEXT(ctx);
union { int i; float f; } c, d;
-   GLchan col[4];
+   GLubyte col[4];
 
switch (pname) {
case GL_FOG_MODE:
@@ -395,7 +395,7 @@ static void radeonFogfv( struct gl_context *ctx, GLenum 
pname, const GLfloat *pa
   break;
case GL_FOG_COLOR:
   RADEON_STATECHANGE( rmesa, ctx );
-  UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx-Fog.Color );
+  _mesa_unclamped_float_rgba_to_ubyte(col, ctx-Fog.Color );
   rmesa-hw.ctx.cmd[CTX_PP_FOG_COLOR] = ~RADEON_FOG_COLOR_MASK;
   rmesa-hw.ctx.cmd[CTX_PP_FOG_COLOR] |=
 radeonPackColor( 4, col[0], col[1], col[2], 0 );
diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.c 
b/src/mesa/drivers/dri/radeon/radeon_tex.c
index c5282ae..611c717 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tex.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tex.c
@@ -270,7 +270,7 @@ static void radeonTexEnv( struct gl_context *ctx, GLenum 
target,
case GL_TEXTURE_ENV_COLOR: {
   GLubyte c[4];
   GLuint envColor;
-  UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit-EnvColor );
+  _mesa_unclamped_float_rgba_to_ubyte(c, texUnit-EnvColor);
   envColor = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
   if ( rmesa-hw.tex[unit].cmd[TEX_PP_TFACTOR] != envColor ) {
 RADEON_STATECHANGE( rmesa, tex[unit] );
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 11/15] mesa: remove unused UNCLAMPED_FLOAT_TO_RGB_CHAN() macro

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/colormac.h |   16 
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index d64cc8d..46377ac 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -97,22 +97,6 @@
 
 
 /**
- * Convert 3 channels at once.
- *
- * \param dst pointer to destination GLchan[3] array.
- * \param f pointer to source GLfloat[3] array.
- *
- * \sa #UNCLAMPED_FLOAT_TO_CHAN.
- */
-#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f)\
-do {   \
-   UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]);  \
-   UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]);  \
-   UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]);  \
-} while (0)
-
-
-/**
  * Convert 4 channels at once.
  *
  * \param dst pointer to destination GLchan[4] array.
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 12/15] mesa: remove unused interp/stride chan macros

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/macros.h |   27 ---
 1 files changed, 0 insertions(+), 27 deletions(-)

diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 01e4d20..2a849e3 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -175,10 +175,6 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
 #define STRIDE_4UB(p, i)  (p = (GLubyte (*)[4])((GLubyte *)p + i))
 /** Stepping a GLfloat[4] pointer by a byte stride */
 #define STRIDE_4F(p, i)  (p = (GLfloat (*)[4])((GLubyte *)p + i))
-/** Stepping a GLchan[4] pointer by a byte stride */
-#define STRIDE_4CHAN(p, i)  (p = (GLchan (*)[4])((GLubyte *)p + i))
-/** Stepping a GLchan pointer by a byte stride */
-#define STRIDE_CHAN(p, i)  (p = (GLchan *)((GLubyte *)p + i))
 /** Stepping a \p t pointer by a byte stride */
 #define STRIDE_T(p, t, i)  (p = (t)((GLubyte *)p + i))
 
@@ -602,14 +598,6 @@ do {\
UNCLAMPED_FLOAT_TO_UBYTE( dstub, dstf ); \
 } while (0)
 
-#define INTERP_CHAN( t, dstc, outc, inc )   \
-do {\
-   GLfloat inf = CHAN_TO_FLOAT( inc );  \
-   GLfloat outf = CHAN_TO_FLOAT( outc );\
-   GLfloat dstf = LINTERP( t, outf, inf );  \
-   UNCLAMPED_FLOAT_TO_CHAN( dstc, dstf );   \
-} while (0)
-
 #define INTERP_UI( t, dstui, outui, inui )  \
dstui = (GLuint) (GLint) LINTERP( (t), (GLfloat) (outui), (GLfloat) (inui) )
 
@@ -631,21 +619,6 @@ do {\
dst[2] = LINTERP( (t), (out)[2], (in)[2] );  \
 } while (0)
 
-#define INTERP_4CHAN( t, dst, out, in ) \
-do {\
-   INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \
-   INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \
-   INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \
-   INTERP_CHAN( (t), (dst)[3], (out)[3], (in)[3] ); \
-} while (0)
-
-#define INTERP_3CHAN( t, dst, out, in ) \
-do {\
-   INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \
-   INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \
-   INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \
-} while (0)
-
 #define INTERP_SZ( t, vec, to, out, in, sz )\
 do {\
switch (sz) {\
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 13/15] mesa: remove CHAN_TYPE cruft from debug.c

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/debug.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 2bb3745..c296438 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -567,9 +567,6 @@ _mesa_dump_image(const char *filename, const void *image, 
GLuint w, GLuint h,
 void
 _mesa_print_texture(struct gl_context *ctx, struct gl_texture_image *img)
 {
-#if CHAN_TYPE != GL_UNSIGNED_BYTE
-   _mesa_problem(NULL, PrintTexture not supported);
-#else
const GLint slice = 0;
GLint srcRowStride;
GLuint i, j, c;
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 14/15] more debug fixing

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/debug.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index c296438..0a393e5 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -623,5 +623,4 @@ _mesa_print_texture(struct gl_context *ctx, struct 
gl_texture_image *img)
}
 
ctx-Driver.UnmapTextureImage(ctx, img, slice);
-#endif
 }
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 15/15] mesa: move last bits of GLchan stuff into swrast

2011-09-17 Thread Brian Paul
From: Brian Paul bri...@vmware.com

This removes the last remnants of the GLchan datatype and associated
macros out of core Mesa and into swrast.
---
 src/mesa/drivers/dri/swrast/swrast_span.c |2 +-
 src/mesa/main/colormac.h  |   75 --
 src/mesa/main/config.h|2 +-
 src/mesa/main/mtypes.h|   23 --
 src/mesa/math/m_translate.h   |2 +-
 src/mesa/swrast/s_chan.h  |  119 +
 src/mesa/swrast/s_span.h  |2 +
 src/mesa/swrast/swrast.h  |1 +
 src/mesa/tnl/t_vertex.c   |2 +-
 src/mesa/tnl/t_vertex_generic.c   |1 +
 10 files changed, 127 insertions(+), 102 deletions(-)
 create mode 100644 src/mesa/swrast/s_chan.h

diff --git a/src/mesa/drivers/dri/swrast/swrast_span.c 
b/src/mesa/drivers/dri/swrast/swrast_span.c
index c7d0bfd..772d09f 100644
--- a/src/mesa/drivers/dri/swrast/swrast_span.c
+++ b/src/mesa/drivers/dri/swrast/swrast_span.c
@@ -45,7 +45,7 @@ static const GLubyte kernel[16] = {
 #if DITHER
 #define DITHER_COMP(X, Y) kernel[((X)  0x3) | (((Y)  0x3)  2)]
 
-#define DITHER_CLAMP(X) (((X)  CHAN_MAX) ? (X) : CHAN_MAX)
+#define DITHER_CLAMP(X) (((X)  255) ? (X) : 255)
 #else
 #define DITHER_COMP(X, Y) 0
 
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index 46377ac..0b8864a 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -38,81 +38,6 @@
 #include mtypes.h
 
 
-/** \def CHAN_TO_UBYTE
- * Convert from GLchan to GLubyte */
-
-/** \def CHAN_TO_FLOAT
- * Convert from GLchan to GLfloat */
-
-/** \def CLAMPED_FLOAT_TO_CHAN
- * Convert from GLclampf to GLchan */
-
-/** \def UNCLAMPED_FLOAT_TO_CHAN
- * Convert from GLfloat to GLchan */
-
-/** \def COPY_CHAN4
- * Copy a GLchan[4] array */
-
-#if CHAN_BITS == 8
-
-#define CHAN_TO_UBYTE(c)  (c)
-#define CHAN_TO_USHORT(c) (((c)  8) | (c))
-#define CHAN_TO_SHORT(c)  (((c)  7) | ((c)  1))
-#define CHAN_TO_FLOAT(c)  UBYTE_TO_FLOAT(c)
-
-#define CLAMPED_FLOAT_TO_CHAN(c, f)CLAMPED_FLOAT_TO_UBYTE(c, f)
-#define UNCLAMPED_FLOAT_TO_CHAN(c, f)  UNCLAMPED_FLOAT_TO_UBYTE(c, f)
-
-#define COPY_CHAN4(DST, SRC)  COPY_4UBV(DST, SRC)
-
-#elif CHAN_BITS == 16
-
-#define CHAN_TO_UBYTE(c)  ((c)  8)
-#define CHAN_TO_USHORT(c) (c)
-#define CHAN_TO_SHORT(c)  ((c)  1)
-#define CHAN_TO_FLOAT(c)  ((GLfloat) ((c) * (1.0 / CHAN_MAXF)))
-
-#define CLAMPED_FLOAT_TO_CHAN(c, f)CLAMPED_FLOAT_TO_USHORT(c, f)
-#define UNCLAMPED_FLOAT_TO_CHAN(c, f)  UNCLAMPED_FLOAT_TO_USHORT(c, f)
-
-#define COPY_CHAN4(DST, SRC)  COPY_4V(DST, SRC)
-
-#elif CHAN_BITS == 32
-
-#define CHAN_TO_UBYTE(c)  FLOAT_TO_UBYTE(c)
-#define CHAN_TO_USHORT(c) ((GLushort) (CLAMP((c), 0.0f, 1.0f) * 65535.0))
-#define CHAN_TO_SHORT(c)  ((GLshort) (CLAMP((c), 0.0f, 1.0f) * 32767.0))
-#define CHAN_TO_FLOAT(c)  (c)
-
-#define CLAMPED_FLOAT_TO_CHAN(c, f)  c = (f)
-#define UNCLAMPED_FLOAT_TO_CHAN(c, f)  c = (f)
-
-#define COPY_CHAN4(DST, SRC)  COPY_4V(DST, SRC)
-
-#else
-
-#error unexpected CHAN_BITS size
-
-#endif
-
-
-/**
- * Convert 4 channels at once.
- *
- * \param dst pointer to destination GLchan[4] array.
- * \param f pointer to source GLfloat[4] array.
- *
- * \sa #UNCLAMPED_FLOAT_TO_CHAN.
- */
-#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f)   \
-do {   \
-   UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]);  \
-   UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]);  \
-   UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]);  \
-   UNCLAMPED_FLOAT_TO_CHAN((dst)[3], (f)[3]);  \
-} while (0)
-
-
 /**
  * Convert four float values in [0,1] to ubytes in [0,255] with clamping.
  */
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 91aef90..1ac3c12 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -329,7 +329,7 @@
 
 
 /**
- * Bits per color channel:  8, 16 or 32
+ * For swrast, bits per color channel:  8, 16 or 32
  */
 #ifndef CHAN_BITS
 #define CHAN_BITS 8
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 429c8b4..1e82020 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -44,29 +44,6 @@
 
 
 /**
- * Color channel data type.
- */
-#if CHAN_BITS == 8
-   typedef GLubyte GLchan;
-#define CHAN_MAX 255
-#define CHAN_MAXF 255.0F
-#define CHAN_TYPE GL_UNSIGNED_BYTE
-#elif CHAN_BITS == 16
-   typedef GLushort GLchan;
-#define CHAN_MAX 65535
-#define CHAN_MAXF 65535.0F
-#define CHAN_TYPE GL_UNSIGNED_SHORT
-#elif CHAN_BITS == 32
-   typedef GLfloat GLchan;
-#define CHAN_MAX 1.0
-#define CHAN_MAXF 1.0F
-#define CHAN_TYPE GL_FLOAT
-#else
-#error illegal number of color channel bits
-#endif
-
-
-/**
  * Stencil buffer data type.
  */
 #if STENCIL_BITS==8
diff --git a/src/mesa/math/m_translate.h b/src/mesa/math/m_translate.h
index 5804103..bf7485c 100644
--- a/src/mesa/math/m_translate.h
+++ b/src/mesa/math/m_translate.h
@@ -29,7 +29,7 @@
 #include main/compiler.h
 #include main/glheader.h
 #include 

[Mesa-dev] [PATCH demos] Allow disabling of egl, gles1, gles2, vg, osmesa, drm, x11, freetype2

2011-09-17 Thread Matt Turner
Signed-off-by: Matt Turner matts...@gmail.com
---
 configure.ac |   50 +-
 1 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index b5b2fcf..c82d7cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,12 +112,36 @@ PKG_CHECK_MODULES(GLU, [glu], [],
 DEMO_CFLAGS=$DEMO_CFLAGS $GLU_CFLAGS
 DEMO_LIBS=$DEMO_LIBS $GLU_LIBS
 
-PKG_CHECK_MODULES(EGL, [egl], [egl_enabled=yes], [egl_enabled=no])
-PKG_CHECK_MODULES(GLESV1, [glesv1_cm], [glesv1_enabled=yes], 
[glesv1_enabled=no])
-PKG_CHECK_MODULES(GLESV2, [glesv2], [glesv2_enabled=yes], [glesv2_enabled=no])
-PKG_CHECK_MODULES(VG, [vg], [vg_enabled=yes], [vg_enabled=no])
-PKG_CHECK_MODULES(OSMESA, [osmesa], [osmesa_enabled=yes], [osmesa_enabled=no])
-PKG_CHECK_MODULES(DRM, [libdrm], [drm_enabled=yes], [drm_enabled=no])
+AC_ARG_ENABLE([egl],
+[AS_HELP_STRING([--disable-egl],
+[disable EGL library @:@default=no@:@])],
+[egl_enabled=$enableval],
+[PKG_CHECK_MODULES(EGL, [egl], [egl_enabled=yes], [egl_enabled=no])])
+AC_ARG_ENABLE([gles1],
+[AS_HELP_STRING([--disable-gles1],
+[disable support for OpenGL ES 1.x API @:@default=no@:@])],
+[glesv1_enabled=$enableval],
+[PKG_CHECK_MODULES(GLESV1, [glesv1_cm], [glesv1_enabled=yes], 
[glesv1_enabled=no])])
+AC_ARG_ENABLE([gles2],
+[AS_HELP_STRING([--disable-gles2],
+[disable support for OpenGL ES 2.x API @:@default=no@:@])],
+[glesv2_enabled=$enableval],
+[PKG_CHECK_MODULES(GLESV2, [glesv2], [glesv2_enabled=yes], 
[glesv2_enabled=no])])
+AC_ARG_ENABLE([vg],
+[AS_HELP_STRING([--disable-vg],
+[disable support for OpenVG API @:@default=no@:@])],
+[vg_enabled=$enableval],
+[PKG_CHECK_MODULES(VG, [vg], [vg_enabled=yes], [vg_enabled=no])])
+AC_ARG_ENABLE([osmesa],
+[AS_HELP_STRING([--disable-osmesa],
+[disable OSMesa library @:@default=no@:@])],
+[osmesa_enabled=$enableval],
+[PKG_CHECK_MODULES(OSMESA, [osmesa], [osmesa_enabled=yes], 
[osmesa_enabled=no])])
+AC_ARG_ENABLE([libdrm],
+[AS_HELP_STRING([--disable-libdrm],
+[disable support for libdrm @:@default=no@:@])],
+[drm_enabled=$enableval],
+[PKG_CHECK_MODULES(DRM, [libdrm], [drm_enabled=yes], [drm_enabled=no])])
 dnl The OSMesa .pc uses OSMesa32, while we want to build with other versions
 dnl too.
 OSMESA32_LIBS=$OSMESA_LIBS
@@ -155,9 +179,17 @@ else
 fi
 DEMO_CFLAGS=$DEMO_CFLAGS $CWARNFLAGS
 
-PKG_CHECK_MODULES(X11, [x11 xext], [x11_enabled=yes], [enable_x11=no])
-PKG_CHECK_MODULES(FREETYPE2, [freetype2],
- [freetype2_enabled=yes], [freetype2_enabled=no])
+AC_ARG_ENABLE([x11],
+[AS_HELP_STRING([--disable-x11],
+[disable support for X11 @:@default=no@:@])],
+[x11_enabled=$enableval],
+[PKG_CHECK_MODULES(X11, [x11 xext], [x11_enabled=yes], [enable_x11=no])])
+AC_ARG_ENABLE([freetype2],
+[AS_HELP_STRING([--disable-freetype2],
+[disable support for X11 @:@default=no@:@])],
+[freetype2_enabled=$enableval],
+[PKG_CHECK_MODULES(FREETYPE2, [freetype2],
+[freetype2_enabled=yes], [freetype2_enabled=no])])
 
 mesa_source_enabled=no
 AC_ARG_WITH([mesa-source],
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 0/15] remove GLchan from core Mesa

2011-09-17 Thread Brian Paul
The GLchan type, etc is really only needed for swrast.  This patch 
series removes all the GLchan-related stuff out of core Mesa.


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


[Mesa-dev] [PATCH] Remove unneeded xdamages header from dri2_glx.c.

2011-09-17 Thread Matt Turner
It's needed for dri1 but not dri2.

Signed-off-by: Matt Turner matts...@gmail.com
---
 src/glx/dri2_glx.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 2d72ae0..01e3fd6 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -34,7 +34,6 @@
 
 #include X11/Xlib.h
 #include X11/extensions/Xfixes.h
-#include X11/extensions/Xdamage.h
 #include glapi.h
 #include glxclient.h
 #include X11/extensions/dri2proto.h
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 1/2] Remove -lXmu from LIBS

2011-09-17 Thread Matt Turner
It's not used anywhere that I can see.

Signed-off-by: Matt Turner matts...@gmail.com
---
 configs/aix|2 +-
 configs/aix-64 |2 +-
 configs/aix-64-static  |2 +-
 configs/aix-gcc|2 +-
 configs/aix-static |2 +-
 configs/darwin |2 +-
 configs/freebsd|2 +-
 configs/hpux10 |2 +-
 configs/hpux10-gcc |2 +-
 configs/hpux10-static  |4 ++--
 configs/hpux11-32-static   |2 +-
 configs/hpux11-32-static-nothreads |2 +-
 configs/hpux11-64  |2 +-
 configs/hpux11-64-static   |2 +-
 configs/hpux11-ia64|2 +-
 configs/hpux11-ia64-static |2 +-
 configs/hpux9  |2 +-
 configs/hpux9-gcc  |2 +-
 configs/irix6-64   |2 +-
 configs/irix6-64-static|2 +-
 configs/irix6-n32  |2 +-
 configs/irix6-n32-static   |2 +-
 configs/irix6-o32  |2 +-
 configs/irix6-o32-static   |2 +-
 configs/linux-ia64-icc-static  |2 +-
 configs/linux-icc-static   |2 +-
 configs/linux-osmesa-static|2 +-
 configs/linux-static   |2 +-
 configs/linux-x86-64-static|2 +-
 configs/linux-x86-static   |2 +-
 configs/netbsd |2 +-
 configs/osf1   |2 +-
 configs/osf1-static|2 +-
 configs/solaris-x86|2 +-
 configs/solaris-x86-gcc|2 +-
 configs/solaris-x86-gcc-static |2 +-
 configs/sunos4 |2 +-
 configs/sunos4-gcc |2 +-
 configs/sunos4-static  |2 +-
 configs/sunos5 |2 +-
 configs/sunos5-gcc |2 +-
 configs/sunos5-smp |2 +-
 configs/sunos5-v8  |2 +-
 configs/sunos5-v8-static   |2 +-
 configs/sunos5-v9  |2 +-
 configs/sunos5-v9-cc-g++   |2 +-
 configs/sunos5-v9-static   |2 +-
 configs/ultrix-gcc |2 +-
 48 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/configs/aix b/configs/aix
index 5d346d5..b3c0756 100644
--- a/configs/aix
+++ b/configs/aix
@@ -24,5 +24,5 @@ GL_LIB_DEPS = -lX11 -lXext -lpthread -lm
 GLU_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lm -lC
 GLW_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lXm -lXt -lX11
 OSMESA_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB)
-APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 
-lXext -lXmu -lXi -lpthread -lm -lC
+APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 
-lXext -lXi -lpthread -lm -lC
 
diff --git a/configs/aix-64 b/configs/aix-64
index a048c55..f59147b 100644
--- a/configs/aix-64
+++ b/configs/aix-64
@@ -21,5 +21,5 @@ OSMESA_LIB_NAME = libOSMesa.a
 GL_LIB_DEPS = -lX11 -lXext -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lC
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lXm -lXt -lX11
-APP_LIB_DEPS = -L$(TOP)/lib64 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 
-lXext -lXmu -lXi -lm -lpthread -lC
+APP_LIB_DEPS = -L$(TOP)/lib64 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 
-lXext -lXi -lm -lpthread -lC
 
diff --git a/configs/aix-64-static b/configs/aix-64-static
index ee4147f..f162d6b 100644
--- a/configs/aix-64-static
+++ b/configs/aix-64-static
@@ -20,5 +20,5 @@ GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 APP_LIB_DEPS = -q64 -L$(TOP)/$(LIB_DIR)  -l$(GLUT_LIB) -l$(GLU_LIB) 
-l$(GL_LIB) \
-   -lX11 -lXext -lXmu -lXi -lm -lpthread -lC
+   -lX11 -lXext -lXi -lm -lpthread -lC
 
diff --git a/configs/aix-gcc b/configs/aix-gcc
index 223e809..310491b 100644
--- a/configs/aix-gcc
+++ b/configs/aix-gcc
@@ -18,5 +18,5 @@ CXXFLAGS += -fno-strict-aliasing
 MKLIB_OPTIONS = -arch aix-gcc
 GL_LIB_DEPS = -lX11 -lXext -lm
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -Wl,-brtl -l$(GLUT_LIB) -l$(GLU_LIB) 
-l$(GL_LIB) -lm -lX11 -lXext -lXmu -lXi
+APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -Wl,-brtl -l$(GLUT_LIB) -l$(GLU_LIB) 
-l$(GL_LIB) -lm -lX11 -lXext -lXi
 
diff --git a/configs/aix-static b/configs/aix-static
index 3350848..a7adda2 100644
--- a/configs/aix-static
+++ b/configs/aix-static
@@ -19,6 +19,6 @@ GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-   -lX11 -lXext -lXmu -lXi -lm -lpthread -lC
+   -lX11 -lXext -lXi -lm -lpthread -lC
 
 
diff --git a/configs/darwin b/configs/darwin
index 83f417c..e5f159a 100644
--- a/configs/darwin
+++ b/configs/darwin
@@ -48,7 +48,7 @@ GL_LIB_DEPS = -L$(INSTALL_DIR)/$(LIB_DIR) 
-L$(X11_DIR)/$(LIB_DIR) -lX11 -lXext -
 OSMESA_LIB_DEPS =
 

[Mesa-dev] [PATCH 2/2] Remove -lXi from LIBS

2011-09-17 Thread Matt Turner
It's not used anywhere that I can see.

Signed-off-by: Matt Turner matts...@gmail.com
---
 configs/aix|2 +-
 configs/aix-64 |2 +-
 configs/aix-64-static  |2 +-
 configs/aix-gcc|2 +-
 configs/aix-static |2 +-
 configs/darwin |2 +-
 configs/freebsd|2 +-
 configs/hpux10 |2 +-
 configs/hpux10-gcc |2 +-
 configs/hpux10-static  |4 ++--
 configs/hpux11-32  |2 +-
 configs/hpux11-32-static   |2 +-
 configs/hpux11-32-static-nothreads |2 +-
 configs/hpux11-64  |2 +-
 configs/hpux11-64-static   |2 +-
 configs/hpux11-ia64|2 +-
 configs/hpux11-ia64-static |2 +-
 configs/hpux9  |2 +-
 configs/hpux9-gcc  |2 +-
 configs/irix6-64   |2 +-
 configs/irix6-64-static|2 +-
 configs/irix6-n32  |2 +-
 configs/irix6-n32-static   |2 +-
 configs/irix6-o32  |2 +-
 configs/irix6-o32-static   |2 +-
 configs/linux-ia64-icc-static  |2 +-
 configs/linux-icc-static   |2 +-
 configs/linux-osmesa-static|2 +-
 configs/linux-static   |2 +-
 configs/linux-x86-64-static|2 +-
 configs/linux-x86-static   |2 +-
 configs/netbsd |2 +-
 configs/osf1   |2 +-
 configs/osf1-static|2 +-
 configs/solaris-x86|2 +-
 configs/solaris-x86-gcc|2 +-
 configs/solaris-x86-gcc-static |2 +-
 configs/sunos4 |2 +-
 configs/sunos4-gcc |2 +-
 configs/sunos4-static  |2 +-
 configs/sunos5 |2 +-
 configs/sunos5-gcc |2 +-
 configs/sunos5-smp |2 +-
 configs/sunos5-v8  |2 +-
 configs/sunos5-v8-static   |2 +-
 configs/sunos5-v9  |2 +-
 configs/sunos5-v9-cc-g++   |2 +-
 configs/sunos5-v9-static   |2 +-
 configs/ultrix-gcc |2 +-
 49 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/configs/aix b/configs/aix
index b3c0756..b9578b2 100644
--- a/configs/aix
+++ b/configs/aix
@@ -24,5 +24,5 @@ GL_LIB_DEPS = -lX11 -lXext -lpthread -lm
 GLU_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lm -lC
 GLW_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lXm -lXt -lX11
 OSMESA_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB)
-APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 
-lXext -lXi -lpthread -lm -lC
+APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 
-lXext -lpthread -lm -lC
 
diff --git a/configs/aix-64 b/configs/aix-64
index f59147b..2b2f28d 100644
--- a/configs/aix-64
+++ b/configs/aix-64
@@ -21,5 +21,5 @@ OSMESA_LIB_NAME = libOSMesa.a
 GL_LIB_DEPS = -lX11 -lXext -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lC
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lXm -lXt -lX11
-APP_LIB_DEPS = -L$(TOP)/lib64 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 
-lXext -lXi -lm -lpthread -lC
+APP_LIB_DEPS = -L$(TOP)/lib64 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 
-lXext -lm -lpthread -lC
 
diff --git a/configs/aix-64-static b/configs/aix-64-static
index f162d6b..90731a7 100644
--- a/configs/aix-64-static
+++ b/configs/aix-64-static
@@ -20,5 +20,5 @@ GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 APP_LIB_DEPS = -q64 -L$(TOP)/$(LIB_DIR)  -l$(GLUT_LIB) -l$(GLU_LIB) 
-l$(GL_LIB) \
-   -lX11 -lXext -lXi -lm -lpthread -lC
+   -lX11 -lXext -lm -lpthread -lC
 
diff --git a/configs/aix-gcc b/configs/aix-gcc
index 310491b..7ceee31 100644
--- a/configs/aix-gcc
+++ b/configs/aix-gcc
@@ -18,5 +18,5 @@ CXXFLAGS += -fno-strict-aliasing
 MKLIB_OPTIONS = -arch aix-gcc
 GL_LIB_DEPS = -lX11 -lXext -lm
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -Wl,-brtl -l$(GLUT_LIB) -l$(GLU_LIB) 
-l$(GL_LIB) -lm -lX11 -lXext -lXi
+APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -Wl,-brtl -l$(GLUT_LIB) -l$(GLU_LIB) 
-l$(GL_LIB) -lm -lX11 -lXext
 
diff --git a/configs/aix-static b/configs/aix-static
index a7adda2..e02db54 100644
--- a/configs/aix-static
+++ b/configs/aix-static
@@ -19,6 +19,6 @@ GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-   -lX11 -lXext -lXi -lm -lpthread -lC
+   -lX11 -lXext -lm -lpthread -lC
 
 
diff --git a/configs/darwin b/configs/darwin
index e5f159a..1dbb8a7 100644
--- a/configs/darwin
+++ b/configs/darwin
@@ -48,7 +48,7 @@ GL_LIB_DEPS = -L$(INSTALL_DIR)/$(LIB_DIR) 
-L$(X11_DIR)/$(LIB_DIR) -lX11 -lXext -
 OSMESA_LIB_DEPS =