[Mesa-dev] [PATCH] mesa: new init_teximage_fields_ms() function to init MS texture images

Anuj Phogat anuj.phogat at gmail.com
Tue Mar 4 11:31:41 PST 2014


On Tue, Mar 4, 2014 at 8:13 AM, Brian Paul <brianp at vmware.com> wrote:
> Before, it was kind of ugly to set the multisample fields with
> assignments after we called _mesa_init_teximage_fields().
> ---
>  src/mesa/main/teximage.c |   44 +++++++++++++++++++++++++++++---------------
>  1 file changed, 29 insertions(+), 15 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 0519d22..a3a7e44 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1290,16 +1290,19 @@ clear_teximage_fields(struct gl_texture_image *img)
>   * \param border image border.
>   * \param internalFormat internal format.
>   * \param format  the actual hardware format (one of MESA_FORMAT_*)
> + * \param numSamples  number of samples per texel, or zero for non-MS.
> + * \param fixedSampleLocations  are sample locations fixed?
>   *
>   * Fills in the fields of \p img with the given information.
>   * Note: width, height and depth include the border.
>   */
> -void
> -_mesa_init_teximage_fields(struct gl_context *ctx,
> -                           struct gl_texture_image *img,
> -                           GLsizei width, GLsizei height, GLsizei depth,
> -                           GLint border, GLenum internalFormat,
> -                           mesa_format format)
> +static void
> +init_teximage_fields_ms(struct gl_context *ctx,
> +                        struct gl_texture_image *img,
> +                        GLsizei width, GLsizei height, GLsizei depth,
> +                        GLint border, GLenum internalFormat,
> +                        mesa_format format,
> +                        GLuint numSamples, GLboolean fixedSampleLocations)
>  {
>     GLenum target;
>     ASSERT(img);
> @@ -1397,6 +1400,20 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
>        _mesa_get_tex_max_num_levels(target,
>                                     img->Width2, img->Height2, img->Depth2);
>     img->TexFormat = format;
> +   img->NumSamples = numSamples;
> +   img->FixedSampleLocations = fixedSampleLocations;
> +}
> +
> +
> +void
> +_mesa_init_teximage_fields(struct gl_context *ctx,
> +                           struct gl_texture_image *img,
> +                           GLsizei width, GLsizei height, GLsizei depth,
> +                           GLint border, GLenum internalFormat,
> +                           mesa_format format)
> +{
> +   init_teximage_fields_ms(ctx, img, width, height, depth, border,
> +                           internalFormat, format, 0, GL_TRUE);
>  }
>
>
> @@ -4420,10 +4437,9 @@ teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
>
>     if (_mesa_is_proxy_texture(target)) {
>        if (dimensionsOK && sizeOK) {
> -         _mesa_init_teximage_fields(ctx, texImage,
> -               width, height, depth, 0, internalformat, texFormat);
> -         texImage->NumSamples = samples;
> -         texImage->FixedSampleLocations = fixedsamplelocations;
> +         init_teximage_fields_ms(ctx, texImage, width, height, depth, 0,
> +                                 internalformat, texFormat,
> +                                 samples, fixedsamplelocations);
>        }
>        else {
>           /* clear all image fields */
> @@ -4452,11 +4468,9 @@ teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
>
>        ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
>
> -      _mesa_init_teximage_fields(ctx, texImage,
> -            width, height, depth, 0, internalformat, texFormat);
> -
> -      texImage->NumSamples = samples;
> -      texImage->FixedSampleLocations = fixedsamplelocations;
> +      init_teximage_fields_ms(ctx, texImage, width, height, depth, 0,
> +                              internalformat, texFormat,
> +                              samples, fixedsamplelocations);
>
>        if (width > 0 && height > 0 && depth > 0) {
>           if (!ctx->Driver.AllocTextureStorage(ctx, texObj, 1,
> --
> 1.7.10.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list