Mesa (master): radeonsi: start reworking inferred state handling

2012-09-26 Thread Christian König
Module: Mesa
Branch: master
Commit: 04473db38ade5902a6ad49dba8ca8215599d57be
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=04473db38ade5902a6ad49dba8ca8215599d57be

Author: Christian König deathsim...@vodafone.de
Date:   Fri Sep 14 17:05:34 2012 +0200

radeonsi: start reworking inferred state handling

Instead of tracking the inferred state changes separately
just check if queued and emitted states are the same.

This patch just reworks the update of the SPI map between
vs and ps, but there are probably more cases like this.

Signed-off-by: Christian König deathsim...@vodafone.de
Reviewed-by: Michel Dänzer michel.daen...@amd.com

---

 src/gallium/drivers/radeonsi/radeonsi_pipe.h |1 -
 src/gallium/drivers/radeonsi/si_state.c  |2 --
 src/gallium/drivers/radeonsi/si_state.h  |3 +++
 src/gallium/drivers/radeonsi/si_state_draw.c |4 +---
 4 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 4253dbb..587cba8 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -140,7 +140,6 @@ struct r600_context {
struct r600_textures_info   ps_samplers;
struct si_resource  *border_color_table;
unsignedborder_color_offset;
-   boolean shader_dirty;
 
struct u_upload_mgr *uploader;
struct util_slab_mempoolpool_transfers;
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 1a5ed2f..4def9a8 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1969,7 +1969,6 @@ static void si_bind_vs_shader(struct pipe_context *ctx, 
void *state)
if (rctx-vs_shader == sel)
return;
 
-   rctx-shader_dirty = true;
rctx-vs_shader = sel;
 
if (sel  sel-current)
@@ -1986,7 +1985,6 @@ static void si_bind_ps_shader(struct pipe_context *ctx, 
void *state)
if (rctx-ps_shader == sel)
return;
 
-   rctx-shader_dirty = true;
rctx-ps_shader = sel;
 
if (sel  sel-current)
diff --git a/src/gallium/drivers/radeonsi/si_state.h 
b/src/gallium/drivers/radeonsi/si_state.h
index d59624c..5c908a7 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -101,6 +101,9 @@ union si_state {
 #define si_pm4_block_idx(member) \
(offsetof(union si_state, named.member) / sizeof(struct si_pm4_state *))
 
+#define si_pm4_state_changed(rctx, member) \
+   ((rctx)-queued.named.member != (rctx)-emitted.named.member)
+
 #define si_pm4_bind_state(rctx, member, value) \
do { \
(rctx)-queued.named.member = (value); \
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
b/src/gallium/drivers/radeonsi/si_state_draw.c
index 0cb8b71..2608ad0 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -406,12 +406,10 @@ static void si_update_derived_state(struct r600_context 
*rctx)
 
if (ps_dirty) {
si_pm4_bind_state(rctx, ps, rctx-ps_shader-current-pm4);
-   rctx-shader_dirty = true;
}
 
-   if (rctx-shader_dirty) {
+   if (si_pm4_state_changed(rctx, ps) || si_pm4_state_changed(rctx, vs)) {
si_update_spi_map(rctx);
-   rctx-shader_dirty = false;
}
 }
 

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


Mesa (master): radeonsi: remove unused code

2012-09-26 Thread Christian König
Module: Mesa
Branch: master
Commit: fcc9c125f45df941dbd7e82c56d99c127255bc4d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fcc9c125f45df941dbd7e82c56d99c127255bc4d

Author: Christian Koenig christian.koe...@amd.com
Date:   Wed Sep 19 14:44:17 2012 +0200

radeonsi: remove unused code

Signed-off-by: Christian Koenig christian.koe...@amd.com
Reviewed-by: Michel Dänzer michel.daen...@amd.com

---

 src/gallium/drivers/radeonsi/radeonsi_shader.c |   19 ---
 1 files changed, 0 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c 
b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 466d565..57950a7 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -48,25 +48,6 @@
 #include errno.h
 #include stdio.h
 
-/*
-static ps_remap_inputs(
-   struct tgsi_llvm_context * tl_ctx,
-   unsigned tgsi_index,
-   unsigned tgsi_chan)
-{
-   :
-}
-
-struct si_input
-{
-   struct list_head head;
-   unsigned tgsi_index;
-   unsigned tgsi_chan;
-   unsigned order;
-};
-*/
-
-
 struct si_shader_context
 {
struct radeon_llvm_context radeon_bld;

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


Mesa (master): radeonsi: get rid of evergreen_hw_context.c

2012-09-26 Thread Christian König
Module: Mesa
Branch: master
Commit: 3c51c60ed00b5777cb5c55664c2da8e010a4f385
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3c51c60ed00b5777cb5c55664c2da8e010a4f385

Author: Christian Koenig christian.koe...@amd.com
Date:   Thu Sep 20 12:00:30 2012 +0200

radeonsi: get rid of evergreen_hw_context.c

Signed-off-by: Christian Koenig christian.koe...@amd.com
Reviewed-by: Michel Dänzer michel.daen...@amd.com

---

 src/gallium/drivers/radeonsi/Makefile.sources  |1 -
 .../drivers/radeonsi/evergreen_hw_context.c|   45 
 src/gallium/drivers/radeonsi/radeonsi_pipe.c   |7 +--
 3 files changed, 3 insertions(+), 50 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/Makefile.sources 
b/src/gallium/drivers/radeonsi/Makefile.sources
index f1b4936..65da1ac 100644
--- a/src/gallium/drivers/radeonsi/Makefile.sources
+++ b/src/gallium/drivers/radeonsi/Makefile.sources
@@ -7,7 +7,6 @@ C_SOURCES := \
r600_resource.c \
radeonsi_shader.c \
r600_texture.c \
-   evergreen_hw_context.c \
r600_translate.c \
radeonsi_pm4.c \
si_state.c \
diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
deleted file mode 100644
index 44fc950..000
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2010 Jerome Glisse gli...@freedesktop.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the Software),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *  Jerome Glisse
- */
-#include r600.h
-#include r600_hw_context_priv.h
-#include radeonsi_pipe.h
-#include sid.h
-#include util/u_memory.h
-#include errno.h
-
-int si_context_init(struct r600_context *ctx)
-{
-   int r;
-
-   LIST_INITHEAD(ctx-active_query_list);
-
-   ctx-cs = ctx-ws-cs_create(ctx-ws);
-
-   ctx-max_db = 8;
-   return 0;
-}
-
-
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
index 03fe88d..7c48db7 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
@@ -219,10 +219,9 @@ static struct pipe_context *r600_create_context(struct 
pipe_screen *screen, void
switch (rctx-chip_class) {
case TAHITI:
si_init_state_functions(rctx);
-   if (si_context_init(rctx)) {
-   r600_destroy_context(rctx-context);
-   return NULL;
-   }
+   LIST_INITHEAD(rctx-active_query_list);
+   rctx-cs = rctx-ws-cs_create(rctx-ws);
+   rctx-max_db = 8;
si_init_config(rctx);
break;
default:

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


Mesa (master): radeonsi: start seperating commands into si_commands.c

2012-09-26 Thread Christian König
Module: Mesa
Branch: master
Commit: 7773c7109c9a3b31767fab012183f64b932264a7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7773c7109c9a3b31767fab012183f64b932264a7

Author: Christian Koenig christian.koe...@amd.com
Date:   Thu Sep 20 12:15:11 2012 +0200

radeonsi: start seperating commands into si_commands.c

Signed-off-by: Christian Koenig christian.koe...@amd.com
Reviewed-by: Michel Dänzer michel.daen...@amd.com

---

 src/gallium/drivers/radeonsi/si_commands.c |8 
 src/gallium/drivers/radeonsi/si_state.c|5 +
 src/gallium/drivers/radeonsi/si_state.h|1 +
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_commands.c 
b/src/gallium/drivers/radeonsi/si_commands.c
index e9492b8..5215a34 100644
--- a/src/gallium/drivers/radeonsi/si_commands.c
+++ b/src/gallium/drivers/radeonsi/si_commands.c
@@ -28,6 +28,14 @@
 #include radeonsi_pm4.h
 #include sid.h
 
+void si_cmd_context_control(struct si_pm4_state *pm4)
+{
+   si_pm4_cmd_begin(pm4, PKT3_CONTEXT_CONTROL);
+   si_pm4_cmd_add(pm4, 0x8000);
+   si_pm4_cmd_add(pm4, 0x8000);
+   si_pm4_cmd_end(pm4, false);
+}
+
 void si_cmd_surface_sync(struct si_pm4_state *pm4, uint32_t cp_coher_cntl)
 {
si_pm4_cmd_begin(pm4, PKT3_SURFACE_SYNC);
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 4def9a8..8d19848 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2596,10 +2596,7 @@ void si_init_config(struct r600_context *rctx)
 {
struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
 
-   si_pm4_cmd_begin(pm4, PKT3_CONTEXT_CONTROL);
-   si_pm4_cmd_add(pm4, 0x8000);
-   si_pm4_cmd_add(pm4, 0x8000);
-   si_pm4_cmd_end(pm4, false);
+   si_cmd_context_control(pm4);
 
si_pm4_set_reg(pm4, R_028A4C_PA_SC_MODE_CNTL_1, 0x0);
 
diff --git a/src/gallium/drivers/radeonsi/si_state.h 
b/src/gallium/drivers/radeonsi/si_state.h
index 5c908a7..5e945ec 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -159,6 +159,7 @@ void si_set_so_targets(struct pipe_context *ctx,
 void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo);
 
 /* si_commands.c */
+void si_cmd_context_control(struct si_pm4_state *pm4);
 void si_cmd_surface_sync(struct si_pm4_state *pm4, uint32_t cp_coher_cntl);
 
 #endif

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


Mesa (master): mesa: fix incorrect error for glCompressedSubTexImage

2012-09-26 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 1f586684d62c4f5208d1f3929d067a79ea2140ac
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1f586684d62c4f5208d1f3929d067a79ea2140ac

Author: Brian Paul bri...@vmware.com
Date:   Sat Sep 22 09:30:23 2012 -0600

mesa: fix incorrect error for glCompressedSubTexImage

If a subtexture region isn't aligned to the compressed block size,
return GL_INVALID_OPERATION, not gl_INVALID_VALUE.

NOTE: This is a candidate for the stable branches.

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

---

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

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 08af668..c22e853 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3574,13 +3574,13 @@ compressed_subtexture_error_check(struct gl_context 
*ctx, GLint dimensions,
get_compressed_block_size(format, bw, bh);
 
if ((xoffset % bw != 0) || (yoffset % bh != 0))
-  return GL_INVALID_VALUE;
+  return GL_INVALID_OPERATION;
 
if ((width % bw != 0)  width != 2  width != 1)
-  return GL_INVALID_VALUE;
+  return GL_INVALID_OPERATION;
 
if ((height % bh != 0)  height != 2  height != 1)
-  return GL_INVALID_VALUE;
+  return GL_INVALID_OPERATION;
 
expectedSize = compressed_tex_size(width, height, depth, format);
if (expectedSize != imageSize)

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


Mesa (master): mesa: consolidate subtexture xoffset/yoffset/width/ height error checking code

2012-09-26 Thread Brian Paul
Module: Mesa
Branch: master
Commit: bd3caa50a569367dfd2d5ed0779f8d2e956f312a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd3caa50a569367dfd2d5ed0779f8d2e956f312a

Author: Brian Paul bri...@vmware.com
Date:   Sat Sep 22 09:30:23 2012 -0600

mesa: consolidate subtexture xoffset/yoffset/width/height error checking code

This is the code that checks if a subtexture region is aligned to the
compressed format's block size.

---

 src/mesa/main/teximage.c |  161 +-
 1 files changed, 73 insertions(+), 88 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 5176308..dd158e2 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1343,6 +1343,60 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, 
GLenum target,
 
 
 /**
+ * Do error checking of xoffset, yoffset, width, height for glTexSubImage,
+ * glCopyTexSubImage and glCompressedTexSubImage.
+ * Basically, check that the subregion is aligned to the compressed format's
+ * block size.  See comments in function for more info.
+ * \return GL_TRUE if error found, GL_FALSE otherwise.
+ */
+static GLboolean
+error_check_subtexture_dimensions(struct gl_context *ctx,
+  const char *function,
+  GLuint dims,
+  gl_format texFormat,
+  GLint xoffset, GLint yoffset,
+  GLsizei subWidth, GLsizei subHeight,
+  GLsizei texWidth, GLsizei texHeight)
+{
+   GLuint bw, bh;
+
+   /*
+* The OpenGL spec (and GL_ARB_texture_compression) says only whole
+* compressed texture images can be updated.  But, that restriction may be
+* relaxed for particular compressed formats.  At this time, all the
+* compressed formats supported by Mesa allow sub-textures to be updated
+* along compressed block boundaries.
+*/
+   _mesa_get_format_block_size(texFormat, bw, bh);
+
+   /* offset must be multiple of block size */
+   if ((xoffset % bw != 0) || (yoffset % bh != 0)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  %s%dD(xoffset = %d, yoffset = %d),
+  function, dims, xoffset, yoffset);
+  return GL_TRUE;
+   }
+
+   /* size must be multiple of bw by bh or equal to whole texture size */
+   if ((subWidth % bw != 0)  subWidth != texWidth) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  %s%dD(width = %d), function, dims, subWidth);
+  return GL_TRUE;
+   }
+
+   if ((subHeight % bh != 0)  subHeight != texHeight) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  %s%dD(height = %d), function, dims, subHeight);
+  return GL_TRUE;
+   } 
+
+   return GL_FALSE;
+}
+
+
+
+
+/**
  * This is the fallback for Driver.TestProxyTexImage() for doing device-
  * specific texture image size checks.
  *
@@ -1649,17 +1703,6 @@ compressed_tex_size(GLsizei width, GLsizei height, 
GLsizei depth,
 }
 
 
-/*
- * Return compressed texture block size, in pixels.
- */
-static void
-get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh)
-{
-   gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat);
-   _mesa_get_format_block_size(mesaFormat, bw, bh);
-}
-
-
 /**
  * Test the glTexImage[123]D() parameters for errors.
  * 
@@ -2195,35 +2238,19 @@ subtexture_error_check2( struct gl_context *ctx, GLuint 
dimensions,
}
 
if (_mesa_is_format_compressed(destTex-TexFormat)) {
-  GLuint bw, bh;
-
   if (compressedteximage_only_format(ctx, destTex-InternalFormat)) {
  _mesa_error(ctx, GL_INVALID_OPERATION,
glTexSubImage%dD(no compression for format), dimensions);
  return GL_TRUE;
   }
 
-  /* do tests which depend on compression block size */
-  _mesa_get_format_block_size(destTex-TexFormat, bw, bh);
-
-  /* offset must be multiple of block size */
-  if ((xoffset % bw != 0) || (yoffset % bh != 0)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- glTexSubImage%dD(xoffset = %d, yoffset = %d),
- dimensions, xoffset, yoffset);
+  if (error_check_subtexture_dimensions(ctx, glTexSubImage, dimensions,
+destTex-TexFormat,
+xoffset, yoffset,
+width, height,
+destTex-Width, destTex-Height)) {
  return GL_TRUE;
   }
-  /* size must be multiple of bw by bh or equal to whole texture size */
-  if ((width % bw != 0)  (GLuint) width != destTex-Width) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- glTexSubImage%dD(width = %d), dimensions, width);
- return GL_TRUE;
-  } 
-  if ((height % bh != 0)  (GLuint) height != destTex-Height) {
- 

Mesa (master): mesa: consolidate glCompressedTexSubImage() error checking

2012-09-26 Thread Brian Paul
Module: Mesa
Branch: master
Commit: f830f10a37603b93f67ff65fb8c9990a9f831c77
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f830f10a37603b93f67ff65fb8c9990a9f831c77

Author: Brian Paul bri...@vmware.com
Date:   Sat Sep 22 09:30:24 2012 -0600

mesa: consolidate glCompressedTexSubImage() error checking

Do all the checking in one function instead of two and fix up some of
the error checking.alignment check

---

 src/mesa/main/teximage.c |  165 -
 1 files changed, 88 insertions(+), 77 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index dd158e2..4ae8417 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3505,87 +3505,80 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
 
 /**
  * Error checking for glCompressedTexSubImage[123]D().
- * \warning  There are some bad assumptions here about the size of compressed
- *   texture tiles (multiple of 4) used to test the validity of the
- *   offset and size parameters.
  * \return error code or GL_NO_ERROR.
  */
 static GLenum
-compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions,
+compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
   GLenum target, GLint level,
   GLint xoffset, GLint yoffset, GLint zoffset,
   GLsizei width, GLsizei height, GLsizei depth,
   GLenum format, GLsizei imageSize)
 {
-   GLint expectedSize, maxLevels = 0, maxTextureSize;
-
-   (void) zoffset;
+   struct gl_texture_object *texObj;
+   struct gl_texture_image *texImage;
+   GLint expectedSize;
+   GLboolean targetOK;
 
-   if (dimensions == 1) {
-  /* 1D compressed textures not allowed */
-  return GL_INVALID_ENUM;
-   }
-   else if (dimensions == 2) {
-  if (target == GL_PROXY_TEXTURE_2D) {
- maxLevels = ctx-Const.MaxTextureLevels;
-  }
-  else if (target == GL_TEXTURE_2D) {
- maxLevels = ctx-Const.MaxTextureLevels;
-  }
-  else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
- if (!ctx-Extensions.ARB_texture_cube_map)
-return GL_INVALID_ENUM; /*target*/
- maxLevels = ctx-Const.MaxCubeTextureLevels;
-  }
-  else if (_mesa_is_cube_face(target)) {
- if (!ctx-Extensions.ARB_texture_cube_map)
-return GL_INVALID_ENUM; /*target*/
- maxLevels = ctx-Const.MaxCubeTextureLevels;
-  }
-  else {
- return GL_INVALID_ENUM; /*target*/
-  }
-   }
-   else if (dimensions == 3) {
-  /* 3D compressed textures not allowed */
-  return GL_INVALID_ENUM;
+   if (dims == 2) {
+  switch (target) {
+  case GL_TEXTURE_2D:
+  case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+  case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+  case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+  case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ targetOK = GL_TRUE;
+ break;
+  default:
+ targetOK = GL_FALSE;
+   }
+}
+   else {
+  assert(dims == 1 || dims == 3);
+  /* no 1D or 3D compressed textures at this time */
+  targetOK = GL_FALSE;
+   }
+ 
+   if (!targetOK) {
+  _mesa_error(ctx, GL_INVALID_ENUM, glCompressedTexImage%uD(target),
+  dims);
+  return GL_TRUE;
}
 
-   maxTextureSize = 1  (maxLevels - 1);
-
/* this will catch any invalid compressed format token */
-   if (!_mesa_is_compressed_format(ctx, format))
-  return GL_INVALID_ENUM;
-
-   if (width  1 || width  maxTextureSize)
-  return GL_INVALID_VALUE;
-
-   if ((height  1 || height  maxTextureSize)
-dimensions  1)
-  return GL_INVALID_VALUE;
+   if (!_mesa_is_compressed_format(ctx, format)) {
+  _mesa_error(ctx, GL_INVALID_ENUM, glCompressedTexImage%uD(format),
+  dims);
+  return GL_TRUE;
+   }
 
-   if (level  0 || level = maxLevels)
-  return GL_INVALID_VALUE;
+   if (level  0 || level = _mesa_max_texture_levels(ctx, target)) {
+  _mesa_error(ctx, GL_INVALID_VALUE, glCompressedTexImage%uD(level=%d),
+  dims, level);
+  return GL_TRUE;
+   }
 
expectedSize = compressed_tex_size(width, height, depth, format);
-   if (expectedSize != imageSize)
-  return GL_INVALID_VALUE;
-
-   return GL_NO_ERROR;
-}
+   if (expectedSize != imageSize) {
+  _mesa_error(ctx, GL_INVALID_VALUE, glCompressedTexImage%uD(size=%d),
+  dims, imageSize);
+  return GL_TRUE;
+   }
 
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY,
+  glCompressedTexSubImage%uD(), dims);
+  return GL_TRUE;
+   }
 
