aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/macros.h
Commit message (Collapse)AuthorAgeFilesLines
* mesa: add fallthrough comments to COPY_SZ_4V()Timothy Arceri2020-07-021-8/+8
| | | | | Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5705>
* remove final imports.h and imports.c bitsDylan Baker2020-04-211-1/+2
| | | | | | | | | | | This moves the fi_types to a new mesa_private.h and removes the imports.c file. The vast majority of this patch is just removing pound includes of imports.h and fixing up the recursive includes. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>
* mesa|mapi: replace _mesa_[v]snprintf with [v]snprintfDylan Baker2020-04-211-0/+9
| | | | | | | | | | MSVC 2015 and newer has perfectly valid snprintf and vsnprintf implementations, let's just use those. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>
* util: move ALIGN/ROUND_DOWN_TO to u_math.hRob Clark2020-03-311-46/+0
| | | | | | | | | These are less mesa specific than the rest of macros.h, and would be nice to use outside of mesa. Prep for next patch. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4381>
* Move compiler.h and imports.h/c from src/mesa/main into src/utilMarek Olšák2020-03-271-1/+2
| | | | | Reviewed-by: Timothy Arceri <[email protected] Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4324>
* mesa: use vbo_attrib_tmp.h to generate display list vertex attrib functionsMarek Olšák2020-03-191-0/+10
| | | | | | | | | | | This removes about 1150 lines of code. The diff is messy, but the new code really starts with save_Attr32bit and below. Ignore false Eval/Material/Begin changes etc. Git can't figure out what was really changed. I didn't change them. Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4123>
* vbo: pass only either uint32_t or uint64_t into ATTR_UNIONMarek Olšák2020-02-111-0/+14
| | | | | | | This makes the next commit possible. Reviewed-by: Mathias Fröhlich <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3766>
* util: move min/max/clamp macros to util macros.hDave Airlie2016-10-191-13/+0
| | | | | | | | | Although the vulkan drivers include mesa macros.h, for radv I'd like to move away from that. Reviewed-by: Nicolai Hähnle <[email protected]> Acked-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa/macros: move ALIGN_NPOT to macros.hNanley Chery2015-08-261-0/+10
| | | | | | | | | | | Aligning with a non-power-of-two number is a general task that can be used in various places. This commit is required for the next one. v2: add greater than 0 assertion (Anuj). convert the macro to a static inline function. Reviewed-by: Anuj Phogat <[email protected]> Signed-off-by: Nanley Chery <[email protected]>
* mesa/macros: add power-of-two assertions for alignment macrosNanley Chery2015-08-261-2/+12
| | | | | | | | | | | | | ALIGN and ROUND_DOWN_TO both require that the alignment value passed into the macro be a power of two in the comments. Using software assertions verifies this to be the case. v2: use static inline functions instead of gcc-specific statement expressions (Brian). v3: fix indendation (Brian). v4: add greater than zero requirement (Anuj). Reviewed-by: Anuj Phogat <[email protected]> Signed-off-by: Nanley Chery <[email protected]>
* mesa: Replace F_TO_I() with _mesa_lroundevenf().Matt Turner2015-08-031-5/+6
| | | | | | | | | | | I'm not sure what the true meaning of "The rounding mode may vary." is, but it is the case that the IROUND() path rounds differently than the other paths (and does it wrong, at that). Like _mesa_roundeven{f,}(), just add an use _mesa_lroundeven{f,}() that has known semantics. Reviewed-by: Roland Scheidegger <[email protected]>
* Delete duplicate function is_power_of_two() and use _mesa_is_pow_two()Anuj Phogat2015-07-291-11/+0
| | | | | | Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* util/macros: Move DIV_ROUND_UP to util/macros.hAxel Davy2015-04-291-4/+1
| | | | | | | Move DIV_ROUND_UP to a shared location accessible everywhere Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Axel Davy <[email protected]>
* mesa: Avoid MSVC C6334 warning in /analyze mode.Jose Fonseca2015-03-251-0/+7
| | | | | | | | | | MSVC's implementation of signbit(x) uses sizeof(x) with expressions to dispatch to an internal function based on the argument's type (float, double, etc), but that raises a flag with MSVC's own static analyzer, and because this is an inline function in a header it causes substantial warning spam. Reviewed-by: Brian Paul <[email protected]>
* mesa: remove extra definition of ARRAY_SIZE in src/mesa/main/macros.hBrian Paul2015-03-021-4/+0
| | | | | | Already defined in src/util/macros.h Reviewed-by: Matt Turner <[email protected]>
* mesa: use fi_type in vertex attribute codeMarius Predut2015-02-251-16/+18
| | | | | | | | | | | | | | | | | | | | | | | For 32-bit builds, floating point operations use x86 FPU registers, not SSE registers. If we're actually storing an integer in a float variable, the value might get modified when written to memory. This patch changes the VBO code to use the fi_type (float/int union) to store/copy vertex attributes. Also, this can improve performance on x86 because moving floats with integer registers instead of FP registers is faster. Neil Roberts review: - include changes on all places that are storing attribute values. - check with and without -O3 compiler flag. Brian Paul review: - use fi_type type instead gl_constant_value type - fix a bunch of nit-picks. - fix compiler warnings Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82668 Signed-off-by: Marius Predut <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: remove INV_SQRTF() macroBrian Paul2015-02-241-1/+1
| | | | | Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* mesa: Use assert() instead of ASSERT wrapper.Matt Turner2015-02-231-1/+1
| | | | Acked-by: Eric Anholt <[email protected]>
* mesa: Use u_math.h from macros.hEric Anholt2015-02-201-17/+1
| | | | | | | | | | This avoids duplication of some macros and other definitions across the tree. Note that COPY_4FV switches from a memcpy-based implementation to an assignment of 4 floats. Reviewed-by: Jose Fonseca <[email protected]>
* mesa: Rename the CEILING() macro to DIV_ROUND_UP().Francisco Jerez2015-02-101-1/+1
| | | | | | | | | | Some people have complained that code using the CEILING() macro is difficult to understand because it's not immediately obvious what it is supposed to do until you go and look up its definition. Use a more descriptive name that matches the similar utility macro in the Linux kernel. Reviewed-by: Matt Turner <[email protected]>
* mesa: Replace IS_NEGATIVE(x) with x < 0.0f.Matt Turner2014-09-251-7/+0
| | | | | | | | I only made IS_NEGATIVE(x) use signbit in commit 0f3ba405 in an attempt to fix 54805, but it didn't help. We didn't use signbit on some platforms and instead defined it to x < 0.0f. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: fix UNCLAMPED_FLOAT_TO_UBYTE() macro for MSVCBrian Paul2014-09-101-4/+4
| | | | | | | | | | MSVC replaces the "F" in "255.0F" with the macro argument which leads to an error. s/F/FLT/ to avoid that. It turns out we weren't using this macro at all on MSVC until the recent "mesa: Drop USE_IEEE define." change. Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: set UniformBooleanTrue = 1.0f by defaultMarek Olšák2014-09-051-0/+7
| | | | | | | | | | because NativeIntegers is 0 by default. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82882 Cc: 10.2 10.3 [email protected] Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* mesa: s/INLINE/inline/Brian Paul2014-09-041-2/+2
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Drop USE_IEEE define.Matt Turner2014-08-071-1/+1
| | | | | | | | | | | | | I think OpenVMS was the only platform that Mesa ran on that used a non-IEEE representation for floats. We removed OpenVMS support a while back, and this should alleviate the need to continue updating the this-platform-uses-IEEE list. The one bit of this patch that needs review is the IS_INF_OR_NAN, because I'm not sure if MSVC supports isfinite. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82268 Reviewed-by: Brian Paul <[email protected]>
* util: Gather some common macrosJason Ekstrand2014-08-041-1/+3
| | | | | | | | | | This gathers macros that have been included across components into util so that the include chain can be more vertical. In particular, this makes util stand on its own without any dependence whatsoever on the rest of mesa. Signed-off-by: "Jason Ekstrand" <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* mesa: Move is_power_of_two() function from brw_context.h to macros.h.Kenneth Graunke2014-04-081-0/+11
| | | | | | | | | This makes the function available from core Mesa code, including the GLSL compiler. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* mesa: Add STRINGIFY macro.Matt Turner2014-01-211-0/+2
| | | | Reviewed-by: Jordan Justen <[email protected]>
* mesa: fix a couple issues with U_FIXED, I_FIXED macrosBrian Paul2013-10-221-3/+3
| | | | | | | | | | Silence a bunch of MSVC type conversion warnings. Changed return type of S_FIXED to int32_t (signed). The result is the same. It just seems more intuitive that a signed conversion function should return a signed value. Reviewed-by: Jose Fonseca <[email protected]>
* mesa: Move U_FIXED/S_FIXED macros from i965 to macros.h.Kenneth Graunke2013-10-131-0/+22
| | | | | | | | | | | | | | | | | These make it easy to convert a floating point value to a fixed point numbers. The second parameter is the number of bits used for the fractional part of the number. It looks like core Mesa has similar functions already, but none that allows an arbitrary number of fractional bits. The more generic version is probably useful to everyone. r600g apparently has an identical copy of the S_FIXED macro, but doesn't include this file. I'm not sure what to do about that, so I'm just going to leave it for now. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Move ROUND_DOWN_TO() macro from i915/i965 to macros.h.Kenneth Graunke2013-10-131-0/+12
| | | | | | | | | | This seems generally useful, so it may as well live in core Mesa. In fact, the comment for ALIGN() in macros.h actually says to "see also" ROUND_DOWN_TO, which...was in a driver somewhere. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Fix compiler warnings when ALIGN's alignment is "1 << value".Eric Anholt2013-10-091-1/+1
| | | | | | | | | | | We hadn't run into order of operation warnings before, apparently, since addition is so low on the order. Cc: "9.1 9.2" <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: init dst values in COPY_CLEAN_4V_TYPE_AS_FLOAT()Brian Paul2013-08-261-1/+2
| | | | | | to silence gcc 4.8.1 warnings. And improve the ASSERT(0) call. Reviewed-by: Chad Versace <[email protected]>
* mesa: Fix bug in unclamped float to ubyte conversion.Manfred Ernst2013-06-121-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The IEEE float optimized version of UNCLAMPED_FLOAT_TO_UBYTE in macros.h computed incorrect results for inputs in the range 0x3f7f0000 (=0.99609375) to 0x3f7f7f80 (=0.99803924560546875) inclusive. 0x3f7f7f80 is the IEEE float value that results in 254.5 when multiplied by 255. With rounding mode "round to closest even integer", this is the largest float in the range 0.0-1.0 that is converted to 254 by the generic implementation of UNCLAMPED_FLOAT_TO_UBYTE. The IEEE float optimized version incorrectly defined the cut-off for mapping to 255 as 0x3f7f0000 (=255.0/256.0). The same bug was present in the function float_to_ubyte in u_math.h. Fix: The proposed fix replaces the incorrect cut-off value by 0x3f800000, which is the IEEE float representation of 1.0f. 0x3f7f7f81 (or any value in between) would also work, but 1.0f is probably cleaner. The patch does not regress piglit on llvmpipe and on i965 on sandy bridge. Tested-by Stéphane Marchesin <[email protected]> Reviewed-by Stéphane Marchesin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: remove outdated version lines in commentsRico Schüller2013-06-051-1/+0
| | | | Signed-off-by: Brian Paul <[email protected]>
* mesa: Restore 78-column wrapping of license text in C-style comments.Kenneth Graunke2013-04-231-3/+4
| | | | | | | | | | | | | | The previous commit introduced extra words, breaking the formatting. This text transformation was done automatically via the following shell command: $ git grep 'THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY' | sed 's/:.*$//' | xargs -I {} sh -c 'vim -e -s {} < vimscript where 'vimscript' is a file containing: /THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY/;/\*\// !fmt -w 78 -p ' * ' :wq Reviewed-by: Brian Paul <[email protected]>
* mesa: Add "OR COPYRIGHT HOLDERS" to license text disclaiming liability.Kenneth Graunke2013-04-231-1/+1
| | | | | | | | | | | | | | | This brings the license text in line with the MIT License as published on the Open Source Initiative website: http://opensource.org/licenses/mit-license.php Generated automatically be the following shell command: $ git grep 'THE AUTHORS BE LIABLE' | sed 's/:.*$//g' | xargs -I '{}' \ sed -i 's/THE AUTHORS/THE AUTHORS OR COPYRIGHT HOLDERS/' {} This introduces some wrapping issues, to be fixed in the next commit. Reviewed-by: Brian Paul <[email protected]>
* mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.Kenneth Graunke2013-04-231-1/+1
| | | | | | | | | | | | | | | | Generated automatically be the following shell command: $ git grep 'BRIAN PAUL BE LIABLE' | sed 's/:.*$//g' | xargs -I '{}' \ sed -i 's/BRIAN PAUL/THE AUTHORS/' {} The intention here is to protect all authors, not just Brian Paul. I believe that was already the sensible interpretation, but spelling it out is probably better. More practically, it also prevents people from accidentally copy & pasting the license into a new file which says Brian is not liable when he isn't even one of the authors. Reviewed-by: Brian Paul <[email protected]>
* mesa: Introduce a globally-available minify() macro.Eric Anholt2013-04-211-0/+6
| | | | | | This matches u_minify()'s behavior, for consistency. Reviewed-by: Brian Paul <[email protected]>
* Consolidate some redundant definitions of ARRAY_SIZE() macro.Paul Berry2013-02-081-0/+3
| | | | | | | | | | | | | | | | | | | | | Previous to this patch, there were 13 identical definitions of this macro in Mesa source. That's ridiculous. This patch consolidates 6 of them to a single definition in src/mesa/main/macros.h. Unfortunately, I wasn't able to eliminate the remaining definitions, since they occur in places that don't include src/mesa/main/macros.h: - include/pci_ids/pci_id_driver_map.h - src/egl/drivers/dri2/egl_dri2.h - src/egl/main/egldefines.h - src/gbm/main/backend.c - src/gbm/main/gbm.c - src/glx/glxclient.h - src/mapi/mapi/stub.c I'm open to suggestions as to how to deal with the remaining redundancy. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Add ALIGN() macro to main/macros.h.Paul Berry2013-01-081-0/+13
| | | | | | | | | Previously this macro existed in 3 separate places, some inside the intel driver and some outside of it. It makes more sense to have it in main/macros.h Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* vbo: fix glVertexAttribI* functionsMarek Olšák2012-11-061-0/+39
| | | | | | | | | | | | | | | | | | | | | | The functions were broken, because they converted ints to floats. Now we can finally advertise OpenGL 3.0. ;) In this commit, the vbo module also tracks the type for each attrib in addition to the size. It can be one of FLOAT, INT, UNSIGNED_INT. The little ugliness is the vertex attribs are declared as floats even though there may be integer values. The code just copies integer values into them without any conversion. This implementation passes the glVertexAttribI piglit test which I am going to commit in piglit soon. The test covers vertex arrays, immediate mode and display lists. NOTE: This is a candidate for the stable branches. Reviewed-by: Brian Paul <[email protected]> v2: cosmetic changes as suggested by Brian
* Use signbit() in IS_NEGATIVE and DIFFERENT_SIGNSMatt Turner2012-09-241-19/+2
| | | | | | | | | | signbit() appears to be available everywhere (even MSVC according to MSDN), so let's use it instead of open-coding some messy and confusing bit twiddling macros. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54805 Reviewed-by: Paul Berry <[email protected]> Suggested-by: Ian Romanick <[email protected]>
* mesa: fix DIFFERENT_SIGNS() functionBrian Paul2012-09-041-1/+1
| | | | | | | | | | Looks like converting this to a macro, returning bool, caused us to lose the high (31st) bit result. Fixes piglit fbo-1d test. Strange that none of the other tests I ran caught this. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=54365 Tested-by: Vinson Lee <[email protected]>
* mesa: remove SQRTF, use sqrtf. Convert INV_SQRT() to inline function.Brian Paul2012-09-031-2/+2
| | | | | | | We were already defining sqrtf where we don't have the C99 version. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* mesa: move IS_NEGATIVE() and DIFFERENT_SIGNS() to macros.hBrian Paul2012-09-011-0/+32
|
* mesa: convert a few more macros to inline functionsBrian Paul2012-08-291-22/+21
|
* mesa: remove COPY_4V_CAST() macroBrian Paul2012-08-291-9/+0
| | | | Only used in one place, and not really needed.
* mesa: convert a bunch of math macros to inline functionsBrian Paul2012-08-291-56/+86
|
* mesa: use F_TO_I() instead of IROUND()Brian Paul2012-05-191-5/+5
| | | | | | | | Use it where performance matters more and the exact method of float->int conversion/rounding isn't terribly important. There should no net change here since F_TO_I() is the new name of the old IROUND() function. Reviewed-by: José Fonseca <[email protected]>