summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* linker: Trivial coding standards fixesIan Romanick2016-11-091-15/+13
| | | | | | | | | v2: Revert the unreachable to assert in parcel_out_uniform_storage::visit_field. Suggested by Ilia. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Add some comments to methods of ir_variable_refcount_visitorIan Romanick2016-11-091-0/+6
| | | | | | | | | | 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* nir: add conditional discard optimisation (v4)Dave Airlie2016-11-103-0/+128
| | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Cc: "13.0" <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/cache: correct asprintf error handlingNicolai Hähnle2016-11-041-3/+3
| | | | | | | | | | | 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 <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* nir: Make sure to set the texsrc type in nir drawpixels/bitmap lowering.Eric Anholt2016-11-032-0/+4
| | | | | | | | | 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 <[email protected]> (v1)
* nir: Flip gl_SamplePosition in nir_lower_wpos_ytransform().Francisco Jerez2016-11-031-0/+24
| | | | | | | | | | | | | | | | | | 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: <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: fix lowering of UBO references of named blocksNicolai Hähnle2016-11-031-5/+5
| | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: Update deref types when resizing implicitly sized arrays.Kenneth Graunke2016-11-031-23/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa/glsl: delete previously linked shaders earlier when linkingTimothy Arceri2016-11-034-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97715 Cc: "13.0" <[email protected]>
* nir: fix nir_shader_clone() and nir_sweep()Timothy Arceri2016-11-032-1/+9
| | | | | | | | | | These were broken in e1af20f18a8 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 <[email protected]>
* glsl: compute lvalues of [in]out parameters before inlined function bodyNicolai Hähnle2016-11-021-10/+81
| | | | | | | | | | | | | | | 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 <[email protected]>
* glsl: use a non-malloc'd storage for short ir_variable namesMarek Olšák2016-10-313-3/+22
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_constant_propagationMarek Olšák2016-10-311-3/+11
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_copy_propagationMarek Olšák2016-10-311-1/+6
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_copy_propagation_elementsMarek Olšák2016-10-311-4/+11
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_dead_code_localMarek Olšák2016-10-311-3/+9
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in glsl_symbol_tableMarek Olšák2016-10-311-8/+8
| | | | | | | no ralloc_free occurences Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator for ast_node and derived classesMarek Olšák2016-10-316-113/+114
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/lexer: use the linear allocatorMarek Olšák2016-10-313-8/+12
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glcpp: use the linear allocator for most objectsMarek Olšák2016-10-313-118/+91
| | | | | | | v2: cosmetic changes Tested-by: Edmondo Tommasina <[email protected]> (v1) Reviewed-by: Nicolai Hähnle <[email protected]> (v1)
* ralloc: use rzalloc where it's necessaryMarek Olšák2016-10-317-10/+13
| | | | | | | | | | | | | | | | | 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 <[email protected]> Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* nir: zero allocated memory where neededJuha-Pekka Heikkila2016-10-316-7/+7
| | | | Signed-off-by: Marek Olšák <[email protected]>
* glsl/glcpp: initialize all fields of glcpp_parser_t on creationTapani Pälli2016-10-311-0/+3
| | | | | | | | this fixes some of the regressions with "ralloc: remove memset from ralloc_size" Signed-off-by: Tapani Pälli <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl: Fix reading of uninitialized memoryJuha-Pekka Heikkila2016-10-312-4/+4
| | | | | | | | | | Switch to use memory allocations which zero memory for places where needed. v2: modify and rebase on top of Marek's series (Tapani) Signed-off-by: Juha-Pekka Heikkila <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl: initialize glsl_struct_field properlyMarek Olšák2016-10-312-38/+6
| | | | | | | | | don't rely on ralloc doing memset Reviewed-by: Edward O'Callaghan <[email protected]> Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Improve accuracy of alpha scaling in advanced blend lowering.Kenneth Graunke2016-10-281-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When blending with GL_COLORBURN_KHR and these colors: dst = <0.372549027, 0.372549027, 0.372549027, 0.372549027> src = <0.09375, 0.046875, 0.0, 0.375> the normalized dst value became 0.99999994 (due to precision problems in the floating point divide of rgb by alpha). This caused the color burn equation to fail the dst >= 1.0 comparison. The blue channel would then fall through to the dst < 1.0 && src >= 0 comparison, which was true, since src.b == 0. This produced a factor of 0.0 instead of 1.0. This is an inherent numerical instability in the color burn and dodge equations - depending on the precision of alpha scaling, the value can be either 0.0 or 1.0. Technically, GLSL floating point division doesn't even guarantee that 0.372549027 / 0.372549027 = 1.0. So arguably, the CTS should allow either value. I've filed a bug at Khronos for further discussion (linked below). In the meantime, this patch improves the precision of alpha scaling by replacing the division with (rgb == alpha ? 1.0 : rgb / alpha). We may not need this long term, but for now, it fixes the following CTS tests: ES31-CTS.blend_equation_advanced.blend_specific.GL_COLORBURN_KHR ES31-CTS.blend_equation_advanced.blend_all.GL_COLORBURN_KHR_all_qualifier Cc: [email protected] Cc: [email protected] Bugzilla: https://cvs.khronos.org/bugzilla/show_bug.cgi?id=16042 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: inspect interfaces in contains_foo()Juan A. Suarez Romero2016-10-272-13/+14
| | | | | | | | | | | | | When checking if a type contains doubles, integers, samples, etc. we check if the current type is a record or array, but not if it is an interface. This commit also inspects if the type is an interface. It fixes spec/arb_enhanced_layouts/compiler/transform-feedback-layout-qualifiers/xfb_offset/invalid-block-with-double.vert piglit test. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Size TCS->TES unsized arrays to gl_MaxPatchVertices for queries.Kenneth Graunke2016-10-274-3/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSO validation and other program interface queries want to see that unsized (non-patch) TCS output/TES input arrays are implicitly sized to gl_MaxPatchVertices. By the time we create the program resource lists, we've sized the arrays to their actual size. (We try to create TCS output arrays to match the output patch size right away, and at this point, we should have shrunk TES input arrays.) One option would be to keep them sized to gl_MaxPatchVertices, and defer shrinking them. But that's a big change, and I don't think it's a good idea. Instead, this patch introduces a new ir_variable flag which indicates the variable is implicitly to gl_MaxPatchVertices. Then, the linker munges the types when creating the resource list, ignoring the size in the IR's types. Basically, lie about it for resource queries. It's ugly, but I think it ought to work. We probably could use var->data.implicit_sized_array for this, but I opted for a separate bit to try and avoid convoluting the existing SSBO handling. They're similar in concept, but share none of the same code... Fixes: ES31-CTS.core.tessellation_shader.single.xfb_captures_data_from_correct_stage and the ES32-CTS and ESEXT-CTS variants. v2: Add a comment (requested by Timothy, written by me). Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Pass ctx to program interface query helper functions.Kenneth Graunke2016-10-271-13/+20
| | | | | | | | | | The next commit will use this in add_shader_variable - this just separates out some of the mechanical changes for easier review. Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Add pthread libs to cache_testRhys Kidd2016-10-271-1/+4
| | | | | | | | | | | Fixes the following compile error, present when the SHA1 library is libgcrypt: CCLD glsl/tests/cache-test glsl/.libs/libglsl.a(libmesautil_la-mesa-sha1.o): In function `call_once': /mesa/src/util/../../include/c11/threads_posix.h:96: undefined reference to `pthread_once' Signed-off-by: Rhys Kidd <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* compiler: avoid warning about redefinition of PYTHON_GENErik Faye-Lund2016-10-263-3/+1
| | | | | | | | | | | | PYTHON_GEN is defined to the exact same thing in both Makefile.glsl.am and Makefile.nir.am. This makes automake complain, so let's lift the definition up to Makefile.am, the same way as MKDIR_GEN. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Tested-by: Eric Engestrom <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* compiler: automake: add shader_info.h to the sources listEmil Velikov2016-10-261-1/+2
| | | | | | | Otherwise it'll be missing from the tarball. Fixes: 094fe3a9591 ("nir: move nir_shader_info to a common compiler header") Signed-off-by: Emil Velikov <[email protected]>
* glsl: update default precision qualifier when it is set in the shaderSamuel Iglesias Gonsálvez2016-10-261-1/+4
| | | | | | | | | | | | Default precision qualifier for a data type could be set several times inside a shader. This patch allows to update the default precision qualifier for the given type that is saved in the symbol table. If it is not in the symbol table, just add it. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97804 Reviewed-by: Timothy Arceri <[email protected]>
* nir: stop adjusting driver location for varying packingTimothy Arceri2016-10-262-47/+2
| | | | | | | | | | | | As of 59864e8e020 we just use the location assigned by the front-end and no longer need this for i965. Since there were some issues in the logic with assigning arrays the same driver location if they didn't start at the same location just remove it and let other drivers implement a solution if needed when they add ARB_enhanced_layouts support. Reviewed-by: Kenneth Graunke <[email protected]>
* compiler: remove copy_shader_info()Timothy Arceri2016-10-262-35/+1
| | | | | | | This temporary helper is no longer needed now that we have finished refactoring common shader metadata. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: set uses texture gather directly in shader_infoTimothy Arceri2016-10-262-3/+1
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl/st/mesa: use common system values read fieldTimothy Arceri2016-10-262-3/+2
| | | | | | | | | And set system values read directly in shader_info. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: set patch outputs written directly in shader_infoTimothy Arceri2016-10-262-3/+2
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: set patch inputs read directly in shader_infoTimothy Arceri2016-10-262-3/+2
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: set outputs read directly in shader_infoTimothy Arceri2016-10-262-3/+2
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* r200/glsl/st/mesa: use common outputs written fieldTimothy Arceri2016-10-262-7/+6
| | | | | | | | | And set outputs written directly in shader_info. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/glsl: set double inputs read directly in shader_infoTimothy Arceri2016-10-262-2/+1
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* r200/i915/st/mesa/compiler: use common inputs read fieldTimothy Arceri2016-10-262-7/+6
| | | | | | | | | | | | And set set inputs_read directly in shader_info. To avoid regressions between changes this change is a squashed version of the following patches. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/compiler: copy early fragment tests to shader_info in ↵Timothy Arceri2016-10-261-4/+0
| | | | | | _mesa_copy_linked_program_data() Reviewed-by: Jason Ekstrand <[email protected]>
* st/mesa/r200/i915/i965: eliminate gl_fragment_programTimothy Arceri2016-10-261-11/+2
| | | | | | | | | | Here we move OriginUpperLeft and PixelCenterInteger into gl_program all other fields have been replace by shader_info. V2: Don't use anonymous union/structs to hold vertex/fragment fields suggested by Ian. Reviewed-by: Jason Ekstrand <[email protected]>
* i965/mesa/st/swrast: set fs shader_info directly and switch to using itTimothy Arceri2016-10-262-13/+4
| | | | | | | Note we access shader_info from the program struct rather than the nir_shader pointer because shader cache won't create a nir_shader. Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: remove now unused IsCentroid from gl_fragment_programTimothy Arceri2016-10-261-5/+1
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* compiler: update the comment for enum glsl_interp_modeTimothy Arceri2016-10-261-1/+1
| | | | | | We no longer store the interp mode with the program metadata. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: remove now unused InterpQualifierTimothy Arceri2016-10-261-5/+2
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: set cs shader_info metadata directlyTimothy Arceri2016-10-261-9/+0
| | | | Reviewed-by: Jason Ekstrand <[email protected]>