diff options
Diffstat (limited to 'mesalib/src/mesa/main/teximage.c')
-rw-r--r-- | mesalib/src/mesa/main/teximage.c | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 0519d221f..a6c3581bf 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/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); } @@ -2039,6 +2056,8 @@ texture_error_check( struct gl_context *ctx, GLint depth, GLint border ) { GLboolean colorFormat; + GLboolean is_format_depth_or_depthstencil; + GLboolean is_internalFormat_depth_or_depthstencil; GLenum err; /* Even though there are no color-index textures, we still have to support @@ -2129,11 +2148,18 @@ texture_error_check( struct gl_context *ctx, } /* make sure internal format and format basically agree */ + is_internalFormat_depth_or_depthstencil = + _mesa_is_depth_format(internalFormat) || + _mesa_is_depthstencil_format(internalFormat); + + is_format_depth_or_depthstencil = + _mesa_is_depth_format(format) || + _mesa_is_depthstencil_format(format); + colorFormat = _mesa_is_color_format(format); if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) || - (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) || + (is_internalFormat_depth_or_depthstencil != is_format_depth_or_depthstencil) || (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) || - (_mesa_is_depthstencil_format(internalFormat) != _mesa_is_depthstencil_format(format)) || (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) { _mesa_error(ctx, GL_INVALID_OPERATION, "glTexImage%dD(incompatible internalFormat = %s, format = %s)", @@ -4420,15 +4446,13 @@ 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 */ - _mesa_init_teximage_fields(ctx, texImage, - 0, 0, 0, 0, GL_NONE, MESA_FORMAT_NONE); + clear_teximage_fields(texImage); } } else { @@ -4452,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, |