[Mesa-dev] [PATCH 2/8] compiler/enums: Add an image format enum
Jason Ekstrand
jason at jlekstrand.net
Thu Jul 13 07:32:12 UTC 2017
We have to pass these around various places that are API agnostic. It's
nice to have an API agnostic enum and also be able to print it.
---
src/compiler/shader_enums.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
src/compiler/shader_enums.h | 54 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+)
diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c
index b2ca80b..3939e30 100644
--- a/src/compiler/shader_enums.c
+++ b/src/compiler/shader_enums.c
@@ -273,3 +273,59 @@ gl_frag_result_name(gl_frag_result result)
STATIC_ASSERT(ARRAY_SIZE(names) == FRAG_RESULT_MAX);
return NAME(result);
}
+
+const char *
+gl_image_format_name(enum gl_image_format format)
+{
+ switch (format) {
+#define CASE(fmt) case fmt: return #fmt;
+ CASE(IMAGE_FORMAT_NONE)
+
+ CASE(IMAGE_FORMAT_RGBA32F)
+ CASE(IMAGE_FORMAT_RGBA16F)
+ CASE(IMAGE_FORMAT_RG32F)
+ CASE(IMAGE_FORMAT_RG16F)
+ CASE(IMAGE_FORMAT_R11F_G11F_B10F)
+ CASE(IMAGE_FORMAT_R32F)
+ CASE(IMAGE_FORMAT_R16F)
+
+ CASE(IMAGE_FORMAT_RGBA32UI)
+ CASE(IMAGE_FORMAT_RGBA16UI)
+ CASE(IMAGE_FORMAT_RGB10_A2UI)
+ CASE(IMAGE_FORMAT_RGBA8UI)
+ CASE(IMAGE_FORMAT_RG32UI)
+ CASE(IMAGE_FORMAT_RG16UI)
+ CASE(IMAGE_FORMAT_RG8UI)
+ CASE(IMAGE_FORMAT_R32UI)
+ CASE(IMAGE_FORMAT_R16UI)
+ CASE(IMAGE_FORMAT_R8UI)
+
+ CASE(IMAGE_FORMAT_RGBA32I)
+ CASE(IMAGE_FORMAT_RGBA16I)
+ CASE(IMAGE_FORMAT_RGBA8I)
+ CASE(IMAGE_FORMAT_RG32I)
+ CASE(IMAGE_FORMAT_RG16I)
+ CASE(IMAGE_FORMAT_RG8I)
+ CASE(IMAGE_FORMAT_R32I)
+ CASE(IMAGE_FORMAT_R16I)
+ CASE(IMAGE_FORMAT_R8I)
+
+ CASE(IMAGE_FORMAT_RGBA16)
+ CASE(IMAGE_FORMAT_RGB10_A2)
+ CASE(IMAGE_FORMAT_RGBA8)
+ CASE(IMAGE_FORMAT_RG16)
+ CASE(IMAGE_FORMAT_RG8)
+ CASE(IMAGE_FORMAT_R16)
+ CASE(IMAGE_FORMAT_R8)
+
+ CASE(IMAGE_FORMAT_RGBA16_SNORM)
+ CASE(IMAGE_FORMAT_RGBA8_SNORM)
+ CASE(IMAGE_FORMAT_RG16_SNORM)
+ CASE(IMAGE_FORMAT_RG8_SNORM)
+ CASE(IMAGE_FORMAT_R16_SNORM)
+ CASE(IMAGE_FORMAT_R8_SNORM)
+#undef CASE
+ };
+
+ unreachable("Unknown image format.");
+}
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 352f270..4a227ce 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -26,6 +26,8 @@
#ifndef SHADER_ENUMS_H
#define SHADER_ENUMS_H
+#include "util/macros.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -663,6 +665,58 @@ enum gl_tess_spacing
TESS_SPACING_FRACTIONAL_EVEN,
};
+/* These match the GL enums */
+enum PACKED gl_image_format
+{
+ IMAGE_FORMAT_NONE = 0,
+
+ IMAGE_FORMAT_RGBA32F = 0x8814,
+ IMAGE_FORMAT_RGBA16F = 0x881A,
+ IMAGE_FORMAT_RG32F = 0x8230,
+ IMAGE_FORMAT_RG16F = 0x822F,
+ IMAGE_FORMAT_R11F_G11F_B10F = 0x8C3A,
+ IMAGE_FORMAT_R32F = 0x822E,
+ IMAGE_FORMAT_R16F = 0x822D,
+
+ IMAGE_FORMAT_RGBA32UI = 0x8D70,
+ IMAGE_FORMAT_RGBA16UI = 0x8D76,
+ IMAGE_FORMAT_RGB10_A2UI = 0x906F,
+ IMAGE_FORMAT_RGBA8UI = 0x8D7C,
+ IMAGE_FORMAT_RG32UI = 0x823C,
+ IMAGE_FORMAT_RG16UI = 0x823A,
+ IMAGE_FORMAT_RG8UI = 0x8238,
+ IMAGE_FORMAT_R32UI = 0x8236,
+ IMAGE_FORMAT_R16UI = 0x8234,
+ IMAGE_FORMAT_R8UI = 0x8232,
+
+ IMAGE_FORMAT_RGBA32I = 0x8D82,
+ IMAGE_FORMAT_RGBA16I = 0x8D88,
+ IMAGE_FORMAT_RGBA8I = 0x8D8E,
+ IMAGE_FORMAT_RG32I = 0x823B,
+ IMAGE_FORMAT_RG16I = 0x8239,
+ IMAGE_FORMAT_RG8I = 0x8237,
+ IMAGE_FORMAT_R32I = 0x8235,
+ IMAGE_FORMAT_R16I = 0x8233,
+ IMAGE_FORMAT_R8I = 0x8231,
+
+ IMAGE_FORMAT_RGBA16 = 0x805B,
+ IMAGE_FORMAT_RGB10_A2 = 0x8059,
+ IMAGE_FORMAT_RGBA8 = 0x8058,
+ IMAGE_FORMAT_RG16 = 0x822C,
+ IMAGE_FORMAT_RG8 = 0x822B,
+ IMAGE_FORMAT_R16 = 0x822A,
+ IMAGE_FORMAT_R8 = 0x8229,
+
+ IMAGE_FORMAT_RGBA16_SNORM = 0x8F9B,
+ IMAGE_FORMAT_RGBA8_SNORM = 0x8F97,
+ IMAGE_FORMAT_RG16_SNORM = 0x8F99,
+ IMAGE_FORMAT_RG8_SNORM = 0x8F95,
+ IMAGE_FORMAT_R16_SNORM = 0x8F98,
+ IMAGE_FORMAT_R8_SNORM = 0x8F94,
+};
+
+const char *gl_image_format_name(enum gl_image_format format);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list