[Mesa-dev] [PATCH v2 23/29] mesa: Remove (signed) integer pack and span functions.

2014-12-01 Thread Iago Toral Quiroga
These are no longer used now that we moved to _mesa_format_convert.
---
 src/mesa/main/pack.c | 225 ---
 src/mesa/main/pack.h |  12 ---
 2 files changed, 237 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index a79dd04..6a32820 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -358,231 +358,6 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
}
 }
 
-/* Customization of unsigned integer packing.
- */
-#define SRC_TYPE GLuint
-
-#define DST_TYPE GLuint
-#define SRC_CONVERT(x) (x)
-#define FN_NAME pack_uint_from_uint_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLint
-#define SRC_CONVERT(x) MIN2(x, 0x7fff)
-#define FN_NAME pack_int_from_uint_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLushort
-#define SRC_CONVERT(x) MIN2(x, 0x)
-#define FN_NAME pack_ushort_from_uint_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLshort
-#define SRC_CONVERT(x) CLAMP((int)x, -32768, 32767)
-#define FN_NAME pack_short_from_uint_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLubyte
-#define SRC_CONVERT(x) MIN2(x, 0xff)
-#define FN_NAME pack_ubyte_from_uint_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLbyte
-#define SRC_CONVERT(x) CLAMP((int)x, -128, 127)
-#define FN_NAME pack_byte_from_uint_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#undef SRC_TYPE
-
-static void
-_pack_rgba_span_from_uints_problem(struct gl_context *ctx,
-   GLenum dstFormat, GLenum dstType)
-{
-   _mesa_problem(ctx,
- "Unsupported type (%s) / format (%s) "
- "in _mesa_pack_rgba_span_from_uints",
- _mesa_lookup_enum_by_nr(dstType),
- _mesa_lookup_enum_by_nr(dstFormat));
-}
-
-void
-_mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint 
rgba[][4],
-GLenum dstFormat, GLenum dstType,
-GLvoid *dstAddr)
-{
-   uint32_t dstMesaFormat;
-
-   switch(dstType) {
-   case GL_UNSIGNED_INT:
-  pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
-  break;
-   case GL_INT:
-  pack_int_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
-  break;
-   case GL_UNSIGNED_SHORT:
-  pack_ushort_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
-  break;
-   case GL_SHORT:
-  pack_short_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
-  break;
-   case GL_UNSIGNED_BYTE:
-  pack_ubyte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
-  break;
-   case GL_BYTE:
-  pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
-  break;
-   case GL_UNSIGNED_BYTE_3_3_2:
-   case GL_UNSIGNED_BYTE_2_3_3_REV:
-   case GL_UNSIGNED_SHORT_5_6_5:
-   case GL_UNSIGNED_SHORT_5_6_5_REV:
-   case GL_UNSIGNED_SHORT_4_4_4_4:
-   case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-   case GL_UNSIGNED_SHORT_5_5_5_1:
-   case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-   case GL_UNSIGNED_INT_8_8_8_8:
-   case GL_UNSIGNED_INT_8_8_8_8_REV:
-   case GL_UNSIGNED_INT_10_10_10_2:
-   case GL_UNSIGNED_INT_2_10_10_10_REV:
-  dstMesaFormat = _mesa_format_from_format_and_type(dstFormat, dstType);
-  if (!(dstMesaFormat & MESA_ARRAY_FORMAT_BIT)) {
- _mesa_pack_uint_rgba_row(dstMesaFormat, n, (void *)rgba[0], (void 
*)dstAddr);
- break;
-  } else {
- /* Fall through */
-  }
-   default:
-  _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  return;
-   }
-}
-
-/* Customization of signed integer packing.
- */
-#define SRC_TYPE GLint
-
-#define DST_TYPE GLuint
-#define SRC_CONVERT(x) MAX2(x, 0)
-#define FN_NAME pack_uint_from_int_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLushort
-#define SRC_CONVERT(x) MAX2(x, 0)
-#define FN_NAME pack_ushort_from_int_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLshort
-#define SRC_CONVERT(x) CLAMP(x, -0x8000, 0x7fff)
-#define FN_NAME pack_short_from_int_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLubyte
-#define SRC_CONVERT(x) MAX2(x, 0)
-#define FN_NAME pack_ubyte_from_int_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLbyte
-#define SRC_CONVERT(x) CLAMP(x, -0x80, 0x7f)
-#define FN_NAME pack_byte_from_int_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FN_NAME
-
-#undef SRC_TYPE
-
-static void
-_pack_rgba_span_from_ints_problem(struct gl_context *ctx,
-   GLenum dstFormat, GLenum ds

[Mesa-dev] [PATCH v2 25/29] mesa: Remove _mesa_pack_rgba_span_float and tmp_pack.h

2014-12-01 Thread Iago Toral Quiroga
_mesa_pack_rgba_span_float was the last of the color span functions
and we have replaced all calls to it with calls to _mesa_format_convert,
so we can remove it together with tmp_pack.h which was used to
generate the pack functions for multiple types that were used from
the various color span functions that have been removed.
---
 src/mesa/main/pack.c | 403 ---
 src/mesa/main/pack.h |   8 -
 src/mesa/main/pack_tmp.h | 196 ---
 3 files changed, 607 deletions(-)
 delete mode 100644 src/mesa/main/pack_tmp.h

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 6baa36e..b46a6fb 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -232,409 +232,6 @@ _mesa_pack_bitmap( GLint width, GLint height, const 
GLubyte *source,
 }
 
 
-/**
- * For small integer types, return the min and max possible values.
- * Used for clamping floats to unscaled integer types.
- * \return GL_TRUE if type is handled, GL_FALSE otherwise.
- */
-static GLboolean
-get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
-{
-   switch (type) {
-   case GL_BYTE:
-  *min = -128.0;
-  *max = 127.0;
-  return GL_TRUE;
-   case GL_UNSIGNED_BYTE:
-  *min = 0.0;
-  *max = 255.0;
-  return GL_TRUE;
-   case GL_SHORT:
-  *min = -32768.0;
-  *max = 32767.0;
-  return GL_TRUE;
-   case GL_UNSIGNED_SHORT:
-  *min = 0.0;
-  *max = 65535.0;
-  return GL_TRUE;
-   default:
-  return GL_FALSE;
-   }
-}
-
-/* Customization of float packing.
- */
-#define SRC_TYPE GLfloat
-
-#define DST_TYPE GLuint
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_UINT(x)
-#define SRC_CONVERT(x) (GLuint) x
-#define FN_NAME pack_uint_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLint
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_INT(x)
-#define SRC_CONVERT(x) (GLint) x
-#define FN_NAME pack_int_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLshort
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_SHORT_TEX(x)
-#define SRC_CONVERT(x) (GLshort) x
-#define FN_NAME pack_short_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLubyte
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_UBYTE(x)
-#define SRC_CONVERT(x) (GLubyte) x
-#define FN_NAME pack_ubyte_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLbyte
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_BYTE_TEX(x)
-#define SRC_CONVERT(x) (GLbyte) x
-#define FN_NAME pack_byte_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLfloat
-#define FLOAT_SRC_CONVERT(x) x
-#define SRC_CONVERT(x) x
-#define FN_NAME pack_float_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLhalfARB
-#define FLOAT_SRC_CONVERT(x) _mesa_float_to_half(x)
-#define FN_NAME pack_half_float_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#undef SRC_TYPE
-
-/**
- * Used to pack an array [][4] of RGBA float colors as specified
- * by the dstFormat, dstType and dstPacking.  Used by glReadPixels.
- * Historically, the RGBA values were in [0,1] and rescaled to fit
- * into GLubytes, etc.  But with new integer formats, the RGBA values
- * may have any value and we don't always rescale when converting to
- * integers.
- *
- * Note: the rgba values will be modified by this function when any pixel
- * transfer ops are enabled.
- */
-void
-_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
-   GLenum dstFormat, GLenum dstType,
-   GLvoid *dstAddr,
-   const struct gl_pixelstore_attrib *dstPacking,
-   GLbitfield transferOps)
-{
-   GLfloat *luminance;
-   const GLint comps = _mesa_components_in_format(dstFormat);
-   const GLboolean intDstFormat = _mesa_is_enum_format_integer(dstFormat);
-   GLuint i;
-   uint32_t dstMesaFormat;
-
-   if (dstFormat == GL_LUMINANCE ||
-   dstFormat == GL_LUMINANCE_ALPHA ||
-   dstFormat == GL_LUMINANCE_INTEGER_EXT ||
-   dstFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT) {
-  luminance = malloc(n * sizeof(GLfloat));
-  if (!luminance) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
- return;
-  }
-   }
-   else {
-  luminance = NULL;
-   }
-
-   /* EXT_texture_integer specifies no transfer ops on integer
-* types in the resolved issues section. Just set them to 0
-* for integer surfaces.
-*/
-   if (intDstFormat)
-  transferOps = 0;
-
-   if (transferOps) {

[Mesa-dev] [PATCH v2 16/23] mesa: Add _mesa_pack_uint_rgba_row() format conversion function

2014-12-01 Thread Iago Toral Quiroga
From: Samuel Iglesias Gonsalvez 

We will use this later on to handle uint conversion scenarios in a master
convert function.

v2:
- Modify pack_uint_*() function generation to use c.datatype() and
  f.datatype().
- Remove UINT_TO_FLOAT() macro usage from pack_uint*()
- Remove "if not f.is_normalized()" conditional as pack_uint*()
  functions are only autogenerated for non normalized formats.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/mesa/main/format_pack.c.mako | 82 
 src/mesa/main/format_pack.h  |  3 ++
 2 files changed, 85 insertions(+)

diff --git a/src/mesa/main/format_pack.c.mako b/src/mesa/main/format_pack.c.mako
index aced58d..7feb3f8 100644
--- a/src/mesa/main/format_pack.c.mako
+++ b/src/mesa/main/format_pack.c.mako
@@ -149,6 +149,56 @@ pack_ubyte_r11g11b10_float(const GLubyte src[4], void *dst)
*d = float3_to_r11g11b10f(rgb);
 }
 
+/* uint packing functions */
+
+%for f in rgb_formats:
+   %if not f.is_int():
+  <% continue %>
+   %elif f.is_normalized():
+  <% continue %>
+   %elif f.is_compressed():
+  <% continue %>
+   %endif
+
+static inline void
+pack_uint_${f.short_name()}(const GLuint src[4], void *dst)
+{
+   %for (i, c) in enumerate(f.channels):
+  <% i = f.swizzle.inverse()[i] %>
+  %if c.type == 'x':
+ <% continue %>
+  %endif
+
+  ${c.datatype()} ${c.name} =
+  %if c.type == parser.FLOAT and c.size == 16:
+ _mesa_float_to_half(src[${i}]);
+  %else:
+ (${c.datatype()}) src[${i}];
+  %endif
+   %endfor
+
+   %if f.layout == parser.ARRAY:
+  ${f.datatype()} *d = (${f.datatype()} *)dst;
+  %for (i, c) in enumerate(f.channels):
+ %if c.type == 'x':
+<% continue %>
+ %endif
+ d[${i}] = ${c.name};
+  %endfor
+   %elif f.layout == parser.PACKED:
+  ${f.datatype()} d = 0;
+  %for (i, c) in enumerate(f.channels):
+ %if c.type == 'x':
+<% continue %>
+ %endif
+ d |= PACK(${c.name}, ${c.shift}, ${c.size});
+  %endfor
+  (*(${f.datatype()} *)dst) = d;
+   %else:
+  <% assert False %>
+   %endif
+}
+%endfor
 
 /* float packing functions */
 
@@ -297,6 +347,38 @@ _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n,
 }
 
 /**
+ * Pack a row of GLuint rgba[4] values to the destination.
+ */
+void
+_mesa_pack_uint_rgba_row(mesa_format format, GLuint n,
+  const GLuint src[][4], void *dst)
+{
+   GLuint i;
+   GLubyte *d = dst;
+
+   switch (format) {
+%for f in rgb_formats:
+   %if not f.is_int():
+  <% continue %>
+   %elif f.is_normalized():
+  <% continue %>
+   %elif f.is_compressed():
+  <% continue %>
+   %endif
+
+   case ${f.name}:
+  for (i = 0; i < n; ++i) {
+ pack_uint_${f.short_name()}(src[i], d);
+ d += ${f.block_size() / 8};
+  }
+  break;
+%endfor
+   default:
+  assert(!"Invalid format");
+   }
+}
+
+/**
  * Pack a row of GLfloat rgba[4] values to the destination.
  */
 void
diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h
index 2577def..1582ad1 100644
--- a/src/mesa/main/format_pack.h
+++ b/src/mesa/main/format_pack.h
@@ -77,6 +77,9 @@ extern void
 _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n,
   const GLubyte src[][4], void *dst);
 
+extern void
+_mesa_pack_uint_rgba_row(mesa_format format, GLuint n,
+ const GLuint src[][4], void *dst);
 
 extern void
 _mesa_pack_ubyte_rgba_rect(mesa_format format, GLuint width, GLuint height,
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 08/29] mesa/pack: use _mesa_format_from_format_and_type in _mesa_pack_rgba_span_from_*

2014-12-01 Thread Iago Toral Quiroga
From: Samuel Iglesias Gonsalvez 

We had previously added the needed mesa formats, so we can simplify
the code further.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/mesa/main/pack.c | 282 +--
 1 file changed, 26 insertions(+), 256 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 06993d4..de6ab27 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -529,6 +529,8 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, 
GLuint n, GLuint rgba[][
 GLenum dstFormat, GLenum dstType,
 GLvoid *dstAddr)
 {
+   uint32_t dstMesaFormat;
+
switch(dstType) {
case GL_UNSIGNED_INT:
   pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
@@ -549,109 +551,24 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, 
GLuint n, GLuint rgba[][
   pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_UNSIGNED_BYTE_3_3_2:
-  if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_B2G3R3_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else
- _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  break;
case GL_UNSIGNED_BYTE_2_3_3_REV:
-  if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_R3G3B2_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else
- _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  break;
case GL_UNSIGNED_SHORT_5_6_5:
-  if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_B5G6R5_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else
- _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  break;
case GL_UNSIGNED_SHORT_5_6_5_REV:
-  if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_R5G6B5_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else
- _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  break;
case GL_UNSIGNED_SHORT_4_4_4_4:
-  if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_A4B4G4R4_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_A4R4G4B4_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if (dstFormat == GL_ABGR_EXT)
- _mesa_pack_uint_rgba_row(MESA_FORMAT_R4G4B4A4_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else
- _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  break;
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-  if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_R4G4B4A4_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_B4G4R4A4_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if (dstFormat == GL_ABGR_EXT)
- _mesa_pack_uint_rgba_row(MESA_FORMAT_A4B4G4R4_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else
- _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  break;
case GL_UNSIGNED_SHORT_5_5_5_1:
-  if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT))
-  _mesa_pack_uint_rgba_row(MESA_FORMAT_A1B5G5R5_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_A1R5G5B5_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if (dstFormat == GL_ABGR_EXT)
- _mesa_pack_uint_rgba_row(MESA_FORMAT_R1G5B5A5_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else
- _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  break;
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-  if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_R5G5B5A1_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_B5G5R5A1_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if (dstFormat == GL_ABGR_EXT)
- _mesa_pack_uint_rgba_row(MESA_FORMAT_A5B5G5R1_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else
- _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
-  break;
case GL_UNSIGNED_INT_8_8_8_8:
-  if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT))
- _mesa_pack_uint_rgba_row(MESA_FORMAT_A8B8G8R8_UNORM, n, (void 
*)rgba[0], (void *)dstAddr);
-  else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_I

[Mesa-dev] [PATCH v2 21/23] mesa/pack: use autogenerated format_pack functions

2014-12-01 Thread Iago Toral Quiroga
From: Samuel Iglesias Gonsalvez 

Take advantage of new mesa formats and new format_pack functions to
reduce source code in _mesa_pack_rgba_span_from_ints() and
_mesa_pack_rgba_span_from_uints().

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/mesa/main/pack.c | 663 +++
 1 file changed, 138 insertions(+), 525 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 649a74c..067a0f5 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -55,6 +55,8 @@
 #include "glformats.h"
 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+#include "format_utils.h"
+#include "format_pack.h"
 
 
 /**
@@ -527,8 +529,6 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, 
GLuint n, GLuint rgba[][
 GLenum dstFormat, GLenum dstType,
 GLvoid *dstAddr)
 {
-   GLuint i;
-
switch(dstType) {
case GL_UNSIGNED_INT:
   pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
@@ -549,300 +549,108 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, 
GLuint n, GLuint rgba[][
   pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
   break;
case GL_UNSIGNED_BYTE_3_3_2:
-  if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
- GLubyte *dst = (GLubyte *) dstAddr;
- for (i=0;ihttp://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 10/29] mesa: Add RGBA to Luminance conversion helpers

2014-12-01 Thread Iago Toral Quiroga
For glReadPixels with a Luminance destination format we compute luminance
values from RGBA as L=R+G+B. This, however, requires ad-hoc implementation,
since pack/unpack functions or _mesa_swizzle_and_convert won't do this
(and thus, neither will _mesa_format_convert). This patch adds helpers
to do this computation so they can be used to support conversion to luminance
formats.

The current implementation of glReadPixels does this computation as part
of the span functions in pack.c (see _mesa_pack_rgba_span_float), that do
this together with other things like type conversion, etc. We do not want
to use these functions but use _mesa_format_convert instead (later patches
will remove the color span functions), so we need to extract this functionality
as helpers.
---
 src/mesa/main/pack.c | 63 
 src/mesa/main/pack.h |  9 
 2 files changed, 72 insertions(+)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index de6ab27..fa4046c 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -4334,4 +4334,67 @@ _mesa_rebase_rgba_uint(GLuint n, GLuint rgba[][4], 
GLenum baseFormat)
}
 }
 
+void
+_mesa_pack_luminance_from_rgba_float(GLuint n, GLfloat rgba[][4],
+ GLvoid *dstAddr, GLenum dst_format,
+ GLbitfield transferOps)
+{
+   int i;
+   GLfloat *dst = (GLfloat *) dstAddr;
+
+   switch (dst_format) {
+   case GL_LUMINANCE:
+  if (transferOps & IMAGE_CLAMP_BIT) {
+ for (i = 0; i < n; i++) {
+GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+dst[i] = CLAMP(sum, 0.0F, 1.0F);
+ }
+  } else {
+ for (i = 0; i < n; i++) {
+dst[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+ }
+  }
+  return;
+   case GL_LUMINANCE_ALPHA:
+  if (transferOps & IMAGE_CLAMP_BIT) {
+ for (i = 0; i < n; i++) {
+GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+dst[2*i] = CLAMP(sum, 0.0F, 1.0F);
+dst[2*i+1] = rgba[i][ACOMP];
+ }
+  } else {
+ for (i = 0; i < n; i++) {
+dst[2*i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+dst[2*i+1] = rgba[i][ACOMP];
+ }
+  }
+  return;
+   default:
+  assert(!"Unsupported format");
+   }
+}
+
+void
+_mesa_pack_luminance_from_rgba_integer(GLuint n, GLuint rgba[][4],
+   GLvoid *dstAddr, GLenum dst_format)
+{
+   int i;
+   GLuint *dst = (GLuint *) dstAddr;
+
+   switch (dst_format) {
+   case GL_LUMINANCE:
+  for (i = 0; i < n; i++) {
+ dst[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+  }
+  return;
+   case GL_LUMINANCE_ALPHA:
+  for (i = 0; i < n; i++) {
+ dst[2*i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+ dst[2*i+1] = rgba[i][ACOMP];
+  }
+  return;
+   default:
+  assert(!"Unsupported format");
+   }
+}
 
diff --git a/src/mesa/main/pack.h b/src/mesa/main/pack.h
index 2173b65..2783f23 100644
--- a/src/mesa/main/pack.h
+++ b/src/mesa/main/pack.h
@@ -155,4 +155,13 @@ _mesa_rebase_rgba_float(GLuint n, GLfloat rgba[][4], 
GLenum baseFormat);
 extern void
 _mesa_rebase_rgba_uint(GLuint n, GLuint rgba[][4], GLenum baseFormat);
 
+extern void
+_mesa_pack_luminance_from_rgba_float(GLuint n, GLfloat rgba[][4],
+ GLvoid *dstAddr, GLenum dst_format,
+ GLbitfield transferOps);
+
+extern void
+_mesa_pack_luminance_from_rgba_integer(GLuint n, GLuint rgba[][4],
+   GLvoid *dstAddr, GLenum dst_format);
+
 #endif
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 13/29] mesa: use _mesa_format_convert to implement glReadPixels.

2014-12-01 Thread Iago Toral Quiroga
---
 src/mesa/main/readpix.c | 321 +++-
 1 file changed, 179 insertions(+), 142 deletions(-)

diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index b09cf54..31c0453 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -39,6 +39,8 @@
 #include "state.h"
 #include "glformats.h"
 #include "fbobject.h"
+#include "format_utils.h"
+#include "pixeltransfer.h"
 
 
 /**
@@ -405,174 +407,209 @@ read_stencil_pixels( struct gl_context *ctx,
ctx->Driver.UnmapRenderbuffer(ctx, rb);
 }
 
-
-/**
- * Try to do glReadPixels of RGBA data using swizzle.
- * \return GL_TRUE if successful, GL_FALSE otherwise (use the slow path)
+/*
+ * Read R, G, B, A, RGB, L, or LA pixels.
  */
-static GLboolean
-read_rgba_pixels_swizzle(struct gl_context *ctx,
- GLint x, GLint y,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing)
+static void
+read_rgba_pixels( struct gl_context *ctx,
+  GLint x, GLint y,
+  GLsizei width, GLsizei height,
+  GLenum format, GLenum type, GLvoid *pixels,
+  const struct gl_pixelstore_attrib *packing )
 {
-   struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+   GLbitfield transferOps;
+   bool dst_is_integer, dst_is_luminance, needs_rebase;
+   int dst_stride, src_stride, rb_stride;
+   uint32_t dst_format, src_format;
GLubyte *dst, *map;
-   int dstStride, stride, j;
-   GLboolean swizzle_rb = GL_FALSE, copy_xrgb = GL_FALSE;
-
-   /* XXX we could check for other swizzle/special cases here as needed */
-   if (rb->Format == MESA_FORMAT_R8G8B8A8_UNORM &&
-   format == GL_BGRA &&
-   type == GL_UNSIGNED_INT_8_8_8_8_REV &&
-   !ctx->Pack.SwapBytes) {
-  swizzle_rb = GL_TRUE;
-   }
-   else if (rb->Format == MESA_FORMAT_B8G8R8X8_UNORM &&
-   format == GL_BGRA &&
-   type == GL_UNSIGNED_INT_8_8_8_8_REV &&
-   !ctx->Pack.SwapBytes) {
-  copy_xrgb = GL_TRUE;
-   }
-   else {
-  return GL_FALSE;
-   }
+   mesa_format rb_format;
+   bool needs_rgba;
+   void *rgba, *src;
+   uint8_t rebase_swizzle[4];
+   struct gl_framebuffer *fb = ctx->ReadBuffer;
+   struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
 
-   dstStride = _mesa_image_row_stride(packing, width, format, type);
+   if (!rb)
+  return;
+
+   transferOps = get_readpixels_transfer_ops(ctx, rb->Format, format, type,
+ GL_FALSE);
+   /* Describe the dst format */
+   dst_is_integer = _mesa_is_enum_format_integer(format);
+   dst_stride = _mesa_image_row_stride(packing, width, format, type);
+   dst_format = _mesa_format_from_format_and_type(format, type);
+   dst_is_luminance = format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA;
dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
-  format, type, 0, 0);
+   format, type, 0, 0);
 
+   /* Map the source render buffer */
ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
-  &map, &stride);
+   &map, &rb_stride);
if (!map) {
   _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
-  return GL_TRUE;  /* don't bother trying the slow path */
+  return;
}
+   rb_format = _mesa_get_srgb_format_linear(rb->Format);
 
-   if (swizzle_rb) {
-  /* swap R/B */
-  for (j = 0; j < height; j++) {
- int i;
- for (i = 0; i < width; i++) {
-GLuint *dst4 = (GLuint *) dst, *map4 = (GLuint *) map;
-GLuint pixel = map4[i];
-dst4[i] = (pixel & 0xff00ff00)
-   | ((pixel & 0x00ff) >> 16)
-   | ((pixel & 0x00ff) << 16);
- }
- dst += dstStride;
- map += stride;
-  }
-   } else if (copy_xrgb) {
-  /* convert xrgb -> argb */
-  for (j = 0; j < height; j++) {
- GLuint *dst4 = (GLuint *) dst, *map4 = (GLuint *) map;
- int i;
- for (i = 0; i < width; i++) {
-dst4[i] = map4[i] | 0xff00;  /* set A=0xff */
- }
- dst += dstStride;
- map += stride;
-  }
+   /*
+* Depending on the base formats involved in the conversion we might need to
+* rebase some values, so for these formats we compute a rebase swizzle.
+*/
+   if (rb->_BaseFormat == GL_LUMINANCE || rb->_BaseFormat == GL_INTENSITY) {
+  needs_rebase = true;
+  rebase_swizzle[0] = MESA_FORMAT_SWIZZLE_X;
+  rebase_swizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
+  rebase_swizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
+  rebase_swizzle[3] = MESA_FORMAT_SWIZZLE_ONE;
+   } else if (rb->_BaseFormat == GL_LUMINANCE_ALPHA) {
+  needs_rebase = true

[Mesa-dev] [PATCH v2 28/29] mesa: Remove _mesa_rebase_rgba_uint and _mesa_rebase_rgba_float

2014-12-01 Thread Iago Toral Quiroga
These are no longer used anywhere now that we have _mesa_format_convert.
---
 src/mesa/main/pack.c | 126 ---
 src/mesa/main/pack.h |   7 ---
 2 files changed, 133 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index cb0956c..4f3ecec 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -1325,132 +1325,6 @@ _mesa_unpack_image( GLuint dimensions,
}
 }
 
-
-
-/**
- * If we unpack colors from a luminance surface, we'll get pixel colors
- * such as (l, l, l, a).
- * When we call _mesa_pack_rgba_span_float(format=GL_LUMINANCE), that
- * function will compute L=R+G+B before packing.  The net effect is we'll
- * accidentally store luminance values = 3*l.
- * This function compensates for that by converting (aka rebasing) (l,l,l,a)
- * to be (l,0,0,a).
- * It's a similar story for other formats such as LUMINANCE_ALPHA, ALPHA
- * and INTENSITY.
- *
- * Finally, we also need to do this when the actual surface format does
- * not match the logical surface format.  For example, suppose the user
- * requests a GL_LUMINANCE texture but the driver stores it as RGBA.
- * Again, we'll get pixel values like (l,l,l,a).
- */
-void
-_mesa_rebase_rgba_float(GLuint n, GLfloat rgba[][4], GLenum baseFormat)
-{
-   GLuint i;
-
-   switch (baseFormat) {
-   case GL_ALPHA:
-  for (i = 0; i < n; i++) {
- rgba[i][RCOMP] = 0.0F;
- rgba[i][GCOMP] = 0.0F;
- rgba[i][BCOMP] = 0.0F;
-  }
-  break;
-   case GL_INTENSITY:
-  /* fall-through */
-   case GL_LUMINANCE:
-  for (i = 0; i < n; i++) {
- rgba[i][GCOMP] = 0.0F;
- rgba[i][BCOMP] = 0.0F;
- rgba[i][ACOMP] = 1.0F;
-  }
-  break;
-   case GL_LUMINANCE_ALPHA:
-  for (i = 0; i < n; i++) {
- rgba[i][GCOMP] = 0.0F;
- rgba[i][BCOMP] = 0.0F;
-  }
-  break;
-   case GL_RGB:
-  for (i = 0; i < n; i++) {
- rgba[i][ACOMP] = 1.0F;
-  }
-  break;
-   case GL_RG:
-  for (i = 0; i < n; i++) {
- rgba[i][BCOMP] = 0.0F;
- rgba[i][ACOMP] = 1.0F;
-  }
-  break;
-   case GL_RED:
-  for (i = 0; i < n; i++) {
- rgba[i][GCOMP] = 0.0F;
- rgba[i][BCOMP] = 0.0F;
- rgba[i][ACOMP] = 1.0F;
-  }
-  break;
-
-   default:
-  /* no-op */
-  ;
-   }
-}
-
-
-/**
- * As above, but GLuint components.
- */
-void
-_mesa_rebase_rgba_uint(GLuint n, GLuint rgba[][4], GLenum baseFormat)
-{
-   GLuint i;
-
-   switch (baseFormat) {
-   case GL_ALPHA:
-  for (i = 0; i < n; i++) {
- rgba[i][RCOMP] = 0;
- rgba[i][GCOMP] = 0;
- rgba[i][BCOMP] = 0;
-  }
-  break;
-   case GL_INTENSITY:
-  /* fall-through */
-   case GL_LUMINANCE:
-  for (i = 0; i < n; i++) {
- rgba[i][GCOMP] = 0;
- rgba[i][BCOMP] = 0;
- rgba[i][ACOMP] = 1;
-  }
-  break;
-   case GL_LUMINANCE_ALPHA:
-  for (i = 0; i < n; i++) {
- rgba[i][GCOMP] = 0;
- rgba[i][BCOMP] = 0;
-  }
-  break;
-   case GL_RGB:
-  for (i = 0; i < n; i++) {
- rgba[i][ACOMP] = 1;
-  }
-  break;
-   case GL_RG:
-  for (i = 0; i < n; i++) {
- rgba[i][BCOMP] = 0;
- rgba[i][ACOMP] = 1;
-  }
-  break;
-   case GL_RED:
-  for (i = 0; i < n; i++) {
- rgba[i][GCOMP] = 0;
- rgba[i][BCOMP] = 0;
- rgba[i][ACOMP] = 1;
-  }
-   default:
-  /* no-op */
-  ;
-   }
-}
-
 void
 _mesa_pack_luminance_from_rgba_float(GLuint n, GLfloat rgba[][4],
  GLvoid *dstAddr, GLenum dst_format,
diff --git a/src/mesa/main/pack.h b/src/mesa/main/pack.h
index cd6d0aa..064305a 100644
--- a/src/mesa/main/pack.h
+++ b/src/mesa/main/pack.h
@@ -85,13 +85,6 @@ _mesa_unpack_image(GLuint dimensions,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack);
 
-
-extern void
-_mesa_rebase_rgba_float(GLuint n, GLfloat rgba[][4], GLenum baseFormat);
-
-extern void
-_mesa_rebase_rgba_uint(GLuint n, GLuint rgba[][4], GLenum baseFormat);
-
 extern void
 _mesa_pack_luminance_from_rgba_float(GLuint n, GLfloat rgba[][4],
  GLvoid *dstAddr, GLenum dst_format,
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 22/29] mesa: Remove _mesa_unpack_color_span_ubyte

2014-12-01 Thread Iago Toral Quiroga
This is no longer used anywhere after moving to _mesa_format_convert.
---
 src/mesa/main/pack.c | 256 ---
 src/mesa/main/pack.h |   9 --
 2 files changed, 265 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 1f6da70..a79dd04 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -1941,262 +1941,6 @@ clamp_half_to_uint(GLhalfARB h)
 }
 
 
-/*
- * Unpack a row of color image data from a client buffer according to
- * the pixel unpacking parameters.
- * 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
- * dstFormat - format of destination color array
- * dest - the destination color array
- * srcFormat - source image format
- * srcType - source image  data type
- * source - source image pointer
- * srcPacking - pixel unpacking parameters
- * transferOps - bitmask of IMAGE_*_BIT values of operations to apply
- *
- * XXX perhaps expand this to process whole images someday.
- */
-void
-_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,
-  GLbitfield transferOps )
-{
-   GLboolean intFormat = _mesa_is_enum_format_integer(srcFormat);
-   ASSERT(dstFormat == GL_ALPHA ||
-  dstFormat == GL_LUMINANCE ||
-  dstFormat == GL_LUMINANCE_ALPHA ||
-  dstFormat == GL_INTENSITY ||
-  dstFormat == GL_RED ||
-  dstFormat == GL_RG ||
-  dstFormat == GL_RGB ||
-  dstFormat == GL_RGBA);
-
-   ASSERT(srcFormat == GL_RED ||
-  srcFormat == GL_GREEN ||
-  srcFormat == GL_BLUE ||
-  srcFormat == GL_ALPHA ||
-  srcFormat == GL_LUMINANCE ||
-  srcFormat == GL_LUMINANCE_ALPHA ||
-  srcFormat == GL_INTENSITY ||
-  srcFormat == GL_RG ||
-  srcFormat == GL_RGB ||
-  srcFormat == GL_BGR ||
-  srcFormat == GL_RGBA ||
-  srcFormat == GL_BGRA ||
-  srcFormat == GL_ABGR_EXT ||
-  srcFormat == GL_COLOR_INDEX);
-
-   ASSERT(srcType == GL_BITMAP ||
-  srcType == GL_UNSIGNED_BYTE ||
-  srcType == GL_BYTE ||
-  srcType == GL_UNSIGNED_SHORT ||
-  srcType == GL_SHORT ||
-  srcType == GL_UNSIGNED_INT ||
-  srcType == GL_INT ||
-  srcType == GL_HALF_FLOAT_ARB ||
-  srcType == GL_FLOAT ||
-  srcType == GL_UNSIGNED_BYTE_3_3_2 ||
-  srcType == GL_UNSIGNED_BYTE_2_3_3_REV ||
-  srcType == GL_UNSIGNED_SHORT_5_6_5 ||
-  srcType == GL_UNSIGNED_SHORT_5_6_5_REV ||
-  srcType == GL_UNSIGNED_SHORT_4_4_4_4 ||
-  srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ||
-  srcType == GL_UNSIGNED_SHORT_5_5_5_1 ||
-  srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ||
-  srcType == GL_UNSIGNED_INT_8_8_8_8 ||
-  srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
-  srcType == GL_UNSIGNED_INT_10_10_10_2 ||
-  srcType == GL_UNSIGNED_INT_2_10_10_10_REV ||
-  srcType == GL_UNSIGNED_INT_5_9_9_9_REV ||
-  srcType == GL_UNSIGNED_INT_10F_11F_11F_REV);
-
-   /* EXT_texture_integer specifies no transfer ops on integer
-* types in the resolved issues section. Just set them to 0
-* for integer surfaces.
-*/
-   if (intFormat)
-  transferOps = 0;
-
-   /* Try simple cases first */
-   if (transferOps == 0) {
-  if (srcType == GL_UNSIGNED_BYTE) {
- if (dstFormat == GL_RGBA) {
-if (srcFormat == GL_RGBA) {
-   memcpy( dest, source, n * 4 * sizeof(GLubyte) );
-   return;
-}
-else if (srcFormat == GL_RGB) {
-   GLuint i;
-   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] = 255;
-  src += 3;
-  dst += 4;
-   }
-   return;
-}
- }
- else if (dstFormat == GL_RGB) {
-if (srcFormat == GL_RGB) {
-   memcpy( dest, source, n * 3 * sizeof(GLubyte) );
-   return;
-}
-else if (srcFormat == GL_RGBA) {
-   GLuint i;
-   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];
- 

[Mesa-dev] [PATCH v2 12/29] mesa: Use _mesa_format_convert to implement texstore_rgba.

2014-12-01 Thread Iago Toral Quiroga
Notice that _mesa_format_convert does not handle byte-swapping scenarios,
GL_COLOR_INDEX or MESA_FORMAT_YCBCR(_REV), so these must be handled
separately.

Also, remove all the code that goes unused after using _mesa_format_convert.
---
 src/mesa/main/texstore.c | 684 +--
 1 file changed, 71 insertions(+), 613 deletions(-)

diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index de9f4df..999a009 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -221,116 +221,6 @@ _mesa_make_temp_float_image(struct gl_context *ctx, 
GLuint dims,
 
 
 /**
- * Make temporary image with uint pixel values.  Used for unsigned
- * integer-valued textures.
- */
-static GLuint *
-make_temp_uint_image(struct gl_context *ctx, GLuint dims,
- GLenum logicalBaseFormat,
- GLenum textureBaseFormat,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking)
-{
-   GLuint *tempImage;
-   const GLint components = _mesa_components_in_format(logicalBaseFormat);
-   const GLint srcStride =
-  _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
-   GLuint *dst;
-   GLint img, row;
-
-   ASSERT(dims >= 1 && dims <= 3);
-
-   ASSERT(logicalBaseFormat == GL_RGBA ||
-  logicalBaseFormat == GL_RGB ||
-  logicalBaseFormat == GL_RG ||
-  logicalBaseFormat == GL_RED ||
-  logicalBaseFormat == GL_LUMINANCE_ALPHA ||
-  logicalBaseFormat == GL_LUMINANCE ||
-  logicalBaseFormat == GL_INTENSITY ||
-  logicalBaseFormat == GL_ALPHA);
-
-   ASSERT(textureBaseFormat == GL_RGBA ||
-  textureBaseFormat == GL_RGB ||
-  textureBaseFormat == GL_RG ||
-  textureBaseFormat == GL_RED ||
-  textureBaseFormat == GL_LUMINANCE_ALPHA ||
-  textureBaseFormat == GL_LUMINANCE ||
-  textureBaseFormat == GL_INTENSITY ||
-  textureBaseFormat == GL_ALPHA);
-
-   tempImage = malloc(srcWidth * srcHeight * srcDepth
- * components * sizeof(GLuint));
-   if (!tempImage)
-  return NULL;
-
-   dst = tempImage;
-   for (img = 0; img < srcDepth; img++) {
-  const GLubyte *src
-= (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
-srcWidth, srcHeight,
-srcFormat, srcType,
-img, 0, 0);
-  for (row = 0; row < srcHeight; row++) {
-_mesa_unpack_color_span_uint(ctx, srcWidth, logicalBaseFormat,
-  dst, srcFormat, srcType, src,
-  srcPacking);
-dst += srcWidth * components;
-src += srcStride;
-  }
-   }
-
-   if (logicalBaseFormat != textureBaseFormat) {
-  /* more work */
-  GLint texComponents = _mesa_components_in_format(textureBaseFormat);
-  GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
-  GLuint *newImage;
-  GLint i, n;
-  GLubyte map[6];
-
-  /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
-  ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA ||
- textureBaseFormat == GL_LUMINANCE_ALPHA);
-
-  /* The actual texture format should have at least as many components
-   * as the logical texture format.
-   */
-  ASSERT(texComponents >= logComponents);
-
-  newImage = malloc(srcWidth * srcHeight * srcDepth
-   * texComponents * sizeof(GLuint));
-  if (!newImage) {
- free(tempImage);
- return NULL;
-  }
-
-  _mesa_compute_component_mapping(logicalBaseFormat, textureBaseFormat, 
map);
-
-  n = srcWidth * srcHeight * srcDepth;
-  for (i = 0; i < n; i++) {
- GLint k;
- for (k = 0; k < texComponents; k++) {
-GLint j = map[k];
-if (j == ZERO)
-   newImage[i * texComponents + k] = 0;
-else if (j == ONE)
-   newImage[i * texComponents + k] = 1;
-else
-   newImage[i * texComponents + k] = tempImage[i * logComponents + 
j];
- }
-  }
-
-  free(tempImage);
-  tempImage = newImage;
-   }
-
-   return tempImage;
-}
-
-
-
-/**
  * Make a temporary (color) texture image with GLubyte components.
  * Apply all needed pixel unpacking and pixel transfer operations.
  * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
@@ -518,46 +408,6 @@ memcpy_texture(struct gl_context *ctx,
 
 
 /**
- * General-case function for storing a color texture images with
- * components that can be represented with ubytes.  Example destination
- * texture formats are MESA

[Mesa-dev] [PATCH v2 18/29] mesa: Replace _mesa_unpack_bitmap with _mesa_unpack_image()

2014-12-01 Thread Iago Toral Quiroga
From: Eduardo Lima Mitev 

_mesa_unpack_bitmap() was introduced by commit 02b801c to handle the case
when data is stored in PBO by display lists, in the context of this bug:

Incorrect pixels read back if draw bitmap texture through Display list
https://bugs.freedesktop.org/show_bug.cgi?id=10370

Since _mesa_unpack_image() already handles the case of GL_BITMAP, this patch
removes _mesa_unpack_bitmap() and makes affected calls go through
_mesa_unapck_image() instead.

The sample test attached to the original bug report passes with this change
and there are no piglit regressions.

Signed-off-by: Eduardo Lima Mitev 
---
 src/mesa/main/dlist.c |  14 ++-
 src/mesa/main/pack.c  | 105 +-
 src/mesa/main/pack.h  |   4 --
 3 files changed, 6 insertions(+), 117 deletions(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 4b7b060..4a5d819 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -957,11 +957,8 @@ unpack_image(struct gl_context *ctx, GLuint dimensions,
   /* no PBO */
   GLvoid *image;
 
-  if (type == GL_BITMAP)
- image = _mesa_unpack_bitmap(width, height, pixels, unpack);
-  else
- image = _mesa_unpack_image(dimensions, width, height, depth,
-format, type, pixels, unpack);
+  image = _mesa_unpack_image(dimensions, width, height, depth,
+ format, type, pixels, unpack);
   if (pixels && !image) {
  _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
   }
@@ -983,11 +980,8 @@ unpack_image(struct gl_context *ctx, GLuint dimensions,
   }
 
   src = ADD_POINTERS(map, pixels);
-  if (type == GL_BITMAP)
- image = _mesa_unpack_bitmap(width, height, src, unpack);
-  else
- image = _mesa_unpack_image(dimensions, width, height, depth,
-format, type, src, unpack);
+  image = _mesa_unpack_image(dimensions, width, height, depth,
+ format, type, src, unpack);
 
   ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
 
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 4a08f98..1a07a81 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -100,7 +100,8 @@ void
 _mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
   const struct gl_pixelstore_attrib *unpacking )
 {
-   GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap(32, 32, pattern, unpacking);
+   GLubyte *ptrn = (GLubyte *) _mesa_unpack_image(2, 32, 32, 1, GL_COLOR_INDEX,
+  GL_BITMAP, pattern, 
unpacking);
if (ptrn) {
   /* Convert pattern from GLubytes to GLuints and handle big/little
* endian differences
@@ -144,108 +145,6 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], 
GLubyte *dest,
 
 
 /*
- * Unpack bitmap data.  Resulting data will be in most-significant-bit-first
- * order with row alignment = 1 byte.
- */
-GLvoid *
-_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
- const struct gl_pixelstore_attrib *packing )
-{
-   GLint bytes, row, width_in_bytes;
-   GLubyte *buffer, *dst;
-
-   if (!pixels)
-  return NULL;
-
-   /* Alloc dest storage */
-   bytes = ((width + 7) / 8 * height);
-   buffer = malloc( bytes );
-   if (!buffer)
-  return NULL;
-
-   width_in_bytes = CEILING( width, 8 );
-   dst = buffer;
-   for (row = 0; row < height; row++) {
-  const GLubyte *src = (const GLubyte *)
- _mesa_image_address2d(packing, pixels, width, height,
-   GL_COLOR_INDEX, GL_BITMAP, row, 0);
-  if (!src) {
- free(buffer);
- return NULL;
-  }
-
-  if ((packing->SkipPixels & 7) == 0) {
- memcpy( dst, src, width_in_bytes );
- if (packing->LsbFirst) {
-flip_bytes( dst, width_in_bytes );
- }
-  }
-  else {
- /* handling SkipPixels is a bit tricky (no pun intended!) */
- GLint i;
- if (packing->LsbFirst) {
-GLubyte srcMask = 1 << (packing->SkipPixels & 0x7);
-GLubyte dstMask = 128;
-const GLubyte *s = src;
-GLubyte *d = dst;
-*d = 0;
-for (i = 0; i < width; i++) {
-   if (*s & srcMask) {
-  *d |= dstMask;
-   }
-   if (srcMask == 128) {
-  srcMask = 1;
-  s++;
-   }
-   else {
-  srcMask = srcMask << 1;
-   }
-   if (dstMask == 1) {
-  dstMask = 128;
-  d++;
-  *d = 0;
-   }
-   else {
-  dstMask = dstMask >> 1;
-   }
-}
- }
- else {
-GLubyte srcMask = 128 >> (packing->SkipPix

[Mesa-dev] [PATCH v2 15/29] mesa: Use _mesa_format_convert to implement get_tex_rgba_compressed.

2014-12-01 Thread Iago Toral Quiroga
---
 src/mesa/main/texgetimage.c | 73 +
 1 file changed, 34 insertions(+), 39 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 024fb4d..f17bb6f 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -242,13 +242,15 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint 
dimensions,
const mesa_format texFormat =
   _mesa_get_srgb_format_linear(texImage->TexFormat);
const GLenum baseFormat = _mesa_get_format_base_format(texFormat);
-   const GLenum destBaseFormat = _mesa_base_tex_format(ctx, format);
-   GLenum rebaseFormat = GL_NONE;
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
const GLuint depth = texImage->Depth;
-   GLfloat *tempImage, *tempSlice, *srcRow;
-   GLuint row, slice;
+   GLfloat *tempImage, *tempSlice;
+   GLuint slice;
+   int srcStride, dstStride;
+   uint32_t dstFormat;
+   bool needsRebase;
+   uint8_t rebaseSwizzle[4];
 
/* Decompress into temp float buffer, then pack into user buffer */
tempImage = malloc(width * height * depth
@@ -282,46 +284,39 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint 
dimensions,
   }
}
 
+   /* Depending on the base format involved we may need to apply a rebase
+* tranaform (for example: if we download to a Luminance format we want
+* G=0 and B=0).
+*/
if (baseFormat == GL_LUMINANCE ||
-   baseFormat == GL_INTENSITY ||
-   baseFormat == GL_LUMINANCE_ALPHA) {
-  /* If a luminance (or intensity) texture is read back as RGB(A), the
-   * returned value should be (L,0,0,1), not (L,L,L,1).  Set rebaseFormat
-   * here to get G=B=0.
-   */
-  rebaseFormat = texImage->_BaseFormat;
-   }
-   else if ((baseFormat == GL_RGBA ||
- baseFormat == GL_RGB  ||
- baseFormat == GL_RG) &&
-(destBaseFormat == GL_LUMINANCE ||
- destBaseFormat == GL_LUMINANCE_ALPHA ||
- destBaseFormat == GL_LUMINANCE_INTEGER_EXT ||
- destBaseFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT)) {
-  /* If we're reading back an RGB(A) texture as luminance then we need
-   * to return L=tex(R).  Note, that's different from glReadPixels which
-   * returns L=R+G+B.
-   */
-  rebaseFormat = GL_LUMINANCE_ALPHA; /* this covers GL_LUMINANCE too */
-   }
-
-   if (rebaseFormat) {
-  _mesa_rebase_rgba_float(width * height, (GLfloat (*)[4]) tempImage,
-  rebaseFormat);
+   baseFormat == GL_INTENSITY) {
+  needsRebase = true;
+  rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
+  rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
+  rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
+  rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_ONE;
+   } else if (baseFormat == GL_LUMINANCE_ALPHA) {
+  needsRebase = true;
+  rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
+  rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
+  rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
+  rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_W;
+   } else {
+  needsRebase = false;
}
 
+   srcStride = 4 * width * sizeof(GLfloat);
+   dstStride = _mesa_image_row_stride(&ctx->Pack, width, format, type);
+   dstFormat = _mesa_format_from_format_and_type(format, type);
tempSlice = tempImage;
for (slice = 0; slice < depth; slice++) {
-  srcRow = tempSlice;
-  for (row = 0; row < height; row++) {
- void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
-  width, height, format, type,
-  slice, row, 0);
-
- _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) srcRow,
-format, type, dest, &ctx->Pack, 
transferOps);
- srcRow += 4 * width;
-  }
+  void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+   width, height, format, type,
+   slice, 0, 0);
+  _mesa_format_convert(dest, dstFormat, dstStride,
+   tempSlice, RGBA_FLOAT.as_uint, srcStride,
+   width, height,
+   needsRebase ? rebaseSwizzle : NULL);
   tempSlice += 4 * width * height;
}
 
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 12/23] mesa: Add a _mesa_is_format_color_format helper

2014-12-01 Thread Iago Toral Quiroga
From: Jason Ekstrand 

---
 src/mesa/main/formats.c | 19 +++
 src/mesa/main/formats.h |  3 +++
 2 files changed, 22 insertions(+)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 05b6aea..8eb1838 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -462,6 +462,25 @@ _mesa_is_format_integer(mesa_format format)
return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT);
 }
 