-/**
- * Do second part of glCompressedTexSubImage error checking.
- * \return GL_TRUE if error found, GL_FALSE otherwise.
- */
-static GLboolean

Mesa (master): mesa: minor fix to glTexSubImage error message

2012-09-26 Thread Brian Paul
Module: Mesa
Branch: master
Commit: b52e05cecb3650f875bd27c27bef529f35faea0a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b52e05cecb3650f875bd27c27bef529f35faea0a

Author: Brian Paul bri...@vmware.com
Date:   Sat Sep 22 09:30:24 2012 -0600

mesa: minor fix to glTexSubImage error message

---

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

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 501d33d..e4bee28 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2204,7 +2204,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
dimensions,
 
/* level check */
if (level  0 || level = _mesa_max_texture_levels(ctx, target)) {
-  _mesa_error(ctx, GL_INVALID_ENUM, glTexSubImage2D(level=%d), level);
+  _mesa_error(ctx, GL_INVALID_ENUM, glTexSubImage%uD(level=%d),
+  dimensions, level);
   return GL_TRUE;
}
 

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


Mesa (master): mesa: move _mesa_es_error_check_format_and_type() to glformats.c

2012-09-26 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 3ba9dbbabf591cfeb388cafbd9fa40cb784d32d9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ba9dbbabf591cfeb388cafbd9fa40cb784d32d9

