[Mesa-dev] [PATCH 04/13] isl: Take a devinfo in lower_storage_image_format instead of an isl_device

Jason Ekstrand jason at jlekstrand.net
Sat Apr 16 19:45:12 UTC 2016


We want to call this function from the shader compiler and having a full
isl_device available at that point isn't practical.
---
 src/intel/isl/isl.h               |  2 +-
 src/intel/isl/isl_storage_image.c | 30 +++++++++++++++---------------
 src/intel/isl/isl_surface_state.c |  3 ++-
 src/intel/vulkan/anv_image.c      |  2 +-
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index c3a1106..2982bad 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -909,7 +909,7 @@ enum isl_format isl_format_rgb_to_rgbx(enum isl_format rgb) ATTRIBUTE_CONST;
 bool isl_is_storage_image_format(enum isl_format fmt);
 
 enum isl_format
-isl_lower_storage_image_format(const struct isl_device *dev,
+isl_lower_storage_image_format(const struct brw_device_info *devinfo,
                                enum isl_format fmt);
 
 static inline bool
diff --git a/src/intel/isl/isl_storage_image.c b/src/intel/isl/isl_storage_image.c
index 2b5b5cd..8d9bea3 100644
--- a/src/intel/isl/isl_storage_image.c
+++ b/src/intel/isl/isl_storage_image.c
@@ -76,7 +76,7 @@ isl_is_storage_image_format(enum isl_format format)
 }
 
 enum isl_format
-isl_lower_storage_image_format(const struct isl_device *dev,
+isl_lower_storage_image_format(const struct brw_device_info *devinfo,
                                enum isl_format format)
 {
    switch (format) {
@@ -100,8 +100,8 @@ isl_lower_storage_image_format(const struct isl_device *dev,
    case ISL_FORMAT_R32G32_UINT:
    case ISL_FORMAT_R32G32_SINT:
    case ISL_FORMAT_R32G32_FLOAT:
-      return (ISL_DEV_GEN(dev) >= 9 ? format :
-              ISL_DEV_GEN(dev) >= 8 || dev->info->is_haswell ?
+      return (devinfo->gen >= 9 ? format :
+              devinfo->gen >= 8 || devinfo->is_haswell ?
               ISL_FORMAT_R16G16B16A16_UINT :
               ISL_FORMAT_R32G32_UINT);
 
@@ -117,31 +117,31 @@ isl_lower_storage_image_format(const struct isl_device *dev,
     */
    case ISL_FORMAT_R8G8B8A8_UINT:
    case ISL_FORMAT_R8G8B8A8_SINT:
-      return (ISL_DEV_GEN(dev) >= 9 ? format :
-              ISL_DEV_GEN(dev) >= 8 || dev->info->is_haswell ?
+      return (devinfo->gen >= 9 ? format :
+              devinfo->gen >= 8 || devinfo->is_haswell ?
               ISL_FORMAT_R8G8B8A8_UINT : ISL_FORMAT_R32_UINT);
 
    case ISL_FORMAT_R16G16_UINT:
    case ISL_FORMAT_R16G16_SINT:
    case ISL_FORMAT_R16G16_FLOAT:
-      return (ISL_DEV_GEN(dev) >= 9 ? format :
-              ISL_DEV_GEN(dev) >= 8 || dev->info->is_haswell ?
+      return (devinfo->gen >= 9 ? format :
+              devinfo->gen >= 8 || devinfo->is_haswell ?
               ISL_FORMAT_R16G16_UINT : ISL_FORMAT_R32_UINT);
 
    case ISL_FORMAT_R8G8_UINT:
    case ISL_FORMAT_R8G8_SINT:
-      return (ISL_DEV_GEN(dev) >= 9 ? format :
-              ISL_DEV_GEN(dev) >= 8 || dev->info->is_haswell ?
+      return (devinfo->gen >= 9 ? format :
+              devinfo->gen >= 8 || devinfo->is_haswell ?
               ISL_FORMAT_R8G8_UINT : ISL_FORMAT_R16_UINT);
 
    case ISL_FORMAT_R16_UINT:
    case ISL_FORMAT_R16_FLOAT:
    case ISL_FORMAT_R16_SINT:
-      return (ISL_DEV_GEN(dev) >= 9 ? format : ISL_FORMAT_R16_UINT);
+      return (devinfo->gen >= 9 ? format : ISL_FORMAT_R16_UINT);
 
    case ISL_FORMAT_R8_UINT:
    case ISL_FORMAT_R8_SINT:
-      return (ISL_DEV_GEN(dev) >= 9 ? format : ISL_FORMAT_R8_UINT);
+      return (devinfo->gen >= 9 ? format : ISL_FORMAT_R8_UINT);
 
    /* Neither the 2/10/10/10 nor the 11/11/10 packed formats are supported
     * by the hardware.
@@ -154,23 +154,23 @@ isl_lower_storage_image_format(const struct isl_device *dev,
    /* No normalized fixed-point formats are supported by the hardware. */
    case ISL_FORMAT_R16G16B16A16_UNORM:
    case ISL_FORMAT_R16G16B16A16_SNORM:
-      return (ISL_DEV_GEN(dev) >= 8 || dev->info->is_haswell ?
+      return (devinfo->gen >= 8 || devinfo->is_haswell ?
               ISL_FORMAT_R16G16B16A16_UINT :
               ISL_FORMAT_R32G32_UINT);
 
    case ISL_FORMAT_R8G8B8A8_UNORM:
    case ISL_FORMAT_R8G8B8A8_SNORM:
-      return (ISL_DEV_GEN(dev) >= 8 || dev->info->is_haswell ?
+      return (devinfo->gen >= 8 || devinfo->is_haswell ?
               ISL_FORMAT_R8G8B8A8_UINT : ISL_FORMAT_R32_UINT);
 
    case ISL_FORMAT_R16G16_UNORM:
    case ISL_FORMAT_R16G16_SNORM:
-      return (ISL_DEV_GEN(dev) >= 8 || dev->info->is_haswell ?
+      return (devinfo->gen >= 8 || devinfo->is_haswell ?
               ISL_FORMAT_R16G16_UINT : ISL_FORMAT_R32_UINT);
 
    case ISL_FORMAT_R8G8_UNORM:
    case ISL_FORMAT_R8G8_SNORM:
-      return (ISL_DEV_GEN(dev) >= 8 || dev->info->is_haswell ?
+      return (devinfo->gen >= 8 || devinfo->is_haswell ?
               ISL_FORMAT_R8G8_UINT : ISL_FORMAT_R16_UINT);
 
    case ISL_FORMAT_R16_UNORM:
diff --git a/src/intel/isl/isl_surface_state.c b/src/intel/isl/isl_surface_state.c
index cac59fa..dd88531 100644
--- a/src/intel/isl/isl_surface_state.c
+++ b/src/intel/isl/isl_surface_state.c
@@ -308,7 +308,8 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
    }
 
    if (info->view->usage & ISL_SURF_USAGE_STORAGE_BIT) {
-      s.SurfaceFormat = isl_lower_storage_image_format(dev, info->view->format);
+      s.SurfaceFormat =
+         isl_lower_storage_image_format(dev->info, info->view->format);
    } else {
       s.SurfaceFormat = info->view->format;
    }
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index db10962..7236b81 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -678,7 +678,7 @@ void anv_buffer_view_init(struct anv_buffer_view *view,
 
       enum isl_format storage_format =
          has_matching_storage_typed_format(device, view->format) ?
-         isl_lower_storage_image_format(&device->isl_dev, view->format) :
+         isl_lower_storage_image_format(&device->info, view->format) :
          ISL_FORMAT_RAW;
 
       anv_fill_buffer_surface_state(device, view->storage_surface_state,
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list