[Piglit] [PATCH] ext_framebuffer_multisample: Add NORETURN attribute to print_usage_and_exit.

2014-07-03 Thread Vinson Lee
Silence clang sometimes-uninitialized warning.

accuracy.cpp:130:13: warning: variable 'test_type' is used uninitialized 
whenever 'if' condition is false [-Wsometimes-uninitialized]
} else if (strcmp(argv[2], "depth_resolve") == 0) {
   ^
accuracy.cpp:135:21: note: uninitialized use occurs here
test = create_test(test_type, num_samples, small,
   ^
accuracy.cpp:130:9: note: remove the 'if' if its condition is always true
} else if (strcmp(argv[2], "depth_resolve") == 0) {
   ^~~
accuracy.cpp:119:2: note: variable 'test_type' is declared here
test_type_enum test_type;
^

Signed-off-by: Vinson Lee 
---
 tests/spec/ext_framebuffer_multisample/accuracy.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/spec/ext_framebuffer_multisample/accuracy.cpp 
b/tests/spec/ext_framebuffer_multisample/accuracy.cpp
index 2c0d445..8299f79 100644
--- a/tests/spec/ext_framebuffer_multisample/accuracy.cpp
+++ b/tests/spec/ext_framebuffer_multisample/accuracy.cpp
@@ -58,7 +58,7 @@ const int pattern_width = 256; const int pattern_height = 256;
 const int supersample_factor = 16;
 Test *test = NULL;
 
-void
+NORETURN void
 print_usage_and_exit(char *prog_name)
 {
printf("Usage: %s   [options]\n"
-- 
1.9.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] cl-program-tester: Add NORETURN attribute to exit_report_result.

2014-07-03 Thread Vinson Lee
Fix clang sometimes-uninitialized warning.

program-tester.c:1523:12: warning: variable 'main_argument_type' is used 
uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
} else if(regex_match(main_argument, "\\.bin$")) {
  ^
program-tester.c:1542:9: note: uninitialized use occurs here
switch(main_argument_type) {
   ^~
program-tester.c:1523:9: note: remove the 'if' if its condition is always true
} else if(regex_match(main_argument, "\\.bin$")) {
   ^~
program-tester.c:1455:2: note: variable 'main_argument_type' is declared here
enum main_argument_type_t {
^

Signed-off-by: Vinson Lee 
---
 tests/cl/program/program-tester.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/cl/program/program-tester.c 
b/tests/cl/program/program-tester.c
index a51f148..38a9379 100644
--- a/tests/cl/program/program-tester.c
+++ b/tests/cl/program/program-tester.c
@@ -451,7 +451,7 @@ clean(const int argc,
free_tests();
 }
 
-void
+NORETURN void
 exit_report_result(enum piglit_result result)
 {
free_dynamic_strs();
-- 
1.9.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 4/5] framework: refactor the log module

2014-07-03 Thread Ilia Mirkin
On Thu, Jul 3, 2014 at 4:56 PM, Dylan Baker  wrote:
> This refactors the log module away from a single class that does
> everything to having two classes. The first class LogFactory, is a state
> manager that returns BaseLog derived objects when it's get() method is
> called. However, it mainly acts as a shared state manager.
>
> The BaseLog derived classes provide three public methods; start(),
> log(), summary().
>
> This makes the interfaces much cleaner, just 3 public methods that are
> fairly obvious and clearly documented. It uses inheritance for more
> shared code, and is just generally much less complex than the previous
> implementation
>
> This makes two changes to behavior, and I believe it is out of necessity.
> In the previous implementation verbose printed a line at the start of
> the test and at the end, but it also printed the status line like the
> non-verbose logger does, using the '\r' character to overwrite the line.
> As far as I can tell the new logger is too performant for this behavior,
> it literally overwrites the line before a human could read it.
>
> The second change is to the command line arguments. Because one of the
> design goals of this series is to allow multiple loggers to be created
> for different purposes having a single command line option to toggle
> between one state or another isn't really feasible.

I suspect this will annoy people... why not leave -v around and just
have it alter the log level? (And error out if both it and the log
level are provided.)

Also, in the cover letter you allude to performance... do you have
numbers, or is it largely subjective? (Not that I don't believe there
are performance improvements to be had...)

[I will look at the full contents of this patch later...]

>
> Signed-off-by: Dylan Baker 
> ---
>  framework/core.py|   5 +-
>  framework/exectest.py|   7 +-
>  framework/log.py | 290 
> ---
>  framework/profile.py |  10 +-
>  framework/programs/run.py|  26 ++--
>  framework/results.py |   6 +-
>  framework/tests/log_tests.py | 177 +-
>  7 files changed, 339 insertions(+), 182 deletions(-)
>
> diff --git a/framework/core.py b/framework/core.py
> index 675b7aa..b4ba54a 100644
> --- a/framework/core.py
> +++ b/framework/core.py
> @@ -71,13 +71,11 @@ class Options(object):
>  exclude_filter -- list of compiled regex which exclude tests that match
>  valgrind -- True if valgrind is to be used
>  dmesg -- True if dmesg checking is desired. This forces concurrency off
> -verbose -- verbosity level.
>  env -- environment variables set for each test before run
>
>  """
>  def __init__(self, concurrent=True, execute=True, include_filter=None,
> - exclude_filter=None, valgrind=False, dmesg=False,
> - verbose=False):
> + exclude_filter=None, valgrind=False, dmesg=False):
>  self.concurrent = concurrent
>  self.execute = execute
>  self.filter = [re.compile(x) for x in include_filter or []]
> @@ -85,7 +83,6 @@ class Options(object):
>  self.exclude_tests = set()
>  self.valgrind = valgrind
>  self.dmesg = dmesg
> -self.verbose = verbose
>  # env is used to set some base environment variables that are not 
> going
>  # to change across runs, without sending them to os.environ which is
>  # fickle as easy to break
> diff --git a/framework/exectest.py b/framework/exectest.py
> index 7d08774..c27be90 100644
> --- a/framework/exectest.py
> +++ b/framework/exectest.py
> @@ -84,7 +84,7 @@ class Test(object):
>  Fully qualified test name as a string.  For example,
>  ``spec/glsl-1.30/preprocessor/compiler/keywords/void.frag``.
>  '''
> -log_current = log.pre_log(path if self.OPTS.verbose else None)
> +log.start(path)
>
>  # Run the test
>  if self.OPTS.execute:
> @@ -104,11 +104,10 @@ class Test(object):
>  self.result['traceback'] = "".join(
>  traceback.format_tb(exception[2]))
>
> -log.log(path, self.result['result'], log_current)
> -
> +log.log(self.result['result'])
>  json_writer.write_dict_item(path, self.result)
>  else:
> -log.log(path, 'dry-run', log_current)
> +log.log('dry-run')
>
>  @property
>  def command(self):
> diff --git a/framework/log.py b/framework/log.py
> index d6ab735..491ab7f 100644
> --- a/framework/log.py
> +++ b/framework/log.py
> @@ -18,136 +18,230 @@
>  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>  # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
>  # IN THE SOFTWARE.
> -#
> +
> +""" Module for terminal logging
> +
> +This module provides a class LogManager, which acts as a state manager
> +returning BaseLog derived insta

Re: [Piglit] [PATCH 3/5] log.py: Makes method names clearer

2014-07-03 Thread Ilia Mirkin
On Thu, Jul 3, 2014 at 4:56 PM, Dylan Baker  wrote:
> This replace _summary, _running, and _percent with _print*. This makes
> the methods easier to understand, especially with names like __summary
> also used in the class

Certainly _summary vs __summary is a little confusing. OTOH I would
expect _print_summary to... print the summary. How about
_format_summary? (Or some other clever name.)

>
> Signed-off-by: Dylan Baker 
> ---
>  framework/log.py | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/framework/log.py b/framework/log.py
> index c967028..d6ab735 100644
> --- a/framework/log.py
> +++ b/framework/log.py
> @@ -78,17 +78,17 @@ class Log(object):
>  # newline.
>  sys.stdout.flush()
>
> -def _summary(self):
> +def _print_summary(self):
>  """ return a summary of the statuses """
>  return ", ".join("{0}: {1}".format(k, self.__summary[k])
>   for k in sorted(self.__summary))
>
> -def _running(self):
> +def _print_running(self):
>  """ return running tests """
>  return "Running Test(s): {}".format(
>  " ".join([str(x).zfill(self.__pad) for x in self.__running]))
>
> -def _percent(self):
> +def _print_percent(self):
>  """ return the percentage of tess completed """
>  return "{0}/{1}".format(str(self.__complete).zfill(self.__pad),
>  str(self.__total).zfill(self.__pad))
> @@ -96,9 +96,9 @@ class Log(object):
>  def __print(self, name, result):
>  """ Do the actual printing """
>  self._write_output(self.__output.format(
> -percent=self._percent(),
> -running=self._running(),
> -summary=self._summary(),
> +percent=self._print_percent(),
> +running=self._print_running(),
> +summary=self._print_summary(),
>  name=name,
>  result=result))
>
> @@ -149,5 +149,5 @@ class Log(object):
>
>  def summary(self):
>  self._write_output(self.__summary_output.format(
> -percent=self._percent(),
> -summary=self._summary()))
> +percent=self._print_percent(),
> +summary=self._print_summary()))
> --
> 2.0.0
>
> ___
> Piglit mailing list
> Piglit@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/5] framework/log.py: Merge Log.log() and Log.post_log()

2014-07-03 Thread Dylan Baker
These methods were always called back to back, and required an
overlapping set of arguments. Initially I thought that having a second
method might be useful, but it doesn't really seem that useful at this
point.

Signed-off-by: Dylan Baker 
---
 framework/exectest.py|  6 ++
 framework/log.py | 30 +-
 framework/tests/log_tests.py | 37 +
 3 files changed, 32 insertions(+), 41 deletions(-)

diff --git a/framework/exectest.py b/framework/exectest.py
index fcc29af..7d08774 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -104,13 +104,11 @@ class Test(object):
 self.result['traceback'] = "".join(
 traceback.format_tb(exception[2]))
 
-log.log(path, self.result['result'])
-log.post_log(log_current, self.result['result'])
+log.log(path, self.result['result'], log_current)
 
 json_writer.write_dict_item(path, self.result)
 else:
-log.log(path, 'dry-run')
-log.post_log(log_current, 'dry-run')
+log.log(path, 'dry-run', log_current)
 
 @property
 def command(self):
diff --git a/framework/log.py b/framework/log.py
index d261dbb..97afeb1 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -102,14 +102,21 @@ class Log(object):
'result': result}))
 
 @synchronized_self
-def post_log(self, value, result):
-""" Used to mark a test as complete in the log
+def log(self, name, result, value):
+""" Print to the screen
+
+Works by moving the cursor back to the front of the line and printing
+over it.
 
 Arguments:
-value -- the test number to mark complete
-result -- the result of the completed test
+name -- the name of the test
+result -- the result of the test
+value -- the number of the test to remove
 
 """
+assert result in self.__summary_keys
+self.__print(name, result)
+
 # Mark running complete
 assert value in self.__running
 self.__running.remove(value)
@@ -121,27 +128,16 @@ class Log(object):
 self.__summary[result] += 1
 
 @synchronized_self
-def log(self, name, result):
-""" Print to the screen 
-
-Works by moving the cursor back to the front of the line and printing
-over it.
-
-"""
-assert result in self.__summary_keys
-self.__print(name, result)
-
-@synchronized_self
 def pre_log(self, running=None):
 """ Hook to run before log()