+
+/**
+ * Return true if the given format is a color format.
+ */
+GLenum
+_mesa_is_format_color_format(mesa_format format)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   switch (info->BaseFormat) {
+   case GL_DEPTH_COMPONENT:
+   case GL_STENCIL_INDEX:
+   case GL_DEPTH_STENCIL:
+  return false;
+   default:
+  return true;
+   }
+}
+
+
 /**
  * Return color encoding for given format.
  * \return GL_LINEAR or GL_SRGB
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index cba12dc..072b486 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -552,6 +552,9 @@ _mesa_is_format_integer(mesa_format format);
 extern bool
 _mesa_is_format_etc2(mesa_format format);
 
+GLenum
+_mesa_is_format_color_format(mesa_format format);
+
 extern GLenum
 _mesa_get_format_color_encoding(mesa_format format);
 
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 07/29] mesa: Add helper to convert a GL format and type to a mesa (array) format.

2014-12-01 Thread Iago Toral Quiroga
v2 after review by Jason Ekstrand:
- Move _mesa_format_from_format_and_type to glformats
- Return a mesa_format for GL_UNSIGNED_INT_8_8_8_8(_REV)
---
 src/mesa/main/formats.c   |  18 +++-
 src/mesa/main/formats.h   |   7 ++
 src/mesa/main/glformats.c | 259 +-
 src/mesa/main/glformats.h |   2 +
 4 files changed, 281 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index d0e218c..87f6bf1 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -333,8 +333,8 @@ _mesa_get_format_swizzle(mesa_format format, uint8_t 
swizzle_out[4])
memcpy(swizzle_out, info->Swizzle, sizeof(info->Swizzle));
 }
 
-static mesa_array_format
-array_format_flip_channels(mesa_array_format format)
+mesa_array_format
+_mesa_array_format_flip_channels(mesa_array_format format)
 {
if (format.num_channels == 1)
   return format;
@@ -366,7 +366,7 @@ _mesa_format_to_array_format(mesa_format format)
if (_mesa_little_endian())
   return info->ArrayFormat.as_uint;
else
-  return array_format_flip_channels(info->ArrayFormat).as_uint;
+  return _mesa_array_format_flip_channels(info->ArrayFormat).as_uint;
 }
 
 mesa_format
@@ -378,7 +378,7 @@ _mesa_format_from_array_format(uint32_t array_format)
af.as_uint = array_format;
af.pad = 0;
if (!_mesa_little_endian())
-  af = array_format_flip_channels(af);
+  af = _mesa_array_format_flip_channels(af);
 
assert(af.array_format_bit);
for (f = 1; f < MESA_FORMAT_COUNT; ++f)
@@ -388,6 +388,16 @@ _mesa_format_from_array_format(uint32_t array_format)
return MESA_FORMAT_NONE;
 }
 
+void
+_mesa_array_format_set_swizzle(mesa_array_format *array_format,
+   int x, int y, int z, int w)
+{
+   array_format->swizzle_x = x;
+   array_format->swizzle_y = y;
+   array_format->swizzle_z = z;
+   array_format->swizzle_w = w;
+}
+
 /** Is the given format a compressed format? */
 GLboolean
 _mesa_is_format_compressed(mesa_format format)
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index e0e5804..944c410 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -537,9 +537,16 @@ _mesa_get_format_base_format(uint32_t format);
 extern void
 _mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh);
 
+extern mesa_array_format
+_mesa_array_format_flip_channels(mesa_array_format format);
+
 extern void
 _mesa_get_format_swizzle(mesa_format format, uint8_t swizzle_out[4]);
 
+extern void
+_mesa_array_format_set_swizzle(mesa_array_format *array_format,
+   int x, int y, int z, int w);
+
 extern uint32_t
 _mesa_format_to_array_format(mesa_format format);
 
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 00478f9..d3ea749 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -27,7 +27,7 @@
 
 #include "context.h"
 #include "glformats.h"
-
+#include "formats.h"
 
 /**
  * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise.
@@ -2207,3 +2207,260 @@ _mesa_es3_error_check_format_and_type(GLenum format, 
GLenum type,
 
return GL_NO_ERROR;
 }
+
+static bool
+_mesa_array_format_set_swizzle_from_format(mesa_array_format *array_format,
+   GLenum format)
+{
+   switch (format) {
+   case GL_RGBA:
+   case GL_RGBA_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 0, 1, 2, 3);
+  return true;
+   case GL_BGRA:
+   case GL_BGRA_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 2, 1, 0, 3);
+  return true;
+   case GL_ABGR_EXT:
+  _mesa_array_format_set_swizzle(array_format, 3, 2, 1, 0);
+  return true;
+   case GL_RGB:
+   case GL_RGB_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 0, 1, 2, 5);
+  return true;
+   case GL_BGR:
+   case GL_BGR_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 2, 1, 0, 5);
+  return true;
+   case GL_LUMINANCE_ALPHA:
+   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 0, 0, 0, 1);
+  return true;
+   case GL_RG:
+   case GL_RG_INTEGER:
+  _mesa_array_format_set_swizzle(array_format, 0, 1, 4, 5);
+  return true;
+   case GL_RED:
+   case GL_RED_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 0, 4, 4, 5);
+  return true;
+   case GL_GREEN:
+   case GL_GREEN_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 4, 0, 4, 5);
+  return true;
+   case GL_BLUE:
+   case GL_BLUE_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 4, 4, 0, 5);
+  return true;
+   case GL_ALPHA:
+   case GL_ALPHA_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 4, 4, 4, 0);
+  return true;
+   case GL_LUMINANCE:
+   case GL_LUMINANCE_INTEGER_EXT:
+  _mesa_array_format_set_swizzle(array_format, 0, 0, 0, 5);
+  return true;
+   case GL_INTENSITY:
+  _mesa_arra

[Mesa-dev] [PATCH v2 15/23] configure: require python mako module

2014-12-01 Thread Iago Toral Quiroga
From: Samuel Iglesias Gonsalvez 

It is now a hard dependency because of the autogeneration of
format pack and unpack functions.

Update the documentation to reflect this change.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 configure.ac  |  2 ++
 docs/install.html |  6 -
 m4/ax_check_python_mako_module.m4 | 56 +++
 src/mesa/main/python_mako.py  | 17 
 4 files changed, 80 insertions(+), 1 deletion(-)
 create mode 100644 m4/ax_check_python_mako_module.m4
 create mode 100644 src/mesa/main/python_mako.py

diff --git a/configure.ac b/configure.ac
index 1d9d015..f38acfd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,8 @@ if test "x$INDENT" != "xcat"; then
 AC_SUBST(INDENT_FLAGS, '-i4 -nut -br -brs -npcs -ce -TGLubyte -TGLbyte 
-TBool')
 fi
 
+AC_CHECK_PYTHON_MAKO_MODULE(0.7.3)
+
 AC_PROG_INSTALL
 
 dnl We need a POSIX shell for parts of the build. Assume we have one
diff --git a/docs/install.html b/docs/install.html
index f12425f..b12e1cb 100644
--- a/docs/install.html
+++ b/docs/install.html
@@ -38,6 +38,10 @@
 Version 2.6.4 or later should work.
 
 
+http://www.makotemplates.org/";>Python Mako module -
+Python Mako module is required. Version 0.7.3 or later should work.
+
+
 http://www.scons.org/";>SCons is required for building on
 Windows and optional for Linux (it's an alternative to autoconf/automake.)
 
@@ -78,7 +82,7 @@ the needed dependencies:
 
   sudo yum install flex bison imake libtool xorg-x11-proto-devel libdrm-devel \
   gcc-c++ xorg-x11-server-devel libXi-devel libXmu-devel libXdamage-devel git \
-  expat-devel llvm-devel
+  expat-devel llvm-devel python-mako
 
 
 
diff --git a/m4/ax_check_python_mako_module.m4 
b/m4/ax_check_python_mako_module.m4
new file mode 100644
index 000..5a66a80
--- /dev/null
+++ b/m4/ax_check_python_mako_module.m4
@@ -0,0 +1,56 @@
+# ===
+#
+# SYNOPSIS
+#
+#   AX_CHECK_PYTHON_MAKO_MODULE(MIN_VERSION_NUMBER)
+#
+# DESCRIPTION
+#
+#   Check whether Python mako module is installed and its version higher than
+#   minimum requested.
+#
+#   Example of its use:
+#
+#   For example, the minimum mako version would be 0.7.3. Then configure.ac
+#   would contain:
+#
+#   AC_CHECK_PYTHON_MAKO_MODULE(0.7.3)
+#
+# LICENSE
+#
+#   Copyright (c) 2014 Intel Corporation.
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see .
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+dnl macro that checks for mako module in python
+AC_DEFUN([AC_CHECK_PYTHON_MAKO_MODULE],
+[AC_MSG_CHECKING(for module mako in python)
+python $srcdir/src/mesa/main/python_mako.py $1
+if test $? -ne 0 ; then
+AC_MSG_ERROR(mako $1 or later is required.)
+fi
+])
diff --git a/src/mesa/main/python_mako.py b/src/mesa/main/python_mako.py
new file mode 100644
index 000..081abbc
--- /dev/null
+++ b/src/mesa/main/python_mako.py
@@ -0,0 +1,17 @@
+try:
+import sys
+import mako
+except ImportError as err:
+sys.exit(err)
+else:
+ver_min_req_str = str(sys.argv[1]);
+ver_min_req = ver_min_req_str.split('.');
+ver_str = mako.__version__
+ver = ver_str.split('.')
+
+for i in range(len(ver)):
+if int(ver[i]) < int(ver_min_req[i]):
+sys.exit(1);
+if int(ver[i]) > int(ver_min_req[i]):
+sys.exit(0);
+sys.exit(0);
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 01/29] mesa: Add an implementation of a master convert function.

2014-12-01 Thread Iago Toral Quiroga
From: Jason Ekstrand 

v2 by Iago Toral :

- When testing if we can directly pack we should use the src format to check
  if we are packing from an RGBA format. The original code used the dst format
  for the ubyte case by mistake.
- Fixed incorrect number of bits for dst, it was computed using the src format
  instead of the dst format.
- If the dst format is an array format, check if it is signed. We were only
  checking this for the case where it was not an array format, but we need
  to know this in both scenarios.
- Fixed incorrect swizzle transform for the cases where we convert between
  array formats.
- Compute is_signed and bits only once and for the dst format. We were
  computing these for the src format too but they were overwritten by the
  dst values immediately after.
- Be more careful when selecting the integer path. Specifically, check that
  both src and dst are integer types. Checking only one of them should suffice
  since OpenGL does not allow conversions between normalized and integer types,
  but putting extra care here makes sense and also makes the actual requirements
  for this path more clear.
- The format argument for pack functions is the destination format we are
  packing to, not the source format (which has to be RGBA).
- Expose RGBA_* to other files. These will come in handy when in need to
  test if a given array format is RGBA or in need to pass RGBA formats to
  mesa_format_convert.

v3 by Samuel Iglesias :

- Add an RGBA_INT definition.

v4 by Iago Toral  after review by Jason Ekstrand:

- Added documentation for _mesa_format_convert.
- Added additional explanatory comments for integer conversions.
- Ensure that we use _messa_swizzle_and_convert for all signed source formats.
- Squashed: do not directly (un)pack to RGBA UINT if the source is not unsigned.
---
 src/mesa/main/format_utils.c | 425 +++
 src/mesa/main/format_utils.h |  10 +
 2 files changed, 435 insertions(+)

diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
index dc63e1f..4db5269 100644
--- a/src/mesa/main/format_utils.c
+++ b/src/mesa/main/format_utils.c
@@ -24,6 +24,431 @@
 
 #include "format_utils.h"
 #include "glformats.h"
+#include "format_pack.h"
+#include "format_unpack.h"
+
+mesa_array_format RGBA_FLOAT = {{
+   MESA_ARRAY_FORMAT_TYPE_FLOAT,
+   0,
+   4,
+   0, 1, 2, 3,
+   0, 1
+}};
+
+mesa_array_format RGBA_UBYTE = {{
+   MESA_ARRAY_FORMAT_TYPE_UBYTE,
+   1,
+   4,
+   0, 1, 2, 3,
+   0, 1
+}};
+
+mesa_array_format RGBA_UINT = {{
+   MESA_ARRAY_FORMAT_TYPE_UINT,
+   0,
+   4,
+   0, 1, 2, 3,
+   0, 1
+}};
+
+mesa_array_format RGBA_INT = {{
+   MESA_ARRAY_FORMAT_TYPE_INT,
+   0,
+   4,
+   0, 1, 2, 3,
+   0, 1
+}};
+
+static void
+invert_swizzle(uint8_t dst[4], const uint8_t src[4])
+{
+   int i, j;
+
+   dst[0] = MESA_FORMAT_SWIZZLE_NONE;
+   dst[1] = MESA_FORMAT_SWIZZLE_NONE;
+   dst[2] = MESA_FORMAT_SWIZZLE_NONE;
+   dst[3] = MESA_FORMAT_SWIZZLE_NONE;
+
+   for (i = 0; i < 4; ++i)
+  for (j = 0; j < 4; ++j)
+ if (src[j] == i && dst[i] == MESA_FORMAT_SWIZZLE_NONE)
+dst[i] = j;
+}
+
+static GLenum
+gl_type_for_array_format_datatype(enum mesa_array_format_datatype type)
+{
+   switch (type) {
+   case MESA_ARRAY_FORMAT_TYPE_UBYTE:
+  return GL_UNSIGNED_BYTE;
+   case MESA_ARRAY_FORMAT_TYPE_USHORT:
+  return GL_UNSIGNED_SHORT;
+   case MESA_ARRAY_FORMAT_TYPE_UINT:
+  return GL_UNSIGNED_INT;
+   case MESA_ARRAY_FORMAT_TYPE_BYTE:
+  return GL_BYTE;
+   case MESA_ARRAY_FORMAT_TYPE_SHORT:
+  return GL_SHORT;
+   case MESA_ARRAY_FORMAT_TYPE_INT:
+  return GL_INT;
+   case MESA_ARRAY_FORMAT_TYPE_HALF:
+  return GL_HALF_FLOAT;
+   case MESA_ARRAY_FORMAT_TYPE_FLOAT:
+  return GL_FLOAT;
+   default:
+  assert(!"Invalid datatype");
+  return GL_NONE;
+   }
+}
+
+/**
+ * This can be used to convert between most color formats.
+ *
+ * Limitations:
+ * - This function doesn't handle GL_COLOR_INDEX or YCBCR formats.
+ * - This function doesn't handle byte-swapping or transferOps, these should
+ *   be handled by the caller.
+ *
+ * \param void_dst  The address where converted color data will be stored.
+ *  The caller must ensure that the buffer is large enough
+ *  to hold the converted pixel data.
+ * \param dst_format  The destination color format. It can be a mesa_format
+ *or a mesa_array_format represented as an uint32_t.
+ * \param dst_stride  The stride of the destination format in bytes.
+ * \param void_src  The address of the source color data to convert.
+ * \param src_format  The source color format. It can be a mesa_format
+ *or a mesa_array_format represented as an uint32_t.
+ * \param src_stride  The stride of the source format in bytes.
+ * \param width  The width, in pixels, of the source image to convert.
+ * \param height  The height, in pixels, of the source image to conve

[Mesa-dev] [PATCH v2 23/23] mesa/pack: refactor _mesa_pack_rgba_span_float()

2014-12-01 Thread Iago Toral Quiroga
From: Samuel Iglesias Gonsalvez 

Use autogenerated format pack functions and take advantage of some
macros to reduce source code, facilitating its maintenance.

Unfortunately, dstType == GL_UNSIGNED_SHORT cannot simplified like
the others, so keep it as it is.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/mesa/main/pack.c | 1318 ++
 src/mesa/main/pack_tmp.h |1 +
 2 files changed, 153 insertions(+), 1166 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 067a0f5..06993d4 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -531,22 +531,22 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, 
GLuint n, GLuint rgba[][
 {
switch(dstType) {
case GL_UNSIGNED_INT:
-  pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_INT:
-  pack_int_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_int_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_UNSIGNED_SHORT:
-  pack_ushort_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_ushort_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_SHORT:
-  pack_short_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_short_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_UNSIGNED_BYTE:
-  pack_ubyte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_ubyte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_BYTE:
-  pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_UNSIGNED_BYTE_3_3_2:
   if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER))
@@ -722,23 +722,23 @@ _mesa_pack_rgba_span_from_ints(struct gl_context *ctx, 
GLuint n, GLint rgba[][4]
 {
switch(dstType) {
case GL_UNSIGNED_INT:
-  pack_uint_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_uint_from_int_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_INT:
   /* No conversion necessary. */
-  pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, (GLuint (*)[4]) rgba, 
n);
+  pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, (GLuint (*)[4]) rgba, 
NULL, n);
   break;
case GL_UNSIGNED_SHORT:
-  pack_ushort_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_ushort_from_int_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_SHORT:
-  pack_short_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_short_from_int_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_UNSIGNED_BYTE:
-  pack_ubyte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_ubyte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_BYTE:
-  pack_byte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+  pack_byte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, NULL, n);
   break;
case GL_UNSIGNED_BYTE_3_3_2:
   if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER))
@@ -850,6 +850,80 @@ _mesa_pack_rgba_span_from_ints(struct gl_context *ctx, 
GLuint n, GLint rgba[][4]
}
 }
 
+/* Customization of float packing.
+ */
+#define SRC_TYPE GLfloat
+
+#define DST_TYPE GLuint
+#define FLOAT_SRC_CONVERT(x) FLOAT_TO_UINT(x)
+#define SRC_CONVERT(x) (GLuint) x
+#define FN_NAME pack_uint_from_float_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FLOAT_SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLint
+#define FLOAT_SRC_CONVERT(x) FLOAT_TO_INT(x)
+#define SRC_CONVERT(x) (GLint) x
+#define FN_NAME pack_int_from_float_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FLOAT_SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLshort
+#define FLOAT_SRC_CONVERT(x) FLOAT_TO_SHORT_TEX(x)
+#define SRC_CONVERT(x) (GLshort) x
+#define FN_NAME pack_short_from_float_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FLOAT_SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLubyte
+#define FLOAT_SRC_CONVERT(x) FLOAT_TO_UBYTE(x)
+#define SRC_CONVERT(x) (GLubyte) x
+#define FN_NAME pack_ubyte_from_float_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FLOAT_SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLbyte
+#define FLOAT_SRC_CONVERT(x) FLOAT_TO_BYTE_TEX(x)
+#define SRC_CONVERT(x) (GLbyte) x
+#define FN_NAME pack_byte_from_float_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FLOAT_SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLfloat
+#define FLOAT_SRC_CONVERT(x) x
+#define SRC_CONVERT(x) x
+#define FN_NAME pack_float_from_float_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FLOAT_SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLhalfARB
+

[Mesa-dev] [PATCH v2 03/29] mesa: Expose compute_component_mapping as _mesa_compute_component_mapping

2014-12-01 Thread Iago Toral Quiroga
This is necessary to handle conversions between array types where
the driver does not support the dst format requested by the client and
chooses a different format instead.

We will need this in _mesa_format_convert, so move it to format_utils.c,
prefix it with '_mesa_' and make it available to other files.
---
 src/mesa/main/format_utils.c | 198 +++
 src/mesa/main/format_utils.h |   3 +
 src/mesa/main/texstore.c | 216 ++-
 3 files changed, 210 insertions(+), 207 deletions(-)

diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
index 5139511..4f28e96 100644
--- a/src/mesa/main/format_utils.c
+++ b/src/mesa/main/format_utils.c
@@ -26,6 +26,7 @@
 #include "glformats.h"
 #include "format_pack.h"
 #include "format_unpack.h"
+#include "enums.h"
 
 mesa_array_format RGBA_FLOAT = {{
MESA_ARRAY_FORMAT_TYPE_FLOAT,
@@ -101,6 +102,203 @@ gl_type_for_array_format_datatype(enum 
mesa_array_format_datatype type)
}
 }
 
+enum {
+   ZERO = 4,
+   ONE = 5
+};
+
+enum {
+   IDX_LUMINANCE = 0,
+   IDX_ALPHA,
+   IDX_INTENSITY,
+   IDX_LUMINANCE_ALPHA,
+   IDX_RGB,
+   IDX_RGBA,
+   IDX_RED,
+   IDX_GREEN,
+   IDX_BLUE,
+   IDX_BGR,
+   IDX_BGRA,
+   IDX_ABGR,
+   IDX_RG,
+   MAX_IDX
+};
+
+#define MAP1(x)   MAP4(x, ZERO, ZERO, ZERO)
+#define MAP2(x,y) MAP4(x, y, ZERO, ZERO)
+#define MAP3(x,y,z)   MAP4(x, y, z, ZERO)
+#define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE }
+
+static const struct {
+   GLubyte format_idx;
+   GLubyte to_rgba[6];
+   GLubyte from_rgba[6];
+} mappings[MAX_IDX] =
+{
+   {
+  IDX_LUMINANCE,
+  MAP4(0,0,0,ONE),
+  MAP1(0)
+   },
+
+   {
+  IDX_ALPHA,
+  MAP4(ZERO, ZERO, ZERO, 0),
+  MAP1(3)
+   },
+
+   {
+  IDX_INTENSITY,
+  MAP4(0, 0, 0, 0),
+  MAP1(0),
+   },
+
+   {
+  IDX_LUMINANCE_ALPHA,
+  MAP4(0,0,0,1),
+  MAP2(0,3)
+   },
+
+   {
+  IDX_RGB,
+  MAP4(0,1,2,ONE),
+  MAP3(0,1,2)
+   },
+
+   {
+  IDX_RGBA,
+  MAP4(0,1,2,3),
+  MAP4(0,1,2,3),
+   },
+
+   {
+  IDX_RED,
+  MAP4(0, ZERO, ZERO, ONE),
+  MAP1(0),
+   },
+
+   {
+  IDX_GREEN,
+  MAP4(ZERO, 0, ZERO, ONE),
+  MAP1(1),
+   },
+
+   {
+  IDX_BLUE,
+  MAP4(ZERO, ZERO, 0, ONE),
+  MAP1(2),
+   },
+
+   {
+  IDX_BGR,
+  MAP4(2,1,0,ONE),
+  MAP3(2,1,0)
+   },
+
+   {
+  IDX_BGRA,
+  MAP4(2,1,0,3),
+  MAP4(2,1,0,3)
+   },
+
+   {
+  IDX_ABGR,
+  MAP4(3,2,1,0),
+  MAP4(3,2,1,0)
+   },
+
+   {
+  IDX_RG,
+  MAP4(0, 1, ZERO, ONE),
+  MAP2(0, 1)
+   },
+};
+
+/**
+ * Convert a GL image format enum to an IDX_* value (see above).
+ */
+static int
+get_map_idx(GLenum value)
+{
+   switch (value) {
+   case GL_LUMINANCE:
+   case GL_LUMINANCE_INTEGER_EXT:
+  return IDX_LUMINANCE;
+   case GL_ALPHA:
+   case GL_ALPHA_INTEGER:
+  return IDX_ALPHA;
+   case GL_INTENSITY:
+  return IDX_INTENSITY;
+   case GL_LUMINANCE_ALPHA:
+   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+  return IDX_LUMINANCE_ALPHA;
+   case GL_RGB:
+   case GL_RGB_INTEGER:
+  return IDX_RGB;
+   case GL_RGBA:
+   case GL_RGBA_INTEGER:
+  return IDX_RGBA;
+   case GL_RED:
+   case GL_RED_INTEGER:
+  return IDX_RED;
+   case GL_GREEN:
+  return IDX_GREEN;
+   case GL_BLUE:
+  return IDX_BLUE;
+   case GL_BGR:
+   case GL_BGR_INTEGER:
+  return IDX_BGR;
+   case GL_BGRA:
+   case GL_BGRA_INTEGER:
+  return IDX_BGRA;
+   case GL_ABGR_EXT:
+  return IDX_ABGR;
+   case GL_RG:
+   case GL_RG_INTEGER:
+  return IDX_RG;
+   default:
+  _mesa_problem(NULL, "Unexpected inFormat %s",
+_mesa_lookup_enum_by_nr(value));
+  return 0;
+   }
+}
+
+/**
+ * When promoting texture formats (see below) we need to compute the
+ * mapping of dest components back to source components.
+ * This function does that.
+ * \param inFormat  the incoming format of the texture
+ * \param outFormat  the final texture format
+ * \return map[6]  a full 6-component map
+ */
+void
+_mesa_compute_component_mapping(GLenum inFormat, GLenum outFormat, GLubyte 
*map)
+{
+   const int inFmt = get_map_idx(inFormat);
+   const int outFmt = get_map_idx(outFormat);
+   const GLubyte *in2rgba = mappings[inFmt].to_rgba;
+   const GLubyte *rgba2out = mappings[outFmt].from_rgba;
+   int i;
+
+   for (i = 0; i < 4; i++)
+  map[i] = in2rgba[rgba2out[i]];
+
+   map[ZERO] = ZERO;
+   map[ONE] = ONE;
+
+#if 0
+   printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n",
+ inFormat, _mesa_lookup_enum_by_nr(inFormat),
+ outFormat, _mesa_lookup_enum_by_nr(outFormat),
+ map[0],
+ map[1],
+ map[2],
+ map[3],
+ map[4],
+ map[5]);
+#endif
+}
+
 /**
  * This can be used to convert between most color formats.
  *
diff --git a/src/mesa/main/format_utils.h b/src/mesa/main/format_utils.h
index e41f6c7..aa15d7d 100644
--- a/src/mesa/main/format_utils.h
+

[Mesa-dev] [PATCH v2 20/29] mesa: Remove _mesa_make_temp_ubyte_image

2014-12-01 Thread Iago Toral Quiroga
Now that we have _mesa_format_convert we don't need this.

texstore_rgba will use the GL_COLOR_INDEX to RGBA conversion
helpers instead and compressed formats that used
_mesa_make_temp_ubyte_image to create an ubyte RGBA temporary
image can call _mesa_texstore with a RGBA/ubyte dst to
achieve the same goal.
---
 src/mesa/main/texcompress_bptc.c |  19 +++---
 src/mesa/main/texcompress_fxt1.c |  34 ++
 src/mesa/main/texcompress_rgtc.c |  45 +
 src/mesa/main/texcompress_s3tc.c |  68 ---
 src/mesa/main/texstore.c | 141 ++-
 src/mesa/main/texstore.h |   9 ---
 6 files changed, 114 insertions(+), 202 deletions(-)

diff --git a/src/mesa/main/texcompress_bptc.c b/src/mesa/main/texcompress_bptc.c
index 9204f12..3225d96 100644
--- a/src/mesa/main/texcompress_bptc.c
+++ b/src/mesa/main/texcompress_bptc.c
@@ -1276,7 +1276,6 @@ _mesa_texstore_bptc_rgba_unorm(TEXSTORE_PARAMS)
 {
const GLubyte *pixels;
const GLubyte *tempImage = NULL;
-   GLenum baseFormat;
int rowstride;
 
if (srcFormat != GL_RGBA ||
@@ -1284,15 +1283,19 @@ _mesa_texstore_bptc_rgba_unorm(TEXSTORE_PARAMS)
ctx->_ImageTransferState ||
srcPacking->SwapBytes) {
   /* convert image to RGBA/ubyte */
-  baseFormat = _mesa_get_format_base_format(dstFormat);
-  tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
-  baseInternalFormat,
-  baseFormat,
-  srcWidth, srcHeight, srcDepth,
-  srcFormat, srcType, srcAddr,
-  srcPacking);
+  GLubyte *tempImageSlices[1];
+  int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
+  tempImage = malloc(srcWidth * srcHeight * 4 * sizeof(GLubyte));
   if (!tempImage)
  return GL_FALSE; /* out of memory */
+  tempImageSlices[0] = (GLubyte *) tempImage;
+  _mesa_texstore(ctx, dims,
+ baseInternalFormat,
+ MESA_FORMAT_R8G8B8A8_UNORM,
+ rgbaRowStride, tempImageSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
 
   pixels = tempImage;
   rowstride = srcWidth * 4;
diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c
index 61b01c6..7b25e10 100644
--- a/src/mesa/main/texcompress_fxt1.c
+++ b/src/mesa/main/texcompress_fxt1.c
@@ -69,14 +69,19 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
srcPacking->RowLength != srcWidth ||
srcPacking->SwapBytes) {
   /* convert image to RGB/GLubyte */
-  tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- 
_mesa_get_format_base_format(dstFormat),
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
+  GLubyte *tempImageSlices[1];
+  int rgbRowStride = 3 * srcWidth * sizeof(GLubyte);
+  tempImage = malloc(srcWidth * srcHeight * 3 * sizeof(GLubyte));
   if (!tempImage)
  return GL_FALSE; /* out of memory */
+  tempImageSlices[0] = (GLubyte *) tempImage;
+  _mesa_texstore(ctx, dims,
+ baseInternalFormat,
+ MESA_FORMAT_RGB_UNORM8,
+ rgbRowStride, tempImageSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
   pixels = tempImage;
   srcRowStride = 3 * srcWidth;
   srcFormat = GL_RGB;
@@ -118,14 +123,19 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
ctx->_ImageTransferState ||
srcPacking->SwapBytes) {
   /* convert image to RGBA/GLubyte */
-  tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- 
_mesa_get_format_base_format(dstFormat),
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
+  GLubyte *tempImageSlices[1];
+  int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
+  tempImage = malloc(srcWidth * srcHeight * 4 * sizeof(GLubyte));
   if (!tempImage)
  return GL_FALSE; /* out of memory */
+  tempImageSlices[0] = (GLubyte *) tempImage;
+  _mesa_texstore(ctx, dims,
+ baseInternalFormat,
+ MESA_FORMAT_R8G8B8A8_UNORM,
+ rgbaRowStride, tempImageSlices,
+ srcWidth, srcHei

[Mesa-dev] [PATCH v2 05/29] mesa: Add a helper _mesa_compute_rgba2base2rgba_component_mapping

2014-12-01 Thread Iago Toral Quiroga
This will come in handy when callers of _mesa_format_convert need
to compute the rebase swizzle parameter to use.
---
 src/mesa/main/format_utils.c | 55 
 src/mesa/main/format_utils.h |  3 +++
 2 files changed, 58 insertions(+)

diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
index 86a5985..8b435f4 100644
--- a/src/mesa/main/format_utils.c
+++ b/src/mesa/main/format_utils.c
@@ -369,6 +369,61 @@ compute_src2dst_component_mapping(uint8_t *src2rgba, 
uint8_t *rgba2dst,
 }
 
 /**
+ * This function is used by clients of _mesa_format_convert to obtain
+ * the rebase swizzle to use in a format conversion based on the base
+ * format involved.
+ *
+ * \param baseFormat  the base internal format involved in the conversion.
+ * \param map  the rebase swizzle to consider
+ *
+ * This function computes 'map' as rgba -> baseformat -> rgba and returns true
+ * if the resulting swizzle transform is not the identity transform (thus, a
+ * rebase is needed). If the function returns false then a rebase swizzle
+ * is not necessary and the value of 'map' is undefined. In this situation
+ * clients of _mesa_format_convert should pass NULL in the 'rebase_swizzle'
+ * parameter.
+ */
+bool
+_mesa_compute_rgba2base2rgba_component_mapping(GLenum baseFormat, uint8_t *map)
+{
+   uint8_t rgba2base[6], base2rgba[6];
+   int i;
+
+   switch (baseFormat) {
+   case GL_ALPHA:
+   case GL_RED:
+   case GL_GREEN:
+   case GL_BLUE:
+   case GL_RG:
+   case GL_RGB:
+   case GL_BGR:
+   case GL_RGBA:
+   case GL_BGRA:
+   case GL_ABGR_EXT:
+   case GL_LUMINANCE:
+   case GL_INTENSITY:
+   case GL_LUMINANCE_ALPHA:
+  {
+ bool needRebase = false;
+ _mesa_compute_component_mapping(GL_RGBA, baseFormat, rgba2base);
+ _mesa_compute_component_mapping(baseFormat, GL_RGBA, base2rgba);
+ for (i = 0; i < 4; i++) {
+if (base2rgba[i] > MESA_FORMAT_SWIZZLE_W) {
+   map[i] = base2rgba[i];
+} else {
+   map[i] = rgba2base[base2rgba[i]];
+}
+if (map[i] != i)
+   needRebase = true;
+ }
+ return needRebase;
+  }
+   default:
+  assert(!"Unexpected base format");
+   }
+}
+
+/**
  * This can be used to convert between most color formats.
  *
  * Limitations:
diff --git a/src/mesa/main/format_utils.h b/src/mesa/main/format_utils.h
index a7bd491..1d3a192 100644
--- a/src/mesa/main/format_utils.h
+++ b/src/mesa/main/format_utils.h
@@ -180,6 +180,9 @@ _mesa_swizzle_and_convert(void *dst, GLenum dst_type, int 
num_dst_channels,
 void
 _mesa_compute_component_mapping(GLenum inFormat, GLenum outFormat, GLubyte 
*map);
 
+bool
+_mesa_compute_rgba2base2rgba_component_mapping(GLenum baseFormat, uint8_t 
*map);
+
 void
 _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,
  void *void_src, uint32_t src_format, size_t src_stride,
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 04/29] mesa: Add a rebase_swizzle parameter to _mesa_format_convert

2014-12-01 Thread Iago Toral Quiroga
The new parameter allows callers to provide a rebase swizzle that
the function needs to use to match the requirements of the base
internal format involved. This is necessary when the source or
destination internal formats (depending on whether we are doing
the conversion for a pixel download or a pixel upload respectively)
do not match the base formats of the source or destination
formats of the conversion. This can happen when the driver does not
support the internal formats and uses a different format to store
pixel data internally.

For example, a texture upload from RGB to Luminance in a driver
that does not support textures with a Luminance format may decide
to store the Luminance data as RGBA. In this case we want to store
the RGBA values as (R,R,R,1). Following the same example, when we
download from that texture to RGBA we want to read (R,0,0,1). The
rebase_swizzle parameter allows these transforms to happen.
---
 src/mesa/main/format_utils.c | 241 ++-
 src/mesa/main/format_utils.h |   2 +-
 2 files changed, 171 insertions(+), 72 deletions(-)

diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
index 4f28e96..86a5985 100644
--- a/src/mesa/main/format_utils.c
+++ b/src/mesa/main/format_utils.c
@@ -299,6 +299,75 @@ _mesa_compute_component_mapping(GLenum inFormat, GLenum 
outFormat, GLubyte *map)
 #endif
 }
 
+/* Takes a src to RGBA swizzle and applies a rebase swizzle to it. This
+ * is used when we need to rebase a format to match a different
+ * base internal format.
+ *
+ * The rebase swizzle can be NULL, which means that no rebase is necessary,
+ * in which case the src to RGBA swizzle is copied to the output without
+ * changes.
+ *
+ * The resulting rebased swizzle and well as the input swizzles are
+ * all 4-element swizzles, but the rebase swizzle can be NULL if no rebase
+ * is necessary.
+ */
+static void
+compute_rebased_rgba_component_mapping(uint8_t *src2rgba,
+   uint8_t *rebase_swizzle,
+   uint8_t *rebased_src2rgba)
+{
+   int i;
+
+   if (rebase_swizzle) {
+  for (i = 0; i < 4; i++) {
+ if (rebase_swizzle[i] > MESA_FORMAT_SWIZZLE_W)
+rebased_src2rgba[i] = rebase_swizzle[i];
+ else
+rebased_src2rgba[i] = src2rgba[rebase_swizzle[i]];
+  }
+   } else {
+  /* No rebase needed, so src2rgba is all that we need */
+  memcpy(rebased_src2rgba, src2rgba, 4 * sizeof(uint8_t));
+   }
+}
+
+/* Computes the final swizzle transform to apply from src to dst in a
+ * conversion that might involve a rebase swizzle.
+ *
+ * This is used to compute the swizzle transform to apply in conversions
+ * between array formats where we have a src2rgba swizzle, a rgba2dst swizzle
+ * and possibly, a rebase swizzle.
+ *
+ * The final swizzle transform to apply (src2dst) when a rebase swizzle is
+ * involved is: src -> rgba -> base -> rgba -> dst
+ */
+static void
+compute_src2dst_component_mapping(uint8_t *src2rgba, uint8_t *rgba2dst,
+  uint8_t *rebase_swizzle, uint8_t *src2dst)
+{
+   int i;
+
+   if (!rebase_swizzle) {
+  for (i = 0; i < 4; i++) {
+ if (rgba2dst[i] > MESA_FORMAT_SWIZZLE_W) {
+src2dst[i] = rgba2dst[i];
+ } else {
+src2dst[i] = src2rgba[rgba2dst[i]];
+ }
+  }
+   } else {
+  for (i = 0; i < 4; i++) {
+ if (rgba2dst[i] > MESA_FORMAT_SWIZZLE_W) {
+src2dst[i] = rgba2dst[i];
+ } else if (rebase_swizzle[rgba2dst[i]] > MESA_FORMAT_SWIZZLE_W) {
+src2dst[i] = rebase_swizzle[rgba2dst[i]];
+ } else {
+src2dst[i] = src2rgba[rebase_swizzle[rgba2dst[i]]];
+ }
+  }
+   }
+}
+
 /**
  * This can be used to convert between most color formats.
  *
@@ -319,22 +388,29 @@ _mesa_compute_component_mapping(GLenum inFormat, GLenum 
outFormat, GLubyte *map)
  * \param src_stride  The stride of the source format in bytes.
  * \param width  The width, in pixels, of the source image to convert.
  * \param height  The height, in pixels, of the source image to convert.
+ * \param rebase_swizzle  A swizzle transform to apply during the conversion,
+ *typically used to match a different internal base
+ *format involved. NULL if no rebase transform is 
needed
+ *(i.e. the internal base format and the base format of
+ *the dst or the src -depending on whether we are doing
+ *an upload or a download respectively- are the same).
  */
 void
 _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,
  void *void_src, uint32_t src_format, size_t src_stride,
- size_t width, size_t height)
+ size_t width, size_t height, uint8_t *rebase_swizzle)
 {
uint8_t *dst = (uint8_t *)void_dst;
uint

[Mesa-dev] [PATCH v2 14/29] mesa: use _mesa_format_convert to implement get_tex_rgba_uncompressed.

2014-12-01 Thread Iago Toral Quiroga
---
 src/mesa/main/texgetimage.c | 250 +++-
 1 file changed, 133 insertions(+), 117 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index cb5f793..024fb4d 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -45,7 +45,8 @@
 #include "texgetimage.h"
 #include "teximage.h"
 #include "texstore.h"
-
+#include "format_utils.h"
+#include "pixeltransfer.h"
 
 
 /**
@@ -376,145 +377,160 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, 
GLuint dimensions,
const mesa_format texFormat =
   _mesa_get_srgb_format_linear(texImage->TexFormat);
const GLuint width = texImage->Width;
-   GLenum destBaseFormat = _mesa_base_pack_format(format);
-   GLenum rebaseFormat = GL_NONE;
GLuint height = texImage->Height;
GLuint depth = texImage->Depth;
-   GLuint img, row;
-   GLfloat (*rgba)[4];
-   GLuint (*rgba_uint)[4];
-   GLboolean tex_is_integer = 
_mesa_is_format_integer_color(texImage->TexFormat);
-   GLboolean tex_is_uint = _mesa_is_format_unsigned(texImage->TexFormat);
-   GLenum texBaseFormat = _mesa_get_format_base_format(texImage->TexFormat);
-
-   /* Allocate buffer for one row of texels */
-   rgba = malloc(4 * width * sizeof(GLfloat));
-   rgba_uint = (GLuint (*)[4]) rgba;
-   if (!rgba) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()");
-  return;
-   }
+   GLuint img;
+   GLboolean dst_is_integer = _mesa_is_enum_format_integer(format);
+   uint32_t dst_format;
+   int dst_stride;
+   uint8_t rebaseSwizzle[4];
+   bool needsRebase;
+   void *rgba = NULL;
 
if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
   depth = height;
   height = 1;
}
 
+   /* Depending on the base format involved we may need to apply a rebase
+* tranaform (for example: if we download to a Luminance format we want
+* G=0 and B=0).
+*/
if (texImage->_BaseFormat == GL_LUMINANCE ||
-   texImage->_BaseFormat == GL_INTENSITY ||
-   texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
-  /* If a luminance (or intensity) texture is read back as RGB(A), the
-   * returned value should be (L,0,0,1), not (L,L,L,1).  Set rebaseFormat
-   * here to get G=B=0.
-   */
-  rebaseFormat = texImage->_BaseFormat;
-   }
-   else if ((texImage->_BaseFormat == GL_RGBA ||
- texImage->_BaseFormat == GL_RGB ||
- texImage->_BaseFormat == GL_RG) &&
-(destBaseFormat == GL_LUMINANCE ||
- destBaseFormat == GL_LUMINANCE_ALPHA ||
- destBaseFormat == GL_LUMINANCE_INTEGER_EXT ||
- destBaseFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT)) {
-  /* If we're reading back an RGB(A) texture as luminance then we need
-   * to return L=tex(R).  Note, that's different from glReadPixels which
-   * returns L=R+G+B.
-   */
-  rebaseFormat = GL_LUMINANCE_ALPHA; /* this covers GL_LUMINANCE too */
-   }
-   else if (texImage->_BaseFormat != texBaseFormat) {
-  /* The internal format and the real format differ, so we can't rely
-   * on the unpack functions setting the correct constant values.
-   * (e.g. reading back GL_RGB8 which is actually RGBA won't set alpha=1)
-   */
-  switch (texImage->_BaseFormat) {
-  case GL_RED:
- if ((texBaseFormat == GL_RGBA ||
-  texBaseFormat == GL_RGB ||
-  texBaseFormat == GL_RG) &&
- (destBaseFormat == GL_RGBA ||
-  destBaseFormat == GL_RGB ||
-  destBaseFormat == GL_RG ||
-  destBaseFormat == GL_GREEN)) {
-rebaseFormat = texImage->_BaseFormat;
-break;
- }
- /* fall through */
-  case GL_RG:
- if ((texBaseFormat == GL_RGBA ||
-  texBaseFormat == GL_RGB) &&
- (destBaseFormat == GL_RGBA ||
-  destBaseFormat == GL_RGB ||
-  destBaseFormat == GL_BLUE)) {
-rebaseFormat = texImage->_BaseFormat;
-break;
- }
- /* fall through */
-  case GL_RGB:
- if (texBaseFormat == GL_RGBA &&
- (destBaseFormat == GL_RGBA ||
-  destBaseFormat == GL_ALPHA ||
-  destBaseFormat == GL_LUMINANCE_ALPHA)) {
-rebaseFormat = texImage->_BaseFormat;
- }
- break;
-
-  case GL_ALPHA:
- if (destBaseFormat != GL_ALPHA) {
-rebaseFormat = texImage->_BaseFormat;
- }
- break;
-  }
-   }
+   texImage->_BaseFormat == GL_INTENSITY) {
+  needsRebase = true;
+  rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
+  rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
+  rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
+  rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_ONE;
+   } else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
+  needsRebase = true;
+  rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
+  rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
+  re

[Mesa-dev] [PATCH v2 26/29] mesa: Remove _mesa_(un)pack_index_span

