summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_format.c
AgeCommit message (Collapse)AuthorFilesLines
2014-02-27util/u_format: don't crash in util_format_translate if we can't do translationRoland Scheidegger1-5/+16
Some formats can't be handled - in particular cannot handle ints/uints formats, which lack the pack_rgba_float/unpack_rgba_float functions. Instead of trying to call these (and crash) return an error (I'm not sure yet if we should try to translate such formats too here might not make much sense). v2: suggested by Jose, use separate checks for pack/unpack of rgba_8unorm and rgba_float functions (right now if one exists the other should as well). Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2013-11-07draw,llvmpipe,util: add depth bias calculation for arb_depth_buffer_floatMatthew McClure1-10/+6
With this patch, the llvmpipe and draw modules will calculate the depth bias according to floating point depth buffer semantics described in the arb_depth_buffer_float specification, when the driver has a z buffer bound with a format type of UTIL_FORMAT_TYPE_FLOAT. By default, the driver will use the existing UNORM calculation for depth bias. A new function, draw_set_zs_format, was added to calculate the Minimum Resolvable Depth value and floating point depth sense for the draw module. Reviewed-by: Jose Fonseca <jfonseca@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2013-10-29util,llvmpipe: correctly set the minimum representable depth valueMatthew McClure1-0/+41
Reviewed-by: Roland Scheidegger <sroland@vmware.com> Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2013-09-30gallium: include u_surface.h instead of u_rect.hBrian Paul1-1/+1
u_rect.h was including u_surface.h just to avoid touching a bunch of other source files after some functions were moved from u_rect.h to u_surface.h. This patch cleans up that hack. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2013-07-17gallium/util: use explicily sized types for {un, }pack_rgba_{s, u}intEmil Velikov1-4/+4
Every function but the above four uses explicitly sized types for their src and dst arguments. Even fetch_rgba_{s,u}int follows the convention. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Marek Olšák <maraeo@gmail.com>
2013-06-30st/mesa: handle SNORM formats in generic CopyPixels pathMarek Olšák1-0/+20
v2: check desc->is_mixed in util_format_is_snorm
2013-04-18st/mesa: optionally apply texture swizzle to border color v2Christoph Bumiller1-0/+34
This is the only sane solution for nv50 and nvc0 (really, trust me), but since on other hardware the border colour is tightly coupled with texture state they'd have to undo the swizzle, so I've added a cap. The dependency of update_sampler on the texture updates was introduced to avoid doing the apply_depthmode to the swizzle twice. v2: Moved swizzling helper to u_format.c, extended the CAP to provide more accurate information.
2013-02-06gallium/util: remove duplicated function util_format_is_rgb_no_alphaMarek Olšák1-7/+4
It only checks if alpha is present, so it's the same as util_format_has_alpha. Reviewed-by: Brian Paul <brianp@vmware.com>
2012-11-29util/u_format: Kill util_format_is_array().José Fonseca1-41/+0
It is buggy (it was giving wrong results for some of the formats with padding), and util_format_description::is_array already does precisely what's intended. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2012-11-28util: Updated util_format_is_array to be more accurate.James Benton1-2/+12
Will allow formats with padding, e.g. RGBX. Will now allow swizzled formats as long as the alpha is channel 3. Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2012-11-09softpipe,util: Fix blending of R and RG formats.José Fonseca1-25/+1
Alpha is also 1 for formats like R32G32_FLOAT. NOTE: Candidate for the stable branches. Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2012-09-05Remove useless checks for NULL before freeingMatt Turner1-6/+2
Same as earlier commit, except for "FREE" This patch has been generated by the following Coccinelle semantic patch: // Remove useless checks for NULL before freeing // // free (NULL) is a no-op, so there is no need to avoid it @@ expression E; @@ + FREE (E); + E = NULL; - if (unlikely (E != NULL)) { - FREE(E); ( - E = NULL; | - E = 0; ) ... - } @@ expression E; type T; @@ + FREE ((T) E); + E = NULL; - if (unlikely (E != NULL)) { - FREE((T) E); ( - E = NULL; | - E = 0; ) ... - } @@ expression E; @@ + FREE (E); - if (unlikely (E != NULL)) { - FREE (E); - } @@ expression E; type T; @@ + FREE ((T) E); - if (unlikely (E != NULL)) { - FREE ((T) E); - } Reviewed-by: Brian Paul <brianp@vmware.com>
2012-06-29util: Added util_format_is_array.James Benton1-0/+32
This function checks whether a format description is in a simple array format. Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2011-11-06u_format: fix RGTC support in fits 8unorm.Dave Airlie1-2/+7
Signed RGTC won't fit in a unorm, so don't allow them. Signed-off-by: Dave Airlie <airlied@redhat.com>
2011-10-11gallium: rename ZS stencil type to UINT (v2)Dave Airlie1-4/+4
these are never USCALED, always UINT in reality. taken from some work by Christoph Bumiller v2: fixup formatting of table + tabs Signed-off-by: Dave Airlie <airlied@redhat.com>
2011-10-08gallium: add initial pure integer support (v2)Dave Airlie1-0/+122
This add support for unsigned/signed integer types via adding a 'pure' bit in the format description table. It adds 4 new u_format get/put hooks, for get/put uint and get/put sint so that accessors can get native access to the integer bits. This is used to avoid precision loss via float converting paths. It doesn't add any float fetchers for these types at the moment, GL doesn't require float fetching from these types and I expect we'll introduce a lot of hidden bugs if we start allowing such conversions without an API mandating it. It adds all formats from EXT_texture_integer and EXT_texture_rg. 0 regressions on llvmpipe here with this. (there is some more follow on code in my gallium-int-work branch, bringing softpipe and mesa to a pretty integer clean state) v2: fixup python generator to get signed->unsigned and unsigned->signed fetches working. Signed-off-by: Dave Airlie <airlied@redhat.com>
2011-10-08u_format: add inline helper to find first non void channelDave Airlie1-8/+2
This is used in a few places in drivers as well, also the integer support can use it as well. Signed-off-by: Dave Airlie <airlied@redhat.com>
2011-09-22util: Handle conversion between depth stencil formats.José Fonseca1-0/+44
2011-09-15util: add util_format_is_luminance/intensity/rgb(), etcBrian Paul1-0/+94
Reviewed-by: José Fonseca <jfonseca@vmware.com>
2011-08-03util: fix a typo in util_format_swizzle_4fMarek Olšák1-1/+1
Reported by Gustaw Smolarczyk.
2011-08-02gallium/util: add functions for manipulating swizzlesMarek Olšák1-0/+50
Some of those have been in drivers already.
2011-04-15gallium: add and use generic function for querying patented format support (v2)Marek Olšák1-0/+49
v2: Unsigned floats are allowed regardless of the configure switch.
2010-09-17util: linearized sRGB values don't fit into 8bitsJosé Fonseca1-0/+8
Fixes glean texture_srgb test.
2010-09-05util: Helper function to determined whether two formats can be memcpy'ed.José Fonseca1-4/+52
These are the non-trivial conversions that this function recognizes, which was produced by u_format_compatible_test.c: b8g8r8a8_unorm -> b8g8r8x8_unorm a8r8g8b8_unorm -> x8r8g8b8_unorm b5g5r5a1_unorm -> b5g5r5x1_unorm b4g4r4a4_unorm -> b4g4r4x4_unorm l8_unorm -> r8_unorm i8_unorm -> l8_unorm i8_unorm -> a8_unorm i8_unorm -> r8_unorm l16_unorm -> r16_unorm z24_unorm_s8_uscaled -> z24x8_unorm s8_uscaled_z24_unorm -> x8z24_unorm r8g8b8a8_unorm -> r8g8b8x8_unorm a8b8g8r8_srgb -> x8b8g8r8_srgb b8g8r8a8_srgb -> b8g8r8x8_srgb a8r8g8b8_srgb -> x8r8g8b8_srgb a8b8g8r8_unorm -> x8b8g8r8_unorm r10g10b10a2_uscaled -> r10g10b10x2_uscaled r10sg10sb10sa2u_norm -> r10g10b10x2_snorm State trackers and pipe drivers should be updated to take advantage of this knowledge, e.g., in surface_copy.
2010-07-02util: Expose util_format_fits_8unorm().José Fonseca1-1/+1
2010-06-07util: allocate larger tmp_row in util_format_translateKeith Whitwell1-3/+4
The tmp_row storage allocation took into account the format's y block size by allocating y_step rows of data. However, the x block size was not being taken into account when deciding how wide those rows need to be. Now make sure that tmp_row is at least x_step by y_step in size.
2010-04-09util: Add missing break statement.José Fonseca1-0/+1
2010-04-09util: Add dedicated depth-stencil packing/unpacking functions.José Fonseca1-12/+12
Depth-stencil manually written given that each one is very close to be a special case. u_format_zs.c's still untested.
2010-04-08util: (Almost) universal format translation function.José Fonseca1-0/+167
Untested.
2010-04-03util: Revert unsolicited, untested, unreviewed, and broken changes to format ↵José Fonseca1-2/+1
support. Not all is bad, but I'm afraid I'll have to throw the baby with the water given they are all tied to together.
2010-04-02gallium/util: revert util_format_init additionLuca Barbieri1-8/+0
Putting calls to util_format_init all over the codebase is infeasible. Instead, half float tables are pregenerated, and the s3tc library is loaded on demand. I believe this is a solution that combines performance, cleanliness, flexibility and portability.
2010-04-02gallium/util: pregenerate half float tablesLuca Barbieri1-1/+0
This solution avoids the issue of how to run the initializers and also allows those pages (and the parts of them in processor caches) to be shared between multiple processes. The drawback is slightly higher library size.
2010-04-02gallium/util: add util_format_init that inits s3tc and util_halfLuca Barbieri1-0/+10
Switch from auto-init to explicit init for util_half per Brian Paul's indication. NOTE: this is probably broken because not enough things call util_format_init. Will be fixed shortly
2010-03-31util: Make the accessors bidimensional again.José Fonseca1-32/+4
Otherwise there's no way to unpack blocks with height >1
2010-03-31util: Use u_format_pack.py's code instead of u_format_access.py.José Fonseca1-0/+146
2010-02-24util: Cope with the fact that formats in u_format.csv are not ordered.José Fonseca1-45/+0
2009-12-08util/format: Take advantage of sequential nature of pipe_format enum.Michal Krol1-8/+7
Make sure the format descriptor table can be indexed directly.
2009-08-29util: Pixel format database.José Fonseca1-0/+46
There are some inconsistencies in pipe_format, but above all, there simply aren't enough bits in an enum to conveniently store all information about a pixel format we need to be able to dynamically generate pixel packing/unpacking code.