-
+
 Returns a new number to know what processes are running, if running is
 set it will print a running message for the test
 
 Keyword Arguments:
 running -- the name of a test to print is running. If Falsy then
nothing will be printed. Default: None
-
+
 """
 if running:
 self.__print(running, 'running')
diff --git a/framework/tests/log_tests.py b/framework/tests/log_tests.py
index d2cb336..333ba35 100644
--- a/framework/tests/log_tests.py
+++ b/framework/tests/log_tests.py
@@ -20,8 +20,6 @@
 
 """ Module provides tests for log.py module """
 
-import sys
-import itertools
 from types import *  # This is a special * safe module
 import nose.tools as nt
 from framework.log import Log
@@ -51,21 +49,20 @@ def test_pre_log_return():
msg="Log.pre_log() didn't return a numeric type!")
 
 
-def test_post_log_increment_complete():
-""" Tests that Log.post_log() increments self.__complete """
+def test_log_increment_complete():
+""" Tests that Log.log() increments self.__complete """
 log = Log(100, False)
 ret = log.pre_log()
-log.post_log(ret, 'pass')
+log.log('test', 'pass', ret)
 nt.assert_equal(log._Log__complete, 1,
-msg="Log.post_log() did not properly incremented "
-"Log.__current")
+msg="Log.log() did not properly incremented Log.__current")
 
 
-def check_post_log_increment_summary(stat):
-""" Test that passing a result to post_log works correctly """
+def check_log_increment_summary(stat):
+""" Test that passing a result to log works correctly """
 log = Log(100, False)
 ret = log.pre_log()
-log.post_log(ret, stat)
+log.log('test', stat, ret)
 print log._Log__summary
 nt.assert_equal(log._Log__summary[stat], 1,
 msg="Log.__summary[{}] was not properly "
@@ -73,26 +70,26 @@ def check_post_log_increment_summary(stat):
 
 
 @utils.nose_generator
-def test_post_log_increment_summary():
+def test_log_increment_summary():
 """ Generator that creates tests for self.__summary """
 for stat in valid_statuses:
-check_post_log_increment_summary.description = \
-"Test that Log.post_log increments self._su

[Piglit] [PATCH 0/5] Refactor log module

2014-07-03 Thread Dylan Baker
Hopefully this is the last major overhaul to this code I have to do.

I'll start by saything that my first take at reworking the log module
wasn't as successful as I had hoped it would be. The performance was
better, but not as much as I'd hoped. The code was okay when it first
landed, but not great, and as more features were added (and bugs were
fixed) it the worse it got.

The biggest problem with the initial design was the use of a single
class that had too much to do. Too much state to manage, to many
different logical trees to follow, to many methods, and too many
options. So I took a different aproach, the state is held in a Manager
class, which creates Log instances for each test running. These tests do
a small amount of state work, but are mostly concerned with printing
information to the conosle.

This gives us a couple of advantages, first the seperation of code makes
the invidual peices much simpler than the previous implementation. The
second advantage is in exendability, it should be fairly easy to add new
loggers.

Dylan Baker (5):
  framework/log.py: Merge Log.log() and Log.post_log()
  framework/log.py: Use keyword args to format instead of splat
  log.py: Makes method names clearer
  framework: refactor the log module
  framework: Add dummy logger that produces no output

 framework/core.py|   5 +-
 framework/exectest.py|   9 +-
 framework/log.py | 307 +--
 framework/profile.py |  10 +-
 framework/programs/run.py|  26 ++--
 framework/results.py |   6 +-
 framework/tests/log_tests.py | 179 -
 7 files changed, 353 insertions(+), 189 deletions(-)

-- 
2.0.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 4/5] framework: refactor the log module

2014-07-03 Thread Dylan Baker
This refactors the log module away from a single class that does
everything to having two classes. The first class LogFactory, is a state
manager that returns BaseLog derived objects when it's get() method is
called. However, it mainly acts as a shared state manager.

The BaseLog derived classes provide three public methods; start(),
log(), summary().

This makes the interfaces much cleaner, just 3 public methods that are
fairly obvious and clearly documented. It uses inheritance for more
shared code, and is just generally much less complex than the previous
implementation

This makes two changes to behavior, and I believe it is out of necessity.
In the previous implementation verbose printed a line at the start of
the test and at the end, but it also printed the status line like the
non-verbose logger does, using the '\r' character to overwrite the line.
As far as I can tell the new logger is too performant for this behavior,
it literally overwrites the line before a human could read it.

The second change is to the command line arguments. Because one of the
design goals of this series is to allow multiple loggers to be created
for different purposes having a single command line option to toggle
between one state or another isn't really feasible.

Signed-off-by: Dylan Baker 
---
 framework/core.py|   5 +-
 framework/exectest.py|   7 +-
 framework/log.py | 290 ---
 framework/profile.py |  10 +-
 framework/programs/run.py|  26 ++--
 framework/results.py |   6 +-
 framework/tests/log_tests.py | 177 +-
 7 files changed, 339 insertions(+), 182 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index 675b7aa..b4ba54a 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -71,13 +71,11 @@ class Options(object):
 exclude_filter -- list of compiled regex which exclude tests that match
 valgrind -- True if valgrind is to be used
 dmesg -- True if dmesg checking is desired. This forces concurrency off
-verbose -- verbosity level.
 env -- environment variables set for each test before run
 
 """
 def __init__(self, concurrent=True, execute=True, include_filter=None,
- exclude_filter=None, valgrind=False, dmesg=False,
- verbose=False):
+ exclude_filter=None, valgrind=False, dmesg=False):
 self.concurrent = concurrent
 self.execute = execute
 self.filter = [re.compile(x) for x in include_filter or []]
@@ -85,7 +83,6 @@ class Options(object):
 self.exclude_tests = set()
 self.valgrind = valgrind
 self.dmesg = dmesg
-self.verbose = verbose
 # env is used to set some base environment variables that are not going
 # to change across runs, without sending them to os.environ which is
 # fickle as easy to break
