summaryrefslogtreecommitdiffstats
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* util/set: Assert that keys are not reserved pointersJason Ekstrand2019-06-061-0/+10
| | | | | | | | | | | If we insert a NULL key, it will appear to succeed but will mess up entry counting. Similar errors can occur if someone accidentally inserts the deleted key. The later is highly unlikely but technically possible so we should guard against it too. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* util/hash_table: Use fast modulo computationConnor Abbott2019-05-312-37/+52
| | | | | | | | While we're here, copy the size table from set.c to get rid of hard tabs in the hash_table.c version. Reviewed-by: Eric Anholt <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* util/set: Use fast modulo computationConnor Abbott2019-05-312-37/+52
| | | | | | | | | | | | Compilation times with my shader-db database: Difference at 95.0% confidence -1.22312 +/- 0.726033 -0.283979% +/- 0.168254% (Student's t, pooled s = 1.02177) Reviewed-by: Eric Anholt <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* util: Add a helper for faster remaindersConnor Abbott2019-05-314-0/+206
| | | | | | | | | | This should be at least as fast as using fast_idiv_by_const, and has the advantage that the precomputation is simple enough to be evaluated at Mesa-compile time for hash tables and sets which have a fixed table of possible divisors. Acked-by: Eric Anholt <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* util/hash_table: Add specialized resizing add functionConnor Abbott2019-05-311-1/+27
| | | | | | | To keep it in sync with the set implementation. Reviewed-by: Eric Anholt <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* util/set: Add specialized resizing add functionConnor Abbott2019-05-311-3/+23
| | | | | | | | | | | | | | | | | | | | A significant portion of the time spent in nir_opt_cse for the Dolphin ubershaders was in resizing the set. When resizing a hash table, we know in advance that each new element to be inserted will be different from every other element, so we don't have to compare them, and there will be no tombstone elements, so we don't have to worry about caching the first-seen tombstone. We add a specialized add function which skips these steps entirely, speeding up resizing. Compile-time results from my shader-db database: Difference at 95.0% confidence -2.29143 +/- 0.845534 -0.529475% +/- 0.194767% (Student's t, pooled s = 1.08807) Reviewed-by: Eric Anholt <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* util/hash_table: Pull out loop-invariant computationsConnor Abbott2019-05-311-14/+13
| | | | | | | | | To keep the set and hash table in sync. Note that some of this had already been done for hash tables, in particular pulling out the hash % ht->size computation. Reviewed-by: Eric Anholt <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* util/set: Pull out loop-invariant computationsConnor Abbott2019-05-311-16/+16
| | | | | | | | | | | | | | | | | | | | | | Unfortunately GCC can't do this for us, probably because we call the key comparison function which GCC can't prove won't modify arbitrary memory. This is a pretty hot function, so do the optimization manually to be sure the compiler will get it right. While we're here, make the computation of the new probe address use a single conditional subtract instead of a modulo, since we know that it won't ever get as big as 2 * ht->size before the modulo. Modulos tend to be pretty expensive operations. shader-db compile time results for my database: Difference at 95.0% confidence -2.24934 +/- 0.69897 -0.516296% +/- 0.159993% (Student's t, pooled s = 0.983684) Reviewed-by: Eric Anholt <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* util/set: Add a _mesa_set_search_or_add() functionConnor Abbott2019-05-313-23/+107
| | | | | | | | | | Unlike _mesa_set_search_and_add(), it doesn't replace an entry if it's found, returning it instead. This is useful for nir_instr_set, where we have to know both the original original instruction and its equivalent. Reviewed-by: Eric Anholt <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* list: add some iterator debugRob Clark2019-05-301-5/+16
| | | | | | | | | | | | Debugging use of unsafe iterators when you should have used the _safe version sucks. Add some DEBUG build support to catch and assert if someone does that. I didn't update the UPPERCASE verions of the iterators. They should probably be deprecated/removed. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Erik Faye-Lund <[email protected]>
* Change a few frequented uses of DEBUG to !NDEBUGMarek Olšák2019-05-291-2/+2
| | | | | | | | debugoptimized builds don't define NDEBUG, but they also don't define DEBUG. We want to enable cheap debug code for these builds. I only chose those occurences that I care about. Reviewed-by: Mathias Fröhlich <[email protected]>
* radeonsi: add drirc workaround for American Truck SimulatorTimothy Arceri2019-05-281-0/+3
| | | | | Reviewed-by: Marek Olšák <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110711
* util: add missing include to build_id.hTimothy Arceri2019-05-201-0/+2
| | | | | | Required to use uint8_t Reviewed-by: Tapani Pälli <[email protected]>
* radeonsi: disable primitive restart for triangles for DiRT RallyMarek Olšák2019-05-161-0/+3
| | | | | | It may decrease performance and it prevents compute-based primitive culling. Acked-by: Nicolai Hähnle <[email protected]>
* util/os_file: always use the 'grow' mechanismEric Engestrom2019-05-161-42/+20
| | | | | | | | | | | | | Use fstat() only to pre-allocate a big enough buffer. This fixes a race where if the file grows between fstat() and read() we would be missing the end of the file, and if the file slims down read() would just fail. Fixes: 316964709e21286c2af5 "util: add os_read_file() helper" Reported-by: Jason Ekstrand <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util/ra: Assert nodes are in-bounds in add_node_interferenceJason Ekstrand2019-05-141-0/+1
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* util/ra: Don't destroy the graph in ra_allocate()Jason Ekstrand2019-05-141-76/+102
| | | | | | | | | | | | We want to be able to call ra_allocate() and, when it fails, mutate the graph and try again rather than re-building the graph from scratch. This commit moves all the scratch bits except the final register allocation (which is really an out value not scratch) into sub-structs named "tmp" to make it clear which things are scratch. It also adds bits to the ra_select() initialization loop to initialize things (since we can't trust rzalloc anymore) and copy q_test and forced_reg over. Reviewed-by: Eric Anholt <[email protected]>
* util/ra: Add a helper for resetting a node's interferenceJason Ekstrand2019-05-142-0/+37
| | | | Reviewed-by: Eric Anholt <[email protected]>
* util/ra: Add helpers for adding nodes to an interference graphJason Ekstrand2019-05-142-20/+72
| | | | Reviewed-by: Eric Anholt <[email protected]>
* util/ralloc: Add helpers for growing zero-initialized memoryJason Ekstrand2019-05-142-0/+87
| | | | | | | Unfortunately, we can't quite follow the standard C conventions for these because ralloc doesn't know the sizes of pointers. Reviewed-by: Eric Anholt <[email protected]>
* util/ra: Improve the performance of ra_simplifyJason Ekstrand2019-05-141-30/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The most expensive part of register allocation is the ra_simplify step which is a fixed-point algorithm with a worst-case complexity of O(n^2) which adds the registers to a stack which we then use later to do the actual allocation. This commit uses bit sets and changes the core loop of ra_simplify to first walk 32-node chunks and then walk each chunk. This lets us skip whole 32-node chunks in one go based on bit operations and compute the minimum q value potentially 32x as fast. Of course, the algorithm still has the same fundamental O(n^2) run-time but the constant is now much lower. In the nasty Aztec Ruins compute shader, this shaves a full four seconds off the 30s compile time for a release build of mesa. In a debug build (needed for accurate stack traces), perf says that ra_select takes 20% of runtime before this patch and only 5-6% of runtime after this patch. It also makes shader-db runs faster. Shader-db results on Kaby Lake: total instructions in shared programs: 15311100 -> 15311100 (0.00%) instructions in affected programs: 0 -> 0 helped: 0 HURT: 0 total cycles in shared programs: 355468050 -> 355468050 (0.00%) cycles in affected programs: 0 -> 0 helped: 0 HURT: 0 Total CPU time (seconds): 2602.37 -> 2524.31 (-3.00%) Reviewed-by: Eric Anholt <[email protected]>
* util/ra: Only update q_total if the reg is not assignedJason Ekstrand2019-05-141-1/+1
| | | | | | | | We only use q_total if the reg is not assigned so there's no point in updating it if the reg is not assigned. This has no known perf benefit but it will reduce churn in a future commit. Reviewed-by: Eric Anholt <[email protected]>
* util/ra: Only update best_optimistic_node if !progressJason Ekstrand2019-05-141-1/+5
| | | | | | | This shaves about half a second off the 30 second compile time of one of the compute shaders in Aztec ruins. Reviewed-by: Eric Anholt <[email protected]>
* util/ra: Make in_stack a bitset in the graphJason Ekstrand2019-05-141-18/+15
| | | | Reviewed-by: Eric Anholt <[email protected]>
* util/ra: Get rid of tabsJason Ekstrand2019-05-142-28/+28
| | | | Reviewed-by: Eric Anholt <[email protected]>
* v3d: Use driconf to expose non-MSAA texture limits for Xorg.Eric Anholt2019-05-132-1/+9
| | | | | | The V3D 4.2 HW has a limit to MSAA texture sizes of 4096. With non-MSAA, we can go up to 7680 (actually probably 8138, but that hasn't been validated by the HW team). Exposing 7680 in X11 will allow dual 4k displays.
* util/set: Add a helper to resize a setJason Ekstrand2019-05-132-0/+16
| | | | | | | | | Often times you don't know how big a set will be and you want the code to just grow it as needed. However, sometimes you do know and you can avoid a lot of rehashing if you just specify a size up-front. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* util/set: Add a search_and_add functionJason Ekstrand2019-05-132-5/+31
| | | | | | | | | This function is identical to _mesa_set_add except that it takes an extra out parameter that lets the caller detect if a replacement happened. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* radeonsi: add config entry for Counter-Strike Global OffensiveTimothy Arceri2019-05-071-0/+3
| | | | | | | | | This fixes rendering issues with gun scopes which is rather important. Cc: "19.0" "19.1" <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100239
* util/drirc: add workarounds for bugs in Doom 3: BFGTimothy Arceri2019-05-061-0/+5
| | | | | | | | This makes the game playable on radeonsi. Cc: "19.0" "19.1" <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110143
* tests/vma: fix build with MSVCDylan Baker2019-05-031-0/+8
| | | | Reviewed-by: Eric Anholt <[email protected]>
* util/tests: Use define instead of VLADylan Baker2019-05-035-20/+25
| | | | | | | To allow the this test to be built with MSVC, which doesn't support VLAs. Reviewed-by: Eric Anholt <[email protected]>
* util/bitset: fix bitset range mask calculations.Dave Airlie2019-05-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | The MASK macro is used in the RANGE macro, and it should return the pre-bitset word mask for the (b) value. i.e. BITSET_MASK(0) should be undefined since it's meaningless. BITSET_MASK(31) should give 0x7fffffff BITSET_MASK(32) should give 0xffffffff BITSET_MASK(33) should give 0x00000001 BITSET_MASK(64) should give 0xffffffff However then BITSET_RANGE ends up broken for cases where it's (b) value is the 0,32,64 value as in that case the lower mask would be 0 not 0xffffffff. This fixes the unit tests that I've added, and my code that uses bitsets. Reviewed-by: Jason Ekstrand <[email protected]> Fixes: bb38cadb1c5f2 "More GLSL code" Reviewed-by: Kristian H. Kristensen <[email protected]>
* util/tests: add basic unit tests for bitsetDave Airlie2019-05-032-0/+141
| | | | | | | The last test here currently fails as there is a bug in bitset.h Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util/bitset: Return an actual bool from test macrosJason Ekstrand2019-05-021-2/+2
| | | | | | | | | I want to be able to do BITSET_TEST() != BITSET_TEST() and this isn't currently possible because BITSET_TEST() returns a random bit. Compare to zero to get an actual Boolean. Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* util: move #include out of #if linuxEric Engestrom2019-05-011-1/+1
| | | | | | | | | This #include is needed for `NULL`, which is used on all OSes, not just Linux. Reported-by: Juan A. Suarez Romero <[email protected]> Fixes: 316964709e21286c2af5 "util: add os_read_file() helper" Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Juan A. Suarez <[email protected]>
* st/nine: Control shader constant inlining with drircAxel Davy2019-04-301-0/+5
| | | | | | | Until we use async shader compilation for constant inlining, don't enable it unless user asks for it. Signed-off-by: Axel Davy <[email protected]>
* drirc: Add Gallium nine workaround for Rayman LegendsAxel Davy2019-04-301-0/+5
| | | | | | The game requires it to display many textures properly. Signed-off-by: Axel Davy <[email protected]>
* st/nine: Add drirc option to use data_internal for dynamic texturesAxel Davy2019-04-301-0/+5
| | | | | | | | | | | | | | dynamic textures seem to have predictable stride. This stride should be the same as for a ram buffer. It seems some game don't check the actual stride value, assuming it to be the expected one. Thus this workaround (protected by drirc option) is to use an intermediate ram buffer. Fixes Rayman Legends texture issues when enabled. Signed-off-by: Axel Davy <[email protected]>
* util: add os_read_file() helperEric Engestrom2019-04-304-0/+158
| | | | | | | | readN() taken from igt. os_read_file() inspired by igt_sysfs_get() Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* delete autotools .gitignore filesEric Engestrom2019-04-293-22/+0
| | | | | | | | One special case, `src/util/xmlpool/.gitignore` is not entirely deleted, as `xmlpool.pot` still gets generated (eg. by `ninja xmlpool-pot`). Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* radeonsi: add si_debug_options for convenient adding/removing of optionsNicolai Hähnle2019-04-252-15/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the definition of radeonsi_clear_db_cache_before_clear there, as well as radeonsi_enable_nir. This removes the AMD_DEBUG=nir option. We currently still have two places for options: the driconf machinery and AMD_DEBUG/R600_DEBUG. If we are to have a single place for options, then the driconf machinery should be preferred since it's more flexible. The only downside of the driconf machinery was that adding new options was quite inconvenient. With this change, a simple boolean option can be added with a single line of code, same as for AMD_DEBUG. One technical limitation of this particular implementation is that while almost all driconf features are available, the translation machinery doesn't pick up the description strings for options added in si_debvug_options. In practice, translations haven't been provided anyway, and this is intended for developer options, so I'm not too worried. It could always be added later if anybody really cares. v2: - use bool instead of uint8_t for options - si_debug_options.inc -> si_debug_options.h Reviewed-by: Marek Olšák <[email protected]>
* drirc: Add workaround for Epic Games LauncherDanylo Piliaiev2019-04-221-0/+4
| | | | | | | | | | | | Epic Games Launcher could be launched in opengl mode with "-opengl" option. It creates 4.4 opengl core context however it uses deprecated functionality e.g. default vertex buffer object. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110462 Signed-off-by: Danylo Piliaiev <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* ralloc: Fully qualify non-virtual destructor callKristian H. Kristensen2019-04-191-1/+1
| | | | | | | | | | | | This suppresses warning about calling a non-virtual destructor in a non-final class with virtual functions: src/compiler/glsl/ast.h:53:4: warning: destructor called on non-final 'ast_node' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor] DECLARE_LINEAR_ZALLOC_CXX_OPERATORS(ast_node); Signed-off-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* drirc: add Spectacle, Falkon to a-sync blacklistgrmat2019-04-151-0/+6
| | | | | | Spectacle is the plasma screenshot utility Falkon is a KDE web browser that should succeed Konqueror
* drirc: add Waterfox to adaptive-sync blacklist davidbepo2019-04-151-0/+3
|
* drirc: add Budgie WM to adaptive-sync blacklistEl Christianito2019-04-151-0/+3
| | | | | | | Budgie Window Manager is an increasingly used alternative to GNOME and MATE. Default in Solus OS, also used in other distros. Signed-off-by: Marek Olšák <[email protected]>
* Delete autotoolsDylan Baker2019-04-157-425/+0
| | | | | | | | | | Acked-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Acked-by: Marek Olšák <[email protected]> Acked-by: Jason Ekstrand <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Matt Turner <[email protected]>
* u_dynarray: add util_dynarray_grow_capQiang Yu2019-04-111-6/+17
| | | | | | | | | | | | | This is for the case that user only know a max size it wants to append to the array and enlarge the array capacity before writing into it. v2: - rename newsize to newcap - rename util_dynarray_enlarge to util_dynarray_grow_cap Signed-off-by: Qiang Yu <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* u_math: add ushort_to_float/float_to_ushortQiang Yu2019-04-111-0/+31
| | | | | | | | v2: - return 0 for NaN too Signed-off-by: Qiang Yu <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>