On Thu, Mar 8, 2012 at 2:15 PM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com">brianp@vmware.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 03/08/2012 03:12 PM, Anuj Phogat wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
On Thu, Mar 8, 2012 at 7:22 AM, Brian Paul <<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a><br></div><div><div class="h5">
<mailto:<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>>> wrote:<br>
<br>
Test various combinations of getting a luminance texture.<br>
<br>
See <a href="https://bugs.freedesktop.org/show_bug.cgi?id=46679" target="_blank">https://bugs.freedesktop.org/<u></u>show_bug.cgi?id=46679</a><br>
---<br>
tests/all.tests | 1 +<br>
tests/texturing/CMakeLists.gl.<u></u>txt | 1 +<br>
tests/texturing/getteximage-<u></u>luminance.c | 198<br>
++++++++++++++++++++++++++++++<u></u>+<br>
3 files changed, 200 insertions(+), 0 deletions(-)<br>
create mode 100644 tests/texturing/getteximage-<u></u>luminance.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index e4d56b8..1231559 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -669,6 +669,7 @@ add_plain_test(texturing, 'gen-nonzero-unit')<br>
add_plain_test(texturing, 'gen-texsubimage')<br>
add_plain_test(texturing, 'getteximage-formats')<br>
add_plain_test(texturing, 'getteximage-simple')<br>
+add_plain_test(texturing, 'getteximage-luminance')<br>
<br>
texturing['incomplete-texture-<u></u>fixed'] =<br>
concurrent_test('incomplete-<u></u>texture -auto fixed')<br>
texturing['incomplete-texture-<u></u>arb_fp'] =<br>
concurrent_test('incomplete-<u></u>texture -auto arb_fp')<br>
diff --git a/tests/texturing/CMakeLists.<u></u>gl.txt<br>
b/tests/texturing/CMakeLists.<u></u>gl.txt<br>
index 6e12cc0..b60503d 100644<br>
--- a/tests/texturing/CMakeLists.<u></u>gl.txt<br>
+++ b/tests/texturing/CMakeLists.<u></u>gl.txt<br>
@@ -31,6 +31,7 @@ add_executable (gen-teximage gen-teximage.c)<br>
add_executable (gen-texsubimage gen-texsubimage.c)<br>
add_executable (getteximage-simple getteximage-simple.c)<br>
add_executable (getteximage-formats getteximage-formats.c)<br>
+add_executable (getteximage-luminance getteximage-luminance.c)<br>
add_executable (incomplete-texture incomplete-texture.c)<br>
add_executable (fragment-and-vertex-texturing<br>
fragment-and-vertex-texturing.<u></u>c)<br>
add_executable (levelclamp levelclamp.c)<br>
diff --git a/tests/texturing/getteximage-<u></u>luminance.c<br>
b/tests/texturing/getteximage-<u></u>luminance.c<br>
new file mode 100644<br>
index 0000000..3da5549<br>
--- /dev/null<br>
+++ b/tests/texturing/getteximage-<u></u>luminance.c<br>
@@ -0,0 +1,198 @@<br>
+/*<br>
+ * Copyright (c) 2012 VMware, Inc.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person<br>
obtaining a<br>
+ * copy of this software and associated documentation files (the<br>
"Software"),<br>
+ * to deal in the Software without restriction, including without<br>
limitation<br>
+ * on the rights to use, copy, modify, merge, publish,<br>
distribute, sub<br>
+ * license, and/or sell copies of the Software, and to permit<br>
persons to whom<br>
+ * the Software is furnished to do so, subject to the following<br>
conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice<br>
(including the next<br>
+ * paragraph) shall be included in all copies or substantial<br>
portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND<br>
+ * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS<br>
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN<br>
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br>
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br>
+ * SOFTWARE.<br>
+ */<br>
+<br>
+/*<br>
+ * Test glGetTexImage for luminance formats.<br>
+ * Brian Paul<br>
+ * 8 Mar 2012<br>
+ */<br>
+<br>
+#include "piglit-util.h"<br>
+<br>
+int piglit_width = 100, piglit_height = 100;<br>
+int piglit_window_mode = GLUT_RGBA | GLUT_DOUBLE;<br>
+static const char *TestName = "getteximage-luminance";<br>
+static float tolerance = 2.0 / 255.0;<br>
+<br>
+<br>
+static bool<br>
+rgba_equal(const float *c1, const float *c2)<br>
+{<br>
+ return ((fabs(c1[0] - c2[0]) < tolerance) &&<br>
+ (fabs(c1[1] - c2[1]) < tolerance) &&<br>
+ (fabs(c1[2] - c2[2]) < tolerance) &&<br>
+ (fabs(c1[3] - c2[3]) < tolerance));<br>
+}<br>
+<br>
+<br>
+static bool<br>
+lum_equal(const float *l1, const float *l2)<br>
+{<br>
+ return fabs(*l1 - *l2) < tolerance;<br>
+}<br>
+<br>
+<br>
+/*<br>
+ * Test reading back a luminance texture as luminance and RGBA.<br>
+ */<br>
+static bool<br>
+test_luminance(void)<br>
+{<br>
+ static const GLfloat lumImage[2*2] = { 0.25, 0.25, 0.25,<br>
0.25 };<br>
+ static const GLfloat rgbaImage[4] = { 0.25, 0.0, 0.0, 1.0 };<br>
+ GLuint tex;<br>
+ GLfloat test[2*2*4];<br>
+<br>
+ /* create 2x2 GL_LUMINANCE texture */<br>
+ glGenTextures(1, &tex);<br>
+ glBindTexture(GL_TEXTURE_2D, tex);<br>
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 2, 2, 0,<br>
+ GL_LUMINANCE, GL_FLOAT, lumImage);<br>
+<br>
+ /* Get and check luminance image */<br>
+ glGetTexImage(GL_TEXTURE_2D, 0, GL_LUMINANCE, GL_FLOAT, test);<br>
+ if (!lum_equal(lumImage, test)) {<br>
+ printf("%s: glGetTexImage(GL_LUMINANCE as"<br>
+ " GL_LUMINANCE) failed\n", TestName);<br>
+ printf(" Expected %g Found %g\n", lumImage[0],<br>
test[0]);<br>
+ return false;<br>
+ }<br>
+<br>
+ /* Get and check rgba image */<br>
+ glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, &test);<br>
+ if (!rgba_equal(rgbaImage, test)) {<br>
+ printf("%s: glGetTexImage(GL_LUMINANCE as GL_RGBA)<br>
failed\n",<br>
+ TestName);<br>
+ printf(" Expected %g, %g, %g, %g Found %g, %g,<br>
%g, %g\n",<br>
+ rgbaImage[0], rgbaImage[1], rgbaImage[2],<br>
rgbaImage[3],<br>
+ test[0], test[1], test[2], test[3]);<br>
+ return false;<br>
+ }<br>
+<br>
+ return true;<br>
+}<br>
+<br>
+<br>
+/*<br>
+ * Test reading back an RGBA texture as luminance.<br>
+ */<br>
+static bool<br>
+test_rgba(void)<br>
+{<br>
+ static const GLfloat rgbaImage[4] = { 0.5, 0.25, 0.125, 1.0 };<br>
+ static const GLfloat lumImage[1] = { 0.5 };<br>
<br>
I think expected value should be: l = 0.5 + 0.25 + 0.125<br>
</div></div></blockquote>
<br>
No, per the GL spec and testing with NVIDIA's driver, the result for glGetTexImage() should be 0.5. But if the texture is read back with glReadPixels using an FBO wrapper, the result should be 0.5+0.25+0.125 There's a test for that also, below.</blockquote>
<div>Thanks for explaining Brian. Test below is FBO + glReadPixels(GL_LUMINANCE as GL_RGBA).</div><div>We can also add a case of FBO + glReadPixels(GL_RGBA as GL_LUMINANCE) if it is not tested in any other piglit test.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm getting this failure on Sandybridge:<br>
getteximage-luminance: glGetTexImage(GL_RGBA as GL_LUMINANCE) failed<br>
Expected 0.5 Found 0.878431<br>
<br>
There is another failure for which i'll send out a patch:<br>
getteximage-luminance: glReadPixels(GL_LUMINANCE as GL_RGBA) failed<br>
Expected 0.25, 0, 0, 1 Found 0.25098, 0.25098, 0.25098, 1<br>
</blockquote>
<br></div>
As I wrote in the bug report, I have patches that fix these issues and I'll post them later.</blockquote><div>I noticed you pushed the changes.</div><div><br></div><div>- Anuj </div></div><br>