[Mesa-dev,10/10] meta: Support BlitFramebuffer from all the other texture targets.

Submitted by Eric Anholt on March 4, 2014, 10:17 p.m.

Details

Message ID 1393971464-12892-11-git-send-email-eric@anholt.net
State New
Headers show

Not browsing as part of any series.

Commit Message

Eric Anholt March 4, 2014, 10:17 p.m.
There's already code for them due to the GenerateMipmap path, so we just
need to make sure we've got our coordinates present.
---
 src/mesa/drivers/common/meta_blit.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 550133f..a2046d8 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -418,16 +418,6 @@  blitframebuffer_texture(struct gl_context *ctx,
       srcLevel = readAtt->TextureLevel;
       texObj = readAtt->Texture;
       target = texObj->Target;
-
-      switch (target) {
-      case GL_TEXTURE_2D:
-      case GL_TEXTURE_RECTANGLE:
-      case GL_TEXTURE_2D_MULTISAMPLE:
-      case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
-         break;
-      default:
-         return false;
-      }
    } else if (ctx->Driver.BindRenderbufferTexImage) {
       /* Otherwise, we need the driver to be able to bind a renderbuffer as
        * a texture image.
@@ -537,7 +527,9 @@  blitframebuffer_texture(struct gl_context *ctx,
       struct vertex verts[4];
       GLfloat s0, t0, s1, t1;
 
-      if (target == GL_TEXTURE_2D) {
+      if (!(target == GL_TEXTURE_RECTANGLE_ARB ||
+            target == GL_TEXTURE_2D_MULTISAMPLE ||
+            target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
          const struct gl_texture_image *texImage
             = _mesa_select_tex_image(ctx, texObj, target, srcLevel);
          s0 = srcX0 / (float) texImage->Width;
@@ -546,9 +538,6 @@  blitframebuffer_texture(struct gl_context *ctx,
          t1 = srcY1 / (float) texImage->Height;
       }
       else {
-         assert(target == GL_TEXTURE_RECTANGLE_ARB ||
-                target == GL_TEXTURE_2D_MULTISAMPLE ||
-                target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
          s0 = (float) srcX0;
          s1 = (float) srcX1;
          t0 = (float) srcY0;

Comments

On 03/04/2014 02:17 PM, Eric Anholt wrote:
> There's already code for them due to the GenerateMipmap path, so we just
> need to make sure we've got our coordinates present.
> ---
>  src/mesa/drivers/common/meta_blit.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
> index 550133f..a2046d8 100644
> --- a/src/mesa/drivers/common/meta_blit.c
> +++ b/src/mesa/drivers/common/meta_blit.c
> @@ -418,16 +418,6 @@ blitframebuffer_texture(struct gl_context *ctx,
>        srcLevel = readAtt->TextureLevel;
>        texObj = readAtt->Texture;
>        target = texObj->Target;
> -
> -      switch (target) {
> -      case GL_TEXTURE_2D:
> -      case GL_TEXTURE_RECTANGLE:
> -      case GL_TEXTURE_2D_MULTISAMPLE:
> -      case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
> -         break;
> -      default:
> -         return false;
> -      }
>     } else if (ctx->Driver.BindRenderbufferTexImage) {
>        /* Otherwise, we need the driver to be able to bind a renderbuffer as
>         * a texture image.
> @@ -537,7 +527,9 @@ blitframebuffer_texture(struct gl_context *ctx,
>        struct vertex verts[4];
>        GLfloat s0, t0, s1, t1;
>  
> -      if (target == GL_TEXTURE_2D) {
> +      if (!(target == GL_TEXTURE_RECTANGLE_ARB ||
> +            target == GL_TEXTURE_2D_MULTISAMPLE ||
> +            target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {

I think this might be a little easier to read as:
if (target != GL_TEXTURE_RECTANGLE &&
    target != GL_TEXTURE_2D_MULTISAMPLE &&
    target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {

or maybe:
bool unnormalized_coords =
   target == GL_TEXTURE_RECTANGLE ||
   target == GL_TEXTURE_2D_MULTISAMPLE ||
   target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;

if (!unnormalized_coords) {

But, whatever suits you is fine.  This patch is:
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

>           const struct gl_texture_image *texImage
>              = _mesa_select_tex_image(ctx, texObj, target, srcLevel);
>           s0 = srcX0 / (float) texImage->Width;
> @@ -546,9 +538,6 @@ blitframebuffer_texture(struct gl_context *ctx,
>           t1 = srcY1 / (float) texImage->Height;
>        }
>        else {
> -         assert(target == GL_TEXTURE_RECTANGLE_ARB ||
> -                target == GL_TEXTURE_2D_MULTISAMPLE ||
> -                target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
>           s0 = (float) srcX0;
>           s1 = (float) srcX1;
>           t0 = (float) srcY0;
>