Author: Brian Paul bri...@vmware.com
Date:   Sat Sep 22 09:30:24 2012 -0600

mesa: move _mesa_es_error_check_format_and_type() to glformats.c

Where the non-ES _mesa_error_check_format_and_type() function lives.

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

---

 src/mesa/main/glformats.c |   69 +
 src/mesa/main/glformats.h |4 ++
 src/mesa/main/readpix.c   |1 -
 src/mesa/main/teximage.c  |   65 --
 src/mesa/main/teximage.h  |3 --
 5 files changed, 73 insertions(+), 69 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 047a613..04029c0 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1372,3 +1372,72 @@ _mesa_error_check_format_and_type(const struct 
gl_context *ctx,
}
return GL_NO_ERROR;
 }
+
+
+/**
+ * Do error checking of format/type combinations for OpenGL ES glReadPixels
+ * and glTex[Sub]Image.
+ * \return error code, or GL_NO_ERROR.
+ */
+GLenum
+_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
+ unsigned dimensions)
+{
+   GLboolean type_valid = GL_TRUE;
+
+   switch (format) {
+   case GL_ALPHA:
+   case GL_LUMINANCE:
+   case GL_LUMINANCE_ALPHA:
+  type_valid = (type == GL_UNSIGNED_BYTE
+|| type == GL_FLOAT
+|| type == GL_HALF_FLOAT_OES);
+  break;
+
+   case GL_RGB:
+  type_valid = (type == GL_UNSIGNED_BYTE
+|| type == GL_UNSIGNED_SHORT_5_6_5
+|| type == GL_FLOAT
+|| type == GL_HALF_FLOAT_OES);
+  break;
+
+   case GL_RGBA:
+  type_valid = (type == GL_UNSIGNED_BYTE
+|| type == GL_UNSIGNED_SHORT_4_4_4_4
+|| type == GL_UNSIGNED_SHORT_5_5_5_1
+|| type == GL_FLOAT
+|| type == GL_HALF_FLOAT_OES
+|| type == GL_UNSIGNED_INT_2_10_10_10_REV);
+  break;
+
+   case GL_DEPTH_COMPONENT:
+  /* This format is filtered against invalid dimensionalities elsewhere.
+   */
+  type_valid = (type == GL_UNSIGNED_SHORT
+|| type == GL_UNSIGNED_INT);
+  break;
+
+   case GL_DEPTH_STENCIL:
+  /* This format is filtered against invalid dimensionalities elsewhere.
+   */
+  type_valid = (type == GL_UNSIGNED_INT_24_8);
+  break;
+
+   case GL_BGRA_EXT:
+  type_valid = (type == GL_UNSIGNED_BYTE);
+
+  /* This feels like a bug in the EXT_texture_format_BGRA spec, but
+   * the format does not appear to be allowed for 3D textures in OpenGL
+   * ES.
+   */
+  if (dimensions != 2)
+ return GL_INVALID_VALUE;
+
+  break;
+
+   default:
+  return GL_INVALID_VALUE;
+   }
+
+   return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
+}
diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h
index 24fbda9..e5b63a9 100644
--- a/src/mesa/main/glformats.h
+++ b/src/mesa/main/glformats.h
@@ -98,6 +98,10 @@ extern GLenum
 _mesa_error_check_format_and_type(const struct gl_context *ctx,
   GLenum format, GLenum type);
 
