aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.c41
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h12
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_other.c10
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_parse.py11
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_inlines.h16
5 files changed, 32 insertions, 58 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c
index ddce95601..8228de1f2 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format.c
@@ -134,47 +134,6 @@ util_format_is_pure_uint(enum pipe_format format)
return (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
}
-boolean
-util_format_is_array(const struct util_format_description *desc)
-{
- unsigned chan;
-
- if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
- desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB ||
- desc->block.width != 1 ||
- desc->block.height != 1) {
- return FALSE;
- }
-
- for (chan = 0; chan < desc->nr_channels; ++chan) {
- if (desc->channel[chan].size != desc->channel[0].size)
- return FALSE;
-
- if (desc->channel[chan].type == UTIL_FORMAT_TYPE_VOID && (chan + 1) == desc->nr_channels)
- continue;
-
- if (desc->channel[chan].type != desc->channel[0].type)
- return FALSE;
-
- if (desc->channel[chan].normalized != desc->channel[0].normalized)
- return FALSE;
-
- if (desc->channel[chan].pure_integer != desc->channel[0].pure_integer)
- return FALSE;
- }
-
- if (desc->nr_channels == 4) {
- if (desc->swizzle[3] < 3)
- return FALSE;
- } else {
- for (chan = 0; chan < desc->nr_channels; ++chan) {
- if (desc->swizzle[chan] != chan)
- return FALSE;
- }
- }
-
- return TRUE;
-}
boolean
util_format_is_luminance_alpha(enum pipe_format format)
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 25bfd234b..024dabb07 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -156,7 +156,7 @@ struct util_format_description
unsigned nr_channels:3;
/**
- * Whether all channels have the same number of (whole) bytes.
+ * Whether all channels have the same number of (whole) bytes and type.
*/
unsigned is_array:1;
@@ -591,16 +591,6 @@ boolean
util_format_is_pure_uint(enum pipe_format format);
/**
- * Whether the format is a simple array format where all channels
- * are of the same type and can be loaded from memory as a vector.
- *
- * If format is 4 channel it can be swizzled (eg BGRA) as long
- * as the alpha is the 3rd channel.
- */
-boolean
-util_format_is_array(const struct util_format_description *desc);
-
-/**
* Check if the src format can be blitted to the destination format with
* a simple memcpy. For example, blitting from RGBA to RGBx is OK, but not
* the reverse.
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_other.c b/mesalib/src/gallium/auxiliary/util/u_format_other.c
index c23f4ee4a..85001c14f 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_other.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_other.c
@@ -342,7 +342,7 @@ util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
int16_t r, g;
#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
+ value = util_bswap16(value);
#endif
r = ((int16_t)(value << 8)) >> 8;
@@ -374,7 +374,7 @@ util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid
int16_t r, g;
#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
+ value = util_bswap16(value);
#endif
r = ((int16_t)(value << 8)) >> 8;
@@ -408,7 +408,7 @@ util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
value |= (uint16_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ;
#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
+ value = util_bswap16(value);
#endif
*dst++ = value;
@@ -438,7 +438,7 @@ util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
value |= (src[1] >> 1) << 8;
#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
+ value = util_bswap16(value);
#endif
*dst++ = value;
@@ -459,7 +459,7 @@ util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src,
int16_t r, g;
#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
+ value = util_bswap16(value);
#endif
r = ((int16_t)(value << 8)) >> 8;
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_parse.py b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
index 3a39e5ba5..07052b996 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_parse.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
@@ -144,9 +144,18 @@ class Format:
if self.layout != PLAIN:
return False
ref_channel = self.channels[0]
- for channel in self.channels[1:]:
+ if ref_channel.type == VOID:
+ ref_channel = self.channels[1]
+ for channel in self.channels:
if channel.size and (channel.size != ref_channel.size or channel.size % 8):
return False
+ if channel.type != VOID:
+ if channel.type != ref_channel.type:
+ return False
+ if channel.norm != ref_channel.norm:
+ return False
+ if channel.pure != ref_channel.pure:
+ return False
return True
def is_mixed(self):
diff --git a/mesalib/src/gallium/auxiliary/util/u_inlines.h b/mesalib/src/gallium/auxiliary/util/u_inlines.h
index 6ef5fecc6..cb06ee2e0 100644
--- a/mesalib/src/gallium/auxiliary/util/u_inlines.h
+++ b/mesalib/src/gallium/auxiliary/util/u_inlines.h
@@ -114,6 +114,22 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
*ptr = surf;
}
+/**
+ * Similar to pipe_surface_reference() but always set the pointer to NULL
+ * and pass in an explicit context. The explicit context avoids the problem
+ * of using a deleted context's surface_destroy() method when freeing a surface
+ * that's shared by multiple contexts.
+ */
+static INLINE void
+pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr)
+{
+ if (pipe_reference_described(&(*ptr)->reference, NULL,
+ (debug_reference_descriptor)debug_describe_surface))
+ pipe->surface_destroy(pipe, *ptr);
+ *ptr = NULL;
+}
+
+
static INLINE void
pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
{