2014-12-01 Thread Iago Toral Quiroga
These are not used anywhere.
---
 src/mesa/main/pack.c | 219 ---
 src/mesa/main/pack.h |  15 
 2 files changed, 234 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index b46a6fb..cb0956c 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -481,225 +481,6 @@ clamp_half_to_uint(GLhalfARB h)
 
 
 /*
- * Unpack a row of color index data from a client buffer according to
- * the pixel unpacking parameters.
- * This is (or will be) used by glDrawPixels, glTexImage[123]D, etc.
- *
- * Args:  ctx - the context
- *n - number of pixels
- *dstType - destination data type
- *dest - destination array
- *srcType - source pixel type
- *source - source data pointer
- *srcPacking - pixel unpacking parameters
- *transferOps - the pixel transfer operations to apply
- */
-void
-_mesa_unpack_index_span( struct gl_context *ctx, GLuint n,
- GLenum dstType, GLvoid *dest,
- GLenum srcType, const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking,
- GLbitfield transferOps )
-{
-   ASSERT(srcType == GL_BITMAP ||
-  srcType == GL_UNSIGNED_BYTE ||
-  srcType == GL_BYTE ||
-  srcType == GL_UNSIGNED_SHORT ||
-  srcType == GL_SHORT ||
-  srcType == GL_UNSIGNED_INT ||
-  srcType == GL_INT ||
-  srcType == GL_HALF_FLOAT_ARB ||
-  srcType == GL_FLOAT);
-
-   ASSERT(dstType == GL_UNSIGNED_BYTE ||
-  dstType == GL_UNSIGNED_SHORT ||
-  dstType == GL_UNSIGNED_INT);
-
-
-   transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT);
-
-   /*
-* Try simple cases first
-*/
-   if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE
-   && dstType == GL_UNSIGNED_BYTE) {
-  memcpy(dest, source, n * sizeof(GLubyte));
-   }
-   else if (transferOps == 0 && srcType == GL_UNSIGNED_INT
-&& dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) {
-  memcpy(dest, source, n * sizeof(GLuint));
-   }
-   else {
-  /*
-   * general solution
-   */
-  GLuint *indexes = malloc(n * sizeof(GLuint));
-
-  if (!indexes) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
- return;
-  }
-
-  extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source,
-   srcPacking);
-
-  if (transferOps)
- _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes);
-
-  /* convert to dest type */
-  switch (dstType) {
- case GL_UNSIGNED_BYTE:
-{
-   GLubyte *dst = (GLubyte *) dest;
-   GLuint i;
-   for (i = 0; i < n; i++) {
-  dst[i] = (GLubyte) (indexes[i] & 0xff);
-   }
-}
-break;
- case GL_UNSIGNED_SHORT:
-{
-   GLuint *dst = (GLuint *) dest;
-   GLuint i;
-   for (i = 0; i < n; i++) {
-  dst[i] = (GLushort) (indexes[i] & 0x);
-   }
-}
-break;
- case GL_UNSIGNED_INT:
-memcpy(dest, indexes, n * sizeof(GLuint));
-break;
- default:
-_mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span");
-  }
-
-  free(indexes);
-   }
-}
-
-
-void
-_mesa_pack_index_span( struct gl_context *ctx, GLuint n,
-   GLenum dstType, GLvoid *dest, const GLuint *source,
-   const struct gl_pixelstore_attrib *dstPacking,
-   GLbitfield transferOps )
-{
-   GLuint *indexes = malloc(n * sizeof(GLuint));
-
-   if (!indexes) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
-  return;
-   }
-
-   transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT);
-
-   if (transferOps & (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT)) {
-  /* make a copy of input */
-  memcpy(indexes, source, n * sizeof(GLuint));
-  _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes);
-  source = indexes;
-   }
-
-   switch (dstType) {
-   case GL_UNSIGNED_BYTE:
-  {
- GLubyte *dst = (GLubyte *) dest;
- GLuint i;
- for (i = 0; i < n; i++) {
-*dst++ = (GLubyte) source[i];
- }
-  }
-  break;
-   case GL_BYTE:
-  {
- GLbyte *dst = (GLbyte *) dest;
- GLuint i;
- for (i = 0; i < n; i++) {
-dst[i] = (GLbyte) source[i];
- }
-  }
-  break;
-   case GL_UNSIGNED_SHORT:
-  {
- GLushort *dst = (GLushort *) dest;
- GLuint i;
- for (i = 0; i < n; i++) {
-dst[i] = (GLushort) source[i];
- }
- if (dstPacking->SwapBytes) {
-_mesa_swap2( (GLushort *) dst, n );
- }
-  }
-  break;
-   case GL_SHORT:
-  {
- GLshort *dst = (G

[Mesa-dev] [PATCH v2 24/29] mesa: Remove _mesa_unpack_color_span_float

2014-12-01 Thread Iago Toral Quiroga
And various helper functions that went unused after removing it.
---
 src/mesa/main/pack.c | 1033 --
 src/mesa/main/pack.h |9 -
 2 files changed, 1042 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 6a32820..6baa36e 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -53,8 +53,6 @@
 #include "pixeltransfer.h"
 #include "imports.h"
 #include "glformats.h"
-#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
-#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
 #include "format_utils.h"
 #include "format_pack.h"
 
@@ -235,100 +233,6 @@ _mesa_pack_bitmap( GLint width, GLint height, const 
GLubyte *source,
 
 
 /**
- * Get indexes of color components for a basic color format, such as
- * GL_RGBA, GL_RED, GL_LUMINANCE_ALPHA, etc.  Return -1 for indexes
- * that do not apply.
- */
-static void
-get_component_indexes(GLenum format,
-  GLint *redIndex,
-  GLint *greenIndex,
-  GLint *blueIndex,
-  GLint *alphaIndex,
-  GLint *luminanceIndex,
-  GLint *intensityIndex)
-{
-   *redIndex = -1;
-   *greenIndex = -1;
-   *blueIndex = -1;
-   *alphaIndex = -1;
-   *luminanceIndex = -1;
-   *intensityIndex = -1;
-
-   switch (format) {
-   case GL_LUMINANCE:
-   case GL_LUMINANCE_INTEGER_EXT:
-  *luminanceIndex = 0;
-  break;
-   case GL_LUMINANCE_ALPHA:
-   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
-  *luminanceIndex = 0;
-  *alphaIndex = 1;
-  break;
-   case GL_INTENSITY:
-  *intensityIndex = 0;
-  break;
-   case GL_RED:
-   case GL_RED_INTEGER_EXT:
-  *redIndex = 0;
-  break;
-   case GL_GREEN:
-   case GL_GREEN_INTEGER_EXT:
-  *greenIndex = 0;
-  break;
-   case GL_BLUE:
-   case GL_BLUE_INTEGER_EXT:
-  *blueIndex = 0;
-  break;
-   case GL_ALPHA:
-   case GL_ALPHA_INTEGER_EXT:
-  *alphaIndex = 0;
-  break;
-   case GL_RG:
-   case GL_RG_INTEGER:
-  *redIndex = 0;
-  *greenIndex = 1;
-  break;
-   case GL_RGB:
-   case GL_RGB_INTEGER_EXT:
-  *redIndex = 0;
-  *greenIndex = 1;
-  *blueIndex = 2;
-  break;
-   case GL_BGR:
-   case GL_BGR_INTEGER_EXT:
-  *blueIndex = 0;
-  *greenIndex = 1;
-  *redIndex = 2;
-  break;
-   case GL_RGBA:
-   case GL_RGBA_INTEGER_EXT:
-  *redIndex = 0;
-  *greenIndex = 1;
-  *blueIndex = 2;
-  *alphaIndex = 3;
-  break;
-   case GL_BGRA:
-   case GL_BGRA_INTEGER:
-  *redIndex = 2;
-  *greenIndex = 1;
-  *blueIndex = 0;
-  *alphaIndex = 3;
-  break;
-   case GL_ABGR_EXT:
-  *redIndex = 3;
-  *greenIndex = 2;
-  *blueIndex = 1;
-  *alphaIndex = 0;
-  break;
-   default:
-  assert(0 && "bad format in get_component_indexes()");
-   }
-}
-
-
-
-/**
  * For small integer types, return the min and max possible values.
  * Used for clamping floats to unscaled integer types.
  * \return GL_TRUE if type is handled, GL_FALSE otherwise.
@@ -964,743 +868,6 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
 }
 
 
-/**
- * Return source/dest RGBA indexes for unpacking pixels.
- */
-static void
-get_component_mapping(GLenum format,
-  GLint *rSrc,
-  GLint *gSrc,
-  GLint *bSrc,
-  GLint *aSrc,
-  GLint *rDst,
-  GLint *gDst,
-  GLint *bDst,
-  GLint *aDst)
-{
-   switch (format) {
-   case GL_RED:
-   case GL_RED_INTEGER_EXT:
-  *rSrc = 0;
-  *gSrc = *bSrc = *aSrc = -1;
-  break;
-   case GL_GREEN:
-   case GL_GREEN_INTEGER_EXT:
-  *gSrc = 0;
-  *rSrc = *bSrc = *aSrc = -1;
-  break;
-   case GL_BLUE:
-   case GL_BLUE_INTEGER_EXT:
-  *bSrc = 0;
-  *rSrc = *gSrc = *aSrc = -1;
-  break;
-   case GL_ALPHA:
-   case GL_ALPHA_INTEGER_EXT:
-  *rSrc = *gSrc = *bSrc = -1;
-  *aSrc = 0;
-  break;
-   case GL_LUMINANCE:
-   case GL_LUMINANCE_INTEGER_EXT:
-  *rSrc = *gSrc = *bSrc = 0;
-  *aSrc = -1;
-  break;
-   case GL_LUMINANCE_ALPHA:
-   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
-  *rSrc = *gSrc = *bSrc = 0;
-  *aSrc = 1;
-  break;
-   case GL_INTENSITY:
-  *rSrc = *gSrc = *bSrc = *aSrc = 0;
-  break;
-   case GL_RG:
-   case GL_RG_INTEGER:
-  *rSrc = 0;
-  *gSrc = 1;
-  *bSrc = -1;
-  *aSrc = -1;
-  *rDst = 0;
-  *gDst = 1;
-  *bDst = 2;
-  *aDst = 3;
-  break;
-   case GL_RGB:
-   case GL_RGB_INTEGER:
-  *rSrc = 0;
-  *gSrc = 1;
-  *bSrc = 2;
-  *aSrc = -1;
-  *rDst = 0;
-  *gDst = 1;
-  *bDst = 2;
-  *aDst = 3;
-  break;
-   case GL_BGR:
-   case GL_BGR_INTEGER:
-  *rSrc = 2;
-  *gSrc = 1;
-  *bSrc = 0;
-  *aSrc = -1;
-  *rDst = 2;
-  *gDst = 1;
-  *bDst = 0;
-  *aDst = 3;
-  break;
- 

Re: [Mesa-dev] sampler types in tgsi

2014-12-01 Thread Roland Scheidegger
IIRC there were some brief plans to actually deprecate the tex opcodes
at some point and just use the sample ones, which would clean up tgsi  a
bit (having both isn't terribly nice, you can't actually mix them in the
same shader etc.). But I think that idea was quickly dropped and not
really seriously considered (too much work, too disruptive, might even
need new opcode for expressing TXP for old hardware etc.). But if you
had sampler view dcls that would go in that direction...

Roland

Am 29.11.2014 um 19:50 schrieb Ilia Mirkin:
> Adding "DCL SVIEW[0], 2D, UINT" would be precisely what I need. I just
> wanted to clarify that what Marek is talking about is way more complex
> than what my immediate needs are. However ARB_shader_image_load_store
> is "around the corner", so probably should start thinking about it.
> 
> I had already implemented the shader key by the time that I saw your
> suggestion though. I might rework it later to do the more generic
> thing.
> 
> On Sat, Nov 29, 2014 at 1:28 PM, Jose Fonseca  wrote:
>> Why can't you just get the type information from the t#0's declaration in 
>> this case too, as I was suggesting?
>>
>> Jose
>>
>>
>> 
>> From: ibmir...@gmail.com [ibmir...@gmail.com] on behalf of Ilia Mirkin 
>> [imir...@alum.mit.edu]
>> Sent: 29 November 2014 18:05
>> To: Marek Olšák
>> Cc: Jose Fonseca; Roland Scheidegger; mesa-dev@lists.freedesktop.org
>> Subject: Re: [Mesa-dev] sampler types in tgsi
>>
>> This is the next level of sophistication... to be clear I was talking
>> about distinguishing sampler2D from isampler2D in glsl (and, if
>> possible usampler2D, but I'm pretty sure that wouldn't actually
>> matter). The issue is that the instructions are like
>>
>> sam (f32)(xyzw)r0.x, r0.z, s#0, t#0
>>
>> vs
>>
>> sam (u32)(xyzw)r0.x, r0.z, s#0, t#0
>>
>> I think that the gpu samples the value in some internal
>> representation, and then spits it out as either f32 or u32 as
>> requested. Since TGSI values are typeless, I can't tell how I'm
>> supposed to be returning it.
>>
>> For now I've just added a shader key.
>>
>>   -ilia
>>
>> On Sat, Nov 29, 2014 at 7:42 AM, Marek Olšák  wrote:
>>> GLSL allows specifying sampler formats in shaders too, but it only
>>> appears to be allowed for GL_ARB_shader_image_load_store and it must
>>> match the sample view format, so that drivers can ignore it if they
>>> want. The format specification is complete except for component
>>> ordering. e.g. a shader can declare "rgba16_snorm", but it cannot
>>> declare "bgra16_snorm".
>>>
>>> Marek
>>>
>>> On Sat, Nov 29, 2014 at 8:43 AM, Jose Fonseca  wrote:
 On 29/11/14 06:07, Roland Scheidegger wrote:
>
> Am 29.11.2014 um 06:12 schrieb Ilia Mirkin:
>>
>> Hello,
>>
>> It appears that the A3XX ISA (freedreno) requires the texture
>> instruction to properly specify its output type (or at least f32 vs
>> u32). Now I could stick this into a driver-local shader key, but it
>> seems unfortunate since in glsl, it knows whether it's an int or float
>> sampler.
>>
>> Would there be any objections to being able to specify an int property
>> on the SAMP declaration? Or some alternate approach?
>>
>
> Hmm I guess the return type of the sampler_view decl was intended for
> something along these lines (it's a d3d10-ism but not really used right
> now, and it is per channel too).


 Right --
 https://urldefense.proofpoint.com/v2/url?u=http-3A__msdn.microsoft.com_en-2Dus_library_windows_desktop_bb943976.aspx&d=AAIFaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=nXlt_5vGi1RctORgwiMYVQlxu0sDao9j7V3TqLQDVdE&s=4JWo8Lk3FskpTEtiOhE2_H_3l3E1dBDlx9_3RtP-GTk&e=

> If you make some return type in sampler
> this is thus not very nice as now you've got it both in sampler and
> sampler_view. Not sure what a good solution of that would be...


 I think a good compromise would be to force separate declarations of
 sampler_view and sampler, like we need to do for D3D10 sample opcodes


   DCL SVIEW[0], 2D, UINT
   DCL SAMP[0]
   TEX OUT[1], IN[1], SAMP[0]

 at least for the UINT resources.


 I also think that eventually we should have TGSI to drop the opcodes that
 take combined sampler and sampler_views, have only the D3D10 like opcodes
 with seperate operands for sampler and sampler_view, and have a
 PIPE_CAP_SEPARATE just for those drivers that can handle the combination.
 But this can wait.


 Jose


 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=AAIFaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=nXlt_5vGi1RctORgwiMYVQlxu0s

Re: [Mesa-dev] sampler types in tgsi

2014-12-01 Thread Marek Olšák
I've got no problem with that if somebody wants to do it.

Marek

On Mon, Dec 1, 2014 at 1:18 PM, Roland Scheidegger  wrote:
> IIRC there were some brief plans to actually deprecate the tex opcodes
> at some point and just use the sample ones, which would clean up tgsi  a
> bit (having both isn't terribly nice, you can't actually mix them in the
> same shader etc.). But I think that idea was quickly dropped and not
> really seriously considered (too much work, too disruptive, might even
> need new opcode for expressing TXP for old hardware etc.). But if you
> had sampler view dcls that would go in that direction...
>
> Roland
>
> Am 29.11.2014 um 19:50 schrieb Ilia Mirkin:
>> Adding "DCL SVIEW[0], 2D, UINT" would be precisely what I need. I just
>> wanted to clarify that what Marek is talking about is way more complex
>> than what my immediate needs are. However ARB_shader_image_load_store
>> is "around the corner", so probably should start thinking about it.
>>
>> I had already implemented the shader key by the time that I saw your
>> suggestion though. I might rework it later to do the more generic
>> thing.
>>
>> On Sat, Nov 29, 2014 at 1:28 PM, Jose Fonseca  wrote:
>>> Why can't you just get the type information from the t#0's declaration in 
>>> this case too, as I was suggesting?
>>>
>>> Jose
>>>
>>>
>>> 
>>> From: ibmir...@gmail.com [ibmir...@gmail.com] on behalf of Ilia Mirkin 
>>> [imir...@alum.mit.edu]
>>> Sent: 29 November 2014 18:05
>>> To: Marek Olšák
>>> Cc: Jose Fonseca; Roland Scheidegger; mesa-dev@lists.freedesktop.org
>>> Subject: Re: [Mesa-dev] sampler types in tgsi
>>>
>>> This is the next level of sophistication... to be clear I was talking
>>> about distinguishing sampler2D from isampler2D in glsl (and, if
>>> possible usampler2D, but I'm pretty sure that wouldn't actually
>>> matter). The issue is that the instructions are like
>>>
>>> sam (f32)(xyzw)r0.x, r0.z, s#0, t#0
>>>
>>> vs
>>>
>>> sam (u32)(xyzw)r0.x, r0.z, s#0, t#0
>>>
>>> I think that the gpu samples the value in some internal
>>> representation, and then spits it out as either f32 or u32 as
>>> requested. Since TGSI values are typeless, I can't tell how I'm
>>> supposed to be returning it.
>>>
>>> For now I've just added a shader key.
>>>
>>>   -ilia
>>>
>>> On Sat, Nov 29, 2014 at 7:42 AM, Marek Olšák  wrote:
 GLSL allows specifying sampler formats in shaders too, but it only
 appears to be allowed for GL_ARB_shader_image_load_store and it must
 match the sample view format, so that drivers can ignore it if they
 want. The format specification is complete except for component
 ordering. e.g. a shader can declare "rgba16_snorm", but it cannot
 declare "bgra16_snorm".

 Marek

 On Sat, Nov 29, 2014 at 8:43 AM, Jose Fonseca  wrote:
> On 29/11/14 06:07, Roland Scheidegger wrote:
>>
>> Am 29.11.2014 um 06:12 schrieb Ilia Mirkin:
>>>
>>> Hello,
>>>
>>> It appears that the A3XX ISA (freedreno) requires the texture
>>> instruction to properly specify its output type (or at least f32 vs
>>> u32). Now I could stick this into a driver-local shader key, but it
>>> seems unfortunate since in glsl, it knows whether it's an int or float
>>> sampler.
>>>
>>> Would there be any objections to being able to specify an int property
>>> on the SAMP declaration? Or some alternate approach?
>>>
>>
>> Hmm I guess the return type of the sampler_view decl was intended for
>> something along these lines (it's a d3d10-ism but not really used right
>> now, and it is per channel too).
>
>
> Right --
> https://urldefense.proofpoint.com/v2/url?u=http-3A__msdn.microsoft.com_en-2Dus_library_windows_desktop_bb943976.aspx&d=AAIFaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=nXlt_5vGi1RctORgwiMYVQlxu0sDao9j7V3TqLQDVdE&s=4JWo8Lk3FskpTEtiOhE2_H_3l3E1dBDlx9_3RtP-GTk&e=
>
>> If you make some return type in sampler
>> this is thus not very nice as now you've got it both in sampler and
>> sampler_view. Not sure what a good solution of that would be...
>
>
> I think a good compromise would be to force separate declarations of
> sampler_view and sampler, like we need to do for D3D10 sample opcodes
>
>
>   DCL SVIEW[0], 2D, UINT
>   DCL SAMP[0]
>   TEX OUT[1], IN[1], SAMP[0]
>
> at least for the UINT resources.
>
>
> I also think that eventually we should have TGSI to drop the opcodes that
> take combined sampler and sampler_views, have only the D3D10 like opcodes
> with seperate operands for sampler and sampler_view, and have a
> PIPE_CAP_SEPARATE just for those drivers that can handle the combination.
> But this can wait.
>
>
> Jose
>
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.fr

[Mesa-dev] [PATCH] i965: Make validate_reg tables constant

2014-12-01 Thread Juha-Pekka Heikkila
Declare local tables constant. Also added extra '32' at end of
"width_for_reg" to be future proof, cvt function which give
indexes to access here could already give index to reach place
number five now containing '32'.

Signed-off-by: Juha-Pekka Heikkila 
---
 src/mesa/drivers/dri/i965/brw_eu_emit.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index c475393..a027b58 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -226,10 +226,10 @@ extern int reg_type_size[];
 static void
 validate_reg(const struct brw_context *brw, brw_inst *inst, struct brw_reg reg)
 {
-   int hstride_for_reg[] = {0, 1, 2, 4};
-   int vstride_for_reg[] = {0, 1, 2, 4, 8, 16, 32};
-   int width_for_reg[] = {1, 2, 4, 8, 16};
-   int execsize_for_reg[] = {1, 2, 4, 8, 16};
+   const int hstride_for_reg[] = {0, 1, 2, 4};
+   const int vstride_for_reg[] = {0, 1, 2, 4, 8, 16, 32};
+   const int width_for_reg[] = {1, 2, 4, 8, 16, 32};
+   const int execsize_for_reg[] = {1, 2, 4, 8, 16};
int width, hstride, vstride, execsize;
 
if (reg.file == BRW_IMMEDIATE_VALUE) {
-- 
1.8.5.1

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


[Mesa-dev] [PATCH 03/10] mesa: Returns zero samples when querying GL_NUM_SAMPLE_COUNTS when internal format is integer

2014-12-01 Thread Eduardo Lima Mitev
In GLES3, multisampling is not supported for signed and unsigned integer
internal formats. See 
https://www.khronos.org/opengles/sdk/docs/man3/docbook4/xhtml/glGetInternalformativ.xml.

Fixes 19 dEQP tests under 'dEQP-GLES3.functional.state_query.internal_format.*'.
---
 src/mesa/main/formatquery.c | 44 +++-
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 40eca87..629b07b 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -115,23 +115,33 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
internalformat, GLenum pname,
 internalformat, buffer);
   break;
case GL_NUM_SAMPLE_COUNTS: {
-  /* The driver can return 0, and we should pass that along to the
-   * application.  The ARB decided that ARB_internalformat_query should
-   * behave as ARB_internalformat_query2 in this situation.
-   *
-   * The ARB_internalformat_query2 spec says:
-   *
-   * "- NUM_SAMPLE_COUNTS: The number of sample counts that would be
-   *returned by querying SAMPLES is returned in .
-   ** If  is not color-renderable,
-   *  depth-renderable, or stencil-renderable (as defined in
-   *  section 4.4.4), or if  does not support multiple
-   *  samples (ie other than TEXTURE_2D_MULTISAMPLE,
-   *  TEXTURE_2D_MULTISAMPLE_ARRAY, or RENDERBUFFER), 0 is
-   *  returned."
-   */
-  const size_t num_samples =
- ctx->Driver.QuerySamplesForFormat(ctx, target, internalformat, 
buffer);
+  size_t num_samples;
+
+  if (_mesa_is_gles3(ctx) && _mesa_is_enum_format_integer(internalformat)) 
{
+ /* In GLES3.0, multisampling is not supported for signed and unsigned 
integer internal
+formats 
,
+so return zero
+ */
+ num_samples = 0;
+  }
+  else {
+ /* The driver can return 0, and we should pass that along to the
+  * application.  The ARB decided that ARB_internalformat_query should
+  * behave as ARB_internalformat_query2 in this situation.
+  *
+  * The ARB_internalformat_query2 spec says:
+  *
+  * "- NUM_SAMPLE_COUNTS: The number of sample counts that would be
+  *returned by querying SAMPLES is returned in .
+  ** If  is not color-renderable,
+  *  depth-renderable, or stencil-renderable (as defined in
+  *  section 4.4.4), or if  does not support multiple
+  *  samples (ie other than TEXTURE_2D_MULTISAMPLE,
+  *  TEXTURE_2D_MULTISAMPLE_ARRAY, or RENDERBUFFER), 0 is
+  *  returned."
+  */
+ num_samples =  ctx->Driver.QuerySamplesForFormat(ctx, target, 
internalformat, buffer);
+  }
 
   /* QuerySamplesForFormat writes some stuff to buffer, so we have to
* separately over-write it with the requested value.
-- 
2.1.3

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


[Mesa-dev] [PATCH 05/10] glsl: Don't allow gl_FragData[i], with i>0 in GLES shaders

2014-12-01 Thread Eduardo Lima Mitev
The OpenGL ES Shading Language specification describes the
values that may be output by a fragment shader. These are
gl_FragColor and gl_FragData[0]. Multiple render targets
are not supported in GLES.

Fixes dEQP test:
  * dEQP-GLES3.functional.shaders.fragdata.invalid_assign_to_1
---
 src/glsl/ast_array_index.cpp | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp
index ff0c757..b507d34 100644
--- a/src/glsl/ast_array_index.cpp
+++ b/src/glsl/ast_array_index.cpp
@@ -46,7 +46,9 @@ ast_array_specifier::print(void) const
  *
  * This function also checks whether the array is a built-in array whose
  * maximum size is too small to accommodate the given index, and if so uses
- * loc and state to report the error.
+ * loc and state to report the error. It also checks that the built-in array
+ * gl_FragData is not accessed with indexes greater than zero in OpenGL ES,
+ * where multiple render targets are not allowed.
  */
 static void
 update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE *loc,
@@ -54,6 +56,23 @@ update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE *loc,
 {
if (ir_dereference_variable *deref_var = ir->as_dereference_variable()) {
   ir_variable *var = deref_var->var;
+
+  /* Page 89 in the section 3.8 (Fragment Shaders) of the the
+   * OpenGL ES 2.0.25 spec says:
+   * "The OpenGL ES Shading Language specification describes the
+   * values that may be output by a fragment shader. These are
+   * gl_FragColor and gl_FragData[0].
+   *  ...
+   * gl_FragData is supported for compatibility with the desktop
+   * OpenGL Shading Language, but only a single fragment color
+   * output is allowed in the OpenGL ES Shading Language."
+   */
+  if (state->es_shader && idx > 0 &&
+  strcmp(var->name, "gl_FragData") == 0) {
+ _mesa_glsl_error(loc, state,
+  "multiple render targets are not supported");
+  }
+
   if (idx > (int)var->data.max_array_access) {
  var->data.max_array_access = idx;
 
-- 
2.1.3

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


[Mesa-dev] [PATCH 01/10] mesa: Considers GL_DEPTH_STENCIL_ATTACHMENT a valid argument for FBO invalidation under GLES3

2014-12-01 Thread Eduardo Lima Mitev
In OpenGL and OpenGL-Es 3+, GL_DEPTH_STENCIL_ATTACHMENT is a valid attachment 
point for the family of functions
that invalidate a framebuffer object (e.g, glInvalidateFramebuffer, 
glInvalidateSubFramebuffer, etc).
Currently, a GL_INVALID_ENUM error is emitted for this attachment point.

Fixes 21 dEQP test failures under 'dEQP-GLES3.functional.fbo.invalidate.*'.
---
 src/mesa/main/fbobject.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8283373..19c4020 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3073,6 +3073,10 @@ invalidate_framebuffer_storage(GLenum target, GLsizei 
numAttachments,
  case GL_DEPTH_ATTACHMENT:
  case GL_STENCIL_ATTACHMENT:
 break;
+ case GL_DEPTH_STENCIL_ATTACHMENT:
+if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx))
+   break;
+/* otherwise fall through */
  case GL_COLOR_ATTACHMENT0:
  case GL_COLOR_ATTACHMENT1:
  case GL_COLOR_ATTACHMENT2:
-- 
2.1.3

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


[Mesa-dev] [PATCH 02/10] mesa: Enables GL_RGB and GL_RGBA unsized internal formats for OpenGL ES 3.0

2014-12-01 Thread Eduardo Lima Mitev
GL_RGB and GL_RGBA are valid internal formats on a GLES3 profile. See
"Table 1. Unsized Internal Formats" at
https://www.khronos.org/opengles/sdk/docs/man3/html/glTexImage2D.xhtml.

Fixes 2 dEQP tests:
- dEQP-GLES3.functional.state_query.internal_format.rgb_samples
- dEQP-GLES3.functional.state_query.internal_format.rgba_samples
---
 src/mesa/main/fbobject.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 19c4020..cce5370 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1429,6 +1429,8 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum 
internalFormat)
case GL_RGB8:
   return GL_RGB;
case GL_RGB:
+  if (_mesa_is_gles3(ctx))
+ return GL_RGB;
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
@@ -1443,6 +1445,8 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum 
internalFormat)
case GL_RGBA8:
   return GL_RGBA;
case GL_RGBA:
+  if (_mesa_is_gles3(ctx))
+ return GL_RGBA;
case GL_RGBA2:
case GL_RGBA12:
case GL_RGBA16:
-- 
2.1.3

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


[Mesa-dev] [PATCH 08/10] glsl: A shader cannot redefine or overload built-in functions in GLSL ES 3.00

2014-12-01 Thread Eduardo Lima Mitev
From: Samuel Iglesias Gonsalvez 

Create a new search function to look for matching built-in functions by name
and use it for built-in function redefinition or overload in GLSL ES 3.00.

GLSL ES 3.0 spec, chapter 6.1 "Function Definitions", page 71

"A shader cannot redefine or overload built-in functions."

In case of GLSL ES 1.0 spec, chapter 6.1 "Function Definitions", page 54

"Function names can be overloaded. This allows the same function name to be
used for multiple functions, as long as the argument list types differ. If
functions’ names and argument types match, then their return type and
parameter qualifiers must also match. Function signature matching is based on
parameter type only, no qualifiers are used. Overloading is used heavily in the
built-in functions. When overloaded functions (or indeed any functions) are
resolved, an exact match for the function's signature is sought. This includes
exact match of array size as well. No promotion or demotion of the return type
or input argument types is done. All expected combination of inputs and
outputs must be defined as separate functions."

So this check is specific to GLSL ES 3.00.

This patch fixes the following dEQP tests:

dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_vertex
dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_fragment
dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function_vertex
dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function_fragment

No piglit regressions.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/glsl/ast_to_hir.cpp| 22 ++
 src/glsl/builtin_functions.cpp | 11 +++
 src/glsl/ir.h  |  4 
 3 files changed, 37 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index fe1e129..b7074bc 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4167,6 +4167,28 @@ ast_function::hir(exec_list *instructions,
return NULL;
 }
  }
+  } else {
+ /* From GLSL ES 3.0 spec, chapter 6.1 "Function Definitions", page 71:
+  *
+  * "A shader cannot redefine or overload built-in functions."
+  *
+  * While in GLSL ES 1.0 spec, chapter 6.1 "Function Definitions", page
+  * 54, this is allowed:
+  *
+  * "Function names can be overloaded. [...] Overloading is used 
heavily
+  * in the built-in functions."
+  *
+  */
+ if (state->es_shader && state->language_version >= 300) {
+/* Local shader has no exact candidates; check the built-ins. */
+_mesa_glsl_initialize_builtin_functions();
+if (_mesa_glsl_find_builtin_function_by_name(state, name)) {
+   YYLTYPE loc = this->get_location();
+   _mesa_glsl_error(& loc, state,
+"A shader cannot redefine or overload built-in 
"
+"function `%s' in GLSL ES 3.00", name);
+}
+ }
   }
}
 
diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index bb7fbcd..f5052d3 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -4618,6 +4618,17 @@ _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state 
*state,
return s;
 }
 
+ir_function *
+_mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state *state,
+ const char *name)
+{
+   ir_function * f;
+   mtx_lock(&builtins_lock);
+   f = builtins.shader->symbols->get_function(name);
+   mtx_unlock(&builtins_lock);
+   return f;
+}
+
 gl_shader *
 _mesa_glsl_get_builtin_function_shader()
 {
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index a0f48b2..f2d8269 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -2417,6 +2417,10 @@ extern ir_function_signature *
 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
  const char *name, exec_list 
*actual_parameters);
 
+extern ir_function *
+_mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state *state,
+ const char *name);
+
 extern gl_shader *
 _mesa_glsl_get_builtin_function_shader(void);
 
-- 
2.1.3

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


[Mesa-dev] [PATCH 06/10] glsl: invariant qualifier is not valid for shader inputs in GLSL ES 3.00

2014-12-01 Thread Eduardo Lima Mitev
From: Samuel Iglesias Gonsalvez 

GLSL ES 3.00 spec, chapter 4.6.1 "The Invariant Qualifier",

Only variables output from a shader can be candidates for invariance. This
includes user-defined output variables and the built-in output variables.
As only outputs can be declared as invariant, an invariant output from one
shader stage will still match an input of a subsequent stage without the
input being declared as invariant.

This patch fixes the following dEQP tests:

dEQP-GLES3.functional.shaders.qualification_order.variables.valid.invariant_interp_storage_precision
dEQP-GLES3.functional.shaders.qualification_order.variables.valid.invariant_interp_storage
dEQP-GLES3.functional.shaders.qualification_order.variables.valid.invariant_storage_precision
dEQP-GLES3.functional.shaders.qualification_order.variables.valid.invariant_storage
dEQP-GLES3.functional.shaders.qualification_order.variables.invalid.invariant_interp_storage_precision_invariant_input
dEQP-GLES3.functional.shaders.qualification_order.variables.invalid.invariant_interp_storage_invariant_input
dEQP-GLES3.functional.shaders.qualification_order.variables.invalid.invariant_storage_precision_invariant_input
dEQP-GLES3.functional.shaders.qualification_order.variables.invalid.invariant_storage_invariant_input

No piglit regressions observed.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/glsl/glsl_parser.yy| 2 ++
 src/glsl/link_varyings.cpp | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 6160e26..55b3a7d 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1591,6 +1591,8 @@ type_qualifier:
 
   $$ = $2;
   $$.flags.q.invariant = 1;
+  if (state->es_shader && state->language_version >= 300 && $$.flags.q.in)
+ _mesa_glsl_error(&@1, state, "invariant qualifiers cannot be used 
with shader inputs");
}
| interpolation_qualifier type_qualifier
{
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 1866ab2..1fe198a 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -116,7 +116,7 @@ cross_validate_types_and_qualifiers(struct 
gl_shader_program *prog,
   return;
}
 
-   if (input->data.invariant != output->data.invariant) {
+   if (!prog->IsES && input->data.invariant != output->data.invariant) {
   linker_error(prog,
"%s shader output `%s' %s invariant qualifier, "
"but %s shader input %s invariant qualifier\n",
-- 
2.1.3

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


[Mesa-dev] [PATCH 00/10] Various fixes for dEQP failing tests

2014-12-01 Thread Eduardo Lima Mitev
This set of (unrelated) patches fixes over 230 tests from the dEQP test suite 
[1].
While the tests failures were gathered on i965 (gen8) against 10.3.3, there are 
several driver and version agnostic fixes.

There is one piglit regression brought by patch 10 , specifically in test:

bin/glslparsertest \
tests/spec/glsl-1.50/compiler/gs-also-uses-smooth-flat-noperspective.geom 
pass \
1.50 --check-link

The piglit test seems to be wrong in this case because it contradicts the spec, 
please check that commit's log for details. It would be good to hear other 
people's comments on this in case we are missing something.

The plan is to continue sending these random fixes in batches like this one, 
with the purpose of improving the pass rate of dEQP tests against Mesa.

Eduardo Lima

[1] https://android.googlesource.com/platform/external/deqp/

Patch summary:

Eduardo Lima Mitev (4):
  mesa: Considers GL_DEPTH_STENCIL_ATTACHMENT a valid argument for FBO
invalidation under GLES3
  mesa: Enables GL_RGB and GL_RGBA unsized internal formats for OpenGL
ES 3.0
  mesa: Returns zero samples when querying GL_NUM_SAMPLE_COUNTS when
internal format is integer
  glsl: Don't allow gl_FragData[i], with i>0 in GLES shaders

Iago Toral Quiroga (1):
  mesa: Recompute LegalTypesMask if the GL API has changed

Samuel Iglesias Gonsalvez (5):
  glsl: invariant qualifier is not valid for shader inputs in GLSL ES
3.00
  glsl: don't allow invariant qualifiers for interface blocks in GLSL ES
  glsl: A shader cannot redefine or overload built-in functions in GLSL
ES 3.00
  main/glsles: return two minor digits for SHADING_LANGUAGE_VERSION
  glsl: fail when a shader's input var has not an equivalent out var in
previous

 src/glsl/ast_array_index.cpp   | 21 +++-
 src/glsl/ast_to_hir.cpp| 22 +
 src/glsl/builtin_functions.cpp | 11 +++
 src/glsl/glsl_parser.yy| 27 ++
 src/glsl/ir.h  |  4 
 src/glsl/link_varyings.cpp | 18 -
 src/mesa/main/fbobject.c   |  8 
 src/mesa/main/formatquery.c| 44 ++
 src/mesa/main/getstring.c  |  2 +-
 src/mesa/main/mtypes.h |  3 ++-
 src/mesa/main/varray.c |  3 ++-
 11 files changed, 141 insertions(+), 22 deletions(-)

-- 
2.1.3

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


[Mesa-dev] [PATCH 04/10] mesa: Recompute LegalTypesMask if the GL API has changed

2014-12-01 Thread Eduardo Lima Mitev
From: Iago Toral Quiroga 

The current code computes ctx->Array.LegalTypesMask just once,
however, computing this needs to consider ctx->API so we need
to make sure that the API for that context has not changed if
we intend to reuse the result.

The context API can change, at least, if we go through
_mesa_meta_begin, since that will always force
API_OPENGL_COMPAT until we call _mesa_meta_end. If any
operation in between these two calls triggers a call to
update_array_format, then we might be caching a value for
LegalTypesMask that will not be right once we have called
_mesa_meta_end and restored the context API.

Fixes the following 179 dEQP tests in i965:
dEQP-GLES3.functional.vertex_arrays.single_attribute.strides.fixed.*
dEQP-GLES3.functional.vertex_arrays.single_attribute.normalize.fixed.*
dEQP-GLES3.functional.vertex_arrays.single_attribute.output_types.fixed.*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.static_draw.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.stream_draw.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.dynamic_draw.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.static_copy.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.stream_copy.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.dynamic_copy.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.static_read.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.stream_read.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.dynamic_read.*fixed*
dEQP-GLES3.functional.vertex_arrays.multiple_attributes.input_types.3_*fixed2*
dEQP-GLES3.functional.draw.random.{2,18,28,68,83,106,109,156,181,191}
---
 src/mesa/main/mtypes.h | 3 ++-
 src/mesa/main/varray.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7389baa..78f034d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1701,8 +1701,9 @@ struct gl_array_attrib
/** One of the DRAW_xxx flags, not consumed by drivers */
gl_draw_method DrawMethod;
 
-   /** Legal array datatypes */
+   /** Legal array datatypes and the API for which they have been computed */
GLbitfield LegalTypesMask;
+   int LegalTypesMaskAPI;
 };
 
 
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 96c2b26..acfc4bd 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -258,11 +258,12 @@ update_array_format(struct gl_context *ctx,
GLuint elementSize;
GLenum format = GL_RGBA;
 
-   if (ctx->Array.LegalTypesMask == 0) {
+   if (ctx->Array.LegalTypesMask == 0 || ctx->Array.LegalTypesMaskAPI != 
ctx->API) {
   /* One-time initialization.  We can't do this in _mesa_init_varrays()
* below because extensions are not yet enabled at that point.
*/
   ctx->Array.LegalTypesMask = get_legal_types_mask(ctx);
+  ctx->Array.LegalTypesMaskAPI = ctx->API;
}
 
legalTypesMask &= ctx->Array.LegalTypesMask;
-- 
2.1.3

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


[Mesa-dev] [PATCH 07/10] glsl: don't allow invariant qualifiers for interface blocks in GLSL ES

2014-12-01 Thread Eduardo Lima Mitev
From: Samuel Iglesias Gonsalvez 

From GLSL ES 3.0, chapter 4.3.7 "Interface Blocks", page 38:

"GLSL ES 3.0 does not support interface blocks for shader inputs or outputs."

and from GLSL ES 3.0, chapter 4.6.1 "The invariant qualifier", page 52.

"Only variables output from a shader can be candidates for invariance. This
includes user-defined output variables and the built-in output variables. As
only outputs can be declared as invariant, an invariant output from one shader
stage will still match an input of a subsequent stage without the input being
declared as invariant."

From GLSL ES 1.0, chapter 4.6.1 "The invariant qualifier", page 37.

"Only the following variables may be declared as invariant:
* Built-in special variables output from the vertex shader
* Varying variables output from the vertex shader
* Built-in special variables input to the fragment shader
* Varying variables input to the fragment shader
* Built-in special variables output from the fragment shader."

This patch fixes the following dEQP tests:

dEQP-GLES3.functional.shaders.declarations.invalid_declarations.invariant_uniform_block_2_vertex
dEQP-GLES3.functional.shaders.declarations.invalid_declarations.invariant_uniform_block_2_fragment

No piglit regressions.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/glsl/glsl_parser.yy | 25 +
 1 file changed, 25 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 55b3a7d..489d3af 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -2519,6 +2519,31 @@ basic_interface_block:
  "interface block member does not match "
  "the interface block");
  }
+ /* From GLSL ES 3.0, chapter 4.3.7 "Interface Blocks", page 38:
+  *
+  * "GLSL ES 3.0 does not support interface blocks for shader inputs or
+  * outputs."
+  *
+  * And from GLSL ES 3.0, chapter 4.6.1 "The invariant qualifier", 
page 52.
+  *
+  * "Only variables output from a shader can be candidates for
+  * invariance. This includes user-defined output variables and the
+  * built-in output variables. As only outputs can be declared as
+  * invariant, an invariant output from one shader stage will
+  * still match an input of a subsequent stage without the input being
+  * declared as invariant."
+  *
+  * From GLSL ES 1.0, chapter 4.6.1 "The invariant qualifier", page 37.
+  *
+  * "Only the following variables may be declared as invariant:
+  *  * Built-in special variables output from the vertex shader
+  *  * Varying variables output from the vertex shader
+  *  * Built-in special variables input to the fragment shader
+  *  * Varying variables input to the fragment shader
+  *  * Built-in special variables output from the fragment shader."
+  */
+ if (state->es_shader && qualifier.flags.q.invariant)
+_mesa_glsl_error(&@1, state, "invariant qualifiers cannot be used 
with interface blocks in GLSL ES");
   }
 
   $$ = block;
-- 
2.1.3

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


[Mesa-dev] [PATCH 10/10] glsl: fail when a shader's input var has not an equivalent out var in previous

2014-12-01 Thread Eduardo Lima Mitev
From: Samuel Iglesias Gonsalvez 

GLSL ES 3.00 spec, 4.3.10 (Linking of Vertex Outputs and Fragment Inputs),
page 45 says the following:

"The type of vertex outputs and fragment input with the same name must match,
otherwise the link command will fail. The precision does not need to match.
Only those fragment inputs statically used (i.e. read) in the fragment shader
must be declared as outputs in the vertex shader; declaring superfluous vertex
shader outputs is permissible."
[...]
"The term static use means that after preprocessing the shader includes at
least one statement that accesses the input or output, even if that statement
is never actually executed."

And it includes a table with all the possibilities.

Similar table or content is present in other GLSL specs: GLSL 4.40, GLSL 1.50,
etc but for more stages (vertex and geometry shaders, etc).

This patch detects that case and returns a link error. It fixes the following
dEQP test:

  dEQP-GLES3.functional.shaders.linkage.varying.rules.illegal_usage_1

However, it adds a new regression in piglit because the test hasn't a
vertex shader and it checks the link status.

bin/glslparsertest \
tests/spec/glsl-1.50/compiler/gs-also-uses-smooth-flat-noperspective.geom pass \
1.50 --check-link

This piglit test is wrong according to the spec wording above, so if this patch
is merged it should be updated.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/glsl/link_varyings.cpp | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 1fe198a..036996f 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -263,6 +263,22 @@ cross_validate_outputs_to_inputs(struct gl_shader_program 
*prog,
  if (output != NULL) {
 cross_validate_types_and_qualifiers(prog, input, output,
 consumer->Stage, 
producer->Stage);
+ } else {
+/* Check for input vars with unmatched output vars in prev stage
+ * taking into account that interface blocks could have a match
+ * output but with different name, so we ignore them.
+ */
+if (input->data.used && !input->data.assigned &&
+!(input->is_interface_instance() ||
+  input->get_interface_type() ||
+  input->is_in_uniform_block()) &&
+input->data.how_declared == ir_var_declared_normally &&
+input->data.location == -1)
+   linker_error(prog,
+"%s shader input `%s' "
+"has no matching output in the previous stage\n",
+_mesa_shader_stage_to_string(consumer->Stage),
+input->name);
  }
   }
}
-- 
2.1.3

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


[Mesa-dev] [PATCH 09/10] main/glsles: return two minor digits for SHADING_LANGUAGE_VERSION

2014-12-01 Thread Eduardo Lima Mitev
From: Samuel Iglesias Gonsalvez 

For OpenGL ES 3.0 spec, the minor number for SHADING_LANGUAGE_VERSION is always
two digits, matching the OpenGL ES Shading Language Specification release
number. For example, this query might return the string "3.00".

This patch fixes the following dEQP test:

   dEQP-GLES3.functional.state_query.string.shading_language_version

No piglit regression observed.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/mesa/main/getstring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index 431d60b..7054fc7 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -68,7 +68,7 @@ shading_language_version(struct gl_context *ctx)
case API_OPENGLES2:
   return (ctx->Version < 30)
  ? (const GLubyte *) "OpenGL ES GLSL ES 1.0.16"
- : (const GLubyte *) "OpenGL ES GLSL ES 3.0";
+ : (const GLubyte *) "OpenGL ES GLSL ES 3.00";
 
case API_OPENGLES:
   /* fall-through */
-- 
2.1.3

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


Re: [Mesa-dev] [PATCH] ir_to_mesa: Don't optimize clamp into saturate when target is GL_VERTEX_PROGRAM_ARB

2014-12-01 Thread Abdiel Janulgue


On 11/29/2014 12:10 PM, Kenneth Graunke wrote:
> On Thursday, November 27, 2014 10:45:00 AM Abdiel Janulgue wrote:
>> Add the the same restriction as in the previous try_emit_sat when trying
>> to optimize clamp. Fixes an infinite loop in swrast where the lowering
>> pass unpacks saturate into clamp but the opt_algebraic pass tries to do
>> the opposite.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83463
>>
>> Tested-by: Vinson Lee 
>> Signed-off-by: Abdiel Janulgue 
>> ---
>>  src/glsl/opt_algebraic.cpp  | 3 ++-
>>  src/mesa/main/mtypes.h  | 1 +
>>  src/mesa/program/ir_to_mesa.cpp | 3 ++-
>>  3 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
>> index 430f5cb..62b14dd 100644
>> --- a/src/glsl/opt_algebraic.cpp
>> +++ b/src/glsl/opt_algebraic.cpp
>> @@ -679,7 +679,8 @@ ir_algebraic_visitor::handle_expression(ir_expression 
>> *ir)
>>  
>> case ir_binop_min:
>> case ir_binop_max:
>> -  if (ir->type->base_type != GLSL_TYPE_FLOAT)
>> +  if (ir->type->base_type != GLSL_TYPE_FLOAT ||
>> + options->EmitNoSat)
>>   break;
>>  
>>/* Replace min(max) operations and its commutative combinations with
>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>> index 7389baa..199443a 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -2990,6 +2990,7 @@ struct gl_shader_compiler_options
>> GLboolean EmitNoMainReturn;/**< Emit CONT/RET opcodes? */
>> GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */
>> GLboolean EmitNoPow;   /**< Emit POW opcodes? */
>> +   GLboolean EmitNoSat;
>> GLboolean LowerClipDistance; /**< Lower gl_ClipDistance from float[8] to 
>> vec4[2]? */
>>  
>> /**
>> diff --git a/src/mesa/program/ir_to_mesa.cpp 
>> b/src/mesa/program/ir_to_mesa.cpp
>> index 5cd9058..44fd315 100644
>> --- a/src/mesa/program/ir_to_mesa.cpp
>> +++ b/src/mesa/program/ir_to_mesa.cpp
>> @@ -2935,7 +2935,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct 
>> gl_shader_program *prog)
>>  
>>bool progress;
>>exec_list *ir = prog->_LinkedShaders[i]->ir;
>> -  const struct gl_shader_compiler_options *options =
>> +  struct gl_shader_compiler_options *options =
>>  
>> &ctx->Const.ShaderCompilerOptions[prog->_LinkedShaders[i]->Stage];
>>  
>>do {
>> @@ -2949,6 +2949,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct 
>> gl_shader_program *prog)
>>   | ((options->EmitNoPow) ? POW_TO_EXP2 : 0)
>>   | ((target == GL_VERTEX_PROGRAM_ARB) ? 
>> SAT_TO_CLAMP
>>  : 0)));
>> + options->EmitNoSat = (target == GL_VERTEX_PROGRAM_ARB);
>>  
>>   progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, 
>> options->EmitNoCont, options->EmitNoLoops) || progress;
> 
> NAK.  You don't get to edit ctx->Const.  It should be set up at context
> initialization time (either in core mesa or in the driver), and never
> touched after that.
> 
> You should:
> 1. Create an gl_shader_compiler_options::EmitNoSat field (hunk 2 of this 
> patch).
> 2. Set it appropriately in all relevant drivers:
>- swrast
>- r200
>- i915
>- i965
>- Gallium (st_extensions.c)
>You can skip radeon and nouveau_vieux as they don't support shaders.
> 3. Make opt_algebraic pay attention to it (hunk 1 of this patch).
> 4. Change all callers of lower_instructions with SAT_TO_CLAMP to
>use options->EmitNoSat, not target == GL_VERTEX_PROGRAM stuff.
> 
> It's unclear to me that we're making the correct decisions today - in other
> words, setting EmitNoSat /properly/ for drivers may be a change in behavior.
> 
> In particular, in commit cfa8c1cb, your st_glsl_to_tgsi.cpp hunk appears to be
> doing SAT_TO_CLAMP lowering only for vertex shaders on pipe drivers that
> *support SM3*.  It seems like you meant to do lowering for ones that
> *don't* support SM3.
> 
> Please try to get this fixed ASAP - we have a release coming up in under a
> week; we can't afford to wait two months to attend to simple regressions.
> 

Will do. Sending v2 now...

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


[Mesa-dev] [PATCH v2 1/7] ir_to_mesa: Only lower saturate to clamp when EmitNoSat is set

2014-12-01 Thread Abdiel Janulgue
Fixes an infinite loop in swrast where the lowering pass unpacks saturate into 
clamp
but the opt_algebraic pass tries to do the opposite.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83463
Signed-off-by: Abdiel Janulgue 
---
 src/mesa/main/mtypes.h  | 1 +
 src/mesa/program/ir_to_mesa.cpp | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7389baa..cee11a3 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2990,6 +2990,7 @@ struct gl_shader_compiler_options
GLboolean EmitNoMainReturn;/**< Emit CONT/RET opcodes? */
GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */
GLboolean EmitNoPow;   /**< Emit POW opcodes? */
+   GLboolean EmitNoSat;   /**< Emit SAT opcodes? */
GLboolean LowerClipDistance; /**< Lower gl_ClipDistance from float[8] to 
vec4[2]? */
 
/**
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 5cd9058..7e7aded 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2947,8 +2947,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
 lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2
 | LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP
 | ((options->EmitNoPow) ? POW_TO_EXP2 : 0)
-| ((target == GL_VERTEX_PROGRAM_ARB) ? 
SAT_TO_CLAMP
-: 0)));
+| ((options->EmitNoSat) ? SAT_TO_CLAMP : 0)));
 
 progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, 
options->EmitNoCont, options->EmitNoLoops) || progress;
 
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 4/7] dri/radeon: Don't emit saturate for vertex shaders

2014-12-01 Thread Abdiel Janulgue
Signed-off-by: Abdiel Janulgue 
---
 src/mesa/drivers/dri/r200/r200_context.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/r200/r200_context.c 
b/src/mesa/drivers/dri/r200/r200_context.c
index 931f437..8533123 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -368,6 +368,8 @@ GLboolean r200CreateContext( gl_api api,
ctx->Extensions.NV_texture_rectangle = true;
ctx->Extensions.OES_EGL_image = true;
 
+   ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoSat = true;
+
if (!(rmesa->radeon.radeonScreen->chip_flags & R200_CHIPSET_YCBCR_BROKEN)) {
  /* yuv textures don't work with some chips - R200 / rv280 okay so far
others get the bit ordering right but don't actually do YUV-RGB 
conversion */
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 6/7] i915: Don't emit saturate for vertex shaders

2014-12-01 Thread Abdiel Janulgue
Signed-off-by: Abdiel Janulgue 
---
 src/mesa/drivers/dri/i915/i915_context.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i915/i915_context.c 
b/src/mesa/drivers/dri/i915/i915_context.c
index 42ea54e..847105a 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -256,6 +256,8 @@ i915CreateContext(int api,
 */
ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitCondCodes = true;
 
+   ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoSat = true;
+
struct gl_shader_compiler_options *const fs_options =
   & ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
fs_options->MaxIfDepth = 0;
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 3/7] swrast: Don't emit saturate for vertex shaders

2014-12-01 Thread Abdiel Janulgue
Signed-off-by: Abdiel Janulgue 
---
 src/mesa/drivers/dri/swrast/swrast.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/swrast/swrast.c 
b/src/mesa/drivers/dri/swrast/swrast.c
index e8a2c12..5bd8a9b 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -793,6 +793,8 @@ dri_create_context(gl_api api,
 _mesa_initialize_dispatch_tables(mesaCtx);
 _mesa_initialize_vbo_vtxfmt(mesaCtx);
 
+mesaCtx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoSat = true;
+
 *error = __DRI_CTX_ERROR_SUCCESS;
 return GL_TRUE;
 
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 2/7] glsl: Don't optimize min/max into saturate when EmitNoSat is set

2014-12-01 Thread Abdiel Janulgue
Signed-off-by: Abdiel Janulgue 
---
 src/glsl/opt_algebraic.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 430f5cb..89fc0de 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -679,7 +679,8 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
 
case ir_binop_min:
case ir_binop_max:
-  if (ir->type->base_type != GLSL_TYPE_FLOAT)
+  if (ir->type->base_type != GLSL_TYPE_FLOAT ||
+  options->EmitNoSat)
  break;
 
   /* Replace min(max) operations and its commutative combinations with
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 5/7] st/mesa: For vertex shaders, don't emit saturate when SM 3.0 is unsupported

2014-12-01 Thread Abdiel Janulgue
There is a bug in the current lowering pass implementation where we lower 
saturate
to clamp only for vertex shaders on drivers supporting SM 3.0. The correct 
behavior
is to actually lower to clamp only when we don't support saturate which happens
on drivers that don't support SM 3.0

Signed-off-by: Abdiel Janulgue 
---
 src/mesa/state_tracker/st_context.c| 2 ++
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 5 +
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index 1723513..9da0c77 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -271,6 +271,8 @@ st_create_context_priv( struct gl_context *ctx, struct 
pipe_context *pipe,
 */
st->ctx->Point.MaxSize = MAX2(ctx->Const.MaxPointSize,
  ctx->Const.MaxPointSizeAA);
+   /* For vertex shaders, make sure not to emit saturate when SM 3.0 is not 
supported */
+   ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoSat = 
!st->has_shader_model3;
 
_mesa_compute_version(ctx);
 
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 8e91c4b..3ef7138 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5391,9 +5391,6 @@ st_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
   if (!pscreen->get_param(pscreen, PIPE_CAP_TEXTURE_GATHER_OFFSETS))
  lower_offset_arrays(ir);
   do_mat_op_to_vec(ir);
-  /* Emit saturates in the vertex shader only if SM 3.0 is supported. */
-  bool vs_sm3 = 
(_mesa_shader_stage_to_program(prog->_LinkedShaders[i]->Stage) ==
- GL_VERTEX_PROGRAM_ARB) && 
st_context(ctx)->has_shader_model3;
   lower_instructions(ir,
  MOD_TO_FRACT |
  DIV_TO_MUL_RCP |
@@ -5404,7 +5401,7 @@ st_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
  BORROW_TO_ARITH |
  (options->EmitNoPow ? POW_TO_EXP2 : 0) |
  (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0) 
|
- (vs_sm3 ? SAT_TO_CLAMP : 0));
+ (options->EmitNoSat ? SAT_TO_CLAMP : 0));
 
   lower_ubo_reference(prog->_LinkedShaders[i], ir);
   do_vec_index_to_cond_assign(ir);
-- 
1.9.1

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


[Mesa-dev] [PATCH v2 7/7] i965: Don't emit saturate for vertex shaders

2014-12-01 Thread Abdiel Janulgue
Signed-off-by: Abdiel Janulgue 
---
 src/mesa/drivers/dri/i965/brw_context.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 8b0f391..660e856 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -567,6 +567,8 @@ brw_initialize_context_constants(struct brw_context *brw)
ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true;
ctx->Const.ShaderCompilerOptions[MESA_SHADER_GEOMETRY].OptimizeForAOS = 
true;
 
+   ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoSat = true;
+
/* ARB_viewport_array */
if (brw->gen >= 7 && ctx->API == API_OPENGL_CORE) {
   ctx->Const.MaxViewports = GEN7_NUM_VIEWPORTS;
-- 
1.9.1

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


[Mesa-dev] [PATCH] mesa: removed reference to unused header

2014-12-01 Thread Albert Freeman
Removed reference to unused header file to reduce src/mesa/main dependency on
src/mesa/drivers.

Signed-off-by: Albert Freeman 
---

I do not have commit access!
No regressions with piglit (tests/quick.py).

 src/mesa/main/enable.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 417548a..fe49188 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -39,9 +39,6 @@
 #include "enums.h"
 #include "api_arrayelt.h"
 #include "texstate.h"
-#include "drivers/common/meta.h"
-
-
 
 #define CHECK_EXTENSION(EXTNAME, CAP)  \
if (!ctx->Extensions.EXTNAME) { \
-- 
2.1.3

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


Re: [Mesa-dev] [Patch v2] Mesa: Add support for GL_OES_texture_*float* extensions.

2014-12-01 Thread Brian Paul

Thanks for the updates.  A few more nitpicks...


On 11/27/2014 11:56 AM, Kalyan Kondapally wrote:

This patch adds support for following GLES2 Texture Float extensions:
1)GL_OES_texture_float,
2)GL_OES_texture_half_float,
3)GL_OES_texture_float_linear,
4)GL_OES_texture_half_float_linear.

