On 09/17/2013 02:18 PM, Paul Berry wrote: > On 15 September 2013 00:10, Francisco Jerez <curroje...@riseup.net > <mailto:curroje...@riseup.net>> wrote: > > --- > src/glsl/ast_to_hir.cpp | 1 + > src/glsl/builtin_type_macros.h | 2 ++ > src/glsl/builtin_types.cpp | 6 ++++++ > src/glsl/glsl_types.cpp | 2 ++ > src/glsl/glsl_types.h | 14 ++++++++++++++ > src/glsl/ir_clone.cpp | 1 + > src/glsl/link_uniform_initializers.cpp | 1 + > src/glsl/tests/uniform_initializer_utils.cpp | 3 +++ > src/mesa/program/ir_to_mesa.cpp | 2 ++ > src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 + > 10 files changed, 33 insertions(+) > > diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp > index 2316cf8..fcca5df 100644 > --- a/src/glsl/ast_to_hir.cpp > +++ b/src/glsl/ast_to_hir.cpp > @@ -902,6 +902,7 @@ do_comparison(void *mem_ctx, int operation, > ir_rvalue *op0, ir_rvalue *op1) > case GLSL_TYPE_VOID: > case GLSL_TYPE_SAMPLER: > case GLSL_TYPE_INTERFACE: > + case GLSL_TYPE_ATOMIC_UINT: > /* I assume a comparison of a struct containing a sampler just > * ignores the sampler present in the type. > */ > diff --git a/src/glsl/builtin_type_macros.h > b/src/glsl/builtin_type_macros.h > index fec38da..263fd83 100644 > --- a/src/glsl/builtin_type_macros.h > +++ b/src/glsl/builtin_type_macros.h > @@ -110,6 +110,8 @@ DECL_TYPE(sampler2DRectShadow, > GL_SAMPLER_2D_RECT_SHADOW, GLSL_SAMPLER > > DECL_TYPE(samplerExternalOES, GL_SAMPLER_EXTERNAL_OES, > GLSL_SAMPLER_DIM_EXTERNAL, 0, 0, GLSL_TYPE_FLOAT) > > +DECL_TYPE(atomic_uint, GL_UNSIGNED_INT_ATOMIC_COUNTER, > GLSL_TYPE_ATOMIC_UINT, 1, 1) > + > STRUCT_TYPE(gl_DepthRangeParameters) > STRUCT_TYPE(gl_PointParameters) > STRUCT_TYPE(gl_MaterialParameters) > diff --git a/src/glsl/builtin_types.cpp b/src/glsl/builtin_types.cpp > index 722eda2..8311a91 100644 > --- a/src/glsl/builtin_types.cpp > +++ b/src/glsl/builtin_types.cpp > @@ -203,6 +203,8 @@ const static struct builtin_type_versions { > T(sampler2DRectShadow, 140, 999) > > T(struct_gl_DepthRangeParameters, 110, 100) > + > + T(atomic_uint, 130, 999) > > > This should be the GLSL version in which the type became available > without the use of an extension, so it should be 420, not 130. > > > }; > > const glsl_type *const deprecated_types[] = { > @@ -284,5 +286,9 @@ _mesa_glsl_initialize_types(struct > _mesa_glsl_parse_state *state) > if (state->OES_texture_3D_enable) { > add_type(symbols, glsl_type::sampler3D_type); > } > + > + if (state->ARB_shader_atomic_counters_enable) { > + add_type(symbols, glsl_type::atomic_uint_type); > + } > } > /** @} */ > diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp > index 3c396dd..e1fe153 100644 > --- a/src/glsl/glsl_types.cpp > +++ b/src/glsl/glsl_types.cpp > @@ -586,6 +586,7 @@ glsl_type::component_slots() const > return this->length * this->fields.array->component_slots(); > > case GLSL_TYPE_SAMPLER: > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_VOID: > case GLSL_TYPE_ERROR: > break; > @@ -874,6 +875,7 @@ glsl_type::count_attribute_slots() const > return this->length * > this->fields.array->count_attribute_slots(); > > case GLSL_TYPE_SAMPLER: > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_VOID: > case GLSL_TYPE_ERROR: > break; > diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h > index acdf48f..d0274e6 100644 > --- a/src/glsl/glsl_types.h > +++ b/src/glsl/glsl_types.h > @@ -53,6 +53,7 @@ enum glsl_base_type { > GLSL_TYPE_FLOAT, > GLSL_TYPE_BOOL, > GLSL_TYPE_SAMPLER, > + GLSL_TYPE_ATOMIC_UINT, > GLSL_TYPE_STRUCT, > GLSL_TYPE_INTERFACE, > GLSL_TYPE_ARRAY, > @@ -434,6 +435,19 @@ struct glsl_type { > } > > /** > + * Return the amount of atomic counter storage required for a type. > + */ > + unsigned atomic_size() const > + { > + if (base_type == GLSL_TYPE_ATOMIC_UINT) > + return ATOMIC_COUNTER_SIZE; > + else if (is_array()) > + return length * element_type()->atomic_size(); > + else > + return 0; > + } > > Can atomic counters appear inside structs? If so, we probably need an > is_record() case here. If not, it would be nice to have a comment > explaining why it's unnecessary.
The GL_ARB-shader_atomic_counter spec isn't clear, but the GLSL 4.40 spec is. There's a table on page 23 (page 29 of the PDF) containing all the opaque unsigned integer types. Immediately after this table, the spec says: "In addition, a shader can aggregate these basic types using arrays and structures to build more complex types." There are a bunch of restrictions that apply to all opaque types (samplers, images, and atomics). Perhaps our predicates should be is_opaque() and contains_opaque()? > + > + /** > * Query the full type of a matrix row > * > * \return > diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp > index fb303b0..b70b7db 100644 > --- a/src/glsl/ir_clone.cpp > +++ b/src/glsl/ir_clone.cpp > @@ -385,6 +385,7 @@ ir_constant::clone(void *mem_ctx, struct > hash_table *ht) const > } > > case GLSL_TYPE_SAMPLER: > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_VOID: > case GLSL_TYPE_ERROR: > case GLSL_TYPE_INTERFACE: > diff --git a/src/glsl/link_uniform_initializers.cpp > b/src/glsl/link_uniform_initializers.cpp > index 3f66710..786aaf0 100644 > --- a/src/glsl/link_uniform_initializers.cpp > +++ b/src/glsl/link_uniform_initializers.cpp > @@ -69,6 +69,7 @@ copy_constant_to_storage(union gl_constant_value > *storage, > break; > case GLSL_TYPE_ARRAY: > case GLSL_TYPE_STRUCT: > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_INTERFACE: > case GLSL_TYPE_VOID: > case GLSL_TYPE_ERROR: > diff --git a/src/glsl/tests/uniform_initializer_utils.cpp > b/src/glsl/tests/uniform_initializer_utils.cpp > index a04f5dd..5e86c24 100644 > --- a/src/glsl/tests/uniform_initializer_utils.cpp > +++ b/src/glsl/tests/uniform_initializer_utils.cpp > @@ -92,6 +92,7 @@ generate_data_element(void *mem_ctx, const > glsl_type *type, > case GLSL_TYPE_BOOL: > data.b[i] = bool(values[idx]); > break; > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_STRUCT: > case GLSL_TYPE_ARRAY: > case GLSL_TYPE_VOID: > @@ -119,6 +120,7 @@ generate_data_element(void *mem_ctx, const > glsl_type *type, > case GLSL_TYPE_BOOL: > ASSERT_EQ(data.b[i], val->value.b[i]); > break; > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_STRUCT: > case GLSL_TYPE_ARRAY: > case GLSL_TYPE_VOID: > @@ -217,6 +219,7 @@ verify_data(gl_constant_value *storage, unsigned > storage_array_size, > case GLSL_TYPE_BOOL: > EXPECT_EQ(int(val->value.b[i]), storage[i].i); > break; > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_STRUCT: > case GLSL_TYPE_ARRAY: > case GLSL_TYPE_VOID: > diff --git a/src/mesa/program/ir_to_mesa.cpp > b/src/mesa/program/ir_to_mesa.cpp > index 41274a2..44f6d08 100644 > --- a/src/mesa/program/ir_to_mesa.cpp > +++ b/src/mesa/program/ir_to_mesa.cpp > @@ -619,6 +619,7 @@ type_size(const struct glsl_type *type) > * at link time. > */ > return 1; > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_VOID: > case GLSL_TYPE_ERROR: > case GLSL_TYPE_INTERFACE: > @@ -2584,6 +2585,7 @@ _mesa_associate_uniform_storage(struct > gl_context *ctx, > format = uniform_native; > columns = 1; > break; > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_ARRAY: > case GLSL_TYPE_VOID: > case GLSL_TYPE_STRUCT: > diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > index cd4802b..67a8ed6 100644 > --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > @@ -974,6 +974,7 @@ type_size(const struct glsl_type *type) > * at link time. > */ > return 1; > + case GLSL_TYPE_ATOMIC_UINT: > case GLSL_TYPE_INTERFACE: > case GLSL_TYPE_VOID: > case GLSL_TYPE_ERROR: > -- > 1.8.3.4 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org <mailto:mesa-dev@lists.freedesktop.org> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev