intel: Split gen_device_info out into libintel_dev
[mesa.git] / src / intel / isl / isl_priv.h
index bca8503b4fd8dce420b5a33c6c248b2c1186e3c9..871518409eef258ae8edb9503861ddeac9b10d1b 100644 (file)
  *  IN THE SOFTWARE.
  */
 
-#pragma once
+#ifndef ISL_PRIV_H
+#define ISL_PRIV_H
 
 #include <assert.h>
+#include <strings.h>
 
-#include "brw_device_info.h"
+#include "dev/gen_device_info.h"
 #include "util/macros.h"
 
 #include "isl.h"
 
 #define isl_finishme(format, ...) \
-   __isl_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__)
+   do { \
+      static bool reported = false; \
+      if (!reported) { \
+         __isl_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__); \
+         reported = true; \
+      } \
+   } while (0)
 
 void PRINTFLIKE(3, 4) UNUSED
 __isl_finishme(const char *file, int line, const char *fmt, ...);
@@ -39,11 +47,6 @@ __isl_finishme(const char *file, int line, const char *fmt, ...);
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 
-static inline uint32_t
-ffs(uint32_t n) {
-   return __builtin_ffs(n);
-}
-
 static inline bool
 isl_is_pow2(uintmax_t n)
 {
@@ -77,6 +80,13 @@ isl_align_npot(uintmax_t n, uintmax_t a)
    return ((n + a - 1) / a) * a;
 }
 
+static inline uintmax_t
+isl_assert_div(uintmax_t n, uintmax_t a)
+{
+   assert(n % a == 0);
+   return n / a;
+}
+
 /**
  * Alignment must be a power of 2.
  */
@@ -102,6 +112,15 @@ isl_log2u(uint32_t n)
    return 31 - __builtin_clz(n);
 }
 
+static inline uint32_t
+isl_round_up_to_power_of_two(uint32_t value)
+{
+   if (value <= 1)
+      return value;
+
+   return 1 << (32 - __builtin_clz(value - 1));
+}
+
 static inline uint32_t
 isl_minify(uint32_t n, uint32_t levels)
 {
@@ -138,3 +157,42 @@ isl_extent3d_el_to_sa(enum isl_format fmt, struct isl_extent3d extent_el)
       .d = extent_el.d * fmtl->bd,
    };
 }
+
+/* This is useful for adding the isl_prefix to genX functions */
+#define __PASTE2(x, y) x ## y
+#define __PASTE(x, y) __PASTE2(x, y)
+#define isl_genX(x) __PASTE(isl_, genX(x))
+
+#ifdef genX
+#  include "isl_genX_priv.h"
+#else
+#  define genX(x) gen4_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#  define genX(x) gen5_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#  define genX(x) gen6_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#  define genX(x) gen7_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#  define genX(x) gen75_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#  define genX(x) gen8_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#  define genX(x) gen9_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#  define genX(x) gen10_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#  define genX(x) gen11_##x
+#  include "isl_genX_priv.h"
+#  undef genX
+#endif
+
+#endif /* ISL_PRIV_H */