mesa.git
10 years agodraw: fix prim id float cast for non-llvm path
Roland Scheidegger [Thu, 7 Aug 2014 16:37:42 +0000 (18:37 +0200)]
draw: fix prim id float cast for non-llvm path

These values are always uints, casting them to floats does no good.
Fixes piglit glsl-1.50-geometry-primitive-id-restart tests for softpipe.

Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agoclover: Add support for CL_MAP_WRITE_INVALIDATE_REGION
Bruno Jiménez [Thu, 7 Aug 2014 14:34:53 +0000 (16:34 +0200)]
clover: Add support for CL_MAP_WRITE_INVALIDATE_REGION

OpenCL 1.2 CL_MAP_WRITE_INVALIDATE_REGION sounds a lot like
PIPE_TRANSFER_DISCARD_RANGE:

From OpenCL 1.2 spec:
    The contents of the region being mapped are to be discarded.

From p_defines.h:
    Discards the memory within the mapped region.

v2: Move the code for validating flags to the front-end as
    suggested by Francisco Jerez

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
10 years agoilo: break down the format table
Chia-I Wu [Fri, 8 Aug 2014 06:52:15 +0000 (14:52 +0800)]
ilo: break down the format table

The PRMs no longer have a single table for format capabilities.  Multiple
tables take up less space, and are easier to maintain.

Encode typed write information while at it.

10 years agoi965: Emit a performance warning on conditional rendering.
Kenneth Graunke [Mon, 4 Aug 2014 06:54:22 +0000 (23:54 -0700)]
i965: Emit a performance warning on conditional rendering.

We have a CPU-side implementation of conditional rendering; it really
should be done on the GPU.  It's not necessarily that hard, but nobody
has gotten to fixing it yet.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
10 years agoi965: Set ExecSize to 16 for loop instructions in SIMD16 shaders.
Kenneth Graunke [Mon, 4 Aug 2014 07:06:05 +0000 (00:06 -0700)]
i965: Set ExecSize to 16 for loop instructions in SIMD16 shaders.

Previously, we explicitly set the execution size to BRW_EXECUTE_8 and
disabled compression for loop instructions.  I can't imagine how this
could be correct in SIMD16 mode.

Looking at the history, it appears that this code has used BRW_EXECUTE_8
since 2007, when we had a SIMD8 backend that supported control flow and
a separate SIMD16 backend that didn't.  Presumably, when we added SIMD16
support for shaders with control flow, we simply neglected to update it.

Note that Gen4-5 don't support SIMD16 on shaders with control flow.

This might be a candidate for stable, but would need to be rewritten
completely due to the brw_inst API changes in master.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agoi965/eu: Merge brw_CONT and gen6_CONT.
Kenneth Graunke [Mon, 4 Aug 2014 21:26:26 +0000 (14:26 -0700)]
i965/eu: Merge brw_CONT and gen6_CONT.

The only difference is setting PopCount on Gen4-5.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agoi965/eu: Drop redundant brw_set_src0/brw_set_dest from gen6_CONT.
Kenneth Graunke [Mon, 4 Aug 2014 21:07:27 +0000 (14:07 -0700)]
i965/eu: Drop redundant brw_set_src0/brw_set_dest from gen6_CONT.

We shouldn't need to set them, then set them differently.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agoutil: add src/util/format_srgb.c to .gitignore
Juha-Pekka Heikkila [Thu, 7 Aug 2014 12:58:26 +0000 (15:58 +0300)]
util: add src/util/format_srgb.c to .gitignore

format_srgb.c is generated by format_srgb.py python script, having
format_srgb.c in git ignore list will silence git complaints about
untracked file.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
10 years agomesa: Fold _mesa_uniform_merge_location_offset into its only caller
Ian Romanick [Sat, 2 Aug 2014 01:53:09 +0000 (18:53 -0700)]
mesa: Fold _mesa_uniform_merge_location_offset into its only caller

Also delete the comment before that function.  Everything in that
comment was either stale, wrong, or captured elsewhere.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agomesa: Fold _mesa_uniform_split_location_offset into its only caller
Ian Romanick [Sat, 2 Aug 2014 01:51:30 +0000 (18:51 -0700)]
mesa: Fold _mesa_uniform_split_location_offset into its only caller

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoglsl_to_tgsi: Delete unused function set_uniform_initializer
Ian Romanick [Sat, 2 Aug 2014 01:50:07 +0000 (18:50 -0700)]
glsl_to_tgsi: Delete unused function set_uniform_initializer

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agomesa: Use MAX2 to calculate maximum uniform element
Ian Romanick [Sat, 2 Aug 2014 01:39:21 +0000 (18:39 -0700)]
mesa: Use MAX2 to calculate maximum uniform element

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agomesa: Have validate_uniform_parameters return the gl_uniform_storage pointer
Ian Romanick [Sat, 2 Aug 2014 01:37:58 +0000 (18:37 -0700)]
mesa: Have validate_uniform_parameters return the gl_uniform_storage pointer

This simplifies all the callers, and it enables the removal of one of
the function parameters.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoglsl/glcpp: Rename one test to avoid a duplicate test number
Carl Worth [Mon, 28 Jul 2014 19:26:06 +0000 (12:26 -0700)]
glsl/glcpp: Rename one test to avoid a duplicate test number

With two tests both numbered 118, there was a confusing off-by-two difference
between the last test number and the total number of tests (as reported by
glcpp-test).

With this rename, there's only an off-by-one difference left, (which is easy
to understand given the zero-based test numbering).

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Fix handling of commas that result from macro expansion
Carl Worth [Thu, 3 Jul 2014 21:16:07 +0000 (14:16 -0700)]
glsl/glcpp: Fix handling of commas that result from macro expansion

Here is some additional stress testing of nested macros where the expansion
of macros involves commas, (and whether those commas are interpreted as
argument separators or not in subsequent function-like macro calls).

Credit to the GCC documentation that directed my attention toward this issue:

https://gcc.gnu.org/onlinedocs/gcc-3.2/cpp/Argument-Prescan.html

