util: Make piglit_probe_rect_halves_equal_rgba() GLES-compatible

In GLES, glReadPixels does not accept format=GL_FLOAT, but it does accept
format=GL_BYTE.

This shouldn't make any tests begin failing. If anything, this commit may
make pass some almost-passing tests because there is less precision in
probing with glReadPixels(GL_BYTE) than glReadPixels(GL_FLOAT).

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util: Define piglit_probe_rect_halves_equal_rgba() for all GL API's

Move the function from piglit-util-gl.c to piglit-util-gl-common.c so that
all GL API's can use it.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util: Add piglit_source_dir()

This function reads the environment variable PIGLIT_SOURCE_DIR, and
reports failure if the function is undefined. The intention is that tests
should use to construct the path to any needed data files.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
framework: Set env var PIGLIT_SOURCE_DIR if unset

Otherwise, if the user forgets to set PIGLIT_SOURCE_DIR himself, then
tests that use piglit_source_dir() will fail.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util: Add piglit_join_paths()

This is a variable argument function that joins together paths with the
system path separator (Unix='/', Windows='\\').

v2: Prevent a buffer overflow found by Jose.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
glut_waffle: Fix glutMainLoop

Stop calling waffle_swap_buffers() from glutMainLoop. It breaks tests in
non-auto mode. It's the test's responsibility to call swapBuffers, anyway.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
util: Add utilities for KTX file format

The KTX (Khronos texture) file format specifies a simple format for
storing texture miptrees. This patch adds utility functions for reading
and inspecting KTX files, iterating over the contained images, and easily
loading the miptree with glTexImage().

A future test (oes_compressed_etc1_rgb8_test-miptree) will use this to
load an ETC1 miptree and a reference RGB miptree.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
etc1: Test texturing from an ETC1 miptree

Add test spec/OES_compressed_ETC1_RGB8_texture/miptree.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
etc1: Remove texturing test from 'basic' test file

Now that oes_compressed_etc1_rgb8_texture-miptree, a test for realworld
ETC1 data, has been added to Piglit, the minimal, artificial texturing test
in oes_compressed_etc1_rgb8_texture-basic is unneeded. This patch removes
the texturing test from that file, and only api tests remain.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Changed test name generation so that regardless of OS path seperator, the test name will always use '/'.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Changed piglit-run.py to automatically correct previous test results on a platform where the os seperator is not '\'.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Changed all tests profile to automatically exclude glx on windows.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Modified tests to allow the test profiles to properly work on platforms where execfile() calls in python do not automatically declare variables as globals.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
msaa/formats: Use a wider color range in MSAA float tests.

Previously, the MSAA tests for floating-point color buffers only
exercised color values in the range [0, 1].  This patch extends the
range to [-10, 10], in order to verify that floating-point color
values are not inadvertently clamped.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
msaa/formats: Test signed normalized formats.

The GL spec mandates that signed normalized color formats be clamped
to [0, 1] when in GL_FIXED_ONLY mode, despite the fact that they can
represent values in the range [-1, 1].  So, when testing these
formats, we use a color clamping mode of GL_FALSE.

Note: it would have been easier to simply use a color clamping mode of
GL_FALSE for all formats, however since part of the purpose of the
test is to verify that unnecessary clipping does not occur, we want to
give as many opportunities as possible for the implementation to
incorrectly clip.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
msaa: Add the ability to run msaa tests without color/depth/stencil buffers.

This patch modifies the common code for MSAA tests, so that we can
easily configure framebuffers that lack a color, depth, and/or stencil
buffer.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Add the ability to test computed depths.

This patch modifies the common code for MSAA tests, so that when
testing depth buffer behaviour, we can choose to either output the
depth value from the vertex shader (using gl_Position) or from the
fragment shader (using gl_FragDepth).

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Test proper functioning when no color buffer is present.

This test reproduces a problem in Mesa's i965 driver as of 7/12/12
(commit 1a06e84): when no color buffer is present, but a multisampled
depth or stencil buffer is present, Mesa fails to set up the rendering
pipeline for multisampling.

The test includes variants for testing both the stencil buffer and the
depth buffer.  The depth buffer test may be run in a "computed" mode,
in which case the depth values are output by the fragment shader (this
is an important corner case for i965).

Verified on nVidia's proprietary binary driver for Linux.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
msaa: Check for proper error for operations prohibited on MSAA buffers.

From the GL 3.0 spec, section 4.3.3, in the documentation for
CopyPixels():

    "An INVALID_OPERATION error will be generated if the object bound
    to READ_FRAMEBUFFER_BINDING is framebuffer complete and the value
    of SAMPLE_BUFFERS is greater than zero."

The same applies to CopyTexImage...() and CopyTexSubImage...()
functions, since they are defined in terms of CopyPixels().

Previously we were checking for an INVALID_FRAMEBUFFER_OPERATION error
in these cases.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
linestipple: print what is tested