Mesa (master): mesa: Fix error returned by glCopyTexImage2D() upon an invalid internal format

2015-08-05 Thread Eduardo Lima Mitev
Module: Mesa
Branch: master
Commit: 4b07e9a033ddb6733eba206b5bd47a2373756f7d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b07e9a033ddb6733eba206b5bd47a2373756f7d

Author: Eduardo Lima Mitev el...@igalia.com
Date:   Wed Jul 29 16:01:28 2015 +0200

mesa: Fix error returned by glCopyTexImage2D() upon an invalid internal format

Page 161 of the OpenGL-ES 3.1 (PDF) spec, and page 207 of the OpenGL 4.5 (PDF),
both on section '8.6. ALTERNATE TEXTURE IMAGE SPECIFICATION COMMANDS', states:

An INVALID_ENUM error is generated if an invalid value is specified for
 internalformat.

It is currently returning INVALID_OPERATION error because
_mesa_get_read_renderbuffer_for_format() is called before the internalformat
argument has been validated. To fix this, we move this call down the validation
process, after _mesa_base_tex_format() has been called. _mesa_base_tex_format()
effectively serves as a validator for the internal format.

Fixes 1 dEQP test:
* dEQP-GLES3.functional.negative_api.texture.copyteximage2d_invalid_format

Fixes 1 piglit test:
* spec@oes_compressed_etc1_rgb8_texture@basic

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Cc: 10.6 mesa-sta...@lists.freedesktop.org

---

 src/mesa/main/teximage.c |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 115dee6..d19ad64 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2630,13 +2630,6 @@ copytexture_error_check( struct gl_context *ctx, GLuint 
dimensions,
   return GL_TRUE;
}
 
-   rb = _mesa_get_read_renderbuffer_for_format(ctx, internalFormat);
-   if (rb == NULL) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  glCopyTexImage%dD(read buffer), dimensions);
-  return GL_TRUE;
-   }
-
/* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the
 * internalFormat.
 */
@@ -2649,7 +2642,7 @@ copytexture_error_check( struct gl_context *ctx, GLuint 
dimensions,
   case GL_LUMINANCE_ALPHA:
  break;
   default:
- _mesa_error(ctx, GL_INVALID_VALUE,
+ _mesa_error(ctx, GL_INVALID_ENUM,
  glCopyTexImage%dD(internalFormat=%s), dimensions,
  _mesa_enum_to_string(internalFormat));
  return GL_TRUE;
@@ -2658,12 +2651,19 @@ copytexture_error_check( struct gl_context *ctx, GLuint 
dimensions,
 
baseFormat = _mesa_base_tex_format(ctx, internalFormat);
if (baseFormat  0) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
+  _mesa_error(ctx, GL_INVALID_ENUM,
   glCopyTexImage%dD(internalFormat=%s), dimensions,
   _mesa_enum_to_string(internalFormat));
   return GL_TRUE;
}
 
+   rb = _mesa_get_read_renderbuffer_for_format(ctx, internalFormat);
+   if (rb == NULL) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  glCopyTexImage%dD(read buffer), dimensions);
+  return GL_TRUE;
+   }
+
rb_internal_format = rb-InternalFormat;
rb_base_format = _mesa_base_tex_format(ctx, rb-InternalFormat);
if (_mesa_is_color_format(internalFormat)) {

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


Mesa (master): mesa: Fix errors values returned by glShaderBinary()

2015-08-05 Thread Eduardo Lima Mitev
Module: Mesa
Branch: master
Commit: b38a50f1e3edae6079c91f73a8d9c63a2dbf512a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b38a50f1e3edae6079c91f73a8d9c63a2dbf512a

Author: Eduardo Lima Mitev el...@igalia.com
Date:   Wed Jul 29 16:01:23 2015 +0200

mesa: Fix errors values returned by glShaderBinary()

Page 68, section 7.2 'Shader Binaries of the of the OpenGL ES 3.1,
and page 88 of the OpenGL 4.5 specs state:

An INVALID_VALUE error is generated if count or length is negative.
 An INVALID_ENUM error is generated if binaryformat is not a supported
 format returned in SHADER_BINARY_FORMATS.

Currently, an INVALID_OPERATION error is returned for all cases.

Fixes 1 dEQP test:
* dEQP-GLES3.functional.negative_api.shader.shader_binary

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Cc: 10.6 mesa-sta...@lists.freedesktop.org

---

 src/mesa/main/shaderapi.c |   17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index b702dcd..5b28a2c 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1793,12 +1793,23 @@ _mesa_ShaderBinary(GLint n, const GLuint* shaders, 
GLenum binaryformat,
const void* binary, GLint length)
 {
GET_CURRENT_CONTEXT(ctx);
-   (void) n;
(void) shaders;
(void) binaryformat;
(void) binary;
-   (void) length;
-   _mesa_error(ctx, GL_INVALID_OPERATION, glShaderBinary);
+
+   /* Page 68, section 7.2 'Shader Binaries of the of the OpenGL ES 3.1, and
+* page 88 of the OpenGL 4.5 specs state:
+*
+* An INVALID_VALUE error is generated if count or length is negative.
+*  An INVALID_ENUM error is generated if binaryformat is not a 
supported
+*  format returned in SHADER_BINARY_FORMATS.
+*/
+   if (n  0 || length  0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, glShaderBinary(count or length  
0));
+  return;
+   }
+
+   _mesa_error(ctx, GL_INVALID_ENUM, glShaderBinary(format));
 }
 
 

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


