summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_format.h
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2011-09-19 15:04:48 +0100
committerDave Airlie <[email protected]>2011-10-08 17:44:59 +0100
commita441feb757b1be4845ba378f0207dcdc5cc1a407 (patch)
tree63a6b44c082a8850a0001fa8e772d58042123dc4 /src/gallium/auxiliary/util/u_format.h
parentc2060c0af7de4678d55962369244451fe678c4e8 (diff)
gallium: add initial pure integer support (v2)
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 <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util/u_format.h')
-rw-r--r--src/gallium/auxiliary/util/u_format.h66
1 files changed, 65 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 96066532631..215a00ab551 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -120,8 +120,9 @@ enum util_format_colorspace {
struct util_format_channel_description
{
- unsigned type:6; /**< UTIL_FORMAT_TYPE_x */
+ unsigned type:5; /**< UTIL_FORMAT_TYPE_x */
unsigned normalized:1;
+ unsigned pure_integer:1;
unsigned size:9; /**< bits per channel */
};
@@ -321,6 +322,37 @@ struct util_format_description
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height);
+ /**
+ * Unpack pixel blocks to R32G32B32A32_UINT.
+ * Note: strides are in bytes.
+ *
+ * Only defined for INT formats.
+ */
+ void
+ (*unpack_rgba_uint)(unsigned *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ void
+ (*pack_rgba_uint)(uint8_t *dst, unsigned dst_stride,
+ const unsigned *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ /**
+ * Unpack pixel blocks to R32G32B32A32_SINT.
+ * Note: strides are in bytes.
+ *
+ * Only defined for INT formats.
+ */
+ void
+ (*unpack_rgba_sint)(signed *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ void
+ (*pack_rgba_sint)(uint8_t *dst, unsigned dst_stride,
+ const int *src, unsigned src_stride,
+ unsigned width, unsigned height);
};
@@ -511,6 +543,14 @@ util_format_is_luminance_alpha(enum pipe_format format);
boolean
util_format_is_intensity(enum pipe_format format);
+boolean
+util_format_is_pure_integer(enum pipe_format format);
+
+boolean
+util_format_is_pure_sint(enum pipe_format format);
+
+boolean
+util_format_is_pure_uint(enum pipe_format format);
/**
* Whether the src format can be blitted to destation format with a simple
@@ -854,6 +894,30 @@ util_format_write_4ub(enum pipe_format format,
void *dst, unsigned dst_stride,
unsigned x, unsigned y, unsigned w, unsigned h);
+void
+util_format_read_4ui(enum pipe_format format,
+ unsigned *dst, unsigned dst_stride,
+ const void *src, unsigned src_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h);
+
+void
+util_format_write_4ui(enum pipe_format format,
+ const unsigned int *src, unsigned src_stride,
+ void *dst, unsigned dst_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h);
+
+void
+util_format_read_4i(enum pipe_format format,
+ int *dst, unsigned dst_stride,
+ const void *src, unsigned src_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h);
+
+void
+util_format_write_4i(enum pipe_format format,
+ const int *src, unsigned src_stride,
+ void *dst, unsigned dst_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h);
+
/*
* Generic format conversion;
*/