summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2014-01-06 12:50:43 -0700
committerCarl Worth <cworth@cworth.org>2014-01-09 12:15:17 -0800
commitb1ff3f627092029c5842f28de27b7b77cea9e5fd (patch)
tree5ddf074b0e66bb8837944826843c541ba9c4d416 /src
parent5310a8cc2039f8f1c2d9ea5b3f2e14d50d4a1fa9 (diff)
mesa: implement missing glGet(GL_RGBA_SIGNED_COMPONENTS_EXT) query
This is part of the GL_EXT_packed_float extension. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Chris Forbes <chrisf@ijw.co.nz> (cherry picked from commit 3486f6f31b8cdb01e480cfbd8814c1e4222d26b0 Also squashed in a subsequent bug fix: mesa: check for MESA_FORMAT_RGB9_E5_FLOAT in _mesa_is_format_signed() This packed floating point format only stores positive values. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Roland Scheidegger <sroland@vmware.com> (cherry picked from commit 0fc8d7c66e08c295b701586afdc1f6d86eb8a514) Also squashed in a second, subsequent bug fix: mesa: check bits per channel for GL_RGBA_SIGNED_COMPONENTS_EXT query If a channel has zero bits it's not signed. v2: also check for luminance and intensity format bits. Bruce Merry's proposed piglit test hits the luminance case. Reviewed-by: Matt Turner <mattst88@gmail.com> (cherry picked from commit d046fd731ab192dceee0916323dd718b78df5976) Bugzilla: http://bugs.freedesktop.org/show_bug.cgi?id=73096 Cc: 10.0 <mesa-stable@lists.freedesktop.org> Conflicts: src/mesa/main/get.c
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/formats.c20
-rw-r--r--src/mesa/main/formats.h3
-rw-r--r--src/mesa/main/get.c45
-rw-r--r--src/mesa/main/get_hash_params.py3
4 files changed, 71 insertions, 0 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 07d2a72406b..7e0ec23198c 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1967,6 +1967,26 @@ _mesa_is_format_unsigned(gl_format format)
/**
+ * Does the given format store signed values?
+ */
+GLboolean
+_mesa_is_format_signed(gl_format format)
+{
+ if (format == MESA_FORMAT_R11_G11_B10_FLOAT ||
+ format == MESA_FORMAT_RGB9_E5_FLOAT) {
+ /* these packed float formats only store unsigned values */
+ return GL_FALSE;
+ }
+ else {
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+ return (info->DataType == GL_SIGNED_NORMALIZED ||
+ info->DataType == GL_INT ||
+ info->DataType == GL_FLOAT);
+ }
+}
+
+
+/**
* Return color encoding for given format.
* \return GL_LINEAR or GL_SRGB
*/
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 64b4b9a015f..0c91aeaac86 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -341,6 +341,9 @@ _mesa_is_format_integer_color(gl_format format);
extern GLboolean
_mesa_is_format_unsigned(gl_format format);
+extern GLboolean
+_mesa_is_format_signed(gl_format format);
+
extern GLenum
_mesa_get_format_color_encoding(gl_format format);
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index eee85500701..119b085b3a5 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -327,6 +327,12 @@ static const int extra_EXT_framebuffer_sRGB_and_new_buffers[] = {
EXTRA_END
};
+static const int extra_EXT_packed_float[] = {
+ EXT(EXT_packed_float),
+ EXTRA_NEW_BUFFERS,
+ EXTRA_END
+};
+
static const int extra_MESA_texture_array_es3[] = {
EXT(MESA_texture_array),
EXTRA_API_ES3,
@@ -758,6 +764,45 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name;
break;
+ /* GL_EXT_packed_float */
+ case GL_RGBA_SIGNED_COMPONENTS_EXT:
+ {
+ /* Note: we only check the 0th color attachment. */
+ const struct gl_renderbuffer *rb =
+ ctx->DrawBuffer->_ColorDrawBuffers[0];
+ if (rb && _mesa_is_format_signed(rb->Format)) {
+ /* Issue 17 of GL_EXT_packed_float: If a component (such as
+ * alpha) has zero bits, the component should not be considered
+ * signed and so the bit for the respective component should be
+ * zeroed.
+ */
+ GLint r_bits =
+ _mesa_get_format_bits(rb->Format, GL_RED_BITS);
+ GLint g_bits =
+ _mesa_get_format_bits(rb->Format, GL_GREEN_BITS);
+ GLint b_bits =
+ _mesa_get_format_bits(rb->Format, GL_BLUE_BITS);
+ GLint a_bits =
+ _mesa_get_format_bits(rb->Format, GL_ALPHA_BITS);
+ GLint l_bits =
+ _mesa_get_format_bits(rb->Format, GL_TEXTURE_LUMINANCE_SIZE);
+ GLint i_bits =
+ _mesa_get_format_bits(rb->Format, GL_TEXTURE_INTENSITY_SIZE);
+
+ v->value_int_4[0] = r_bits + l_bits + i_bits > 0;
+ v->value_int_4[1] = g_bits + l_bits + i_bits > 0;
+ v->value_int_4[2] = b_bits + l_bits + i_bits > 0;
+ v->value_int_4[3] = a_bits + i_bits > 0;
+ }
+ else {
+ v->value_int_4[0] =
+ v->value_int_4[1] =
+ v->value_int_4[2] =
+ v->value_int_4[3] = 0;
+ }
+ }
+ break;
+
/* GL_ARB_vertex_buffer_object */
case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index c961feeeeed..5fa9c6a8a35 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -613,6 +613,9 @@ descriptor=[
# GL_ARB_fragment_program
[ "FRAGMENT_PROGRAM_ARB", "CONTEXT_BOOL(FragmentProgram.Enabled), extra_ARB_fragment_program" ],
+# GL_EXT_packed_float
+ [ "RGBA_SIGNED_COMPONENTS_EXT", "LOC_CUSTOM, TYPE_INT_4, 0, extra_EXT_packed_float" ],
+
# GL_EXT_depth_bounds_test
[ "DEPTH_BOUNDS_TEST_EXT", "CONTEXT_BOOL(Depth.BoundsTest), extra_EXT_depth_bounds_test" ],
[ "DEPTH_BOUNDS_EXT", "CONTEXT_FLOAT2(Depth.BoundsMin), extra_EXT_depth_bounds_test" ],