Commit Graph

1208 Commits

Author SHA1 Message Date
Kenneth Graunke 151aecabe4 glsl: Don't crash on function names with invalid identifiers.
Karol Herbst's fuzzing efforts noticed that we would segfault on:

   void bug() {
      2(0);
   }

We just need to bail if the function name isn't an identifier.

Based on a bug fix by Karol Herbst.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97422
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
2016-11-12 22:08:15 -08:00
Kenneth Graunke 9c676a6427 glsl: Fix assert fails when assignment expressions are in array sizes.
Karol Herbst's fuzzing efforts discovered that we would hit the
following assert:

   assert(dummy_instructions.is_empty());

when processing an illegal array size expression of

   float[(1=1)?1:1] t;

In do_assignment, we realized we needed an rvalue for (1 = 1), and
generated a temporary variable and assignment from the RHS.  We've
already flagged an error (non-lvalue in assignment), and return a bogus
value as the rvalue.  But process_array_size sees the bogus value, which
happened to be a constant expression, and rightly assumes that
processing a constant expression shouldn't have generated any code.
instructions.

To handle this, make do_assignment not generate any temps or assignments
when it's already raised an error - just return an error value directly.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98694
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
2016-11-12 22:08:15 -08:00
Brian Paul 92ec47a6ba glsl: define __STDC_FORMAT_MACROS to get PRIx64 macro
Otherwise, inttypes.h may not define the macro for C++ on MinGW.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98681
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-11 09:43:29 -07:00
Emil Velikov db45f1eaab glsl: automake: add opt_add_neg_to_sub.h to the sources list
Otherwise it'll be missing in the release tarball.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-11 14:46:12 +00:00
Tapani Pälli 1c2de8977b android: add SPIRV_FILES to libmesa_nir
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-11-11 07:59:29 +02:00
Brian Paul d881e1c024 glsl: include inttypes.h for PRIx64 macro
To fix MinGW build.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2016-11-10 17:59:18 -07:00
Ian Romanick e9acae8486 glsl/standalone: Add the ability to generate ir_builder code
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-11-10 14:30:49 -08:00
Ian Romanick 191d9a5195 glsl: Add a C++ code generator that uses ir_builder to rebuild a program
This is only in libstandalone currently because it will only be used in
the stand-alone compiler.

v2: Change the signature of the generated function.  The ir_factory is
created in the generator, and an availability predicate is taken as a
parameter.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-11-10 14:30:49 -08:00
Ian Romanick 984f16bbd7 glsl: Generate strings that are the enum names without the ir_*op_ prefix
For many expressions, this is different from the printable name.  The
printable name for ir_binop_add is "+", but we want "add".  This is
needed for ir_builder_print_visitor.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-11-10 14:30:49 -08:00
Ian Romanick d0028b2e1c glsl/standalone: Enable par-linking
If the user did not request full linking, link the shader with the
built-in functions, inline them, and eliminate them.  Previous to this
you'd see all these calls to "dot" and "max" in the output.  This
prevented a lot of expected optimizations and cluttered the output.
This gives it some chance of being useful.

v2: Rebase on top of Ken's "built-ins now" work.

v3: Don't do_common_optimizations if par-linking fails.  Update expected
output of warnings tests to prevent 'make check' regressions.

v4: Optimize harder.  Most important, do function inlining.  Otherwise
it's quite impractical for one function in a file to call another
function in the same file.

v5: Add some code simplifications and an assertion suggested by Iago.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-11-10 14:30:49 -08:00
Ian Romanick 4dc759c8c2 glsl/standalone: Optimize dead variable declarations
We didn't bother with this in the regular compiler because it doesn't
change the generated code.  In the stand-alone compiler, this can
clutter the output with useless variables.  It's especially bad after
functions are inlined but the foo_retval declarations remain.

v2: Use set_foreach.  Suggested by Tapani.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-11-10 14:30:49 -08:00
Ian Romanick f45a2a93ae glsl/standalone: Optimize add-of-neg to subtract
This just makes the output of the standalone compiler a little more
compact.