Fixing the bug required only removing code from glcpp. When first testing the
details of expansions involving commas, I had come to the mistaken conclusion
that an expanded comma should never be treated as an argument separator, (so
had introduced the rather ugly COMMA_FINAL token to represent this).

In fact, an expanded comma should be treated as a separator, (as tested here),
and this treatment can be avoided by judicious use of parentheses (as also
tested here).

With this simple removal of the COMMA_FINAL token, the behavior of glcpp
matches that of gcc's preprocessor for all of these hairy cases.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Integrate recent glcpp-test-cr-lf test into "make check"
Carl Worth [Thu, 3 Jul 2014 20:25:47 +0000 (13:25 -0700)]
glsl/glcpp: Integrate recent glcpp-test-cr-lf test into "make check"

Beyond just listing this in the TESTS variable in Makefile.am, only minor
changes were needed to make this work. The primary issue is that the build
system runs the test script from a different directory than the script
itself. So we have to use the $srcdir variable to find the test input files.

Using $srcdir in this way also ensures that this test works when using an
out-of-tree build.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Fix glcpp-test to correctly extract test-specific arguments
Carl Worth [Thu, 3 Jul 2014 05:58:57 +0000 (22:58 -0700)]
glsl/glcpp: Fix glcpp-test to correctly extract test-specific arguments

The (optional) test-specific command-line arguments to be passed to glcpp are
embedded within the source files of some tests, and glcpp-test uses grep to
extract them.

Of course, grep is line-based and looks for the native line-separator to
determine line boundaries. So, for files using non-native line separators,
grep was getting quite confused and passing bogus arguments to glcpp.

Fix this by canonical-izing the line separators in the source file prior to
using grep.

With this commit, the glcpp-test-cr-lf tests pass entirely:

\r: 143/143 tests pass
\r\n: 143/143 tests pass
\n\r: 143/143 tests pass

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Fix line-continuation code to handle multiple newline flavors
Carl Worth [Thu, 3 Jul 2014 05:49:58 +0000 (22:49 -0700)]
glsl/glcpp: Fix line-continuation code to handle multiple newline flavors

Sometimes the newline separator is a single character, and sometimes it is two
characters. Before we can fold away and line-continuation backslashes, we
identify the flavor of line separator that is in use.

With this identified, we then correctly search for backslashes followed
immediately by the first character of the line separator.

Also, when re-inserting newlines to replace collapsed newlines, we carefully
insert newlines of the same flavor.

With this commit, almost all remaining test are fixed as tested by
glcpp-test-cr-lf:

\r: 142/143 tests pass
\r\n: 142/143 tests pass
\n\r: 143/143 tests pass

(The only remaining failures have nothing to do with the actual pre-processor
code, but are due to a bug in the way the test suite uses grep to try to
extract test-specific command-line options from the source files.)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Don't include any newline characters in #error token
Carl Worth [Thu, 3 Jul 2014 05:20:43 +0000 (22:20 -0700)]
glsl/glcpp: Don't include any newline characters in #error token

Some tests were failing because the message printed by #error was including a
'\r' character from the source file in its output.

This is easily avoided by fixing the regular expression for #error to never
include any of the possible newline characters, (neither '\r' nor '\n').

With this commit 2 tests are fixed for each of the '\r' and '\r\n' cases.

Current results after the commit are:

\r: 137/143 tests pass
\r\n 142/143 tests pass
\n\r: 139/143 tests pass

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Treat CR+LF pair as a single newline
Carl Worth [Tue, 1 Jul 2014 23:31:07 +0000 (16:31 -0700)]
glsl/glcpp: Treat CR+LF pair as a single newline

The GLSL specification says that either carriage-return, line-feed, or both
together can be used to terminate lines. Further, it says that when used
together, the pair of terminators shall be interpreted as a single line.

This final requirement has not been respected by glcpp up until now, (it has
been emitting two newlines for every CR+LF pair).

Here, we fix the lexer by using a regular expression for NEWLINE that eats
up both "\r\n" (or even "\n\r") if possible before also considering a single
'\n' or a single '\r' as a line terminator.

Before this commit, the test results are as follows:

\r: 135/143 tests pass
\r\n:   4/143 tests pass
\n\r:   4/143 tests pass

After this commit, the test results are as follows:

\r: 135/143 tests pass
\r\n: 140/143 tests pass
\n\r: 139/143 tests pass

So, obviously, a dramatic improvement.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Add test script for testing various line-termination characters
Carl Worth [Thu, 3 Jul 2014 00:14:51 +0000 (17:14 -0700)]
glsl/glcpp: Add test script for testing various line-termination characters

The GLSL specification has a very broad definition of what is a
newline. Namely, it can be the carriage-return character, '\r', the newline
character, '\n', or any combination of the two, (though in combination, the
two are treated as a single newline).

Here, we add a new test-runner, glcpp-test-cr-lf, that, for each possible
line-termination combination, runs through the existing test suite with all
source files modified to use those line-termination characters. Instead of
using the .expected files for this, this script assumes that the regular test
suite has been run already and expects the output to match the .out
files. This avoids getting 4 test failures for any one bug, and instead will
hopefully only report bugs actually related to the line-termination
characters.

The new testing is not yet integrated into "make check". For that, some
munging of the testdir option will be necessary, (to support "make check" with
out-of-tree builds). For now, the scripts can just be run directly by hand.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Fix for macros that expand to include "defined" operators
Carl Worth [Wed, 2 Jul 2014 19:52:33 +0000 (12:52 -0700)]
glsl/glcpp: Fix for macros that expand to include "defined" operators

Prior to this commit, the following snippet would trigger an error in glcpp:

#define FOO defined BAR
#if FOO
        #endif

The problem was that support for the "defined" operator was implemented within
the grammar, (where the parser was parsing the tokens of the condition
itself). But what is required is to interpret the "defined" operator that
results after macro expansion is performed.

I could not find any fix for this case by modifying the grammar alone. The
difficulty is that outside of the grammar we already have a recursive function
that performs macro expansion (_glcpp_parser_expand_token_list) and that
function itself must be augmented to be made aware of the semantics of the
"defined" operator.

