summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
Commit message (Collapse)AuthorAgeFilesLines
* util: Prefer atomic intrinsics to inline assembly.Matt Turner2014-11-241-2/+2
| | | | | | | | | | | | | Cuts a little more than 1k of .text size from i915g. This was previously done in commit 5f66b340 and subsequently reverted in commit 3661f757 after bug 30514 was filed. I believe the cause of bug 30514 wasn't anything related to cross compiling, but rather that the toolchain used defaulted to -march=i386, and i386 doesn't have the CMPXCHG or XADD instructions used to implement the intrinsics. So we reverted a patch that improved things so that we didn't break compilation for a platform that never could have worked anyway.
* st/mesa: add a fallback for clear_with_quad when no vs_layerIlia Mirkin2014-11-172-0/+76
| | | | | | | | | | | | | | | | | Not all drivers can set gl_Layer from VS. Add a fallback that passes the instance id from VS to GS, and then uses the GS to set the layer. Tested by adding quad_buffers |= clear_buffers; clear_buffers = 0; to the st_Clear logic, and forcing set_vertex_shader_layered in all cases. No piglit regressions (on piglits with 'clear' in the name). Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
* gallium/auxiliary: add contained and rect checks (v6)Christoph Bumiller2014-11-182-0/+136
| | | | | | | | | | | | | v3: thanks to Brian, improved coding style, also glennk helped spot few things (unsigned -> int, two constify) v4: thanks Ilia improved function, dropped u_box_clip_3d v5: incorporated rest of Gregor proposed changes,clean ups v6: u_box_clip_2d simplify proposed by Ilia Mirkin Acked-by: Jose Fonseca <jfonseca@vmware.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: David Heidelberg <david@ixit.cz>
* gallium/auxiliary: add inc and dec alternative with return (v4)Christoph Bumiller2014-11-181-0/+52
| | | | | | | | | | | | | | | At this moment we use only zero or positive values. v2: Implement it for also for Solaris, MSVC assembly and enable for other combinations. v3: Replace MSVC assembly by assert + warning during compilation v4: remove inc and dec with return for MSVC assembly Acked-by: Jose Fonseca <jfonseca@vmware.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Signed-off-by: David Heidelberg <david@ixit.cz>
* gallium: remove unused pipe_viewport_state::translate[3] and scale[3]Marek Olšák2014-11-163-6/+0
| | | | Almost all drivers ignore them.
* tgsi/ureg: simplify code for declaring propertiesMarek Olšák2014-11-161-1/+1
| | | | Tested-by: Nick Sarnie <commendsarnex@gmail.com>
* gallium/util: add a test for TGSI_PROPERTY_VS_WINDOW_SPACE_POSITIONMarek Olšák2014-11-162-0/+307
| | | | | | Not testable by OpenGL. Required by Nine. This is an example of how to implement a piglit-like test using gallium only.
* gallium/util: add a window_space option to the passthrough vertex shaderMarek Olšák2014-11-164-6/+15
| | | | Tested-by: Nick Sarnie <commendsarnex@gmail.com>
* util/format: Fix clamping to 32bit integers.José Fonseca2014-11-081-0/+27
| | | | | | | | | | | | | | | | Use clamping constants that guarantee no integer overflows. As spotted by Chris Forbes. This causes the code to change as: - value |= (uint32_t)CLAMP(src[0], 0.0f, 4294967295.0f); + value |= (uint32_t)CLAMP(src[0], 0.0f, 4294967040.0f); - value |= (uint32_t)((int32_t)CLAMP(src[0], -2147483648.0f, 2147483647.0f)); + value |= (uint32_t)((int32_t)CLAMP(src[0], -2147483648.0f, 2147483520.0f)); Reviewed-by: Roland Scheidegger <sroland@vmware.com>
* util/format: Generate floating point constants for clamping.José Fonseca2014-11-081-4/+4
| | | | | | | | | | | | | | | | | | | | | This commit causes the generated C code to change as union util_format_r32g32b32a32_sscaled pixel; - pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647); - pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647); - pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648, 2147483647); - pixel.chan.a = (int32_t)CLAMP(src[3], -2147483648, 2147483647); + pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648.0f, 2147483647.0f); + pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648.0f, 2147483647.0f); + pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648.0f, 2147483647.0f); + pixel.chan.a = (int32_t)CLAMP(src[3], -2147483648.0f, 2147483647.0f); memcpy(dst, &pixel, sizeof pixel); which surprisingly makes a difference for MSVC. Thanks to Juraj Svec for diagnosing this and drafting a fix. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29661
* util: simplify u_pstipple.c codeBrian Paul2014-10-311-123/+62
| | | | | | | Use the new helper functions in the tgsi_transform.h file to emit declarations and instructions. Reviewed-by: Charmaine Lee <charmainel@vmware.com>
* util: simplify temp register selection in u_pstipple.cBrian Paul2014-10-311-27/+18
| | | | Reviewed-by: Charmaine Lee <charmainel@vmware.com>
* util: simplify util_pstipple_create_fragment_shader() paramsBrian Paul2014-10-312-20/+13
| | | | | | | | Pass and return tgsi_token buffers instead of pipe_shader_state. And update softpipe driver (the only user of this function). Reviewed-by: Charmaine Lee <charmainel@vmware.com>
* u_math.h: fix 64 to 32 bit truncation warningAlon Levy2014-10-231-1/+1
| | | | | Signed-off-by: Alon Levy <alevy@redhat.com> Reviewed-by: Brian Paul <brianp@vmware.com>
* u_blitter: put a comment on util_blitter_cache_all_shaders()Brian Paul2014-10-221-0/+7
| | | | Trivial.
* u_blitter: use ctx->bind_fs_state(), not pipe->bind_fs_state()Brian Paul2014-10-221-3/+3
| | | | | | Consistently use the function pointer we saved earlier. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* u_blitter: create basic fs shaders in util_blitter_cache_all_shaders()Brian Paul2014-10-221-1/+12
| | | | | | We need to create all fs shaders in this function. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* u_blitter: do error checking assertions for shader cachingBrian Paul2014-10-221-21/+30
| | | | | | | | | If the user calls util_blitter_cache_all_shaders() set a flag and assert that we never try to create any new fragment shaders after that point. If the assertions fails, it means we missed generating some shader in util_blitter_cache_all_shaders(). Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* tgsi: change tgsi_shader_info::properties to a one-dimensional arrayMarek Olšák2014-10-041-1/+1
| | | | | | Reviewed-by: Roland Scheidegger <sroland@vmware.com> v2: fix svga too
* tgsi: simplify shader properties in tgsi_shader_infoMarek Olšák2014-10-041-6/+2
| | | | Use an array of properties indexed by TGSI_PROPERTY_* definitions.
* gallium/util: add util_bitcount64Marek Olšák2014-10-041-0/+12
| | | | | | | | I'll need this in radeonsi. v2: use __builtin_popcountll if available Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
* st/vdpau: move common functions to utilLeo Liu2014-10-011-0/+74
| | | | | | | | Break out these functions so that they can be shared with a other state trackers. They will be used in subsequent patches for the new VA-API state tracker. Signed-off-by: Leo Liu <leo.liu@amd.com>
* util: simplify PIPE_TEXTURE_CUBE case in util_max_layer()Brian Paul2014-09-301-2/+3
| | | | | | | | | For cube resources, the array_size value should be 6. So handle that case as we do for array texture resources. But assert that array_size==6 just to be safe. Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* util: use linear formats in util_blit_pixels()Brian Paul2014-09-241-2/+2
| | | | Reviewed-by: Roland Scheidegger <sroland@vmware.com>
* util: simplify writemask parameters for util_blit_pixels()Brian Paul2014-09-242-15/+17
| | | | | | | Instead of separate color and Z/S writemasks, just have one writemask parameter that takes a mask of the PIPE_MASK_[RGBAZS] flags. Reviewed-by: Charmaine Lee <charmainel@vmware.com>
* util: s/PIPE_TEX_MIPFILTER/PIPE_TEX_FILTER/ in u_blit codeBrian Paul2014-09-241-5/+5
| | | | | | | | | | PIPE_TEX_MIPFILTER_x is not legal for the pipe_sampler_state:: min/mag_img_filter fields. But PIPE_TEX_MIPFILTER_x == PIPE_TEX_FILTER_x so we were getting lucky. This also makes the code consistent with u_blitter.c. Reviewed-by: Charmaine Lee <charmainel@vmware.com>
* mesa: Unifdef _WIN32_WCE.Matt Turner2014-09-241-9/+0
| | | | | | Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Jose Fonseca <jfonseca@vmware.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* util: don't try to emit half-float intrinsics if avx isn't availableRoland Scheidegger2014-09-191-1/+1
| | | | | | | | | These instructions only have vex encodings, thus they can't be used without avx. (Technically, one can still use avx-128 if avx isn't available because the environment doesn't store the ymm registers, however I don't think llvm can.) Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
* gallium: Add PIPE_FORMAT_x8B8G8R8_SNORM formatsRichard Sandiford2014-09-171-0/+3
| | | | | | | | | | | This means that each RnGnBnxn format has a reversed counterpart, which is necessary for handling big-endian mesa<->gallium mappings. The associated UNORM and SRGB formats already exist. Signed-off-by: Richard Sandiford <rsandifo@linux.vnet.ibm.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
* gallium: Add PIPE_FORMAT_AnLn and PIPE_FORMAT_GnRn formatsRichard Sandiford2014-09-171-0/+9
| | | | | | | | | | | | ...i.e. formats in which the alpha or green channel is first in memory. This means that each LnAn and RnGn format has a reversed counterpart, which is necessary for handling big-endian mesa<->gallium mappings. Signed-off-by: Richard Sandiford <rsandifo@linux.vnet.ibm.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
* util: move shared rgtc code to util (v2)Dave Airlie2014-09-172-118/+46
| | | | | | | | | | | This was being shared using a ../../ get out of gallium into mesa, and I swore when I did it I'd fix things when we got a util dir, we did, so I have. v2: move RGTC_DEBUG define Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
* util: Add big-endian layout for a number of formats.Richard Sandiford2014-09-162-35/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch builds on 6c8f547f66e68b495c708f8ffcb67370caa5ffe8 and previous patches by allowing u_format.csv to specify separate big-endian and little-endian layouts. It then uses this to specify the correct layouts for various depth/stencil formats. Later patches handle other formats. To recap, the idea is that u_format.csv lists the channels for an N-byte value as though it were an N-byte integer. For little-endian targets the channels are listed starting at the least-significant bit of the integer while for big-endian targets the channels are listed starting at the most-significant bit. This means that for something like PIPE_FORMAT_B8G8R8A8_UNORM (blue in first byte of memory, alpha in last byte of memory) the orders are the same for both endiannesses. But for something like PIPE_FORMAT_S8_UINT_Z24_UNORM, where the stencil is in the least significant byte of a 32-bit integer, there need to be separate channel definitions for each endianness. The effect of this patch is to make the affected PIPE_FORMAT_*s have the same layout as the associated MESA_FORMAT_*s for big-endian. The MESA_FORMAT_*s are already handled correctly. Fixes various piglit tests on z. No regressions on x86_64. [airlied: squash subsequent patches] util: Add big-endian layout for 5551 and 565 formats util: Add big-endian layout for 10/10/10/2 formats util: Add big-endian layout for 4444 formats util: Add big-endian layout for 233 format util: Add big-endian layout for 44 formats Signed-off-by: Dave Airlie <airlied@redhat.com>
* util/u_format: add _is_alpha()Rob Clark2014-09-122-0/+19
| | | | | | | | | Because of render-to-alpha (000x) shenanigans, freedreno needs to do some special handling when rendering to alpha-only formats. And I noticed that while we had _is_luminance(), _is_intensity(), etc, an _is_alpha() helper was missing. So fix that. Signed-off-by: Rob Clark <robclark@freedesktop.org>
* gallium/util: add missing u_debug includeAndreas Boll2014-09-121-0/+1
| | | | | | | | | | | | | | | | | | | Needed for assert. Fixes build on BE archs with -Werror=implicit-function-declaration. In file included from ../../../../../src/gallium/auxiliary/draw/draw_fs.c:30:0: ../../../../../src/gallium/auxiliary/util/u_math.h: In function 'util_memcpy_cpu_to_le32': ../../../../../src/gallium/auxiliary/util/u_math.h:810:4: error: implicit declaration of function 'assert' [-Werror=implicit-function-declaration] assert(n % 4 == 0); ^ Cc: "10.3" <mesa-stable@lists.freedesktop.org> Signed-off-by: Andreas Boll <andreas.boll.dev@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* gallium: add a texture target to sampler view and a CAP to use itIlia Mirkin2014-09-121-0/+1
| | | | | | | | | | This allows a sampler view to have a different texture target than the underlying resource. This will be used to implement the type casting between 2d arrays and cube maps as specified in ARB_texture_view. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* u_vbuf: simple whitespace fixBrian Paul2014-09-101-1/+2
|
* u_blitter: Create all shaders on demandMichel Dänzer2014-09-021-43/+104
| | | | | | | Not all of these are used in every context, so this can make a significant difference for short-lived contexts such as in piglit tests. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* u_vbuf: Make sure all caps are initializedMichel Dänzer2014-08-291-24/+16
| | | | | | | Pointed out by valgrind. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83148 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
* u_vbuf: Add a few more format fallbacks.Eric Anholt2014-08-241-0/+32
| | | | | | | | | | Fixes piglit draw-vertices and gl-2.0-vertexattribpointer on vc4, where I'm only advertising R32F to RGBA32F support so far. Note: regresses gl-1.5-normal3b3s-invariance due to introduced flushes and missing depth buffer load/store support in the driver. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* u_vbuf: Simplify the format fallback translation.Eric Anholt2014-08-242-106/+86
| | | | | | | | | | Individual caps made supporting new fallbacks more complicated than it needed to be. Instead, just make a table of fallbacks at context init time. v2: Fix inverted "do we need to install vbuf?" flagging caught by Marek. Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2)
* gallium/u_blitter: don't use an empty fragment shader if there's a colorbufferMarek Olšák2014-08-191-1/+1
| | | | | | This is custom code used by some drivers. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
* gallium/util: handle PIPE_BUFFER in util_pipe_tex_to_tgsi_texMarek Olšák2014-08-191-0/+3
| | | | Reviewed-by: Roland Scheidegger <sroland@vmware.com>
* util: whitespace and formatting fixes in u_math.hBrian Paul2014-08-161-17/+23
| | | | Trivial.
* android: gallium/auxiliary: drop log2/log2f redefitionsEmil Velikov2014-08-131-22/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent versions of bionic has picked up support for these functions, leading to build issues due to the redefition of the symbols. Note: wrapping things in #ifdef does not cut it :\ Identical patch is available in chromium, android-x86 and perhaps other projects. commit 66c1c789ce3407472de9ed620c9f815639058835 Author: rmcilroy@chromium.org Date: Wed Apr 02 10:59:34 2014 +0000 Porting to x64 Android. Remove redefinitions of log2 and log2f. BUG= R=kbr@chromium.org Review URL: https://codereview.chromium.org/216773005 commit 9cc0a0d2b0499556680b182888af86f29d4ec30b Author: Chih-Wei Huang <cwhuang@linux.org.tw> Date: Sun Jul 21 23:04:19 2013 +0800 android: remove log2, log2f The functions are already defined in the latest bionic. Cc: Chia-I Wu <olvaffe@gmail.com> Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Chia-I Wu <olvaffe@gmail.com>
* gallium: add basic support for BPTC formatsIlia Mirkin2014-08-127-3/+159
| | | | | | | Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
* gallium: remove PIPE_SHADER_CAP_MAX_ADDRSMarek Olšák2014-08-111-2/+0
| | | | | | | | | | | | | | | This limit is fixed in Mesa core and cannot be changed. It only affects ARB_vertex_program and ARB_fragment_program. The minimum value for ARB_vertex_program is 1 according to the spec. The maximum value for ARB_vertex_program is limited to 1 by Mesa core. The value should be zero for ARB_fragment_program, because it doesn't support ARL. Finally, drivers shouldn't mess with these values arbitrarily. Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
* gallium: Move sRGB <-> RGB handling to libmesautilJason Ekstrand2014-08-044-304/+2
| | | | | Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
* gallium: Add a uif() helper function to complement fui()Eric Anholt2014-07-301-0/+8
| | | | | | | | | I found myself often wanting this when I'm printing out a uint32_t mapping of some GPU data, and I want to put in an interpretation of that value as a float. Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* gallium/util: add a helper for calculating primitive count from vertex countMarek Olšák2014-07-281-0/+15
| | | | | | This is needed by the following commit which is a candidate for stable too. Cc: mesa-stable@lists.freedesktop.org
* gallium: rename shader cap MAX_CONSTS to MAX_CONST_BUFFER_SIZEMarek Olšák2014-07-281-2/+2
| | | | | | | | | | This new name isn't so confusing. I also changed the gallivm limit, because it looked wrong. Reviewed-by: Brian Paul <brianp@vmware.com> v2: use sizeof(float[4])