Mesa (master): mesa/st: Add checks for signed/ unsigned integer conversions in ReadPixels
Iago Toral Quiroga
itoral at kemper.freedesktop.org
Thu Jul 2 06:20:40 UTC 2015
Module: Mesa
Branch: master
Commit: 9d408a41a3ab2fe456ebf2f7af7bad8f6c4bca17
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d408a41a3ab2fe456ebf2f7af7bad8f6c4bca17
Author: Iago Toral Quiroga <itoral at igalia.com>
Date: Mon Jun 29 10:44:52 2015 +0200
mesa/st: Add checks for signed/unsigned integer conversions in ReadPixels
These checks were in Mesa prior to commit fbba25bba, but they were
not necessary for the purpose that Mesa intended (check if we could
resolve ReadPixels via memcpy), so that commit took them away.
Unfortunately, it seems that some Gallium drivers rely on these
checks to make the decision of whether they should fallback to Mesa's
implementation of ReadPixels correctly. Michel Dänzer reported that
the following piglit test would fail on radeonsi after commit
fbba25bba:
spec at ext_texture_integer@fbo_integer_readpixels_sint_uint
This patch puts the checks back in Gallium, where they are needed.
Tested-by: Michel Dänzer <michel.daenzer at amd.com>
---
src/mesa/state_tracker/st_cb_readpixels.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index d95a608..18ea43f 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -43,6 +43,30 @@
#include "state_tracker/st_format.h"
#include "state_tracker/st_texture.h"
+static boolean
+needs_integer_signed_unsigned_conversion(const struct gl_context *ctx,
+ GLenum format, GLenum type)
+{
+ struct gl_renderbuffer *rb =
+ _mesa_get_read_renderbuffer_for_format(ctx, format);
+
+ assert(rb);
+
+ GLenum srcType = _mesa_get_format_datatype(rb->Format);
+
+ if ((srcType == GL_INT &&
+ (type == GL_UNSIGNED_INT ||
+ type == GL_UNSIGNED_SHORT ||
+ type == GL_UNSIGNED_BYTE)) ||
+ (srcType == GL_UNSIGNED_INT &&
+ (type == GL_INT ||
+ type == GL_SHORT ||
+ type == GL_BYTE))) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
/**
* This uses a blit to copy the read buffer to a texture format which matches
@@ -123,6 +147,10 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y,
goto fallback;
}
+ if (needs_integer_signed_unsigned_conversion(ctx, format, type)) {
+ goto fallback;
+ }
+
/* Convert the source format to what is expected by ReadPixels
* and see if it's supported. */
src_format = util_format_linear(src->format);
More information about the mesa-commit
mailing list