<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Dec 2, 2016 at 11:19 AM, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Dec 1, 2016 at 10:35 AM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
><br>
> When I originally implemented the ARB_copy_image extension, the fast-path<br>
> was written in meta using texture views.  This path only worked if both<br>
> images were uncompressed color images.  All of the other cases fell back to<br>
> the blitter or, in the worst case, mapping and memcpy on the CPU.  Now that<br>
> we have the blorp path, it handles all copies ever and the old meta,<br>
> blitter, and CPU paths are only used on gen5 and below.  The primary reason<br>
> why we needed the meta path (apart from having a slow blitter on later<br>
> hardware) was to handle multisampling which gen5 and earlier don't support<br>
> anyway.  Since the blitter is reasonably fast on gen5, we can just delete<br>
> the meta path and get rid of all that terrible code.<br>
><br>
> If we decide that we're ok with just disabling ARB_copy_image on gen5 and<br>
> earlier (I personally am), then we could get rid of another 300 lines or so<br>
> of semi-hairy code.<br>
> ---<br>
>  src/mesa/Makefile.sources                    |   1 -<br>
>  src/mesa/drivers/common/meta.h               |  10 -<br>
>  src/mesa/drivers/common/meta_<wbr>copy_image.c    | 307 ---------------------------<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_copy_image.c |  10 -<br>
>  4 files changed, 328 deletions(-)<br>
>  delete mode 100644 src/mesa/drivers/common/meta_<wbr>copy_image.c<br>
><br>
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources<br>
> index 410a61a..ee737b0 100644<br>
> --- a/src/mesa/Makefile.sources<br>
> +++ b/src/mesa/Makefile.sources<br>
> @@ -621,7 +621,6 @@ COMMON_DRIVER_FILES =                       \<br>
>         drivers/common/driverfuncs.c    \<br>
>         drivers/common/driverfuncs.h    \<br>
>         drivers/common/meta_blit.c      \<br>
> -       drivers/common/meta_copy_<wbr>image.c        \<br>
>         drivers/common/meta_generate_<wbr>mipmap.c   \<br>
>         drivers/common/meta_tex_<wbr>subimage.c      \<br>
>         drivers/common/meta.c \<br>
> diff --git a/src/mesa/drivers/common/<wbr>meta.h b/src/mesa/drivers/common/<wbr>meta.h<br>
> index a7018f5..0a913e9 100644<br>
> --- a/src/mesa/drivers/common/<wbr>meta.h<br>
> +++ b/src/mesa/drivers/common/<wbr>meta.h<br>
> @@ -492,16 +492,6 @@ _mesa_meta_and_swrast_<wbr>BlitFramebuffer(struct gl_context *ctx,<br>
>                                        GLint dstX1, GLint dstY1,<br>
>                                        GLbitfield mask, GLenum filter);<br>
><br>
> -bool<br>
> -_mesa_meta_CopyImageSubData_<wbr>uncompressed(struct gl_context *ctx,<br>
> -                                         struct gl_texture_image *src_tex_image,<br>
> -                                         struct gl_renderbuffer *src_renderbuffer,<br>
> -                                         int src_x, int src_y, int src_z,<br>
> -                                         struct gl_texture_image *dst_tex_image,<br>
> -                                         struct gl_renderbuffer *dst_renderbuffer,<br>
> -                                         int dst_x, int dst_y, int dst_z,<br>
> -                                         int src_width, int src_height);<br>
> -<br>
>  extern void<br>
>  _mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers);<br>
><br>
> diff --git a/src/mesa/drivers/common/<wbr>meta_copy_image.c b/src/mesa/drivers/common/<wbr>meta_copy_image.c<br>
> deleted file mode 100644<br>
> index e1c90a3..0000000<br>
> --- a/src/mesa/drivers/common/<wbr>meta_copy_image.c<br>
> +++ /dev/null<br>
> @@ -1,307 +0,0 @@<br>
> -/*<br>
> - * Mesa 3-D graphics library<br>
> - *<br>
> - * Copyright (C) 2014 Intel Corporation.  All Rights Reserved.<br>
> - *<br>
> - * Permission is hereby granted, free of charge, to any person obtaining a<br>
> - * copy of this software and associated documentation files (the "Software"),<br>
> - * to deal in the Software without restriction, including without limitation<br>
> - * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> - * and/or sell copies of the Software, and to permit persons to whom the<br>
> - * Software is furnished to do so, subject to the following conditions:<br>
> - *<br>
> - * The above copyright notice and this permission notice shall be included<br>
> - * in all copies or substantial portions of the Software.<br>
> - *<br>
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS<br>
> - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
> - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> - * OTHER DEALINGS IN THE SOFTWARE.<br>
> - */<br>
> -<br>
> -#include "glheader.h"<br>
> -#include "context.h"<br>
> -#include "enums.h"<br>
> -#include "imports.h"<br>
> -#include "macros.h"<br>
> -#include "teximage.h"<br>
> -#include "texobj.h"<br>
> -#include "fbobject.h"<br>
> -#include "framebuffer.h"<br>
> -#include "buffers.h"<br>
> -#include "state.h"<br>
> -#include "mtypes.h"<br>
> -#include "meta.h"<br>
> -<br>
> -/**<br>
> - * Create a texture image that wraps a renderbuffer.<br>
> - */<br>
> -static struct gl_texture_image *<br>
> -wrap_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)<br>
> -{<br>
> -   GLenum texTarget;<br>
> -   struct gl_texture_object *texObj;<br>
> -   struct gl_texture_image *texImage;<br>
> -<br>
> -   if (rb->NumSamples > 1)<br>
> -      texTarget = GL_TEXTURE_2D_MULTISAMPLE;<br>
> -   else<br>
> -      texTarget = GL_TEXTURE_2D;<br>
> -<br>
> -   /* Texture ID is not significant since it never goes into the hash table */<br>
> -   texObj = ctx->Driver.NewTextureObject(<wbr>ctx, 0, texTarget);<br>
> -   assert(texObj);<br>
> -   if (!texObj)<br>
> -      return NULL;<br>
> -<br>
> -   texImage = _mesa_get_tex_image(ctx, texObj, texTarget, 0);<br>
> -   assert(texImage);<br>
> -   if (!texImage)<br>
> -      return NULL;<br>
> -<br>
> -   if (!ctx->Driver.<wbr>BindRenderbufferTexImage(ctx, rb, texImage)) {<br>
> -      _mesa_problem(ctx, "Failed to create texture from renderbuffer");<br>
> -      return NULL;<br>
> -   }<br>
> -<br>
> -   if (ctx->Driver.<wbr>FinishRenderTexture && !rb->NeedsFinishRenderTexture) {<br>
> -      rb->NeedsFinishRenderTexture = true;<br>
> -      ctx->Driver.<wbr>FinishRenderTexture(ctx, rb);<br>
> -   }<br>
> -<br>
> -   return texImage;<br>
> -}<br>
> -<br>
> -<br>
> -/* This function makes a texture view without bothering with all of the API<br>
> - * checks.  Most of them are the same for CopyTexSubImage so checking would<br>
> - * be redundant.  The one major difference is that we don't check for<br>
> - * whether the texture is immutable or not.  However, since the view will<br>
> - * be created and then immediately destroyed, this should not be a problem.<br>
> - */<br>
> -static bool<br>
> -make_view(struct gl_context *ctx, struct gl_texture_image *tex_image,<br>
> -          struct gl_texture_image **view_tex_image, GLuint *view_tex_name,<br>
> -          GLenum internal_format)<br>
> -{<br>
> -   struct gl_texture_object *tex_obj = tex_image->TexObject;<br>
> -   struct gl_texture_object *view_tex_obj;<br>
> -   mesa_format tex_format;<br>
> -<br>
> -   /* Set up the new texture object */<br>
> -   _mesa_GenTextures(1, view_tex_name);<br>
> -   view_tex_obj = _mesa_lookup_texture(ctx, *view_tex_name);<br>
> -   if (!view_tex_obj)<br>
> -      return false;<br>
> -<br>
> -   tex_format = _mesa_choose_texture_format(<wbr>ctx, view_tex_obj, tex_obj->Target,<br>
> -                                           0, internal_format,<br>
> -                                           GL_NONE, GL_NONE);<br>
> -<br>
> -   if (!ctx->Driver.<wbr>TestProxyTexImage(ctx, tex_obj->Target, 1, 0, tex_format,<br>
> -                                      1, tex_image->Width, tex_image->Height,<br>
> -                                      tex_image->Depth)) {<br>
> -      _mesa_DeleteTextures(1, view_tex_name);<br>
> -      *view_tex_name = 0;<br>
> -      return false;<br>
> -   }<br>
> -<br>
> -   assert(tex_obj->Target != 0);<br>
> -   assert(tex_obj->TargetIndex < NUM_TEXTURE_TARGETS);<br>
> -<br>
> -   view_tex_obj->Target = tex_obj->Target;<br>
> -   view_tex_obj->TargetIndex = tex_obj->TargetIndex;<br>
> -<br>
> -   *view_tex_image = _mesa_get_tex_image(ctx, view_tex_obj, tex_obj->Target, 0);<br>
> -<br>
> -   if (!*view_tex_image) {<br>
> -      _mesa_DeleteTextures(1, view_tex_name);<br>
> -      *view_tex_name = 0;<br>
> -      return false;<br>
> -   }<br>
> -<br>
> -   _mesa_init_teximage_fields(<wbr>ctx, *view_tex_image,<br>
> -                              tex_image->Width, tex_image->Height,<br>
> -                              tex_image->Depth,<br>
> -                              0, internal_format, tex_format);<br>
> -<br>
> -   view_tex_obj->MinLevel = tex_image->Level;<br>
> -   view_tex_obj->NumLevels = 1;<br>
> -   view_tex_obj->MinLayer = tex_obj->MinLayer;<br>
> -   view_tex_obj->NumLayers = tex_obj->NumLayers;<br>
> -   view_tex_obj->Immutable = tex_obj->Immutable;<br>
> -   view_tex_obj->ImmutableLevels = tex_obj->ImmutableLevels;<br>
> -<br>
> -   if (ctx->Driver.TextureView != NULL &&<br>
> -       !ctx->Driver.TextureView(ctx, view_tex_obj, tex_obj)) {<br>
> -      _mesa_DeleteTextures(1, view_tex_name);<br>
> -      *view_tex_name = 0;<br>
> -      return false; /* driver recorded error */<br>
> -   }<br>
> -<br>
> -   return true;<br>
> -}<br>
> -<br>
> -/** A partial implementation of glCopyImageSubData<br>
> - *<br>
> - * This is a partial implementation of glCopyImageSubData that works only<br>
> - * if both textures are uncompressed and the destination texture is<br>
> - * renderable.  It uses a slight abuse of a texture view (see make_view) to<br>
> - * turn the source texture into the destination texture type and then uses<br>
> - * _mesa_meta_BlitFramebuffers to do the copy.<br>
> - */<br>
> -bool<br>
> -_mesa_meta_CopyImageSubData_<wbr>uncompressed(struct gl_context *ctx,<br>
> -                                         struct gl_texture_image *src_tex_image,<br>
> -                                         struct gl_renderbuffer *src_renderbuffer,<br>
> -                                         int src_x, int src_y, int src_z,<br>
> -                                         struct gl_texture_image *dst_tex_image,<br>
> -                                         struct gl_renderbuffer *dst_renderbuffer,<br>
> -                                         int dst_x, int dst_y, int dst_z,<br>
> -                                         int src_width, int src_height)<br>
> -{<br>
> -   mesa_format src_format, dst_format;<br>
> -   GLint src_internal_format, dst_internal_format;<br>
> -   GLuint src_view_texture = 0;<br>
> -   struct gl_texture_image *src_view_tex_image;<br>
> -   struct gl_framebuffer *readFb;<br>
> -   struct gl_framebuffer *drawFb = NULL;<br>
> -   bool success = false;<br>
> -   GLbitfield mask;<br>
> -   GLenum status, attachment;<br>
> -<br>
> -   if (src_renderbuffer) {<br>
> -      src_format = src_renderbuffer->Format;<br>
> -      src_internal_format = src_renderbuffer-><wbr>InternalFormat;<br>
> -   } else {<br>
> -      assert(src_tex_image);<br>
> -      src_format = src_tex_image->TexFormat;<br>
> -      src_internal_format = src_tex_image->InternalFormat;<br>
> -   }<br>
> -<br>
> -   if (dst_renderbuffer) {<br>
> -      dst_format = dst_renderbuffer->Format;<br>
> -      dst_internal_format = dst_renderbuffer-><wbr>InternalFormat;<br>
> -   } else {<br>
> -      assert(dst_tex_image);<br>
> -      dst_format = dst_tex_image->TexFormat;<br>
> -      dst_internal_format = dst_tex_image->InternalFormat;<br>
> -   }<br>
> -<br>
> -   if (_mesa_is_format_compressed(<wbr>src_format))<br>
> -      return false;<br>
> -<br>
> -   if (_mesa_is_format_compressed(<wbr>dst_format))<br>
> -      return false;<br>
> -<br>
> -   if (src_internal_format == dst_internal_format) {<br>
> -      src_view_tex_image = src_tex_image;<br>
> -   } else {<br>
> -      if (src_renderbuffer) {<br>
> -         assert(src_tex_image == NULL);<br>
> -         src_tex_image = wrap_renderbuffer(ctx, src_renderbuffer);<br>
> -      }<br>
> -      if (!make_view(ctx, src_tex_image, &src_view_tex_image, &src_view_texture,<br>
> -                     dst_internal_format))<br>
> -         goto cleanup;<br>
> -   }<br>
> -<br>
> -   /* We really only need to stash the bound framebuffers and scissor. */<br>
> -   _mesa_meta_begin(ctx, MESA_META_SCISSOR);<br>
> -<br>
> -   readFb = ctx->Driver.NewFramebuffer(<wbr>ctx, 0xDEADBEEF);<br>
> -   if (readFb == NULL)<br>
> -      goto meta_end;<br>
> -<br>
> -   drawFb = ctx->Driver.NewFramebuffer(<wbr>ctx, 0xDEADBEEF);<br>
> -   if (drawFb == NULL)<br>
> -      goto meta_end;<br>
> -<br>
> -   _mesa_bind_framebuffers(ctx, drawFb, readFb);<br>
> -<br>
> -   switch (_mesa_get_format_base_format(<wbr>src_format)) {<br>
> -   case GL_DEPTH_COMPONENT:<br>
> -      attachment = GL_DEPTH_ATTACHMENT;<br>
> -      mask = GL_DEPTH_BUFFER_BIT;<br>
> -      break;<br>
> -   case GL_DEPTH_STENCIL:<br>
> -      attachment = GL_DEPTH_STENCIL_ATTACHMENT;<br>
> -      mask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;<br>
> -      break;<br>
> -   case GL_STENCIL_INDEX:<br>
> -      attachment = GL_STENCIL_ATTACHMENT;<br>
> -      mask = GL_STENCIL_BUFFER_BIT;<br>
> -      break;<br>
> -   default:<br>
> -      attachment = GL_COLOR_ATTACHMENT0;<br>
> -      mask = GL_COLOR_BUFFER_BIT;<br>
> -      _mesa_DrawBuffer(GL_COLOR_<wbr>ATTACHMENT0);<br>
> -      _mesa_ReadBuffer(GL_COLOR_<wbr>ATTACHMENT0);<br>
> -   }<br>
> -<br>
> -   if (src_view_tex_image) {<br>
> -      /* Prefer the tex image because, even if we have a renderbuffer, we may<br>
> -       * have had to wrap it in a texture view.<br>
> -       */<br>
> -      _mesa_meta_framebuffer_<wbr>texture_image(ctx, ctx->ReadBuffer, attachment,<br>
> -                                           src_view_tex_image, src_z);<br>
> -   } else {<br>
> -      _mesa_framebuffer_<wbr>renderbuffer(ctx, ctx->ReadBuffer, attachment,<br>
> -                                     src_renderbuffer);<br>
> -   }<br>
> -<br>
> -   status = _mesa_check_framebuffer_<wbr>status(ctx, ctx->ReadBuffer);<br>
> -   if (status != GL_FRAMEBUFFER_COMPLETE)<br>
> -      goto meta_end;<br>
> -<br>
> -   if (dst_renderbuffer) {<br>
> -      _mesa_framebuffer_<wbr>renderbuffer(ctx, ctx->DrawBuffer, attachment,<br>
> -                                     dst_renderbuffer);<br>
> -   } else {<br>
> -      _mesa_meta_framebuffer_<wbr>texture_image(ctx, ctx->DrawBuffer, attachment,<br>
> -                                           dst_tex_image, dst_z);<br>
> -   }<br>
> -<br>
> -   status = _mesa_check_framebuffer_<wbr>status(ctx, ctx->DrawBuffer);<br>
> -   if (status != GL_FRAMEBUFFER_COMPLETE)<br>
> -      goto meta_end;<br>
> -<br>
> -   /* Explicitly disable sRGB encoding */<br>
> -   ctx->DrawBuffer->Visual.<wbr>sRGBCapable = false;<br>
> -<br>
> -   /* Since we've bound a new draw framebuffer, we need to update its<br>
> -    * derived state -- _Xmin, etc -- for BlitFramebuffer's clipping to<br>
> -    * be correct.<br>
> -    */<br>
> -   _mesa_update_state(ctx);<br>
> -<br>
> -   /* We skip the core BlitFramebuffer checks for format consistency.<br>
> -    * We have already created views to ensure that the texture formats<br>
> -    * match.<br>
> -    */<br>
> -   ctx->Driver.BlitFramebuffer(<wbr>ctx, ctx->ReadBuffer, ctx->DrawBuffer,<br>
> -                               src_x, src_y,<br>
> -                               src_x + src_width, src_y + src_height,<br>
> -                               dst_x, dst_y,<br>
> -                               dst_x + src_width, dst_y + src_height,<br>
> -                               mask, GL_NEAREST);<br>
> -<br>
> -   success = true;<br>
> -<br>
> -meta_end:<br>
> -   _mesa_reference_framebuffer(&<wbr>readFb, NULL);<br>
> -   _mesa_reference_framebuffer(&<wbr>drawFb, NULL);<br>
> -   _mesa_meta_end(ctx);<br>
> -<br>
> -cleanup:<br>
> -   _mesa_DeleteTextures(1, &src_view_texture);<br>
> -<br>
> -   /* If we got a renderbuffer source, delete the temporary texture */<br>
> -   if (src_renderbuffer && src_tex_image)<br>
> -      ctx->Driver.DeleteTexture(ctx, src_tex_image->TexObject);<br>
> -<br>
> -   return success;<br>
> -}<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_copy_image.c b/src/mesa/drivers/dri/i965/<wbr>intel_copy_image.c<br>
> index 56eaed6..85585c7 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_copy_image.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_copy_image.c<br>
> @@ -183,16 +183,6 @@ intel_copy_image_sub_data(<wbr>struct gl_context *ctx,<br>
>     struct intel_mipmap_tree *src_mt, *dst_mt;<br>
>     unsigned src_level, dst_level;<br>
><br>
> -   if (brw->gen < 6 &&<br>
> -       _mesa_meta_CopyImageSubData_<wbr>uncompressed(ctx,<br>
> -                                                src_image, src_renderbuffer,<br>
> -                                                src_x, src_y, src_z,<br>
> -                                                dst_image, dst_renderbuffer,<br>
> -                                                dst_x, dst_y, dst_z,<br>
> -                                                src_width, src_height)) {<br>
> -      return;<br>
> -   }<br>
> -<br>
>     if (src_image) {<br>
>        src_mt = intel_texture_image(src_image)<wbr>->mt;<br>
>        src_level = src_image->Level + src_image->TexObject-><wbr>MinLevel;<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
<br>
Series is:<br>
Reviewed-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>><br>
</blockquote></div><br></div><div class="gmail_extra">Thanks!<br></div><div class="gmail_extra"><br></div></div>