+extern GLenum
+_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
+ unsigned dimensions);
+
 
 #ifdef __cplusplus
 }
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 1793095..f6680c9 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -38,7 +38,6 @@
 #include state.h
 #include glformats.h
 #include fbobject.h
-#include teximage.h
 
 
 /**
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index fb22c8d..afda0ea 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1681,71 +1681,6 @@ mutable_tex_object(struct gl_context *ctx, GLenum target)
 }
 
 
-GLenum
-_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
- unsigned dimensions)
-{
-   bool type_valid = true;
-
-   switch (format) {
-   case GL_ALPHA:
-   case GL_LUMINANCE:
-   case GL_LUMINANCE_ALPHA:
-  type_valid = (type == GL_UNSIGNED_BYTE
-|| type == GL_FLOAT
-|| type == GL_HALF_FLOAT_OES);
-  break;
-
-   case GL_RGB:
-  type_valid = (type == GL_UNSIGNED_BYTE
-|| type == GL_UNSIGNED_SHORT_5_6_5
-|| type == GL_FLOAT
-|| type == GL_HALF_FLOAT_OES);
-  break;
-
-   case GL_RGBA:
-  type_valid = (type == GL_UNSIGNED_BYTE
-|| type == GL_UNSIGNED_SHORT_4_4_4_4
-|| type == GL_UNSIGNED_SHORT_5_5_5_1
-|| type == GL_FLOAT
-|| type == GL_HALF_FLOAT_OES
-   

Mesa (master): radeonsi: fix truncated register define.

2012-09-26 Thread Alex Deucher
Module: Mesa
Branch: master
Commit: 0aa47b2d8b83bbed9d774d58558058a35faa8795
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0aa47b2d8b83bbed9d774d58558058a35faa8795

Author: Alex Deucher alexander.deuc...@amd.com
Date:   Wed Sep 26 09:34:59 2012 -0400

radeonsi: fix truncated register define.

Signed-off-by: Alex Deucher alexander.deuc...@amd.com

---

 src/gallium/drivers/radeonsi/sid.h |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/sid.h 
b/src/gallium/drivers/radeonsi/sid.h
index d26e194..bc5fcda 100644
--- a/src/gallium/drivers/radeonsi/sid.h
+++ b/src/gallium/drivers/radeonsi/sid.h
@@ -5775,9 +5775,9 @@
 #define   S_02880C_Z_EXPORT_ENABLE(x) (((x)  
0x1)  0)
 #define   G_02880C_Z_EXPORT_ENABLE(x) (((x)  
0)  0x1)
 #define   C_02880C_Z_EXPORT_ENABLE
0xFFFE
-#define   S_02880C_STENCIL_TEST_VAL_EXPORT_ENAB(x)(((x)  
0x1)  1)
-#define   G_02880C_STENCIL_TEST_VAL_EXPORT_ENAB(x)(((x)  
1)  0x1)
-#define   C_02880C_STENCIL_TEST_VAL_EXPORT_ENAB   
0xFFFD
+#define   S_02880C_STENCIL_TEST_VAL_EXPORT_ENABLE(x)  (((x)  
0x1)  1)
+#define   G_02880C_STENCIL_TEST_VAL_EXPORT_ENABLE(x)  (((x)  
1)  0x1)
+#define   C_02880C_STENCIL_TEST_VAL_EXPORT_ENABLE 
0xFFFD
 #define   S_02880C_STENCIL_OP_VAL_EXPORT_ENABLE(x)(((x)  
0x1)  2)
 #define   G_02880C_STENCIL_OP_VAL_EXPORT_ENABLE(x)(((x)  
2)  0x1)
 #define   C_02880C_STENCIL_OP_VAL_EXPORT_ENABLE   
0xFFFB

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


Mesa (master): intel: Fix size of temporary etc1 buffer

2012-09-26 Thread Chad Versace
Module: Mesa
Branch: master
Commit: bb7ecb29fb6358a4c65278c2fe88936c578074cd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb7ecb29fb6358a4c65278c2fe88936c578074cd

Author: Chad Versace chad.vers...@linux.intel.com
Date:   Thu Sep 20 18:54:29 2012 +0200

intel: Fix size of temporary etc1 buffer

Fixes valgrind errors in piglit test
oes_compressed_etc1_rgb8_texture-miptree: an invalid write in
_mesa_store_compressed_store_texsubimage() at line 4406 and invalid reads
in texcompress_etc_tmp.h:etc1_parse_block().

The calculation of the size of the temporary etc1 buffer allocated by
intel_miptree_map_etc1() was incorrect. Sometimes the allocated buffer was
too small, sometimes too large.  This patch corrects the size to that
expected by _mesa_store_compressed_store_texsubimage().

Note: This is candidate for the 9.0 branch.
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Chad Versace chad.vers...@linux.intel.com

---

 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 556a82f..cd7299e 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -1292,9 +1292,10 @@ intel_miptree_map_etc1(struct intel_context *intel,
assert(map-x == 0);
assert(map-y == 0);
 
-   /* Each ETC1 block contains 4x4 pixels in 8 bytes. */
-   map-stride = 2 * map-w;
-   map-buffer = map-ptr = malloc(map-stride * map-h);
+   map-stride = _mesa_format_row_stride(MESA_FORMAT_ETC1_RGB8, map-w);
+   map-buffer = malloc(_mesa_format_image_size(MESA_FORMAT_ETC1_RGB8,
+map-w, map-h, 1));
+   map-ptr = map-buffer;
 }
 
 static void

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