Support for these extensions need to be explicitly enabled per driver
and this patch enables support for i965 drivers.

v2: Indentation fixes. (Brian Paul)
 Fixed Comments and added some to new private functions.(Brian Paul)
 Added assert in valid_filter_for_float.(Brian Paul)
 Renamed Float and HALF_FLOAT_OES as IsFloatOES and IsHalfFloatOES.(Brian 
Paul)
 adjust_for_oes_float_texture to return GLenum. (Brain Paul)
 Use RGB_32F internal floating point format for RGB base format.

Signed-off-by: Kevin Rogovin 
Signed-off-by: Kalyan Kondapally 
---
  src/mesa/drivers/dri/i965/intel_extensions.c |  6 +++
  src/mesa/main/extensions.c   |  4 ++
  src/mesa/main/glformats.c| 46 +--
  src/mesa/main/glformats.h|  3 +-
  src/mesa/main/mtypes.h   |  6 +++
  src/mesa/main/pack.c | 16 +++
  src/mesa/main/teximage.c | 68 +++-
  src/mesa/main/texobj.c   | 53 ++
  8 files changed, 196 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 76f..e95eaef 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -245,6 +245,12 @@ intelInitExtensions(struct gl_context *ctx)
 ctx->Extensions.OES_standard_derivatives = true;
 ctx->Extensions.OES_EGL_image_external = true;

+   bool enable_opengles2_extensions = ctx->API == API_OPENGLES2;
+   ctx->Extensions.OES_texture_float = enable_opengles2_extensions;
+   ctx->Extensions.OES_texture_half_float = enable_opengles2_extensions;
+   ctx->Extensions.OES_texture_float_linear = enable_opengles2_extensions;
+   ctx->Extensions.OES_texture_half_float_linear = enable_opengles2_extensions;
+


I think this would be nicer as:

   if (ctx->API == API_OPENGLES2) {
  ctx->Extensions.OES_texture_float = true;
  ...
   }



 if (brw->gen >= 6)
ctx->Const.GLSLVersion = 330;
 else
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 0df04c2..6833fcf 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -314,6 +314,10 @@ static const struct extension extension_table[] = {
 { "GL_OES_texture_3D",  o(EXT_texture3D),  
ES2, 2005 },
 { "GL_OES_texture_cube_map",o(ARB_texture_cube_map),   
  ES1,   2007 },
 { "GL_OES_texture_env_crossbar",
o(ARB_texture_env_crossbar), ES1,   2005 },
+   { "GL_OES_texture_float",   o(OES_texture_float),   
   ES2, 2005 },
+   { "GL_OES_texture_float_linear",
o(OES_texture_float_linear),   ES2, 2005 },
+   { "GL_OES_texture_half_float",  o(OES_texture_half_float),  
   ES2, 2005 },
+   { "GL_OES_texture_half_float_linear",   
o(OES_texture_half_float_linear),  ES2, 2005 },
 { "GL_OES_texture_mirrored_repeat", o(dummy_true), 
  ES1,   2005 },
 { "GL_OES_texture_npot",
o(ARB_texture_non_power_of_two), ES1 | ES2, 2005 },
 { "GL_OES_vertex_array_object", o(dummy_true), 
  ES1 | ES2, 2010 },
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 00478f9..c2e6c37 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -93,6 +93,7 @@ _mesa_sizeof_type(GLenum type)
 case GL_DOUBLE:
return sizeof(GLdouble);
 case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
return sizeof(GLhalfARB);
 case GL_FIXED:
return sizeof(GLfixed);
@@ -125,6 +126,7 @@ _mesa_sizeof_packed_type(GLenum type)
 case GL_INT:
return sizeof(GLint);
 case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
return sizeof(GLhalfARB);
 case GL_FLOAT:
return sizeof(GLfloat);
@@ -241,6 +243,7 @@ _mesa_bytes_per_pixel(GLenum format, GLenum type)
 case GL_FLOAT:
return comps * sizeof(GLfloat);
 case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
return comps * sizeof(GLhalfARB);
 case GL_UNSIGNED_BYTE_3_3_2:
 case GL_UNSIGNED_BYTE_2_3_3_REV:
@@ -1448,6 +1451,18 @@ _mesa_error_check_format_and_type(const struct 
gl_context *ctx,
}
return GL_NO_ERROR;

+   case GL_HALF_FLOAT_OES:
+  switch (f

Re: [Mesa-dev] [PATCH 01/13] mesa/meta: Don't free meta if it was never initialized

2014-12-01 Thread Brian Paul

On 11/28/2014 04:25 AM, Juha-Pekka Heikkila wrote:

Signed-off-by: Juha-Pekka Heikkila 
---
  src/mesa/drivers/common/meta.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 87532c1..fab360d 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -403,6 +403,9 @@ _mesa_meta_init(struct gl_context *ctx)
  void
  _mesa_meta_free(struct gl_context *ctx)
  {
+   if (!ctx->Meta)
+  return;
+
 GET_CURRENT_CONTEXT(old_context);
 _mesa_make_current(ctx, NULL, NULL);
 _mesa_meta_glsl_blit_cleanup(&ctx->Meta->Blit);


GET_CURRENT_CONTEXT declares a variable so this won't compile with MSVC.

-Brian


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


Re: [Mesa-dev] [PATCH 03/13] mesa/main: Don't go freeing texture data which was never allocated

2014-12-01 Thread Brian Paul

On 11/28/2014 04:25 AM, Juha-Pekka Heikkila wrote:

Signed-off-by: Juha-Pekka Heikkila 
---
  src/mesa/main/texstate.c | 13 +
  1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index e0f0852..7f29208 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -930,14 +930,19 @@ _mesa_free_texture_data(struct gl_context *ctx)
 }

 /* Free proxy texture objects */
-   for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++)
-  ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]);
+   for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
+  if (ctx->Texture.ProxyTex[tgt])
+ ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]);
+   }

 /* GL_ARB_texture_buffer_object */
-   _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);
+   if (ctx->Texture.BufferObject)
+  _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);

 for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
-  _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL);
+  if (ctx->Texture.Unit[u].Sampler)
+ _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler,
+NULL);
 }
  }


I don't understand those last two conditionals.  If the pointer is 
already null, calling _mesa_reference_foo() shouldn't matter, right?


-Brian


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


Re: [Mesa-dev] [PATCH 13/13] mesa/main: Verify context creation on progress

2014-12-01 Thread Brian Paul

On 11/28/2014 04:25 AM, Juha-Pekka Heikkila wrote:

Stop context creation if something failed. If something errored
during context creation we'd segfault. Now will clean up and
return error.

Signed-off-by: Juha-Pekka Heikkila 
---
  src/mesa/main/shared.c | 66 +++---
  1 file changed, 62 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index f74a823..28807c1 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -64,9 +64,21 @@ _mesa_alloc_shared_state(struct gl_context *ctx)

 mtx_init(&shared->Mutex, mtx_plain);

+   /* Mutex and timestamp for texobj state validation */
+   mtx_init(&shared->TexMutex, mtx_recursive);
+   shared->TextureStateStamp = 0;
+
 shared->DisplayList = _mesa_NewHashTable();
+   if (!shared->DisplayList)
+  goto error_out;
+
 shared->TexObjects = _mesa_NewHashTable();
+   if (!shared->TexObjects)
+  goto error_out;
+
 shared->Programs = _mesa_NewHashTable();
+   if (!shared->Programs)
+  goto error_out;

 shared->DefaultVertexProgram =
gl_vertex_program(ctx->Driver.NewProgram(ctx,
@@ -76,17 +88,28 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
   GL_FRAGMENT_PROGRAM_ARB, 0));

 shared->ATIShaders = _mesa_NewHashTable();
+   if (!shared->ATIShaders)
+  goto error_out;
+
 shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0);

 shared->ShaderObjects = _mesa_NewHashTable();
+   if (!shared->ShaderObjects)
+  goto error_out;

 shared->BufferObjects = _mesa_NewHashTable();
+   if (!shared->BufferObjects)
+  goto error_out;

 /* GL_ARB_sampler_objects */
 shared->SamplerObjects = _mesa_NewHashTable();
+   if (!shared->SamplerObjects)
+  goto error_out;

 /* Allocate the default buffer object */
 shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0);
+   if (!shared->NullBufferObj)
+   goto error_out;

 /* Create default texture objects */
 for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
@@ -112,16 +135,51 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
 /* sanity check */
 assert(shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount == 1);

-   /* Mutex and timestamp for texobj state validation */
-   mtx_init(&shared->TexMutex, mtx_recursive);
-   shared->TextureStateStamp = 0;
-
 shared->FrameBuffers = _mesa_NewHashTable();
+   if (!shared->FrameBuffers)
+  goto error_out;
+
 shared->RenderBuffers = _mesa_NewHashTable();
+   if (!shared->RenderBuffers)
+  goto error_out;

 shared->SyncObjects = _mesa_set_create(NULL, _mesa_key_pointer_equal);
+   if (!shared->SyncObjects)
+  goto error_out;

 return shared;
+
+error_out:
+   for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
+  if (shared->DefaultTex[i]) {
+ ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]);
+  }
+   }
+
+   if (shared->NullBufferObj)
+  _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL);


As before, I don't think the conditionals here are needed.



+
+
+   _mesa_DeleteHashTable(shared->RenderBuffers);
+   _mesa_DeleteHashTable(shared->FrameBuffers);
+   _mesa_DeleteHashTable(shared->SamplerObjects);
+   _mesa_DeleteHashTable(shared->BufferObjects);
+   _mesa_DeleteHashTable(shared->ShaderObjects);
+   _mesa_DeleteHashTable(shared->ATIShaders);
+   _mesa_DeleteHashTable(shared->Programs);
+   _mesa_DeleteHashTable(shared->TexObjects);
+   _mesa_DeleteHashTable(shared->DisplayList);
+
+   _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL);
+   _mesa_reference_geomprog(ctx, &shared->DefaultGeometryProgram, NULL);
+   _mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL);
+
+   mtx_destroy(&shared->Mutex);
+
+   mtx_destroy(&shared->TexMutex);
+
+   free(shared);
+   return NULL;
  }





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


Re: [Mesa-dev] [PATCH 05/10] glsl: Don't allow gl_FragData[i], with i>0 in GLES shaders

