diff options
author | Dave Airlie <[email protected]> | 2011-09-19 15:04:48 +0100 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2011-10-08 17:44:59 +0100 |
commit | a441feb757b1be4845ba378f0207dcdc5cc1a407 (patch) | |
tree | 63a6b44c082a8850a0001fa8e772d58042123dc4 /src/gallium/auxiliary/util/u_tile.c | |
parent | c2060c0af7de4678d55962369244451fe678c4e8 (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_tile.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_tile.c | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 23f12e5f464..6342bfbfc3a 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -389,6 +389,29 @@ pipe_tile_raw_to_rgba(enum pipe_format format, } } +void +pipe_tile_raw_to_unsigned(enum pipe_format format, + void *src, + uint w, uint h, + unsigned *dst, unsigned dst_stride) +{ + util_format_read_4ui(format, + dst, dst_stride * sizeof(float), + src, util_format_get_stride(format, w), + 0, 0, w, h); +} + +void +pipe_tile_raw_to_signed(enum pipe_format format, + void *src, + uint w, uint h, + int *dst, unsigned dst_stride) +{ + util_format_read_4i(format, + dst, dst_stride * sizeof(float), + src, util_format_get_stride(format, w), + 0, 0, w, h); +} void pipe_get_tile_rgba(struct pipe_context *pipe, @@ -492,6 +515,61 @@ pipe_put_tile_rgba_format(struct pipe_context *pipe, FREE(packed); } +void +pipe_put_tile_i_format(struct pipe_context *pipe, + struct pipe_transfer *pt, + uint x, uint y, uint w, uint h, + enum pipe_format format, + const int *p) +{ + unsigned src_stride = w * 4; + void *packed; + + if (u_clip_tile(x, y, &w, &h, &pt->box)) + return; + + packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format)); + + if (!packed) + return; + + util_format_write_4i(format, + p, src_stride * sizeof(float), + packed, util_format_get_stride(format, w), + 0, 0, w, h); + + pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0); + + FREE(packed); +} + +void +pipe_put_tile_ui_format(struct pipe_context *pipe, + struct pipe_transfer *pt, + uint x, uint y, uint w, uint h, + enum pipe_format format, + const unsigned int *p) +{ + unsigned src_stride = w * 4; + void *packed; + + if (u_clip_tile(x, y, &w, &h, &pt->box)) + return; + + packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format)); + + if (!packed) + return; + + util_format_write_4ui(format, + p, src_stride * sizeof(float), + packed, util_format_get_stride(format, w), + 0, 0, w, h); + + pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0); + + FREE(packed); +} /** * Get a block of Z values, converted to 32-bit range. @@ -688,3 +766,63 @@ pipe_put_tile_z(struct pipe_context *pipe, } +void +pipe_get_tile_ui_format(struct pipe_context *pipe, + struct pipe_transfer *pt, + uint x, uint y, uint w, uint h, + enum pipe_format format, + unsigned int *p) +{ + unsigned dst_stride = w * 4; + void *packed; + + if (u_clip_tile(x, y, &w, &h, &pt->box)) { + return; + } + + packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format)); + if (!packed) { + return; + } + + if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) { + assert((x & 1) == 0); + } + + pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0); + + pipe_tile_raw_to_unsigned(format, packed, w, h, p, dst_stride); + + FREE(packed); +} + + +void +pipe_get_tile_i_format(struct pipe_context *pipe, + struct pipe_transfer *pt, + uint x, uint y, uint w, uint h, + enum pipe_format format, + int *p) +{ + unsigned dst_stride = w * 4; + void *packed; + + if (u_clip_tile(x, y, &w, &h, &pt->box)) { + return; + } + + packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format)); + if (!packed) { + return; + } + + if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) { + assert((x & 1) == 0); + } + + pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0); + + pipe_tile_raw_to_signed(format, packed, w, h, p, dst_stride); + + FREE(packed); +} |