summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2017-11-06 12:44:06 -0700
committerBrian Paul <[email protected]>2017-11-16 20:35:17 -0700
commit92c1290dc57b493690ffe754b1b7724e93d41900 (patch)
tree8555c880a5e9be0a3235263cf7b29dc806c05b58 /src/compiler
parent940fba68c903d9b4da2d99a68f1c06c53d4fe82a (diff)
glsl: s/unsigned/glsl_base_type/ in glsl type code (v2)
Declare glsl_type::sampled_type as glsl_base_type as we do for the base_type field. And make base_type a bitfield to save a few bytes. Update glsl_type constructor to take glsl_base_type instead of unsigned and pass GLSL_TYPE_VOID instead of zero. No Piglit regressions with llvmpipe. v2: - Declare both base_type and sampled_type as 8-bit fields - Use the new ASSERT_BITFIELD_SIZE() macro. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl_types.cpp30
-rw-r--r--src/compiler/glsl_types.h27
2 files changed, 35 insertions, 22 deletions
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 704b63c5cf2..107a81f5e79 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -50,9 +50,9 @@ glsl_type::glsl_type(GLenum gl_type,
glsl_base_type base_type, unsigned vector_elements,
unsigned matrix_columns, const char *name) :
gl_type(gl_type),
- base_type(base_type),
+ base_type(base_type), sampled_type(GLSL_TYPE_VOID),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
- sampled_type(0), interface_packing(0), interface_row_major(0),
+ interface_packing(0), interface_row_major(0),
vector_elements(vector_elements), matrix_columns(matrix_columns),
length(0)
{
@@ -79,11 +79,11 @@ glsl_type::glsl_type(GLenum gl_type,
glsl_type::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) :
gl_type(gl_type),
- base_type(base_type),
+ base_type(base_type), sampled_type(type),
sampler_dimensionality(dim), sampler_shadow(shadow),
- sampler_array(array), sampled_type(type), interface_packing(0),
+ sampler_array(array), interface_packing(0),
interface_row_major(0), length(0)
{
mtx_lock(&glsl_type::mem_mutex);
@@ -102,9 +102,9 @@ glsl_type::glsl_type(GLenum gl_type, glsl_base_type base_type,
glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
const char *name) :
gl_type(0),
- base_type(GLSL_TYPE_STRUCT),
+ base_type(GLSL_TYPE_STRUCT), sampled_type(GLSL_TYPE_VOID),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
- sampled_type(0), interface_packing(0), interface_row_major(0),
+ interface_packing(0), interface_row_major(0),
vector_elements(0), matrix_columns(0),
length(num_fields)
{
@@ -131,9 +131,9 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
enum glsl_interface_packing packing,
bool row_major, const char *name) :
gl_type(0),
- base_type(GLSL_TYPE_INTERFACE),
+ base_type(GLSL_TYPE_INTERFACE), sampled_type(GLSL_TYPE_VOID),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
- sampled_type(0), interface_packing((unsigned) packing),
+ interface_packing((unsigned) packing),
interface_row_major((unsigned) row_major),
vector_elements(0), matrix_columns(0),
length(num_fields)
@@ -159,9 +159,9 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
glsl_type::glsl_type(const glsl_type *return_type,
const glsl_function_param *params, unsigned num_params) :
gl_type(0),
- base_type(GLSL_TYPE_FUNCTION),
+ base_type(GLSL_TYPE_FUNCTION), sampled_type(GLSL_TYPE_VOID),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
- sampled_type(0), interface_packing(0), interface_row_major(0),
+ interface_packing(0), interface_row_major(0),
vector_elements(0), matrix_columns(0),
length(num_params)
{
@@ -191,9 +191,9 @@ glsl_type::glsl_type(const glsl_type *return_type,
glsl_type::glsl_type(const char *subroutine_name) :
gl_type(0),
- base_type(GLSL_TYPE_SUBROUTINE),
+ base_type(GLSL_TYPE_SUBROUTINE), sampled_type(GLSL_TYPE_VOID),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
- sampled_type(0), interface_packing(0), interface_row_major(0),
+ interface_packing(0), interface_row_major(0),
vector_elements(1), matrix_columns(1),
length(0)
{
@@ -442,9 +442,9 @@ _mesa_glsl_release_types(void)
glsl_type::glsl_type(const glsl_type *array, unsigned length) :
- base_type(GLSL_TYPE_ARRAY),
+ base_type(GLSL_TYPE_ARRAY), sampled_type(GLSL_TYPE_VOID),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
- sampled_type(0), interface_packing(0), interface_row_major(0),
+ interface_packing(0), interface_row_major(0),
vector_elements(0), matrix_columns(0),
length(length), name(NULL)
{
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 0b4a66ca4d2..0cb0f9ee8ae 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -145,23 +145,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 */
@@ -874,7 +887,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,