Mesa (master): st/mesa: handle SNORM formats in generic CopyPixels path
Marek Olšák
mareko at kemper.freedesktop.org
Mon Jul 1 01:05:15 UTC 2013
Module: Mesa
Branch: master
Commit: f83e220d360776dae0fbb61df3741501c2dd4d96
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f83e220d360776dae0fbb61df3741501c2dd4d96
Author: Marek Olšák <maraeo at gmail.com>
Date: Thu Jun 6 13:45:24 2013 +0200
st/mesa: handle SNORM formats in generic CopyPixels path
v2: check desc->is_mixed in util_format_is_snorm
---
src/gallium/auxiliary/util/u_format.c | 20 ++++++++++++++++++++
src/gallium/auxiliary/util/u_format.h | 3 +++
src/mesa/state_tracker/st_cb_drawpixels.c | 6 ++++++
3 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
index 9bdc2ea..686ca8a 100644
--- a/src/gallium/auxiliary/util/u_format.c
+++ b/src/gallium/auxiliary/util/u_format.c
@@ -131,6 +131,26 @@ util_format_is_pure_uint(enum pipe_format format)
return (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
}
+/**
+ * Returns true if all non-void channels are normalized signed.
+ */
+boolean
+util_format_is_snorm(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ int i;
+
+ if (desc->is_mixed)
+ return FALSE;
+
+ i = util_format_get_first_non_void_channel(format);
+ if (i == -1)
+ return FALSE;
+
+ return desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED &&
+ !desc->channel[i].pure_integer &&
+ desc->channel[i].normalized;
+}
boolean
util_format_is_luminance_alpha(enum pipe_format format)
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 9774a2b..bb729c0 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -645,6 +645,9 @@ util_format_is_pure_sint(enum pipe_format format);
boolean
util_format_is_pure_uint(enum pipe_format format);
+boolean
+util_format_is_snorm(enum pipe_format format);
+
/**
* Check if the src format can be blitted to the destination format with
* a simple memcpy. For example, blitting from RGBA to RGBx is OK, but not
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 0200a62..2ce4728 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1546,6 +1546,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
if (!screen->is_format_supported(screen, srcFormat, st->internal_target, 0,
srcBind)) {
+ /* srcFormat is non-renderable. Find a compatible renderable format. */
if (type == GL_DEPTH) {
srcFormat = st_choose_format(st, GL_DEPTH_COMPONENT, GL_NONE,
GL_NONE, st->internal_target, 0,
@@ -1569,6 +1570,11 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
GL_NONE, st->internal_target, 0,
srcBind, FALSE);
}
+ else if (util_format_is_snorm(srcFormat)) {
+ srcFormat = st_choose_format(st, GL_RGBA16_SNORM, GL_NONE,
+ GL_NONE, st->internal_target, 0,
+ srcBind, FALSE);
+ }
else {
srcFormat = st_choose_format(st, GL_RGBA, GL_NONE,
GL_NONE, st->internal_target, 0,
More information about the mesa-commit
mailing list