Re: [Mesa-dev] [PATCH v2 1/4] mesa: Implement ext_framebuffer_multisample_blit_scaled extension

2013-05-24 Thread Paul Berry
On 16 May 2013 11:44, Anuj Phogat anuj.pho...@gmail.com wrote:

 Signed-off-by: Anuj Phogat anuj.pho...@gmail.com
 Reviewed-by: Paul Berry stereotype...@gmail.com
 Reviewed-by: Brian Paul bri...@vmware.com
 ---
  src/mesa/main/extensions.c |  1 +
  src/mesa/main/fbobject.c   | 30 +++---
  src/mesa/main/mtypes.h |  1 +
  3 files changed, 29 insertions(+), 3 deletions(-)

 diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
 index db5a5ed..39aaad4 100644
 --- a/src/mesa/main/extensions.c
 +++ b/src/mesa/main/extensions.c
 @@ -184,6 +184,7 @@ static const struct extension extension_table[] = {
 { GL_EXT_fog_coord,   o(EXT_fog_coord),
   GLL,1999 },
 { GL_EXT_framebuffer_blit,
  o(EXT_framebuffer_blit),GL, 2005 },
 { GL_EXT_framebuffer_multisample,
 o(EXT_framebuffer_multisample), GL, 2005 },
 +   { GL_EXT_framebuffer_multisample_blit_scaled,
 o(EXT_framebuffer_multisample_blit_scaled), GL, 2011 },
 { GL_EXT_framebuffer_object,
  o(EXT_framebuffer_object),  GL, 2000 },
 { GL_EXT_framebuffer_sRGB,
  o(EXT_framebuffer_sRGB),GL, 1998 },
 { GL_EXT_gpu_program_parameters,
  o(EXT_gpu_program_parameters),  GLL,2006 },
 diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
 index 80485f7..e7300f6 100644
 --- a/src/mesa/main/fbobject.c
 +++ b/src/mesa/main/fbobject.c
 @@ -2974,6 +2974,20 @@ compatible_resolve_formats(const struct
 gl_renderbuffer *readRb,
 return GL_FALSE;
  }

 +static GLboolean
 +is_valid_blit_filter(const struct gl_context *ctx, GLenum filter)
 +{
 +   switch (filter) {
 +   case GL_NEAREST:
 +   case GL_LINEAR:
 +  return true;
 +   case GL_SCALED_RESOLVE_FASTEST_EXT:
 +   case GL_SCALED_RESOLVE_NICEST_EXT:
 +  return ctx-Extensions.EXT_framebuffer_multisample_blit_scaled;
 +   default:
 +  return false;
 +   }
 +}

  /**
   * Blit rectangular region, optionally from one framebuffer to another.
 @@ -3023,8 +3037,17 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0,
 GLint srcX1, GLint srcY1,
return;
 }

 -   if (filter != GL_NEAREST  filter != GL_LINEAR) {
 -  _mesa_error(ctx, GL_INVALID_ENUM, glBlitFramebufferEXT(filter));
 +   if (!is_valid_blit_filter(ctx, filter)) {
 +  _mesa_error(ctx, GL_INVALID_ENUM, glBlitFramebufferEXT(%s),
 +  _mesa_lookup_enum_by_nr(filter));
 +  return;
 +   }
 +
 +   if ((filter == GL_SCALED_RESOLVE_FASTEST_EXT ||
 +filter == GL_SCALED_RESOLVE_NICEST_EXT) 
 +(readFb-Visual.samples == 0 || drawFb-Visual.samples  0)) {
 +  _mesa_error(ctx, GL_INVALID_OPERATION, glBlitFramebufferEXT(%s),
 +  _mesa_lookup_enum_by_nr(filter));
return;
 }

 @@ -3257,7 +3280,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0,
 GLint srcX1, GLint srcY1,
}

/* extra checks for multisample copies... */
 -  if (readFb-Visual.samples  0 || drawFb-Visual.samples  0) {
 +  if ((readFb-Visual.samples  0 || drawFb-Visual.samples  0) 
 +  (filter == GL_NEAREST || filter == GL_LINEAR)) {
   /* src and dest region sizes must be the same */
   if (abs(srcX1 - srcX0) != abs(dstX1 - dstX0) ||
   abs(srcY1 - srcY0) != abs(dstY1 - dstY0)) {


Later in this function, the following error check appears:

 if (filter == GL_LINEAR) {
/* 3.1 spec, page 199:
 * Calling BlitFramebuffer will result in an INVALID_OPERATION
error
 * if filter is LINEAR and read buffer contains integer data.
 */
GLenum type = _mesa_get_format_datatype(colorReadRb-Format);
if (type == GL_INT || type == GL_UNSIGNED_INT) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
   glBlitFramebufferEXT(integer color type));
   return;
}
 }

This needs to be changed to if (filter != GL_NEAREST) in accordance with
the following text from the extension:

Calling BlitFramebuffer will result in an INVALID_OPERATION error if
filter is not NEAREST and read buffer contains integer data.

With that fixed, this patch is:

Reviewed-by: Paul Berry stereotype...@gmail.com


 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index b68853b..8af6dc6 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -3023,6 +3023,7 @@ struct gl_extensions
 GLboolean EXT_fog_coord;
 GLboolean EXT_framebuffer_blit;
 GLboolean EXT_framebuffer_multisample;
 +   GLboolean EXT_framebuffer_multisample_blit_scaled;
 GLboolean EXT_framebuffer_object;
 GLboolean EXT_framebuffer_sRGB;
 GLboolean EXT_gpu_program_parameters;
 --
 1.8.1.4


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

[Mesa-dev] [PATCH v2 1/4] mesa: Implement ext_framebuffer_multisample_blit_scaled extension

2013-05-16 Thread Anuj Phogat
Signed-off-by: Anuj Phogat anuj.pho...@gmail.com
Reviewed-by: Paul Berry stereotype...@gmail.com
Reviewed-by: Brian Paul bri...@vmware.com
---
 src/mesa/main/extensions.c |  1 +
 src/mesa/main/fbobject.c   | 30 +++---
 src/mesa/main/mtypes.h |  1 +
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index db5a5ed..39aaad4 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -184,6 +184,7 @@ static const struct extension extension_table[] = {
{ GL_EXT_fog_coord,   o(EXT_fog_coord),   
GLL,1999 },
{ GL_EXT_framebuffer_blit,o(EXT_framebuffer_blit),
GL, 2005 },
{ GL_EXT_framebuffer_multisample, 
o(EXT_framebuffer_multisample), GL, 2005 },
+   { GL_EXT_framebuffer_multisample_blit_scaled, 
o(EXT_framebuffer_multisample_blit_scaled), GL, 2011 },
{ GL_EXT_framebuffer_object,  o(EXT_framebuffer_object),  
GL, 2000 },
{ GL_EXT_framebuffer_sRGB,o(EXT_framebuffer_sRGB),
GL, 1998 },
{ GL_EXT_gpu_program_parameters,  
o(EXT_gpu_program_parameters),  GLL,2006 },
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 80485f7..e7300f6 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2974,6 +2974,20 @@ compatible_resolve_formats(const struct gl_renderbuffer 
*readRb,
return GL_FALSE;
 }
 
+static GLboolean
+is_valid_blit_filter(const struct gl_context *ctx, GLenum filter)
+{
+   switch (filter) {
+   case GL_NEAREST:
+   case GL_LINEAR:
+  return true;
+   case GL_SCALED_RESOLVE_FASTEST_EXT:
+   case GL_SCALED_RESOLVE_NICEST_EXT:
+  return ctx-Extensions.EXT_framebuffer_multisample_blit_scaled;
+   default:
+  return false;
+   }
+}
 
 /**
  * Blit rectangular region, optionally from one framebuffer to another.
@@ -3023,8 +3037,17 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
   return;
}
 
-   if (filter != GL_NEAREST  filter != GL_LINEAR) {
-  _mesa_error(ctx, GL_INVALID_ENUM, glBlitFramebufferEXT(filter));
+   if (!is_valid_blit_filter(ctx, filter)) {
+  _mesa_error(ctx, GL_INVALID_ENUM, glBlitFramebufferEXT(%s),
+  _mesa_lookup_enum_by_nr(filter));
+  return;
+   }
+
+   if ((filter == GL_SCALED_RESOLVE_FASTEST_EXT ||
+filter == GL_SCALED_RESOLVE_NICEST_EXT) 
+(readFb-Visual.samples == 0 || drawFb-Visual.samples  0)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, glBlitFramebufferEXT(%s),
+  _mesa_lookup_enum_by_nr(filter));
   return;
}
 
@@ -3257,7 +3280,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
   }
 
   /* extra checks for multisample copies... */
-  if (readFb-Visual.samples  0 || drawFb-Visual.samples  0) {
+  if ((readFb-Visual.samples  0 || drawFb-Visual.samples  0) 
+  (filter == GL_NEAREST || filter == GL_LINEAR)) {
  /* src and dest region sizes must be the same */
  if (abs(srcX1 - srcX0) != abs(dstX1 - dstX0) ||
  abs(srcY1 - srcY0) != abs(dstY1 - dstY0)) {
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b68853b..8af6dc6 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3023,6 +3023,7 @@ struct gl_extensions
GLboolean EXT_fog_coord;
GLboolean EXT_framebuffer_blit;
GLboolean EXT_framebuffer_multisample;
+   GLboolean EXT_framebuffer_multisample_blit_scaled;
GLboolean EXT_framebuffer_object;
GLboolean EXT_framebuffer_sRGB;
GLboolean EXT_gpu_program_parameters;
-- 
1.8.1.4

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