The reason we can't simply handle "defined" outside of the recursive expansion
function is that not only must we scan for any "defined" operators in the
original condition (before any macro expansion occurs); but at each level of
the recursive expansion, we must again scan the list of tokens resulting from
expansion and handle "defined" before entering the next level of recursion to
further expand macros.

And of course, all of this is context dependent. The evaluation of "defined"
operators must only happen when we are handling preprocessor conditionals,
(#if and #elif) and not when performing any other expansion, (such as in the
main body).

To implement this, we add a new "mode" parameter to all of the expansion
functions to specify whether resulting DEFINED tokens should be evaluated or
ignored.

One side benefit of this change is that an ugly wart in the grammar is
removed. We previously had "conditional_token" and "conditional_tokens"
productions that were basically copies of "pp_token" and "pp_tokens" but with
added productions for the various forms of DEFINED operators. With the new
code here, those ugly copy-and-paste productions are eliminated from the
grammar.

A new "make check" test is added to stress-test the code here.

This commit fixes the following Khronos GLES3 CTS tests:

conditional_inclusion.basic_2_vertex
conditional_inclusion.basic_2_fragment

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Swallow empty #pragma directives.
Carl Worth [Wed, 2 Jul 2014 17:32:46 +0000 (10:32 -0700)]
glsl/glcpp: Swallow empty #pragma directives.

Previously, we were passing these through, just like any other pragma. But the
downstream compiler was tripping up on them. It seems easier to swallow these
in the preprocessor and not pass them on at all rather than fixing the
downstream compiler.

This fixes the following Khronos GLES3 CTS tests:

preprocessor.pragmas.pragma_vertex
preprocessor.pragmas.pragma_fragment

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Fix #pragma to not over-increment the line-number count
Carl Worth [Wed, 2 Jul 2014 17:27:50 +0000 (10:27 -0700)]
glsl/glcpp: Fix #pragma to not over-increment the line-number count

Previously, the #pragma directive was swallowing an entire line, (including
the final newline). At that time it was appropriate for it to increment the
line count.

More recently, our handling of #pragma changed to not include the newline. But
the code to increment yylineno stuck around. This was causing __LINE__ to be
increased by one more than desired for every #pragma.

Remove the bogus, extra increment, and add a test for this case.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Add testing for null directives with spaces and comments
Carl Worth [Wed, 2 Jul 2014 01:00:41 +0000 (18:00 -0700)]
glsl/glcpp: Add testing for null directives with spaces and comments

This new "make check" test stresses out the support from the last two commits,
(to esnure that '#' is correctly interpreted as the null directives,
regardless of any whitespace or comments on the same line).

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Fix NULL directives when followed by a single-line comment
Carl Worth [Wed, 2 Jul 2014 00:58:37 +0000 (17:58 -0700)]
glsl/glcpp: Fix NULL directives when followed by a single-line comment

This is the fix for the following line:

#  // comment to ignore here

According to the translation-phase rules, the comment should be removed before
the preprocessor looks to interpret the null directive.

So in our implementation we must explicitly look for single-line comments in
the <HASH> start condition as well.

This commit fixes the following Khronos GLES3 CTS tests:

null_directive_vertex
null_directive_fragment

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Add tests for #define followed by comments
Carl Worth [Wed, 2 Jul 2014 00:49:45 +0000 (17:49 -0700)]
glsl/glcpp: Add tests for #define followed by comments

This simply tests the previous commit, (that #define followed by a comment
will still generate the expected "#define without macro name" error message).

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Allow single-line comments immediately after #define
Carl Worth [Wed, 2 Jul 2014 00:47:29 +0000 (17:47 -0700)]
glsl/glcpp: Allow single-line comments immediately after #define

We were already correctly supporting single-line comments in case like:

#define FOO bar // comment here...

The new support added here is simply for the none-too-useful:

#define // comment instead of macro name

With this commit, this line will now give the expected "#define without
macro name" error message instead of the lexer just going off into the
weeds.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Add test for "#define without macro name"
Carl Worth [Wed, 2 Jul 2014 00:44:55 +0000 (17:44 -0700)]
glsl/glcpp: Add test for "#define without macro name"

This ensures that the previous commit indeed generates the expected error
message when a "#define" directive is not followed by anything except for a
newline.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl/glcpp: Add explicit error for "#define without macro name"
Carl Worth [Wed, 2 Jul 2014 00:40:28 +0000 (17:40 -0700)]
glsl/glcpp: Add explicit error for "#define without macro name"

Previously, glcpp would emit an error like this if <EOF> happened to occur
immediately after the "#define", but in general would just get confused,
(leading to un-helpful error messages).

To fix things to generate a clean error message, we do a few things:

1. Don't require horizontal whitespace immediately after #define

2. Add a production for the error case, (DEFINE_TOKEN followed
   immediately by a NEWLINE token).

3. Make the lexer reset to the <INITIAL> state after every NEWLINE.

This 3rd point prevents the lexer from getting so confused and generating
further spurious errors in the file because it was stuck in the <DEFINE> start
condition.

We also drop the similar error message from the <EOF> rule since the
newly-added rule will have already printed the error message.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agodocs: List GL+GLSL versions as parts of a whole.
Matt Turner [Thu, 7 Aug 2014 04:11:50 +0000 (21:11 -0700)]
docs: List GL+GLSL versions as parts of a whole.

Listing the GLSL version as an individual component of a GL version,
separate from the extensions isn't really right. The GLSL changes are
(almost?) entirely comprised of changes listed in the extensions.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
10 years agoi965/vec4: Remove unused emit_bool_comparison method.
Matt Turner [Thu, 7 Aug 2014 02:58:34 +0000 (19:58 -0700)]
i965/vec4: Remove unused emit_bool_comparison method.

Apparently unused since it was added in commit af3c9803.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
10 years agomesa: Drop USE_IEEE define.
Matt Turner [Wed, 6 Aug 2014 23:13:26 +0000 (16:13 -0700)]
mesa: Drop USE_IEEE define.

