[Mesa-dev] [PATCH] llvmpipe: simplify lp_resource_copy()

Roland Scheidegger sroland at vmware.com
Wed Jun 10 07:28:23 PDT 2015


I don't think this can potentially fix anything, since buffers were
falling back to using util_resource_copy_region() already.
I am actually wondering though if the separate flushing done in
lp_resource_copy() is still necessary given that it should be done when
getting the transfers in util_resource_copy_region().
In any case, this makes sense (I think the code was mostly there because
it originated from something quite different to
util_resource_copy_region(), to handle the swizzled/unswizzled copies in
some more direct way back).

Reviewed-by: Roland Scheidegger <sroland at vmware.com>


Am 10.06.2015 um 16:06 schrieb Jose Fonseca:
> Indeed I don't see any reason not to use  util_resource_copy_region.
> 
> In fact, it might actually fix some bugs, as llvmpipe_transfer_map()
> which has some extra smarts for tracking diry constant buffers, which
> was not being exercised by lp_resource_copy().
> 
> Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
> 
> 
> Jose
> 
> On 10/06/15 14:35, Brian Paul wrote:
>> Just implement it in terms of util_resource_copy_region().  Both the
>> original code and util_resource_copy_region() boil down to mapping,
>> calling util_copy_box() and unmapping.
>>
>> No piglit regressions.  This will also help to implement
>> GL_ARB_copy_image.
>> ---
>>   src/gallium/drivers/llvmpipe/lp_surface.c | 61
>> +------------------------------
>>   1 file changed, 2 insertions(+), 59 deletions(-)
>>
>> diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c
>> b/src/gallium/drivers/llvmpipe/lp_surface.c
>> index b985877..96f8ed8 100644
>> --- a/src/gallium/drivers/llvmpipe/lp_surface.c
>> +++ b/src/gallium/drivers/llvmpipe/lp_surface.c
>> @@ -42,13 +42,6 @@ lp_resource_copy(struct pipe_context *pipe,
>>                    struct pipe_resource *src, unsigned src_level,
>>                    const struct pipe_box *src_box)
>>   {
>> -   struct llvmpipe_resource *src_tex = llvmpipe_resource(src);
>> -   struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst);
>> -   const enum pipe_format format = src_tex->base.format;
>> -   unsigned width = src_box->width;
>> -   unsigned height = src_box->height;
>> -   unsigned depth = src_box->depth;
>> -
>>      llvmpipe_flush_resource(pipe,
>>                              dst, dst_level,
>>                              FALSE, /* read_only */
>> @@ -63,58 +56,8 @@ lp_resource_copy(struct pipe_context *pipe,
>>                              FALSE, /* do_not_block */
>>                              "blit src");
>>
>> -   /* Fallback for buffers. */
>> -   if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
>> -      util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
>> -                                src, src_level, src_box);
>> -      return;
>> -   }
>> -
>> -   /*
>> -   printf("surface copy from %u lvl %u to %u lvl %u: %u,%u,%u to
>> %u,%u,%u %u x %u x %u\n",
>> -          src_tex->id, src_level, dst_tex->id, dst_level,
>> -          src_box->x, src_box->y, src_box->z, dstx, dsty, dstz,
>> -          src_box->width, src_box->height, src_box->depth);
>> -   */
>> -
>> -   /* make sure display target resources (which cannot have
>> levels/layers) are mapped */
>> -   if (src_tex->dt)
>> -      (void) llvmpipe_resource_map(src, src_level, 0,
>> LP_TEX_USAGE_READ);
>> -   if (dst_tex->dt)
>> -      /*
>> -       * Could set this to WRITE_ALL if complete dst is covered but
>> it gets
>> -       * ignored anyway.
>> -       */
>> -      (void) llvmpipe_resource_map(dst, dst_level, 0,
>> LP_TEX_USAGE_READ_WRITE);
>> -
>> -
>> -   /* copy */
>> -   {
>> -      const ubyte *src_linear_ptr
>> -         = llvmpipe_get_texture_image_address(src_tex, src_box->z,
>> -                                              src_level);
>> -      ubyte *dst_linear_ptr
>> -         = llvmpipe_get_texture_image_address(dst_tex, dstz,
>> -                                              dst_level);
>> -
>> -      if (dst_linear_ptr && src_linear_ptr) {
>> -         util_copy_box(dst_linear_ptr, format,
>> -                       llvmpipe_resource_stride(&dst_tex->base,
>> dst_level),
>> -                       dst_tex->img_stride[dst_level],
>> -                       dstx, dsty, 0,
>> -                       width, height, depth,
>> -                       src_linear_ptr,
>> -                       llvmpipe_resource_stride(&src_tex->base,
>> src_level),
>> -                       src_tex->img_stride[src_level],
>> -                       src_box->x, src_box->y, 0);
>> -      }
>> -   }
>> -
>> -   if (src_tex->dt)
>> -      llvmpipe_resource_unmap(src, 0, 0);
>> -   if (dst_tex->dt)
>> -      llvmpipe_resource_unmap(dst, 0, 0);
>> -
>> +   util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
>> +                             src, src_level, src_box);
>>   }
>>
>>
>>
> 



More information about the mesa-dev mailing list