intel/isl/gen4: Make depth/stencil buffers Y-Tiled
[mesa.git] / src / compiler / glsl_types.h
index 0b4a66ca4d21a7c7c03d601912d37436654e1b31..efc6324865620a6a9bbfb89033754b5abdce67bc 100644 (file)
 
 #include "shader_enums.h"
 #include "blob.h"
+#include "c11/threads.h"
+
+#ifdef __cplusplus
+#include "main/config.h"
+#endif
 
 struct glsl_type;
 
@@ -61,7 +66,12 @@ enum glsl_base_type {
    GLSL_TYPE_UINT = 0,
    GLSL_TYPE_INT,
    GLSL_TYPE_FLOAT,
+   GLSL_TYPE_FLOAT16,
    GLSL_TYPE_DOUBLE,
+   GLSL_TYPE_UINT8,
+   GLSL_TYPE_INT8,
+   GLSL_TYPE_UINT16,
+   GLSL_TYPE_INT16,
    GLSL_TYPE_UINT64,
    GLSL_TYPE_INT64,
    GLSL_TYPE_BOOL,
@@ -141,51 +151,31 @@ enum {
 #ifdef __cplusplus
 #include "GL/gl.h"
 #include "util/ralloc.h"
-#include "main/mtypes.h" /* for gl_texture_index, C++'s enum rules are broken */
+#include "main/menums.h" /* for gl_texture_index, C++'s enum rules are broken */
 
 struct glsl_type {
    GLenum gl_type;
-   glsl_base_type base_type;
+   glsl_base_type base_type:8;
+
+   glsl_base_type sampled_type:8; /**< Type of data returned using this
+                                   * sampler or image.  Only \c
+                                   * GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
+                                   * and \c GLSL_TYPE_UINT are valid.
+                                   */
 
    unsigned sampler_dimensionality:4; /**< \see glsl_sampler_dim */
    unsigned sampler_shadow:1;
    unsigned sampler_array:1;
-   unsigned sampled_type:2;    /**< Type of data returned using this
-                               * sampler or image.  Only \c
-                               * GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
-                               * and \c GLSL_TYPE_UINT are valid.
-                               */
    unsigned interface_packing:2;
    unsigned interface_row_major:1;
 
-   /* Callers of this ralloc-based new need not call delete. It's
-    * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
-   static void* operator new(size_t size)
-   {
-      mtx_lock(&glsl_type::mem_mutex);
-
-      /* mem_ctx should have been created by the static members */
-      assert(glsl_type::mem_ctx != NULL);
-
-      void *type;
-
-      type = ralloc_size(glsl_type::mem_ctx, size);
-      assert(type != NULL);
-
-      mtx_unlock(&glsl_type::mem_mutex);
-
-      return type;
-   }
-
-   /* If the user *does* call delete, that's OK, we will just
-    * ralloc_free in that case. */
-   static void operator delete(void *type)
+private:
+   glsl_type() : mem_ctx(NULL)
    {
-      mtx_lock(&glsl_type::mem_mutex);
-      ralloc_free(type);
-      mtx_unlock(&glsl_type::mem_mutex);
+      // Dummy constructor, just for the sake of ASSERT_BITFIELD_SIZE.
    }
 
+public:
    /**
     * \name Vector and matrix element counts
     *
@@ -238,13 +228,19 @@ struct glsl_type {
     * Convenience accessors for vector types (shorter than get_instance()).
     * @{
     */
+   static const glsl_type *vec(unsigned components, const glsl_type *const ts[]);
    static const glsl_type *vec(unsigned components);
+   static const glsl_type *f16vec(unsigned components);
    static const glsl_type *dvec(unsigned components);
    static const glsl_type *ivec(unsigned components);
    static const glsl_type *uvec(unsigned components);
    static const glsl_type *bvec(unsigned components);
    static const glsl_type *i64vec(unsigned components);
    static const glsl_type *u64vec(unsigned components);
+   static const glsl_type *i16vec(unsigned components);
+   static const glsl_type *u16vec(unsigned components);
+   static const glsl_type *i8vec(unsigned components);
+   static const glsl_type *u8vec(unsigned components);
    /**@}*/
 
    /**
@@ -474,7 +470,9 @@ struct glsl_type {
    bool is_matrix() const
    {
       /* GLSL only has float matrices. */
-      return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT || base_type == GLSL_TYPE_DOUBLE);
+      return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT ||
+                                      base_type == GLSL_TYPE_DOUBLE ||
+                                      base_type == GLSL_TYPE_FLOAT16);
    }
 
    /**
@@ -852,19 +850,16 @@ struct glsl_type {
       return (bool) interface_row_major;
    }
 
+   ~glsl_type();
+
 private:
 
-   static mtx_t mem_mutex;
    static mtx_t hash_mutex;
 
    /**
-    * ralloc context for all glsl_type allocations
-    *
-    * Set on the first call to \c glsl_type::new.
+    * ralloc context for the type itself.
     */
-   static void *mem_ctx;
-
-   void init_ralloc_type_ctx(void);
+   void *mem_ctx;
 
    /** Constructor for vector and matrix types */
    glsl_type(GLenum gl_type,
@@ -874,7 +869,7 @@ private:
    /** Constructor for sampler or image types */
    glsl_type(GLenum gl_type, glsl_base_type base_type,
             enum glsl_sampler_dim dim, bool shadow, bool array,
-            unsigned type, const char *name);
+            glsl_base_type type, const char *name);
 
    /** Constructor for record types */
    glsl_type(const glsl_struct_field *fields, unsigned num_fields,