Mesa (master): gallium/hud: use sRGB for nicer AA lines
Marek Olšák
mareko at kemper.freedesktop.org
Mon Aug 22 14:03:02 UTC 2016
Module: Mesa
Branch: master
Commit: b9c9551c09caac241ea44b618748c133897d59b9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b9c9551c09caac241ea44b618748c133897d59b9
Author: Marek Olšák <marek.olsak at amd.com>
Date: Wed Aug 17 18:27:48 2016 +0200
gallium/hud: use sRGB for nicer AA lines
Reviewed-by: Brian Paul <brianp at vmware.com>
---
src/gallium/auxiliary/hud/hud_context.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index fb9c8c6..8ab998e 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -42,6 +42,7 @@
#include "cso_cache/cso_context.h"
#include "util/u_draw_quad.h"
+#include "util/u_format.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_math.h"
@@ -97,6 +98,8 @@ struct hud_context {
unsigned max_num_vertices;
unsigned num_vertices;
} text, bg, whitelines;
+
+ bool has_srgb;
};
#ifdef PIPE_OS_UNIX
@@ -484,6 +487,18 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
/* set states */
memset(&surf_templ, 0, sizeof(surf_templ));
surf_templ.format = tex->format;
+
+ /* Without this, AA lines look thinner if they are between 2 pixels
+ * because the alpha is 0.5 on both pixels. (it's ugly)
+ *
+ * sRGB makes the width of all AA lines look the same.
+ */
+ if (hud->has_srgb) {
+ enum pipe_format srgb_format = util_format_srgb(tex->format);
+
+ if (srgb_format != PIPE_FORMAT_NONE)
+ surf_templ.format = srgb_format;
+ }
surf = pipe->create_surface(pipe, tex, &surf_templ);
memset(&fb, 0, sizeof(fb));
@@ -1138,6 +1153,7 @@ print_help(struct pipe_screen *screen)
struct hud_context *
hud_create(struct pipe_context *pipe, struct cso_context *cso)
{
+ struct pipe_screen *screen = pipe->screen;
struct hud_context *hud;
struct pipe_sampler_view view_templ;
unsigned i;
@@ -1173,6 +1189,11 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso)
return NULL;
}
+ hud->has_srgb = screen->is_format_supported(screen,
+ PIPE_FORMAT_B8G8R8A8_SRGB,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_RENDER_TARGET) != 0;
+
/* blend state */
hud->no_blend.rt[0].colormask = PIPE_MASK_RGBA;
More information about the mesa-commit
mailing list