Commit Graph

45844 Commits

Author SHA1 Message Date
Brian Paul
971905bf39 svga: add missing switch case for PIPE_SHADER_CAP_INTEGERS 2011-08-09 08:58:47 -06:00
Brian Paul
e0496b63ff glx: move declarations before code 2011-08-09 08:58:20 -06:00
Fabio Pedretti
afd1d85775 swrast: silence unused var warnings
Signed-off-by: Brian Paul <brianp@vmware.com>
2011-08-09 08:08:59 -06:00
Dave Airlie
36291173c2 docs: update GL3.txt with new GL 4.2 extensions 2011-08-09 10:39:52 +01:00
Paul Berry
c148ef6ddb glsl: validate IR after linking (debug builds only)
At least one of the invariants verified by IR validation concerns the
relative ordering of toplevel constructs in the IR: references to
global variables must come after the declarations of those global
variables.

Since linking affects the ordering of toplevel constructs in the IR,
it's possible that a bug in the linker will cause invalid IR to be
generated, even if all the pre-linked shaders are valid.  (In fact,
such a bug was fixed by the previous commit.)

Bugs like this are easily masked by further optimization passes,
particularly inlining.  So to make them easier to track down, this
patch addes an IR validation step right after linking, and before
final optimization occurs.  The validation only occurs on debug
builds.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-08-08 12:44:02 -07:00
Paul Berry
01a851c296 glsl: When linking, emit functions at the tail of the final linked program.
When link_functions.cpp adds a new function to the final linked
program, it needs to add it after any global variable declarations
that the function refers to, otherwise the IR will be invalid (because
variable declarations must occur before variable accesses).  The
easiest way to do that is to have the linker emit functions to the
tail of the final linked program.

The linker used to emit functions to the head of the final linked
program, in an effort to keep callees sorted before their callers.
However, this was not reliable: it didn't work for functions declared
or defined in the same compilation unit as main, for diamond-shaped
patterns in the call graph, or for some obscure cases involving
overloaded functions.  And no code currently relies on this sort
order.

No Piglit regressions with i965 Ironlake.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-08-08 12:43:57 -07:00
Paul Berry
d4144a123b glsl: Check array size is const before asserting that no IR was generated.
process_array_type() contains an assertion to verify that no IR
instructions are generated while processing the expression that
specifies the size of the array.  This assertion needs to happen
_after_ checking whether the expression is constant.  Otherwise we may
crash on an illegal shader rather than reporting an error.

Fixes piglit tests array-size-non-builtin-function.vert and
array-size-with-side-effect.vert.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-08-08 12:43:53 -07:00
Paul Berry
789ee6516b glsl: Constant-fold built-in functions before outputting IR
Rearranged the logic for converting the ast for a function call to
hir, so that we constant fold before emitting any IR.  Previously we
would emit some IR, and then only later detect whether we could
constant fold.  The unnecessary IR would usually get cleaned up by a
later optimization step, however in the case of a builtin function
being used to compute an array size, it was causing an assertion.

Fixes Piglit test array-size-constant-relational.vert.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38625
2011-08-08 12:43:45 -07:00
Paul Berry
0d81b0e184 glsl: Emit function signatures at toplevel, even for built-ins.
The ast-to-hir conversion needs to emit function signatures in two
circumstances: when a function declaration (or definition) is
encountered, and when a built-in function is encountered.

To avoid emitting a function signature in an illegal place (such as
inside a function), emit_function() checked whether we were inside a
function definition, and if so, emitted the signature before the
function definition.

However, this didn't cover the case of emitting function signatures
for built-in functions when those built-in functions are called from
inside the constant integer expression that specifies the length of a
global array.  This failed because when processing an array length, we
are emitting IR into a dummy exec_list (see process_array_type() in
ast_to_hir.cpp).  process_array_type() later checks (via an assertion)
that no instructions were emitted to the dummy exec_list, based on the
reasonable assumption that we shouldn't need to emit instructions to
calculate the value of a constant.

This patch changes emit_function() so that it emits function
signatures at toplevel in all cases.

