summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Avoid variable length arrays.José Fonseca2013-07-121-7/+14
| | | | | | | | | They are a non-standard GCC extension that's not widely supported by other C/C++ compilers. Use a dynamic array instead. Trivial. Should fix the MSVC build.
* glsl: Add support for C-style initializers.Matt Turner2013-07-114-1/+257
| | | | | | | | | Required by GL_ARB_shading_language_420pack. Parts based on work done by Todd Previte and Ken Graunke, implementing basic support for C-style initializers of arrays. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add infrastructure for aggregate initializers.Matt Turner2013-07-114-1/+72
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add an is_declaration field to ast_struct_specifier.Matt Turner2013-07-112-1/+4
| | | | | | | | | | | | | | | | | | Will be used in a later commit to differentiate between a structure type declaration and a variable declaration of a struct type. I.e., the difference between struct S { float x; }; (is_declaration = true) and S s; (is_declaration = false) Also note that is_declaration = true for struct S { float x; } s; Reviewed-by: Ian Romanick <[email protected]>
* glsl: Track structs' ast_type_specifiers in symbol table.Matt Turner2013-07-112-4/+27
| | | | | | | | | Will be used in a future commit. An ast_type_specifier is stored (rather than an ast_struct_specifier) with the idea that we may have more general uses for this in the future. struct names are prefixed with '#ast.' to avoid collisions with the glsl_types in the symbol table. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add process_vec_mat_constructor() function.Matt Turner2013-07-111-0/+114
| | | | | | Based largely on process_array_constructor(). Reviewed-by: Ian Romanick <[email protected]>
* glsl: Separate code into process_record_constructor().Matt Turner2013-07-111-48/+60
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add copy-constructor for ast_struct_specifier.Matt Turner2013-07-111-0/+12
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a constructor for ast_type_specifier.Matt Turner2013-07-111-0/+16
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Clean up and clarify comment explaining initializer rules.Matt Turner2013-07-111-7/+13
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Change type of is_array to bool.Matt Turner2013-07-112-5/+5
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a comment to note what an exec_list is a list of.Matt Turner2013-07-111-0/+1
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix inverted conditional in error message.Matt Turner2013-07-111-1/+1
| | | | | | | | | | | | The code float a[2] = float[2]( 3.4, 4.2, 5.0 ); previously generated this: error: array constructor must have at least 2 parameters when in fact it requires exactly two. Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add missing return error_value(ctx) in error path.Matt Turner2013-07-111-0/+1
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove unnecessary #include from ast_type.cpp.Matt Turner2013-07-111-3/+0
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/build: build builtin_compiler with VISIBILITY_CFLAGSChia-I Wu2013-07-121-1/+2
| | | | | | | | | libglslcore.la and libglcpp.la that are built with builtin_compiler are also linked to by drivers not using libdricore. Since there is no public symbol in them, it is better to mark all symbols hidden. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add comment explaining "row_major" parsing.Matt Turner2013-07-111-0/+6
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Mark "row_major" as not a reserved word in GLSL ES 3.0.Matt Turner2013-07-111-2/+2
| | | | | | | | | | We mark ARB_uniform_buffer_object as enabled under ES 3 since it contains that functionality, which tricked the compiler into tokenizing "row_major". Acked-by: Anuj Phogat <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove outdated FINISHME comment.Matt Turner2013-07-111-3/+0
| | | | | | Explicit index support was added by commit 1256a5dc. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Silence unused variable warning in the release buildEmil Velikov2013-07-081-0/+2
| | | | | | | | | | | | Resolves the following gcc warning opt_flip_matrices.cpp:84:32: warning: unused variable 'deref' v2: keep the variable, but wrap it in a ifndef NDEBUG block (suggested by Ian) Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/ast: Silence uninitialized variable warnings in the release buildEmil Velikov2013-07-081-0/+2
| | | | | | | | | | | | Resolves the following gcc warnings warning: 'iface_type_name' may be used uninitialized in this function warning: 'var_mode' may be used uninitialized in this function Note: The variables are initialised to UNKNOWN and ir_var_auto Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Allow non-constant expression initializers of const-qualified vars.Matt Turner2013-07-081-11/+19
| | | | | | Required by ARB_shading_language_420pack. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Ensure snprintf is defined on MSVC builds.José Fonseca2013-07-031-0/+1
| | | | | | | Should fix: src\glsl\opt_dead_builtin_varyings.cpp(244) : error C3861: 'snprintf': identifier not found ...
* mesa,glsl,gallium: remove GLSLSkipStrictMaxVaryingLimitCheck and dependenciesMarek Olšák2013-07-021-24/+8
| | | | | | Not needed with do_dead_builtin_varyings. Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: eliminate unused and set-but-unused built-in varyingsMarek Olšák2013-07-025-2/+496
| | | | | | | | | | | | | This eliminates built-in varyings such as gl_Color, gl_SecondaryColor, gl_TexCoord, and gl_FogFragCoord if they are unused by the next stage or not written at all (e.g. gl_TexCoord elements). The gl_TexCoord array is broken down into separate vec4s if needed. v2: - use a switch statement in varying_info_visitor::visit(ir_variable*) - use snprintf - disable the optimization for GLES2 Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: check against varying limit after unused varyings are eliminatedMarek Olšák2013-07-023-11/+33
| | | | | | | We counted even the varyings which were later eliminated, which was suboptimal. Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: link shaders in the opposite order (from fragment to vertex)Marek Olšák2013-07-021-50/+58
| | | | | | | | | | | | | | This ensures that inter-shader outputs and inputs are properly eliminated across 3 or more shader stages. The behavior is unchanged with 2 or less shader stages. For example, elimination of unused FS inputs causes elimination of matching GS outputs, which causes elimination of the GS inputs that were needed for evaluation of the eliminated GS outputs, which causes elimination of matching VS outputs. An unused FS input is all that's needed to trigger this chain reaction. Reviewed-by: Ian Romanick <[email protected]>
* mesa: renumber shader indices according to their placement in pipelineMarek Olšák2013-07-021-8/+8
| | | | | | | | | See my explanation in mtypes.h. v2: don't do this in gallium v3: also updated the comment at the gl_shader_type definition Reviewed-by: Ian Romanick <[email protected]>
* glsl/builtins: Fix ARB_texture_cube_map_array built-in availability.Kenneth Graunke2013-07-022-1/+8
| | | | | | | | | | | | | | | | | | | | | This patch adds texture() for isamplerCubeArray and usamplerCubeArray, which were entirely missing. It also makes texture() with a LOD bias fragment shader specific. The main GLSL specification explicitly says that texturing with LOD bias should not be allowed for vertex shaders. Affects Piglit's ARB_texture_cube_map_array/compiler/tex_bias-01.vert. which tries to use bias in a vertex shader. Currently, it expects this to pass (so this patch regresses the test), but I've sent a patch to reverse the expected behavior (so this patch would fix the updated test): http://lists.freedesktop.org/archives/piglit/2013-June/006123.html NOTE: This is a candidate for stable branches. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: Initialize member variable is_ubo_var in constructor.Vinson Lee2013-06-271-1/+1
| | | | | | | Fixes "Uninitialized scalar field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use the C99 variadic macro syntax.José Fonseca2013-06-272-4/+4
| | | | | | | MSVC does not support the old GCC syntax. See also http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html
* glsl: Move all var decls to the front of the IR list in reverse orderIan Romanick2013-06-261-0/+18
| | | | | | | | | | | | | | | | | | This has the (intended!) side effect that vertex shader inputs and fragment shader outputs will appear in the IR in the same order that they appeared in the shader code. This results in the locations being assigned in the declared order. Many (arguably buggy) applications depend on this behavior, and it matches what nearly all other drivers do. Fixes the (new) piglit test attrib-assignments. NOTE: This is a candidate for stable release branches (and requires the previous commit to prevent a regression in OpenGL ES 2.0 conformance test stencil_plane_operation). Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Streamline the built-in type handling code.Kenneth Graunke2013-06-266-694/+424
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Don't use random pointers as an array of glsl_type objects.Kenneth Graunke2013-06-261-1/+1
| | | | | | | | | | | | Using a random glsl_type convenience pointer as an array is a really bad idea, for all the reasons mentioned in the previous commit. The new glsl_type::bvec() function is simpler anyway. Prevents breakage in the next commit. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Stop being clever with pointer arithmetic when fetching types.Kenneth Graunke2013-06-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | Currently, vector types are linked together closely: the glsl_type objects for float, vec2, vec3, and vec4 are all elements of the same array, in that exact order. This makes it possible to obtain vector types via pointer arithmetic on the scalar type's convenience pointer. For example, float_type + (3 - 1) = vec3. However, relying on this is extremely fragile. There's no particular reason the underlying type objects need to be stored in an array. They could be individual class members, possibly with padding between them. Then the pointer arithmetic would break, and we'd get bad pointers to non-heap allocated data, causing subtle breakage that can't be detected by valgrind. Cue insanity. Or someone could simply reorder the type variables, causing us to get the wrong type entirely. Also cue insanity. Writing this explicitly is much safer. With the new helper functions, it's a bit less code even. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Add simple vector type accessor helpers.Kenneth Graunke2013-06-262-0/+61
| | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: Move the common _mesa_glsl_compile_shader() code to glsl/.Eric Anholt2013-06-213-60/+98
| | | | | | | | | | | This code had no relation to ir_to_mesa.cpp, since it was also used by intel and state_tracker, and most of it was duplicated with the standalone compiler (which has periodically drifted from the Mesa copy). v2: Split from the ir_to_mesa to shaderapi.c changes. Acked-by: Paul Berry <[email protected]> (v1) Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Use shared code for converting shader targets to short strings.Eric Anholt2013-06-214-7/+50
| | | | | | | | We were duplicating this code all over the place, and they all would need updating for the next set of shader targets. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Remove ir_print_visitor.h includes and usageEric Anholt2013-06-216-6/+0
| | | | | | | | | | | | | We have ir->print() to do the old declaration of a visitor and having the IR accept the visitor (yuck!). And now you can call _mesa_print_ir() safely anywhere that you know what an ir_instruction is. A couple of missing printf("\n")s are added in error paths -- when an expression is handed to the visitor, it doesn't print '\n' (since it might be a step in printing a whole expression tree). Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Make _mesa_print_ir() available from anything including ir.h.Eric Anholt2013-06-213-3/+11
| | | | | | | | | | No more forgetting to #include "ir_print_visitor.h" when doing temporary debug code, or forgetting and leaving it in after removing your temporary debug code. Also, available from C code so you don't need to move the caller to C++ just to call it (see also: ir_to_mesa.cpp). Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Make some files safe to include from CPaul Berry2013-06-213-0/+8
| | | | | Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Disallow return with a void argument from void functions.Matt Turner2013-06-141-1/+17
| | | | | | NOTE: This is a candidate for the stable branches. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Allow implicit conversion of return values.Matt Turner2013-06-141-9/+22
| | | | | | Required by ARB_shading_language_420pack. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add gl_{Max,Min}ProgramTexelOffset built-in constants.Matt Turner2013-06-141-0/+7
| | | | | | | | Required by ARB_shading_language_420pack. Note that the 420pack spec incorrectly specifies their values as (Min, Max) = (-7, 8) when they should be (-8, 7) as listed in the GLSL 4.30 and ESSL 3.0 specs. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Allow swizzles on scalars.Matt Turner2013-06-141-1/+3
| | | | | | Required by ARB_shading_language_420pack. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Allow .length() method on vectors and matrices.Matt Turner2013-06-141-20/+38
| | | | | | Required by ARB_shading_language_420pack. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Add infrastructure for ARB_shading_language_420pack.Todd Previte2013-06-143-0/+6
| | | | | | | | v2 [mattst88] - Split infrastructure into separate patch. - Add preprocessor #define. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix null check in read_dereference.Vinson Lee2013-06-131-1/+1
| | | | | | | Fixes "Logically dead code" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: fix OES_EGL_image_external being partially allowed in the core profileMarek Olšák2013-06-131-7/+7
| | | | Reviewed-by: Chad Versace <[email protected]>
* glsl: Generate smaller values for uniform locationsIan Romanick2013-06-121-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would generate uniform locations as (slot << 16) + array_index. We do this to handle applications that assume the location of a[2] will be +1 from the location of a[1]. This resulted in every uniform location being at least 0x10000. The OpenGL 4.3 spec was amended to require this behavior, but previous versions did not require locations of array (or structure) members be sequential. We've now encountered two applications that assume uniform values will be "small." As far as we can tell, these applications store the GLint returned by glGetUniformLocation in a int16_t or possibly an int8_t. THIS BEHAVIOR IS NOT GUARANTEED OR IMPLIED BY ANY VERSION OF OpenGL. Other implementations happen to have both these behaviors (sequential array elements and small values) since OpenGL 2.0, so let's just match their behavior. Fixes "3D Bowling" on Android. NOTE: This is a candidate for stable release branches. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-and-tested-by: Chad Versace <[email protected]>