2014-12-01 Thread Matteo Bruni
2014-12-01 14:04 GMT+01:00 Eduardo Lima Mitev :
> The OpenGL ES Shading Language specification describes the
> values that may be output by a fragment shader. These are
> gl_FragColor and gl_FragData[0]. Multiple render targets
> are not supported in GLES.
>
> Fixes dEQP test:
>   * dEQP-GLES3.functional.shaders.fragdata.invalid_assign_to_1
> ---
>  src/glsl/ast_array_index.cpp | 21 -
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp
> index ff0c757..b507d34 100644
> --- a/src/glsl/ast_array_index.cpp
> +++ b/src/glsl/ast_array_index.cpp
> @@ -46,7 +46,9 @@ ast_array_specifier::print(void) const
>   *
>   * This function also checks whether the array is a built-in array whose
>   * maximum size is too small to accommodate the given index, and if so uses
> - * loc and state to report the error.
> + * loc and state to report the error. It also checks that the built-in array
> + * gl_FragData is not accessed with indexes greater than zero in OpenGL ES,
> + * where multiple render targets are not allowed.
>   */
>  static void
>  update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE *loc,
> @@ -54,6 +56,23 @@ update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE 
> *loc,
>  {
> if (ir_dereference_variable *deref_var = ir->as_dereference_variable()) {
>ir_variable *var = deref_var->var;
> +
> +  /* Page 89 in the section 3.8 (Fragment Shaders) of the the
> +   * OpenGL ES 2.0.25 spec says:
> +   * "The OpenGL ES Shading Language specification describes the
> +   * values that may be output by a fragment shader. These are
> +   * gl_FragColor and gl_FragData[0].
> +   *  ...
> +   * gl_FragData is supported for compatibility with the desktop
> +   * OpenGL Shading Language, but only a single fragment color
> +   * output is allowed in the OpenGL ES Shading Language."
> +   */
> +  if (state->es_shader && idx > 0 &&
> +  strcmp(var->name, "gl_FragData") == 0) {
> + _mesa_glsl_error(loc, state,
> +  "multiple render targets are not supported");
> +  }
> +
>if (idx > (int)var->data.max_array_access) {
>   var->data.max_array_access = idx;
>
> --
> 2.1.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

AFAICS this restriction is lifted in ES 3.0+ (e.g. see section 3.9.2
in the OpenGL ES 3.0 spec).
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 09/29] mesa: Add _mesa_swap2_copy and _mesa_swap4_copy

2014-12-01 Thread Brian Paul

On 12/01/2014 04:05 AM, Iago Toral Quiroga wrote:

We have _mesa_swap{2,4} but these do in-place byte-swapping only. The new
functions receive an extra parameter so we can swap bytes on a source
input array and store the results in a (possibly different) destination
array.

This is useful to implement byte-swapping in pixel uploads, since in this
case we need to swap bytes on the src data which is owned by the
application so we can't do an in-place byte swap.
---
  src/mesa/main/image.c | 25 +
  src/mesa/main/image.h | 10 --
  2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 4ea5f04..9ad97c5 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -41,36 +41,45 @@


  /**
- * Flip the order of the 2 bytes in each word in the given array.
+ * Flip the order of the 2 bytes in each word in the given array (src) and
+ * store the result in another array (dst). For in-place byte-swapping this
+ * function can be called with the same array for src and dst.
   *
- * \param p array.
+ * \param dst the array where byte-swapped data will be stored.
+ * \param src the array with the source data we want to byte-swap.
   * \param n number of words.
   */
  void
-_mesa_swap2( GLushort *p, GLuint n )
+_mesa_swap2_copy( GLushort *dst, GLushort *src, GLuint n )
  {
 GLuint i;
 for (i = 0; i < n; i++) {
-  p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00);
+  dst[i] = (src[i] >> 8) | ((src[i] << 8) & 0xff00);
 }
  }



  /*
- * Flip the order of the 4 bytes in each word in the given array.
+ * Flip the order of the 4 bytes in each word in the given array (src) and
+ * store the result in another array (dst). For in-place byte-swapping this
+ * function can be called with the same array for src and dst.
+ *
+ * \param dst the array where byte-swapped data will be stored.
+ * \param src the array with the source data we want to byte-swap.
+ * \param n number of words.
   */
  void
-_mesa_swap4( GLuint *p, GLuint n )
+_mesa_swap4_copy( GLuint *dst, GLuint *src, GLuint n )
  {
 GLuint i, a, b;
 for (i = 0; i < n; i++) {
-  b = p[i];
+  b = src[i];
a =  (b >> 24)
| ((b >> 8) & 0xff00)
| ((b << 8) & 0xff)
| ((b << 24) & 0xff00);
-  p[i] = a;
+  dst[i] = a;
 }
  }

diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index abd84bf..79c6e68 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -33,10 +33,16 @@ struct gl_context;
  struct gl_pixelstore_attrib;

  extern void
-_mesa_swap2( GLushort *p, GLuint n );
+_mesa_swap2_copy( GLushort *dst, GLushort *src, GLuint n );

  extern void
-_mesa_swap4( GLuint *p, GLuint n );
+_mesa_swap4_copy( GLuint *dst, GLuint *src, GLuint n );
+
+static inline void
+_mesa_swap2( GLushort *p, GLuint n ) { _mesa_swap2_copy(p, p, n); }


I'd prefer to see these functions formatted normally:

static inline void
_mesa_swap2(GLushort *p, GLuint n)
{
   _mesa_swap2_copy(p, p, n);
}



+
+static inline void
+_mesa_swap4( GLuint *p, GLuint n ) { _mesa_swap4_copy(p, p, n); }

  extern GLintptr
  _mesa_image_offset( GLuint dimensions,



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


Re: [Mesa-dev] [PATCH 04/10] mesa: Recompute LegalTypesMask if the GL API has changed

2014-12-01 Thread Brian Paul

On 12/01/2014 06:04 AM, Eduardo Lima Mitev wrote:

From: Iago Toral Quiroga 

The current code computes ctx->Array.LegalTypesMask just once,
however, computing this needs to consider ctx->API so we need
to make sure that the API for that context has not changed if
we intend to reuse the result.

The context API can change, at least, if we go through
_mesa_meta_begin, since that will always force
API_OPENGL_COMPAT until we call _mesa_meta_end. If any
operation in between these two calls triggers a call to
update_array_format, then we might be caching a value for
LegalTypesMask that will not be right once we have called
_mesa_meta_end and restored the context API.

Fixes the following 179 dEQP tests in i965:
dEQP-GLES3.functional.vertex_arrays.single_attribute.strides.fixed.*
dEQP-GLES3.functional.vertex_arrays.single_attribute.normalize.fixed.*
dEQP-GLES3.functional.vertex_arrays.single_attribute.output_types.fixed.*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.static_draw.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.stream_draw.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.dynamic_draw.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.static_copy.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.stream_copy.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.dynamic_copy.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.static_read.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.stream_read.*fixed*
dEQP-GLES3.functional.vertex_arrays.single_attribute.usages.dynamic_read.*fixed*
dEQP-GLES3.functional.vertex_arrays.multiple_attributes.input_types.3_*fixed2*
dEQP-GLES3.functional.draw.random.{2,18,28,68,83,106,109,156,181,191}
---
  src/mesa/main/mtypes.h | 3 ++-
  src/mesa/main/varray.c | 3 ++-
  2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7389baa..78f034d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1701,8 +1701,9 @@ struct gl_array_attrib
 /** One of the DRAW_xxx flags, not consumed by drivers */
 gl_draw_method DrawMethod;

-   /** Legal array datatypes */
+   /** Legal array datatypes and the API for which they have been computed */
 GLbitfield LegalTypesMask;
+   int LegalTypesMaskAPI;


gl_api LegalTypesMaskAPI;



  };


diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 96c2b26..acfc4bd 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -258,11 +258,12 @@ update_array_format(struct gl_context *ctx,
 GLuint elementSize;
 GLenum format = GL_RGBA;

-   if (ctx->Array.LegalTypesMask == 0) {
+   if (ctx->Array.LegalTypesMask == 0 || ctx->Array.LegalTypesMaskAPI != 
ctx->API) {
/* One-time initialization.  We can't do this in _mesa_init_varrays()
 * below because extensions are not yet enabled at that point.
 */


Should probably update the comment to say something like:

"Compute the LegalTypesMask if it's uninitialized or the context API 
changes."




ctx->Array.LegalTypesMask = get_legal_types_mask(ctx);
+  ctx->Array.LegalTypesMaskAPI = ctx->API;
 }

 legalTypesMask &= ctx->Array.LegalTypesMask;



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


Re: [Mesa-dev] [PATCH 09/10] main/glsles: return two minor digits for SHADING_LANGUAGE_VERSION

2014-12-01 Thread Brian Paul
I'd change the subject to "main: return two minor digits for ES shading 
language version"



On 12/01/2014 06:04 AM, Eduardo Lima Mitev wrote:

From: Samuel Iglesias Gonsalvez 

For OpenGL ES 3.0 spec, the minor number for SHADING_LANGUAGE_VERSION is always
two digits, matching the OpenGL ES Shading Language Specification release
number. For example, this query might return the string "3.00".

This patch fixes the following dEQP test:

dEQP-GLES3.functional.state_query.string.shading_language_version

No piglit regression observed.

Signed-off-by: Samuel Iglesias Gonsalvez 
---
  src/mesa/main/getstring.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index 431d60b..7054fc7 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -68,7 +68,7 @@ shading_language_version(struct gl_context *ctx)
 case API_OPENGLES2:
return (ctx->Version < 30)
   ? (const GLubyte *) "OpenGL ES GLSL ES 1.0.16"
- : (const GLubyte *) "OpenGL ES GLSL ES 3.0";
+ : (const GLubyte *) "OpenGL ES GLSL ES 3.00";

 case API_OPENGLES:
/* fall-through */



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


Re: [Mesa-dev] [PATCH 00/10] Various fixes for dEQP failing tests

2014-12-01 Thread Brian Paul

On 12/01/2014 06:04 AM, Eduardo Lima Mitev wrote:

This set of (unrelated) patches fixes over 230 tests from the dEQP test suite 
[1].
While the tests failures were gathered on i965 (gen8) against 10.3.3, there are 
several driver and version agnostic fixes.

There is one piglit regression brought by patch 10 , specifically in test:

bin/glslparsertest \
 tests/spec/glsl-1.50/compiler/gs-also-uses-smooth-flat-noperspective.geom 
pass \
 1.50 --check-link

The piglit test seems to be wrong in this case because it contradicts the spec, 
please check that commit's log for details. It would be good to hear other 
people's comments on this in case we are missing something.

The plan is to continue sending these random fixes in batches like this one, 
with the purpose of improving the pass rate of dEQP tests against Mesa.

Eduardo Lima

[1] 
https://urldefense.proofpoint.com/v2/url?u=https-3A__android.googlesource.com_platform_external_deqp_&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=fAE0uqehtpO4ulnoKJnU_Eg9a2TCw24OVXuq_gLWGbM&s=45bTrgaG9RYA41Cln3IrEM3mgeyiZmCYRGndRq3Ovy0&e=

Patch summary:

Eduardo Lima Mitev (4):
   mesa: Considers GL_DEPTH_STENCIL_ATTACHMENT a valid argument for FBO
 invalidation under GLES3
   mesa: Enables GL_RGB and GL_RGBA unsized internal formats for OpenGL
 ES 3.0
   mesa: Returns zero samples when querying GL_NUM_SAMPLE_COUNTS when
 internal format is integer
   glsl: Don't allow gl_FragData[i], with i>0 in GLES shaders

Iago Toral Quiroga (1):
   mesa: Recompute LegalTypesMask if the GL API has changed

Samuel Iglesias Gonsalvez (5):
   glsl: invariant qualifier is not valid for shader inputs in GLSL ES
 3.00
   glsl: don't allow invariant qualifiers for interface blocks in GLSL ES
   glsl: A shader cannot redefine or overload built-in functions in GLSL
 ES 3.00
   main/glsles: return two minor digits for SHADING_LANGUAGE_VERSION
   glsl: fail when a shader's input var has not an equivalent out var in
 previous

  src/glsl/ast_array_index.cpp   | 21 +++-
  src/glsl/ast_to_hir.cpp| 22 +
  src/glsl/builtin_functions.cpp | 11 +++
  src/glsl/glsl_parser.yy| 27 ++
  src/glsl/ir.h  |  4 
  src/glsl/link_varyings.cpp | 18 -
  src/mesa/main/fbobject.c   |  8 
  src/mesa/main/formatquery.c| 44 ++
  src/mesa/main/getstring.c  |  2 +-
  src/mesa/main/mtypes.h |  3 ++-
  src/mesa/main/varray.c |  3 ++-
  11 files changed, 141 insertions(+), 22 deletions(-)



The non-GLSL changes look good to me and are: Reviewed-by: Brian Paul 



The GLSL changes look OK too but should probably be reviewed by someone 
more active in that area.


-Brian

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


Re: [Mesa-dev] [Patch v2] Mesa: Add support for GL_OES_texture_*float* extensions.

2014-12-01 Thread kalyan kondapally
>>I think this would be nicer as:

  >> if (ctx->API == API_OPENGLES2) {
>>  ctx->Extensions.OES_texture_fl

>> The indentation of the new lines there looks inconsistent.

I sent v3 which already has the fixes.


On Mon, Dec 1, 2014 at 7:34 AM, Brian Paul  wrote:
> Thanks for the updates.  A few more nitpicks...
>
>
>
> On 11/27/2014 11:56 AM, Kalyan Kondapally wrote:
>>
>> This patch adds support for following GLES2 Texture Float extensions:
>> 1)GL_OES_texture_float,
>> 2)GL_OES_texture_half_float,
>> 3)GL_OES_texture_float_linear,
>> 4)GL_OES_texture_half_float_linear.
>>
>> Support for these extensions need to be explicitly enabled per driver
>> and this patch enables support for i965 drivers.
>>
>> v2: Indentation fixes. (Brian Paul)
>>  Fixed Comments and added some to new private functions.(Brian Paul)
>>  Added assert in valid_filter_for_float.(Brian Paul)
>>  Renamed Float and HALF_FLOAT_OES as IsFloatOES and
>> IsHalfFloatOES.(Brian Paul)
>>  adjust_for_oes_float_texture to return GLenum. (Brain Paul)
>>  Use RGB_32F internal floating point format for RGB base format.
>>
>> Signed-off-by: Kevin Rogovin 
>> Signed-off-by: Kalyan Kondapally 
>> ---
>>   src/mesa/drivers/dri/i965/intel_extensions.c |  6 +++
>>   src/mesa/main/extensions.c   |  4 ++
>>   src/mesa/main/glformats.c| 46 +--
>>   src/mesa/main/glformats.h|  3 +-
>>   src/mesa/main/mtypes.h   |  6 +++
>>   src/mesa/main/pack.c | 16 +++
>>   src/mesa/main/teximage.c | 68
>> +++-
>>   src/mesa/main/texobj.c   | 53 ++
>>   8 files changed, 196 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c
>> b/src/mesa/drivers/dri/i965/intel_extensions.c
>> index 76f..e95eaef 100644
>> --- a/src/mesa/drivers/dri/i965/intel_extensions.c
>> +++ b/src/mesa/drivers/dri/i965/intel_extensions.c
>> @@ -245,6 +245,12 @@ intelInitExtensions(struct gl_context *ctx)
>>  ctx->Extensions.OES_standard_derivatives = true;
>>  ctx->Extensions.OES_EGL_image_external = true;
>>
>> +   bool enable_opengles2_extensions = ctx->API == API_OPENGLES2;
>> +   ctx->Extensions.OES_texture_float = enable_opengles2_extensions;
>> +   ctx->Extensions.OES_texture_half_float = enable_opengles2_extensions;
>> +   ctx->Extensions.OES_texture_float_linear =
>> enable_opengles2_extensions;
>> +   ctx->Extensions.OES_texture_half_float_linear =
>> enable_opengles2_extensions;
>> +
>
>
> I think this would be nicer as:
>
>if (ctx->API == API_OPENGLES2) {
>   ctx->Extensions.OES_texture_float = true;
>   ...
>
>}
>
>
>>  if (brw->gen >= 6)
>> ctx->Const.GLSLVersion = 330;
>>  else
>> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
>> index 0df04c2..6833fcf 100644
>> --- a/src/mesa/main/extensions.c
>> +++ b/src/mesa/main/extensions.c
>> @@ -314,6 +314,10 @@ static const struct extension extension_table[] = {
>>  { "GL_OES_texture_3D",  o(EXT_texture3D),
>> ES2, 2005 },
>>  { "GL_OES_texture_cube_map",
>> o(ARB_texture_cube_map), ES1,   2007 },
>>  { "GL_OES_texture_env_crossbar",
>> o(ARB_texture_env_crossbar), ES1,   2005 },
>> +   { "GL_OES_texture_float",   o(OES_texture_float),
>> ES2, 2005 },
>> +   { "GL_OES_texture_float_linear",
>> o(OES_texture_float_linear),   ES2, 2005 },
>> +   { "GL_OES_texture_half_float",
>> o(OES_texture_half_float), ES2, 2005 },
>> +   { "GL_OES_texture_half_float_linear",
>> o(OES_texture_half_float_linear),  ES2, 2005 },
>>  { "GL_OES_texture_mirrored_repeat", o(dummy_true),
>> ES1,   2005 },
>>  { "GL_OES_texture_npot",
>> o(ARB_texture_non_power_of_two), ES1 | ES2, 2005 },
>>  { "GL_OES_vertex_array_object", o(dummy_true),
>> ES1 | ES2, 2010 },
>> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
>> index 00478f9..c2e6c37 100644
>> --- a/src/mesa/main/glformats.c
>> +++ b/src/mesa/main/glformats.c
>> @@ -93,6 +93,7 @@ _mesa_sizeof_type(GLenum type)
>>  case GL_DOUBLE:
>> return sizeof(GLdouble);
>>  case GL_HALF_FLOAT_ARB:
>> +   case GL_HALF_FLOAT_OES:
>> return sizeof(GLhalfARB);
>>  case GL_FIXED:
>> return sizeof(GLfixed);
>> @@ -125,6 +126,7 @@ _mesa_sizeof_packed_type(GLenum type)
>>  case GL_INT:
>> return sizeof(GLint);
>>  case GL_HALF_FLOAT_ARB:
>> +   case GL_HALF_FLOAT_OES:
>> return sizeof(GLhalfARB);
>>  case GL_FLOAT:
>> return sizeof(GLfloat);
>> @@ -241,6 +243,7 @@ _mesa_bytes_per_pixel(GLenum format, GLenum type)
>>  case GL_FLOAT:
>> return comps * sizeof(GLfloat);
>>

Re: [Mesa-dev] [PATCH 2/2] st/nine: Fix vertex declarations for non-standard (usage/index)

2014-12-01 Thread Ilia Mirkin
On Thu, Nov 27, 2014 at 5:13 AM, Axel Davy  wrote:
> Nine code to match vertex declaration to vs inputs was limiting
> the number of possible combinations.
>
> Some sm3 games have issues with that, because arbitrary (usage/index)
> can be used.
>
> This patch does the following changes to fix the problem:
> . Change the numbers given to (usage/index) combinations to uint16
> . Do not put limits on the indices when it doesn't make sense
> . change the conversion rule (usage/index) -> number to fit all combinations
> . Instead of having a table usage_map mapping a (usage/index) number to
> an input index, usage_map maps input indices to their (usage/index)
>
> Cc: "10.4" 
> Tested-by: Yaroslav Andrusyak 
> Signed-off-by: Axel Davy 
> ---
>  src/gallium/state_trackers/nine/nine_defines.h | 40 ++-
>  src/gallium/state_trackers/nine/nine_ff.c  | 49 +++--
>  src/gallium/state_trackers/nine/nine_shader.h  |  2 +-
>  src/gallium/state_trackers/nine/nine_state.c   | 16 +++--
>  .../state_trackers/nine/vertexdeclaration9.c   | 84 
> +++---
>  .../state_trackers/nine/vertexdeclaration9.h   |  4 +-
>  src/gallium/state_trackers/nine/vertexshader9.h|  2 +-
>  7 files changed, 89 insertions(+), 108 deletions(-)
>
> diff --git a/src/gallium/state_trackers/nine/nine_defines.h 
> b/src/gallium/state_trackers/nine/nine_defines.h
> index aa3b257..06529da 100644
> --- a/src/gallium/state_trackers/nine/nine_defines.h
> +++ b/src/gallium/state_trackers/nine/nine_defines.h
> @@ -30,25 +30,27 @@
>  #define NINE_RESOURCE_FLAG_DUMMY(PIPE_RESOURCE_FLAG_ST_PRIV << 2)
>
>  /* vertexdeclaration9.c */
> -unsigned nine_d3d9_to_nine_declusage(unsigned usage, unsigned index);
> -
> -#define NINE_DECLUSAGE_POSITION(i) ( 0 + (i))
> -#define NINE_DECLUSAGE_BLENDWEIGHT(i)  ( 5 + (i))
> -#define NINE_DECLUSAGE_BLENDINDICES(i) ( 9 + (i))
> -#define NINE_DECLUSAGE_NORMAL(i)   (13 + (i))
> -#define NINE_DECLUSAGE_PSIZE15
> -#define NINE_DECLUSAGE_TEXCOORD(i) (16 + (i))
> -#define NINE_DECLUSAGE_TANGENT(i)  (32 + (i))
> -#define NINE_DECLUSAGE_BINORMAL(i) (34 + (i))
> -#define NINE_DECLUSAGE_TESSFACTOR   36
> -#define NINE_DECLUSAGE_POSITIONT37
> -#define NINE_DECLUSAGE_COLOR(i)(38 + (i))
> -#define NINE_DECLUSAGE_DEPTH43
> -#define NINE_DECLUSAGE_FOG  44
> -#define NINE_DECLUSAGE_SAMPLE   45
> -#define NINE_DECLUSAGE_NONE 46
> -#define NINE_DECLUSAGE_LAST NINE_DECLUSAGE_NONE
> -#define NINE_DECLUSAGE_COUNT   (NINE_DECLUSAGE_LAST + 1)
> +uint16_t nine_d3d9_to_nine_declusage(unsigned usage, unsigned index);
> +
> +#define NINE_DECLUSAGE_POSITION 0
> +#define NINE_DECLUSAGE_BLENDWEIGHT  1
> +#define NINE_DECLUSAGE_BLENDINDICES 2
> +#define NINE_DECLUSAGE_NORMAL   3
> +#define NINE_DECLUSAGE_TEXCOORD 4
> +#define NINE_DECLUSAGE_TANGENT  5
> +#define NINE_DECLUSAGE_BINORMAL 6
> +#define NINE_DECLUSAGE_COLOR7
> +#define NINE_DECLUSAGE_POSITIONT8
> +
> +#define NINE_DECLUSAGE_PSIZE9
> +#define NINE_DECLUSAGE_TESSFACTOR   10
> +#define NINE_DECLUSAGE_DEPTH11
> +#define NINE_DECLUSAGE_FOG  12
> +#define NINE_DECLUSAGE_SAMPLE   13
> +#define NINE_DECLUSAGE_NONE 14
> +#define NINE_DECLUSAGE_BASE (NINE_DECLUSAGE_NONE + 1)

I'd call it NINE_DECLUSAGE_COUNT (as it was called before). BASE can
have many different meanings -- the numerical base (like base 2) as
you're using, or the start, or probably other things. Count is
unambiguous.

I won't pretend to having looked at this whole patch with a high level
of attention, but the concept seems fine in principle. Series is
Acked-by: Ilia Mirkin 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] i965: Don't treat IF or WHILE with cmod as writing the flag.

2014-12-01 Thread Matt Turner
---
These are a couple of fixes from a Jenkins run of my flagdce branch.

 src/mesa/drivers/dri/i965/brw_fs.cpp | 4 +++-
 src/mesa/drivers/dri/i965/brw_vec4.h | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 028eff2..37015ec 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -933,7 +933,9 @@ fs_inst::reads_flag() const
 bool
 fs_inst::writes_flag() const
 {
-   return (conditional_mod && opcode != BRW_OPCODE_SEL) ||
+   return (conditional_mod && (opcode != BRW_OPCODE_SEL &&
+   opcode != BRW_OPCODE_IF &&
+   opcode != BRW_OPCODE_WHILE)) ||
   opcode == FS_OPCODE_MOV_DISPATCH_TO_FLAGS;
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 7d814ca..abdab99 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -234,7 +234,9 @@ public:
 
bool writes_flag()
{
-  return conditional_mod && opcode != BRW_OPCODE_SEL;
+  return (conditional_mod && (opcode != BRW_OPCODE_SEL &&
+  opcode != BRW_OPCODE_IF &&
+  opcode != BRW_OPCODE_WHILE));
}
 };
 
-- 
2.0.4

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


[Mesa-dev] [PATCH 2/2] i965/fs: Treat the FB_WRITE as predicated if we're discarding.

2014-12-01 Thread Matt Turner
Pre-Haswell hardware couldn't actually predicate it, but it's easier to
pretend as if it's predicated in the visitor since it will generate a
MOV from f0.1.
---
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 4 
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 8d3f093..bbed4cc 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -163,6 +163,10 @@ fs_generator::generate_fb_write(fs_inst *inst, struct 
brw_reg payload)
const brw_wm_prog_key * const key = (brw_wm_prog_key * const) this->key;
struct brw_reg implied_header;
 
+   if (brw->gen < 8 && !brw->is_haswell) {
+  brw_set_default_predicate_control(p, BRW_PREDICATE_NONE);
+   }
+
if (inst->base_mrf >= 0)
   payload = brw_message_reg(inst->base_mrf);
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 0b62496..cc12e48 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -3334,7 +3334,7 @@ fs_visitor::emit_single_fb_write(fs_reg color0, fs_reg 
color1,
 
write->mlen = load->regs_written;
write->header_present = header_present;
-   if ((brw->gen >= 8 || brw->is_haswell) && prog_data->uses_kill) {
+   if (prog_data->uses_kill) {
   write->predicate = BRW_PREDICATE_NORMAL;
   write->flag_subreg = 1;
}
-- 
2.0.4

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


Re: [Mesa-dev] [PATCH v2 08/23] mesa: Fix _mesa_swizzle_and_convert integer conversions to clamp properly

2014-12-01 Thread Jason Ekstrand
This looks much better.  Two comments though.  First, I think we need to
tweak the float_to_uint function to clamp above.  I don't know that it
properly handles values larger than MAX_UINT right now.  Second, I think we
may want a MIN_INT macro for this.  In particular, I don't know that this
is well-defined to work for dst_size == 32 because a signed shift by 31
isn't well-defined according to the C spec.

With those two fixed, this one is Reviewed-by: Jason Ekstrand <
jason.ekstr...@intel.com>
--Jason

On Mon, Dec 1, 2014 at 3:04 AM, Iago Toral Quiroga 
wrote:

> From: Samuel Iglesias Gonsalvez 
>
> Fix various conversion paths that involved integer data types of different
> sizes (uint16_t to uint8_t, int16_t to uint8_t, etc) that were not
> being clamped properly.
>
> Also, one of the paths was incorrectly assigning the value 12, instead of
> 1,
> to the constant "one".
>
> v2:
> - Create auxiliary clamping functions and use them in all paths that
>   required clamp because of different source and destination sizes
>   and signed-unsigned conversions.
>
> Signed-off-by: Samuel Iglesias Gonsalvez 
> ---
>  src/mesa/main/format_utils.c | 47
> ++--
>  src/mesa/main/format_utils.h | 25 +++
>  2 files changed, 48 insertions(+), 24 deletions(-)
>
> diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
> index 41fd043..dc63e1f 100644
> --- a/src/mesa/main/format_utils.c
> +++ b/src/mesa/main/format_utils.c
> @@ -449,7 +449,6 @@ convert_half_float(void *void_dst, int
> num_dst_channels,
> }
>  }
>
> -
>  static void
>  convert_ubyte(void *void_dst, int num_dst_channels,
>const void *void_src, GLenum src_type, int num_src_channels,
> @@ -469,7 +468,7 @@ convert_ubyte(void *void_dst, int num_dst_channels,
>if (normalized) {
>   SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_half_to_unorm(src, 8));
>} else {
> - SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_uint(src));
> + SWIZZLE_CONVERT(uint8_t, uint16_t,
> _mesa_unsigned_to_unsigned(half_to_uint(src), 8));
>}
>break;
> case GL_UNSIGNED_BYTE:
> @@ -479,35 +478,35 @@ convert_ubyte(void *void_dst, int num_dst_channels,
>if (normalized) {
>   SWIZZLE_CONVERT(uint8_t, int8_t, _mesa_snorm_to_unorm(src, 8,
> 8));
>} else {
> - SWIZZLE_CONVERT(uint8_t, int8_t, (src < 0) ? 0 : src);
> + SWIZZLE_CONVERT(uint8_t, int8_t, _mesa_signed_to_unsigned(src,
> 8));
>}
>break;
> case GL_UNSIGNED_SHORT:
>if (normalized) {
>   SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_unorm_to_unorm(src, 16,
> 8));
>} else {
> - SWIZZLE_CONVERT(uint8_t, uint16_t, src);
> + SWIZZLE_CONVERT(uint8_t, uint16_t,
> _mesa_unsigned_to_unsigned(src, 8));
>}
>break;
> case GL_SHORT:
>if (normalized) {
>   SWIZZLE_CONVERT(uint8_t, int16_t, _mesa_snorm_to_unorm(src, 16,
> 8));
>} else {
> - SWIZZLE_CONVERT(uint8_t, int16_t, (src < 0) ? 0 : src);
> + SWIZZLE_CONVERT(uint8_t, int16_t, _mesa_signed_to_unsigned(src,
> 8));
>}
>break;
> case GL_UNSIGNED_INT:
>if (normalized) {
>   SWIZZLE_CONVERT(uint8_t, uint32_t, _mesa_unorm_to_unorm(src, 32,
> 8));
>} else {
> - SWIZZLE_CONVERT(uint8_t, uint32_t, src);
> + SWIZZLE_CONVERT(uint8_t, uint32_t,
> _mesa_unsigned_to_unsigned(src, 8));
>}
>break;
> case GL_INT:
>if (normalized) {
>   SWIZZLE_CONVERT(uint8_t, int32_t, _mesa_snorm_to_unorm(src, 32,
> 8));
>} else {
> - SWIZZLE_CONVERT(uint8_t, int32_t, (src < 0) ? 0 : src);
> + SWIZZLE_CONVERT(uint8_t, int32_t, _mesa_signed_to_unsigned(src,
> 8));
>}
>break;
> default:
> @@ -542,7 +541,7 @@ convert_byte(void *void_dst, int num_dst_channels,
>if (normalized) {
>   SWIZZLE_CONVERT(int8_t, uint8_t, _mesa_unorm_to_snorm(src, 8,
> 8));
>} else {
> - SWIZZLE_CONVERT(int8_t, uint8_t, src);
> + SWIZZLE_CONVERT(int8_t, uint8_t, _mesa_unsigned_to_signed(src,
> 8));
>}
>break;
> case GL_BYTE:
> @@ -552,28 +551,28 @@ convert_byte(void *void_dst, int num_dst_channels,
>if (normalized) {
>   SWIZZLE_CONVERT(int8_t, uint16_t, _mesa_unorm_to_snorm(src, 16,
> 8));
>} else {
> - SWIZZLE_CONVERT(int8_t, uint16_t, src);
> + SWIZZLE_CONVERT(int8_t, uint16_t, _mesa_unsigned_to_signed(src,
> 8));
>}
>break;
> case GL_SHORT:
>if (normalized) {
>   SWIZZLE_CONVERT(int8_t, int16_t, _mesa_snorm_to_snorm(src, 16,
> 8));
>} else {
> - SWIZZLE_CONVERT(int8_t, int16_t, src);
> + SWIZZLE_CONVERT(int8_t, int16_t, _mesa_signed_to_signed(src, 8));
>}
>break;
> case GL_UNSIGNED_INT:
>if (normalized) {
>   SWIZZLE_CONVERT(in

Re: [Mesa-dev] [PATCH v2 06/23] mesa: Fix incorrect assertion in init_teximage_fields_ms

2014-12-01 Thread Jason Ekstrand
On Mon, Dec 1, 2014 at 3:04 AM, Iago Toral Quiroga 
wrote:

> _BaseFormat is a GLenum (unsigned int) so testing if its value is
> greater than 0 to detect the cases where _mesa_base_tex_format
> returns -1 doesn't work.
>
> Fixing the assertion breaks the arb_texture_view-lifetime-format
> piglit test on nouveau, since that test calls
> _mesa_base_tex_format with GL_R16F with a context that does not
> have ARB_texture_float, so it returns -1 for the BaseFormat, which
> was not being catched properly by the ASSERT in init_teximage_fields_ms
> until now.
>

Reviewed-by: Jason Ekstrand 

---
>  src/mesa/main/teximage.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index e238863..c9658c1 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1313,7 +1313,7 @@ init_teximage_fields_ms(struct gl_context *ctx,
>
> target = img->TexObject->Target;
> img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
> -   ASSERT(img->_BaseFormat > 0);
> +   ASSERT(img->_BaseFormat != -1);
> img->InternalFormat = internalFormat;
> img->Border = border;
> img->Width = width;
> --
> 1.9.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 11/23] mesa: Let _mesa_get_format_base_format also handle mesa_array_format.

2014-12-01 Thread Jason Ekstrand
On Mon, Dec 1, 2014 at 3:04 AM, Iago Toral Quiroga 
wrote:

> If we need the base format for a mesa_array_format we have to find the
> matching mesa_format first. This is expensive because it requires
> to loop through all existing mesa formats until we find the right match.
>
> We can resolve the base format of an array format directly by looking
> at its swizzle information. Also, we can have _mesa_get_format_base_format
> accept an uint32_t which can pack either a mesa_format or a
> mesa_array_format
> and resolve the base format for either type. This way clients do not need
> to
> check if they have a mesa_format or a mesa_array_format and call different
> functions depending on the case.
>
> Another reason to resolve the base format for array formats directly is
> that
> we don't have matching mesa_format enums for every possible array format,
> so
> for some GL format/type combinations we can produce array formats that
> don't
> have a corresponding mesa format, in which case we would not be able to
> find the base format. Example format=GL_RGB, type=GL_UNSIGNED_SHORT. This
> type
> would map to something like MESA_FORMAT_RGB_UNORM16, but we don't have
> that.
> ---
>  src/mesa/main/formats.c | 69
> ++---
>  src/mesa/main/formats.h |  2 +-
>  2 files changed, 67 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
> index f86925e..05b6aea 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -214,17 +214,80 @@ _mesa_get_format_datatype(mesa_format format)
> return info->DataType;
>  }
>
> +static GLenum
> +get_base_format_for_array_format(mesa_array_format format)
> +{
> +   switch (format.num_channels) {
> +   case 4:
> +  /* FIXME: RGBX formats have 4 channels, but their base format is
> GL_RGB.
> +   * This is not really a problem for now because we only create array
> +   * formats from GL format/type combinations, and these cannot
> specify
> +   * RGBX formats.
> +   */
> +  return GL_RGBA;
> +   case 3:
> +  return GL_RGB;
> +   case 2:
> +  if (format.swizzle_x == 0 &&
> +  format.swizzle_y == 0 &&
> +  format.swizzle_z == 0 &&
> +  format.swizzle_w == 1)
> + return GL_LUMINANCE_ALPHA;
> +  if (format.swizzle_x == 1 &&
> +  format.swizzle_y == 1 &&
> +  format.swizzle_z == 1 &&
> +  format.swizzle_w == 0)
> + return GL_LUMINANCE_ALPHA;
> +  if (format.swizzle_x == 0 &&
> +  format.swizzle_y == 1 &&
> +  format.swizzle_z == 4 &&
> +  format.swizzle_w == 5)
> + return GL_RG;
> +  if (format.swizzle_x == 1 &&
> +  format.swizzle_y == 0 &&
> +  format.swizzle_z == 4 &&
> +  format.swizzle_w == 5)
> + return GL_RG;
> +  break;
> +   case 1:
> +  if (format.swizzle_x == 0 &&
> +  format.swizzle_y == 0 &&
> +  format.swizzle_z == 0 &&
> +  format.swizzle_w == 5)
> + return GL_LUMINANCE;
> +  if (format.swizzle_x == 0 &&
> +  format.swizzle_y == 0 &&
> +  format.swizzle_z == 0 &&
> +  format.swizzle_w == 0)
> + return GL_INTENSITY;
> +  if (format.swizzle_x <= MESA_FORMAT_SWIZZLE_W)
> + return GL_RED;
> +  if (format.swizzle_y <= MESA_FORMAT_SWIZZLE_W)
> + return GL_GREEN;
> +  if (format.swizzle_z <= MESA_FORMAT_SWIZZLE_W)
> + return GL_BLUE;
> +  if (format.swizzle_w <= MESA_FORMAT_SWIZZLE_W)
> + return GL_ALPHA;
> +  break;
> +   }
> +   assert(!"Unsupported format");
> +}
>
>  /**
>   * Return the basic format for the given type.  The result will be one of
>   * GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
> GL_INTENSITY,
>   * GL_YCBCR_MESA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
> + * This functions accepts a mesa_format or a mesa_array_format.
>   */
>  GLenum
> -_mesa_get_format_base_format(mesa_format format)
> +_mesa_get_format_base_format(uint32_t format)
>  {
> -   const struct gl_format_info *info = _mesa_get_format_info(format);
> -   return info->BaseFormat;
> +   if (!(format & MESA_ARRAY_FORMAT_BIT)) {
> +  const struct gl_format_info *info = _mesa_get_format_info(format);
> +  return info->BaseFormat;
> +   } else {
> +  return get_base_format_for_array_format((mesa_array_format) format);
>

I'm kind of surprised that this cast even works.  Let's make a temporary
variable somewhere and use the union the way it was intended.  With that
changed,
Reviewed-by 


> +   }
>  }
>
>
> diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
> index 8b62788..cba12dc 100644
> --- a/src/mesa/main/formats.h
> +++ b/src/mesa/main/formats.h
> @@ -517,7 +517,7 @@ extern GLenum
>  _mesa_get_format_datatype(mesa_format format);
>
>  extern GLenum
> -_mesa_get_format_base_format(mesa_format format);
> +_mesa_get_format_base_format(uint32_t form

Re: [Mesa-dev] [PATCH] i965: Make validate_reg tables constant

2014-12-01 Thread Matt Turner
On Mon, Dec 1, 2014 at 4:59 AM, Juha-Pekka Heikkila
 wrote:
> Declare local tables constant. Also added extra '32' at end of
> "width_for_reg" to be future proof, cvt function which give
> indexes to access here could already give index to reach place
> number five now containing '32'.

I don't see any evidence of 32 being a valid width. We don't have a
macro for it in brw_defines.h. Damien's tool [1] also says 32 isn't
valid.

[1] http://damien.lespiau.name/intel/gen_regions.html

With that removed (or justified),

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


Re: [Mesa-dev] [PATCH v2 06/23] mesa: Fix incorrect assertion in init_teximage_fields_ms

2014-12-01 Thread Ilia Mirkin
On Mon, Dec 1, 2014 at 6:04 AM, Iago Toral Quiroga  wrote:
> _BaseFormat is a GLenum (unsigned int) so testing if its value is
> greater than 0 to detect the cases where _mesa_base_tex_format
> returns -1 doesn't work.
>
> Fixing the assertion breaks the arb_texture_view-lifetime-format
> piglit test on nouveau, since that test calls
> _mesa_base_tex_format with GL_R16F with a context that does not
> have ARB_texture_float, so it returns -1 for the BaseFormat, which
> was not being catched properly by the ASSERT in init_teximage_fields_ms
> until now.

Sorry to hijack the thread, but... can you elaborate why this would
fail on nouveau but not on i965? Does st/mesa do something differently
wrt exposing ARB_texture_float vs i965? Does nouveau do something
wrong?

> ---
>  src/mesa/main/teximage.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index e238863..c9658c1 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1313,7 +1313,7 @@ init_teximage_fields_ms(struct gl_context *ctx,
>
> target = img->TexObject->Target;
> img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
> -   ASSERT(img->_BaseFormat > 0);
> +   ASSERT(img->_BaseFormat != -1);
> img->InternalFormat = internalFormat;
> img->Border = border;
> img->Width = width;
> --
> 1.9.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] i965/vs: Set brw_vs_prog_key::clamp_vertex_color to 0 when irrelevant.

2014-12-01 Thread Matt Turner
On Mon, Dec 1, 2014 at 2:00 AM, Kenneth Graunke  wrote:
> Vertex color clamping is only relevant if the shader writes to
> the built-in gl_[Secondary]{Front,Back}Color varyings.  Otherwise,
> brw_vs_prog_key::clamp_vertex_color is never used, so we can simply
> leave it set to 0.
>
> This enables us to correctly predict the clamp_vertex_color key value
> in the precompile for shaders which don't use those varyings.
>
> Eliminates virtually all VS recompiles in Serious Sam 3's intro.
>
> Signed-off-by: Kenneth Graunke 
> ---

Nice! The series is

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


Re: [Mesa-dev] [PATCH 2/5] i965: Drop use of GL types in program keys.

2014-12-01 Thread Matt Turner
On Mon, Dec 1, 2014 at 2:00 AM, Kenneth Graunke  wrote:
> This is really far removed from the API; we should just use C types.
>
> Signed-off-by: Kenneth Graunke 

Can we fix the type of the gen6_gather_wa field while we're at it? We
can mark the gen6_gather_sampler_wa as PACKED to keep the 1-byte size.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Remove "disable_derivative_optimization" driconf option.

2014-12-01 Thread Matt Turner
Reviewed-by: Matt Turner 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 7/7] i965: Don't emit saturate for vertex shaders

2014-12-01 Thread Matt Turner
i965's vertex shaders can use saturate. This isn't needed.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 6/7] i915: Don't emit saturate for vertex shaders

2014-12-01 Thread Matt Turner
I think i915's vertex shaders can use saturate. I don't think this is needed.

The code you were modifying (in Gallium) in the original patch doesn't
affect this driver.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/10] mesa: Considers GL_DEPTH_STENCIL_ATTACHMENT a valid argument for FBO invalidation under GLES3

2014-12-01 Thread Matt Turner
On Mon, Dec 1, 2014 at 5:04 AM, Eduardo Lima Mitev  wrote:
> In OpenGL and OpenGL-Es 3+, GL_DEPTH_STENCIL_ATTACHMENT is a valid attachment 
> point for the family of functions
> that invalidate a framebuffer object (e.g, glInvalidateFramebuffer, 
> glInvalidateSubFramebuffer, etc).
> Currently, a GL_INVALID_ENUM error is emitted for this attachment point.
>
> Fixes 21 dEQP test failures under 'dEQP-GLES3.functional.fbo.invalidate.*'.
> ---
>  src/mesa/main/fbobject.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 8283373..19c4020 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -3073,6 +3073,10 @@ invalidate_framebuffer_storage(GLenum target, GLsizei 
> numAttachments,
>   case GL_DEPTH_ATTACHMENT:
>   case GL_STENCIL_ATTACHMENT:
>  break;
> + case GL_DEPTH_STENCIL_ATTACHMENT:
> +if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx))
> +   break;
> +/* otherwise fall through */

I'd change the comment to just '/* fallthrough */' to match other occurrences.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/10] mesa: Enables GL_RGB and GL_RGBA unsized internal formats for OpenGL ES 3.0

2014-12-01 Thread Matt Turner
On Mon, Dec 1, 2014 at 5:04 AM, Eduardo Lima Mitev  wrote:
> GL_RGB and GL_RGBA are valid internal formats on a GLES3 profile. See
> "Table 1. Unsized Internal Formats" at
> https://www.khronos.org/opengles/sdk/docs/man3/html/glTexImage2D.xhtml.
>
> Fixes 2 dEQP tests:
> - dEQP-GLES3.functional.state_query.internal_format.rgb_samples
> - dEQP-GLES3.functional.state_query.internal_format.rgba_samples
> ---
>  src/mesa/main/fbobject.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 19c4020..cce5370 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -1429,6 +1429,8 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum 
> internalFormat)
> case GL_RGB8:
>return GL_RGB;
> case GL_RGB:
> +  if (_mesa_is_gles3(ctx))
> + return GL_RGB;

