summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* nir: Fix setup of constant bool initializers.Eric Anholt2015-01-221-1/+1
| | | | | | | | | | brw_fs_nir has only seen scalar bools so far, thanks to vector splitting, and the ralloc of in glsl_to_nir.cpp will *usually* get you a 0-filled chunk of memory, so reading too large of a value will usually get you the right bool value. But once we start doing vector bools in a few commits, we end up getting bad values. Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
* nir: Make an easier helper for setting up SSA defs.Eric Anholt2015-01-2213-66/+46
| | | | | | | | Almost all instructions we nir_ssa_def_init() for are nir_dests, and you have to keep from forgetting to set is_ssa when you do. Just provide the simpler helper, instead. Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
* glsl: Link glsl_test with pthreads library.Jonathan Gray2015-01-221-1/+3
| | | | | | | | | | Otherwise pthread_mutex_lock will be an undefined reference on OpenBSD. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88219 Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
* glsl: do not allow interface block to have name already takenTapani Pälli2015-01-221-1/+15
| | | | | | | | | | Fixes currently failing Piglit case interface-blocks-name-reused-globally.vert v2: combine var declaration with assignment (Ian) Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* nir: Replace assert(0) with unreachable().Matt Turner2015-01-214-43/+22
| | | | | | Fixes a couple of warnings in the process. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Stop using designated initializersJason Ekstrand2015-01-2110-105/+47
| | | | | | | | | Designated initializers with anonymous unions don't work in MSVC or GCC < 4.6. With a couple of constructor methods, we don't need them any more and the code is actually cleaner. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88467 Reviewed-by: Connor Abbot <cwabbott0@gmail.com>
* nir: Add src and dest constructorsJason Ekstrand2015-01-211-0/+37
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a nir_foreach_phi_src helper macroJason Ekstrand2015-01-209-11/+14
| | | | Reviewed-by: Connor Abbott <cwabbott02gmail.com>
* mesa: Add ARB_shader_precision infrastructureMicah Fedke2015-01-193-0/+6
| | | | | Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
* nir: s/malloc.h/stdlib.h/Vinson Lee2015-01-161-1/+1
| | | | | | | | | | | Fix build error on Mac OS X. CC nir_to_ssa.lo nir_to_ssa.c:29:10: fatal error: 'malloc.h' file not found ^ Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88478 Signed-off-by: Vinson Lee <vlee@freedesktop.org>
* glsl: Add unit tests for blob.cCarl Worth2015-01-163-0/+328
| | | | | | In addition to exercising all of the functions in blob.h, this includes a stress test that forces some reallocing, and also tests to verify the alignment and overrun-detection code in blob.c.
* glsl: Add blob_overwrite_bytes and blob_overwrite_uint32Tapani Pälli2015-01-162-0/+66
| | | | | | | | | | | | | | | | | | These functions are useful when serializing an unknown number of items to a blob. The caller can first save the current offset, write a placeholder uint32, write out (and count) the items, then use blob_overwrite_uint32 with the saved offset to replace the placeholder value. Then, when deserializing, the reader will first read the count and know how many subsequent items to expect. (I wrote this code after reading a very similar patch written by Tapani when he wrote serialization code for IR. Since I re-used the idea of his code so directly, I've credited him as the author of this code. --Carl) Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
* glsl: Add blob.c---a simple interface for serializing dataCarl Worth2015-01-163-0/+548
| | | | | | | | | | | | | | | This new interface allows for writing a series of objects to a chunk of memory (a "blob").. The allocated memory is maintained within the blob itself, (and re-allocated by doubling when necessary). There are also functions for reading objects from a blob as well. If code attempts to read beyond the available memory, the read functions return 0 values (or its moral equivalent) without reading past the allocated memory. Once the caller is done with the reads, it can check blob->overrun to ensure whether any invalid values were previously returned due to attempts to read too far. Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
* glsl: Add convenience function get_sampler_instanceCarl Worth2015-01-162-0/+120
| | | | | | | | | | This is similar to the existing functions get_instance, get_array_instance, etc. for getting a type singleton. The new get_sampler_instance() function will be used by the upcoming shader cache. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
* nir/live_variables: Use a worklistJason Ekstrand2015-01-151-55/+75
| | | | | | | | | | This is a rework of the liveness algorithm using a worklist as suggested by Connor. Doing so reduces the number of times we walk over the instructions because we don't have to do an entire pointless walk over the instructions just to figure out it's time to stop. Also, the stuff after the last loop in the funciton will only ever get visited once. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a worklist helper structureJason Ekstrand2015-01-153-0/+237
| | | | | | | A worklist is a common concept in optimizations. This adds a structure that we can reuse for many different types of optimizations. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: fix incorrect argument passed to validate_src() in validate_tex_instr()Brian Paul2015-01-151-1/+1
| | | | | | Silences a compiler warning. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: silence compiler warning from visit_src() callBrian Paul2015-01-151-1/+1
| | | | | | v2: use proper argument Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* util/hash_set: Rework the API to know about hashingJason Ekstrand2015-01-159-103/+76
| | | | | | | | | | | | | | | | | | | | | | | | Previously, the set API required the user to do all of the hashing of keys as it passed them in. Since the hashing function is intrinsically tied to the comparison function, it makes sense for the hash set to know about it. Also, it makes for a somewhat clumsy API as the user is constantly calling hashing functions many of which have long names. This is especially bad when the standard call looks something like _mesa_set_add(ht, _mesa_pointer_hash(key), key); In the above case, there is no reason why the hash set shouldn't do the hashing for you. We leave the option for you to do your own hashing if it's more efficient, but it's no longer needed. Also, if you do do your own hashing, the hash set will assert that your hash matches what it expects out of the hashing function. This should make it harder to mess up your hashing. This is analygous to 94303a0750 where we did this for hash_table Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* util: Move main/set to util/hash_setJason Ekstrand2015-01-151-1/+1
| | | | | Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* hash_table: Rename insert_with_hash to insert_pre_hashedJason Ekstrand2015-01-151-1/+1
| | | | | | | We already have search_pre_hashed. This makes the APIs match better. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* nir/algebraic: Only replace an instruction onceJason Ekstrand2015-01-151-1/+3
| | | | | | | | | Without the break, it was possible that an instruction would match multiple expressions. If this happened, you could end up trying to replace it multiple times and get a segfault. This makes it so that, after a successful replacement, it moves on to the next instruction. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/vars_to_ssa: Use the copy lowering from lower_var_copiesJason Ekstrand2015-01-151-152/+46
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add a pass for lowering copy instructionsJason Ekstrand2015-01-153-0/+227
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/vars_to_ssa: Refactor get_deref_nodeJason Ekstrand2015-01-151-20/+25
| | | | | | | | This refactor allows you to more easily get the deref node associated with a given variable. We then use that new functionality in the deref_may_be_aliased function instead of creating a 1-element deref chain. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Rename lower_variables to lower_vars_to_ssaJason Ekstrand2015-01-153-5/+5
| | | | | | | | The original name wasn't particularly descriptive. This one indicates that it actually gives you SSA values as opposed to the old pass which lowered variables to registers. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/tex_instr: Add a nir_tex_src struct and dynamically allocate the src arrayJason Ekstrand2015-01-156-40/+48
| | | | | | | | This solves a number of problems. First is the ability to change the number of sources that a texture instruction has. Second, it solves the delema that may occur if a texture instruction has more than 4 sources. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/validate: Only build in debug modeJason Ekstrand2015-01-152-0/+11
| | | | | | Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/lower_variables: Improve documentationJason Ekstrand2015-01-151-27/+79
| | | | | | | | Additional description was added to a variety of places. Also, we no longer use the term "leaf" to describe fully-qualified direct derefs. Instead, we simply use the term "direct" or spell it out completely. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/lower_variables: Use a for loop for get_deref_nodeJason Ekstrand2015-01-151-58/+48
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Use the actual FNV-1a hash for hashing derefsJason Ekstrand2015-01-152-90/+79
| | | | | | We also switch to using loops rather than recursion. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Make intrinsic flags into an enumJason Ekstrand2015-01-151-14/+14
| | | | | | | | This should be much better for debugging as GDB will pick up on the fact that it's an enum and actually tell you what you're looking at instead of giving you some arbitrary hex value you have to go look up. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Use static inlines instead of macros for list gettersJason Ekstrand2015-01-151-28/+81
| | | | | | | | This should make debugging a lot easier as GDB handles static inlines much better than macros. Also, static inlines are typesafe. Reviewed-By: Glenn Kennard <glenn.kennard@gmail.com> Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/variable: Remove the constant_value fieldJason Ekstrand2015-01-152-16/+4
| | | | | | | | | This was a left-over relic of GLSL IR that we aren't using for anything. If we ever want that value again, we can add it back, but NIR constant folding should be just as good as GLSL IR's if not better pretty soon, so I'm not worried about it. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Add some documentationJason Ekstrand2015-01-151-22/+69
| | | | | Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/lower_variables: Follow the Cytron paper more closelyJason Ekstrand2015-01-151-26/+69
| | | | | | | | | | Previously, our variable renaming algorithm, while similar to the one in the Cytron paper, was not the same. While I'm pretty sure it was correct, it will be easier for readers of the code in the variable renaming pass if it follows more closely. This commit removes the automatic stack popping we were doing and replaces it with explicit popping like Cytron does. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/print: Various cleanups recommended by EricJason Ekstrand2015-01-151-33/+12
| | | | | Cc: Eric Anholt <eric@anholt.net> Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/lower_variables: Add a bunch of comments and re-arrange a few thingsJason Ekstrand2015-01-151-57/+170
| | | | | | | | This commit seeks to make the lower_variables pass much more clear by adding a pile of comments and re-arranging a few things. There are no functional or algorithmic changes. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Rename parallel_copy_copy to parallel_copy_entry and add a foreach macroJason Ekstrand2015-01-154-46/+55
| | | | | | | | | | parallel_copy_copy was a silly name. Also, things were getting long and annoying, so I added a foreach macro. For historical reasons, several of the original iterations over parallel copy entries in from_ssa used the _safe variants of the loop. However, all of these no longer ever remove an entry so it's ok to make them all use the normal iterator. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/from_ssa: Clean up parallel copy handling and document it betterJason Ekstrand2015-01-153-66/+92
| | | | | | | | | | | | | | | Previously, we were doing a lazy creation of the parallel copy instructions. This is confusing, hard to get right, and involves some extra state tracking of the copies. This commit adds an extra walk over the basic blocks to add the block-end parallel copies up front. This should be much less confusing and, consequently, easier to get right. This commit also adds more comments about parallel copies to help explain what all is going on. As a consequence of these changes, we can now remove the at_end parameter from nir_parallel_copy_instr. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Rename nir_block_following_if to nir_block_get_following_ifJason Ekstrand2015-01-155-5/+5
| | | | | | The new name is a little longer but less confusing. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/opcodes: Remove the per_component info fieldJason Ekstrand2015-01-153-37/+33
| | | | | | | | | | | Originally, this field was intended for determining if the given instruction acted per-component or if it had mismatching source and destination sizes that would have to be interpreted specially. However, we can easily derive this from output_size == 0, so it's not really that useful. Also, the values we were setting in nir_opcodes.h for this field were completely bogus and it was never used. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/search: Use nir_op_infos to determine if an operation is commutativeJason Ekstrand2015-01-151-33/+2
| | | | | | | Prior to this commit, we had a big switch statement for this. Now it's baked into the opcode metadata so we can just use that. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/opcodes: Add algebraic properties metadataJason Ekstrand2015-01-153-71/+89
| | | | | | | | | | | | | | | | | | This commit adds some algebraic properties to the metadata of each opcode in NIR. In particular, you now know, just from the metadata, if a given opcode is commutative or associative. This will be useful for algebraic transformation passes that want to be able to match a + b as well as b + a in one go. v2: Make algebraic properties all caps. This was more consistent with the intrinsics flags and seems better for flags in general. Also, the enums are now declared with (1 << n) rather then hex values. v3: fmin and fmax technically aren't commutative or associative. Things get funny when one of the arguments is a NaN. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Make load_const SSA-onlyJason Ekstrand2015-01-1514-136/+51
| | | | | | | | As it was, we weren't ever using load_const in a non-SSA way. This allows us to substantially simplify the load_const instruction. If we ever need a non-SSA constant load, we can do a load_const and an imov. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Make nir_ssa_undef_instr_create initialize the destinationJason Ekstrand2015-01-154-13/+11
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/lower_system_values: Handle SSA destinationsJason Ekstrand2015-01-151-1/+14
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/lower_atomics: Use/support SSAJason Ekstrand2015-01-151-18/+32
| | | | | | | | | | | Previously, lower_atomics was non-SSA only. We assert-failed if the destination of an atomic operation intrinsic was an SSA def and we used temporary registers for computing offsets. This commit changes both of these behaviors. We now use SSA values for computing offsets (so we can optimize them) and we handle SSA destinations. We also move the pass to run before we go out of SSA on i965 as it now generates SSA values. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir/live_variables: Use the new ssa_def iteratorJason Ekstrand2015-01-151-19/+13
| | | | Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
* nir: Use nir_foreach_ssa_def for setting up ssa destinationsJason Ekstrand2015-01-151-13/+11
| | | | | | | | | | | | Before, we were using foreach_dest and switching on whether the destination was an SSA value. This works, except not all destinations are SSA values so we have to special-case ssa_undef instructions. Now that we have a foreach_ssa_def function, we can iterate over all of the register destinations in one pass and iterate over the SSA destinations in a second. This way, if we add other ssa-only instructions, we won't have to worry about adding them to the special case we have for ssa_undef. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>