[Mesa-dev] [PATCH 3/7] i965: Add an image format metadata array

Jason Ekstrand jason at jlekstrand.net
Wed Nov 4 17:03:52 PST 2015


This little data structure and associated array contains all of the image
format metadata needed for doing image_load_store work-arounds.  This way
we can pull metadata from within the i965 driver without having to go out
to core mesa for it.  It is a bit of duplication with what we have in core
mesa but it's limited enough that it's easily verified and not a big deal.
---
 src/mesa/drivers/dri/i965/brw_image_load_store.c | 45 ++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_image_load_store.h | 20 +++++++++++
 2 files changed, 65 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_image_load_store.c b/src/mesa/drivers/dri/i965/brw_image_load_store.c
index 4876041..b78d6b2 100644
--- a/src/mesa/drivers/dri/i965/brw_image_load_store.c
+++ b/src/mesa/drivers/dri/i965/brw_image_load_store.c
@@ -26,6 +26,51 @@
 #include "brw_defines.h"
 #include "brw_image_load_store.h"
 
+#define IF(r, g, b, a, dt, f) \
+   [BRW_SURFACEFORMAT_##f] = { true, r, g, b, a, BRW_IMAGE_FORMAT_##dt },
+const struct brw_image_format_info brw_image_format_info[] = {
+   IF( 8,  0,  0,  0, UNORM, R8_UNORM)
+   IF( 8,  0,  0,  0, SNORM, R8_SNORM)
+   IF( 8,  0,  0,  0,  UINT, R8_UINT)
+   IF( 8,  0,  0,  0,  SINT, R8_SINT)
+   IF( 8,  8,  0,  0, UNORM, R8G8_UNORM)
+   IF( 8,  8,  0,  0, SNORM, R8G8_SNORM)
+   IF( 8,  8,  0,  0,  UINT, R8G8_UINT)
+   IF( 8,  8,  0,  0,  SINT, R8G8_SINT)
+   IF( 8,  8,  8,  8, UNORM, R8G8B8A8_UNORM)
+   IF( 8,  8,  8,  8, SNORM, R8G8B8A8_SNORM)
+   IF( 8,  8,  8,  8,  UINT, R8G8B8A8_UINT)
+   IF( 8,  8,  8,  8,  SINT, R8G8B8A8_SINT)
+   IF(11, 11, 10,  0, FLOAT, R11G11B10_FLOAT)
+   IF(10, 10, 10,  2, UNORM, R10G10B10A2_UNORM)
+   IF(10, 10, 10,  2,  UINT, R10G10B10A2_UINT)
+   IF(16,  0,  0,  0, UNORM, R16_UNORM)
+   IF(16,  0,  0,  0, SNORM, R16_SNORM)
+   IF(16,  0,  0,  0, FLOAT, R16_FLOAT)
+   IF(16,  0,  0,  0,  UINT, R16_UINT)
+   IF(16,  0,  0,  0,  SINT, R16_SINT)
+   IF(16, 16,  0,  0, UNORM, R16G16_UNORM)
+   IF(16, 16,  0,  0, SNORM, R16G16_SNORM)
+   IF(16, 16,  0,  0, FLOAT, R16G16_FLOAT)
+   IF(16, 16,  0,  0,  UINT, R16G16_UINT)
+   IF(16, 16,  0,  0,  SINT, R16G16_SINT)
+   IF(16, 16, 16, 16, UNORM, R16G16B16A16_UNORM)
+   IF(16, 16, 16, 16, SNORM, R16G16B16A16_SNORM)
+   IF(16, 16, 16, 16, FLOAT, R16G16B16A16_FLOAT)
+   IF(16, 16, 16, 16,  UINT, R16G16B16A16_UINT)
+   IF(16, 16, 16, 16,  SINT, R16G16B16A16_SINT)
+   IF(32,  0,  0,  0, FLOAT, R32_FLOAT)
+   IF(32,  0,  0,  0,  UINT, R32_UINT)
+   IF(32,  0,  0,  0,  SINT, R32_SINT)
+   IF(32, 32,  0,  0, FLOAT, R32G32_FLOAT)
+   IF(32, 32,  0,  0,  UINT, R32G32_UINT)
+   IF(32, 32,  0,  0,  SINT, R32G32_SINT)
+   IF(32, 32, 32, 32, FLOAT, R32G32B32A32_FLOAT)
+   IF(32, 32, 32, 32,  UINT, R32G32B32A32_UINT)
+   IF(32, 32, 32, 32,  SINT, R32G32B32A32_SINT)
+};
+#undef IF
+
 uint32_t
 brw_lower_image_format(const struct brw_device_info *devinfo,
                        uint32_t format)
diff --git a/src/mesa/drivers/dri/i965/brw_image_load_store.h b/src/mesa/drivers/dri/i965/brw_image_load_store.h
index 883eec4..2ab85cc 100644
--- a/src/mesa/drivers/dri/i965/brw_image_load_store.h
+++ b/src/mesa/drivers/dri/i965/brw_image_load_store.h
@@ -23,6 +23,7 @@
 
 #pragma once
 
+#include <stdbool.h>
 #include <stdint.h>
 
 #include "brw_device_info.h"
@@ -31,6 +32,25 @@
 extern "C" {
 #endif
 
+enum brw_image_format_data_type {
+   BRW_IMAGE_FORMAT_UNORM,
+   BRW_IMAGE_FORMAT_SNORM,
+   BRW_IMAGE_FORMAT_UINT,
+   BRW_IMAGE_FORMAT_SINT,
+   BRW_IMAGE_FORMAT_FLOAT,
+};
+
+struct brw_image_format_info {
+   bool is_image_format;
+   uint8_t red_bits;
+   uint8_t green_bits;
+   uint8_t blue_bits;
+   uint8_t alpha_bits;
+   enum brw_image_format_data_type data_type;
+};
+
+extern const struct brw_image_format_info brw_image_format_info[];
+
 uint32_t brw_lower_image_format(const struct brw_device_info *devinfo,
                                 uint32_t format);
 #ifdef __cplusplus
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list