u2f_emit: Fix type parameter in LLVM call.

The type is the destination type (i.e. float vector) and not the
source type.  Fixes piglit fs-{in,de}crement-uint.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
Signed-off-by: José Fonseca <jfonseca@vmware.com>
glsl: fix comment typo
svga: return 1 for PIPE_CAP_MIXED_COLORBUFFER_FORMATS

This is actually required for GL_ARB_framebuffer_object, but the state
tracker doesn't currently check it.
Direct3D 9 allows mixed format color buffers with some restrictions.
Setting this allows Unigine Heaven 2.5 and 3.0 to run.  Tested both on
GL and D3D hosts.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
softpipe: handle more PIPE_CAP_x queries

These all return zero.  Add a debug_printf() to catch the default case so
we don't accidently mishandle something important in the future.

v2: remove 'default' case to get compile-time warning

Reviewed-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
llvmpipe: handle more PIPE_CAP_x queries

As with the previous commit for softpipe.

v2: remove 'default' case to get compile-time warning

Reviewed-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
svga: handle missing PIPE_CAP_x queries

And fix incorrect error message for a bad shader type/number.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
r600g: cache shader variants instead of rebuilding v3

Shader variants are stored in the list, the key for lookup is based on the
states that require different hw shaders - currently it's rctx->two_side (all
gpus) and rctx->nr_cbufs (evergreen/cayman, when writes_all property is set).

v2:
 - use simple list instead of keymap as suggested by Marek on irc
 - call r600_adjust_gprs from r600_bind_vs_shader for r6xx/r7xx
   (r600_shader_select isn't used for vertex shaders currently)

v3:
 - fix call to r600_adjust_gprs - do it after updating current shader

Improves performance for some apps, e.g. FlightGear -
see https://bugs.freedesktop.org/show_bug.cgi?id=50360

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
r600g: avoid unnecessary shader exports v2

In some cases TGSI shader has more color outputs than the number of CBs,
so it seems we need to limit the number of color exports. This requires
different shader variants depending on the nr_cbufs, but on the other hand
we are doing less exports, which are very costly.

v2: fix various piglit regressions

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
r600g: enable DUAL_EXPORT mode when possible

It seems DUAL_EXPORT on evergreen may be enabled when all CBs use 16-bit export
mode (EXPORT_4C_16BPC), also there should be at least one CB, and the PS
shouldn't export depth/stencil.

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
r600g: enable DUAL_EXPORT mode when possible on r6xx/r7xx

DUAL_EXPORT can be enabled on r6xx/r7xx when all CBs use 16-bit export
and there is no depth/stencil export.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
glsl: glcpp: Allow "#if undefined-macro' to evaluate to false.

A strict reading of the GLSL specification would have this be an
error, but we've received reports from users who expect the
preprocessor to interepret undefined macros as 0. This is the standard
behavior of the rpeprocessor for C, and according to these user
reports is also the behavior of other OpenGL implementations.

So here's one of those cases where we can make our users happier by
ignoring the specification. And it's hard to imagine users who really,
really want to see an error for this case.

The two affected tests cases are updated to reflect the new behavior.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
glsl: Consistently use length-based ralloc string functions for info_log.

Commit b823b99ec0f13af257dcd885f436a4d294c6222a switched from using
functions such as ralloc_asprintf and ralloc_strcat to
ralloc_asprintf_rewrite_tail. This change maintains the string's
length as a aparamter that is updated by the ralloc functions (rather
than recomputing it with strlen over and over).

However, the change failed to updated two locations (glcpp_error and
glcpp_warning), with the result that the string's length wasn't
updated by these calls. Then, subsequent calls to other
ralloc_asprintf_rewrite_tail would overwrite the text appended by
glcpp_error.

This commit fixes the two missing updates, and restores line numbers
to the output of glcpp error messages, (as noticed by a glcpp unit
test case that has been failing since the above-mentioned commit).

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
glsl: glcpp: Rename and document _glcpp_parser_expand_if

This function is currently used only in the expansion of #if lines,
but we will soon be using it more generally (for the expansion of
(_glcpp_parser_expand_and_lex_from) and some more documentation.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
glsl: glcpp: Move handling of #line directives from lexer to parser.

The GLSL specification requires that #line directives be interpreted
after macro expansion. Our existing implementation of #line macros in
the lexer prevents conformance on this point.

Moving the handling of #line from the lexer to the parser gives us the
macro expansion we need. An additional benefit is that the
preprocessor also now supports comments on the same line as #line
directives.

Finally, the preprocessor now emits the (fully-macro-expanded) #line
directives into the output. This allows the full GLSL compiler to also
see and interpret these directives so it can also generate correct
line numbers in error messages.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
glsl: glcpp: Extend testing of #line directives

The most recent commit adds support for comments and macro expansion
on #line directives. Add testing to verify the new features.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
llvmpipe: return 120 for PIPE_CAP_GLSL_FEATURE_LEVEL

Reviewed-by: Marek Olšák <maraeo@gmail.com>
svga: return 120 for PIPE_CAP_GLSL_FEATURE_LEVEL

Reviewed-by: Marek Olšák <maraeo@gmail.com>
i915g: Implement sRGB textures

Since we don't have them in hw we emulate them in the shader. Although not
recommended by the spec it is legit.

As a side effect we also get GL 2.1. I think this is as far as we can take
the i915.
gallivm: Added a generic lp_build_print_value which prints a LLVMValueRef.

Updated lp_build_printf to share common code.
Removed specific lp_build_print_vecX.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
gallium/util: Fix parsing of options with underscore.

For example

  GALLIVM_DEBUG=no_brilinear

which was being parsed as two options, "no" and "brilinear".