v2: Fix indexing typo noticed by Iago.  Move the add_neg_to_sub_visitor
to it's own header file.  Add a unit test that exercises the visitor.
Both the neg_a_plus_b and neg_a_plus_neg_b tests reproduced the bug that
Iago discovered.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-11-10 14:30:49 -08:00
Ian Romanick 9788b3b6f3 glsl/linker: Allow link_intrastage_shaders when there is no main()
This enables a sort of par-linking.  The primary use for this feature is
resolving built-in functions in the stand-alone compiler.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-11-10 14:30:49 -08:00
Timothy Arceri 7372d2153a nir: update nir_gather_info to only mark used array/matrix elements
This is based on the code from the GLSL IR pass however unlike the GLSL IR
pass it also supports arrays of arrays.

As well as implementing the logic from the GLSL IR pass we add some
additional intrinsic cases to catch more system values.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-11-11 09:17:07 +11:00
Kenneth Graunke 53d1f4251f mesa/compiler: move MAX_VARYING to shader_enums.h
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
2016-11-11 09:17:07 +11:00
Timothy Arceri cd52b4fb16 nir: add more helpers to nir_types.cpp
These new helpers will be used in nir_gather_info.c in a following patch.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-11-11 09:17:07 +11:00
Kenneth Graunke ad9d4a4f8d nir: Generalize the "is per-vertex variable?" helpers and export them.
I want this function for nir_gather_info(), and realized it's basically
the same as the ones in nir_lower_io().

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
2016-11-11 09:17:07 +11:00
Ian Romanick c8c46641af glsl: Parse 0 as a preprocessor INTCONSTANT
This allows a more reasonable error message for '#version 0' of

    0:1(10): error: GLSL 0.00 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

instead of

    0:1(10): error: syntax error, unexpected $undefined, expecting INTCONSTANT

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97420
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Cc: mesa-stable@lists.freedesktop.org
Cc: Juan A. Suarez Romero <jasuarez@igalia.com>
Cc: Karol Herbst <karolherbst@gmail.com>
2016-11-10 10:57:59 -08:00
Ian Romanick e85a747e29 glcpp: Handle '#version 0' and other invalid values
The #version directive can only handle decimal constants.  Enforce that
the value is a decimal constant.

Section 3.3 (Preprocessor) of the GLSL 4.50 spec says:

    The language version a shader is written to is specified by

        #version number profile opt

    where number must be a version of the language, following the same
    convention as __VERSION__ above.

The same section also says:

    __VERSION__ will substitute a decimal integer reflecting the version
    number of the OpenGL shading language.

Use a separate flag to track whether or not the #version line has been
encountered.  Any possible sentinel (0 is currently used) could be
specified in a #version directive.  This would lead to trying to
(internally) redefine __VERSION__.  Since there is no parser location
for this addition, NULL is passed.  This eventually results in a NULL
dereference and a segfault.

Attempts to use -1 as the sentinel would also fail if '#version
4294967295' or '#version 18446744073709551615' were used.  We should
have piglit tests for both of these.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97420
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Cc: mesa-stable@lists.freedesktop.org
Cc: Juan A. Suarez Romero <jasuarez@igalia.com>
Cc: Karol Herbst <karolherbst@gmail.com>
2016-11-10 10:57:59 -08:00
Ian Romanick cbba5e13ac linker: Remove unnecessary overload of program_resource_visitor::visit_field
It looks like I added this version as a short-hand for users that didn't
need the fuller version.  I don't think there's any real utility in
that.  I'm not sure what my thinking was there.  Maybe if those users
overloaded the recursion function could just call the compact version to
avoid passing some parameters?  None of the users do that.

Either way, having this extra overload is not useful.  Delete it.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2016-11-10 10:57:46 -08:00
Marek Olšák f500c36339 mesa: remove LowerShaderSharedVariables
always true for compute shaders

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-11-10 18:34:55 +01:00
Marek Olšák 0f6360eedb glsl: handle partial swizzles in opt_dead_code_local correctly
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-11-10 18:34:55 +01:00
Marek Olšák e27333a568 glsl: don't run loop passes if loop unrolling is disabled
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-11-10 18:34:55 +01:00
Iago Toral Quiroga 8933417565 glsl: validate output blocks against input blocks
Until now were validating in/out blocks by listing the inputs in the
consumer stage and then, for each output of the producer, we checked that
it was a match if it was consumed. This method does not catch the case
where the consumer has an input that is not present as an output in the
producer stage, because it only generates link errors for outputs present
in the producer stage that don't match the inputs in the consumer stage.
The current method does catch the case were an output from the producer
stage is not consumed, which is irrelevant and is ignored.

By reversing the way we do this, we can detect this situation, so this
patch lists the outputs of the producer stage and then validates inputs
of the consumer stage against them. If we see an input in the consumer
for which there is no associated output in the producer, we produce a
link error.

The only exception to this is the special built-in input block gl_in[],
since this is implicitly generated for geometry and tessellation stages,
but we don't generate it if the producer stage does not write to any of
the pre-defined outputs (for example, if the vertex shader does not write
to gl_Position, etc). Since writing to these is not mandatory, do not
produce a link error in that case. There is a CTS tessellation test
(GL45-CTS.tessellation_shader.program_object_properties) that has an
empty vertex shader (so it does not produce gl_in[]) and would fail to
link if we don't do this.

This fixes the following dEQP test:
dEQP-GLES31.functional.shaders.linkage.io_block.missing_output_block

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98245
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-11-10 08:08:07 +01:00
Ilia Mirkin 73f53c097a glsl: record number of components used in each slot for varying packing
Instead of packing varyings into vec4's, keep track of how many
components each slot uses and create varyings with matching types. This
ensures that we don't end up using more components than the orginal
shader, which is especially important for geometry shader output limits.

This comes up for NVIDIA hw, where the limit is 1024 output components
for a GS, and the hardware complains *loudly* if you even think about
going over.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
2016-11-09 20:26:48 -05:00
Ilia Mirkin 885c788017 glsl: fix slot_end calculations and simplify reserved_slots check
The previous code was confused about whether slot_end was inclusive or
exclusive. Make it so that it is inclusive consistently, and use it for
setting the new location. This also avoids discrepancies in how
num_components is calculated vs the more manual approach taken for the
former reserved_slots check.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
2016-11-09 20:25:15 -05:00
Ian Romanick 084105c213 linker: Accurately track gl_uniform_block::stageref
As the linked per-stage shaders are processed, mark any block that has a
field that is accessed as referenced.  When combining all the linked
shaders, combine the per-stage stageref masks.

This fixes a number of GLES CTS tests:

    ES31-CTS.core.geometry_shader.program_resource.program_resource
    ES32-CTS.core.geometry_shader.program_resource.program_resource
    ESEXT-CTS.geometry_shader.program_resource.program_resource
    piglit.gl45-cts.geometry_shader.program_resource.program_resource

However, it makes quite a few more fail:

    ES31-CTS.functional.program_interface_query.buffer_variable.random.6
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.compute.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.separable_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment_only_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment_only_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment_only_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment_only_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.random.6
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.compute.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.separable_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment_only_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment_only_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment_only_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment_only_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment.unnamed_block.float

I have diagnosed the failures, but I'm not sure whether we or the
tests are wrong.  After optimizations are applied, all of the tests
are of the form:

    buffer X {
        float f;
    } x;

    void main()
    {
        x.f = x.f;
    }

The test then queries that x is referenced by that shader stage.  We
eliminate the assignment of x.f to itself, and that removes the last
reference to x.  We report that x is not referenced, and the test fails.
I do not know whether or not we are allowed to eliminate that assignment
of x.f to itself.

After discussions with the OpenGL ES group in Khronos, we believe that
Mesa's behavior is correct.  I will provide patches to the CTS tests
to Khronos.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-11-09 12:47:51 -08:00
Ian Romanick 392fabcfee linker: Slight code rearrange to prevent duplication in the next commit
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-11-09 12:47:51 -08:00
Ian Romanick a529acfb2b linker: Trivial coding standards fixes
v2: Revert the unreachable to assert in
parcel_out_uniform_storage::visit_field.  Suggested by Ilia.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-11-09 12:47:51 -08:00
Ian Romanick fbc1a4b7d2 glsl: Add some comments to methods of ir_variable_refcount_visitor
It was not obvious from the just the .h file what the hash table
contained.  It was also not obvious that get_variable_entry would create
a new entry in the hash table.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-11-09 12:47:51 -08:00
Dave Airlie b16dff2d88 nir: add conditional discard optimisation (v4)
This is ported from GLSL and converts

if (cond)
	discard;

into
discard_if(cond);

This removes a block, but also is needed by radv
to workaround a bug in the LLVM backend.

v2: handle if (a) discard_if(b) (nha)
cleanup and drop pointless loop (Matt)
make sure there are no dependent phis (Eric)
v3: make sure only one instruction in the then block.
v4: remove sneaky tabs, add cursor init (Eric)

Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2016-11-10 05:46:33 +10:00
Nicolai Hähnle aef7eb4cac glsl/cache: correct asprintf error handling
From the manpage of asprintf:

   "If memory allocation wasn't possible, or some other error occurs,
    these functions will return -1, and the contents of strp are
    undefined."

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2016-11-04 10:28:08 +01:00
Eric Anholt 49936364e4 nir: Make sure to set the texsrc type in nir drawpixels/bitmap lowering.
We were leaving an undefined value since the ralloc zeroing changes.
Fixes nir_validate() failures on vc4.

v2: Fix the color-index case of drawpixels as well.

Reviewed-by: Rob Clark <robdclark@gmail.com> (v1)
2016-11-03 18:42:58 -07:00
Francisco Jerez f3d387867f nir: Flip gl_SamplePosition in nir_lower_wpos_ytransform().
Assuming the hardware is set up to use a screen coordinate system
flipped vertically with respect to the GL's window coordinate system,
the SYSTEM_VALUE_SAMPLE_POS vector will also be flipped vertically
with respect to the value expected by the GL, so we need to give it
the same treatment as gl_FragCoord.  Fixes the following CTS tests on
i965:

 ES31-CTS.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.default_framebuffer
 ES31-CTS.functional.shaders.sample_variables.sample_pos.correctness.default_framebuffer

when run with any multisample configuration, e.g. rgba8888d24s8ms4.

Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2016-11-03 11:46:44 -07:00
Nicolai Hähnle 37d646c1b3 glsl: fix lowering of UBO references of named blocks
When a UBO reference has the form block_name.foo where block_name refers
to a block where the first member has a non-zero offset, the base offset
was incorrectly added to the reference.

Fixes an assertion triggered in debug builds by
GL45-CTS.enhanced_layouts.uniform_block_layout_qualifier_conflict. That test
doesn't properly check for correct execution in this case, so I am also
going to send out a piglit test.

Cc: 13.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-11-03 09:57:25 +01:00
Kenneth Graunke 8df4aebc94 glsl: Update deref types when resizing implicitly sized arrays.
At link time, we resolve the size of implicitly sized arrays.
When doing so, we update the type of the ir_variables.  However,
we neglected to update the type of ir_dereference nodes which
reference those variables.

It turns out array_resize_visitor (for GS/TCS/TES interface array
handling) already did 2/3 of the cases for this, so we can simply
refactor the code and reuse it.

This fixes:
GL45-CTS.shader_storage_buffer_object.basic-syntax
GL45-CTS.shader_storage_buffer_object.basic-syntaxSSO