This partially fixes bug 38625
(https://bugs.freedesktop.org/show_bug.cgi?id=38625).  The remainder
of the fix is in the patch that follows.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-08-08 12:43:38 -07:00
Paul Berry
482338842d Revert "glsl: Skip processing the first function's body in do_dead_functions()."
opt_dead_functions contained a shortcut to skip processing the first
function's body, based on the assumption that IR functions are
topologically sorted, with callees always coming before their callers
(therefore the first function cannot contain any calls).

This assumption turns out not to be true in general.  For example, the
following code snippet gets translated to IR that violates this
assumption:

    void f();
    void g();
    void f() { g(); }
    void g() { ... }

In practice, the shortcut didn't cause bugs because of a coincidence
of the circumstances in which opt_dead_functions is called:

(a) we do inlining right before dead function elimination, and
    inlining (when successful) eliminates all calls.

(b) for user-defined functions, inlining is always successful, because
    previous optimization passes (during compilation) have reduced
    them to a form that is eligible for inlining.

(c) the function that appears first in the IR can't possibly call a
    built-in function, because built-in functions are always emitted
    before the function that calls them.

It seems unnecessarily fragile to have opt_dead_functions depend on
these coincidences.  And the next patch in this series will break (c).
So I'm reverting the shortcut.  The consequence will be a slight
increase in link time for complex shaders.

This reverts commit c75427f4c8.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-08-08 12:43:04 -07:00
Bryan Cain
ffb7d02154 st/mesa: inline st_prepare_fragment_program in st_translate_fragment_program
This reverts an unnecessary part of commit 4683529048 and fixes misrendering
and an assertion failure in Cogs.

Fixes freedesktop.org bug 39888.

Reviewed-by: Brian Paul <brianp@vmware.com>
2011-08-08 10:28:59 -05:00
Brian Paul
506de19549 glext: upgrade to version 72 2011-08-08 09:01:13 -06:00
Brian Paul
75a9874021 glsl: silence warning about trailing comma in enum list 2011-08-08 09:00:57 -06:00
Brian Paul
7d4d8a8de7 gallium: silence warnings about trailing commas in enum lists 2011-08-08 09:00:06 -06:00
Brian Paul
8488112d20 mesa: whitespace changes 2011-08-08 08:26:49 -06:00
Christoph Bumiller
4dd3272df9 d3d1x: adapt to resource_resolve interface change 2011-08-07 15:34:34 +02:00
Christoph Bumiller
9e466e87e6 nv50,nvc0: never convert in resource copy when format sizes match
If there are any cases left where the st thinks that RGBA -> BGRA
will swap components, it will get what it deserves.

Now the GPU's 2D engine goes unused. What a shame.
2011-08-07 15:34:34 +02:00
Christoph Bumiller
425b179faf st/mesa: don't resolve stencil twice 2011-08-07 15:34:34 +02:00
Marek Olšák
1554e69e00 winsys/radeon: disable use of the buffer busy-for-write flag 2011-08-06 05:45:19 +02:00
Kenneth Graunke
db726b048e mesa: In validate_program(), initialize errMsg for safety.
validate_program relies on validate_shader_program to fill in errMsg;
empirically, there exist cases where that doesn't happen.

While tracking those down may be worthwhile, initializing the string so
we don't try to ralloc_strdup random garbage also seems wise.

Fixes issues caught by valgrind while running some test case.

NOTE: This is a candidate for stable release branches.

Reviewed-by: Chad Versace <chad@chad-versace.us>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2011-08-05 14:19:39 -07:00
Eric Anholt
a9e97d022c intel: Fix warnings from gl_constant_parameter changes. 2011-08-05 12:56:12 -07:00
Bryan Cain
5164244df0 glsl_to_tgsi: replace open-coded swizzle_for_size()
This is a port of commit 4c7e215c7b to glsl_to_tgsi.
2011-08-05 14:39:18 -05:00
Bryan Cain
b44648c918 glsl_to_tgsi: try to avoid emitting a MOV_SAT to saturate an expression tree
This is a port of commit 62722d9 to glsl_to_tgsi, with minor aesthetic
changes (moved the declaration and assignment of new_inst inside the if block).
2011-08-05 14:39:18 -05:00
Eric Anholt
4c7e215c7b ir_to_mesa: Replace open-coded swizzle_for_size() 2011-08-05 10:37:15 -07:00
Christopher James Halse Rogers
fbc2fcf685 glx/dri2: Paper over errors in DRI2Connect when indirect
DRI2 will throw BadRequest for this when the client is not local, but
DRI2 is an implementation detail and not something callers should have
to know about.  Silently swallow errors in this case, and just propagate
the failure through DRI2Connect's return code.

Note: This is a candidate for the stable release branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=28125
Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2011-08-05 10:11:05 -07:00
Eric Anholt
62722d90af ir_to_mesa: Try to avoid emitting a MOV_SAT to saturate an expression tree.
Fixes a regression in codegen quality for ff_fragment_shader
conversion to GLSL -- glean texCombine produces 7.5% fewer Mesa IR
instructions.
2011-08-05 10:08:31 -07:00
Eric Anholt
6bd5f43f21 prog_optimize: Add support for saturates to _mesa_merge_mov_into_inst.
This fixes the remaining regression from ff_fragment_shader in Mesa IR
instruction count, to now being a 1.9% win overall.
2011-08-05 10:08:31 -07:00
Eric Anholt
9998df36c2 i965: Add dumping for gen6 WM constants too.
This looks just like the VS dump for now.
2011-08-05 10:08:31 -07:00
Eric Anholt
69dc529da2 mesa: Remove dead "MemPool" field of gl_shader_state. 2011-08-05 10:08:31 -07:00
Eric Anholt
ee0373b833 i965/fs: Don't upload unused uniform components.
This saves both register space and upload bandwidth for unused values.

Note that previously we were relying on the visitor not initially
generating references to different sets of uniforms between the 8-wide
and 16-wide code generation, and now we're relying on them dead-code
eliminating the same stuff, too.
2011-08-05 10:08:31 -07:00
Eric Anholt
0722edc59c i965/fs: Don't allocate the old backend's compile structs for our compile.
This saves some 35MB when the program only uses GLSL shaders.
2011-08-05 10:08:31 -07:00
Marek Olšák
5b005ecc2b winsys/radeon: do the CS cleanup in the CS ioctl thread 2011-08-05 07:08:18 +02:00
Marek Olšák
64ab39b035 winsys/radeon: fix space checking
We should remove the relocations which caused a validation failure
from the list, so that the kernel receives only the validated ones.

NOTE: This is a candidate for the 7.11 branch.
2011-08-05 07:08:18 +02:00
Marek Olšák
115651241b st/dri: remove an unused-but-set variable 2011-08-05 07:08:18 +02:00
Marek Olšák
a3cde50eff st/dri: remove a dummy function dri2_create_context
It does nothing besides calling dri_create_context with the same parameters.
2011-08-05 07:05:24 +02:00
Marek Olšák
6e7942936c st/mesa: remove unused-but-set variables in st_glsl_to_tgsi.cpp 2011-08-05 07:05:24 +02:00
Marek Olšák
d99c8e191b r300g: handle new CAPs 2011-08-05 07:05:24 +02:00
Marek Olšák
6b3bbf52b8 r300g: adapt to the resource_resolve interface change 2011-08-05 07:05:24 +02:00
Marek Olšák
c251d83d91 vbo: do not call _mesa_max_buffer_index in debug builds
That code drops performance in Unigine Heaven and Tropics
by a factor of 10. That's too crazy even for a debug build.

NOTE: This is a candidate for the 7.11 branch.

Reviewed-by: Brian Paul <brianp@vmware.com>
2011-08-05 07:05:24 +02:00
Chia-I Wu
547212d963 glsl: empty declarations should be valid
Unlike C++, empty declarations such as

  float;

should be valid.  The spec is not explicit about this actually.

Some apps that generate their shader sources may rely on this.  This was
noted when porting one of them to Linux from Windows.

Reviewed-by: Chad Versace <chad@chad-versace.us>

Note: this is a candidate for the 7.11 branch.
2011-08-05 12:14:24 +09:00
Vinson Lee
a48118e510 mesa: Remove MSVC stdint typedefs from compiler.h.
MSVC can now include the stdint.h at include/c99/stdint.h.
2011-08-04 18:06:18 -07:00
Brian Paul
bf8d06c518 mesa: pass correct constant type to _mesa_fetch_state()
Fixes assorted warnings about float vs. gl_constant_value pointers.
2011-08-04 16:02:08 -06:00
Brian Paul
324857599b mesa: use gl_constant_value type in ARB program parser 2011-08-04 16:00:06 -06:00
Brian Paul
a0eb83401e mesa: use gl_constant_value type in _mesa_[Get]ProgramNamedParameter4fNV() 2011-08-04 15:55:50 -06:00
Brian Paul
d7f2e38fca mesa: add st_glsl_to_tgsi.cpp to Sconscript 2011-08-04 15:55:13 -06:00
Brian Paul
1c8d079e20 mesa: fix out of bounds array access in rtgc debug code
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=39841
This would only be hit if someone set RGTC_DEBUG=1.
2011-08-04 15:33:39 -06:00
Brian Paul
d6a0692f9d mesa: don't use K&R style function pointer calls 2011-08-04 15:33:39 -06:00
Bryan Cain
4683529048 Merge branch 'glsl-to-tgsi'
Conflicts:
	src/mesa/state_tracker/st_atom_pixeltransfer.c
	src/mesa/state_tracker/st_program.c
2011-08-04 15:43:34 -05:00
Bryan Cain
9adcab9cd4 st/mesa: replace duplicated create_color_map_texture() function with shared function 2011-08-04 13:52:09 -05:00
Bryan Cain
b7e8911531 glsl_to_tgsi: remove debugging printf 2011-08-04 13:52:06 -05:00