summaryrefslogtreecommitdiff
path: root/src/glsl/glsl_types.h
AgeCommit message (Collapse)AuthorFilesLines
2013-10-31glsl: fix MSVC int->bool conversion warningBrian Paul1-1/+1
2013-10-29glsl: Add type predicate to check whether a type contains any opaque types.Francisco Jerez1-0/+5
And use it to forbid comparisons of opaque operands. According to the GL 4.2 specification: > Except for array indexing, structure member selection, and > parentheses, opaque variables are not allowed to be operands in > expressions. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-10-29glsl: Add new atomic_uint built-in GLSL type.Francisco Jerez1-0/+22
v2: Fix GLSL version in which the type became available. Add contains_atomic() convenience method. Split off atomic counter comparison error checking to a separate patch that will handle all opaque types. Include new ir_variable fields for atomic types. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-10-28glsl: Add check for unsized arrays to glsl typesTimothy Arceri1-0/+8
The main purpose of this patch is to increase readability of the array code by introducing is_unsized_array() to glsl_types. Some redundent is_array() checks are also removed, and small number of other related clean ups. The introduction of is_unsized_array() should also make the ARB_arrays_of_arrays code simpler and more readable when it arrives. V2: Also replace code that checks for unsized arrays directly with the length variable Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au> v3 (Paul Berry <stereotype441@gmail.com>): clean up formatting. Separate whitespace cleanups to their own patch. Reviewed-by: Paul Berry <stereotype441@gmail.com>
2013-10-28glsl: whitespace cleanups.Timothy Arceri1-3/+0
Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au> v2 (Paul Berry <stereotype441@gmail.com>): Separate from "glsl: Add check for unsized arrays to glsl types". Reviewed-by: Paul Berry <stereotype441@gmail.com>
2013-10-24glsl: Keep track of centroid/interpolation mode for interface block members.Paul Berry1-0/+12
Fixes piglit tests: - interface-block-interpolation-{array,named,unnamed} - glsl-1.50-interface-block-centroid {array,named,unnamed} Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
2013-10-09glsl: Rename the fourth argument to get_interface_instance.Paul Berry1-1/+1
Interface declarations have two names associated with them: the block name and the instance name. It's the block name that needs to be passed to get_interface_instance(). This patch renames the argument so that there's no confusion. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-10-08glsl: Keep track of location for interface block fields.Paul Berry1-0/+9
This patch adds a "location" element to struct glsl_struct_field, so that we can keep track of the gl_varying_slot associated with each built-in geometry shader input. In lower_named_interface_blocks, we use this value to populate the "location" field in the ir_variable that stores each geometry shader input. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2013-09-11glsl: Add a new glsl_type::sampler_coordinate_components() function.Kenneth Graunke1-0/+12
This computes the number of components necessary to address a sampler based on its dimensionality. It will be useful for texturing built-ins. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2013-08-01Move count_attribute_slots() out of the linker and into glsl_type.Paul Berry1-0/+12
Our previous justification for leaving this function out of glsl_type was that it implemented counting rules that were specific to GLSL 1.50. However, these counting rules also describe the number of varying slots that Mesa will assign to a varying in the absence of varying packing. That's useful to be able to compute from outside of the linker code (a future patch will use it from ir_set_program_inouts.cpp). So go ahead and move it to glsl_type. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-07-27glsl: Less const for glsl_type convenience accessorsIan Romanick1-4/+4
The second 'const' says that the pointer itself is constant. This in unenforcible in C++, so GCC emits a warning (see) below for each of these functions in every file that includes glsl_types.h. It's a lot of warning spam. ../../../src/glsl/glsl_types.h:176:58: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Cc: mesa-stable@lists.freedesktop.org
2013-06-27glsl: Use the C99 variadic macro syntax.José Fonseca1-2/+2
MSVC does not support the old GCC syntax. See also http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html
2013-06-26glsl: Streamline the built-in type handling code.Kenneth Graunke1-73/+15
Over the last few years, the compiler has grown to support 7 different language versions and 6 extensions that add new built-in types. With more and more features being added, some of our core code has devolved into an unmaintainable spaghetti of sorts. A few problems with the old code: 1. Built-in types are declared...where exactly? The types in builtin_types.h were organized in arrays by the language version or extension they were introduced in. It's factored out to avoid duplicates---every type only exists in one array. But that means that sampler1D is declared in 110, sampler2D is in core types, sampler3D is a unique global not in a list...and so on. 2. Spaghetti call-chains with weird parameters: generate_300ES_types calls generate_130_types which calls generate_120_types and generate_EXT_texture_array_types, which calls generate_110_types, which calls generate_100ES_types...and more Except that ES doesn't want 1D types, so we have a skip_1d parameter. add_deprecated also falls into this category. 3. Missing type accessors. Common types have convenience pointers (like glsl_type::vec4_type), but others may not be accessible at all without a symbol table (for example, sampler types). 4. Global variable declarations in a header file? #include "builtin_types.h" in two C++ files would break the build. The new code addresses these problems. All built-in types are declared together in a single table, independent of when they were introduced. The macro that declares a new built-in type also creates a convenience pointer, so every type is available and it won't get out of sync. The code to populate a symbol table with the appropriate types for a particular language version and set of extensions is now a single table-driven function. The table lists the type name and GL/ES versions when it was introduced (similar to how the lexer handles reserved words). A single loop adds types based on the language version. Explicit extension checks then add additional types. If they were already added based on the language version, glsl_symbol_table simply ignores the request to add them a second time, meaning we don't need to worry about duplicates and can simply list types where they belong. v2: Mark uvecs and shadow samplers as ES3 only, and 1DArrayShadow as unsupported in ES entirely. Add a touch more doxygen. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2013-06-26glsl: Add simple vector type accessor helpers.Kenneth Graunke1-0/+9
This patch introduces new functions to quickly grab a pointer to a vector type. For example: glsl_type::bvec(4) returns glsl_type::bvec4_type glsl_type::ivec(3) returns glsl_type::ivec3_type glsl_type::uvec(2) returns glsl_type::uvec2_type glsl_type::vec(1) returns glsl_type::float_type This is less wordy than glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1), which can help avoid extra word wrapping. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2013-04-11glsl: Fix (and validate) comment above glsl_type::name.Paul Berry1-2/+1
The comment above glsl_type::name claimed that it could sometimes be NULL. This was wrong--it is never NULL. Many error handling paths would segfault if it were. (Anonymous structs are assigned names like "#anon_struct_0001"--see the ast_struct_specifier constructor in glsl_parser_extras.cpp.) Fix the comment and add assertions to validate that it really is never NULL. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-03-20glsl: Add sampler2DMS/sampler2DMSArray types to GLSL 1.50.Kenneth Graunke1-0/+1
GLSL 1.50 includes support for the new sampler types introduced by the ARB_texture_multisample extension. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
2013-03-02glsl: add support for ARB_texture_multisampleChris Forbes1-1/+4
V2: - emit `sample` parameter properly for multisample texelFetch() - fix spurious whitespace change - introduce a new opcode ir_txf_ms rather than overloading the existing ir_txf further. This makes doing the right thing in the driver somewhat simpler. V3: - fix weird whitespace V4: - don't forget to include the new opcode in tex_opcode_strs[] (thanks Kenneth for spotting this) Signed-off-by: Chris Forbes <chrisf@ijw.co.nz> [V2] Reviewed-by: Eric Anholt <eric@anholt.net> [V2] Reviewed-by: Paul Berry <stereotype441@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-02-13glsl: don't allow non-flat integral types in varying structs/arrays.Paul Berry1-0/+6
In the GLSL 1.30 spec, section 4.3.6 ("Outputs") says: "If a vertex output is a signed or unsigned integer or integer vector, then it must be qualified with the interpolation qualifier flat." The GLSL ES 3.00 spec further clarifies, in section 4.3.6 ("Output Variables"): "Vertex shader outputs that are, *or contain*, signed or unsigned integers or integer vectors must be qualified with the interpolation qualifier flat." (Emphasis mine.) The language in the GLSL ES 3.00 spec is clearly correct and should be applied to all shading language versions, since varyings that contain ints can't be interpolated, regardless of which shading language version is in use. (Note that in GLSL 1.50 the restriction is changed to apply to fragment shader inputs rather than vertex shader outputs, to accommodate the fact that in the presence of geometry shaders, vertex shader outputs are not necessarily interpolated. That will be addressed by a future patch). NOTE: This is a candidate for stable branches. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2013-01-25glsl: Make the align function available elsewhere in the linkerIan Romanick1-0/+6
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Carl Worth <cworth@cworth.org>
2013-01-25glsl: Add GLSL_TYPE_INTERFACEIan Romanick1-2/+34
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>
2013-01-25glsl: Add row_major field to glsl_struct_fieldIan Romanick1-0/+1
For now, this will always be false. In the near future, an "interface" type will be added that shares a lot of infrastructure with structures. v2: Move row_major checking in glsl_type::record_key_compare from the next patch to this patch. Suggested by Paul Berry. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Carl Worth <cworth@cworth.org> Reviewed-by: Paul Berry <stereotype441@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-12-06glsl: Populate built-in types correctly for GLSL 3.00 ES.Paul Berry1-3/+8
This patch implements all of the built-in types for GLSL 3.00 ES. This is almost exactly the same as the set of built-in types for GLSL 1.30, except ate 1D samplers are skipped, and samplerCubeShadow is added. This patch also addes an assertion so that when we add new GLSL versions, we'll notice that we need to update the types. In review, Eric noted: "This change looks correct. The overall interaction of profiles is getting ugly, though. I'm imagining a restructure of the symbol table population so that there's a big list of types, and each #version has a nice list of strings of type names copy and pasted out of its spec." Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net> Acked-by: Carl Worth <cworth@cworth.org>
2012-11-09glsl: add ARB_texture_cube_map_array support (v2)Dave Airlie1-0/+2
This adds all the new builtins + the new sampler types, and hooks them up if the extension is supported. v2: fix missing signatures for grad/lod fix missing textureSize clarifications fix compare vs starts with usage Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-30glsl: Make bvec and ivec types accessible without using get_instance.Kenneth Graunke1-0/+5
It's more convenient to use shortcuts like glsl_type::bvec2_type than the longwinded glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1). Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Olivier Galibert <galibert@pobox.com>
2012-07-20glsl: Assign locations for uniforms in UBOs using the std140 rules.Eric Anholt1-0/+13
Fixes piglit layout-std140. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-03-19glsl: Don't include the deprecated structure types in GLSL 1.40.Eric Anholt1-3/+3
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-03-15glsl: Add support for integer sampler2DRect variants in GLSL 1.40.Eric Anholt1-0/+2
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-01-11glsl: Add glsl_type::sampler_indexIan Romanick1-0/+6
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-11-09mesa,glsl,mapi: Put extern "C" { ... } where appropriate.José Fonseca1-3/+3
Probably a several places missing, but enough to cover all headers (in)directly included by uniform_query.cpp, and fix the MSVC build.
2011-11-07glsl: Allow glsl_types.h to be included in C sourcesIan Romanick1-8/+15
Some C code will want access to the glsl_base_type and glsl_sampler_dim enums in the near future. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Tested-by: Tom Stellard <thomas.stellard@amd.com>
2011-11-03glsl: add support for GL_OES_EGL_image_externalChia-I Wu1-1/+4
This extension introduces a new sampler type: samplerExternalOES. texture2D (and texture2DProj) can be used to do a texture look up in an external texture. Reviewed-by: Brian Paul <brianp@vmware.com> Acked-by: Jakob Bornecrantz <jakob@vmware.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-10-31mesa: Add glsl_type::get_scalar_type() function.Paul Berry1-0/+11
This function is similar to get_base_type(), but when called on arrays, it returns the scalar type composing the array. For example, glsl_type(vec4[]) => float_type. Acked-by: Kenneth Graunke <kenneth@whitecape.org>
2011-07-30glsl: Add method glsl_type::can_implicitly_convert_to()Chad Versace1-0/+35
This method checks if a source type is identical to or can be implicitly converted to a target type according to the GLSL 1.20 spec, Section 4.1.10 Implicit Conversions. The following commits use the method for a bugfix: glsl: Fix implicit conversions in non-constructor function calls glsl: Fix implicit conversions in array constructors Note: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-07-18glsl: Move type_contains_sampler() into glsl_type for later reuse.Paul Berry1-0/+6
The new location, as a member function of glsl_type, is more consistent with queries like is_sampler(), is_boolean(), is_float(), etc. Placing the function inside glsl_type also makes it available to any code that uses glsl_types.
2011-03-12glsl: Document glsl_type::sampler_dimensionalityChad Versace1-1/+1
2011-02-28glsl: Enable GL_OES_texture_3D extension for ES2.Kenneth Graunke1-0/+2
2011-02-21Use C-style system headers in C++ code to avoid issues with std:: namespaceIan Romanick1-2/+2
2011-01-31Convert everything from the talloc API to the ralloc API.Kenneth Graunke1-9/+10
2010-12-17glsl: Expose a public glsl_type::void_type const pointer.Kenneth Graunke1-1/+2
This is analogous to glsl_type::int_type and all the others.
2010-11-15glsl: Convert glsl_type::base_type from #define'd constants to an enum.Kenneth Graunke1-11/+13
This is nice because printing type->base_type in GDB will now give you a readable name instead of a number.
2010-11-15glsl: Remove GLSL_TYPE_FUNCTION define.Kenneth Graunke1-8/+2
Functions are not first class objects in GLSL, so there is never a value of function type. No code actually used this except for one function which asserted it shouldn't occur. One comment mentioned it, but was incorrect. So we may as well remove it entirely.
2010-10-11glsl: Add glsl_type::uvecN_type for N=2,3Chad Versace1-0/+2
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2010-09-07glsl: Split out types that are in 1.10 but not GLSL ES 1.00.Kenneth Graunke1-4/+4
2010-09-01glsl2: Remove unused method glsl_type::generate_constructorIan Romanick1-4/+0
2010-08-26glsl: Use a single shared namespace in the symbol table.Kenneth Graunke1-2/+2
As of 1.20, variable names, function names, and structure type names all share a single namespace, and should conflict with one another in the same scope, or hide each other in nested scopes. However, in 1.10, variables and functions can share the same name in the same scope. Structure types, however, conflict with/hide both. Fixes piglit tests redeclaration-06.vert, redeclaration-11.vert, redeclaration-19.vert, and struct-05.vert.
2010-08-14glsl: Standardize a few more uses of struct vs class keyword.José Fonseca1-6/+7
2010-08-04glsl2: Remove uses of deprecated TALLOC_CTX type.Kenneth Graunke1-6/+6
2010-08-02glsl_type: Use string key for array type hashIan Romanick1-3/+0
2010-08-02glsl2: Make glsl_types::ctx private againIan Romanick1-1/+3
2010-07-27glsl2: Talloc type names.Eric Anholt1-1/+1
Otherwise, we end up losing structure names after compile time, and dumping IR often ends up reporting some other mysterious string.