diff --git a/framework/exectest.py b/framework/exectest.py
index 7d08774..c27be90 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -84,7 +84,7 @@ class Test(object):
 Fully qualified test name as a string.  For example,
 ``spec/glsl-1.30/preprocessor/compiler/keywords/void.frag``.
 '''
-log_current = log.pre_log(path if self.OPTS.verbose else None)
+log.start(path)
 
 # Run the test
 if self.OPTS.execute:
@@ -104,11 +104,10 @@ class Test(object):
 self.result['traceback'] = "".join(
 traceback.format_tb(exception[2]))
 
-log.log(path, self.result['result'], log_current)
-
+log.log(self.result['result'])
 json_writer.write_dict_item(path, self.result)
 else:
-log.log(path, 'dry-run', log_current)
+log.log('dry-run')
 
 @property
 def command(self):
diff --git a/framework/log.py b/framework/log.py
index d6ab735..491ab7f 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -18,136 +18,230 @@
 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
-#
+
+""" Module for terminal logging
+
+This module provides a class LogManager, which acts as a state manager
+returning BaseLog derived instances to individual tests.
+
+"""
 
 import sys
+import abc
+import itertools
+import threading
 import collections
-from .threads import synchronized_self
+
+__all__ = ['LogManager']
 
 
-class Log(object):
-""" Print Progress to stdout
+class BaseLog(object):
+""" Abstract base class for Log objects
 
 Arguments:
-total -- The total number of tests to run.
+state -- the state dict from LogManager
 
 """
-def __init__(self, total, verbose):
-self.__total = total
-self.__complete = 0
-self.__running = []
-self.__generator = (x for x in xrange(self.__total))
-self.__pad = len(str(s

[Piglit] [PATCH 2/5] framework/log.py: Use keyword args to format instead of splat

2014-07-03 Thread Dylan Baker
Using splat with a dictionary makes sense when the dictionary is already
available (like with locals()), but it isn't very clear.

Signed-off-by: Dylan Baker 
---
 framework/log.py | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/framework/log.py b/framework/log.py
index 97afeb1..c967028 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -95,11 +95,12 @@ class Log(object):
 
 def __print(self, name, result):
 """ Do the actual printing """
-self._write_output(self.__output.format(**{'percent': self._percent(),
-   'running': self._running(),
-   'summary': self._summary(),
-   'name': name,
-   'result': result}))
+self._write_output(self.__output.format(
+percent=self._percent(),
+running=self._running(),
+summary=self._summary(),
+name=name,
+result=result))
 
 @synchronized_self
 def log(self, name, result, value):
@@ -147,5 +148,6 @@ class Log(object):
 return x
 
 def summary(self):
-self._write_output(self.__summary_output.format(**{'percent': 
self._percent(),
-   'summary': 
self._summary()}))
+self._write_output(self.__summary_output.format(
+percent=self._percent(),
+summary=self._summary()))
-- 
2.0.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 5/5] framework: Add dummy logger that produces no output

2014-07-03 Thread Dylan Baker
This adds a new logger option that produces no output. This is aimed at
headless setups or for systems like jenkins where the output data isn't
very useful.

Signed-off-by: Dylan Baker 
---
 framework/log.py | 13 +
 framework/programs/run.py|  2 +-
 framework/tests/log_tests.py |  3 ++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/framework/log.py b/framework/log.py
index 491ab7f..84b6855 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -208,6 +208,18 @@ class VerboseLog(QuietLog):
 super(VerboseLog, self).log(value)
 
 
+class DummyLog(BaseLog):
+""" A Logger that does nothing """
+def start(self, name):
+pass
+
+def log(self, status):
+pass
+
+def summary(self):
+pass
+
+
 class LogManager(object):
 """ Creates new log objects
 
@@ -229,6 +241,7 @@ class LogManager(object):
 LOG_MAP = {
 'quiet': QuietLog,
 'verbose': VerboseLog,
+'dummy': DummyLog,
 }
 
 def __init__(self, logger, total):
diff --git a/framework/programs/run.py b/framework/programs/run.py
index f04fdcf..7685a5a 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -88,7 +88,7 @@ def run(input_):
 parser.add_argument("-l", "--log-level",
 dest="log_level",
 action="store",
-choices=['quiet', 'verbose'],
+choices=['quiet', 'verbose', 'dummy'],
 default='quiet',
 help="Set the logger verbosity level")
 parser.add_argument("test_profile",
diff --git a/framework/tests/log_tests.py b/framework/tests/log_tests.py
index a71f3ca..9703b11 100644
--- a/framework/tests/log_tests.py
+++ b/framework/tests/log_tests.py
@@ -37,7 +37,8 @@ def test_initialize():
 check_initialize = lambda c, *a: c(*a)
 
 for name, class_ in [('QuiteLog', log.QuietLog),
- ('VerboseLog', log.VerboseLog)]:
+ ('VerboseLog', log.VerboseLog),
+ ('DummyLog', log.DummyLog)]:
 check_initialize.description = "{} initializes".format(name)
 yield check_initialize, class_, TEST_STATE
 
-- 
2.0.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 3/5] log.py: Makes method names clearer

2014-07-03 Thread Dylan Baker
This replace _summary, _running, and _percent with _print*. This makes
the methods easier to understand, especially with names like __summary
also used in the class

Signed-off-by: Dylan Baker 
---
 framework/log.py | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/framework/log.py b/framework/log.py
index c967028..d6ab735 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -78,17 +78,17 @@ class Log(object):
 # newline.
 sys.stdout.flush()
 
-def _summary(self):
+def _print_summary(self):
 """ return a summary of the statuses """
 return ", ".join("{0}: {1}".format(k, self.__summary[k])
  for k in sorted(self.__summary))
 
-def _running(self):
+def _print_running(self):
 """ return running tests """
 return "Running Test(s): {}".format(
 " ".join([str(x).zfill(self.__pad) for x in self.__running]))
 
-def _percent(self):
+def _print_percent(self):
 """ return the percentage of tess completed """
 return "{0}/{1}".format(str(self.__complete).zfill(self.__pad),
 str(self.__total).zfill(self.__pad))
@@ -96,9 +96,9 @@ class Log(object):
 def __print(self, name, result):
 """ Do the actual printing """
 self._write_output(self.__output.format(
-percent=self._percent(),
-running=self._running(),
-summary=self._summary(),
+percent=self._print_percent(),
+running=self._print_running(),
+summary=self._print_summary(),
 name=name,
 result=result))
 
@@ -149,5 +149,5 @@ class Log(object):
 
 def summary(self):
 self._write_output(self.__summary_output.format(
-percent=self._percent(),
-summary=self._summary()))
+percent=self._print_percent(),
+summary=self._print_summary()))
-- 
2.0.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 06/16] Unify piglit_probe_image_* functions between GL and GLES

2014-07-03 Thread Josh Triplett
Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 210 +
 tests/util/piglit-util-gl.c| 166 -
 tests/util/piglit-util-gles.c  |  44 
 3 files changed, 210 insertions(+), 210 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 6764d96..9f778c5 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1273,3 +1273,213 @@ piglit_probe_rect_rgba_uint(int x, int y, int w, int h,
free(pixels);
return 1;
 }
+
+static void
+print_pixel_ubyte(const GLubyte *pixel, unsigned components)
+{
+   int p;
+   for (p = 0; p < components; ++p)
+   printf(" %u", pixel[p]);
+}
+
+static void
+print_pixel_float(const float *pixel, unsigned components)
+{
+   int p;
+   for (p = 0; p < components; ++p)
+   printf(" %f", pixel[p]);
+}
+
+/**
+ * Compute the appropriate tolerance for comparing images of the given
+ * base format.
+ */
+void
+piglit_compute_probe_tolerance(GLenum format, float *tolerance)
+{
+   int num_components, component;
+   switch (format) {
+   case GL_LUMINANCE_ALPHA:
+   tolerance[0] = piglit_tolerance[0];
+   tolerance[1] = piglit_tolerance[3];
+   break;
+   case GL_ALPHA:
+   tolerance[0] = piglit_tolerance[3];
+   break;
+   default:
+   num_components = piglit_num_components(format);
+   for (component = 0; component < num_components; ++component)
+   tolerance[component] = piglit_tolerance[component];
+   break;
+   }
+}
+
+/**
+ * Compare two in-memory floating-point images.
+ */
+int
+piglit_compare_images_color(int x, int y, int w, int h, int num_components,
+   const float *tolerance,
+   const float *expected_image,
+   const float *observed_image)
+{
+   int i, j, p;
+   for (j = 0; j < h; j++) {
+   for (i = 0; i < w; i++) {
+   const float *expected =
+   &expected_image[(j*w+i)*num_components];
+   const float *probe =
+   &observed_image[(j*w+i)*num_components];
+
+   for (p = 0; p < num_components; ++p) {
+   if (fabs(probe[p] - expected[p])
+   >= tolerance[p]) {
+   printf("Probe at (%i,%i)\n", x+i, y+j);
+   printf("  Expected:");
+   print_pixel_float(expected, 
num_components);
+   printf("\n  Observed:");
+   print_pixel_float(probe, 
num_components);
+   printf("\n");
+
+   return 0;
+   }
+   }
+   }
+   }
+
+   return 1;
+}
+
+/**
+ * Compare the contents of the current read framebuffer with the given
+ * in-memory floating-point image.
+ */
+int
+piglit_probe_image_color(int x, int y, int w, int h, GLenum format,
+const float *image)
+{
+   int c = piglit_num_components(format);
+   GLfloat *pixels;
+   float tolerance[4];
+   int result;
+
+   piglit_compute_probe_tolerance(format, tolerance);
+
+   if (format == GL_INTENSITY) {
+   /* GL_INTENSITY is not allowed for ReadPixels so
+* substitute GL_LUMINANCE.
+*/
+   format = GL_LUMINANCE;
+   }
+
+   pixels = piglit_read_pixels_float(x, y, w, h, format, NULL);
+
+   result = piglit_compare_images_color(x, y, w, h, c, tolerance, image,
+pixels);
+
+   free(pixels);
+   return result;
+}
+
+int
+piglit_probe_image_rgb(int x, int y, int w, int h, const float *image)
+{
+   return piglit_probe_image_color(x, y, w, h, GL_RGB, image);
+}
+
+int
+piglit_probe_image_rgba(int x, int y, int w, int h, const float *image)
+{
+   return piglit_probe_image_color(x, y, w, h, GL_RGBA, image);
+}
+
+/**
+ * Compare two in-memory unsigned-byte images.
+ */
+int
+piglit_compare_images_ubyte(int x, int y, int w, int h,
+   const GLubyte *expected_image,
+   const GLubyte *observed_image)
+{
+   int i, j;
+   for (j = 0; j < h; j++) {
+   for (i = 0; i < w; i++) {
+   const GLubyte expected = expected_image[j*w+i];
+   const GLubyte probe = observed_image[j*w+i];
+
+   if (probe != expected) {
+   printf("Probe at (%i,%i)\n", x+i, y+j);
+   

[Piglit] [PATCH 15/16] Unify piglit_rgbw_texture between GL and GLES; drop piglit-util-gles.c

2014-07-03 Thread Josh Triplett
With the image generation factored out to piglit_rgbw_image and
piglit_rgbw_image_ubyte, the remainder of the implementation becomes
common between GL and GLES.

This eliminates the last helper function from piglit-util-gles.c, so
drop it.

Signed-off-by: Josh Triplett 
---
 tests/util/CMakeLists.gles1.txt|   5 -
 tests/util/CMakeLists.gles2.txt|   1 -
 tests/util/CMakeLists.gles3.txt|   1 -
 tests/util/piglit-util-gl-common.c | 209 +
 tests/util/piglit-util-gl.c| 166 -
 tests/util/piglit-util-gles.c  | 126 --
 6 files changed, 209 insertions(+), 299 deletions(-)
 delete mode 100644 tests/util/piglit-util-gles.c

diff --git a/tests/util/CMakeLists.gles1.txt b/tests/util/CMakeLists.gles1.txt
index fe38404..4342cf2 100644
--- a/tests/util/CMakeLists.gles1.txt
+++ b/tests/util/CMakeLists.gles1.txt
@@ -1,8 +1,3 @@
-set(UTIL_GL_SOURCES
-   ${UTIL_GL_SOURCES}
-   piglit-util-gles.c
-   )
-
 include_directories(
${UTIL_GL_INCLUDES}
)
diff --git a/tests/util/CMakeLists.gles2.txt b/tests/util/CMakeLists.gles2.txt
index 2ce87e5..0faedb5 100644
--- a/tests/util/CMakeLists.gles2.txt
+++ b/tests/util/CMakeLists.gles2.txt
@@ -5,7 +5,6 @@ set(UTIL_GL_SOURCES
piglit-dispatch-init.c
piglit-shader.c
piglit-shader-gles2.c
-   piglit-util-gles.c
minmax-test.c
)
 
diff --git a/tests/util/CMakeLists.gles3.txt b/tests/util/CMakeLists.gles3.txt
index 9572b59..50abd08 100644
--- a/tests/util/CMakeLists.gles3.txt
+++ b/tests/util/CMakeLists.gles3.txt
@@ -4,7 +4,6 @@ list(APPEND UTIL_GL_SOURCES
piglit-dispatch-init.c
piglit-shader.c
piglit-shader-gles2.c # Compatible with gles3.
-   piglit-util-gles.c
piglit-vbo.cpp
)
 
diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 537e19c..94e0816 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -2066,3 +2066,212 @@ piglit_miptree_texture()
}
return tex;
 }
+
+/**
+ * Generates an image of the given size with quadrants of red, green,
+ * blue and white.
+ * Note that for compressed teximages, where the blocking would be
+ * problematic, we assign the whole layers at w == 4 to red, w == 2 to
+ * green, and w == 1 to blue.
+ *
+ * \param internalFormat  either GL_RGBA or a specific compressed format
+ * \param w  the width in texels
+ * \param h  the height in texels
+ * \param alpha  if TRUE, use varied alpha values, else all alphas = 1
+ * \param basetype  either GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALIZED
+ *  or GL_FLOAT
+ */
+GLfloat *
+piglit_rgbw_image(GLenum internalFormat, int w, int h,
+ GLboolean alpha, GLenum basetype)
+{
+   float red[4]   = {1.0, 0.0, 0.0, 0.0};
+   float green[4] = {0.0, 1.0, 0.0, 0.25};
+   float blue[4]  = {0.0, 0.0, 1.0, 0.5};
+   float white[4] = {1.0, 1.0, 1.0, 1.0};
+   GLfloat *data;
+   int x, y;
+
+   if (!alpha) {
+   red[3] = 1.0;
+   green[3] = 1.0;
+   blue[3] = 1.0;
+   white[3] = 1.0;
+   }
+
+   switch (basetype) {
+   case GL_UNSIGNED_NORMALIZED:
+   break;
+
+   case GL_SIGNED_NORMALIZED:
+   for (x = 0; x < 4; x++) {
+   red[x] = red[x] * 2 - 1;
+   green[x] = green[x] * 2 - 1;
+   blue[x] = blue[x] * 2 - 1;
+   white[x] = white[x] * 2 - 1;
+   }
+   break;
+
+   case GL_FLOAT:
+   for (x = 0; x < 4; x++) {
+   red[x] = red[x] * 10 - 5;
+   green[x] = green[x] * 10 - 5;
+   blue[x] = blue[x] * 10 - 5;
+   white[x] = white[x] * 10 - 5;
+   }
+   break;
+
+   default:
+   assert(0);
+   }
+
+   data = malloc(w * h * 4 * sizeof(GLfloat));
+
+   for (y = 0; y < h; y++) {
+   for (x = 0; x < w; x++) {
+   const int size = w > h ? w : h;
+   const float *color;
+
+   if (x < w / 2 && y < h / 2)
+   color = red;
+   else if (y < h / 2)
+   color = green;
+   else if (x < w / 2)
+   color = blue;
+   else
+   color = white;
+
+   switch (internalFormat) {
+   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+   case GL_COMPRESSED_RGB_FXT1_3DFX:
+   c

[Piglit] [PATCH 08/16] Move piglit_probe_texel_* functions to GL common code

2014-07-03 Thread Josh Triplett
These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 183 +
 tests/util/piglit-util-gl.c| 183 -
 2 files changed, 183 insertions(+), 183 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 3a31e42..e05ae43 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1497,3 +1497,186 @@ piglit_probe_image_ubyte(int x, int y, int w, int h, 
GLenum format,
free(pixels);
return 1;
 }
+
+/**
+ * Read a texel rectangle from the given location and compare its RGB value to
+ * the given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_texel_rect_rgb(int target, int level, int x, int y,
+   int w, int h, const float* expected)
+{
+   GLfloat *buffer;
+   GLfloat *probe;
+   int i, j, p;
+   GLint width;
+   GLint height;
+
+   glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
+   glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
+   buffer = malloc(width * height * 3 * sizeof(GLfloat));
+
+   glGetTexImage(target, level, GL_RGB, GL_FLOAT, buffer);
+
+   assert(x >= 0);
+   assert(y >= 0);
+   assert(x+w <= width);
+   assert(y+h <= height);
+
+   for (j = y; j < y+h; ++j) {
+   for (i = x; i < x+w; ++i) {
+   probe = &buffer[(j * width + i) * 3];
+
+   for (p = 0; p < 3; ++p) {
+   if (fabs(probe[p] - expected[p]) >= 
piglit_tolerance[p]) {
+   printf("Probe color at (%i,%i)\n", i, 
j);
+   printf("  Expected: %f %f %f\n",
+  expected[0], expected[1], 
expected[2]);
+   printf("  Observed: %f %f %f\n",
+  probe[0], probe[1], probe[2]);
+
+   free(buffer);
+   return 0;
+   }
+   }
+   }
+   }
+
+   free(buffer);
+   return 1;
+}
+
+/**
+ * Read a texel from the given location and compare its RGB value to the
+ * given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_texel_rgb(int target, int level, int x, int y,
+  const float *expected)
+{
+   return piglit_probe_texel_rect_rgb(target, level, x, y, 1, 1, expected);
+}
+
+/**
+ * Read a texel rectangle from the given location and compare its RGBA value to
+ * the given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_texel_rect_rgba(int target, int level, int x, int y,
+int w, int h, const float* expected)
+{
+   GLfloat *buffer;
+   GLfloat *probe;
+   int i, j, p;
+   GLint width;
+   GLint height;
+
+   glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
+   glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
+   buffer = malloc(width * height * 4 * sizeof(GLfloat));
+
+   glGetTexImage(target, level, GL_RGBA, GL_FLOAT, buffer);
+
+   assert(x >= 0);
+   assert(y >= 0);
+   assert(x+w <= width);
+   assert(y+h <= height);
+
+   for (j = y; j < y+h; ++j) {
+   for (i = x; i < x+w; ++i) {
+   probe = &buffer[(j * width + i) * 4];
+
+   for (p = 0; p < 4; ++p) {
+   if (fabs(probe[p] - expected[p]) >= 
piglit_tolerance[p]) {
+   printf("Probe color at (%i,%i)\n", i, 
j);
+   printf("  Expected: %f %f %f %f\n",
+  expected[0], expected[1], 
expected[2], expected[3]);
+   printf("  Observed: %f %f %f %f\n",
+  probe[0], probe[1], probe[2], 
probe[3]);
+
+   free(buffer);
+   return 0;
+   }
+   }
+   }
+   }
+
+   free(buffer);
+   return 1;
+}
+
+/**
+ * Read a texel from the given location and compare its RGBA value to the
+ * given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ 

[Piglit] [PATCH 11/16] Move piglit_draw_triangle* helper functions to GL common code

2014-07-03 Thread Josh Triplett
These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 40 ++
 tests/util/piglit-util-gl.c| 40 --
 2 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index c00c9c7..f84fd2c 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1877,3 +1877,43 @@ GLuint piglit_compile_program(GLenum target, const char* 
text)
 
return program;
 }
+
+/**
+ * Convenience function to draw a triangle.
+ */
+GLvoid
+piglit_draw_triangle(float x1, float y1, float x2, float y2,
+float x3, float y3)
+{
+   piglit_draw_triangle_z(0.0, x1, y1, x2, y2, x3, y3);
+}
+
+/**
+ * Convenience function to draw a triangle at a given depth.
+ */
+GLvoid
+piglit_draw_triangle_z(float z, float x1, float y1, float x2, float y2,
+float x3, float y3)
+{
+   float verts[3][4];
+
+   verts[0][0] = x1;
+   verts[0][1] = y1;
+   verts[0][2] = z;
+   verts[0][3] = 1.0;
+   verts[1][0] = x2;
+   verts[1][1] = y2;
+   verts[1][2] = z;
+   verts[1][3] = 1.0;
+   verts[2][0] = x3;
+   verts[2][1] = y3;
+   verts[2][2] = z;
+   verts[2][3] = 1.0;
+
+   glVertexPointer(4, GL_FLOAT, 0, verts);
+   glEnableClientState(GL_VERTEX_ARRAY);
+
+   glDrawArrays(GL_TRIANGLES, 0, 3);
+
+   glDisableClientState(GL_VERTEX_ARRAY);
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index bec2940..346a985 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -37,46 +37,6 @@
 
 
 /**
- * Convenience function to draw a triangle.
- */
-GLvoid
-piglit_draw_triangle(float x1, float y1, float x2, float y2,
-float x3, float y3)
-{
-   piglit_draw_triangle_z(0.0, x1, y1, x2, y2, x3, y3);
-}
-
-/**
- * Convenience function to draw a triangle at a given depth.
- */
-GLvoid
-piglit_draw_triangle_z(float z, float x1, float y1, float x2, float y2,
-float x3, float y3)
-{
-   float verts[3][4];
-
-   verts[0][0] = x1;
-   verts[0][1] = y1;
-   verts[0][2] = z;
-   verts[0][3] = 1.0;
-   verts[1][0] = x2;
-   verts[1][1] = y2;
-   verts[1][2] = z;
-   verts[1][3] = 1.0;
-   verts[2][0] = x3;
-   verts[2][1] = y3;
-   verts[2][2] = z;
-   verts[2][3] = 1.0;
-
-   glVertexPointer(4, GL_FLOAT, 0, verts);
-   glEnableClientState(GL_VERTEX_ARRAY);
-
-   glDrawArrays(GL_TRIANGLES, 0, 3);
-
-   glDisableClientState(GL_VERTEX_ARRAY);
-}
-
-/**
  * Generate a checkerboard texture
  *
  * \param texName of the texture to be used.  If \c tex is
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 01/16] Fix piglit_is_gles to return true for "OpenGL ES-CM 1.1 ..."

2014-07-03 Thread Josh Triplett
Piglit looked for a GL_VERSION starting with "OpenGL ES ", which did not
match "OpenGL ES-CM 1.1 Mesa 10.2.1".  Stop requiring the trailing
space.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 4abbd57..609f6a9 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -40,7 +40,7 @@ bool piglit_is_core_profile;
 bool piglit_is_gles(void)
 {
const char *version_string = (const char *) glGetString(GL_VERSION);
-   return strncmp("OpenGL ES ", version_string, 10) == 0;
+   return strncmp("OpenGL ES", version_string, 9) == 0;
 }
 
 int piglit_get_gl_version(void)
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 10/16] Move piglit program helper functions to GL common code

2014-07-03 Thread Josh Triplett
These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 81 +
 tests/util/piglit-util-gl.c| 82 --
 2 files changed, 81 insertions(+), 82 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index a4c283d..c00c9c7 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1796,3 +1796,84 @@ bool piglit_probe_buffer(GLuint buf, GLenum target, 
const char *label,
return status;
 }
 
+GLint piglit_ARBfp_pass_through = 0;
+
+int piglit_use_fragment_program(void)
+{
+   static const char source[] =
+   "!!ARBfp1.0\n"
+   "MOVresult.color, fragment.color;\n"
+   "END\n"
+   ;
+
+   piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
+   if (!piglit_is_extension_supported("GL_ARB_fragment_program"))
+   return 0;
+
+   piglit_ARBfp_pass_through =
+   piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, source);
+
+   return (piglit_ARBfp_pass_through != 0);
+}
+
+void piglit_require_fragment_program(void)
+{
+   if (!piglit_use_fragment_program()) {
+   printf("GL_ARB_fragment_program not supported.\n");
+   piglit_report_result(PIGLIT_SKIP);
+   }
+}
+
+int piglit_use_vertex_program(void)
+{
+   piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
+   return piglit_is_extension_supported("GL_ARB_vertex_program");
+}
+
+void piglit_require_vertex_program(void)
+{
+   if (!piglit_use_vertex_program()) {
+   printf("GL_ARB_vertex_program not supported.\n");
+   piglit_report_result(PIGLIT_SKIP);
+   }
+}
+
+GLuint piglit_compile_program(GLenum target, const char* text)
+{
+   GLuint program;
+   GLint errorPos;
+
+   glGenProgramsARB(1, &program);
+   glBindProgramARB(target, program);
+   glProgramStringARB(
+   target,
+   GL_PROGRAM_FORMAT_ASCII_ARB,
+   strlen(text),
+   (const GLubyte *)text);
+   glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
+   if (glGetError() != GL_NO_ERROR || errorPos != -1) {
+   int l = piglit_find_line(text, errorPos);
+   int a;
+
+   fprintf(stderr, "Compiler Error (pos=%d line=%d): %s\n",
+   errorPos, l,
+   (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+
+   for (a=-10; a<10; a++)
+   {
+   if (errorPos+a < 0)
+   continue;
+   if (errorPos+a >= strlen(text))
+   break;
+   fprintf(stderr, "%c", text[errorPos+a]);
+   }
+   fprintf(stderr, "\nin program:\n%s", text);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   if (!glIsProgramARB(program)) {
+   fprintf(stderr, "glIsProgramARB failed\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   return program;
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 611b59a..bec2940 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -36,88 +36,6 @@
 #include "piglit-util-gl-common.h"
 
 
-GLint piglit_ARBfp_pass_through = 0;
-
-int piglit_use_fragment_program(void)
-{
-   static const char source[] =
-   "!!ARBfp1.0\n"
-   "MOVresult.color, fragment.color;\n"
-   "END\n"
-   ;
-
-   piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
-   if (!piglit_is_extension_supported("GL_ARB_fragment_program"))
-   return 0;
-
-   piglit_ARBfp_pass_through =
-   piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, source);
-
-   return (piglit_ARBfp_pass_through != 0);
-}
-
-void piglit_require_fragment_program(void)
-{
-   if (!piglit_use_fragment_program()) {
-   printf("GL_ARB_fragment_program not supported.\n");
-   piglit_report_result(PIGLIT_SKIP);
-   }
-}
-
-int piglit_use_vertex_program(void)
-{
-   piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
-   return piglit_is_extension_supported("GL_ARB_vertex_program");
-}
-
-void piglit_require_vertex_program(void)
-{
-   if (!piglit_use_vertex_program()) {
-   printf("GL_ARB_vertex_program not supported.\n");
-   piglit_report_result(PIGLIT_SKIP);
-   }
-}
-
-GLuint piglit_compile_program(GLenum target, const char* text)
-{
-   GLuint program;
-   GLint errorPos;
-
-   glGenProgramsARB(1, &program);
-   glBindProgramARB(target, program);
-   glProgramStringARB(
-   target,
-   GL_PROGRAM_FORMAT_ASCII_ARB,
-  

[Piglit] [PATCH 09/16] Move remaining piglit_probe_* functions to GL common code

2014-07-03 Thread Josh Triplett
These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 116 +
 tests/util/piglit-util-gl.c| 115 
 2 files changed, 116 insertions(+), 115 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index e05ae43..a4c283d 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1680,3 +1680,119 @@ int piglit_probe_texel_volume_rgba(int target, int 
level, int x, int y, int z,
free(buffer);
return 1;
 }
+
+/**
+ * Read a pixel from the given location and compare its depth value to the
+ * given expected value.
+ *
+ * Print a log message if the depth value deviates from the expected value.
+ * \return true if the depth value matches, false otherwise
+ */
+int piglit_probe_pixel_depth(int x, int y, float expected)
+{
+   GLfloat probe;
+   GLfloat delta;
+
+   glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &probe);
+
+   delta = probe - expected;
+   if (fabs(delta) < 0.01)
+   return 1;
+
+   printf("Probe depth at (%i,%i)\n", x, y);
+   printf("  Expected: %f\n", expected);
+   printf("  Observed: %f\n", probe);
+
+   return 0;
+}
+
+int piglit_probe_rect_depth(int x, int y, int w, int h, float expected)
+{
+   int i, j;
+   GLfloat *probe;
+   GLfloat *pixels = malloc(w*h*sizeof(float));
+
+   glReadPixels(x, y, w, h, GL_DEPTH_COMPONENT, GL_FLOAT, pixels);
+
+   for (j = 0; j < h; j++) {
+   for (i = 0; i < w; i++) {
+   probe = &pixels[j*w+i];
+
+   if (fabs(*probe - expected) >= 0.01) {
+   printf("Probe depth at (%i,%i)\n", x+i, y+j);
+   printf("  Expected: %f\n", expected);
+   printf("  Observed: %f\n", *probe);
+
+   free(pixels);
+   return 0;
+   }
+   }
+   }
+
+   free(pixels);
+   return 1;
+}
+
+int piglit_probe_pixel_stencil(int x, int y, unsigned expected)
+{
+   GLuint probe;
+   glReadPixels(x, y, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_INT, &probe);
+
+   if (probe == expected)
+   return 1;
+
+   printf("Probe stencil at (%i, %i)\n", x, y);
+   printf("  Expected: %u\n", expected);
+   printf("  Observed: %u\n", probe);
+
+   return 0;
+}
+
+int piglit_probe_rect_stencil(int x, int y, int w, int h, unsigned expected)
+{
+   int i, j;
+   GLuint *pixels = malloc(w*h*sizeof(GLuint));
+
+   glReadPixels(x, y, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_INT, pixels);
+
+   for (j = 0; j < h; j++) {
+   for (i = 0; i < w; i++) {
+   GLuint probe = pixels[j * w + i];
+   if (probe != expected) {
+   printf("Probe stencil at (%i, %i)\n", x + i, y 
+ j);
+   printf("  Expected: %u\n", expected);
+   printf("  Observed: %u\n", probe);
+   free(pixels);
+   return 0;
+   }
+   }
+   }
+
+   free(pixels);
+   return 1;
+}
+
+bool piglit_probe_buffer(GLuint buf, GLenum target, const char *label,
+unsigned n, unsigned num_components,
+const float *expected)
+{
+   float *ptr;
+   unsigned i;
+   bool status = true;
+
+   glBindBuffer(target, buf);
+   ptr = glMapBuffer(target, GL_READ_ONLY);
+
+   for (i = 0; i < n * num_components; i++) {
+   if (fabs(ptr[i] - expected[i % num_components]) > 0.01) {
+   printf("%s[%i]: %f, Expected: %f\n", label, i, ptr[i],
+   expected[i % num_components]);
+   status = false;
+   }
+   }
+
+   glUnmapBuffer(target);
+
+   return status;
+}
+
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 8e4fc52..611b59a 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -38,121 +38,6 @@
 
 GLint piglit_ARBfp_pass_through = 0;
 
-/**
- * Read a pixel from the given location and compare its depth value to the
- * given expected value.
- *
- * Print a log message if the depth value deviates from the expected value.
- * \return true if the depth value matches, false otherwise
- */
-int piglit_probe_pixel_depth(int x, int y, float expected)
-{
-   GLfloat probe;
-   GLfloat delta;
-
-   glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &probe);
-
-   delta = probe - expected;
-   if (fabs(delta) < 0.01)
-   return 1;
-
-   printf("Probe depth at (%i,%i)\n", x, y);
-   printf("  Expect

[Piglit] [PATCH 05/16] Unify piglit_probe_pixel_* and piglit_probe_rect_* between GL and GLES

2014-07-03 Thread Josh Triplett
Introduce a new internal helper, piglit_read_pixels_float, that always
returns floats.  On GL it just calls glReadPixels with GL_FLOAT; on GLES
it uses GL_UNSIGNED_BYTE and converts.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 280 +
 tests/util/piglit-util-gl.c| 258 --
 tests/util/piglit-util-gles.c  | 127 -
 3 files changed, 280 insertions(+), 385 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 32bddf8..6764d96 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -993,3 +993,283 @@ piglit_get_luminance_intensity_bits(GLenum 
internalformat, int *bits)
}
return false;
 }
+
+/* Wrapper around glReadPixels that always returns floats; reads and converts
+ * GL_UNSIGNED_BYTE on GLES.  If pixels == NULL, malloc a float array of the
+ * appropriate size, otherwise use the one provided. */
+static GLfloat *
+piglit_read_pixels_float(GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLfloat *pixels)
+{
+   GLubyte *pixels_b;
+   unsigned i, ncomponents;
+
+   ncomponents = width * height * piglit_num_components(format);
+   if (!pixels)
+   pixels = malloc(ncomponents * sizeof(GLfloat));
+
+   if (!piglit_is_gles()) {
+   glReadPixels(x, y, width, height, format, GL_FLOAT, pixels);
+   return pixels;
+   }
+
+   pixels_b = malloc(ncomponents * sizeof(GLubyte));
+   glReadPixels(x, y, width, height, format, GL_UNSIGNED_BYTE, pixels_b);
+   for (i = 0; i < ncomponents; i++)
+   pixels[i] = pixels_b[i] / 255.0;
+   free(pixels_b);
+   return pixels;
+}
+
+int
+piglit_probe_pixel_rgb_silent(int x, int y, const float* expected, float 
*out_probe)
+{
+   GLfloat probe[3];
+   int i;
+   GLboolean pass = GL_TRUE;
+
+   piglit_read_pixels_float(x, y, 1, 1, GL_RGB, probe);
+
+   for(i = 0; i < 3; ++i)
+   if (fabs(probe[i] - expected[i]) > piglit_tolerance[i])
+   pass = GL_FALSE;
+
+   if (out_probe)
+   memcpy(out_probe, probe, sizeof(probe));
+
+   return pass;
+}
+
+int
+piglit_probe_pixel_rgba_silent(int x, int y, const float* expected, float 
*out_probe)
+{
+   GLfloat probe[4];
+   int i;
+   GLboolean pass = GL_TRUE;
+
+   piglit_read_pixels_float(x, y, 1, 1, GL_RGBA, probe);
+
+   for(i = 0; i < 4; ++i)
+   if (fabs(probe[i] - expected[i]) > piglit_tolerance[i])
+   pass = GL_FALSE;
+
+   if (out_probe)
+   memcpy(out_probe, probe, sizeof(probe));
+
+   return pass;
+}
+
+/**
+ * Read a pixel from the given location and compare its RGB value to the
+ * given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int
+piglit_probe_pixel_rgb(int x, int y, const float* expected)
+{
+   GLfloat probe[3];
+   int i;
+   GLboolean pass = GL_TRUE;
+
+   piglit_read_pixels_float(x, y, 1, 1, GL_RGB, probe);
+
+   for(i = 0; i < 3; ++i)
+   if (fabs(probe[i] - expected[i]) > piglit_tolerance[i])
+   pass = GL_FALSE;
+
+   if (pass)
+   return 1;
+
+   printf("Probe color at (%i,%i)\n", x, y);
+   printf("  Expected: %f %f %f\n", expected[0], expected[1], expected[2]);
+   printf("  Observed: %f %f %f\n", probe[0], probe[1], probe[2]);
+
+   return 0;
+}
+
+/**
+ * Read a pixel from the given location and compare its RGBA value to the
+ * given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int
+piglit_probe_pixel_rgba(int x, int y, const float* expected)
+{
+   GLfloat probe[4];
+   int i;
+   GLboolean pass = GL_TRUE;
+
+   piglit_read_pixels_float(x, y, 1, 1, GL_RGBA, probe);
+
+   for(i = 0; i < 4; ++i)
+   if (fabs(probe[i] - expected[i]) > piglit_tolerance[i])
+   pass = GL_FALSE;
+
+   if (pass)
+   return 1;
+
+   printf("Probe color at (%i,%i)\n", x, y);
+   printf("  Expected: %f %f %f %f\n", expected[0], expected[1], 
expected[2], expected[3]);
+   printf("  Observed: %f %f %f %f\n", probe[0], probe[1], probe[2], 
probe[3]);
+
+   return 0;
+}
+
+int
+piglit_probe_rect_rgb_silent(int x, int y, int w, int h, const float *expected)
+{
+   int i, j, p;
+   GLfloat *probe;
+   GLfloat *pixels;
+
+   pixels = piglit_read_pixels_float(x, y, w, h, GL_RGB, NULL);
+
+   for (j = 0; j < h; j++) {
+   for (i = 0; i < w; i++) {
+   probe = &pixels[(j*w+i)*3];
+
+  

[Piglit] [PATCH 13/16] Move piglit_miptree_texture to GL common code

2014-07-03 Thread Josh Triplett
This doesn't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 39 +
 tests/util/piglit-util-gl.c| 40 --
 2 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index bd61e35..537e19c 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -2027,3 +2027,42 @@ piglit_checkerboard_texture(GLuint tex, unsigned level,
 
return tex;
 }
+
+/**
+ * Generates a 8x8 mipmapped texture whose layers contain solid r, g, b, and w.
+ */
+GLuint
+piglit_miptree_texture()
+{
+   GLfloat *data;
+   int size, i, level;
+   GLuint tex;
+   const float color_wheel[4][4] = {
+   {1, 0, 0, 1}, /* red */
+   {0, 1, 0, 1}, /* green */
+   {0, 0, 1, 1}, /* blue */
+   {1, 1, 1, 1}, /* white */
+   };
+
+   glGenTextures(1, &tex);
+   glBindTexture(GL_TEXTURE_2D, tex);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+   GL_NEAREST_MIPMAP_NEAREST);
+
+   for (level = 0; level < 4; ++level) {
+   size = 8 >> level;
+
+   data = malloc(size*size*4*sizeof(GLfloat));
+   for (i = 0; i < size * size; ++i) {
+   memcpy(data + 4 * i, color_wheel[level],
+  4 * sizeof(GLfloat));
+   }
+   glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA,
+size, size, 0, GL_RGBA, GL_FLOAT, data);
+   free(data);
+   }
+   return tex;
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index cbaf167..5e20b01 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -37,46 +37,6 @@
 
 
 /**
- * Generates a 8x8 mipmapped texture whose layers contain solid r, g, b, and w.
- */
-GLuint
-piglit_miptree_texture()
-{
-   GLfloat *data;
-   int size, i, level;
-   GLuint tex;
-   const float color_wheel[4][4] = {
-   {1, 0, 0, 1}, /* red */
-   {0, 1, 0, 1}, /* green */
-   {0, 0, 1, 1}, /* blue */
-   {1, 1, 1, 1}, /* white */
-   };
-
-   glGenTextures(1, &tex);
-   glBindTexture(GL_TEXTURE_2D, tex);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
-   GL_NEAREST_MIPMAP_NEAREST);
-
-   for (level = 0; level < 4; ++level) {
-   size = 8 >> level;
-
-   data = malloc(size*size*4*sizeof(GLfloat));
-   for (i = 0; i < size * size; ++i) {
-   memcpy(data + 4 * i, color_wheel[level],
-  4 * sizeof(GLfloat));
-   }
-   glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA,
-size, size, 0, GL_RGBA, GL_FLOAT, data);
-   free(data);
-   }
-   return tex;
-}
-
-
-/**
  * Generates an image of the given size with quadrants of red, green,
  * blue and white.
  * Note that for compressed teximages, where the blocking would be
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 04/16] Unify projection utility functions across GL and GLES

2014-07-03 Thread Josh Triplett
piglit_gen_ortho_projection and piglit_ortho_projection already had a
similar implementation for GL and GLES1; common it up and remove the
ifdefs.

Move piglit_frustum_projection out of GL-only code as well, and add
support for GLES1 using glFrustumf.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 58 ++
 tests/util/piglit-util-gl.c| 54 ---
 tests/util/piglit-util-gles.c  | 37 
 3 files changed, 58 insertions(+), 91 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index a0be726..32bddf8 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -520,6 +520,64 @@ piglit_compressed_pixel_offset(GLenum format, unsigned 
width,
return offset;
 }
 
+/**
+ * Convenience function to configure an abitrary orthogonal projection matrix
+ */
+void
+piglit_gen_ortho_projection(double left, double right, double bottom,
+   double top, double near_val, double far_val,
+   GLboolean push)
+{
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   if (push)
+   glPushMatrix();
+
+   if (piglit_is_gles())
+   glOrthof(left, right, bottom, top, near_val, far_val);
+   else
+   glOrtho(left, right, bottom, top, near_val, far_val);
+
+   glMatrixMode(GL_MODELVIEW);
+   if (push)
+   glPushMatrix();
+   glLoadIdentity();
+}
+
+/**
+ * Convenience function to configure projection matrix for window coordinates
+ */
+void
+piglit_ortho_projection(int w, int h, GLboolean push)
+{
+/* Set up projection matrix so we can just draw using window
+ * coordinates.
+ */
+   piglit_gen_ortho_projection(0, w, 0, h, -1, 1, push);
+}
+
+/**
+ * Convenience function to configure frustum projection.
+ */
+void
+piglit_frustum_projection(GLboolean push, double l, double r, double b,
+ double t, double n, double f)
+{
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   if (push)
+   glPushMatrix();
+
+   if (piglit_is_gles())
+   glFrustumf(l, r, b, t, n, f);
+   else
+   glFrustum(l, r, b, t, n, f);
+
+   glMatrixMode(GL_MODELVIEW);
+   if (push)
+   glPushMatrix();
+   glLoadIdentity();
+}
 
 #ifndef PIGLIT_USE_OPENGL_ES1
 /**
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 773e09f..91f3dc0 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -894,60 +894,6 @@ piglit_draw_triangle_z(float z, float x1, float y1, float 
x2, float y2,
 }
 
 /**
- * Convenience function to configure an abitrary orthogonal projection matrix
- */
-void
-piglit_gen_ortho_projection(double left, double right, double bottom,
-   double top, double near_val, double far_val,
-   GLboolean push)
-{
-glMatrixMode(GL_PROJECTION);
-glLoadIdentity();
-   if (push)
-   glPushMatrix();
-glOrtho(left, right, bottom, top, near_val, far_val);
-
-glMatrixMode(GL_MODELVIEW);
-   if (push)
-   glPushMatrix();
-glLoadIdentity();
-}
-
-
-/**
- * Convenience function to configure projection matrix for window coordinates
- */
-void
-piglit_ortho_projection(int w, int h, GLboolean push)
-{
-/* Set up projection matrix so we can just draw using window
- * coordinates.
- */
-   piglit_gen_ortho_projection(0, w, 0, h, -1, 1, push);
-}
-
-/**
- * Convenience function to configure frustum projection.
- */
-void
-piglit_frustum_projection(GLboolean push, double l, double r, double b,
- double t, double n, double f)
-{
-   glMatrixMode(GL_PROJECTION);
-   glLoadIdentity();
-   if (push)
-   glPushMatrix();
-   glFrustum(l, r, b, t, n, f);
-
-   glMatrixMode(GL_MODELVIEW);
-   if (push)
-   glPushMatrix();
-   glLoadIdentity();
-}
-
-
-
-/**
  * Generate a checkerboard texture
  *
  * \param texName of the texture to be used.  If \c tex is
diff --git a/tests/util/piglit-util-gles.c b/tests/util/piglit-util-gles.c
index 6789aeb..26c3fa3 100644
--- a/tests/util/piglit-util-gles.c
+++ b/tests/util/piglit-util-gles.c
@@ -386,40 +386,3 @@ piglit_checkerboard_texture(GLuint tex, unsigned level,
 
return tex;
 }
-
-#if defined(PIGLIT_USE_OPENGL_ES1)
-
-/**
- * Convenience function to configure an abitrary orthogonal projection matrix
- */
-void
-piglit_gen_ortho_projection(double left, double right, double bottom,
-   double top, double near_val, double far_val,
-   GLboolean push)
-{
-   glMatrixMode(GL_PROJECTION);
-   glLoadIdentity();
-   if (push)
-  

[Piglit] [PATCH 16/16] Move the remaining piglit-util-gl functions into piglit-util-gl-common

2014-07-03 Thread Josh Triplett
Drop the now-empty piglit-util-gl.c.

Signed-off-by: Josh Triplett 
---
 tests/util/CMakeLists.gl.txt   |   2 -
 tests/util/piglit-util-gl-common.c | 241 
 tests/util/piglit-util-gl.c| 277 -
 3 files changed, 241 insertions(+), 279 deletions(-)
 delete mode 100644 tests/util/piglit-util-gl.c

diff --git a/tests/util/CMakeLists.gl.txt b/tests/util/CMakeLists.gl.txt
index 67833c9..df32c9c 100644
--- a/tests/util/CMakeLists.gl.txt
+++ b/tests/util/CMakeLists.gl.txt
@@ -3,7 +3,6 @@ set(UTIL_GL_SOURCES
piglit-matrix.c
piglit-shader.c
piglit-shader-gl.c
-   piglit-util-gl.c
piglit-test-pattern.cpp
piglit-fbo.cpp
piglit-vbo.cpp
@@ -31,7 +30,6 @@ IF(PIGLIT_BUILD_GLX_TESTS)
piglit-shader.c
piglit-shader-gl.c
piglit-util-gl-common.c
-   piglit-util-gl.c
piglit-glx-framework.c
piglit-glx-util.c
piglit-dispatch.c
diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 94e0816..024bea2 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -2275,3 +2275,244 @@ piglit_rgbw_texture(GLenum internalFormat, int w, int 
h, GLboolean mip,
 
return tex;
 }
+
+/**
+ * Create a depth texture.  The depth texture will be a gradient which varies
+ * from 0.0 at the left side to 1.0 at the right side.  For a 2D array texture,
+ * all the texture layers will have the same gradient.
+ *
+ * \param target  either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_1D_ARRAY,
+ *GL_TEXTURE_2D_ARRAY or GL_TEXTURE_RECTANGLE.
+ * \param internalformat  either GL_DEPTH_STENCIL, GL_DEPTH_COMPONENT,
+ *GL_DEPTH24_STENCIL8_EXT or GL_DEPTH32F_STENCIL8.
+ * \param w, h, d  level 0 image width, height and depth
+ * \param mip  if true, create a full mipmap.  Else, create single-level 
texture.
+ * \return the new texture object id
+ */
+GLuint
+piglit_depth_texture(GLenum target, GLenum internalformat, int w, int h, int 
d, GLboolean mip)
+{
+   void *data;
+   float *f = NULL, *f2 = NULL;
+   unsigned int  *i = NULL;
+   int size, x, y, level, layer;
+   GLuint tex;
+   GLenum type, format;
+
+   glGenTextures(1, &tex);
+   glBindTexture(target, tex);
+   glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   if (mip) {
+   glTexParameteri(target, GL_TEXTURE_MAG_FILTER,
+   GL_LINEAR);
+   glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
+   GL_LINEAR_MIPMAP_NEAREST);
+   } else {
+   glTexParameteri(target, GL_TEXTURE_MAG_FILTER,
+   GL_NEAREST);
+   glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
+   GL_NEAREST);
+   }
+   data = malloc(w * h * 4 * sizeof(GLfloat));
+
+   if (internalformat == GL_DEPTH_STENCIL_EXT ||
+   internalformat == GL_DEPTH24_STENCIL8_EXT) {
+   format = GL_DEPTH_STENCIL_EXT;
+   type = GL_UNSIGNED_INT_24_8_EXT;
+   i = data;
+   } else if (internalformat == GL_DEPTH32F_STENCIL8) {
+   format = GL_DEPTH_STENCIL;
+   type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+   f2 = data;
+   } else {
+   format = GL_DEPTH_COMPONENT;
+   type = GL_FLOAT;
+   f = data;
+   }
+
+   for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) {
+   for (y = 0; y < h; y++) {
+   for (x = 0; x < w; x++) {
+   float val = (float)(x) / (w - 1);
+   if (f)
+   f[y * w + x] = val;
+   else if (f2)
+   f2[(y * w + x)*2] = val;
+   else
+   i[y * w + x] = 0xff00 * val;
+   }
+   }
+
+   switch (target) {
+   case GL_TEXTURE_1D:
+   glTexImage1D(target, level,
+internalformat,
+w, 0,
+format, type, data);
+   break;
+
+   case GL_TEXTURE_1D_ARRAY:
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_RECTANGLE:
+   glTexImage2D(target, level,
+internalformat,
+w, h, 0,
+format, type, data);
+   break;
+
+   case GL_TEXT

[Piglit] [PATCH 12/16] Unify piglit_checkerboard_texture between GL and GLES

2014-07-03 Thread Josh Triplett
In the GLES implementation, factor out the conversion of the white and
black pixel values from float to ubyte outside the loop.  That then
unifies the loop between the two implementations.

Update the documentation to note that piglit_checkerboard_texture sets
GL_CLAMP_TO_EDGE on GLES, not GL_CLAMP_TO_BORDER as it does on GL.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 110 +
 tests/util/piglit-util-gl.c|  83 
 tests/util/piglit-util-gles.c  |  87 -
 3 files changed, 110 insertions(+), 170 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index f84fd2c..bd61e35 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1917,3 +1917,113 @@ piglit_draw_triangle_z(float z, float x1, float y1, 
float x2, float y2,
 
glDisableClientState(GL_VERTEX_ARRAY);
 }
+
+/**
+ * Generate a checkerboard texture
+ *
+ * \param texName of the texture to be used.  If \c tex is
+ *   zero, a new texture name will be generated.
+ * \param level  Mipmap level the checkerboard should be written to
+ * \param width  Width of the texture image
+ * \param height Height of the texture image
+ * \param horiz_square_size  Size of each checkerboard tile along the X axis
+ * \param vert_square_size   Size of each checkerboard tile along the Y axis
+ * \param black  RGBA color to be used for "black" tiles
+ * \param white  RGBA color to be used for "white" tiles
+ *
+ * A texture with alternating black and white squares in a checkerboard
+ * pattern is generated.  The texture data is written to LOD \c level of
+ * the texture \c tex.
+ *
+ * If \c tex is zero, a new texture created.  This texture will have several
+ * texture parameters set to non-default values:
+ *
+ *  - Min and mag filter will be set to \c GL_NEAREST.
+ *  - For GL:
+ *- S and T wrap modes will be set to \c GL_CLAMP_TO_BORDER.
+ *- Border color will be set to { 1.0, 0.0, 0.0, 1.0 }.
+ *  - For GLES:
+ *- S and T wrap modes will be set to \c GL_CLAMP_TO_EDGE.
+ *
+ * \return
+ * Name of the texture.  In addition, this texture will be bound to the
+ * \c GL_TEXTURE_2D target of the currently active texture unit.
+ */
+GLuint
+piglit_checkerboard_texture(GLuint tex, unsigned level,
+   unsigned width, unsigned height,
+   unsigned horiz_square_size,
+   unsigned vert_square_size,
+   const float *black, const float *white)
+{
+   static const GLfloat border_color[4] = { 1.0, 0.0, 0.0, 1.0 };
+   unsigned i;
+   unsigned j;
+   void *tex_data;
+   char *texel;
+   unsigned pixel_size;
+   GLubyte black_b[4], white_b[4];
+   const void *black_data, *white_data;
+
+   if (piglit_is_gles()) {
+   pixel_size = 4 * sizeof(GLubyte);
+   for (i = 0; i < 4; i++) {
+   black_b[i] = black[i] * 255;
+   white_b[i] = white[i] * 255;
+   }
+   black_data = black_b;
+   white_data = white_b;
+   } else {
+   pixel_size = 4 * sizeof(float);
+   black_data = black;
+   white_data = white;
+   }
+   texel = tex_data = malloc(width * height * pixel_size);
+
+   for (i = 0; i < height; i++) {
+   const unsigned row = i / vert_square_size;
+
+   for (j = 0; j < width; j++) {
+   const unsigned col = j / horiz_square_size;
+
+   if ((row ^ col) & 1) {
+   memcpy(texel, white_data, pixel_size);
+   } else {
+   memcpy(texel, black_data, pixel_size);
+   }
+
+   texel += pixel_size;
+   }
+   }
+
+   if (tex == 0) {
+   glGenTextures(1, &tex);
+
+   glBindTexture(GL_TEXTURE_2D, tex);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+   GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+   GL_NEAREST);
+   if (piglit_is_gles()) {
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+   GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+   GL_CLAMP_TO_EDGE);
+   } else {
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+   GL_CLAMP_TO_BORDER);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+  

[Piglit] [PATCH 02/16] Unify piglit_num_components between GL and GLES

2014-07-03 Thread Josh Triplett
The unified implementation handles all the GLenum values expected by
either.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 26 ++
 tests/util/piglit-util-gl.c| 26 --
 tests/util/piglit-util-gles.c  | 21 -
 3 files changed, 26 insertions(+), 47 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 609f6a9..f4b2192 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -807,3 +807,29 @@ piglit_draw_rect_tex(float x, float y, float w, float h,
 
piglit_draw_rect_from_arrays(verts, tex);
 }
+
+unsigned
+piglit_num_components(GLenum base_format)
+{
+   switch (base_format) {
+   case GL_ALPHA:
+   case GL_DEPTH_COMPONENT:
+   case GL_INTENSITY:
+   case GL_LUMINANCE:
+   case GL_RED:
+   return 1;
+   case GL_DEPTH_STENCIL:
+   case GL_LUMINANCE_ALPHA:
+   case GL_RG:
+   return 2;
+   case GL_RGB:
+   return 3;
+   case GL_RGBA:
+   return 4;
+   default:
+   printf("Unknown num_components for %s\n",
+  piglit_get_gl_enum_name(base_format));
+   piglit_report_result(PIGLIT_FAIL);
+   return 0;
+   }
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index f6cc72c..ac3489d 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -38,32 +38,6 @@
 
 GLint piglit_ARBfp_pass_through = 0;
 
-unsigned
-piglit_num_components(GLenum base_format)
-{
-   switch (base_format) {
-   case GL_ALPHA:
-   case GL_DEPTH_COMPONENT:
-   case GL_INTENSITY:
-   case GL_LUMINANCE:
-   case GL_RED:
-   return 1;
-   case GL_DEPTH_STENCIL:
-   case GL_LUMINANCE_ALPHA:
-   case GL_RG:
-   return 2;
-   case GL_RGB:
-   return 3;
-   case GL_RGBA:
-   return 4;
-   default:
-   printf("Unknown num_components for %s\n",
-  piglit_get_gl_enum_name(base_format));
-   piglit_report_result(PIGLIT_FAIL);
-   return 0;
-   }
-}
-
 /* This function only handles formats not supported by the OpenGL framebuffer
  * size queries, which only support querying the R,G,B,A sizes.
  *
diff --git a/tests/util/piglit-util-gles.c b/tests/util/piglit-util-gles.c
index c29feac..6789aeb 100644
--- a/tests/util/piglit-util-gles.c
+++ b/tests/util/piglit-util-gles.c
@@ -170,27 +170,6 @@ print_pixel(const GLubyte *pixel, unsigned components)
printf(" %u", pixel[p]);
 }
 
-unsigned
-piglit_num_components(GLenum base_format)
-{
-   switch (base_format) {
-   case GL_ALPHA:
-   case GL_LUMINANCE:
-   return 1;
-   case GL_LUMINANCE_ALPHA:
-   return 2;
-   case GL_RGB:
-   return 3;
-   case GL_RGBA:
-   return 4;
-   default:
-   printf("Unknown num_components for %s\n",
-  piglit_get_gl_enum_name(base_format));
-   piglit_report_result(PIGLIT_FAIL);
-   return 0;
-   }
-}
-
 int
 piglit_probe_image_ubyte(int x, int y, int w, int h, GLenum format,
const GLubyte *image)
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 07/16] Unify piglit_escape_exit_key between GL and GLES

2014-07-03 Thread Josh Triplett
Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 14 ++
 tests/util/piglit-util-gl.c| 13 -
 tests/util/piglit-util-gles.c  | 12 
 3 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 9f778c5..3a31e42 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -520,6 +520,20 @@ piglit_compressed_pixel_offset(GLenum format, unsigned 
width,
return offset;
 }
 
+void
+piglit_escape_exit_key(unsigned char key, int x, int y)
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+   case 27:
+   exit(0);
+   break;
+   }
+   if (!piglit_is_gles())
+   piglit_post_redisplay();
+}
+
 /**
  * Convenience function to configure an abitrary orthogonal projection matrix
  */
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 7c3414c..df81a63 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -416,19 +416,6 @@ GLuint piglit_compile_program(GLenum target, const char* 
text)
return program;
 }
 
-void
-piglit_escape_exit_key(unsigned char key, int x, int y)
-{
-   (void) x;
-   (void) y;
-   switch (key) {
-   case 27:
-   exit(0);
-   break;
-   }
-   piglit_post_redisplay();
-}
-
 /**
  * Convenience function to draw a triangle.
  */
diff --git a/tests/util/piglit-util-gles.c b/tests/util/piglit-util-gles.c
index 7eef8e2..f6d6555 100644
--- a/tests/util/piglit-util-gles.c
+++ b/tests/util/piglit-util-gles.c
@@ -35,18 +35,6 @@
 
 #include "piglit-util-gl-common.h"
 
-void
-piglit_escape_exit_key(unsigned char key, int x, int y)
-{
-   (void) x;
-   (void) y;
-   switch (key) {
-   case 27:
-   exit(0);
-   break;
-   }
-}
-
 /**
  * Generates a texture with the given internalFormat, w, h with a
  * teximage of r, g, b w quadrants.
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 14/16] Factor out image generation from GLES piglit_rgbw_texture into a helper

2014-07-03 Thread Josh Triplett
This moves the GLES implementation of piglit_rgbw_texture much closer to
the GL version.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gles.c | 82 ---
 1 file changed, 45 insertions(+), 37 deletions(-)

diff --git a/tests/util/piglit-util-gles.c b/tests/util/piglit-util-gles.c
index 29e8c4d..e4b3ec4 100644
--- a/tests/util/piglit-util-gles.c
+++ b/tests/util/piglit-util-gles.c
@@ -35,6 +35,46 @@
 
 #include "piglit-util-gl-common.h"
 
+static GLubyte *
+piglit_rgbw_image_ubyte(int w, int h, GLboolean alpha)
+{
+   GLubyte red[4]   = {255, 0, 0, 0};
+   GLubyte green[4] = {0, 255, 0, 64};
+   GLubyte blue[4]  = {0, 0, 255, 128};
+   GLubyte white[4] = {255, 255, 255, 255};
+   GLubyte *data;
+   int x, y;
+
+   if (!alpha) {
+   red[3] = 255;
+   green[3] = 255;
+   blue[3] = 255;
+   white[3] = 255;
+   }
+
+   data = malloc(w * h * 4 * sizeof(GLubyte));
+
+   for (y = 0; y < h; y++) {
+   for (x = 0; x < w; x++) {
+   const GLubyte *color;
+
+   if (x < w / 2 && y < h / 2)
+   color = red;
+   else if (y < h / 2)
+   color = green;
+   else if (x < w / 2)
+   color = blue;
+   else
+   color = white;
+
+   memcpy(data + (y * w + x) * 4, color,
+  4 * sizeof(GLubyte));
+   }
+   }
+
+   return data;
+}
+
 /**
  * Generates a texture with the given internalFormat, w, h with a
  * teximage of r, g, b w quadrants.
@@ -47,20 +87,8 @@ GLuint
 piglit_rgbw_texture(GLenum format, int w, int h, GLboolean mip,
GLboolean alpha, GLenum basetype)
 {
-   GLubyte *data;
-   int size, x, y, level;
+   int size, level;
GLuint tex;
-   GLubyte red[4]   = {255, 0, 0, 0};
-   GLubyte green[4] = {0, 255, 0, 64};
-   GLubyte blue[4]  = {0, 0, 255, 128};
-   GLubyte white[4] = {255, 255, 255, 255};
-
-   if (!alpha) {
-   red[3] = 255;
-   green[3] = 255;
-   blue[3] = 255;
-   white[3] = 255;
-   }
 
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
@@ -77,33 +105,14 @@ piglit_rgbw_texture(GLenum format, int w, int h, GLboolean 
mip,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
}
-   data = malloc(w * h * 4 * sizeof(GLubyte));
-
-   /* XXX: Do we want non-square textures?  Surely some day. */
-   assert(w == h);
-
-   for (level = 0, size = w; size > 0; level++, size >>= 1) {
-   for (y = 0; y < size; y++) {
-   for (x = 0; x < size; x++) {
-   const GLubyte *color;
 
-   if (x < size / 2 && y < size / 2)
-   color = red;
-   else if (y < size / 2)
-   color = green;
-   else if (x < size / 2)
-   color = blue;
-   else
-   color = white;
-
-   memcpy(data + (y * size + x) * 4, color,
-  4 * sizeof(GLubyte));
-   }
-   }
+   for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) {
+   GLubyte *data = piglit_rgbw_image_ubyte(w, h, alpha);
glTexImage2D(GL_TEXTURE_2D, level,
 format,
-size, size, 0,
+w, h, 0,
 GL_RGBA, GL_UNSIGNED_BYTE, data);
+   free(data);
 
if (!mip)
break;
@@ -113,6 +122,5 @@ piglit_rgbw_texture(GLenum format, int w, int h, GLboolean 
mip,
if (h > 1)
h >>= 1;
}
-   free(data);
return tex;
 }
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 00/16] Unify piglit-util-{gl, gles}.c into piglit-util-gl-common.c

2014-07-03 Thread Josh Triplett
This patch series unifies both the GL and GLES utility functions into a single
set of functions in piglit-util-gl-common.c, in preparation for unifying the
libraries themselves.

I've confirmed (on an IVB test system) that this causes zero piglit
regressions.

This supersedes the 4-patch series I sent yesterday.

Josh Triplett (16):
  Fix piglit_is_gles to return true for "OpenGL ES-CM 1.1 ..."
  Unify piglit_num_components between GL and GLES
  Move piglit_get_luminance_intensity_bits to GL common code
  Unify projection utility functions across GL and GLES
  Unify piglit_probe_pixel_* and piglit_probe_rect_* between GL and GLES
  Unify piglit_probe_image_* functions between GL and GLES
  Unify piglit_escape_exit_key between GL and GLES
  Move piglit_probe_texel_* functions to GL common code
  Move remaining piglit_probe_* functions to GL common code
  Move piglit program helper functions to GL common code
  Move piglit_draw_triangle* helper functions to GL common code
  Unify piglit_checkerboard_texture between GL and GLES
  Move piglit_miptree_texture to GL common code
  Factor out image generation from GLES piglit_rgbw_texture into a
helper
  Unify piglit_rgbw_texture between GL and GLES; drop piglit-util-gles.c
  Move the remaining piglit-util-gl functions into piglit-util-gl-common

 tests/util/CMakeLists.gl.txt   |2 -
 tests/util/CMakeLists.gles1.txt|5 -
 tests/util/CMakeLists.gles2.txt|1 -
 tests/util/CMakeLists.gles3.txt|1 -
 tests/util/piglit-util-gl-common.c | 1711 +++-
 tests/util/piglit-util-gl.c| 1605 -
 tests/util/piglit-util-gles.c  |  446 --
 7 files changed, 1710 insertions(+), 2061 deletions(-)
 delete mode 100644 tests/util/piglit-util-gl.c
 delete mode 100644 tests/util/piglit-util-gles.c

-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 03/16] Move piglit_get_luminance_intensity_bits to GL common code

2014-07-03 Thread Josh Triplett
This doesn't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett 
---
 tests/util/piglit-util-gl-common.c | 102 +
 tests/util/piglit-util-gl.c| 102 -
 2 files changed, 102 insertions(+), 102 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index f4b2192..a0be726 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -833,3 +833,105 @@ piglit_num_components(GLenum base_format)
return 0;
}
 }
+
+/* This function only handles formats not supported by the OpenGL framebuffer
+ * size queries, which only support querying the R,G,B,A sizes.
+ *
+ * The function doesn't change the bits for formats it doesn't handle.
+ *
+ * The returned number of bits is an approximation but should be no less than
+ * the actual number of bits for the format chosen by OpenGL.
+ *
+ * The combination of the OpenGL framebuffer queries size and calling
+ * this function without checking the return value should give you reasonable
+ * values for any format.
+ */
+bool
+piglit_get_luminance_intensity_bits(GLenum internalformat, int *bits)
+{
+   switch (internalformat) {
+   case GL_LUMINANCE4:
+   bits[0] = bits[1] = bits[2] = 4;
+   bits[3] = 0;
+   return true;
+
+   case GL_LUMINANCE:
+   case GL_LUMINANCE_SNORM:
+   case GL_LUMINANCE8:
+   case GL_LUMINANCE8_SNORM:
+   case GL_LUMINANCE8I_EXT:
+   case GL_LUMINANCE8UI_EXT:
+   bits[0] = bits[1] = bits[2] = 8;
+   bits[3] = 0;
+   return true;
+
+   case GL_LUMINANCE12:
+   bits[0] = bits[1] = bits[2] = 12;
+   bits[3] = 0;
+   return true;
+
+   case GL_LUMINANCE16:
+   case GL_LUMINANCE16_SNORM:
+   case GL_LUMINANCE16I_EXT:
+   case GL_LUMINANCE16UI_EXT:
+   case GL_LUMINANCE16F_ARB:
+   bits[0] = bits[1] = bits[2] = 16;
+   bits[3] = 0;
+   return true;
+
+   case GL_LUMINANCE32I_EXT:
+   case GL_LUMINANCE32UI_EXT:
+   case GL_LUMINANCE32F_ARB:
+   bits[0] = bits[1] = bits[2] = 32;
+   bits[3] = 0;
+   return true;
+
+   case GL_LUMINANCE4_ALPHA4:
+   case GL_INTENSITY4:
+   bits[0] = bits[1] = bits[2] = bits[3] = 4;
+   return true;
+
+   case GL_LUMINANCE_ALPHA:
+   case GL_LUMINANCE_ALPHA_SNORM:
+   case GL_LUMINANCE8_ALPHA8:
+   case GL_LUMINANCE8_ALPHA8_SNORM:
+   case GL_LUMINANCE_ALPHA8I_EXT:
+   case GL_LUMINANCE_ALPHA8UI_EXT:
+   case GL_INTENSITY:
+   case GL_INTENSITY_SNORM:
+   case GL_INTENSITY8:
+   case GL_INTENSITY8_SNORM:
+   case GL_INTENSITY8I_EXT:
+   case GL_INTENSITY8UI_EXT:
+   bits[0] = bits[1] = bits[2] = bits[3] = 8;
+   return true;
+
+   case GL_LUMINANCE12_ALPHA12:
+   case GL_INTENSITY12:
+   bits[0] = bits[1] = bits[2] = bits[3] = 12;
+   return true;
+
+   case GL_LUMINANCE16_ALPHA16:
+   case GL_LUMINANCE16_ALPHA16_SNORM:
+   case GL_LUMINANCE_ALPHA16I_EXT:
+   case GL_LUMINANCE_ALPHA16UI_EXT:
+   case GL_LUMINANCE_ALPHA16F_ARB:
+   case GL_INTENSITY16:
+   case GL_INTENSITY16_SNORM:
+   case GL_INTENSITY16I_EXT:
+   case GL_INTENSITY16UI_EXT:
+   case GL_INTENSITY16F_ARB:
+   bits[0] = bits[1] = bits[2] = bits[3] = 16;
+   return true;
+
+   case GL_LUMINANCE_ALPHA32I_EXT:
+   case GL_LUMINANCE_ALPHA32UI_EXT:
+   case GL_LUMINANCE_ALPHA32F_ARB:
+   case GL_INTENSITY32I_EXT:
+   case GL_INTENSITY32UI_EXT:
+   case GL_INTENSITY32F_ARB:
+   bits[0] = bits[1] = bits[2] = bits[3] = 32;
+   return true;
+   }
+   return false;
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index ac3489d..773e09f 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -38,108 +38,6 @@
 
 GLint piglit_ARBfp_pass_through = 0;
 
-/* This function only handles formats not supported by the OpenGL framebuffer
- * size queries, which only support querying the R,G,B,A sizes.
- *
- * The function doesn't change the bits for formats it doesn't handle.
- *
- * The returned number of bits is an approximation but should be no less than
- * the actual number of bits for the format chosen by OpenGL.
- *
- * The combination of the OpenGL framebuffer queries size and calling
- * this function without checking the return value should give you reasonable
- * values for any format.
- */
-bool
-piglit_get_luminance_intensity_bits(GLenum internalformat, int *bits)
-{
-   switch (internalformat) {
-   case GL_LUMINANCE4:
-   bits[0] = bits[1] = bits[2] = 4;
-   bits[3] = 0;
-   return tru

Re: [Piglit] [PATCH 2/2] arb_provoking_vertex/xfb-before-flatshading: use default window size

2014-07-03 Thread Charmaine Lee
Reviewed-by: Charmaine Lee 

From: Piglit  on behalf of Brian Paul 

Sent: Thursday, July 3, 2014 10:41 AM
To: piglit@lists.freedesktop.org
Subject: [Piglit] [PATCH 2/2] arb_provoking_vertex/xfb-before-flatshading:  
use default window size

---
 tests/spec/arb_provoking_vertex/xfb-before-flatshading.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c 
b/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
index 67cc581..6d168ea 100644
--- a/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
+++ b/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
@@ -40,8 +40,6 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 32;
 config.supports_gl_core_version = 32;

-   config.window_width = 100;
-   config.window_height = 100;
config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;

 PIGLIT_GL_TEST_CONFIG_END
--
1.7.10.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/piglit&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=iVNYIcCaC9TDvyNBQU%2F5q5NVsC01tSgJb3oX27T14ck%3D%0A&m=AOPJ5rlYmUW3z%2BoPP6k1Iavi6h20Rh4GM%2BXEnugnnhU%3D%0A&s=24aeec83ec2e4a9e812d6aede16bb71cfc071c27f120756154752a8cee7d3c63
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 2/2] arb_provoking_vertex/xfb-before-flatshading: use default window size

2014-07-03 Thread Brian Paul
---
 tests/spec/arb_provoking_vertex/xfb-before-flatshading.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c 
b/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
index 67cc581..6d168ea 100644
--- a/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
+++ b/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
@@ -40,8 +40,6 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 32;
 config.supports_gl_core_version = 32;
 
-   config.window_width = 100;
-   config.window_height = 100;
config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
-- 
1.7.10.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cl-api-get-platform-ids: Initialize variable.

2014-07-03 Thread Tom Stellard
On Tue, Jul 01, 2014 at 10:38:56PM -0700, Vinson Lee wrote:
> Fix clang sometimes-uninitialized warning.
> 
> get-platform-ids.c:62:5: warning: variable 'platforms' is used uninitialized 
> whenever 'if' condition is true [-Wsometimes-uninitialized]
> if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
>^
> get-platform-ids.c:93:30: note: uninitialized use occurs here
> errNo = clGetPlatformIDs(0, platforms, NULL);
> ^
> get-platform-ids.c:62:2: note: remove the 'if' if its condition is always 
> false
> if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
> ^~~
> get-platform-ids.c:56:27: note: initialize the variable 'platforms' to 
> silence this warning
> cl_platform_id* platforms;
>  ^
>   = NULL
> 
Reviewed-by: Tom Stellard 
> Signed-off-by: Vinson Lee 
> ---
>  tests/cl/api/get-platform-ids.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/cl/api/get-platform-ids.c b/tests/cl/api/get-platform-ids.c
> index 6cc734a..f94ab0c 100644
> --- a/tests/cl/api/get-platform-ids.c
> +++ b/tests/cl/api/get-platform-ids.c
> @@ -53,7 +53,7 @@ piglit_cl_test(const int argc,
>   int i;
>   cl_int errNo;
>   cl_uint num_platforms;
> - cl_platform_id* platforms;
> + cl_platform_id* platforms = NULL;
>  
>   /*** Normal usage ***/
>  
> -- 
> 1.9.2
> 
> ___
> Piglit mailing list
> Piglit@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/2] arb_blend_func_extended: require GL 3.0

2014-07-03 Thread Brian Paul
Since the test shaders require GLSL 1.30
---
 .../arb_blend_func_extended/execution/fbo-extended-blend-explicit.c  |2 +-
 tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c|2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c 
b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
index 1605961..abc4675 100644
--- a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
+++ b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
@@ -39,7 +39,7 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
-   config.supports_gl_compat_version = 10;
+   config.supports_gl_compat_version = 30;
config.window_visual = PIGLIT_GL_VISUAL_RGB;
 
 PIGLIT_GL_TEST_CONFIG_END
diff --git a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c 
b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
index 8cf16ed..d4e976a 100644
--- a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
+++ b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
@@ -39,7 +39,7 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
-   config.supports_gl_compat_version = 10;
+   config.supports_gl_compat_version = 30;
config.window_visual = PIGLIT_GL_VISUAL_RGB;
 
 PIGLIT_GL_TEST_CONFIG_END
-- 
1.7.10.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit