[Mesa-dev] [PATCH v2 03/11] mesa/st: add helper to return pipe_endian based on pipe_format
Oded Gabbay
oded.gabbay at gmail.com
Thu Apr 14 12:18:46 UTC 2016
Add a helper function which receives pipe_format value and returns a
matching pipe_endian value. It is needed because almost every call to
st_create_texture will use this function to send the pipe_endian value
Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
---
src/mesa/state_tracker/st_format.c | 51 ++++++++++++++++++++++++++++++++++++++
src/mesa/state_tracker/st_format.h | 3 +++
2 files changed, 54 insertions(+)
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 9a280fc..cc44c9a 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -2501,3 +2501,54 @@ st_translate_color(const union gl_color_union *colorIn,
}
}
}
+
+enum pipe_endian
+st_get_endian_by_format(enum pipe_format format)
+{
+ /* return native endianess by default, except for a couple of gallium
+ * formats, where gallium provides different formats based on endianess */
+ switch (format)
+ {
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
+ case PIPE_FORMAT_R8G8B8X8_UNORM:
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_R8G8B8A8_SNORM:
+ case PIPE_FORMAT_R8G8B8X8_SNORM:
+ case PIPE_FORMAT_A8B8G8R8_SNORM:
+ case PIPE_FORMAT_X8B8G8R8_SNORM:
+ case PIPE_FORMAT_R8G8B8A8_SRGB:
+ case PIPE_FORMAT_R8G8B8X8_SRGB:
+ case PIPE_FORMAT_B8G8R8A8_SRGB:
+ case PIPE_FORMAT_B8G8R8X8_SRGB:
+ case PIPE_FORMAT_A8R8G8B8_SRGB:
+ case PIPE_FORMAT_X8R8G8B8_SRGB:
+ case PIPE_FORMAT_A8B8G8R8_SRGB:
+ case PIPE_FORMAT_X8B8G8R8_SRGB:
+ case PIPE_FORMAT_A8L8_UNORM:
+ case PIPE_FORMAT_L8A8_UNORM:
+ case PIPE_FORMAT_A8L8_SNORM:
+ case PIPE_FORMAT_L8A8_SNORM:
+ case PIPE_FORMAT_A8L8_SRGB:
+ case PIPE_FORMAT_L8A8_SRGB:
+ case PIPE_FORMAT_A16L16_UNORM:
+ case PIPE_FORMAT_L16A16_UNORM:
+ case PIPE_FORMAT_G8R8_UNORM:
+ case PIPE_FORMAT_R8G8_UNORM:
+ case PIPE_FORMAT_G8R8_SNORM:
+ case PIPE_FORMAT_R8G8_SNORM:
+ case PIPE_FORMAT_G16R16_UNORM:
+ case PIPE_FORMAT_R16G16_UNORM:
+ case PIPE_FORMAT_G16R16_SNORM:
+ case PIPE_FORMAT_R16G16_SNORM:
+ return PIPE_ENDIAN_LITTLE;
+
+ default:
+ return PIPE_ENDIAN_NATIVE;
+ }
+}
+
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 6ba61df..fbc8dfa 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -79,6 +79,9 @@ st_translate_color(const union gl_color_union *colorIn,
union pipe_color_union *colorOut,
GLenum baseFormat, GLboolean is_integer);
+extern enum pipe_endian
+st_get_endian_by_format(enum pipe_format format);
+
#ifdef __cplusplus
}
#endif
--
2.5.5
More information about the mesa-dev
mailing list