Mesa (master): mesa/get: Make GetFloat/ GetDouble of TYPE_INT_N not normalize things.

Kenneth Graunke kwg at kemper.freedesktop.org
Mon Dec 19 23:30:07 UTC 2016


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sat Dec 17 19:47:38 2016 -0800

mesa/get: Make GetFloat/GetDouble of TYPE_INT_N not normalize things.

GetFloat of integer valued things is supposed to perform a simple
int -> float conversion.  INT_TO_FLOAT is not that.  Instead, it
converts [-2147483648, 2147483647] to a normalized [-1.0, 1.0] float.

This is only used for COMPRESSED_TEXTURE_FORMATS, which nobody in
their right mind would try and access via glGetFloat(), but we may
as well fix it.

Found by inspection.

v2: Gotta catch 'em all (fix another case of this caught by Ilia)

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

---

 src/mesa/main/get.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index ba02cb2..12f937a 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1564,7 +1564,7 @@ _mesa_GetFloatv(GLenum pname, GLfloat *params)
 
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
-	 params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]);
+	 params[i] = (GLfloat) v.value_int_n.ints[i];
       break;
 
    case TYPE_INT64:
@@ -2464,7 +2464,7 @@ _mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params)
 
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
-	 params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]);
+	 params[i] = (GLfloat) v.value_int_n.ints[i];
       break;
 
    case TYPE_INT64:
@@ -2536,7 +2536,7 @@ _mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params)
 
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
-	 params[i] = (GLdouble) INT_TO_FLOAT(v.value_int_n.ints[i]);
+	 params[i] = (GLdouble) v.value_int_n.ints[i];
       break;
 
    case TYPE_INT64:




More information about the mesa-commit mailing list