Mesa (master): radeon/llvm: improve select_cc lowering to generate CND* more often

2012-09-26 Thread Vincent Lejeune
Module: Mesa
Branch: master
Commit: ff947c6d65830b7be6e9fcbfe666fa7dba6341f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff947c6d65830b7be6e9fcbfe666fa7dba6341f6

Author: Vincent Lejeune v...@ovi.com
Date:   Mon Sep 24 16:04:26 2012 +0200

radeon/llvm: improve select_cc lowering to generate CND* more often

v2: - Simplify isZero()
- Remove a unused function prototype
- Clean whitespace trails

Reviewed-by: Tom Stellard thomas.stell...@amd.com

---

 src/gallium/drivers/r600/r600_llvm.c|   15 
 src/gallium/drivers/radeon/R600ISelLowering.cpp |   89 ++-
 src/gallium/drivers/radeon/R600ISelLowering.h   |2 +
 src/gallium/drivers/radeon/R600Instructions.td  |   38 --
 4 files changed, 103 insertions(+), 41 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_llvm.c 
b/src/gallium/drivers/r600/r600_llvm.c
index dd0a714..71ea578 100644
--- a/src/gallium/drivers/r600/r600_llvm.c
+++ b/src/gallium/drivers/r600/r600_llvm.c
@@ -165,6 +165,20 @@ static void llvm_emit_tex(
emit_data-dst_type, args, c, 
LLVMReadNoneAttribute);
 }
 
