diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 1546551d8a4..7f0cfed9bd1 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1084,12 +1084,27 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex, bool is /* initialize level[0] texture image */ texImage = _mesa_get_tex_image(ctx, texObj, faceTarget, 0); - _mesa_init_teximage_fields(ctx, texImage, - width, - (dims > 1) ? height : 1, - (dims > 2) ? depth : 1, - 0, /* border */ - is_depth ? GL_DEPTH_COMPONENT : GL_RGBA, texFormat); + GLenum internalFormat = is_depth ? GL_DEPTH_COMPONENT : GL_RGBA; + if (tex == TEXTURE_2D_MULTISAMPLE_INDEX || + tex == TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX) { + int samples[16]; + st_QueryInternalFormat(ctx, 0, internalFormat, GL_SAMPLES, samples); + _mesa_init_teximage_fields_ms(ctx, texImage, + width, + (dims > 1) ? height : 1, + (dims > 2) ? depth : 1, + 0, /* border */ + internalFormat, texFormat, + samples[0], + GL_TRUE); + } else { + _mesa_init_teximage_fields(ctx, texImage, + width, + (dims > 1) ? height : 1, + (dims > 2) ? depth : 1, + 0, /* border */ + internalFormat, texFormat); + } _mesa_update_texture_object_swizzle(ctx, texObj); if (ctx->st->can_null_texture && is_depth) { texObj->NullTexture = GL_TRUE; diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index a21aa1c138c..9cb9293535a 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1071,14 +1071,22 @@ guess_and_alloc_texture(struct st_context *st, width, height, depth, &ptWidth, &ptHeight, &ptDepth, &ptLayers); + enum pipe_texture_target target = gl_target_to_pipe(stObj->Target); + unsigned nr_samples = 0; + if (stObj->TargetIndex == TEXTURE_2D_MULTISAMPLE_INDEX || + stObj->TargetIndex == TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX) { + int samples[16]; + st_QueryInternalFormat(st->ctx, 0, stImage->InternalFormat, GL_SAMPLES, samples); + nr_samples = samples[0]; + } stObj->pt = st_texture_create(st, - gl_target_to_pipe(stObj->Target), + target, fmt, lastLevel, ptWidth, ptHeight, ptDepth, - ptLayers, 0, + ptLayers, nr_samples, bindings, false);