From 0b0114cc3bd8ceccaa6cbad161a13f2da2631ae0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 4 Mar 2014 09:11:32 -0700 Subject: [PATCH] mesa: new init_teximage_fields_ms() function to init MS texture images Before, it was kind of ugly to set the multisample fields with assignments after we called _mesa_init_teximage_fields(). Reviewed-by: Anuj Phogat --- 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 1192b45..a6c3581 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); } @@ -4429,10 +4446,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 */ @@ -4460,11 +4476,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, -- 2.7.4