diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2015-05-13 10:41:55 +0200 |
---|---|---|
committer | Samuel Iglesias Gonsalvez <siglesias@igalia.com> | 2015-07-14 07:04:03 +0200 |
commit | 18feaa8f36b311c443fd56666507ec1768fb9582 (patch) | |
tree | 2fd84214a9a397fc02591b3300df37486da58f0d | |
parent | 3095ee9b8bd4154cc63b6332c21b16954555e241 (diff) |
glsl: Add ir_var_shader_storage
This will be used to identify buffer variables inside shader storage
buffer objects, which are very similar to uniforms except for a few
differences, most important of which is that they are writable.
Since buffer variables are so similar to uniforms, we will almost always
want them to go through the same paths as uniforms.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
-rw-r--r-- | src/glsl/builtin_variables.cpp | 5 | ||||
-rw-r--r-- | src/glsl/glsl_symbol_table.cpp | 16 | ||||
-rw-r--r-- | src/glsl/ir.cpp | 3 | ||||
-rw-r--r-- | src/glsl/ir.h | 5 | ||||
-rw-r--r-- | src/glsl/ir_function.cpp | 1 | ||||
-rw-r--r-- | src/glsl/ir_print_visitor.cpp | 3 | ||||
-rw-r--r-- | src/glsl/ir_reader.cpp | 2 | ||||
-rw-r--r-- | src/glsl/loop_unroll.cpp | 1 | ||||
-rw-r--r-- | src/glsl/lower_named_interface_blocks.cpp | 5 | ||||
-rw-r--r-- | src/glsl/lower_variable_index_to_cond_assign.cpp | 1 | ||||
-rw-r--r-- | src/glsl/opt_structure_splitting.cpp | 5 |
11 files changed, 34 insertions, 13 deletions
diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index a765d35fde..aba1750c09 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -436,11 +436,12 @@ builtin_variable_generator::add_variable(const char *name, var->data.read_only = true; break; case ir_var_shader_out: + case ir_var_shader_storage: break; default: /* The only variables that are added using this function should be - * uniforms, shader inputs, and shader outputs, constants (which use - * ir_var_auto), and system values. + * uniforms, shader storage, shader inputs, and shader outputs, constants + * (which use ir_var_auto), and system values. */ assert(0); break; diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp index 2294dda42c..536f0a3a8c 100644 --- a/src/glsl/glsl_symbol_table.cpp +++ b/src/glsl/glsl_symbol_table.cpp @@ -36,6 +36,9 @@ public: case ir_var_uniform: dest = &ibu; break; + case ir_var_shader_storage: + dest = &iss; + break; case ir_var_shader_in: dest = &ibi; break; @@ -60,6 +63,8 @@ public: switch (mode) { case ir_var_uniform: return ibu; + case ir_var_shader_storage: + return iss; case ir_var_shader_in: return ibi; case ir_var_shader_out: @@ -71,24 +76,25 @@ public: } symbol_table_entry(ir_variable *v) : - v(v), f(0), t(0), ibu(0), ibi(0), ibo(0), a(0) {} + v(v), f(0), t(0), ibu(0), iss(0), ibi(0), ibo(0), a(0) {} symbol_table_entry(ir_function *f) : - v(0), f(f), t(0), ibu(0), ibi(0), ibo(0), a(0) {} + v(0), f(f), t(0), ibu(0), iss(0), ibi(0), ibo(0), a(0) {} symbol_table_entry(const glsl_type *t) : - v(0), f(0), t(t), ibu(0), ibi(0), ibo(0), a(0) {} + v(0), f(0), t(t), ibu(0), iss(0), ibi(0), ibo(0), a(0) {} symbol_table_entry(const glsl_type *t, enum ir_variable_mode mode) : - v(0), f(0), t(0), ibu(0), ibi(0), ibo(0), a(0) + v(0), f(0), t(0), ibu(0), iss(0), ibi(0), ibo(0), a(0) { assert(t->is_interface()); add_interface(t, mode); } symbol_table_entry(const class ast_type_specifier *a): - v(0), f(0), t(0), ibu(0), ibi(0), ibo(0), a(a) {} + v(0), f(0), t(0), ibu(0), iss(0), ibi(0), ibo(0), a(a) {} ir_variable *v; ir_function *f; const glsl_type *t; const glsl_type *ibu; + const glsl_type *iss; const glsl_type *ibi; const glsl_type *ibo; const class ast_type_specifier *a; diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index dbd064feec..9a25bf413f 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1975,6 +1975,9 @@ mode_string(const ir_variable *var) case ir_var_uniform: return "uniform"; + case ir_var_shader_storage: + return "buffer"; + case ir_var_shader_in: return "shader input"; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index f904555350..2b9533a643 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -324,6 +324,7 @@ protected: enum ir_variable_mode { ir_var_auto = 0, /**< Function local variables and globals. */ ir_var_uniform, /**< Variable declared as a uniform. */ + ir_var_shader_storage, /**< Variable declared as an ssbo. */ ir_var_shader_in, ir_var_shader_out, ir_var_function_in, @@ -445,7 +446,9 @@ public: */ inline bool is_in_uniform_block() const { - return this->data.mode == ir_var_uniform && this->interface_type != NULL; + return (this->data.mode == ir_var_uniform || + this->data.mode == ir_var_shader_storage) && + this->interface_type != NULL; } /** diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp index 1319443900..93034bedb5 100644 --- a/src/glsl/ir_function.cpp +++ b/src/glsl/ir_function.cpp @@ -72,6 +72,7 @@ parameter_lists_match(_mesa_glsl_parse_state *state, switch ((enum ir_variable_mode)(param->data.mode)) { case ir_var_auto: case ir_var_uniform: + case ir_var_shader_storage: case ir_var_temporary: /* These are all error conditions. It is invalid for a parameter to * a function to be declared as auto (not in, out, or inout) or diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 4cbcad4ec6..922f98b6b8 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -168,7 +168,8 @@ void ir_print_visitor::visit(ir_variable *ir) const char *const cent = (ir->data.centroid) ? "centroid " : ""; const char *const samp = (ir->data.sample) ? "sample " : ""; const char *const inv = (ir->data.invariant) ? "invariant " : ""; - const char *const mode[] = { "", "uniform ", "shader_in ", "shader_out ", + const char *const mode[] = { "", "uniform ", "shader_storage", + "shader_in ", "shader_out ", "in ", "out ", "inout ", "const_in ", "sys ", "temporary " }; STATIC_ASSERT(ARRAY_SIZE(mode) == ir_var_mode_count); diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 4eae4131c5..d3ece19b22 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -421,6 +421,8 @@ ir_reader::read_declaration(s_expression *expr) var->data.invariant = 1; } else if (strcmp(qualifier->value(), "uniform") == 0) { var->data.mode = ir_var_uniform; + } else if (strcmp(qualifier->value(), "shader_storage") == 0) { + var->data.mode = ir_var_shader_storage; } else if (strcmp(qualifier->value(), "auto") == 0) { var->data.mode = ir_var_auto; } else if (strcmp(qualifier->value(), "in") == 0) { diff --git a/src/glsl/loop_unroll.cpp b/src/glsl/loop_unroll.cpp index 7a00fb8fea..b9ea350778 100644 --- a/src/glsl/loop_unroll.cpp +++ b/src/glsl/loop_unroll.cpp @@ -145,6 +145,7 @@ public: unsupported_variable_indexing = true; break; case ir_var_uniform: + case ir_var_shader_storage: if (options->EmitNoIndirectUniform) unsupported_variable_indexing = true; break; diff --git a/src/glsl/lower_named_interface_blocks.cpp b/src/glsl/lower_named_interface_blocks.cpp index 7304c51399..28d7987d3c 100644 --- a/src/glsl/lower_named_interface_blocks.cpp +++ b/src/glsl/lower_named_interface_blocks.cpp @@ -108,7 +108,8 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions) * but, this will require changes to the other uniform block * support code. */ - if (var->data.mode == ir_var_uniform) + if (var->data.mode == ir_var_uniform || + var->data.mode == ir_var_shader_storage) continue; const glsl_type * iface_t = var->type; @@ -212,7 +213,7 @@ flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue) * but, this will require changes to the other uniform block * support code. */ - if (var->data.mode == ir_var_uniform) + if (var->data.mode == ir_var_uniform || var->data.mode == ir_var_shader_storage) return; if (var->get_interface_type() != NULL) { diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp index d878cb0781..4a6a76c4eb 100644 --- a/src/glsl/lower_variable_index_to_cond_assign.cpp +++ b/src/glsl/lower_variable_index_to_cond_assign.cpp @@ -370,6 +370,7 @@ public: case ir_var_temporary: return this->lower_temps; case ir_var_uniform: + case ir_var_shader_storage: return this->lower_uniforms; case ir_var_function_in: case ir_var_const_in: diff --git a/src/glsl/opt_structure_splitting.cpp b/src/glsl/opt_structure_splitting.cpp index 5e82fe93aa..abf4310feb 100644 --- a/src/glsl/opt_structure_splitting.cpp +++ b/src/glsl/opt_structure_splitting.cpp @@ -103,8 +103,9 @@ ir_structure_reference_visitor::get_variable_entry(ir_variable *var) { assert(var); - if (!var->type->is_record() || var->data.mode == ir_var_uniform - || var->data.mode == ir_var_shader_in || var->data.mode == ir_var_shader_out) + if (!var->type->is_record() || + var->data.mode == ir_var_uniform || var->data.mode == ir_var_shader_storage || + var->data.mode == ir_var_shader_in || var->data.mode == ir_var_shader_out) return NULL; foreach_in_list(variable_entry, entry, &this->variable_list) { |