aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/format_utils.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2014-08-25 10:55:06 -0700
committerIago Toral Quiroga <[email protected]>2015-01-12 11:20:28 +0100
commitdeca11c0dc127caa7f8643069310ea6e0a5aea5c (patch)
tree2102dfd8e23d5f9da7a0a2805ff27440eab5e300 /src/mesa/main/format_utils.h
parentba5418c60d7301fc78190bf7a39f475d868b6126 (diff)
mesa: Add an implementation of a master convert function.
v2 by Iago Toral <[email protected]>: - When testing if we can directly pack we should use the src format to check if we are packing from an RGBA format. The original code used the dst format for the ubyte case by mistake. - Fixed incorrect number of bits for dst, it was computed using the src format instead of the dst format. - If the dst format is an array format, check if it is signed. We were only checking this for the case where it was not an array format, but we need to know this in both scenarios. - Fixed incorrect swizzle transform for the cases where we convert between array formats. - Compute is_signed and bits only once and for the dst format. We were computing these for the src format too but they were overwritten by the dst values immediately after. - Be more careful when selecting the integer path. Specifically, check that both src and dst are integer types. Checking only one of them should suffice since OpenGL does not allow conversions between normalized and integer types, but putting extra care here makes sense and also makes the actual requirements for this path more clear. - The format argument for pack functions is the destination format we are packing to, not the source format (which has to be RGBA). - Expose RGBA8888_* to other files. These will come in handy when in need to test if a given array format is RGBA or in need to pass RGBA formats to mesa_format_convert. v3 by Samuel Iglesias <[email protected]>: - Add an RGBA8888_INT definition. v4 by Iago Toral <[email protected]> after review by Jason Ekstrand: - Added documentation for _mesa_format_convert. - Added additional explanatory comments for integer conversions. - Ensure that we use _messa_swizzle_and_convert for all signed source formats. - Squashed: do not directly (un)pack to RGBA UINT if the source is not unsigned. v5 by Iago Toral <[email protected]>: - Adapted to the new implementation of mesa_array_format as a plain uint32_t bitfield. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa/main/format_utils.h')
-rw-r--r--src/mesa/main/format_utils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/main/format_utils.h b/src/mesa/main/format_utils.h
index 4e63200da69..f006e18d785 100644
--- a/src/mesa/main/format_utils.h
+++ b/src/mesa/main/format_utils.h
@@ -34,6 +34,11 @@
#include "imports.h"
#include "macros.h"
+extern const mesa_array_format RGBA8888_FLOAT;
+extern const mesa_array_format RGBA8888_UBYTE;
+extern const mesa_array_format RGBA8888_UINT;
+extern const mesa_array_format RGBA8888_INT;
+
/* Only guaranteed to work for BITS <= 32 */
#define MAX_UINT(BITS) ((BITS) == 32 ? UINT32_MAX : ((1u << (BITS)) - 1))
#define MAX_INT(BITS) ((int)MAX_UINT((BITS) - 1))
@@ -207,4 +212,9 @@ _mesa_swizzle_and_convert(void *dst, GLenum dst_type, int num_dst_channels,
const void *src, GLenum src_type, int num_src_channels,
const uint8_t swizzle[4], bool normalized, int count);
+void
+_mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,
+ void *void_src, uint32_t src_format, size_t src_stride,
+ size_t width, size_t height);
+
#endif