summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* glsl: use util_snprintf()Andres Gomez2018-08-026-27/+34
| | | | | | | | | | | Instead of plain snprintf(). To fix the MSVC 2013 build. Fixes: 6ff0c6f4ebc ("gallium: move ddebug, noop, rbug, trace to auxiliary to improve build times") Cc: Marek Olšák <[email protected]> Cc: Brian Paul <[email protected]> Cc: Roland Scheidegger <[email protected]> Signed-off-by: Andres Gomez <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: make a copy of array indices that are used to deref a function out paramTimothy Arceri2018-08-021-0/+54
| | | | | | | Fixes new piglit test: tests/spec/glsl-1.20/execution/qualifiers/vs-out-conversion-int-to-float-vec4-index.shader_test Reviewed-by: Ian Romanick <[email protected]>
* nir/lower_indirect: Bail early if modes == 0Jason Ekstrand2018-08-011-0/+3
| | | | | | | There's no point in walking the program if we're never going to actually lower anything. Reviewed-by: Timothy Arceri <[email protected]>
* nir/meson: fix c vs cpp args for nir testDylan Baker2018-08-011-1/+1
| | | | | | | Fixes: d1992255bb29054fa51763376d125183a9f602f3 ("meson: Add build Intel "anv" vulkan driver") Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* python: Explicitly add the 'L' suffix on Python 3Mathieu Bridon2018-08-011-1/+10
| | | | | | | | | | | | | | | Python 2 had two integer types: int and long. Python 3 dropped the latter, as it made the int type automatically support bigger numbers. As a result, Python 3 lost the 'L' suffix on integer litterals. This probably doesn't make much difference when compiling the generated C code, but adding it explicitly means that both Python 2 and 3 generate the exact same C code anyway, which makes it easier to compare and check for discrepencies when moving to Python 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* python: Don't abuse hex()Mathieu Bridon2018-08-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The hex() builtin returns a string containing the hexa-decimal representation of an integer. When the argument is not an integer, then the function calls that object's __hex__() method, if one is defined. That method is supposed to return a string. While that's not explicitly documented, that string is supposed to be a valid hexa-decimal representation for a number. Python 2 doesn't enforce this though, which is why we got away with returning things like 'NIR_TRUE' which are not numbers. In Python 3, the hex() builtin instead calls an object's __index__() method, which itself must return an integer. That integer is then automatically converted to a string with its hexa-decimal representation by the rest of the hex() function. As a result, we really can't make this compatible with Python 3 as it is. The solution is to stop using the hex() builtin, and instead use a hex() object method, which can return whatever we want, in Python 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* glsl: fix function inlining with opaque parametersRhys Perry2018-08-011-8/+44
| | | | | | Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl, glsl_to_tgsi: fix sampler/image constantsRhys Perry2018-08-011-2/+30
| | | | | Signed-off-by: Rhys Perry <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl: allow ?: operator with images and samplers when bindless is enabledRhys Perry2018-08-011-3/+5
| | | | | Signed-off-by: Rhys Perry <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* nir/linker: Add the start of a pure-NIR linker for XFBNeil Roberts2018-07-314-0/+321
| | | | | | | | | | | | | | | | | | | | v2: ignore names on purpose, for consistency with other places where we are doing the same (Alejandro) v3: changes proposed by Timothy Arceri, implemented by Alejandro Piñeiro: * Remove redundant 'struct active_xfb_varying' * Update several comments, including spec quotes if needed * Rename struct 'active_xfb_varying_array' to 'active_xfb_varyings' * Rename variable 'array' to 'active_varyings' * Replace one if condition for an assert (<MAX_FEEDBACK_BUFFERS) * Remove BufferMode initialization (was already done) v4: simplify output pointer handling (Timothy) Signed-off-by: Neil Roberts <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir/types: Add a wrapper to access gl_typeNeil Roberts2018-07-312-0/+8
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* compiler/spirv: add XFB and GeometryStreams capability check supportAlejandro Piñeiro2018-07-312-2/+10
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* nir/gather_info: Set info.gs.uses_streamsNeil Roberts2018-07-311-0/+5
| | | | | | | | | | | Whenever a non-zero stream is written to it now sets uses_streams to true. This reflects the code in validate_geometry_shader_emissions for GLSL. v2: set uses_streams at gather_info instead that at spirv to nir (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
* spirv/nir: Fix the stream ID when emitting a primitive or vertexNeil Roberts2018-07-311-2/+5
| | | | | | | | | It looks like it was previously taking the SPIR-V instruction number directly instead of looking up the constant value. v2: use vtn_constant_value helper (Jason) Reviewed-by: Jason Ekstrand <[email protected]>
* spirv: Handle the SpvDecorationStream decorationNeil Roberts2018-07-312-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | From SPIR-V 1.0 spec, section 3.20, "Decoration": "Stream Apply to an object or a member of a structure type. Indicates the stream number to put an output on." Note the "or", so that means that it is allowed for both a full struct or a membef or a struct (although the wording is not really ideal, and somewhat error-prone, imho). We found this with some Geometry Streams tests for ARB_gl_spirv, where the full gl_PerVertex is assigned Stream 0 (default value on OpenGL for gl_PerVertex). So this commit allows structs to have this Decoration, and sets the stream at the nir variable if needed. Signed-off-by: Neil Roberts <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> v2: squash two Decoration Stream patches (Jason) Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* spirv: Handle XFB variable decorationsNeil Roberts2018-07-311-3/+9
| | | | | | | | | These set the new explicit XFB members on nir_variable. This is needed to support ARB_gl_spirv, as Vulkan doesn't support transform feedback. Reviewed-by: Timothy Arceri <[email protected]>
* spirv: Handle SpvExecutionModeXfbNeil Roberts2018-07-311-1/+1
| | | | | | This just sets has_transform_feedback_varyings on the shader. Reviewed-by: Timothy Arceri <[email protected]>
* nir: Add members for the explicit XFB properties to nir_variableNeil Roberts2018-07-312-1/+30
| | | | | | | | These are copied from the from the corresponding values in ir_variable. The intention is to eventually use them in a pure-NIR linker. Reviewed-by: Timothy Arceri <[email protected]>
* nir/instr_set: Fix nir_instrs_equal for derefsJason Ekstrand2018-07-291-2/+2
| | | | | | | | | | | | We weren't returning at the end of the nir_isntr_type_deref case in nir_instrs_equal and it was falling through to the default of false. While we're at it, make the default unreachable because all statements in the switch now have their own returns. Had we done that before, we would have caught this bug a long time ago. Fixes: 19a4662a540a8c94 "nir: Add a deref instruction type" Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Reviewed-by: Thomas Helland<[email protected]>
* nir: Take if uses into account in ssa_def_components_readJason Ekstrand2018-07-291-0/+3
| | | | | Fixes: d800b7daa5440 "nir: Add a helper for figuring out what..." Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* nir/lower_int64: mark all metadata as dirtyKarol Herbst2018-07-281-0/+3
| | | | | | | | | v2: use nir_metadata_preserve preserve metadata in case of !progress Fixes: 074f5ba0b56b12ddaca81eac3d9ed19da7054297 "nir: Add a simple int64 lowering pass" Signed-off-by: Karol Herbst <[email protected]>
* glsl: use only copy_propagation_elementsCaio Marcelo de Oliveira Filho2018-07-276-375/+0
| | | | | | | | Now that the elements version handles both cases, remove the non-elements version. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* glsl: teach copy_propagation_elements to deal with whole variablesCaio Marcelo de Oliveira Filho2018-07-271-29/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Keep information in acp_entry whether the entry is full or not, and use the ACP in more nodes when visiting the instructions: - add_copy: write whole variables to the ACP state (regardless the type). - visit(ir_dereference_variable *): perform the propagation here if we have a full candidate. Element-wise here doesn't apply because the mask isn't available at this point. - visit_leave(ir_assignment *): process beyond scalar and vector, as the full variables might have other types. Also import an improvement from opt_copy_propagation.cpp: if ir_call is an intrinsic, we know the variables affected, so keep going. v2: (all from Eric Anholt) Describe how acp_entry attributes are used. Don't do book-keeping to avoid adding repeated element to the dsts in write_elements(). v3: Use _mesa_set_remove_key. (Thomas Helland) Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* i965: Combine both gl_PatchVerticesIn lowering passes.Kenneth Graunke2018-07-262-7/+64
| | | | | | | | | | | | | | | | | | Until now, we had separate passes for lowering gl_PatchVerticesIn to a statically known constant (for TES inputs when linked against a TCS), and a uniform in the other cases. Annoyingly, one had to be run before nir_lower_system_values, and the other afterward. This simplified the passes, but made life painful for the callers. This patch combines both into a single pass. If you give it a non-zero static count, it uses that. If you give it Mesa state slots, it turns it back into a built-in uniform. Otherwise, it does nothing. This also moves the i965 uniform lowering out to shared code. v2: Make token arrays const. Reviewed-by: Eric Anholt <[email protected]>
* nir: Add flipping of gl_PointCoord.y in nir_lower_wpos_ytransform.Eric Anholt2018-07-262-0/+32
| | | | | | | This is controlled by a new nir_shader_compiler_options flag, and fixes dEQP-GLES3.functional.shaders.builtin_variable.pointcoord on V3D. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: remove wrong assertion in print_var_decl()Samuel Pitoiset2018-07-261-1/+0
| | | | | | | | | This breaks printing input/output variables with more than 4 components like mat4. Fixes: 1beef89ad8 ("nir: prepare for bumping up max components to 16") Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* nir: Add a couple of iand/ior optimizationsJason Ekstrand2018-07-241-0/+4
| | | | | | Spotted in a shader in Batman: Arkham City. Reviewed-by: Timothy Arceri <[email protected]>
* nir/serialize: Alloc constants off the variableJason Ekstrand2018-07-241-1/+1
| | | | | | | | | | | nir_sweep assumes that constants area always allocated off the variable to which they belong. Violating this assumption causes them to get freed early and leads to use-after-free bugs. Fixes: 120da00975541 "nir: add serialization and deserialization" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107366 Reviewed-by: Lionel Landwerlin <[email protected]> Tested-by: Mark Janes <[email protected]>
* nir: rename f2f16_undef to f2f16Karol Herbst2018-07-242-6/+6
| | | | | | | | | | | we need rounding modes on other conversions involving floats and it is easier to rename f2f16_undef than renaming all the other ones. v2: rebased on master Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Rob Clark <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir: add builtin builderKarol Herbst2018-07-245-45/+166
| | | | | | | | | | | also move some of the GLSL builtins over we will need for implementing some OpenCL builtins v2: replace NIR_IMM_FP by nir_imm_floatN_t in ported code fix up changes caused by swizzle rework Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir/spirv: import OpenCL.std.hRob Clark2018-07-241-0/+211
| | | | | | | | | Lightly edited to be valid 'C' code. Is there a bug open to fix this upstream? Acked-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* python: Use range() instead of xrange()Mathieu Bridon2018-07-242-3/+3
| | | | | | | | | | | | | | | | Python 2 has a range() function which returns a list, and an xrange() one which returns an iterator. Python 3 lost the function returning a list, and renamed the function returning an iterator as range(). As a result, using range() makes the scripts compatible with both Python versions 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* python: Better use iteratorsMathieu Bridon2018-07-242-3/+5
| | | | | | | | | | | | | | | | | In Python 2, iterators had a .next() method. In Python 3, instead they have a .__next__() method, which is automatically called by the next() builtin. In addition, it is better to use the iter() builtin to create an iterator, rather than calling its __iter__() method. These were also introduced in Python 2.6, so using it makes the script compatible with Python 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* python: Better iterate over dictionariesMathieu Bridon2018-07-246-8/+8
| | | | | | | | | | | | | | | | In Python 2, dictionaries have 2 sets of methods to iterate over their keys and values: keys()/values()/items() and iterkeys()/itervalues()/iteritems(). The former return lists while the latter return iterators. Python 3 dropped the method which return lists, and renamed the methods returning iterators to keys()/values()/items(). Using those names makes the scripts compatible with both Python 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* nir: add 16bit type information to glsl typesDaniel Schürmann2018-07-233-0/+28
| | | | Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* nir: Add a couple trivial abs optimizationsJason Ekstrand2018-07-231-0/+2
| | | | | | | Spotted in a shader in Batman: Arkham City. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: remove delegating constructors to allow build with C++98Caio Marcelo de Oliveira Filho2018-07-231-6/+8
| | | | | | | | | | | | | | Delegating constructors is a C++11 feature, so this was breaking when compiling with C++98. Change the copy_propagation_state() calls that used the convenience constructor to use a static member function instead. Since copy_propagation_state is expected to be heap allocated, this change is a good fit. Tested-by: Vinson Lee <[email protected]> Reviewed-by: Matt Turner <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107305
* spirv: add support for SPV_KHR_post_depth_coverageIlia Mirkin2018-07-222-0/+10
| | | | | | | | | Allow the capability to be exposed, and convert the new execution mode into fs state. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* Android: fix a missing nir_intrinsics.h errorChih-Wei Huang2018-07-211-0/+1
| | | | | | | | | | | | | | | | | | | | | The commit 76dfed8ae2d5 changed nir_intrinsics.h to be a generated header, but the corresponding dependency was not updated for Android. It causes the error: [ 0% 19/4336] target C: libmesa_pipe_radeonsi <= external/mesa/src/gallium/drivers/radeonsi/si_debug.c ... In file included from external/mesa/src/gallium/drivers/radeonsi/si_debug.c:25: In file included from external/mesa/src/gallium/drivers/radeonsi/si_pipe.h:28: In file included from external/mesa/src/gallium/drivers/radeonsi/si_shader.h:140: In file included from external/mesa/src/amd/common/ac_llvm_build.h:30: external/mesa/src/compiler/nir/nir.h:966:10: fatal error: 'nir_intrinsics.h' file not found ^~~~~~~~~~~~~~~~~~ 1 error generated. Fixes: 76dfed8ae2d5 ("nir: mako all the intrinsics") Signed-off-by: Chih-Wei Huang <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Mauro Rossi <[email protected]>
* nir: Fix end of function without return warning/error.Bas Nieuwenhuizen2018-07-201-0/+2
| | | | | | | | | There always is a continue block, so let us just do unreachable. Reviewed-by: Jason Ekstrand <[email protected]> Fixes: 8cacf38f527 "nir: Do not use continue block after removing it." CC: 18.1 <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107312
* nir: Do not use continue block after removing it.Bas Nieuwenhuizen2018-07-201-6/+25
| | | | | | | | | | | | | | | | Reinserting code directly before a jump means the block gets split and merged, removing the original block and replacing it in the process. Hence keeping a pointer to the continue block over a reinsert causes issues. This code changes nir_opt_if to simply look for the new continue block. Reviewed-by: Jason Ekstrand <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107275 CC: 18.1 <[email protected]>
* glsl: don't let an 'if' then-branch kill copy propagation (elements) for ↵Caio Marcelo de Oliveira Filho2018-07-191-19/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | else-branch When handling 'if' in copy propagation elements, if a certain variable was killed when processing the first branch of the 'if', then the second would get any propagation from previous nodes. x = y; if (...) { z = x; // This would turn into z = y. x = 22; // x gets killed. } else { w = x; // This would NOT turn into w = y. } With the change, we let copy propagation happen independently in the two branches and only then apply the killed values for the subsequent code. One example in shader-db part of shaders/unity/8.shader_test: (assign (xyz) (var_ref col_1) (var_ref tmpvar_8) ) (if (expression bool < (swiz y (var_ref xlv_TEXCOORD0) )(constant float (0.000000)) ) ( (assign (xyz) (var_ref col_1) (expression vec3 + (var_ref tmpvar_8) ... ) ... ) ) ( (assign (xyz) (var_ref col_1) (expression vec3 lrp (var_ref col_1) ... ) ... ) )) The variable col_1 was replaced by tmpvar_8 in the then-part but not in the else-part. NIR deals well with copy propagation, so it already covered for the missing ones that this patch fixes. Reviewed-by: Eric Anholt <[email protected]>
* glsl: change opt_copy_propagation_elements data structuresCaio Marcelo de Oliveira Filho2018-07-191-117/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of keeping multiple acp_entries in lists, have a single acp_entry per variable. With this, the implementation of clone is more convenient and now fully implemented. In the previous code, clone was only partial. Before this patch, each acp_entry struct represented a write to a variable including LHS, RHS and a mask of what channels were written to. There were two main hash tables, the first (lhs_ht) stored a list of acp_entries per LHS variable, with the values available to copy for that variable; the second (rhs_ht) was a "reverse index" for the first hash table, so stored acp_entries per RHS variable. After the patch, there's a single acp_entry struct per LHS variable, it contains an array with references to the RHS variables per channel. There now is a single hash table, from LHS variable to the corresponding entry. The "reverse index" is stored in the ACP entry, in the form of a set of variables that copy from the LHS. To make the clone operation cheaper, the ACP entries are created on demand. This should not change the result of copy propagation, a later patch will take advantage of the clone operation. v2: Add note clarifying how the hashtable is destroyed. v3: (all from Eric Anholt) Add remove_unused_var_from_dsts() function for reuse. Remove from dsts as we go instead of clearing at the end. Add clarifying comment to erase(). Reviewed-by: Eric Anholt <[email protected]>
* glsl: separate copy propagation stateCaio Marcelo de Oliveira Filho2018-07-191-126/+142
| | | | | | | | | | | Separate higher level logic of visiting instructions and chosing when to store and use new copy data from the datastructure holding the copy propagation information. This will also make easier later patches that change the structure. v2: Remove empty destructor and clarify how hash tables are destroyed. Reviewed-by: Eric Anholt <[email protected]>
* glsl: remove unnecessary parenthesis from macroCaio Marcelo de Oliveira Filho2018-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The "__inst" will contain the name used for the variable of type "__type *". Parenthesis is not necessary as the name itself shouldn't be an expression. Fixes warning: In file included from ../../src/mesa/main/mtypes.h:49, from ../../src/intel/compiler/brw_compiler.h:30, from ../../src/intel/compiler/brw_shader.h:29, from ../../src/intel/compiler/brw_fs.h:31, from ../../src/intel/compiler/brw_fs_cse.cpp:24: ../../src/intel/compiler/brw_fs_cse.cpp: In member function ‘bool fs_visitor::opt_cse_local(bblock_t*)’: ../../src/compiler/glsl/list.h:675:12: warning: unnecessary parentheses in declaration of ‘entry’ [-Wparentheses] __type *(__inst); \ ^ ../../src/intel/compiler/brw_fs_cse.cpp:257:10: note: in expansion of macro ‘foreach_in_list_use_after’ foreach_in_list_use_after(aeb_entry, entry, &aeb) { ^~~~~~~~~~~~~~~~~~~~~~~~~ Reviewed-by: Anuj Phogat <[email protected]>
* spirv: initialize is_vertex_inputCaio Marcelo de Oliveira Filho2018-07-181-3/+1
| | | | | | | | | | | | | | | Fixes warning: ../../src/compiler/spirv/vtn_variables.c: In function ‘var_decoration_cb’: ../../src/compiler/spirv/vtn_variables.c:1400:12: warning: ‘is_vertex_input’ may be used uninitialized in this function [-Wmaybe-uninitialized] bool is_vertex_input; ^~~~~~~~~~~~~~~ The code used to set is_vertex_input in all possible codepaths, but after 23edc5b1ef3 "spirv: translate default-block uniforms" the compiler isn't sure all codepaths will initialize the variable. Reviewed-by: Anuj Phogat <[email protected]>
* nir: add lowering for gl_HelperInvocationRob Clark2018-07-183-0/+34
| | | | | | | | | v2: reword comment about lower_helper_invocations to be more clear that it might not work on all hardware v3: add special variant of load_sample_id which does not imply per- sample shading Signed-off-by: Rob Clark <[email protected]>
* nir: fixup intrinsic commentRob Clark2018-07-181-1/+1
| | | | | | | Now the deref is the first src. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: add a couple of ior opts to nir_opt_algebraicTimothy Arceri2018-07-181-0/+3
| | | | | | One of these was seen in a Deus Ex shader. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: allow opt_peephole_select to handle nir_instr_type_derefTimothy Arceri2018-07-181-0/+1
| | | | Reviewed-by: Jason Ekstrand <[email protected]>