Mesa (master): mesa: Validate target before resolving tex obj in glTex( ture)SubImageXD

2015-08-05 Thread Eduardo Lima Mitev
Module: Mesa
Branch: master
Commit: 5d64cae8427b090c42d6d38da7fb474b3ddd4eb0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5d64cae8427b090c42d6d38da7fb474b3ddd4eb0

Author: Eduardo Lima Mitev el...@igalia.com
Date:   Wed Jul 29 16:01:26 2015 +0200

mesa: Validate target before resolving tex obj in glTex(ture)SubImageXD

Currently, glTexSubImageXD attempt to resolve the texture object
(by calling _mesa_get_current_tex_object()) before validating the given
target. However, that method explicitly states that target must have been
validated before calling it, so it never returns a user error.

The target validation occurs later when texsubimage_error_check() is called.

This patch reorganizes target validation, taking it out from the error check
function and into a point before the texture object is resolved.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Cc: 10.6 mesa-sta...@lists.freedesktop.org

---

 src/mesa/main/teximage.c |   29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 841ec36..115dee6 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2487,13 +2487,6 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
dimensions,
   return GL_TRUE;
}
 
-   /* check target (proxies not allowed) */
-   if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) {
-  _mesa_error(ctx, GL_INVALID_ENUM, %s(target=%s),
-  callerName, _mesa_enum_to_string(target));
-  return GL_TRUE;
-   }
-
/* level check */
if (level  0 || level = _mesa_max_texture_levels(ctx, target)) {
   _mesa_error(ctx, GL_INVALID_VALUE, %s(level=%d), callerName, level);
@@ -3522,14 +3515,6 @@ _mesa_texture_sub_image(struct gl_context *ctx, GLuint 
dims,
 {
FLUSH_VERTICES(ctx, 0);
 
-   /* check target (proxies not allowed) */
-   if (!legal_texsubimage_target(ctx, dims, target, dsa)) {
-  _mesa_error(ctx, GL_INVALID_ENUM, glTex%sSubImage%uD(target=%s),
-  dsa ? ture : ,
-  dims, _mesa_enum_to_string(target));
-  return;
-   }
-
if (ctx-NewState  _NEW_PIXEL)
   _mesa_update_state(ctx);
 
@@ -3579,6 +3564,13 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum 
target, GLint level,
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
 
+   /* check target (proxies not allowed) */
+   if (!legal_texsubimage_target(ctx, dims, target, false)) {
+  _mesa_error(ctx, GL_INVALID_ENUM, glTexSubImage%uD(target=%s),
+  dims, _mesa_enum_to_string(target));
+  return;
+   }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
   return;
@@ -3639,6 +3631,13 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
   return;
}
 
+   /* check target (proxies not allowed) */
+   if (!legal_texsubimage_target(ctx, dims, texObj-Target, true)) {
+  _mesa_error(ctx, GL_INVALID_ENUM, %s(target=%s),
+  callerName, _mesa_enum_to_string(texObj-Target));
+  return;
+   }
+
if (texsubimage_error_check(ctx, dims, texObj, texObj-Target, level,
xoffset, yoffset, zoffset,
width, height, depth, format, type,

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


Mesa (master): mesa: Add missing check of format and type in glTexSubImageXD on GLES 3.0

2015-08-05 Thread Eduardo Lima Mitev
Module: Mesa
Branch: master
Commit: 03b7221dbb93e2439f30b2e0918f6215eb741979
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=03b7221dbb93e2439f30b2e0918f6215eb741979

Author: Eduardo Lima Mitev el...@igalia.com
Date:   Wed Jul 29 16:01:27 2015 +0200

mesa: Add missing check of format and type in glTexSubImageXD on GLES 3.0

Argument validation for glTexSubImageXD is missing a check of format and type
against texture object's internal format when profile is OpenGL-ES 3.0+.

This patch also groups together all format and type checks on GLES into a
new function texture_format_error_check_gles(), to factorize similar
code in texture_format_error_check().

Fixes 2 dEQP tests:
* dEQP-GLES3.functional.negative_api.texture.texsubimage2d
* dEQP-GLES3.functional.negative_api.texture.texsubimage3d

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Brian Paul bri...@vmware.com

---

 src/mesa/main/teximage.c |  116 +++---
 1 file changed, 69 insertions(+), 47 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index d19ad64..fc69387 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2089,6 +2089,53 @@ texture_formats_agree(GLenum internalFormat,
 }
 
 /**
+ * Test the combination of format, type and internal format arguments of
+ * different texture operations on GLES.
+ *
+ * \param ctx GL context.
+ * \param format pixel data format given by the user.
+ * \param type pixel data type given by the user.
+ * \param internalFormat internal format given by the user.
+ * \param dimensions texture image dimensions (must be 1, 2 or 3).
+ * \param callerName name of the caller function to print in the error message
+ *
+ * \return true if a error is found, false otherwise
+ *
+ * Currently, it is used by texture_error_check() and 
texsubimage_error_check().
+ */
+static bool
+texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
+GLenum type, GLenum internalFormat,
+GLuint dimensions, const char *callerName)
+{
+   GLenum err;
+
+   if (_mesa_is_gles3(ctx)) {
+  err = _mesa_es3_error_check_format_and_type(ctx, format, type,
+  internalFormat);
+  if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err,
+ %s(format = %s, type = %s, internalformat = %s),
+ callerName, _mesa_enum_to_string(format),
+ _mesa_enum_to_string(type),
+ _mesa_enum_to_string(internalFormat));
+ return true;
+  }
+   }
+   else {
+  err = _mesa_es_error_check_format_and_type(format, type, dimensions);
+  if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err, %s(format = %s, type = %s),
+ callerName, _mesa_enum_to_string(format),
+ _mesa_enum_to_string(type));
+ return true;
+  }
+   }
+
+   return false;
+}
+
+/**
  * Test the glTexImage[123]D() parameters for errors.
  *
  * \param ctx GL context.
@@ -2159,32 +2206,10 @@ texture_error_check( struct gl_context *ctx,
 * Formats and types that require additional extensions (e.g., GL_FLOAT
 * requires GL_OES_texture_float) are filtered elsewhere.
 */