I think OpenVMS was the only platform that Mesa ran on that used a
non-IEEE representation for floats. We removed OpenVMS support a while
back, and this should alleviate the need to continue updating the
this-platform-uses-IEEE list.

The one bit of this patch that needs review is the IS_INF_OR_NAN,
because I'm not sure if MSVC supports isfinite.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82268
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa: Group gl_system_value values by the stage where they exist
Ian Romanick [Wed, 18 Jun 2014 22:48:36 +0000 (15:48 -0700)]
mesa: Group gl_system_value values by the stage where they exist

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
10 years agoglsl_to_tgsi: Assert that the _mesa_sysval_to_semantic mapping is correct
Ian Romanick [Wed, 18 Jun 2014 22:43:32 +0000 (15:43 -0700)]
glsl_to_tgsi: Assert that the _mesa_sysval_to_semantic mapping is correct

Future patches will rearrange the values in gl_system_value, and I want
to catch errors.  Designated initializers would make all of this
unnecessary.

v2: Don't use STATIC_ASSERT.  Not only does it not work, but GCC doesn't
tell you that it's not going to work.  Thanks for nothing!

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
10 years agomesa/st: Only one copy of mesa_sysval_to_semantic
Ian Romanick [Wed, 18 Jun 2014 22:41:44 +0000 (15:41 -0700)]
mesa/st: Only one copy of mesa_sysval_to_semantic

Future patches will necessitate changes to the table, and I only want to
update one.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
10 years agoglsl_to_tgsi: Constify mesa_sysval_to_semantic
Ian Romanick [Wed, 18 Jun 2014 22:22:25 +0000 (15:22 -0700)]
glsl_to_tgsi: Constify mesa_sysval_to_semantic

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
10 years agoi965/clip: Fix brw_clip_unfilled.c/compute_offset's assembly.
Kenneth Graunke [Wed, 6 Aug 2014 06:57:17 +0000 (23:57 -0700)]
i965/clip: Fix brw_clip_unfilled.c/compute_offset's assembly.

Due to the destination register width of 1 or 2, these instructions get
ExecSize 1 or 2.  But dir and offset (used as src0) are both registers
of width 4, violating the execsize >= width assertion.

I honestly don't think this could have ever worked.

Fixes Piglit's polygon-offset and polygon-mode-offset tests on Gen4-5.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70441
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
10 years agoglsl: support unsigned increment in ir_loop controls
Tapani Pälli [Wed, 30 Jul 2014 10:02:52 +0000 (13:02 +0300)]
glsl: support unsigned increment in ir_loop controls

Current version can create ir_expression where operands have
different base type, patch adds support for unsigned type.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
https://bugs.freedesktop.org/show_bug.cgi?id=80880

10 years agomesa/formats: Fix the size of ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
Jason Ekstrand [Wed, 6 Aug 2014 17:29:40 +0000 (10:29 -0700)]
mesa/formats: Fix the size of ETC2_SRGB8_PUNCHTHROUGH_ALPHA1

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
10 years agomesa/formats: Use the correct swizzle parameter for the 11-bit EAC formats
Jason Ekstrand [Wed, 6 Aug 2014 17:27:58 +0000 (10:27 -0700)]
mesa/formats: Use the correct swizzle parameter for the 11-bit EAC formats

Red-only formats should be x001 and RG formats should be xy01.

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
10 years agodraw: fix clipvertex trouble if position comes from gs
Roland Scheidegger [Wed, 6 Aug 2014 01:40:31 +0000 (03:40 +0200)]
draw: fix clipvertex trouble if position comes from gs

If the vertex shader has no position but the gs has, the clipvertex output
was -1 (because it's the same as vs position in this case if there's no
explicit clipvertex output). This caused crashes (or assertion failures) in
clipping since in the end position (which came from gs) was different from
cv (-1) and we then tried to use the bogus cv input.
Rather than just test for -1 cv value in clipping, make it explicitly return
the position output of the gs instead which seems cleaner (since we really
don't want to use the clipvertex value from the vs (it could be a valid value
in the (unsupported) case of vs writing clipvertex but still using a gs).
This fixes piglit shader_runner clip-distance-out-values.shader_test.

Reviewed-by: Zack Rusin <zackr@vmware.com>
10 years agodraw: don't run pipeline stages when gs has no position output
Roland Scheidegger [Tue, 5 Aug 2014 23:07:18 +0000 (01:07 +0200)]
draw: don't run pipeline stages when gs has no position output

The clip stage may crash if there's no position output, for this reason
code was added to avoid running the pipeline stages in this case
(c7c7186045ec617c53f7899280cbe12e59503e4d). However, this failed to actually
work when there was a geometry shader, since unlike the vertex shader it did
not initialize the position output to -1, hence the code trying to detect
this didn't trigger. So simply initialize the position output to -1 just like
the vs does.
This fixes piglit glsl-1.50-transform-feedback-type-and-size (segfault->pass).
clip-distance-out-values.shader_test goes from segfault to assertion failure,
suggesting more fixes are needed, no other piglit changes.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Zack Rusin <zackr@vmware.com>
10 years agodri/xmlconfig: s/uint/unsigned int/
Vinson Lee [Sun, 3 Aug 2014 20:00:32 +0000 (13:00 -0700)]
dri/xmlconfig: s/uint/unsigned int/

This patch fixes this build error on Mac OS X.

./xmlconfig.h:61:5: error: unknown type name 'uint'; did you mean 'int'?
    uint nRanges;         /**< \brief Number of ranges */
    ^~~~
    int
./xmlconfig.h:79:5: error: unknown type name 'uint'; did you mean 'int'?
    uint tableSize;
    ^~~~
    int

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa include stdint.h in formats.h
Brian Paul [Tue, 5 Aug 2014 19:07:42 +0000 (13:07 -0600)]
mesa include stdint.h in formats.h

To get uint8_t type, to fix MSVC build.
Trivial.

