diff --git a/src/mesa/drivers/common/meta_copy_image.c b/src/mesa/drivers/common/meta_copy_image.c index 1729766..9f92d7c 100644 --- a/src/mesa/drivers/common/meta_copy_image.c +++ b/src/mesa/drivers/common/meta_copy_image.c @@ -57,8 +57,9 @@ make_view(struct gl_context *ctx, struct gl_texture_image *tex_image, return false; tex_format = _mesa_choose_texture_format(ctx, view_tex_obj, tex_obj->Target, - 0, internal_format, - GL_NONE, GL_NONE); + 0, internal_format, + tex_image->NumSamples, + GL_NONE, GL_NONE); if (!ctx->Driver.TestProxyTexImage(ctx, tex_obj->Target, 0, tex_format, tex_image->Width, tex_image->Height, diff --git a/src/mesa/drivers/dri/i915/intel_fbo.c b/src/mesa/drivers/dri/i915/intel_fbo.c index a5d5c58..37b762c 100644 --- a/src/mesa/drivers/dri/i915/intel_fbo.c +++ b/src/mesa/drivers/dri/i915/intel_fbo.c @@ -178,7 +178,7 @@ intel_renderbuffer_format(struct gl_context * ctx, GLenum internalFormat) * them. */ return intel->ctx.Driver.ChooseTextureFormat(ctx, GL_TEXTURE_2D, - internalFormat, + internalFormat, 0, GL_NONE, GL_NONE); case GL_DEPTH_COMPONENT16: diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c index 05e3f8b..0dd04bb 100644 --- a/src/mesa/drivers/dri/i965/intel_fbo.c +++ b/src/mesa/drivers/dri/i965/intel_fbo.c @@ -273,7 +273,7 @@ intel_renderbuffer_format(struct gl_context * ctx, GLenum internalFormat) * them. */ return ctx->Driver.ChooseTextureFormat(ctx, GL_TEXTURE_2D, - internalFormat, + internalFormat, 0, GL_NONE, GL_NONE); break; case GL_STENCIL_INDEX: diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index dc5699c..ed601fe 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -162,7 +162,7 @@ nouveau_unmap_texture_image(struct gl_context *ctx, struct gl_texture_image *ti, static mesa_format nouveau_choose_tex_format(struct gl_context *ctx, GLenum target, - GLint internalFormat, + GLint internalFormat, GLint samples, GLenum srcFormat, GLenum srcType) { switch (internalFormat) { diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index edfd48b..17f5932 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -245,6 +245,7 @@ static mesa_format radeonChoose8888TexFormat(radeonContextPtr rmesa, mesa_format radeonChooseTextureFormat_mesa(struct gl_context * ctx, GLenum target, GLint internalFormat, + GLint samples, GLenum format, GLenum type) { diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 2d4bb70..95ea57a 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -719,12 +719,14 @@ viewport(struct gl_context *ctx) static mesa_format swrastChooseTextureFormat(struct gl_context * ctx, GLenum target, GLint internalFormat, + GLint samples, GLenum format, GLenum type) { if (internalFormat == GL_RGB) return MESA_FORMAT_B8G8R8X8_UNORM; - return _mesa_choose_tex_format(ctx, target, internalFormat, format, type); + return _mesa_choose_tex_format(ctx, target, internalFormat, samples, + format, type); } static void diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index d783e34..6709ea3 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -184,6 +184,7 @@ struct dd_function_table { */ mesa_format (*ChooseTextureFormat)(struct gl_context *ctx, GLenum target, GLint internalFormat, + GLint samples, GLenum srcFormat, GLenum srcType ); /** diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 3c4baca..ba536df 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -51,6 +51,7 @@ * \param ctx the GL context. * \param target a texture target (GL_TEXTURE_x) * \param internalFormat user's prefered internal texture format. + * \param samples number of samples * \param format incoming image pixel format. * \param type incoming image data type. * @@ -61,7 +62,8 @@ */ mesa_format _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, - GLint internalFormat, GLenum format, GLenum type) + GLint internalFormat, GLint samples, + GLenum format, GLenum type) { (void) format; diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h index 32e2099..ebf3c3e 100644 --- a/src/mesa/main/texformat.h +++ b/src/mesa/main/texformat.h @@ -33,7 +33,8 @@ struct gl_context; extern mesa_format _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, - GLint internalFormat, GLenum format, GLenum type); + GLint internalFormat, GLint samples, + GLenum format, GLenum type); extern GLboolean _mesa_tex_target_is_array(GLenum target); diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 3d85615..fef72c4 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3057,7 +3057,8 @@ mesa_format _mesa_choose_texture_format(struct gl_context *ctx, struct gl_texture_object *texObj, GLenum target, GLint level, - GLenum internalFormat, GLenum format, GLenum type) + GLenum internalFormat, GLint samples, + GLenum format, GLenum type) { mesa_format f; @@ -3109,7 +3110,7 @@ _mesa_choose_texture_format(struct gl_context *ctx, } /* choose format from scratch */ - f = ctx->Driver.ChooseTextureFormat(ctx, target, internalFormat, + f = ctx->Driver.ChooseTextureFormat(ctx, target, internalFormat, samples, format, type); assert(f != MESA_FORMAT_NONE); return f; @@ -3276,7 +3277,7 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, } texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, format, type); + internalFormat, 0, format, type); } assert(texFormat != MESA_FORMAT_NONE); @@ -3905,7 +3906,7 @@ copyteximage(struct gl_context *ctx, GLuint dims, assert(texObj); texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, GL_NONE, GL_NONE); + internalFormat, 0, GL_NONE, GL_NONE); rb = _mesa_get_read_renderbuffer_for_format(ctx, internalFormat); @@ -5648,7 +5649,7 @@ _mesa_texture_image_multisample(struct gl_context *ctx, GLuint dims, } texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0, - internalformat, GL_NONE, GL_NONE); + internalformat, samples, GL_NONE, GL_NONE); assert(texFormat != MESA_FORMAT_NONE); dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0, diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index 1eebaa8..ad124bd 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -90,7 +90,8 @@ extern mesa_format _mesa_choose_texture_format(struct gl_context *ctx, struct gl_texture_object *texObj, GLenum target, GLint level, - GLenum internalFormat, GLenum format, GLenum type); + GLenum internalFormat, GLint samples, + GLenum format, GLenum type); extern void _mesa_update_fbo_texture(struct gl_context *ctx, diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index c563f1e..8a02c00 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1020,7 +1020,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex) texObj->Sampler.MagFilter = GL_NEAREST; texFormat = ctx->Driver.ChooseTextureFormat(ctx, target, - GL_RGBA, GL_RGBA, + GL_RGBA, 0, GL_RGBA, GL_UNSIGNED_BYTE); /* need a loop here just for cube maps */ diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c index 53cb2c0..13923f2 100644 --- a/src/mesa/main/texstorage.c +++ b/src/mesa/main/texstorage.c @@ -385,7 +385,7 @@ _mesa_texture_storage(struct gl_context *ctx, GLuint dims, texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0, - internalformat, GL_NONE, GL_NONE); + internalformat, 0, GL_NONE, GL_NONE); assert(texFormat != MESA_FORMAT_NONE); /* check that width, height, depth are legal for the mipmap level */ diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c index 6b0aed4..f8b0480 100644 --- a/src/mesa/main/textureview.c +++ b/src/mesa/main/textureview.c @@ -528,11 +528,6 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture, return; } - texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0, - internalformat, GL_NONE, GL_NONE); - assert(texFormat != MESA_FORMAT_NONE); - if (texFormat == MESA_FORMAT_NONE) return; - newViewNumLevels = MIN2(numlevels, origTexObj->NumLevels - minlevel); newViewNumLayers = MIN2(numlayers, origTexObj->NumLayers - minlayer); @@ -546,6 +541,13 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture, height = origTexImage->Height; depth = origTexImage->Depth; + texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0, + internalformat, + origTexImage->NumSamples, + GL_NONE, GL_NONE); + assert(texFormat != MESA_FORMAT_NONE); + if (texFormat == MESA_FORMAT_NONE) return; + /* Adjust width, height, depth to be appropriate for new target */ switch (target) { case GL_TEXTURE_1D: diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 7ea3846..bdab1d7 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -584,8 +584,9 @@ prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage, /* oops, need to init this image again */ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - texImage->InternalFormat, format, - type); + texImage->InternalFormat, + texImage->NumSamples, + format, type); _mesa_init_teximage_fields(ctx, texImage, texImage->Width, texImage->Height, diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index db7b5b7..b65701b 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -1939,7 +1939,7 @@ st_choose_matching_format(struct st_context *st, unsigned bind, */ mesa_format st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, - GLint internalFormat, + GLint internalFormat, GLint samples, GLenum format, GLenum type) { struct st_context *st = st_context(ctx); @@ -2002,12 +2002,12 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, } pFormat = st_choose_format(st, internalFormat, format, type, - pTarget, 0, bindings, ctx->Mesa_DXTn); + pTarget, samples, bindings, ctx->Mesa_DXTn); if (pFormat == PIPE_FORMAT_NONE) { /* try choosing format again, this time without render target bindings */ pFormat = st_choose_format(st, internalFormat, format, type, - pTarget, 0, PIPE_BIND_SAMPLER_VIEW, + pTarget, samples, PIPE_BIND_SAMPLER_VIEW, ctx->Mesa_DXTn); } diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h index 90e00e8..ca3a41b 100644 --- a/src/mesa/state_tracker/st_format.h +++ b/src/mesa/state_tracker/st_format.h @@ -63,7 +63,7 @@ st_choose_matching_format(struct st_context *st, unsigned bind, extern mesa_format st_ChooseTextureFormat(struct gl_context * ctx, GLenum target, - GLint internalFormat, + GLint internalFormat, GLint samples, GLenum format, GLenum type); size_t