/* fallthrough */

> case GL_R3_G3_B2:
> case GL_RGB4:
> case GL_RGB5:
> @@ -1443,6 +1445,8 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum 
> internalFormat)
> case GL_RGBA8:
>return GL_RGBA;
> case GL_RGBA:
> +  if (_mesa_is_gles3(ctx))
> + return GL_RGBA;

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


Re: [Mesa-dev] [PATCH v2 16/23] mesa: Add _mesa_pack_uint_rgba_row() format conversion function

2014-12-01 Thread Jason Ekstrand
On Mon, Dec 1, 2014 at 3:04 AM, Iago Toral Quiroga 
wrote:

> From: Samuel Iglesias Gonsalvez 
>
> We will use this later on to handle uint conversion scenarios in a master
> convert function.
>
> v2:
> - Modify pack_uint_*() function generation to use c.datatype() and
>   f.datatype().
> - Remove UINT_TO_FLOAT() macro usage from pack_uint*()
> - Remove "if not f.is_normalized()" conditional as pack_uint*()
>   functions are only autogenerated for non normalized formats.
>
> Signed-off-by: Samuel Iglesias Gonsalvez 
> ---
>  src/mesa/main/format_pack.c.mako | 82
> 
>  src/mesa/main/format_pack.h  |  3 ++
>  2 files changed, 85 insertions(+)
>
> diff --git a/src/mesa/main/format_pack.c.mako
> b/src/mesa/main/format_pack.c.mako
> index aced58d..7feb3f8 100644
> --- a/src/mesa/main/format_pack.c.mako
> +++ b/src/mesa/main/format_pack.c.mako
> @@ -149,6 +149,56 @@ pack_ubyte_r11g11b10_float(const GLubyte src[4], void
> *dst)
> *d = float3_to_r11g11b10f(rgb);
>  }
>
> +/* uint packing functions */
> +
> +%for f in rgb_formats:
> +   %if not f.is_int():
> +  <% continue %>
> +   %elif f.is_normalized():
> +  <% continue %>
> +   %elif f.is_compressed():
> +  <% continue %>
> +   %endif
> +
> +static inline void
> +pack_uint_${f.short_name()}(const GLuint src[4], void *dst)
> +{
> +   %for (i, c) in enumerate(f.channels):
> +  <% i = f.swizzle.inverse()[i] %>
> +  %if c.type == 'x':
> + <% continue %>
> +  %endif
> +
> +  ${c.datatype()} ${c.name} =
> +  %if c.type == parser.FLOAT and c.size == 16:
> + _mesa_float_to_half(src[${i}]);
> +  %else:
> + (${c.datatype()}) src[${i}];
>

I think we're missing the clamping here.  We should probably use the same
clamping functions that we cooked up for swizzle_and_convert.  We'll have
to be careful though because the source gets interpreted as signed vs.
unsigned depending on the destination format.


> +  %endif
> +   %endfor
> +
> +   %if f.layout == parser.ARRAY:
> +  ${f.datatype()} *d = (${f.datatype()} *)dst;
> +  %for (i, c) in enumerate(f.channels):
> + %if c.type == 'x':
> +<% continue %>
> + %endif
> + d[${i}] = ${c.name};
> +  %endfor
> +   %elif f.layout == parser.PACKED:
> +  ${f.datatype()} d = 0;
> +  %for (i, c) in enumerate(f.channels):
> + %if c.type == 'x':
> +<% continue %>
> + %endif
> + d |= PACK(${c.name}, ${c.shift}, ${c.size});
> +  %endfor
> +  (*(${f.datatype()} *)dst) = d;
> +   %else:
> +  <% assert False %>
> +   %endif
> +}
> +%endfor
>
>  /* float packing functions */
>
> @@ -297,6 +347,38 @@ _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint
> n,
>  }
>
>  /**
> + * Pack a row of GLuint rgba[4] values to the destination.
> + */
> +void
> +_mesa_pack_uint_rgba_row(mesa_format format, GLuint n,
> +  const GLuint src[][4], void *dst)
> +{
> +   GLuint i;
> +   GLubyte *d = dst;
> +
> +   switch (format) {
> +%for f in rgb_formats:
> +   %if not f.is_int():
> +  <% continue %>
> +   %elif f.is_normalized():
> +  <% continue %>
> +   %elif f.is_compressed():
> +  <% continue %>
> +   %endif
> +
> +   case ${f.name}:
> +  for (i = 0; i < n; ++i) {
> + pack_uint_${f.short_name()}(src[i], d);
> + d += ${f.block_size() / 8};
> +  }
> +  break;
> +%endfor
> +   default:
> +  assert(!"Invalid format");
> +   }
> +}
> +
> +/**
>   * Pack a row of GLfloat rgba[4] values to the destination.
>   */
>  void
> diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h
> index 2577def..1582ad1 100644
> --- a/src/mesa/main/format_pack.h
> +++ b/src/mesa/main/format_pack.h
> @@ -77,6 +77,9 @@ extern void
>  _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n,
>const GLubyte src[][4], void *dst);
>
> +extern void
> +_mesa_pack_uint_rgba_row(mesa_format format, GLuint n,
> + const GLuint src[][4], void *dst);
>
>  extern void
>  _mesa_pack_ubyte_rgba_rect(mesa_format format, GLuint width, GLuint
> height,
> --
> 1.9.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 17/23] mesa: Add non-normalized formats support for ubyte packing functions

2014-12-01 Thread Jason Ekstrand
On Mon, Dec 1, 2014 at 3:04 AM, Iago Toral Quiroga 
wrote:

> From: Samuel Iglesias Gonsalvez 
>
> Signed-off-by: Samuel Iglesias Gonsalvez 
> ---
>  src/mesa/main/format_pack.c.mako | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/format_pack.c.mako
> b/src/mesa/main/format_pack.c.mako
> index 7feb3f8..6815bf3 100644
> --- a/src/mesa/main/format_pack.c.mako
> +++ b/src/mesa/main/format_pack.c.mako
> @@ -83,7 +83,9 @@ pack_ubyte_${f.short_name()}(const GLubyte src[4], void
> *dst)
>%endif
>
>${c.datatype()} ${c.name} =
> -  %if c.type == parser.UNSIGNED:
> +  %if not f.is_normalized() and f.is_int():
> +(${c.datatype()}) src[${i}];
>

Clamping


> +  %elif c.type == parser.UNSIGNED:
>   %if f.colorspace == 'srgb' and c.name in 'rgb':
>  util_format_linear_to_srgb_8unorm(src[${i}]);
>   %else:
> --
> 1.9.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 00/23] auto-generate pack/unpack functions

2014-12-01 Thread Jason Ekstrand
On Mon, Dec 1, 2014 at 3:04 AM, Iago Toral Quiroga 
wrote:

> This is the first of two series that aim to address:
> https://bugs.freedesktop.org/show_bug.cgi?id=84566
>
> A branch with this series is available here:
> https://github.com/Igalia/mesa/tree/itoral-autogen-packing-review-v2
>
> Link to the original series:
> http://lists.freedesktop.org/archives/mesa-dev/2014-November/070898.html
>
> Main changes in v2:
>   - Fixed auto-generation for a2r10g10b10, removed hand coded
> implementation.
>   - Updated docs and configure to requite mako as a build dependency.
>   - Expanded the patch to mesa_swizzle_and_convert to clamp in all integer
> conversions that require it.
>   - Fixed out-of-tree builds.
>   - Fixed handling of integer formats.
>   - Merged format_conver.py into format_parser.py.
>

This is looking much better!  I had a couple of comments here and there but
otherwise, the whole thing looks pretty good to me.  Most of the fixes at
this point should be pretty trivial, so you probably don't need to re-send
the series.  I'll try and scare up a review for the bits of code in here
that I wrote.


>
> Jason, we decided to keep the support for
> GL_ABGR_EXT/GL_UNSIGNED_SHORT_5_5_5_1,
>   GL_ABGR_EXT/GL_UNSIGNED_SHORT_1_5_5_5_REV,
>   GL_ABGR_EXT/GL_UNSIGNED_INT_2_10_10_10_REV,
>   GL_ABGR_EXT/GL_UNSIGNED_INT_10_10_10_2 in this series, since these types
>   are currently supported and removing them would be a change in behavior.
>   When we send the second series to address format conversion we will
>   include a separate patch at the end to remove these types. If you prefer
> this
>   to be handled differently, let us know.
>

I talked to a few people and as far as we can tell, those should be
disallowed by the type/format checks in TexSubImage and friends.  Ian
suggested that we run that piglit test against nVidia and AMD's
closed-source drivers and see what they do.  If they don't support ABGR
with 5551, then let's go ahead and drop support for it ourselves.  If they
do, then it's not that much code to keep.  It's also possible that they
don't support the extension at all in which case let's keep the extension
and drop support for using it with 5551.  That said, let's make it a
seperate patch so that if anyone complains it's easy to revert.


>
> Patch 11 is optional now that we no longer need to pass a base format to
> _mesa_format_convert (implemented in the second series), but still looks
> like
> a good idea to me.
>

Yeah, let's keep it

--Jason


>
> Tested on i965, classic swrast and gallium (radeon, nouveau, llvmpipe)
> without
> regressions.
>
> Iago Toral Quiroga (3):
>   mesa: Fix incorrect assertion in init_teximage_fields_ms
>   swrast: Remove unused variable.
>   mesa: Let _mesa_get_format_base_format also handle mesa_array_format.
>
> Jason Ekstrand (9):
>   mesa/format_utils: Fix a bug in unorm_to_float helper function
>   mesa: Fix packing/unpacking of MESA_FORMAT_R5G6B5_UNORM
>   mesa/colormac: Remove an unused macro
>   mesa: Fix A1R5G5B5 packing/unpacking
>   mesa/format_utils: Prefix and expose the conversion helper functions
>   mesa: Add a concept of an array format
>   mesa: Add a _mesa_is_format_color_format helper
>   mesa: Autogenerate most of format_pack.c
>   mesa: Autogenerate format_unpack.c
>
> Samuel Iglesias Gonsalvez (11):
>   mesa: Fix get_texbuffer_format().
>   mesa: Fix _mesa_swizzle_and_convert integer conversions to clamp
> properly
>   configure: require python mako module
>   mesa: Add _mesa_pack_uint_rgba_row() format conversion function
>   mesa: Add non-normalized formats support for ubyte packing functions
>   mesa/format_pack: Add _mesa_pack_int_rgba_row()
>   mesa/formats: add new mesa formats and their pack/unpack functions.
>   mesa: use format conversion functions in swrast
>   mesa/pack: use autogenerated format_pack functions
>   mesa/main/pack_tmp.h: Add float conversion support
>   mesa/pack: refactor _mesa_pack_rgba_span_float()
>
>  configure.ac   |2 +
>  docs/install.html  |6 +-
>  m4/ax_check_python_mako_module.m4  |   56 +
>  src/mesa/Makefile.am   |   26 +
>  src/mesa/Makefile.sources  |4 +-
>  src/mesa/main/colormac.h   |3 -
>  src/mesa/main/format_info.py   |   41 +
>  src/mesa/main/format_pack.c| 2994 
>  src/mesa/main/format_pack.c.mako   | 1102 +
>  src/mesa/main/format_pack.h|6 +
>  src/mesa/main/format_parser.py |   71 +
>  src/mesa/main/format_unpack.c  | 4400
> 
>  src/mesa/main/format_unpack.c.mako |  881 
>  src/mesa/main/format_utils.c   |  262 +--
>  src/mesa/main/format_utils.h   |  130 ++
>  src/mesa/main/formats.c|  262 ++-
>  src/mesa/main/formats.csv  |   13 +
>  src/mesa/main/formats.h|   82 +-
>  src/mesa/main/pack.c   | 2111 +++--
>  src/mesa/main/pack_tmp.h 

Re: [Mesa-dev] [PATCH v2 6/7] i915: Don't emit saturate for vertex shaders

2014-12-01 Thread Matt Turner
On Mon, Dec 1, 2014 at 10:50 AM, Matt Turner  wrote:
> I think i915's vertex shaders can use saturate. I don't think this is needed.
>
> The code you were modifying (in Gallium) in the original patch doesn't
> affect this driver.

Actually, i915 doesn't do hardware vertex shaders, so I don't know
what to do here.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/5] i965: Move program key structures to brw_program.h.

2014-12-01 Thread Chris Forbes
For the series:

Reviewed-by: Chris Forbes 

On Mon, Dec 1, 2014 at 11:00 PM, Kenneth Graunke  wrote:
> With fs_visitor/fs_generator being reused for SIMD8 VS/GS programs,
> we're running into weird #include patterns, where scalar code #includes
> brw_vec4.h and such.
>
> Program keys aren't really related to SIMD4X2/SIMD8 execution - they
> mostly capture NOS for a particular shader stage.  Consolidating them
> all in one place that's vec4/scalar neutral should help avoid problems.
>
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/drivers/dri/i965/brw_program.h | 108 
> ++--
>  src/mesa/drivers/dri/i965/brw_vec4.h|  22 -
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h |   9 --
>  src/mesa/drivers/dri/i965/brw_vs.h  |  22 -
>  src/mesa/drivers/dri/i965/brw_wm.h  |  24 --
>  5 files changed, 103 insertions(+), 82 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_program.h 
> b/src/mesa/drivers/dri/i965/brw_program.h
> index 672777f..5328e3c 100644
> --- a/src/mesa/drivers/dri/i965/brw_program.h
> +++ b/src/mesa/drivers/dri/i965/brw_program.h
> @@ -24,11 +24,25 @@
>  #ifndef BRW_PROGRAM_H
>  #define BRW_PROGRAM_H
>
> -enum gen6_gather_sampler_wa {
> -   WA_SIGN = 1,  /* whether we need to sign extend */
> -   WA_8BIT = 2,  /* if we have an 8bit format needing wa */
> -   WA_16BIT = 4, /* if we have a 16bit format needing wa */
> -};
> +/**
> + * Program key structures.
> + *
> + * When drawing, we look for the currently bound shaders in the program
> + * cache.  This is essentially a hash table lookup, and these are the keys.
> + *
> + * Sometimes OpenGL features specified as state need to be simulated via
> + * shader code, due to a mismatch between the API and the hardware.  This
> + * is often referred to as "non-orthagonal state" or "NOS".  We store NOS
> + * in the program key so it's considered when searching for a program.  If
> + * we haven't seen a particular combination before, we have to recompile a
> + * new specialized version.
> + *
> + * Shader compilation should not look up state in gl_context directly, but
> + * instead use the copy in the program key.  This guarantees recompiles will
> + * happen correctly.
> + *
> + *  @{
> + */
>
>  /**
>   * Sampler information needed by VS, WM, and GS program cache keys.
> @@ -57,6 +71,90 @@ struct brw_sampler_prog_key_data {
> uint8_t gen6_gather_wa[MAX_SAMPLERS];
>  };
>
> +
> +struct brw_vec4_prog_key {
> +   GLuint program_string_id;
> +
> +   /**
> +* True if at least one clip flag is enabled, regardless of whether the
> +* shader uses clip planes or gl_ClipDistance.
> +*/
> +   GLuint userclip_active:1;
> +
> +   /**
> +* How many user clipping planes are being uploaded to the vertex shader 
> as
> +* push constants.
> +*/
> +   GLuint nr_userclip_plane_consts:4;
> +
> +   GLuint clamp_vertex_color:1;
> +
> +   struct brw_sampler_prog_key_data tex;
> +};
> +
> +/** The program key for Vertex Shaders. */
> +struct brw_vs_prog_key {
> +   struct brw_vec4_prog_key base;
> +
> +   /*
> +* Per-attribute workaround flags
> +*/
> +   uint8_t gl_attrib_wa_flags[VERT_ATTRIB_MAX];
> +
> +   GLuint copy_edgeflag:1;
> +
> +   /**
> +* For pre-Gen6 hardware, a bitfield indicating which texture coordinates
> +* are going to be replaced with point coordinates (as a consequence of a
> +* call to glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)).  
> Because
> +* our SF thread requires exact matching between VS outputs and FS inputs,
> +* these texture coordinates will need to be unconditionally included in
> +* the VUE, even if they aren't written by the vertex shader.
> +*/
> +   GLuint point_coord_replace:8;
> +};
> +
> +/** The program key for Geometry Shaders. */
> +struct brw_gs_prog_key
> +{
> +   struct brw_vec4_prog_key base;
> +
> +   GLbitfield64 input_varyings;
> +};
> +
> +/** The program key for Fragment/Pixel Shaders. */
> +struct brw_wm_prog_key {
> +   uint8_t iz_lookup;
> +   GLuint stats_wm:1;
> +   GLuint flat_shade:1;
> +   GLuint persample_shading:1;
> +   GLuint persample_2x:1;
> +   GLuint nr_color_regions:5;
> +   GLuint replicate_alpha:1;
> +   GLuint render_to_fbo:1;
> +   GLuint clamp_fragment_color:1;
> +   GLuint compute_pos_offset:1;
> +   GLuint compute_sample_id:1;
> +   GLuint line_aa:2;
> +   GLuint high_quality_derivatives:1;
> +
> +   GLushort drawable_height;
> +   GLbitfield64 input_slots_valid;
> +   GLuint program_string_id:32;
> +   GLenum alpha_test_func;  /* < For Gen4/5 MRT alpha test */
> +   float alpha_test_ref;
> +
> +   struct brw_sampler_prog_key_data tex;
> +};
> +
> +/** @} */
> +
> +enum gen6_gather_sampler_wa {
> +   WA_SIGN = 1,  /* whether we need to sign extend */
> +   WA_8BIT = 2,  /* if we have an 8bit format needing wa */
> +   WA_16BIT = 4, /* if we have a 16bit format needing wa */
> +};
> +
>  #ifdef __cpluspl

Re: [Mesa-dev] [PATCH 2/5] i965: Drop use of GL types in program keys.

2014-12-01 Thread Kenneth Graunke
On Monday, December 01, 2014 10:46:30 AM Matt Turner wrote:
> On Mon, Dec 1, 2014 at 2:00 AM, Kenneth Graunke  wrote:
> > This is really far removed from the API; we should just use C types.
> >
> > Signed-off-by: Kenneth Graunke 
> 
> Can we fix the type of the gen6_gather_wa field while we're at it? We
> can mark the gen6_gather_sampler_wa as PACKED to keep the 1-byte size.

What type would you suggest?  It's a bitfield of width 3 (WA_SIGN, WA_8BIT,
and WA_16BIT).

We could convert it from uint8_t[32] to a 96-bit bitfield...

--Ken

signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 14/16] i965: Add fs_visitor::run_vs() to generate scalar vertex shader code

2014-12-01 Thread Kristian Høgsberg
On Fri, Nov 14, 2014 at 4:21 PM, Kenneth Graunke  wrote:
> On Thursday, November 13, 2014 04:28:20 PM Kristian Høgsberg wrote:
>> This patch uses the previous refactoring to add a new run_vs() method
>> that generates vertex shader code using the scalar visitor and
>> optimizer.
>>
>> Signed-off-by: Kristian Høgsberg 
>> ---
>>  src/mesa/drivers/dri/i965/brw_fs.cpp |  99 -
>>  src/mesa/drivers/dri/i965/brw_fs.h   |  21 +-
>>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 303
> ++-
>>  3 files changed, 412 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> index 4dce0a2..8007977 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> @@ -1828,6 +1828,56 @@ fs_visitor::assign_urb_setup()
>>urb_start + prog_data->num_varying_inputs * 2;
>>  }
>>
>> +void
>> +fs_visitor::assign_vs_urb_setup()
>> +{
>> +   brw_vs_prog_data *vs_prog_data = (brw_vs_prog_data *) prog_data;
>> +   int grf, count, slot, channel, attr;
>> +
>> +   assert(stage == MESA_SHADER_VERTEX);
>> +   count = _mesa_bitcount_64(vs_prog_data->inputs_read);
>> +   if (vs_prog_data->uses_vertexid || vs_prog_data->uses_instanceid)
>> +  count++;
>> +
>> +   /* Each attribute is 4 regs. */
>> +   this->first_non_payload_grf =
>> +  payload.num_regs + prog_data->curb_read_length + count * 4;
>> +
>> +   unsigned vue_entries =
>> +  MAX2(count, vs_prog_data->base.vue_map.num_slots);
>> +
>> +   vs_prog_data->base.urb_entry_size = ALIGN(vue_entries, 4) / 4;
>> +   vs_prog_data->base.urb_read_length = (count + 1) / 2;
>> +
>> +   assert(vs_prog_data->base.urb_read_length <= 15);
>
> What enforces this assertion?  It obviously needs to be true, since
> the "Vertex URB Entry Read Length" field in 3DSTATE_VS has a maximum
> value of 15 in SIMD8 mode.
>
> But this looks like the exact same calculation done in
> vec4_vs_visitor::setup_attributes, and the limit there is [1, 63].
>
> The documentation indicates that the API may allow more vertex attributes
> than can practically be supported by pushing VUEs in as payload registers:
>
> "The EU limit of 128 GRFs imposes a maximum limit of 30 elements per vertex
>  pushed into the payload, though the practical limit may be lower. If input
>  vertices exceed the practical limit, software must decide between resorting
>  to pulling elements during thread execution or dropping back to SIMD4x2
>  dispatch."
>
> I don't see any code in this series for falling back, nor for pulling VUEs
> out of the URB (and avoiding overwriting them before they're loaded), so
> I expect this would simply assert fail on a vertex shader with too many
> inputs.

We only advertise the spec required minimum of 16 vertex attributes
right now.  The 3DSTATE_VS field counts pairs of vertex attributes
which means we can handle up to 30 in scalar mode.

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


[Mesa-dev] [PATCH] i965: Sort array elements to increase chances of reusing buffer relocation

2014-12-01 Thread Neil Roberts
When submitting the vertex buffers the i965 driver will try to recognise when
multiple attributes are using the same buffer so that it can submit a single
relocation for it and set a different offset in the attribute. Previously
however if the application happens to have the attributes in a struct with an
order that doesn't match the order they are listed in the gl_vert_attrib enum
then the loop would end up processing the attributes with a greater offset
first and the optimisation wouldn't be used.

To make the optmisation more likely to be used this patch makes it always
process the elements in increasing order of offset. This is done copying the
element pointers into a separate array and sorting it with qsort. This only
affects the order that the elements are processed and doesn't change the order
that they are submitted to the hardware.
---

I noticed this problem by inspection but I don't have a good feel for
how important avoiding the buffer relocations is so I don't know
whether the patch makes much sense. However I think the added overhead
to sort the attributes is minimal so I don't think it can do much
harm.

I've run the patch through Piglit on IvyBridge and there are no
regressions. I've also verified that it does end up generating two
buffer relocations if you put the attributes in the wrong order with
gdb and also that the patch fixes it.

 src/mesa/drivers/dri/i965/brw_draw_upload.c | 38 ++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c 
b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 7bf9163..8b60563 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -396,6 +396,24 @@ copy_array_to_vbo_array(struct brw_context *brw,
buffer->stride = dst_stride;
 }
 
+static int
+compare_array_ptr(const void *a, const void *b)
+{
+   struct brw_vertex_element *input_a =
+  *(struct brw_vertex_element * const *) a;
+   struct brw_vertex_element *input_b =
+  *(struct brw_vertex_element * const *) b;
+   const GLubyte *ptr_a = input_a->glarray->Ptr;
+   const GLubyte *ptr_b = input_b->glarray->Ptr;
+
+   if (ptr_a < ptr_b)
+  return -1;
+   else if (ptr_a > ptr_b)
+  return 1;
+   else
+  return 0;
+}
+
 void
 brw_prepare_vertices(struct brw_context *brw)
 {
@@ -409,6 +427,7 @@ brw_prepare_vertices(struct brw_context *brw)
int delta, i, j;
 
struct brw_vertex_element *upload[VERT_ATTRIB_MAX];
+   struct brw_vertex_element *sorted[VERT_ATTRIB_MAX];
GLuint nr_uploads = 0;
 
/* _NEW_POLYGON
@@ -442,8 +461,21 @@ brw_prepare_vertices(struct brw_context *brw)
if (brw->vb.nr_buffers)
   return;
 
+   /* In the loop below if it finds an element that is using the same buffer
+* as a previous element then it will reuse the same buffer relocation.
+* However it will only work if the offset for the previous element is less
+* than the offset for the new element and the difference is less than the
+* stride. In order to increase the chances of hitting this optimisation
+* the elements will be processed in increasing order of offset by first
+* sorting the pointers.
+*/
+   memcpy(sorted, brw->vb.enabled,
+  sizeof(sorted[0]) * brw->vb.nr_enabled);
+   qsort(sorted, brw->vb.nr_enabled, sizeof(sorted[0]),
+ compare_array_ptr);
+
for (i = j = 0; i < brw->vb.nr_enabled; i++) {
-  struct brw_vertex_element *input = brw->vb.enabled[i];
+  struct brw_vertex_element *input = sorted[i];
   const struct gl_client_array *glarray = input->glarray;
 
   if (_mesa_is_bufferobj(glarray->BufferObj)) {
@@ -456,13 +488,13 @@ brw_prepare_vertices(struct brw_context *brw)
  * relocations.
  */
 for (k = 0; k < i; k++) {
-   const struct gl_client_array *other = brw->vb.enabled[k]->glarray;
+   const struct gl_client_array *other = sorted[k]->glarray;
if (glarray->BufferObj == other->BufferObj &&
glarray->StrideB == other->StrideB &&
glarray->InstanceDivisor == other->InstanceDivisor &&
(uintptr_t)(glarray->Ptr - other->Ptr) < glarray->StrideB)
{
-  input->buffer = brw->vb.enabled[k]->buffer;
+  input->buffer = sorted[k]->buffer;
   input->offset = glarray->Ptr - other->Ptr;
   break;
}
-- 
1.9.3

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


[Mesa-dev] [PATCH] gallium: add include path to fix building of pipe-loader code

2014-12-01 Thread Brian Paul
The pipe-loader code wasn't finding util/u_atomic.h
---
 src/gallium/auxiliary/pipe-loader/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/auxiliary/pipe-loader/Makefile.am 
b/src/gallium/auxiliary/pipe-loader/Makefile.am
index 44917f3..cb6035d 100644
--- a/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -3,6 +3,7 @@ include Makefile.sources
 AM_CPPFLAGS = $(DEFINES) \
$(VISIBILITY_CFLAGS) \
-I$(top_srcdir)/include \
+   -I$(top_srcdir)/src \
-I$(top_srcdir)/src/loader \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
-- 
1.9.1

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


[Mesa-dev] [PATCH] mesa: update glext.h to version 20141118

2014-12-01 Thread Brian Paul
---
 include/GL/glext.h | 213 +
 1 file changed, 181 insertions(+), 32 deletions(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 256ad35..d3cfbb5 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -33,7 +33,7 @@ extern "C" {
 ** used to make the header, and the header can be found at
 **   http://www.opengl.org/registry/
 **
-** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 
2014) $
+** Khronos $Revision: 28986 $ on $Date: 2014-11-18 18:43:15 -0800 (Tue, 18 Nov 
2014) $
 */
 
 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && 
!defined(__SCITECH_SNAP__)
@@ -53,7 +53,7 @@ extern "C" {
 #define GLAPI extern
 #endif
 
-#define GL_GLEXT_VERSION 20140810
+#define GL_GLEXT_VERSION 20141118
 
 /* Generated C header for:
  * API: gl
@@ -2044,6 +2044,10 @@ GLAPI void APIENTRY glGetDoublei_v (GLenum target, 
GLuint index, GLdouble *data)
 
 #ifndef GL_VERSION_4_2
 #define GL_VERSION_4_2 1
+#define GL_COPY_READ_BUFFER_BINDING   0x8F36
+#define GL_COPY_WRITE_BUFFER_BINDING  0x8F37
+#define GL_TRANSFORM_FEEDBACK_ACTIVE  0x8E24
+#define GL_TRANSFORM_FEEDBACK_PAUSED  0x8E23
 #define GL_UNPACK_COMPRESSED_BLOCK_WIDTH  0x9127
 #define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
 #define GL_UNPACK_COMPRESSED_BLOCK_DEPTH  0x9129
@@ -2694,6 +2698,10 @@ typedef void (APIENTRYP 
PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuin
 typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers);
 typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint 
*pipelines);
 typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, 
GLuint *ids);
+typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint 
buffer, GLenum pname, GLintptr offset);
+typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint 
buffer, GLenum pname, GLintptr offset);
+typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint 
buffer, GLenum pname, GLintptr offset);
+typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint 
buffer, GLenum pname, GLintptr offset);
 typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers);
 typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint 
level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei 
height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void 
*pixels);
 typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint 
texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei 
width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels);
@@ -2813,6 +2821,10 @@ GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint 
vaobj, GLuint index, GLe
 GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers);
 GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines);
 GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids);
+GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, 
GLenum pname, GLintptr offset);
+GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum 
pname, GLintptr offset);
+GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, 
GLenum pname, GLintptr offset);
+GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, 
GLenum pname, GLintptr offset);
 GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers);
 GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint 
xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei 
depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels);
 GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint 
level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei 
height, GLsizei depth, GLsizei bufSize, void *pixels);
@@ -2979,8 +2991,6 @@ GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint 
num_groups_x, GLuint n
 
 #ifndef GL_ARB_copy_buffer
 #define GL_ARB_copy_buffer 1
-#define GL_COPY_READ_BUFFER_BINDING   0x8F36
-#define GL_COPY_WRITE_BUFFER_BINDING  0x8F37
 #endif /* GL_ARB_copy_buffer */
 
 #ifndef GL_ARB_copy_image
@@ -4065,13 +4075,13 @@ GLAPI void APIENTRY glGetNamedStringivARB (GLint 
namelen, const GLchar *name, GL
 #define GL_ARB_sparse_buffer 1
 #define GL_SPARSE_STORAGE_BIT_ARB 0x0400
 #define GL_SPARSE_BUFFER_PAGE_SIZE_ARB0x82F8
-typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, 
GLintptr offset, GLsizei size, GLboolean commit);
-typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, 
GLintptr offset, GLsizei size, GLboolean commit);
-typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, 
GLintptr offset, GLsizei size, GLboolean commit);
+typedef void (APIENTRYP PFNGLBUFFERP

[Mesa-dev] [PATCH 4/5] mesa: some improvements for print_list()

2014-12-01 Thread Brian Paul
Add a filename parameter to print_list() so that a display list can
be printed to a file.
---
 src/mesa/main/dlist.c   | 150 
 src/mesa/main/dlist.h   |   2 +-
 src/mesa/vbo/vbo_save_api.c |   8 +--
 3 files changed, 87 insertions(+), 73 deletions(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 4b7b060..a087f79 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -81,7 +81,7 @@ struct gl_list_instruction
GLuint Size;
void (*Execute)( struct gl_context *ctx, void *data );
void (*Destroy)( struct gl_context *ctx, void *data );
-   void (*Print)( struct gl_context *ctx, void *data );
+   void (*Print)( struct gl_context *ctx, void *data, FILE *f );
 };
 
 
@@ -666,11 +666,11 @@ ext_opcode_execute(struct gl_context *ctx, Node *node)
 
 /** Print an extended opcode instruction */
 static GLint
-ext_opcode_print(struct gl_context *ctx, Node *node)
+ext_opcode_print(struct gl_context *ctx, Node *node, FILE *f)
 {
const GLint i = node[0].opcode - OPCODE_EXT_0;
GLint step;
-   ctx->ListExt->Opcode[i].Print(ctx, &node[1]);
+   ctx->ListExt->Opcode[i].Print(ctx, &node[1], f);
step = ctx->ListExt->Opcode[i].Size;
return step;
 }
@@ -1098,7 +1098,7 @@ _mesa_dlist_alloc_opcode(struct gl_context *ctx,
  GLuint size,
  void (*execute) (struct gl_context *, void *),
  void (*destroy) (struct gl_context *, void *),
- void (*print) (struct gl_context *, void *))
+ void (*print) (struct gl_context *, void *, FILE *))
 {
if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) {
   const GLuint i = ctx->ListExt->NumOpcodes++;
@@ -9716,16 +9716,24 @@ enum_string(GLenum k)
 /**
  * Print the commands in a display list.  For debugging only.
  * TODO: many commands aren't handled yet.
+ * \param fname  filename to write display list to.  If null, use stdout.
  */
 static void GLAPIENTRY
-print_list(struct gl_context *ctx, GLuint list)
+print_list(struct gl_context *ctx, GLuint list, const char *fname)
 {
struct gl_display_list *dlist;
Node *n;
GLboolean done;
+   FILE *f = stdout;
+
+   if (fname) {
+  f = fopen(fname, "w");
+  if (!f)
+ return;
+   }
 
if (!islist(ctx, list)) {
-  printf("%u is not a display list ID\n", list);
+  fprintf(f, "%u is not a display list ID\n", list);
   return;
}
 
@@ -9735,199 +9743,202 @@ print_list(struct gl_context *ctx, GLuint list)
 
n = dlist->Head;
 
-   printf("START-LIST %u, address %p\n", list, (void *) n);
+   fprintf(f, "START-LIST %u, address %p\n", list, (void *) n);
 
done = n ? GL_FALSE : GL_TRUE;
while (!done) {
   const OpCode opcode = n[0].opcode;
 
   if (is_ext_opcode(opcode)) {
- n += ext_opcode_print(ctx, n);
+ n += ext_opcode_print(ctx, n, f);
   }
   else {
  switch (opcode) {
  case OPCODE_ACCUM:
-printf("Accum %s %g\n", enum_string(n[1].e), n[2].f);
+fprintf(f, "Accum %s %g\n", enum_string(n[1].e), n[2].f);
+break;
+ case OPCODE_ACTIVE_TEXTURE:
+fprintf(f, "ActiveTexture(%s)\n", enum_string(n[1].e));
 break;
  case OPCODE_BITMAP:
-printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
+fprintf(f, "Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
n[3].f, n[4].f, n[5].f, n[6].f,
get_pointer(&n[7]));
 break;
  case OPCODE_CALL_LIST:
-printf("CallList %d\n", (int) n[1].ui);
+fprintf(f, "CallList %d\n", (int) n[1].ui);
 break;
  case OPCODE_CALL_LIST_OFFSET:
-printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
+fprintf(f, "CallList %d + offset %u = %u\n", (int) n[1].ui,
  ctx->List.ListBase, ctx->List.ListBase + n[1].ui);
 break;
  case OPCODE_DISABLE:
-printf("Disable %s\n", enum_string(n[1].e));
+fprintf(f, "Disable %s\n", enum_string(n[1].e));
 break;
  case OPCODE_ENABLE:
-printf("Enable %s\n", enum_string(n[1].e));
+fprintf(f, "Enable %s\n", enum_string(n[1].e));
 break;
  case OPCODE_FRUSTUM:
-printf("Frustum %g %g %g %g %g %g\n",
+fprintf(f, "Frustum %g %g %g %g %g %g\n",
  n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
 break;
  case OPCODE_LINE_STIPPLE:
-printf("LineStipple %d %x\n", n[1].i, (int) n[2].us);
+fprintf(f, "LineStipple %d %x\n", n[1].i, (int) n[2].us);
 break;
  case OPCODE_LOAD_IDENTITY:
-printf("LoadIdentity\n");
+fprintf(f, "LoadIdentity\n");
 break;
  case OPCODE_LOAD_MATRIX:
-printf("Loa

[Mesa-dev] [PATCH 2/5] svga: fix comment typo

2014-12-01 Thread Brian Paul
---
 src/gallium/drivers/svga/svga_resource_texture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/svga/svga_resource_texture.c 
b/src/gallium/drivers/svga/svga_resource_texture.c
index c975a19..64fd245 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -474,7 +474,7 @@ svga_texture_transfer_map(struct pipe_context *pipe,
   }
 
   /*
-   * Make sure whe return NULL if the map fails
+   * Make sure we return NULL if the map fails
*/
   if (map == NULL) {
  FREE(st);
-- 
1.9.1

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


[Mesa-dev] [PATCH 1/5] mesa: remove unused functions in prog_execute.c

2014-12-01 Thread Brian Paul
---
 src/mesa/program/prog_execute.c | 74 -
 1 file changed, 74 deletions(-)

diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index 650c40f..33c1751 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -298,15 +298,6 @@ fetch_vector1(const struct prog_src_register *source,
 }
 
 
-static GLuint
-fetch_vector1ui(const struct prog_src_register *source,
-const struct gl_program_machine *machine)
-{
-   const GLuint *src = (GLuint *) get_src_register_pointer(source, machine);
-   return src[GET_SWZ(source->Swizzle, 0)];
-}
-
-
 /**
  * Fetch texel from texture.  Use partial derivatives when possible.
  */
@@ -488,71 +479,6 @@ store_vector4(const struct prog_instruction *inst,
 
 
 /**
- * Store 4 uints into a register.  Observe the set-condition-code flags.
- */
-static void
-store_vector4ui(const struct prog_instruction *inst,
-struct gl_program_machine *machine, const GLuint value[4])
-{
-   const struct prog_dst_register *dstReg = &(inst->DstReg);
-   GLuint writeMask = dstReg->WriteMask;
-   GLuint *dst = (GLuint *) get_dst_register_pointer(dstReg, machine);
-
-   if (dstReg->CondMask != COND_TR) {
-  /* condition codes may turn off some writes */
-  if (writeMask & WRITEMASK_X) {
- if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 0)],
-  dstReg->CondMask))
-writeMask &= ~WRITEMASK_X;
-  }
-  if (writeMask & WRITEMASK_Y) {
- if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 1)],
-  dstReg->CondMask))
-writeMask &= ~WRITEMASK_Y;
-  }
-  if (writeMask & WRITEMASK_Z) {
- if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 2)],
-  dstReg->CondMask))
-writeMask &= ~WRITEMASK_Z;
-  }
-  if (writeMask & WRITEMASK_W) {
- if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 3)],
-  dstReg->CondMask))
-writeMask &= ~WRITEMASK_W;
-  }
-   }
-
-   if (writeMask & WRITEMASK_X)
-  dst[0] = value[0];
-   if (writeMask & WRITEMASK_Y)
-  dst[1] = value[1];
-   if (writeMask & WRITEMASK_Z)
-  dst[2] = value[2];
-   if (writeMask & WRITEMASK_W)
-  dst[3] = value[3];
-
-   if (inst->CondUpdate) {
-  if (writeMask & WRITEMASK_X)
- machine->CondCodes[0] = generate_cc((float)value[0]);
-  if (writeMask & WRITEMASK_Y)
- machine->CondCodes[1] = generate_cc((float)value[1]);
-  if (writeMask & WRITEMASK_Z)
- machine->CondCodes[2] = generate_cc((float)value[2]);
-  if (writeMask & WRITEMASK_W)
- machine->CondCodes[3] = generate_cc((float)value[3]);
-#if DEBUG_PROG
-  printf("CondCodes=(%s,%s,%s,%s) for:\n",
- _mesa_condcode_string(machine->CondCodes[0]),
- _mesa_condcode_string(machine->CondCodes[1]),
- _mesa_condcode_string(machine->CondCodes[2]),
- _mesa_condcode_string(machine->CondCodes[3]));
-#endif
-   }
-}
-
-
-
-/**
  * Execute the given vertex/fragment program.
  *
  * \param ctx  rendering context
-- 
1.9.1

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


[Mesa-dev] [PATCH 3/5] mesa: inline/remove _mesa_polygon_stipple()

2014-12-01 Thread Brian Paul
Was not called from any other place.
---
 src/mesa/main/polygon.c | 38 ++
 src/mesa/main/polygon.h |  4 
 2 files changed, 10 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
index 76d6019..cdaa244 100644
--- a/src/mesa/main/polygon.c
+++ b/src/mesa/main/polygon.c
@@ -176,19 +176,18 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
 
 
 /**
- * This routine updates the ctx->Polygon.Stipple state.
- * If we're getting the stipple data from a PBO, we map the buffer
- * in order to access the data.
- * In any case, we obey the current pixel unpacking parameters when fetching
- * the stipple data.
- *
- * In the future, this routine should be used as a fallback, called via
- * ctx->Driver.PolygonStipple().  We'll have to update all the DRI drivers
- * too.
+ * Called by glPolygonStipple.
  */
