dri: fromPlanar() can return NULL as a valid result
[mesa.git] / src / compiler / glsl_types.h
index 0b4a66ca4d21a7c7c03d601912d37436654e1b31..ab0b26376492d408dd9daf9d3ba9260f3ab959c7 100644 (file)
@@ -61,7 +61,10 @@ enum glsl_base_type {
    GLSL_TYPE_UINT = 0,
    GLSL_TYPE_INT,
    GLSL_TYPE_FLOAT,
+   GLSL_TYPE_FLOAT16,
    GLSL_TYPE_DOUBLE,
+   GLSL_TYPE_UINT16,
+   GLSL_TYPE_INT16,
    GLSL_TYPE_UINT64,
    GLSL_TYPE_INT64,
    GLSL_TYPE_BOOL,
@@ -145,23 +148,36 @@ enum {
 
 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;
 
+private:
+   glsl_type()
+   {
+      // Dummy constructor, just for the sake of ASSERT_BITFIELD_SIZE.
+   }
+
+public:
    /* 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)
    {
+      ASSERT_BITFIELD_SIZE(glsl_type, base_type, GLSL_TYPE_ERROR);
+      ASSERT_BITFIELD_SIZE(glsl_type, sampled_type, GLSL_TYPE_ERROR);
+      ASSERT_BITFIELD_SIZE(glsl_type, sampler_dimensionality,
+                           GLSL_SAMPLER_DIM_SUBPASS_MS);
+
       mtx_lock(&glsl_type::mem_mutex);
 
       /* mem_ctx should have been created by the static members */
@@ -239,12 +255,15 @@ struct glsl_type {
     * @{
     */
    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);
    /**@}*/
 
    /**
@@ -474,7 +493,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);
    }
 
    /**
@@ -874,7 +895,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,