10 years agomesa/texstore: Add a generic rgba integer texture upload path
Jason Ekstrand [Thu, 17 Jul 2014 05:18:53 +0000 (22:18 -0700)]
mesa/texstore: Add a generic rgba integer texture upload path

Again, we delete a lot of functions that aren't really doing anything
interesting anymore.

v2: Comment the texstore_rgba_integer function

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/texstore: Add a generic float/normalized rgba texture upload path
Jason Ekstrand [Tue, 15 Jul 2014 18:02:43 +0000 (11:02 -0700)]
mesa/texstore: Add a generic float/normalized rgba texture upload path

This commit also removes a bunch of functions which aren't doing anything
more interesting than the general path does.

v2: Better comment the texstore_via_float function

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/texstore: Use _mesa_swizzle_and_convert when possible
Jason Ekstrand [Fri, 11 Jul 2014 15:55:47 +0000 (08:55 -0700)]
mesa/texstore: Use _mesa_swizzle_and_convert when possible

This should be both faster and more accurate than our general slow-path of
converting everything to float.

v2: Add a comment to top of the texstore_swizzle function

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomain/texstore: Split texture storage into three functions
Jason Ekstrand [Tue, 15 Jul 2014 19:16:03 +0000 (12:16 -0700)]
main/texstore: Split texture storage into three functions

This commit splits the texture storage into three functions:
texstore_depth_stencil, texstore_compressed, and texstore_rgba.  Right now
this split seems artificial since we just have one function pointer per
format and there is no difference between these three categories.  However,
this split makes it much easier to write a more general function upload
path for one of these categories than the current function pointers.

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/format_utils: Add a function to convert a mesa_format to an array format
Jason Ekstrand [Fri, 11 Jul 2014 15:52:12 +0000 (08:52 -0700)]
mesa/format_utils: Add a function to convert a mesa_format to an array format

This commits adds the _mesa_format_to_array function that determines if the
given format can be represented as an array format and computes the array
format parameters. This is a direct helper function for using
_mesa_swizzle_and_convert

v2: Better documentation and commit message
v3: Fixed a potential segfault from an invalid endianness swizzle

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/format_utils: Add a general format conversion function
Jason Ekstrand [Fri, 11 Jul 2014 15:41:49 +0000 (08:41 -0700)]
mesa/format_utils: Add a general format conversion function

Most format conversion operations required by GL can be performed by
converting one channel at a time, shuffling the channels around, and
optionally filling missing channels with zeros and ones.  This adds a
function to do just that in a general, yet efficient, way.

v2:
 * Add better comments including full docs for functions
 * Don't use __typeof__
 * Use inline helpers instead of writing out conversions by hand,
 * Force full loop unrolling for better performance

v3: Add another set of parens around the MAX_INT macro

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/imports: Add a _mesa_half_is_negative helper function
Jason Ekstrand [Fri, 1 Aug 2014 23:41:16 +0000 (16:41 -0700)]
mesa/imports: Add a _mesa_half_is_negative helper function

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/formats: Add layout and swizzle information
Jason Ekstrand [Fri, 11 Jul 2014 06:59:42 +0000 (23:59 -0700)]
mesa/formats: Add layout and swizzle information

v2: Move the MESA_FORMAT_SWIZZLE enum to the top of the file

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/formats: Remove IndexBits
Jason Ekstrand [Fri, 11 Jul 2014 06:58:56 +0000 (23:58 -0700)]
mesa/formats: Remove IndexBits

Mesa hasn't supported color-indexed textures for some time.  This is 0 for
all texture formats, so we don't need to store it.

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/formats: Autogenerate the format_info structure from a CSV file
Jason Ekstrand [Fri, 20 Jun 2014 22:52:10 +0000 (15:52 -0700)]
mesa/formats: Autogenerate the format_info structure from a CSV file

Instead of a having all of the format metadata in a gigantic hard-to-edit
array of type struct format_info, we now have a human-readable CSV file.
The CSV file also contains more format information than the format_info
struct contained so we can potentially make format_info more detailed later.

The python to generate the format information was added the previous
commit.  This commit turns it on in both automake and scons builds.

v2: Split into two commits and stuff to generate format_info.c from scons

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa/main: Add python code to generate the format_info structure
Jason Ekstrand [Mon, 4 Aug 2014 18:24:09 +0000 (11:24 -0700)]
mesa/main: Add python code to generate the format_info structure

This adds a python script called format_info.py that is used to generate a
single format_info.c file that contains the filled-out format_info array.

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa: Add python to parse the formats CSV file
Jason Ekstrand [Sat, 2 Aug 2014 01:09:46 +0000 (18:09 -0700)]
mesa: Add python to parse the formats CSV file