-void
-_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern)
+void GLAPIENTRY
+_mesa_PolygonStipple(const GLubyte *pattern)
 {
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (MESA_VERBOSE & VERBOSE_API)
+  _mesa_debug(ctx, "glPolygonStipple\n");
+
+   FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE);
+
pattern = _mesa_map_validate_pbo_source(ctx, 2,
&ctx->Unpack, 32, 32, 1,
GL_COLOR_INDEX, GL_BITMAP,
@@ -200,23 +199,6 @@ _mesa_polygon_stipple(struct gl_context *ctx, const 
GLubyte *pattern)
_mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack);
 
_mesa_unmap_pbo_source(ctx, &ctx->Unpack);
-}
-
-
-/**
- * Called by glPolygonStipple.
- */
-void GLAPIENTRY
-_mesa_PolygonStipple( const GLubyte *pattern )
-{
-   GET_CURRENT_CONTEXT(ctx);
-
-   if (MESA_VERBOSE&VERBOSE_API)
-  _mesa_debug(ctx, "glPolygonStipple\n");
-
-   FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE);
-
-   _mesa_polygon_stipple(ctx, pattern);
 
if (ctx->Driver.PolygonStipple)
   ctx->Driver.PolygonStipple(ctx, pattern);
diff --git a/src/mesa/main/polygon.h b/src/mesa/main/polygon.h
index 69c5cbc..530adba 100644
--- a/src/mesa/main/polygon.h
+++ b/src/mesa/main/polygon.h
@@ -39,10 +39,6 @@ struct gl_context;
 extern void GLAPIENTRY
 _mesa_GetnPolygonStippleARB( GLsizei bufSize, GLubyte *dest );
 
-extern void
-_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern);
-
-
 extern void GLAPIENTRY
 _mesa_CullFace( GLenum mode );
 
-- 
1.9.1

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


[Mesa-dev] [PATCH 5/5] vbo: also print buffer object pointer in vbo_print_vertex_list()

2014-12-01 Thread Brian Paul
---
 src/mesa/vbo/vbo_save_api.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 4a6c436..5055c22 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -1527,10 +1527,14 @@ vbo_print_vertex_list(struct gl_context *ctx, void 
*data, FILE *f)
 {
struct vbo_save_vertex_list *node = (struct vbo_save_vertex_list *) data;
GLuint i;
+   struct gl_buffer_object *buffer = node->vertex_store ?
+  node->vertex_store->bufferobj : NULL;
(void) ctx;
 
-   fprintf(f, "VBO-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n",
-   node->count, node->prim_count, node->vertex_size);
+   fprintf(f, "VBO-VERTEX-LIST, %u vertices %d primitives, %d vertsize "
+   "buffer %p\n",
+   node->count, node->prim_count, node->vertex_size,
+   buffer);
 
for (i = 0; i < node->prim_count; i++) {
   struct _mesa_prim *prim = &node->prim[i];
-- 
1.9.1

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


[Mesa-dev] [PATCH] mesa: fix arithmetic error in _mesa_compute_compressed_pixelstore()

2014-12-01 Thread Brian Paul
We need parenthesis around the expression which computes the number of
blocks per row.

Cc: "10.3 10.4" 
---
 src/mesa/main/texstore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index f858cef..50aa1fd 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2231,7 +2231,7 @@ _mesa_compute_compressed_pixelstore(GLuint dims, 
mesa_format texFormat,
 
   if (packing->RowLength) {
  store->TotalBytesPerRow = packing->CompressedBlockSize *
-(packing->RowLength + bw - 1) / bw;
+((packing->RowLength + bw - 1) / bw);
   }
 
   store->SkipBytes += packing->SkipPixels * packing->CompressedBlockSize / 
bw;
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH 2/5] i965: Drop use of GL types in program keys.

2014-12-01 Thread Matt Turner
On Mon, Dec 1, 2014 at 12:00 PM, Kenneth Graunke  wrote:
> On Monday, December 01, 2014 10:46:30 AM Matt Turner wrote:
>> On Mon, Dec 1, 2014 at 2:00 AM, Kenneth Graunke  
>> wrote:
>> > This is really far removed from the API; we should just use C types.
>> >
>> > Signed-off-by: Kenneth Graunke 
>>
>> Can we fix the type of the gen6_gather_wa field while we're at it? We
>> can mark the gen6_gather_sampler_wa as PACKED to keep the 1-byte size.
>
> What type would you suggest?  It's a bitfield of width 3 (WA_SIGN, WA_8BIT,
> and WA_16BIT).
>
> We could convert it from uint8_t[32] to a 96-bit bitfield...

I think it's just a s/uint8_t/enum gen6_gather_sampler_wa/ on this
hunk, isn't it?

   /**
* For Sandybridge, which shader w/a we need for gather quirks.
*/
   uint8_t gen6_gather_wa[MAX_SAMPLERS];

Unless I've misunderstood something?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Add var->location != -1 assertions.

2014-12-01 Thread Kenneth Graunke
We shouldn't receive variables with invalid locations set - adding these
assertions should help catch problems before they cause crashes later.

Inspired by similar code in st_glsl_to_tgsi.

Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 1 +
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 0b62496..34907e3 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -57,6 +57,7 @@ fs_visitor::visit(ir_variable *ir)
   return;
 
if (ir->data.mode == ir_var_shader_in) {
+  assert(ir->data.location != -1);
   if (!strcmp(ir->name, "gl_FragCoord")) {
 reg = emit_fragcoord_interpolation(ir);
   } else if (!strcmp(ir->name, "gl_FrontFacing")) {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index c1c24ac..ffd97f1 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -1020,10 +1020,12 @@ vec4_visitor::visit(ir_variable *ir)
 
switch (ir->data.mode) {
case ir_var_shader_in:
+  assert(ir->data.location != -1);
   reg = new(mem_ctx) dst_reg(ATTR, ir->data.location);
   break;
 
case ir_var_shader_out:
+  assert(ir->data.location != -1);
   reg = new(mem_ctx) dst_reg(this, ir->type);
 
   for (int i = 0; i < type_size(ir->type); i++) {
-- 
2.1.3

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


[Mesa-dev] [PATCH] i965: Remove tabs from instruction scheduler.

2014-12-01 Thread Matt Turner
---
 .../drivers/dri/i965/brw_schedule_instructions.cpp | 196 ++---
 1 file changed, 98 insertions(+), 98 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp 
b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
index f0d941f..b552cf8 100644
--- a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
+++ b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
@@ -673,7 +673,7 @@ instruction_scheduler::compute_delay(schedule_node *n)
  */
 void
 instruction_scheduler::add_dep(schedule_node *before, schedule_node *after,
-  int latency)
+   int latency)
 {
if (!before || !after)
   return;
@@ -682,22 +682,22 @@ instruction_scheduler::add_dep(schedule_node *before, 
schedule_node *after,
 
for (int i = 0; i < before->child_count; i++) {
   if (before->children[i] == after) {
-before->child_latency[i] = MAX2(before->child_latency[i], latency);
-return;
+ before->child_latency[i] = MAX2(before->child_latency[i], latency);
+ return;
   }
}
 
if (before->child_array_size <= before->child_count) {
   if (before->child_array_size < 16)
-before->child_array_size = 16;
+ before->child_array_size = 16;
   else
-before->child_array_size *= 2;
+ before->child_array_size *= 2;
 
   before->children = reralloc(mem_ctx, before->children,
- schedule_node *,
- before->child_array_size);
+  schedule_node *,
+  before->child_array_size);
   before->child_latency = reralloc(mem_ctx, before->child_latency,
-  int, before->child_array_size);
+   int, before->child_array_size);
}
 
before->children[before->child_count] = after;
@@ -728,15 +728,15 @@ instruction_scheduler::add_barrier_deps(schedule_node *n)
 
if (prev) {
   while (!prev->is_head_sentinel()) {
-add_dep(prev, n, 0);
-prev = (schedule_node *)prev->prev;
+ add_dep(prev, n, 0);
+ prev = (schedule_node *)prev->prev;
   }
}
 
if (next) {
   while (!next->is_tail_sentinel()) {
-add_dep(n, next, 0);
-next = (schedule_node *)next->next;
+ add_dep(n, next, 0);
+ next = (schedule_node *)next->next;
   }
}
 }
@@ -791,7 +791,7 @@ fs_instruction_scheduler::calculate_deps()
 
   /* read-after-write deps. */
   for (int i = 0; i < inst->sources; i++) {
-if (inst->src[i].file == GRF) {
+ if (inst->src[i].file == GRF) {
 if (post_reg_alloc) {
for (int r = 0; r < inst->regs_read(v, i); r++)
   add_dep(last_grf_write[inst->src[i].reg + r], n);
@@ -800,10 +800,10 @@ fs_instruction_scheduler::calculate_deps()
   add_dep(last_grf_write[inst->src[i].reg * 16 + 
inst->src[i].reg_offset + r], n);
}
 }
-} else if (inst->src[i].file == HW_REG &&
-   (inst->src[i].fixed_hw_reg.file ==
-BRW_GENERAL_REGISTER_FILE)) {
-   if (post_reg_alloc) {
+ } else if (inst->src[i].file == HW_REG &&
+(inst->src[i].fixed_hw_reg.file ==
+ BRW_GENERAL_REGISTER_FILE)) {
+if (post_reg_alloc) {
int size = reg_width;
if (inst->src[i].fixed_hw_reg.vstride == BRW_VERTICAL_STRIDE_0)
   size = 1;
@@ -814,28 +814,28 @@ fs_instruction_scheduler::calculate_deps()
 }
  } else if (inst->src[i].is_accumulator()) {
 add_dep(last_accumulator_write, n);
-} else if (inst->src[i].file != BAD_FILE &&
-   inst->src[i].file != IMM &&
-   inst->src[i].file != UNIFORM &&
+ } else if (inst->src[i].file != BAD_FILE &&
+inst->src[i].file != IMM &&
+inst->src[i].file != UNIFORM &&
 (inst->src[i].file != HW_REG ||
  inst->src[i].fixed_hw_reg.file != IMM)) {
-   assert(inst->src[i].file != MRF);
-   add_barrier_deps(n);
-}
+assert(inst->src[i].file != MRF);
+add_barrier_deps(n);
+ }
   }
 
   if (inst->base_mrf != -1) {
-for (int i = 0; i < inst->mlen; i++) {
-   /* It looks like the MRF regs are released in the send
-* instruction once it's sent, not when the result comes
-* back.
-*/
-   add_dep(last_mrf_write[inst->base_mrf + i], n);
-}
+ for (int i = 0; i < inst->mlen; i++) {
+/* It looks like the MRF regs are released in the send
+ * instruction once it's sent, not when the result comes
+ * back.
+ */
+a

Re: [Mesa-dev] [PATCH] gallium: add include path to fix building of pipe-loader code

2014-12-01 Thread Matt Turner
Dang. I thought I found them all.

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


Re: [Mesa-dev] [PATCH] mesa: fix arithmetic error in _mesa_compute_compressed_pixelstore()

2014-12-01 Thread Matt Turner
On Mon, Dec 1, 2014 at 12:47 PM, Brian Paul  wrote:
> We need parenthesis around the expression which computes the number of
> blocks per row.
>
> Cc: "10.3 10.4" 
> ---
>  src/mesa/main/texstore.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
> index f858cef..50aa1fd 100644
> --- a/src/mesa/main/texstore.c
> +++ b/src/mesa/main/texstore.c
> @@ -2231,7 +2231,7 @@ _mesa_compute_compressed_pixelstore(GLuint dims, 
> mesa_format texFormat,
>
>if (packing->RowLength) {
>   store->TotalBytesPerRow = packing->CompressedBlockSize *
> -(packing->RowLength + bw - 1) / bw;
> +((packing->RowLength + bw - 1) / bw);
>}

Could we copy

#define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y))

our of r600_pipe.h into src/util/macros.h and use that? Maybe that'd
be better as a coccinelle patch over the whole tree.

Either way,

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


Re: [Mesa-dev] [PATCH v2 14/16] i965: Add fs_visitor::run_vs() to generate scalar vertex shader code

2014-12-01 Thread Kenneth Graunke
On Monday, December 01, 2014 12:02:01 PM Kristian Høgsberg wrote:
> On Fri, Nov 14, 2014 at 4:21 PM, Kenneth Graunke  
> wrote:
> > On Thursday, November 13, 2014 04:28:20 PM Kristian Høgsberg wrote:
> >> This patch uses the previous refactoring to add a new run_vs() method
> >> that generates vertex shader code using the scalar visitor and
> >> optimizer.
> >>
> >> Signed-off-by: Kristian Høgsberg 
> >> ---
> >>  src/mesa/drivers/dri/i965/brw_fs.cpp |  99 -
> >>  src/mesa/drivers/dri/i965/brw_fs.h   |  21 +-
> >>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 303
> > ++-
> >>  3 files changed, 412 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp
> > b/src/mesa/drivers/dri/i965/brw_fs.cpp
> >> index 4dce0a2..8007977 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> >> @@ -1828,6 +1828,56 @@ fs_visitor::assign_urb_setup()
> >>urb_start + prog_data->num_varying_inputs * 2;
> >>  }
> >>
> >> +void
> >> +fs_visitor::assign_vs_urb_setup()
> >> +{
> >> +   brw_vs_prog_data *vs_prog_data = (brw_vs_prog_data *) prog_data;
> >> +   int grf, count, slot, channel, attr;
> >> +
> >> +   assert(stage == MESA_SHADER_VERTEX);
> >> +   count = _mesa_bitcount_64(vs_prog_data->inputs_read);
> >> +   if (vs_prog_data->uses_vertexid || vs_prog_data->uses_instanceid)
> >> +  count++;
> >> +
> >> +   /* Each attribute is 4 regs. */
> >> +   this->first_non_payload_grf =
> >> +  payload.num_regs + prog_data->curb_read_length + count * 4;
> >> +
> >> +   unsigned vue_entries =
> >> +  MAX2(count, vs_prog_data->base.vue_map.num_slots);
> >> +
> >> +   vs_prog_data->base.urb_entry_size = ALIGN(vue_entries, 4) / 4;
> >> +   vs_prog_data->base.urb_read_length = (count + 1) / 2;
> >> +
> >> +   assert(vs_prog_data->base.urb_read_length <= 15);
> >
> > What enforces this assertion?  It obviously needs to be true, since
> > the "Vertex URB Entry Read Length" field in 3DSTATE_VS has a maximum
> > value of 15 in SIMD8 mode.
> >
> > But this looks like the exact same calculation done in
> > vec4_vs_visitor::setup_attributes, and the limit there is [1, 63].
> >
> > The documentation indicates that the API may allow more vertex attributes
> > than can practically be supported by pushing VUEs in as payload registers:
> >
> > "The EU limit of 128 GRFs imposes a maximum limit of 30 elements per vertex
> >  pushed into the payload, though the practical limit may be lower. If input
> >  vertices exceed the practical limit, software must decide between resorting
> >  to pulling elements during thread execution or dropping back to SIMD4x2
> >  dispatch."
> >
> > I don't see any code in this series for falling back, nor for pulling VUEs
> > out of the URB (and avoiding overwriting them before they're loaded), so
> > I expect this would simply assert fail on a vertex shader with too many
> > inputs.
> 
> We only advertise the spec required minimum of 16 vertex attributes
> right now.  The 3DSTATE_VS field counts pairs of vertex attributes
> which means we can handle up to 30 in scalar mode.
> 
> Kristian

You're right, and it looks like the linker enforces this, so we should never
see a program that violates these constraints.

Thanks!

signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/5] mesa: some improvements for print_list()

2014-12-01 Thread Kenneth Graunke
On Monday, December 01, 2014 01:44:22 PM Brian Paul wrote:
> Add a filename parameter to print_list() so that a display list can
> be printed to a file.
> ---
>  src/mesa/main/dlist.c   | 150 
> 
>  src/mesa/main/dlist.h   |   2 +-
>  src/mesa/vbo/vbo_save_api.c |   8 +--
>  3 files changed, 87 insertions(+), 73 deletions(-)
> 
> diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
> index 4b7b060..a087f79 100644
> --- a/src/mesa/main/dlist.c
> +++ b/src/mesa/main/dlist.c
> @@ -81,7 +81,7 @@ struct gl_list_instruction
> GLuint Size;
> void (*Execute)( struct gl_context *ctx, void *data );
> void (*Destroy)( struct gl_context *ctx, void *data );
> -   void (*Print)( struct gl_context *ctx, void *data );
> +   void (*Print)( struct gl_context *ctx, void *data, FILE *f );
>  };
>  
>  
> @@ -666,11 +666,11 @@ ext_opcode_execute(struct gl_context *ctx, Node *node)
>  
>  /** Print an extended opcode instruction */
>  static GLint
> -ext_opcode_print(struct gl_context *ctx, Node *node)
> +ext_opcode_print(struct gl_context *ctx, Node *node, FILE *f)
>  {
> const GLint i = node[0].opcode - OPCODE_EXT_0;
> GLint step;
> -   ctx->ListExt->Opcode[i].Print(ctx, &node[1]);
> +   ctx->ListExt->Opcode[i].Print(ctx, &node[1], f);
> step = ctx->ListExt->Opcode[i].Size;
> return step;
>  }
> @@ -1098,7 +1098,7 @@ _mesa_dlist_alloc_opcode(struct gl_context *ctx,
>   GLuint size,
>   void (*execute) (struct gl_context *, void *),
>   void (*destroy) (struct gl_context *, void *),
> - void (*print) (struct gl_context *, void *))
> + void (*print) (struct gl_context *, void *, FILE *))
>  {
> if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) {
>const GLuint i = ctx->ListExt->NumOpcodes++;
> @@ -9716,16 +9716,24 @@ enum_string(GLenum k)
>  /**
>   * Print the commands in a display list.  For debugging only.
>   * TODO: many commands aren't handled yet.
> + * \param fname  filename to write display list to.  If null, use stdout.
>   */
>  static void GLAPIENTRY
> -print_list(struct gl_context *ctx, GLuint list)
> +print_list(struct gl_context *ctx, GLuint list, const char *fname)
>  {
> struct gl_display_list *dlist;
> Node *n;
> GLboolean done;
> +   FILE *f = stdout;
> +
> +   if (fname) {
> +  f = fopen(fname, "w");
> +  if (!f)
> + return;
> +   }
>  
> if (!islist(ctx, list)) {
> -  printf("%u is not a display list ID\n", list);
> +  fprintf(f, "%u is not a display list ID\n", list);
>return;
> }
>  
> @@ -9735,199 +9743,202 @@ print_list(struct gl_context *ctx, GLuint list)
>  
> n = dlist->Head;
>  
> -   printf("START-LIST %u, address %p\n", list, (void *) n);
> +   fprintf(f, "START-LIST %u, address %p\n", list, (void *) n);
>  
> done = n ? GL_FALSE : GL_TRUE;
> while (!done) {
>const OpCode opcode = n[0].opcode;
>  
>if (is_ext_opcode(opcode)) {
> - n += ext_opcode_print(ctx, n);
> + n += ext_opcode_print(ctx, n, f);
>}
>else {
>   switch (opcode) {
>   case OPCODE_ACCUM:
> -printf("Accum %s %g\n", enum_string(n[1].e), n[2].f);
> +fprintf(f, "Accum %s %g\n", enum_string(n[1].e), n[2].f);
> +break;
> + case OPCODE_ACTIVE_TEXTURE:
> +fprintf(f, "ActiveTexture(%s)\n", enum_string(n[1].e));
>  break;
>   case OPCODE_BITMAP:
> -printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
> +fprintf(f, "Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
> n[3].f, n[4].f, n[5].f, n[6].f,
> get_pointer(&n[7]));
>  break;
>   case OPCODE_CALL_LIST:
> -printf("CallList %d\n", (int) n[1].ui);
> +fprintf(f, "CallList %d\n", (int) n[1].ui);
>  break;
>   case OPCODE_CALL_LIST_OFFSET:
> -printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
> +fprintf(f, "CallList %d + offset %u = %u\n", (int) n[1].ui,
>   ctx->List.ListBase, ctx->List.ListBase + n[1].ui);
>  break;
>   case OPCODE_DISABLE:
> -printf("Disable %s\n", enum_string(n[1].e));
> +fprintf(f, "Disable %s\n", enum_string(n[1].e));
>  break;
>   case OPCODE_ENABLE:
> -printf("Enable %s\n", enum_string(n[1].e));
> +fprintf(f, "Enable %s\n", enum_string(n[1].e));
>  break;
>   case OPCODE_FRUSTUM:
> -printf("Frustum %g %g %g %g %g %g\n",
> +fprintf(f, "Frustum %g %g %g %g %g %g\n",
>   n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
>  break;
>   case OPCODE_LINE_STIPPLE:
> -printf("LineStipple %d %x\n", n

Re: [Mesa-dev] [PATCH 4/5] mesa: some improvements for print_list()

2014-12-01 Thread Brian Paul

On 12/01/2014 03:59 PM, Kenneth Graunke wrote:

On Monday, December 01, 2014 01:44:22 PM Brian Paul wrote:

Add a filename parameter to print_list() so that a display list can
be printed to a file.
---
  src/mesa/main/dlist.c   | 150 
  src/mesa/main/dlist.h   |   2 +-
  src/mesa/vbo/vbo_save_api.c |   8 +--
  3 files changed, 87 insertions(+), 73 deletions(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 4b7b060..a087f79 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c




@@ -9964,6 +9975,9 @@ print_list(struct gl_context *ctx, GLuint list)
   }
}
 }
+
+   fflush(f);
+   fclose(f);


It looks like this would close stdout.  Presumably you want:

if (fname)
   fclose(f);


Yes, thanks!

-Brian



With that fixed, the series is:
Reviewed-by: Kenneth Graunke 



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


Re: [Mesa-dev] [PATCH 1/1] r600, llvm: Fix mem leak

2014-12-01 Thread Jan Vesely
ping

On Mon, 2014-11-03 at 20:29 -0500, Jan Vesely wrote:
> Signed-off-by: Jan Vesely 
> ---
>  src/gallium/drivers/r600/r600_llvm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/gallium/drivers/r600/r600_llvm.c 
> b/src/gallium/drivers/r600/r600_llvm.c
> index c19693a..5f74bf7 100644
> --- a/src/gallium/drivers/r600/r600_llvm.c
> +++ b/src/gallium/drivers/r600/r600_llvm.c
> @@ -888,6 +888,7 @@ unsigned r600_llvm_compile(
>  
>   FREE(binary.code);
>   FREE(binary.config);
> + FREE(binary.rodata);
>  
>   return r;
>  }

-- 
Jan Vesely 


signature.asc
Description: This is a digitally signed message part
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] mesa: fix arithmetic error in _mesa_compute_compressed_pixelstore()

2014-12-01 Thread Brian Paul

On 12/01/2014 03:16 PM, Matt Turner wrote:

On Mon, Dec 1, 2014 at 12:47 PM, Brian Paul  wrote:

We need parenthesis around the expression which computes the number of
blocks per row.

Cc: "10.3 10.4" 
---
  src/mesa/main/texstore.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index f858cef..50aa1fd 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2231,7 +2231,7 @@ _mesa_compute_compressed_pixelstore(GLuint dims, 
mesa_format texFormat,

if (packing->RowLength) {
   store->TotalBytesPerRow = packing->CompressedBlockSize *
-(packing->RowLength + bw - 1) / bw;
+((packing->RowLength + bw - 1) / bw);
}


Could we copy

#define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y))

our of r600_pipe.h into src/util/macros.h and use that? Maybe that'd
be better as a coccinelle patch over the whole tree.

Either way,

Reviewed-by: Matt Turner 


Thanks.  I'm going to commit this as-is for now (simpler to cherry-pick 
to the stable branches).  If someone wants to do ALIGN_DIVUP() later 
that's fine.


-Brian

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


[Mesa-dev] [PATCH 1/2] linker: Wrap access of producer_var with a NULL check

2014-12-01 Thread Ian Romanick
From: Ian Romanick 

producer_var could be NULL if consumer_var is not NULL and
consumer_is_fs is false.  This will occur when the procuder is NULL and
the consumer is the geometry shader for a program that contains only a
geometry shader.  This will occur starting with the next patch.

Signed-off-by: Ian Romanick 
Cc: pa...@klacansky.com
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82585
---
 src/glsl/link_varyings.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 1866ab2..43da2c6 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -835,9 +835,11 @@ varying_matches::record(ir_variable *producer_var, 
ir_variable *consumer_var)
* regardless of where they appear.  We can trivially satisfy that
* requirement by changing the interpolation type to flat here.
*/
-  producer_var->data.centroid = false;
-  producer_var->data.sample = false;
-  producer_var->data.interpolation = INTERP_QUALIFIER_FLAT;
+  if (producer_var) {
+ producer_var->data.centroid = false;
+ producer_var->data.sample = false;
+ producer_var->data.interpolation = INTERP_QUALIFIER_FLAT;
+  }
 
   if (consumer_var) {
  consumer_var->data.centroid = false;
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 2/2] linker: Assign varying locations geometry shader inputs for SSO

2014-12-01 Thread Ian Romanick
From: Ian Romanick 

Previously only geometry shader outputs would be assigned locations if
the geometry shader was the only stage in the linked program.

Signed-off-by: Ian Romanick 
Cc: pa...@klacansky.com
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82585
---
 src/glsl/linker.cpp | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index de6b1fb..6713df1 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2746,6 +2746,21 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
if (last >= 0 && last < MESA_SHADER_FRAGMENT) {
   gl_shader *const sh = prog->_LinkedShaders[last];
 
+  if (first == MESA_SHADER_GEOMETRY) {
+ /* There was no vertex shader, but we still have to assign varying
+  * locations for use by geometry shader inputs in SSO.
+  *
+  * If the shader is not separable (i.e., prog->SeparateShader is
+  * false), linking will have already failed when first is
+  * MESA_SHADER_GEOMETRY.
+  */
+ if (!assign_varying_locations(ctx, mem_ctx, prog,
+   NULL, sh,
+   num_tfeedback_decls, tfeedback_decls,
+   prog->Geom.VerticesIn))
+goto done;
+  }
+
   if (num_tfeedback_decls != 0 || prog->SeparateShader) {
  /* There was no fragment shader, but we still have to assign varying
   * locations for use by transform feedback.
-- 
1.8.1.4

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


  1   2   >