summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-01-02 02:59:51 +0100
committerMarek Olšák <[email protected]>2012-01-05 18:29:11 +0100
commit1ba3240b281fcbbf03372a6e2db68292cb8a8907 (patch)
treea57311a2af64840a44734c03278db57cf9bbdd90 /src/gallium/auxiliary
parent0950086376b1c8b7fb89eda81ed7f2f06dee58bc (diff)
u_format: implement fetch_rgba_uint and fetch_rgba_sint for integer formats
Fetching int as float and vice versa is not allowed. Fetching unsigned int as signed int and vice versa is not allowed either. Doing conversions like that isn't allowed for samplers in OpenGL. The three hooks could be consolidated into one fetch hook, which would fetch uint as uint32, sint as sint32, and everything else as float. The receiving parameter would be void*. This would be useful for implementing vertex fetches for shader model 4.0, which has untyped registers. Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_format.h22
-rw-r--r--src/gallium/auxiliary/util/u_format_pack.py2
-rwxr-xr-xsrc/gallium/auxiliary/util/u_format_table.py12
3 files changed, 32 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 9694c9034d2..874ea7eb12a 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -254,7 +254,7 @@ struct util_format_description
/**
* Fetch a single pixel (i, j) from a block.
*
- * Only defined for non-depth-stencil formats.
+ * Only defined for non-depth-stencil and non-integer formats.
*/
void
(*fetch_rgba_float)(float *dst,
@@ -358,6 +358,26 @@ struct util_format_description
(*pack_rgba_sint)(uint8_t *dst, unsigned dst_stride,
const int *src, unsigned src_stride,
unsigned width, unsigned height);
+
+ /**
+ * Fetch a single pixel (i, j) from a block.
+ *
+ * Only defined for unsigned (pure) integer formats.
+ */
+ void
+ (*fetch_rgba_uint)(uint32_t *dst,
+ const uint8_t *src,
+ unsigned i, unsigned j);
+
+ /**
+ * Fetch a single pixel (i, j) from a block.
+ *
+ * Only defined for signed (pure) integer formats.
+ */
+ void
+ (*fetch_rgba_sint)(int32_t *dst,
+ const uint8_t *src,
+ unsigned i, unsigned j);
};
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index fff409fb75d..0b3a890d591 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -686,6 +686,7 @@ def generate(formats):
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
+ generate_format_fetch(format, channel, native_type, suffix)
channel = Channel(SIGNED, False, True, 32)
native_type = 'int'
@@ -699,6 +700,7 @@ def generate(formats):
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
+ generate_format_fetch(format, channel, native_type, suffix)
native_type = 'unsigned'
suffix = 'unsigned'
diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py
index 07beb38723b..8edb505237d 100755
--- a/src/gallium/auxiliary/util/u_format_table.py
+++ b/src/gallium/auxiliary/util/u_format_table.py
@@ -169,17 +169,23 @@ def write_format_table(formats):
print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
- print " &util_format_%s_pack_signed /* pack_rgba_sint */" % format.short_name()
+ print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name()
+ print " &util_format_%s_fetch_unsigned, /* fetch_rgba_uint */" % format.short_name()
+ print " NULL /* fetch_rgba_sint */"
elif format.colorspace != ZS and format.channels[0].pure == True and format.channels[0].type == SIGNED:
print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
- print " &util_format_%s_pack_signed /* pack_rgba_sint */" % format.short_name()
+ print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name()
+ print " NULL, /* fetch_rgba_uint */"
+ print " &util_format_%s_fetch_signed /* fetch_rgba_sint */" % format.short_name()
else:
print " NULL, /* unpack_rgba_uint */"
print " NULL, /* pack_rgba_uint */"
print " NULL, /* unpack_rgba_sint */"
- print " NULL /* pack_rgba_sint */"
+ print " NULL, /* pack_rgba_sint */"
+ print " NULL, /* fetch_rgba_uint */"
+ print " NULL /* fetch_rgba_sint */"
print "};"
print