[Mesa-dev] [PATCH 22/35] meta: Refactor the table of glsl_sampler structures

Brian Paul brian.e.paul at gmail.com
Wed Jan 29 17:11:49 PST 2014


On Wed, Jan 29, 2014 at 2:53 PM, Ian Romanick <idr at freedesktop.org> wrote:

> From: Ian Romanick <ian.d.romanick at intel.com>
>
> This will allow the same table of shader-per-sampler-type to be used for
> paths in meta other than just mipmap generation.  This is also the
> reason the declarations of the structures was moved towards the top of
> the file.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/mesa/drivers/common/meta.c | 128
> +++++++++++++++++++++++------------------
>  1 file changed, 72 insertions(+), 56 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c
> b/src/mesa/drivers/common/meta.c
> index a987fd7..0241c34 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -215,6 +215,28 @@ struct temp_texture
>     GLfloat Sright, Ttop;  /**< right, top texcoords */
>  };
>
> +/**
> + * State for GLSL texture sampler which is used to generate fragment
> + * shader in _mesa_meta_generate_mipmap().
> + */
> +struct glsl_sampler {
> +   const char *type;
> +   const char *func;
> +   const char *texcoords;
> +   GLuint shader_prog;
> +};
> +
> +/**
> + * Table of all sampler types and shaders for accessing them.
> + */
> +struct sampler_table {
> +   struct glsl_sampler sampler_1d;
> +   struct glsl_sampler sampler_2d;
> +   struct glsl_sampler sampler_3d;
> +   struct glsl_sampler sampler_cubemap;
> +   struct glsl_sampler sampler_1d_array;
> +   struct glsl_sampler sampler_2d_array;
> +};
>
>  /**
>   * State for glBlitFramebufer()
> @@ -281,17 +303,6 @@ struct bitmap_state
>  };
>
>  /**
> - * State for GLSL texture sampler which is used to generate fragment
> - * shader in _mesa_meta_generate_mipmap().
> - */
> -struct glsl_sampler {
> -   const char *type;
> -   const char *func;
> -   const char *texcoords;
> -   GLuint shader_prog;
> -};
> -
> -/**
>   * State for _mesa_meta_generate_mipmap()
>   */
>  struct gen_mipmap_state
> @@ -301,12 +312,8 @@ struct gen_mipmap_state
>     GLuint FBO;
>     GLuint Sampler;
>     GLuint ShaderProg;
> -   struct glsl_sampler sampler_1d;
> -   struct glsl_sampler sampler_2d;
> -   struct glsl_sampler sampler_3d;
> -   struct glsl_sampler sampler_cubemap;
> -   struct glsl_sampler sampler_1d_array;
> -   struct glsl_sampler sampler_2d_array;
> +
> +   struct sampler_table samplers;
>  };
>
>  /**
> @@ -356,12 +363,16 @@ struct vertex {
>     GLfloat r, g, b, a;
>  };
>
> +static struct glsl_sampler * setup_texture_sampler(GLenum target,
> +                                                   struct sampler_table
> *table);
>

Minor nit, but I'd format that function prototype as we do elsewhere
(return type on its own line).


-Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140129/e3b5cc2e/attachment.html>


More information about the mesa-dev mailing list