The basic concept for the format parser was taken from the format CSV
parser in gallium/auxilliary/util.  However, this one has been altered in a
number of ways:

 * Removed big endian vs. little endian stuff (mesa doesn't need it)
 * Better documentation: Almost every method has a full docstring
 * An actual Swizzle class with methods for composition and inverses
 * Over-all cleaner (in my opinion) implementation and class interactions
 * A few bug fixes

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa: Add a format description CSV file
Jason Ekstrand [Fri, 20 Jun 2014 16:52:09 +0000 (09:52 -0700)]
mesa: Add a format description CSV file

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agoutil/tests/hash_table: Link against libmesautil instead of libmesa
Jason Ekstrand [Mon, 4 Aug 2014 23:45:27 +0000 (16:45 -0700)]
util/tests/hash_table: Link against libmesautil instead of libmesa

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82159

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
10 years agost/mesa: adjust Z coordinates for quad clearing
Brian Paul [Fri, 1 Aug 2014 22:55:03 +0000 (16:55 -0600)]
st/mesa: adjust Z coordinates for quad clearing

Specify the quad's Z position in clip coordinate space, not
normalized Z space.  Use viewport scale, translation = 0.5, 0.5.

Before, we were specifying the quad's Z position in [0,1] and using
viewport scale=1.0, translate=0.0.  That works fine, unless your
driver needs to work in clip coordinate space and needs to
reconstruct viewport near/far values from the scale/translation
factors.  The VMware svga driver falls into that category.

When we did that reconstruction we wound up with near=-1 and far=1
which are outside the limits of [0,1].  In some cases, this caused
the quad to be drawn at the wrong depth.  In other cases it was
clipped away.

Fixes some scissored depth clears with VMware driver.  This should
have no effect on other drivers.  We're already using these values
for the glBitmap and glDraw/CopyPixels code.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
10 years agomesa: make vertex array type error checking a little more efficient
Brian Paul [Tue, 29 Jul 2014 15:17:53 +0000 (09:17 -0600)]
mesa: make vertex array type error checking a little more efficient

Compute the bitmask of supported array types once instead of every
time we call a GL vertex array function.

Reviewed-by: Matthew McClure <mcclurem@vmware.com>
10 years agoglsl_to_tgsi: Fix typo shader_program -> shader
Michel Dänzer [Tue, 5 Aug 2014 06:19:11 +0000 (15:19 +0900)]
glsl_to_tgsi: Fix typo shader_program -> shader

This was a regression introduced by commit
f4b0ab7afd83c811329211eae8167c9bf238870c ('st/mesa: fix incorrect size
of UBO declarations') which caused an assertion failure while compiling
shaders of e.g. UE4 demos.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81834
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agomesa: update wglext.h to version 20140630
Brian Paul [Tue, 5 Aug 2014 13:59:46 +0000 (07:59 -0600)]
mesa: update wglext.h to version 20140630

Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agomesa: update glxext.h to version 20140725
Brian Paul [Tue, 5 Aug 2014 13:55:02 +0000 (07:55 -0600)]
mesa: update glxext.h to version 20140725

Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agomesa: update glext.h to version 20140725
Brian Paul [Tue, 5 Aug 2014 13:54:30 +0000 (07:54 -0600)]
mesa: update glext.h to version 20140725

Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agometa: Disable dithering during glBlitFramebuffer
Neil Roberts [Mon, 4 Aug 2014 19:54:03 +0000 (20:54 +0100)]
meta: Disable dithering during glBlitFramebuffer

According to the GL spec the only fragment operations that should affect
glBlitFramebuffer are “the pixel ownership test, the scissor test, and sRGB
conversion”. That implies that dithering should not be performed so we need to
disable it when implementing the blit with a render.

Before commit 05b52efbc97731 the dithering state would be left as whatever the
application picks (the default being GL_TRUE) and after that commit it was
explicitly enabled. Neither of these were correct.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81828
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
10 years agolibgl-xlib: drop duplicate mesautil from scons build
Emil Velikov [Mon, 4 Aug 2014 23:18:38 +0000 (00:18 +0100)]
libgl-xlib: drop duplicate mesautil from scons build

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agollvmpipe/tests: automake: link against libmesautil.la
Emil Velikov [Mon, 4 Aug 2014 22:18:12 +0000 (23:18 +0100)]
llvmpipe/tests: automake: link against libmesautil.la

Or the build will fail due to unresolved symbols.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agogallium/tests: automake: link against libmesautil.la
Emil Velikov [Mon, 4 Aug 2014 22:13:12 +0000 (23:13 +0100)]
gallium/tests: automake: link against libmesautil.la

Or the build will fail due to unresolved symbols.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agotargets/omx: automake: link against libmesautil.la
Emil Velikov [Mon, 4 Aug 2014 21:12:01 +0000 (22:12 +0100)]
targets/omx: automake: link against libmesautil.la

Or the build will fail due to unresolved symbols.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agotargets/xvmc: automake: link against libmesautil.la
Emil Velikov [Mon, 4 Aug 2014 21:10:50 +0000 (22:10 +0100)]
targets/xvmc: automake: link against libmesautil.la

Or the build will fail due to unresolved symbols.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agotargets/clover: link against libmesautil.la
Jan Vesely [Mon, 4 Aug 2014 22:50:03 +0000 (18:50 -0400)]
targets/clover: link against libmesautil.la

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
10 years agogallivm: Fix build with latest LLVM
Jan Vesely [Mon, 4 Aug 2014 22:50:02 +0000 (18:50 -0400)]
gallivm: Fix build with latest LLVM

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
10 years agotargets/dri: link with mesautil
Roland Scheidegger [Tue, 5 Aug 2014 02:03:59 +0000 (04:03 +0200)]
targets/dri: link with mesautil

Similar to other recent build fixes.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
10 years agogallium/docs: Document TEX2/TXL2/TXB2 instructions and fix up other tex doc
Roland Scheidegger [Sat, 2 Aug 2014 02:12:03 +0000 (04:12 +0200)]
gallium/docs: Document TEX2/TXL2/TXB2 instructions and fix up other tex doc

Add documentation for TEX2/TXL2/TXB2 tgsi opcodes. Also, the texture opcode
documentation wasn't very accurate so fix this up a bit.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
10 years agogallivm: fix cube map array (and cube map shadow with bias) handling
Roland Scheidegger [Fri, 1 Aug 2014 23:49:39 +0000 (01:49 +0200)]
gallivm: fix cube map array (and cube map shadow with bias) handling

In particular need to handle TEX2/TXB2/TXL2 opcodes.
cube map shadow with bias already used TXB2 which didn't work before
at all, despite that there's by default no piglit change (but using
no_quad_lod and no_rho_opt indeed passes some more tex-miplevel-selection
tests).
The actual sampling code still won't handle cube map arrays.

Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agollvmpipe: implement support for cube map arrays
Roland Scheidegger [Fri, 1 Aug 2014 21:50:35 +0000 (23:50 +0200)]
llvmpipe: implement support for cube map arrays

This just covers the resource side of things, not the actual sampling.
Here things are trivial as cube map arrays are identical to 2d arrays in
all respects.

Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agoegl: Fix OpenGL ES version checks in _eglParseContextAttribList()
Anuj Phogat [Thu, 19 Jun 2014 00:35:18 +0000 (17:35 -0700)]
egl: Fix OpenGL ES version checks in _eglParseContextAttribList()

We would generate EGL_BAD_CONFIG because _eglGetContextAPIBit
returns zero for the combination of EGL_OPENGL_ES_API and a major
version > 3.  By just returning zero, the caller can't tell the
difference between a bad version (which should generate
EGL_BAD_MATCH) and a bad API (which should generate
EGL_BAD_CONFIG).  This patch causes us to filter out major
versions > 3 at a point where we can generate the correct error.

Fixes gles3 Khronos CTS test:
egl_create_context.egl_create_context

V2: Fix commit message as suggested by Ian.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agometa: Fix datatype computation in get_temp_image_type()
Anuj Phogat [Thu, 12 Jun 2014 21:49:50 +0000 (14:49 -0700)]
meta: Fix datatype computation in get_temp_image_type()

Changes in the patch will cause datatype to be computed
correctly for 8 and 16 bit integer formats. For example:
GL_RG8I, GL_RG16I etc.

Fixes many failures in gles3 Khronos CTS test:
copy_tex_image_conversions_required
copy_tex_image_conversions_forbidden

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
10 years agometa: Move the call to _mesa_get_format_datatype() out of switch
Anuj Phogat [Thu, 12 Jun 2014 21:14:53 +0000 (14:14 -0700)]
meta: Move the call to _mesa_get_format_datatype() out of switch

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
10 years agometa: Use _mesa_get_format_bits() to get the GL_RED_BITS
Anuj Phogat [Thu, 12 Jun 2014 01:07:36 +0000 (18:07 -0700)]
meta: Use _mesa_get_format_bits() to get the GL_RED_BITS

We currently get red bits from ctx->DrawBuffer->Visual.redBits
by making a false assumption that the texture we're writing to
(in glCopyTexImage2D()) is used as a DrawBuffer.

Fixes many failures in gles3 Khronos CTS test:
copy_tex_image_conversions_required

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
10 years agometa: Initialize the variable in declaration statement
Anuj Phogat [Thu, 12 Jun 2014 00:57:30 +0000 (17:57 -0700)]
meta: Initialize the variable in declaration statement

Saves one line of code :)

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
10 years agomesa: Allow GL_TEXTURE_CUBE_MAP target with compressed internal formats
Anuj Phogat [Tue, 10 Jun 2014 00:28:33 +0000 (17:28 -0700)]
mesa: Allow GL_TEXTURE_CUBE_MAP target with compressed internal formats

