Mesa (master): freedreno: stop frob'ing pipe_resource::nr_samples

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 29 18:28:22 UTC 2019


Module: Mesa
Branch: master
Commit: c3baa077bf6db9f9d46be62ed7cbbc3167e68c8f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3baa077bf6db9f9d46be62ed7cbbc3167e68c8f

Author: Rob Clark <robdclark at gmail.com>
Date:   Tue Jan 29 12:23:28 2019 -0500

freedreno: stop frob'ing pipe_resource::nr_samples

Previously we tried to normalize nr_samples to MAX2(1, nr_samples) to
avoid having to deal with 0 vs 1 everywhere.  But this causes problems
in mesa/st, for example st_finalize_texture() will think there is a
nr_samples mismatch and recreate the texture.  Somehow this manifests
as corrupt x11 font rendering on generations that do not support MSAA
(but apparently works fine on a5xx and a6xx which do support MSAA.)

Fixes: cf0c7258ee0 freedreno/a5xx: MSAA
Signed-off-by: Rob Clark <robdclark at gmail.com>

---

 src/gallium/drivers/freedreno/freedreno_batch_cache.c | 2 +-
 src/gallium/drivers/freedreno/freedreno_resource.c    | 7 +++----
 src/gallium/drivers/freedreno/freedreno_resource.h    | 9 +++++++++
 src/gallium/drivers/freedreno/freedreno_texture.c     | 3 ++-
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
index 45cd9c172d..ec3aab128a 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
@@ -402,7 +402,7 @@ key_surf(struct key *key, unsigned idx, unsigned pos, struct pipe_surface *psurf
 	key->surf[idx].texture = psurf->texture;
 	key->surf[idx].u = psurf->u;
 	key->surf[idx].pos = pos;
-	key->surf[idx].samples = psurf->nr_samples;
+	key->surf[idx].samples = MAX2(1, psurf->nr_samples);
 	key->surf[idx].format = psurf->format;
 }
 
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 11319a44bb..9adc3ce1d1 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -927,8 +927,7 @@ fd_resource_create_with_modifiers(struct pipe_screen *pscreen,
 
 	rsc->internal_format = format;
 	rsc->cpp = util_format_get_blocksize(format);
-	prsc->nr_samples = MAX2(1, prsc->nr_samples);
-	rsc->cpp *= prsc->nr_samples;
+	rsc->cpp *= fd_resource_nr_samples(prsc);
 
 	assert(rsc->cpp);
 
@@ -1053,9 +1052,9 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
 	if (!rsc->bo)
 		goto fail;
 
-	prsc->nr_samples = MAX2(1, prsc->nr_samples);
 	rsc->internal_format = tmpl->format;
-	rsc->cpp = prsc->nr_samples * util_format_get_blocksize(tmpl->format);
+	rsc->cpp = util_format_get_blocksize(tmpl->format);
+	rsc->cpp *= fd_resource_nr_samples(prsc);
 	slice->pitch = handle->stride / rsc->cpp;
 	slice->offset = handle->offset;
 	slice->size0 = handle->stride * prsc->height0;
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h
index 10ab8bfa22..9fc93d3c9a 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.h
+++ b/src/gallium/drivers/freedreno/freedreno_resource.h
@@ -179,6 +179,15 @@ fd_resource_level_linear(struct pipe_resource *prsc, int level)
 	return false;
 }
 
+/* access # of samples, with 0 normalized to 1 (which is what we care about
+ * most of the time)
+ */
+static inline unsigned
+fd_resource_nr_samples(struct pipe_resource *prsc)
+{
+	return MAX2(1, prsc->nr_samples);
+}
+
 void fd_blitter_pipe_begin(struct fd_context *ctx, bool render_cond, bool discard,
 		enum fd_render_stage stage);
 void fd_blitter_pipe_end(struct fd_context *ctx);
diff --git a/src/gallium/drivers/freedreno/freedreno_texture.c b/src/gallium/drivers/freedreno/freedreno_texture.c
index d92298d2ea..84b4df6c1d 100644
--- a/src/gallium/drivers/freedreno/freedreno_texture.c
+++ b/src/gallium/drivers/freedreno/freedreno_texture.c
@@ -31,6 +31,7 @@
 
 #include "freedreno_texture.h"
 #include "freedreno_context.h"
+#include "freedreno_resource.h"
 #include "freedreno_util.h"
 
 static void
@@ -83,7 +84,7 @@ static void set_sampler_views(struct fd_texture_stateobj *tex,
 	tex->num_textures = util_last_bit(tex->valid_textures);
 
 	for (i = 0; i < tex->num_textures; i++) {
-		uint nr_samples = tex->textures[i]->texture->nr_samples;
+		uint nr_samples = fd_resource_nr_samples(tex->textures[i]->texture);
 		samplers |= (nr_samples >> 1) << (i * 2);
 	}
 




More information about the mesa-commit mailing list