Re: [Mesa-dev] [PATCH 5/7] mesa: allow multisample texture targets in [Get]TexParameter*

2013-03-18 Thread Eric Anholt
Chris Forbes chr...@ijw.co.nz writes:

 ARB_texture_storage_multisample allows texture parameters to be
 queried for TEXTURE_2D_MULTISAMPLE and TEXTURE_2D_MULTISAMPLE_ARRAY
 targets.

 Some parameters may also be set, with the following exceptions:

 - TEXTURE_BASE_LEVEL may not be set to a nonzero value; generates
INVALID_OPERATION

 - any state which appears in the `per-sampler` state table may not
   be set; generates INVALID_OPERATION


 @@ -348,6 +392,11 @@ set_tex_parameteri(struct gl_context *ctx,
 case GL_TEXTURE_MAX_LEVEL:
if (texObj-MaxLevel == params[0])
   return GL_FALSE;
 +
 +  if ((texObj-Target == GL_TEXTURE_2D_MULTISAMPLE ||
 +   texObj-Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)  params[0] 
 != 0)
 + goto invalid_operation;

I don't see anything banning MAX_LEVEL != 0 -- it's not sampler state,
and it's not otherwise called out.  On the other hand, there's no
useful thing you could do with MAX_LEVEL != 0, since it's a single-level
texture type.

I don't have an opinion either way, really.


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


[Mesa-dev] [PATCH 5/7] mesa: allow multisample texture targets in [Get]TexParameter*

2013-03-15 Thread Chris Forbes
ARB_texture_storage_multisample allows texture parameters to be
queried for TEXTURE_2D_MULTISAMPLE and TEXTURE_2D_MULTISAMPLE_ARRAY
targets.

Some parameters may also be set, with the following exceptions:

- TEXTURE_BASE_LEVEL may not be set to a nonzero value; generates
   INVALID_OPERATION

- any state which appears in the `per-sampler` state table may not
  be set; generates INVALID_OPERATION

Signed-off-by: Chris Forbes chr...@ijw.co.nz
---
 src/mesa/main/texparam.c | 92 +++-
 1 file changed, 91 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 120845b..07a0eb0 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -175,6 +175,16 @@ get_texobj(struct gl_context *ctx, GLenum target, 
GLboolean get)
  return texUnit-CurrentTex[TEXTURE_CUBE_ARRAY_INDEX];
   }
   break;
+   case GL_TEXTURE_2D_MULTISAMPLE:
+  if (ctx-Extensions.ARB_texture_storage_multisample) {
+ return texUnit-CurrentTex[TEXTURE_2D_MULTISAMPLE_INDEX];
+  }
+  break;
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+  if (ctx-Extensions.ARB_texture_storage_multisample) {
+ return texUnit-CurrentTex[TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX];
+  }
+  break;
default:
   ;
}
@@ -250,6 +260,20 @@ incomplete(struct gl_context *ctx, struct 
gl_texture_object *texObj)
 }
 
 
+static GLboolean
+target_allows_setting_sampler_parameters(GLenum target)
+{
+   switch (target) {
+   case GL_TEXTURE_2D_MULTISAMPLE:
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+  return GL_FALSE;
+
+   default:
+  return GL_TRUE;
+   }
+}
+
+
 /**
  * Set an integer-valued texture parameter
  * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
@@ -261,6 +285,9 @@ set_tex_parameteri(struct gl_context *ctx,
 {
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
+  if (!target_allows_setting_sampler_parameters(texObj-Target))
+ goto invalid_operation;
+
   if (texObj-Sampler.MinFilter == params[0])
  return GL_FALSE;
   switch (params[0]) {
@@ -286,6 +313,9 @@ set_tex_parameteri(struct gl_context *ctx,
   return GL_FALSE;
 
case GL_TEXTURE_MAG_FILTER:
+  if (!target_allows_setting_sampler_parameters(texObj-Target))
+ goto invalid_operation;
+
   if (texObj-Sampler.MagFilter == params[0])
  return GL_FALSE;
   switch (params[0]) {
@@ -300,6 +330,9 @@ set_tex_parameteri(struct gl_context *ctx,
   return GL_FALSE;
 
case GL_TEXTURE_WRAP_S:
+  if (!target_allows_setting_sampler_parameters(texObj-Target))
+ goto invalid_operation;
+
   if (texObj-Sampler.WrapS == params[0])
  return GL_FALSE;
   if (validate_texture_wrap_mode(ctx, texObj-Target, params[0])) {
@@ -310,6 +343,9 @@ set_tex_parameteri(struct gl_context *ctx,
   return GL_FALSE;
 
case GL_TEXTURE_WRAP_T:
+  if (!target_allows_setting_sampler_parameters(texObj-Target))
+ goto invalid_operation;
+
   if (texObj-Sampler.WrapT == params[0])
  return GL_FALSE;
   if (validate_texture_wrap_mode(ctx, texObj-Target, params[0])) {
@@ -320,6 +356,9 @@ set_tex_parameteri(struct gl_context *ctx,
   return GL_FALSE;
 
case GL_TEXTURE_WRAP_R:
+  if (!target_allows_setting_sampler_parameters(texObj-Target))
+ goto invalid_operation;
+
   if (texObj-Sampler.WrapR == params[0])
  return GL_FALSE;
   if (validate_texture_wrap_mode(ctx, texObj-Target, params[0])) {
@@ -335,6 +374,11 @@ set_tex_parameteri(struct gl_context *ctx,
 
   if (texObj-BaseLevel == params[0])
  return GL_FALSE;
+
+  if ((texObj-Target == GL_TEXTURE_2D_MULTISAMPLE ||
+   texObj-Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)  params[0] != 
0)
+ goto invalid_operation;
+
   if (params[0]  0 ||
   (texObj-Target == GL_TEXTURE_RECTANGLE_ARB  params[0] != 0)) {
  _mesa_error(ctx, GL_INVALID_VALUE,
@@ -348,6 +392,11 @@ set_tex_parameteri(struct gl_context *ctx,
case GL_TEXTURE_MAX_LEVEL:
   if (texObj-MaxLevel == params[0])
  return GL_FALSE;
+
+  if ((texObj-Target == GL_TEXTURE_2D_MULTISAMPLE ||
+   texObj-Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)  params[0] != 
0)
+ goto invalid_operation;
+
   if (params[0]  0 || texObj-Target == GL_TEXTURE_RECTANGLE_ARB) {
  _mesa_error(ctx, GL_INVALID_VALUE,
  glTexParameter(param=%d), params[0]);
@@ -373,6 +422,10 @@ set_tex_parameteri(struct gl_context *ctx,
case GL_TEXTURE_COMPARE_MODE_ARB:
   if ((_mesa_is_desktop_gl(ctx)  ctx-Extensions.ARB_shadow)
   || _mesa_is_gles3(ctx)) {
+
+ if (!target_allows_setting_sampler_parameters(texObj-Target))
+goto invalid_operation;
+
  if (texObj-Sampler.CompareMode == params[0])
 return GL_FALSE;
  if (params[0] == GL_NONE ||
@@ -388,6 +441,10 @@