which have an SSBO containing an implicitly sized array, followed
by some other members.  setup_buffer_access uses the dereference
types to compute offsets to fields, and it had a stale type where
the implicitly sized array's length was still 0 instead of the
actual length.

While we're here, we can also fix update_array_sizes to properly
update deref types as well, fixing a FINISHME from 2010.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
2016-11-03 01:42:37 -07:00
Timothy Arceri d2861d682a mesa/glsl: delete previously linked shaders earlier when linking
This moves the delete linked shaders call to
_mesa_clear_shader_program_data() which makes sure we delete them
before returning due to any validation problems.

It also reduces some code duplication.

From the OpenGL 4.5 Core spec:

   "If LinkProgram failed, any information about a previous link of
   that program object is lost. Thus, a failed link does not restore
   the old state of program.

   ...

   If one of these commands is called with a program for which
   LinkProgram failed, no error is generated unless otherwise noted.
   Implementations may return information on variables and interface
   blocks that would have been active had the program been linked
   successfully. In cases where the link failed because the program
   required too many resources, these commands may help applications
   determine why limits were exceeded."

Therefore it's expected that we shouldn't be able to query the
program that failed to link and retrieve information about a
previously successful link.

Before this change the linker was doing validation before freeing
the previously linked shaders and therefore could exit on failure
before they were freed.

This change also fixes an issue in compat profile where a program
with no shaders attached is expect to fall back to fixed function
but was instead trying to relink IR from a previous link.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97715
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
2016-11-03 11:58:53 +11:00
Timothy Arceri 903e5eae97 nir: fix nir_shader_clone() and nir_sweep()
These were broken in e1af20f18a when the info field in nir_shader was
turned into a pointer.

Clone was copying the pointer rather than the data and nir_sweep was
cleaning up shader_info rather than claiming it.

Reviewed-by: Eric Anholt <eric@anholt.net>
2016-11-03 10:39:13 +11:00
Nicolai Hähnle 1ef505bb02 glsl: compute lvalues of [in]out parameters before inlined function body
This is required when an out argument involves an array index that is either
a global variable modified by the function or another out argument in the
same function call.

Fixes the shaders/out-parameter-indexing/vs-inout-index-inout-* tests.

v2:
- modify the ir_dereference_array nodes in place
- use ir_hierarchical_visitor
v3: use base_ir (Ian Romanick)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2016-11-02 12:32:47 +01:00
Marek Olšák 7a2387c3e0 glsl: use a non-malloc'd storage for short ir_variable names
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Marek Olšák 21e11b5282 glsl: use the linear allocator in opt_constant_propagation
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Marek Olšák 565b2c4c4b glsl: use the linear allocator in opt_copy_propagation
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Marek Olšák b6f50e4640 glsl: use the linear allocator in opt_copy_propagation_elements
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Marek Olšák 9c19dedff0 glsl: use the linear allocator in opt_dead_code_local
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Marek Olšák 23e373eb4f glsl: use the linear allocator in glsl_symbol_table
no ralloc_free occurences

Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Marek Olšák a4a93103fb glsl: use the linear allocator for ast_node and derived classes
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Marek Olšák 2296bb0967 glsl/lexer: use the linear allocator
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Marek Olšák 47e1758692 glcpp: use the linear allocator for most objects
v2: cosmetic changes

Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com> (v1)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> (v1)
2016-10-31 11:53:38 +01:00
Marek Olšák 52d2b28f7f ralloc: use rzalloc where it's necessary
No change in behavior. ralloc_size is equivalent to rzalloc_size.
That will change though.

Calls not switched to rzalloc_size:
- ralloc_vasprintf
- glsl_type::name allocation (it's filled with snprintf)
- C++ classes where valgrind didn't show uninitialized values

I switched most of non-glsl stuff to rzalloc without checking whether
it's really needed.

Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-31 11:53:38 +01:00
Juha-Pekka Heikkila 3bf6c6c3ad nir: zero allocated memory where needed
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
2016-10-31 11:53:38 +01:00