summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2023-04-13 16:28:16 -0400
committerMarge Bot <emma+marge@anholt.net>2023-04-21 13:21:46 +0000
commitd2ccdc3e8daf87bc782be6071364fa2743a3e74f (patch)
treede7c7d62170081a474b52727ffaba9a9d3400fe3 /src/mesa
parentc29359a008d4436b10649dc62faf475d7f529ca9 (diff)
downloadmesa-d2ccdc3e8daf87bc782be6071364fa2743a3e74f.tar.gz
mesa: fix ms fallback texture creation
when a ms fallback texture is created, it has to actually be a ms texture in order to be consistent with driver expectations for a given sampler in a shader this adds sample querying to both ends of the fallback creation to ensure that a sample count is passed to the driver affects: KHR-GL46.sample_variables.position.fixed.samples_0 Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22492>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/texobj.c27
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c12
2 files changed, 31 insertions, 8 deletions
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);