-
-   if (_mesa_is_gles(ctx)) {
-  if (_mesa_is_gles3(ctx)) {
- err = _mesa_es3_error_check_format_and_type(ctx, format, type,
- internalFormat);
-  } else {
- if (format != internalFormat) {
-_mesa_error(ctx, GL_INVALID_OPERATION,
-glTexImage%dD(format = %s, internalFormat = %s),
-dimensions,
-_mesa_enum_to_string(format),
-_mesa_enum_to_string(internalFormat));
-return GL_TRUE;
- }
-
- err = _mesa_es_error_check_format_and_type(format, type, dimensions);
-  }
-  if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err,
- glTexImage%dD(format = %s, type = %s, internalFormat = 
%s),
- dimensions,
- _mesa_enum_to_string(format),
- _mesa_enum_to_string(type),
- _mesa_enum_to_string(internalFormat));
- return GL_TRUE;
-  }
+   if (_mesa_is_gles(ctx) 
+   texture_format_error_check_gles(ctx, format, type, internalFormat,
+   dimensions, glTexImage%dD)) {
+ return GL_TRUE;
}
 
/* Check internalFormat */
@@ -2493,19 +2518,12 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
dimensions,
   return GL_TRUE;
}
 
-   /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the
-* combinations of format and type that can be used.  Formats and types
-* that require additional extensions (e.g., GL_FLOAT requires
-* GL_OES_texture_float) are 

