summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_types.h
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2012-12-11 12:11:16 -0800
committerIan Romanick <ian.d.romanick@intel.com>2013-01-25 09:07:33 -0500
commit491364e1f34ddb2c8ea439e871dd42aaa5cc9b28 (patch)
tree339b24932702a6421845c15c08fcba2bcc4104f8 /src/glsl/glsl_types.h
parent7f96a8471e8ddf2b49a644780f35ee493157782a (diff)
downloadexternal_mesa3d-491364e1f34ddb2c8ea439e871dd42aaa5cc9b28.zip
external_mesa3d-491364e1f34ddb2c8ea439e871dd42aaa5cc9b28.tar.gz
external_mesa3d-491364e1f34ddb2c8ea439e871dd42aaa5cc9b28.tar.bz2
glsl: Add GLSL_TYPE_INTERFACE
Interfaces are structurally identical to structures from the compiler's point of view. They have some additional restrictions, and generally GPUs use different instructions to access them. Using a different base type should make this a bit easier. This commit also adds the glsl_type::interface_packing fields. For GLSL_TYPE_INTERFACE types, this will track the specified packing mode. It is analogous to gl_uniform_buffer::_Packing. v2: Add serveral missing GLSL_TYPE_INTERFACE cases in switch-statements. v3: Add information about glsl_type::interface_packing. Move row_major checking in glsl_type::record_key_compare from this patch to the previous patch. Both suggested by Paul Berry. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Paul Berry <stereotype441@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/glsl/glsl_types.h')
-rw-r--r--src/glsl/glsl_types.h36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 24ad844..8588685 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -54,6 +54,7 @@ enum glsl_base_type {
GLSL_TYPE_BOOL,
GLSL_TYPE_SAMPLER,
GLSL_TYPE_STRUCT,
+ GLSL_TYPE_INTERFACE,
GLSL_TYPE_ARRAY,
GLSL_TYPE_VOID,
GLSL_TYPE_ERROR
@@ -69,6 +70,12 @@ enum glsl_sampler_dim {
GLSL_SAMPLER_DIM_EXTERNAL
};
+enum glsl_interface_packing {
+ GLSL_INTERFACE_PACKING_STD140,
+ GLSL_INTERFACE_PACKING_SHARED,
+ GLSL_INTERFACE_PACKING_PACKED
+};
+
#ifdef __cplusplus
#include "GL/gl.h"
#include "ralloc.h"
@@ -84,6 +91,7 @@ struct glsl_type {
* only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
* and \c GLSL_TYPE_UINT are valid.
*/
+ unsigned interface_packing:2;
/* Callers of this ralloc-based new need not call delete. It's
* easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
@@ -130,8 +138,9 @@ struct glsl_type {
/**
* For \c GLSL_TYPE_ARRAY, this is the length of the array. For
- * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and
- * the number of values pointed to by \c fields.structure (below).
+ * \c GLSL_TYPE_STRUCT or \c GLSL_TYPE_INTERFACE, it is the number of
+ * elements in the structure and the number of values pointed to by
+ * \c fields.structure (below).
*/
unsigned length;
@@ -232,6 +241,14 @@ struct glsl_type {
const char *name);
/**
+ * Get the instance of an interface block type
+ */
+ static const glsl_type *get_interface_instance(const glsl_struct_field *fields,
+ unsigned num_fields,
+ enum glsl_interface_packing packing,
+ const char *name);
+
+ /**
* Query the total number of scalars that make up a scalar, vector or matrix
*/
unsigned components() const
@@ -394,6 +411,14 @@ struct glsl_type {
}
/**
+ * Query whether or not a type is an interface
+ */
+ bool is_interface() const
+ {
+ return base_type == GLSL_TYPE_INTERFACE;
+ }
+
+ /**
* Query whether or not a type is the void type singleton.
*/
bool is_void() const
@@ -491,6 +516,10 @@ private:
glsl_type(const glsl_struct_field *fields, unsigned num_fields,
const char *name);
+ /** Constructor for interface types */
+ glsl_type(const glsl_struct_field *fields, unsigned num_fields,
+ enum glsl_interface_packing packing, const char *name);
+
/** Constructor for array types */
glsl_type(const glsl_type *array, unsigned length);
@@ -500,6 +529,9 @@ private:
/** Hash table containing the known record types. */
static struct hash_table *record_types;
+ /** Hash table containing the known interface types. */
+ static struct hash_table *interface_types;
+
static int record_key_compare(const void *a, const void *b);
static unsigned record_key_hash(const void *key);