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

Marek Olšák maraeo at gmail.com
Mon Aug 24 17:52:28 PDT 2015


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Tue, Aug 25, 2015 at 1:04 AM, 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: Brian Paul <brianp at vmware.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
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list