+static void emit_cndlt(
+   const struct lp_build_tgsi_action * action,
+   struct lp_build_tgsi_context * bld_base,
+   struct lp_build_emit_data * emit_data)
+{
+   LLVMBuilderRef builder = bld_base-base.gallivm-builder;
+   LLVMValueRef float_zero = lp_build_const_float(
+   bld_base-base.gallivm, 0.0f);
+   LLVMValueRef cmp = LLVMBuildFCmp(
+   builder, LLVMRealULT, emit_data-args[0], float_zero, );
+   emit_data-output[emit_data-chan] = LLVMBuildSelect(builder,
+   cmp, emit_data-args[1], emit_data-args[2], );
+}
+
 static void dp_fetch_args(
struct lp_build_tgsi_context * bld_base,
struct lp_build_emit_data * emit_data)
@@ -241,6 +255,7 @@ LLVMModuleRef r600_tgsi_llvm(
bld_base-op_actions[TGSI_OPCODE_TXF].emit = llvm_emit_tex;
bld_base-op_actions[TGSI_OPCODE_TXQ].emit = llvm_emit_tex;
bld_base-op_actions[TGSI_OPCODE_TXP].emit = llvm_emit_tex;
+   bld_base-op_actions[TGSI_OPCODE_CMP].emit = emit_cndlt;
 
lp_build_tgsi_llvm(bld_base, tokens);
 
diff --git a/src/gallium/drivers/radeon/R600ISelLowering.cpp 
b/src/gallium/drivers/radeon/R600ISelLowering.cpp
index 2fc9c67..5dd2f53 100644
--- a/src/gallium/drivers/radeon/R600ISelLowering.cpp
+++ b/src/gallium/drivers/radeon/R600ISelLowering.cpp
@@ -516,6 +516,17 @@ SDValue R600TargetLowering::LowerROTL(SDValue Op, 
SelectionDAG DAG) const
  Op.getOperand(1)));
 }
 