GL_TEXTURE_CUBE_MAP is an allowed texture target in glTexStorage2D()
and is allowed to be used (like GL_TEXTURE_2D) with compressed internal
formats.

Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
10 years agomesa: Add gles3 condition for normalized internal formats in glCopyTexImage*()
Anuj Phogat [Fri, 6 Jun 2014 18:46:55 +0000 (11:46 -0700)]
mesa: Add gles3 condition for normalized internal formats in glCopyTexImage*()

Fixes many failures in gles3 Khronos CTS test: packed_pixels

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Add utility function _mesa_is_enum_format_unorm()
Anuj Phogat [Fri, 6 Jun 2014 19:35:55 +0000 (12:35 -0700)]
mesa: Add utility function _mesa_is_enum_format_unorm()

V2: Add missing formats.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Add gles3 error condition for GL_RGBA10_A2 buffer format in glCopyTexImage*()
Anuj Phogat [Fri, 6 Jun 2014 18:59:28 +0000 (11:59 -0700)]
mesa: Add gles3 error condition for GL_RGBA10_A2 buffer format in glCopyTexImage*()

Fixes many failures in gles3 Khronos CTS test: packed_pixels

Khronos bug# 9807
Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Add a gles3 error condition for sized internalformat in glCopyTexImage*()
Anuj Phogat [Thu, 5 Jun 2014 18:48:34 +0000 (11:48 -0700)]
mesa: Add a gles3 error condition for sized internalformat in glCopyTexImage*()

Fixes many failures in gles3 Khronos CTS test: packed_pixels

V2: Add the check for alpha bits to avoid confusion.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Add a helper function _mesa_is_enum_format_unsized()
Anuj Phogat [Thu, 5 Jun 2014 18:13:16 +0000 (11:13 -0700)]
mesa: Add a helper function _mesa_is_enum_format_unsized()

Function is utilized by next patch in the series.

V2: Add missing formats.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Don't allow snorm internal formats in glCopyTexImage*() in GLES3
Anuj Phogat [Fri, 6 Jun 2014 21:53:12 +0000 (14:53 -0700)]
mesa: Don't allow snorm internal formats in glCopyTexImage*() in GLES3

Fixes few failures in gles3 Khronos CTS test: packed_pixels

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Add utility function _mesa_is_enum_format_snorm()
Anuj Phogat [Fri, 6 Jun 2014 21:47:52 +0000 (14:47 -0700)]
mesa: Add utility function _mesa_is_enum_format_snorm()

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Fix condition for using compressed internalformat in glCompressedTexImage3D()
Anuj Phogat [Sat, 31 May 2014 00:48:34 +0000 (17:48 -0700)]
mesa: Fix condition for using compressed internalformat in glCompressedTexImage3D()

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Add error condition for using compressed internalformat in glTexStorage3D()
Anuj Phogat [Fri, 30 May 2014 23:24:39 +0000 (16:24 -0700)]
mesa: Add error condition for using compressed internalformat in glTexStorage3D()

Fixes gles3 Khronos CTS test: texture_storage_texture_internal_formats

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Turn target_can_be_compressed() in to a utility function
Anuj Phogat [Sat, 31 May 2014 00:33:54 +0000 (17:33 -0700)]
mesa: Turn target_can_be_compressed() in to a utility function

V2:  Declare the function in teximage.h

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
10 years agomesa: Fix error condition for valid texture targets in glTexStorage* functions
Anuj Phogat [Fri, 30 May 2014 21:55:28 +0000 (14:55 -0700)]
mesa: Fix error condition for valid texture targets in glTexStorage* functions

