[Mesa-dev] [PATCH 4/9] st/mesa: add st_CopyImageSubData() function

Brian Paul brianp at vmware.com
Thu Aug 27 17:18:30 PDT 2015


On 08/27/2015 05:59 PM, Ilia Mirkin wrote:
> You need to rip out the st_CopyImageSubData I already added in
> st_cb_texture.c (I think).

Yes, I created my feature branch before you added that code.  I'll have 
to rebase onto master.  A patch to remove your code will be trivial.

-Brian

>
> On Thu, Aug 27, 2015 at 7:47 PM, Brian Paul <brianp at vmware.com> wrote:
>> From: Neha Bhende <nbhende at vmware.com>
>>
>> Basically, get the src/dst pipe_resource surfaces and call the
>> pipe_context::resource_copy_region() function.
>>
>> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
>> ---
>>   src/mesa/Makefile.sources                |  2 +
>>   src/mesa/state_tracker/st_cb_copyimage.c | 94 ++++++++++++++++++++++++++++++++
>>   src/mesa/state_tracker/st_cb_copyimage.h | 34 ++++++++++++
>>   src/mesa/state_tracker/st_context.c      |  2 +
>>   4 files changed, 132 insertions(+)
>>   create mode 100644 src/mesa/state_tracker/st_cb_copyimage.c
>>   create mode 100644 src/mesa/state_tracker/st_cb_copyimage.h
>>
>> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
>> index ed9848c..3eb9258 100644
>> --- a/src/mesa/Makefile.sources
>> +++ b/src/mesa/Makefile.sources
>> @@ -421,6 +421,8 @@ STATETRACKER_FILES = \
>>          state_tracker/st_cb_clear.h \
>>          state_tracker/st_cb_condrender.c \
>>          state_tracker/st_cb_condrender.h \
>> +       state_tracker/st_cb_copyimage.h \
>> +       state_tracker/st_cb_copyimage.c \
>>          state_tracker/st_cb_drawpixels.c \
>>          state_tracker/st_cb_drawpixels.h \
>>          state_tracker/st_cb_drawtex.c \
>> diff --git a/src/mesa/state_tracker/st_cb_copyimage.c b/src/mesa/state_tracker/st_cb_copyimage.c
>> new file mode 100644
>> index 0000000..6d68996
>> --- /dev/null
>> +++ b/src/mesa/state_tracker/st_cb_copyimage.c
>> @@ -0,0 +1,94 @@
>> +/**************************************************************************
>> + *
>> + * Copyright 2015 VMware, Inc.
>> + * All Rights Reserved.
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the
>> + * "Software"), to deal in the Software without restriction, including
>> + * without limitation the rights to use, copy, modify, merge, publish,
>> + * distribute, sub license, and/or sell copies of the Software, and to
>> + * permit persons to whom the Software is furnished to do so, subject to
>> + * the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the
>> + * next paragraph) shall be included in all copies or substantial portions
>> + * of the Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
>> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
>> + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
>> + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
>> + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
>> + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
>> + *
>> + **************************************************************************/
>> +/*
>> + * Authors:
>> + *     Neha Bhende
>> + */
>> +
>> +#include <stdio.h>
>> +#include "st_context.h"
>> +#include "st_texture.h"
>> +#include "st_cb_copyimage.h"
>> +#include "st_cb_fbo.h"
>> +#include "util/u_inlines.h"
>> +
>> +
>> +static void
>> +st_CopyImageSubData(struct gl_context *ctx,
>> +                    struct gl_texture_image *srcTexImage,
>> +                    struct gl_renderbuffer *srcRenderbuffer, GLint srcX,
>> +                    GLint srcY, GLint srcZ,
>> +                    struct gl_texture_image *dstTexImage,
>> +                    struct gl_renderbuffer *dstRenderbuffer, GLint dstX,
>> +                    GLint dstY, GLint dstZ, GLsizei srcWidth,
>> +                    GLsizei srcHeight)
>> +{
>> +   struct pipe_context *pipe = st_context(ctx)->pipe;
>> +   struct pipe_resource *src, *dst;
>> +   GLuint srcLevel, dstLevel;
>> +   struct pipe_box src_box;
>> +
>> +   /* Get pointer to source pipe_resource and setup srcLevel, srcZ */
>> +   if (srcTexImage) {
>> +      src = st_texture_image(srcTexImage)->pt;
>> +      srcLevel = srcTexImage->Level;
>> +      if (srcTexImage->Face > 0) {
>> +         srcZ = srcTexImage->Face;
>> +      }
>> +   }
>> +   else {
>> +      assert(srcRenderbuffer != NULL);
>> +      src = st_renderbuffer(srcRenderbuffer)->texture;
>> +      srcLevel = 0;
>> +   }
>> +
>> +   /* Get pointer to dest pipe_resource and setup dstLevel, dstZ */
>> +   if (dstTexImage) {
>> +      dst = st_texture_image(dstTexImage)->pt;
>> +      dstLevel = dstTexImage->Level;
>> +      if (dstTexImage->Face > 0) {
>> +         dstZ = dstTexImage->Face;
>> +      }
>> +   }
>> +   else {
>> +      assert(dstRenderbuffer != NULL);
>> +      dst = st_renderbuffer(dstRenderbuffer)->texture;
>> +      dstLevel = 0;
>> +   }
>> +
>> +   u_box_2d_zslice(srcX, srcY, srcZ, srcWidth, srcHeight, &src_box);
>> +
>> +   pipe->resource_copy_region(pipe, dst, dstLevel, dstX, dstY, dstZ,
>> +                              src, srcLevel, &src_box);
>> +}
>> +
>> +
>> +void
>> +st_init_copy_image_functions(struct dd_function_table *functions)
>> +{
>> +   functions->CopyImageSubData = st_CopyImageSubData;
>> +}
>> diff --git a/src/mesa/state_tracker/st_cb_copyimage.h b/src/mesa/state_tracker/st_cb_copyimage.h
>> new file mode 100644
>> index 0000000..86cfc06
>> --- /dev/null
>> +++ b/src/mesa/state_tracker/st_cb_copyimage.h
>> @@ -0,0 +1,34 @@
>> +/***************************************************************************
>> + *
>> + * Copyright 2015 VMware, Inc.
>> + * All Rights Reserved.
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the
>> + * "Software"), to deal in the Software without restriction, including
>> + * without limitation the rights to use, copy, modify, merge, publish,
>> + * distribute, sub license, and/or sell copies of the Software, and to
>> + * permit persons to whom the Software is furnished to do so, subject to
>> + * the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the
>> + * next paragraph) shall be included in all copies or substantial portions
>> + * of the Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
>> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
>> + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
>> + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
>> + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
>> + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
>> + *
>> + **************************************************************************/
>> +
>> +#ifndef ST_CB_COPY_IMAGE_H
>> +#define ST_CB_COPY_IMAGE_H
>> +
>> +extern void
>> +st_init_copy_image_functions(struct dd_function_table *functions);
>> +
>> +#endif /* ST_CB_COPY_IMAGE_H */
>> diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
>> index 72c23ca..f07ee64 100644
>> --- a/src/mesa/state_tracker/st_context.c
>> +++ b/src/mesa/state_tracker/st_context.c
>> @@ -44,6 +44,7 @@
>>   #include "st_cb_bufferobjects.h"
>>   #include "st_cb_clear.h"
>>   #include "st_cb_condrender.h"
>> +#include "st_cb_copyimage.h"
>>   #include "st_cb_drawpixels.h"
>>   #include "st_cb_rasterpos.h"
>>   #include "st_cb_drawtex.h"
>> @@ -415,6 +416,7 @@ void st_init_driver_functions(struct pipe_screen *screen,
>>      st_init_blit_functions(functions);
>>      st_init_bufferobject_functions(functions);
>>      st_init_clear_functions(functions);
>> +   st_init_copy_image_functions(functions);
>>      st_init_bitmap_functions(functions);
>>      st_init_drawpixels_functions(functions);
>>      st_init_rasterpos_functions(functions);
>> --
>> 1.9.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=BQIFaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=HganrksvNuinDG35T5ydRkQSVZ6FqDXOMekw6Jn8zj0&s=GAm2ubgSBgysHzlMzXGkeHa4kb7pTS2OpljndKPd7Qk&e=



More information about the mesa-dev mailing list