Mesa (master): nir: add missing type to type_size_vec4()

2015-08-05 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 2c61d583f8c931fc9834dd852b1c960c95acefb5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c61d583f8c931fc9834dd852b1c960c95acefb5

Author: Timothy Arceri t_arc...@yahoo.com.au
Date:   Wed Aug  5 20:27:24 2015 +1000

nir: add missing type to type_size_vec4()

Reviewed-by: Iago Toral Quiroga ito...@igalia.com

---

 src/glsl/nir/nir_lower_io.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index 3c17929..71bfd34 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -62,6 +62,8 @@ type_size_vec4(const struct glsl_type *type)
  size += type_size_vec4(glsl_get_struct_field(type, i));
   }
   return size;
+   case GLSL_TYPE_SUBROUTINE:
+  return 1;
case GLSL_TYPE_SAMPLER:
   return 0;
case GLSL_TYPE_ATOMIC_UINT:

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


Mesa (master): glsl: Initialize patch member of glsl_struct_field

2015-08-05 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: f7ac4ef4eeea737115d0b574fed7ecae46426072
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7ac4ef4eeea737115d0b574fed7ecae46426072

Author: Michel Dänzer michel.daen...@amd.com
Date:   Wed Aug  5 18:17:14 2015 +0900

glsl: Initialize patch member of glsl_struct_field

There is apparently a subtle difference in C++ between

F f;

and

F f();

The former will use the default constructor.  If there is no default
constructor specified, the compiler provides one that simply invokes the
default constructor for each field.  For built-in basic types, the
default constructor does nothing.  The later will, according to
http://stackoverflow.com/questions/2417065/does-the-default-constructor-initialize-built-in-types)
perform value-initialization of the type.  For built-in types this means
initializing to zero.

The per_vertex_accumulator constructor is:

per_vertex_accumulator::per_vertex_accumulator()
   : fields(),
 num_fields(0)
{
}

This is the second form of constructor, so the glsl_struct_field
objects were previously zero initialized.  With the addition of an empty
default constructor in commit 7ac946e5, per_vertex_accumulator::fields
receive no initialization.

Fixes a bunch of random (mostly tessellation related) piglit failures
since commit 7ac946e5 (glsl: Add constuctors for the common cases of
glsl_struct_field).

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91544
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/builtin_variables.cpp |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 0ff3a3f..53d3500 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -322,6 +322,7 @@ per_vertex_accumulator::add_field(int slot, const glsl_type 
*type,
this-fields[this-num_fields].interpolation = INTERP_QUALIFIER_NONE;
this-fields[this-num_fields].centroid = 0;
this-fields[this-num_fields].sample = 0;
+   this-fields[this-num_fields].patch = 0;
this-num_fields++;
 }
 
@@ -1159,6 +1160,7 @@ builtin_variable_generator::generate_varyings()
  var-data.interpolation = fields[i].interpolation;
  var-data.centroid = fields[i].centroid;
  var-data.sample = fields[i].sample;
+ var-data.patch = fields[i].patch;
  var-init_interface_type(per_vertex_out_type);
   }
}

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