Fixes gles3 Khronos CTS test: texture_storage_texture_targets

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
10 years agoglsl: Rebuild the symbol table without unreachable symbols
Ian Romanick [Mon, 14 Jul 2014 22:48:34 +0000 (15:48 -0700)]
glsl: Rebuild the symbol table without unreachable symbols

Previously we had to keep unreachable global symbols in the symbol table
because the symbol table is used during linking.  Having the symbol
table retain pointers to freed memory... what could possibly go wrong?
At the same time, this meant that we kept live references to tons of
memory that was no longer needed.

New strategy:  destroy the old symbol table, and make a new one from the
reachable symbols.

Valgrind massif results for a trimmed apitrace of dota2:

                  n        time(i)         total(B)   useful-heap(B) extra-heap(B)    stacks(B)
Before (32-bit): 59 40,642,425,451       76,337,968       69,720,886     6,617,082            0
After  (32-bit): 46 40,661,487,174       75,116,800       68,854,065     6,262,735            0

Before (64-bit): 79 37,179,441,771      106,986,512       98,112,095     8,874,417            0
After  (64-bit): 64 37,200,329,700      104,872,672       96,514,546     8,358,126            0

A real savings of 846KiB on 32-bit and 1.5MiB on 64-bit.

v2: (by Kenneth Graunke) Just add the ir_function from the IR stream,
    rather than looking it up in the symbol table; they're now
    identical.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoglsl: Only create one ir_function for a given name.
Kenneth Graunke [Thu, 24 Jul 2014 21:05:41 +0000 (14:05 -0700)]
glsl: Only create one ir_function for a given name.

Piglit's spec/glsl-1.10/linker/override-builtin-{const,uniform}-05 tests
do the following:

1. Call abs(float) - a built-in function.
2. Create a user-defined replacement for abs(float).
3. Call abs(float) again - now the user function.

At step 1, we created an ir_function which included the built-in
signature, added it to the symbol table, and emitted it into the IR
stream.

Then, when processing the function definition at step 2, we'd see that
there was already an ir_function.  But, since there were no user-defined
functions, we skipped over a bunch of code, and ended up creating a
second one.  This new ir_function shadowed the original in the symbol
table, but both ended up in the IR stream.

This results in an awkward situation where searching for an ir_function
via the symbol table, a forward linked list walk, and a reverse linked
list walk may return different ir_functions.  This seems undesirable.

This patch instead re-uses the existing ir_function, putting both
built-in and user-defined signatures in the same one.  The previous
patch's additional filtering ensures everything continues working.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoglsl: Make it possible to ignore built-ins when matching signatures.
Kenneth Graunke [Thu, 24 Jul 2014 21:05:40 +0000 (14:05 -0700)]
glsl: Make it possible to ignore built-ins when matching signatures.

Historically, we've implemented the rules for overriding built-in
functions by creating multiple ir_functions and relying on the symbol
table to hide the one containing built-in functions.  That works, but
has a few drawbacks, so the next patch will change it.

Instead, we'll have a single ir_function for a particular name, which
will contain both built-in and user-defined signatures.  Passing an
extra parameter to matching_signature makes it easy to ignore built-ins
when they're supposed to be hidden.

I didn't add the parameter to exact_matching_signature since it wasn't
necessary.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agomesa: Actually use the Mesa IR optimizer for ARB programs.
Kenneth Graunke [Sat, 2 Aug 2014 12:33:14 +0000 (05:33 -0700)]
mesa: Actually use the Mesa IR optimizer for ARB programs.

On Haswell, this cuts 1-3 instructions from 183 vertex shaders in
"Shadowrun Returns", "Shatter", and "Trine 2."  It adds 2 instructions
to a single fragment shader in "Closure."

total instructions in shared programs: 278803 -> 278546 (-0.09%)
instructions in affected programs:     41930 -> 41673 (-0.61%)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoglsl: Do not add extra padding to structures
Ian Romanick [Sat, 19 Jul 2014 21:14:29 +0000 (14:14 -0700)]
glsl: Do not add extra padding to structures

This code was attemping to align the base of the structure to the required
alignment of the structure.  However, it had two problems:

1. It was aligning the target structure member, not the base of the
structure.

2. It was calculating the alignment based on the members previous to the
target member instead of all the members of the structure.

Fixes gles3conform failures in:

ES3-CTS.shaders.uniform_block.random.nested_structs.6
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.2
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.6
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.5
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.19
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.0
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.2
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.6
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.12

v2: Fix rebase failure noticed by Matt.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agoglsl: Correctly determine when the field of a UBO is row-major
Ian Romanick [Mon, 30 Jun 2014 17:05:27 +0000 (10:05 -0700)]
glsl: Correctly determine when the field of a UBO is row-major

Previously if a field of an block with an instance name was marked
row-major (but block itself was not), we would think the field (and it's
sub-fields) were column-major.

Fixes gles3conform failures in:

ES3-CTS.shaders.uniform_block.random.basic_types.7
ES3-CTS.shaders.uniform_block.random.basic_types.9
ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.1
ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.3
ES3-CTS.shaders.uniform_block.random.nested_structs.3
ES3-CTS.shaders.uniform_block.random.nested_structs.5
ES3-CTS.shaders.uniform_block.random.nested_structs.8
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.3
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.6
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.7
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.8
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.9
ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.0
ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.1
ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.2
ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.3
ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.4
ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.6
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.0
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.1
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.5
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.0
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.4
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.7
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.8
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.12
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.14
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.15
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.16
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.1
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.8
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.9
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.10
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.11
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.13
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.14
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.15
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.16
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.17

Fixes gles3conform failures (caused by previous commits) in:

ES3-CTS.shaders.uniform_block.random.basic_types.8
ES3-CTS.shaders.uniform_block.random.basic_arrays.3
ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.0
ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.2
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.9
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.13
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.18
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.4

v2: Fix rebase failure noticed by Matt.

v3: Use without_array() instead of older predicates.

v4: s/GLSL_MATRIX_LAYOUT_DEFAULT/GLSL_MATRIX_LAYOUT_INHERITED/g

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com> [v2]