Age | Commit message (Collapse) | Author |
|
For a shader involving many small functions, this avoids running
optimization across all of them after they've been inlined
post-linking.
Reduces the runtime of linking and running a fragment shader from Yo
Frankie from 1.6 seconds to 0.9 seconds (-44.9%, +/- 3.3%).
|
|
We wouldn't want to go rewriting dereferences to variables to point at
the same variable it did before. While I didn't find a way to trigger
that, a shader in Yo Frankie managed to produce a self-assignment by
passing a constant to a function doing self assignment like this.
Cleans up the IR for glsl-deadcode-self-assign.shader_test
|
|
|
|
|
|
Fixes glcpp test cases 073 and 074, as well as piglit test
xonotic-vs-generic-diffuse.vert.
|
|
|
|
The original intention was to use #ifdef.
|
|
|
|
I introduced this for ir_dead_code to distinguish function parameter
outvals from varying outputs. Only, since ast_to_hir's
current_function is unset when setting up function parameters (they're
needed for making the function signature in the first place), all
function parameter outvals were marked as shader outputs anyway. This
meant that an inlined function's cloned outval was marked as a shader
output and couldn't be dead-code eliminated. Instead, since
ir_dead_code doesn't even look at function parameters, just use
var->mode.
The longest Mesa IR coming out of ir_to_mesa for Yo Frankie drops from
725 instructions to 636.
|
|
|
|
Mixing stderr (_mesa_print_program, _mesa_print_instruction,
_mesa_print_alu) with stdout means that when writing both to a file,
there isn't a consistent ordering between the two.
|
|
While the Mesa IR dumping includes some corresponding GLSL IR for
correlating Mesa IR to GLSL IR, it doesn't completely express it.
This printing includes things like variable declarations and control
flow structure that is hard to read otherwise.
|
|
|
|
|
|
|
|
Previously the in-line matrix and vector constructors would generate
swizzles in the LHS. The code is actually more clear if it just
generates the masked assignments instead of relying on the
ir_assignment constructor to convert the swizzles to write masks.
|
|
|
|
Replace swizzles on the LHS with additional swizzles on the RHS and a
write mask in the assignment instruction. As part of this add
ir_assignment::set_lhs. Ideally we'd make ir_assignment::lhs private
to prevent erroneous writes, but that would require a lot of code
butchery at this point.
Add ir_assignment constructor that takes an explicit write mask. This
is required for ir_assignment::clone, but it can also be used in other
places. Without this, ir_assignment clones lose their write masks,
and incorrect IR is generated in optimization passes.
Add ir_assignment::whole_variable_written method. This method gets
the variable on the LHS if the whole variable is written or NULL
otherwise. This is different from
ir->lhs->whole_variable_referenced() because the latter has no
knowledge of the write mask stored in the ir_assignment.
Gut all code from ir_to_mesa that handled swizzles on the LHS of
assignments. There is probably some other refactoring that could be
done here, but that can be left for another day.
|
|
|
|
|
|
|
|
|
|
|
|
Calling exit() on a memory failure probably made sense for the
standalone preprocessor, but doesn't seem too appealing as part of
the GL library. Also, we don't use it in the main compiler.
|
|
|
|
|
|
Mesa will do the mapping at _mesa_add_sampler() time. Fixes assertion
failures in debug builds, which might have caught real problems with
multiple samplers linked in a row.
|
|
Instead of using a linker-assigned location (since samplers don't
actually take up uniform space, being a link-time choice), use the
sampler's varaible pointer as a hash key.
|
|
The new compiler doesn't generate Mesa IR at compile time, and that
compile time code previously wouldn't have reflected the link time
code that actually got used. But do dump the info log of the compile
regardless.
|
|
|
|
In most cases, we needed to be reparenting the cloned IR to a
different context (for example, to the linked shader instead of the
unlinked shader), or optimization before the reparent would cause
memory usage of the original object to grow and grow.
|
|
Fixes unset ir_type after inlining.
|
|
An unnamed variable in a prototype will have a NULL ->name, so don't
worry about storage then.
Fixes:
CorrectFunction1.vert
CorrectParse1.frag
|
|
ir_variable always strdups the incoming name so that it matches the
lifetime of the ir_variable.
|
|
I take back the bad things I've said about the signed/unsigned
comparison warning now.
|
|
Fixes:
glsl-uniform-initializer-1
glsl-uniform-initializer-2
glsl-uniform-initializer-3
glsl-uniform-initializer-4
glsl1-GLSL 1.20 uniform array constructor
|
|
We were happily optimizing away the body of
glsl-uniform-initializer-* to never use the uniforms.
|
|
|
|
Fixes glsl-uniform-struct.
|
|
This helps makes sure we don't miss any new fields, and makes totally
uninitialized src_regs be PROGRAM_UNDEFINED.
|
|
This is a zero-ing function, (like calloc), to avoid bugs due to
accessing uninitialized values. Thanks to valgrind for noticing the
use of uninitialized values.
|
|
|
|
The symbol_header structure that tracks symbols with a particular name
may have a different (longer) life time than the symbols it tracks.
Not keeping a local copy of the name can lead to use-after-free
errors. For example, the following sequence would trigger such an
error:
char *copy = strdup(name);
_mesa_symbol_table_push_scope(st);
_mesa_symbol_table_add_symbol(st, 0, name, NULL);
_mesa_symbol_table_pop_scope(st);
free(name);
_mesa_symbol_table_find_symbol(st, 0, copy);
With this change, the symbol table keeps a local copy of the name that
has the same life time as the symbol_header for that name. This
resolves some use-after-free errors with built-in functions in the
GLSL compiler.
|
|
|
|
|
|
Fixes glsl-fs-tan-1.
|
|
|
|
We use vector ir_unop_not to implement builtin not(), and that seems fine.
|
|
Fixes glsl-floating-constant-120.
|
|
Fixes intermittent failure in glsl-arb-fragment-coord-conventions.
|