+bool R600TargetLowering::isZero(SDValue Op) const
+{
+  if(ConstantSDNode *Cst = dyn_castConstantSDNode(Op)) {
+return Cst-isNullValue();
+  } else if(ConstantFPSDNode *CstFP = dyn_castConstantFPSDNode(Op)){
+return CstFP-isZero();
+  } else {
+return false;
+  }
+}
+
 SDValue R600TargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG DAG) const
 {
   DebugLoc DL = Op.getDebugLoc();
@@ -568,47 +579,58 @@ SDValue R600TargetLowering::LowerSELECT_CC(SDValue Op, 
SelectionDAG DAG) const
   if (isHWTrueValue(False)  isHWFalseValue(True)) {
   }
 
-  // XXX Check if we can lower this to a SELECT or if it is supported by a 
native
-  // operation. (The code below does this but we don't have the Instruction
-  // selection patterns to do this yet.
-#if 0
+  // Check if we can lower this to a native operation.
+  // CND* instructions requires all operands to have the same type,
+  // and RHS to be zero.
+
   if (isZero(LHS) || isZero(RHS)) {
 SDValue Cond = (isZero(LHS) ? RHS : LHS);
-bool SwapTF = false;
+SDValue Zero = (isZero(LHS) ? LHS : RHS);
+ISD::CondCode CCOpcode = castCondCodeSDNode(CC)-get();
+if (CompareVT != VT) {
+  True = DAG.getNode(ISD::BITCAST, DL, CompareVT, True);
+  False = DAG.getNode(ISD::BITCAST, DL, CompareVT, False);
+}
+if (isZero(LHS)) {
+  CCOpcode = ISD::getSetCCSwappedOperands(CCOpcode);
+}
+
 switch (CCOpcode) {
-case ISD::SETOEQ:
-case ISD::SETUEQ:
-case ISD::SETEQ:
-  SwapTF = true;
-  // Fall through
 case ISD::SETONE:
 case ISD::SETUNE:
 case ISD::SETNE:
-  // We can lower to select
-  if (SwapTF) {
-Temp = True;
-True = False;
-False = Temp;
-  }
-  // CNDE
-  return DAG.getNode(ISD::SELECT, DL, VT, Cond, True, False);
+case ISD::SETULE:
+case ISD::SETULT:
+case ISD::SETOLE:
+case ISD::SETOLT:
+case ISD::SETLE:
+case ISD::SETLT:
+  CCOpcode = ISD::getSetCCInverse(CCOpcode, CompareVT == MVT::i32);
+  Temp = True;
+  True = False;
+  False = Temp;
+  break;
 default:
-  // Supported by a native operation (CNDGE, CNDGT)
-  return DAG.getNode(ISD::SELECT_CC, DL, VT, LHS, RHS, True, False, CC);
+  break;
 }
+SDValue SelectNode = DAG.getNode(ISD::SELECT_CC, DL, CompareVT,
+