summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Allow precision qualifiers for sampler typesAnuj Phogat2013-08-291-8/+21
| | | | | | | | | | | | | | | | | | | | | | | GLSL 1.30 doesn't allow precision qualifiers on sampler types, but in GLSL ES, sampler types are also allowed. This seems like an oversight (since the intention of including these in GLSL 1.30 is to allow compatibility with ES shaders). Currently, Mesa allows "default" precision qualifiers to be set for sampler types in GLSL (commit d5948f2). This patch makes it follow GLSL ES rules and also allow declaring sampler variables with a precision qualifier in GLSL 1.30 (and later). e.g. uniform lowp sampler2D sampler; This fixes a shader compilation error in Khronos OpenGL conformance test "depth_texture_mipmap". V2: Update comments. Signed-off-by: Ian Romanick <[email protected]> Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Cc: <[email protected]>
* glsl: Add heuristics to print floating-point numbers better.Matt Turner2013-08-2915-32/+42
| | | | | v2: Fix *.expected files to match. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add built-ins from ARB_shader_bit_encoding to ARB_gpu_shader5.Matt Turner2013-08-271-0/+20
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl: Add support for new fma built-in in ARB_gpu_shader5.Matt Turner2013-08-274-0/+20
| | | | | | v2: Add constant folding support. Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add new fma built-in IR and prototype from ARB_gpu_shader5.Matt Turner2013-08-272-0/+34
| | | | | Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Disallow uniform block layout qualifiers on non-uniform block vars.Matt Turner2013-08-261-4/+13
| | | | | | Cc: 9.2 <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68460 Reviewed-by: Ian Romanick <[email protected]>
* glsl: init limit=0 to silence uninitialized var warningBrian Paul2013-08-261-1/+1
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl: Add built-in function prototypes for GLSL 3.30Kenneth Graunke2013-08-252-0/+1169
| | | | | | | | 330.frag is a direct copy of 150.frag. 330.glsl is 150.glsl combined with ARB_shader_bit_encoding.glsl. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Bump standalone compiler versions to 3.30.Kenneth Graunke2013-08-252-3/+3
| | | | | | | These are necessary in order to compile the built-in functions. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Refactor handling of gl_ClipDistance/gl_ClipVertex linkage rules for GS.Paul Berry2013-08-231-29/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch extracts the following logic from validate_vertex_shader_executable(): (a) Generate an error if the shader writes to both gl_ClipDistance and gl_ClipVertex. (b) Record whether the shader writes to gl_ClipDistance in gl_shader_program for use by the back-end. (c) Record the size of gl_ClipDistance in gl_shader_program for use by transform feedback logic. And moves it into a function that is shared between vertex and geometry shaders. Strictly speaking we only need to have shared logic for (b) and (c) right now (since (a) only matters in compatibility contexts, and we're only implementing geometry shaders in core contexts right now). But the three are closely related enough that it seems sensible to keep them together. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Give a warning, not an error, for UBO qualifiers on non-matrices.Ian Romanick2013-08-211-6/+12
| | | | | | Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59648 Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Ian Romanick <[email protected]>
* glsl: Remove ubo_qualifiers_allowed variable.Matt Turner2013-08-214-11/+2
| | | | | | | No longer used. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Drop duplicate error messages.Matt Turner2013-08-211-12/+1
| | | | | | | | This same message is printed in the validate_matrix_layout_for_type function. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Rename ubo_qualifiers_valid to ubo_qualifiers_allowed.Matt Turner2013-08-214-6/+6
| | | | | | | | | The variable means that UBO qualifiers are allowed in a particular context (e.g., not allowed in a struct field declaration), rather than a particular set of UBO qualifiers are valid. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Track existence of default float precision in GLSL ES fragment shadersIan Romanick2013-08-212-4/+68
| | | | | | | | | | | | | | | | | | | This is required by the spec, and it's a bit tricky because the default precision is scoped. As a result, I'm slightly abusing the symbol table. Fixes piglit no-default-float-precision.frag tests and the piglit default-precision-nested-scope-0[1234].frag tests that are currently on the piglit mailing list for review. On IRC I got confirmation from cwabbot that ARM (Mali T6xx and T400) enforces this requirement and from kusma that NVIDIA (Tegra2) enforces this requirement. We should be safe from regressing shipping applications. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Merge precision qualifiers tooIan Romanick2013-08-211-0/+3
| | | | | | | | | | | | | We never noticed this before because we previously didn't enfoce GLSL ES fragement shader requirements that precision be defined. There may also have been some interaction here with the addition of GL_ARB_shading_language_420pack, but it doesn't appear to me that it added any new bugs (just perhaps uncovered some old ones). Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Pass type to is_valid_default_precision_type instead of nameIan Romanick2013-08-211-4/+5
| | | | | | | | This is used by the next patch. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Use alignment of container record for its first fieldIan Romanick2013-08-192-2/+28
| | | | | | | | | | | | | | | | | | | | The first field of a record in a UBO has the aligment of the record itself. Fixes piglit vs-struct-pad, fs-struct-pad, and (with the patch posted to the piglit list that extends the test) layout-std140. NOTE: The bit of strangeness with the version of visit_field without the record_type poitner is because that method is pure virtual in the base class. The original implementation of the class did this to ensure derived classes remembered to implement that flavor. Now they can implement either flavor but not both. I don't know a C++ way to enforce that. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68195 Cc: "9.2 9.1" [email protected]
* glsl: Add new overload of program_resource_visitor::visit_field methodIan Romanick2013-08-192-10/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The outer-most record is passed into the visit_field method for the first field. In other words, in the following structure: struct S1 { vec4 v; float f; }; struct S { S1 s1; S1 s2; }; uniform Ubo { S s; }; s.s1.v would get record_type = S (because s1.v is the first non-record field in S), and s.s2.v would get record_type = S1. s.s1.f and s.s2.f would get record_type = NULL becuase they aren't the first field of anything. This new overload isn't used yet, but the next patch will add several uses. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Cc: "9.2 9.1" [email protected]
* glsl: Disallow embedded structure definitionsIan Romanick2013-08-193-0/+38
| | | | | | | | | | Continue to allow them in GLSL 1.10 because the spec allows it. Generate an error in all other versions because the specs specifically disallow it. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Add default precision qualifiers for ES builtinsIan Romanick2013-08-195-0/+6
| | | | | | | | | Once the compiler proplerly checks for default precision qualifiers, these shaders will cease to compile. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Remove extra "types" from error messageIan Romanick2013-08-191-1/+1
| | | | | | | Send it straight to the Department of Redundancy Department. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: don't eliminate texcoords that can be set by GL_COORD_REPLACEMarek Olšák2013-08-183-12/+23
| | | | | | | | | Tested by examining generated TGSI shaders from piglit/glsl-routing. Cc: [email protected] Reviewed-by: Henri Verbeet <[email protected]> Tested-by: Henri Verbeet <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add i2b() and b2i() to ir_builder.Matt Turner2013-08-142-0/+14
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Add nequal() to ir_builder.Matt Turner2013-08-142-0/+7
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Add abs() to ir_builder.Matt Turner2013-08-142-0/+7
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Add bitcast_i2f() to ir_builder.Matt Turner2013-08-142-0/+28
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Fix incorrect pattern matching in ir_set_program_inoutsPaul Berry2013-08-141-2/+2
| | | | | | | | | | | | | | | | | | | | In commit 8fc41df (glsl: Modify ir_set_program_inouts to handle geometry shaders), when attempting to pattern match the "foo" part of expressions such as: foo[i][j] foo[i] I incorrectly called as_dereference_variable() on the subexpression foo[i] instead of foo. As a result, the pattern never matched, so ir_set_program_inouts would fall back on marking the entire variable as used, rather than just the portion indexed by the array. This didn't result in incorrect behaviour, but it could have resulted in inefficiency by causing the back-end to allocate resources for unused parts of an input or output array. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Emit better warnings for things that look like default precision ↵Ian Romanick2013-08-131-13/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | statements Previously we would emit a warning for empty declarations like float; We would also emit the same warning for things like highp float; However, this second case is most likely the application trying to set the default precision. This makes the compiler generate a stronger warning with some suggestion of a fix. It really seems like this should be an error. I'll bet that 100% of the time someone writes 'highp float;' the actually meant 'precision highp float;'. Alas, both AMD and NVIDIA accept this syntax, and the spec doesn't explicitly forbid it. This makes piglit's precision-05.vert generate the following warnings: 0:12(11): warning: empty declaration with precision qualifier, to set the default precision, use `precision lowp float;' 0:13(12): warning: empty declaration with precision qualifier, to set the default precision, use `precision mediump int;' v2: Add { } around a one-line if body and fix a comment. Suggested by Ken. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.2" <[email protected]>
* glsl/ast: Don't perform GS input array checks on non-inputs.Paul Berry2013-08-131-1/+1
| | | | | | | | Previously, we were accidentally calling handle_geometry_shader_input_decl() on non-input interface block declarations, resulting in bogus error checking. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/ast: Fix assertion failure when GS input declared as non-array.Paul Berry2013-08-131-4/+12
| | | | | | | | | | | | Previously, if a geometry shader input was declared as a non-array, we would flag the proper compiler error, but then before we got a chance to report it to the client, handle_geometry_shader_input_decl() would assertion fail. With this patch, handle_geometry_shader_input_decl() ignores non-arrays. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/ast: Check that geometry shader interface block inputs are arrays.Paul Berry2013-08-131-0/+13
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Require function return type arrays be explicitly sizedIan Romanick2013-08-131-0/+12
| | | | | | | | Fixes piglit array-function-return-unsized.vert. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Move and refine test for unsized arrays in GLSL ESIan Romanick2013-08-131-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | GLSL ES does not allow unsized arrays, and GLSL ES 1.00 does not allow array initializers. However, GLSL ES 3.00 allows array initializers, and the initializer can explicitly size the array. The specification even includes some examples of this: float x[] = float[2] (1.0, 2.0); // declares an array of size 2 float y[] = float[] (1.0, 2.0, 3.0); // declares an array of size 3 float a[5]; float b[] = a; Move the unsized array check to after the initializer has been processed. If the array is still unsized, generate the error. This should have no effect in GLSL ES 1.00 because, as previously mentioned, array initializers are not allowed. Fixes piglit "glsl-es-3.00 compiler array-sized-by-initializer.vert". Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.1 9.2" <[email protected]>
* glsl: Don't allow const on out or inout function parametersIan Romanick2013-08-091-0/+15
| | | | | | | | | Fixes piglit tests const-inout-parameter.frag and const-out-parameter.frag. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Enable ARB_fragment_coord_conventions functionality in GLSL 1.50.Paul Berry2013-08-092-2/+4
| | | | | | | | | GLSL 1.50 incorporates the functionality of the ARB_fragment_coord_conventions extension, so we need to make this functionality available even if the extension isn't enabled. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Disallow interpolation qualifiers on non-input/output variables.Kenneth Graunke2013-08-021-7/+18
| | | | | | | | | | | | | Commit 2548092ad8015 switched the sense of interpolation qualifier checks in order to permit them on geometry shader in/out variables. In doing so, it accidentally allowed interpolation qualifiers to be applied to ordinary variables and function parameters. Fixes a regression in Piglit's local-smooth-01.frag. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Fix NULL pointer dereferences when linking fails.Kenneth Graunke2013-08-021-8/+5
| | | | | | | | | | | | | | | Commit 7cfefe6965d50 introduced a check for whether linked->Type equals GL_GEOMETRY_SHADER. However, linked may be NULL due to an earlier error condition. Since the entire function after the error path is (or should be) guarded by linked != NULL checks, we may as well just return early and remove the checks. Fixes crashes in 9 Piglit tests. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Implement rules for geometry shader input sizes.Paul Berry2013-08-013-0/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec contains some tricky rules for how the sizes of geometry shader input arrays are related to the input layout specification. In essence, those rules boil down to the following: - If an input array declaration does not specify a size, and it follows an input layout declaration, it is sized according to the input layout. - If an input layout declaration follows an input array declaration that didn't specify a size, the input array declaration is given a size at the time the input layout declaration appears. - All input layout declarations and input array sizes must ultimately match. Inconsistencies are reported as soon as they are detected, at compile time if the inconsistency is within one compilation unit, otherwise at link time. - At least one compilation unit must contain an input layout declaration. (Note: the geom_array_resize_visitor class was contributed by Bryan Cain <[email protected]>.) Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Allow geometry shader input instance arrays to be unsized.Paul Berry2013-08-013-17/+49
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Permit non-ubo input interface arrays to use non-const indexing.Paul Berry2013-08-011-1/+2
| | | | | | | | | | | | | | | | | | | From the GLSL ES 3.00 spec: "All indexes used to index a uniform block array must be constant integral expressions." Similar text exists in GLSL specs since 1.50. When we implemented this, the only type of interface block supported by Mesa was uniform blocks, so we required all indexes used to index any interface block to be constant integral expressions. Now that we are adding interface block support for GLSL 1.50, we need a more specific check. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Cross-validate GS layout qualifiers while intrastage linking.Eric Anholt2013-08-011-0/+96
| | | | | | | | | | | This gets piglit's geometry-basic test running. TODO: Still need to validate that the GS layout qualifiers don't get used in places they shouldn't (like an interface block, or a particular shader input or output) Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Export the compiler's GS layout qualifiers to the gl_shader.Eric Anholt2013-08-011-0/+31
| | | | | | | | | | | | | | | | Next step is to validate them at link time. v2 (Paul Berry <[email protected]>): Don't attempt to export the layout qualifiers in the event of a compile error, since some of them are set up by ast_to_hir(), and ast_to_hir() isn't guaranteed to have run in the event of a compile error. Reviewed-by: Kenneth Graunke <[email protected]> v3 (Paul Berry <[email protected]>): Use PRIM_UNKNOWN to represent "not set in this shader". Reviewed-by: Ian Romanick <[email protected]>
* glsl: Parse the GLSL 1.50 GS layout qualifiers.Eric Anholt2013-08-016-1/+177
| | | | | | | | | | | | | | | Limited semantic checking (compatibility between declarations, checking that they're in the right shader target, etc.) is done. v2: Remove stray debug printfs. v3 (Paul Berry <[email protected]>): Process input layout qualifiers at ast_to_hir time rather than at parse time, since certain error conditions depend on the relative ordering between input layout qualifiers, declarations, and calls to .length(). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make sure that we don't put too many bitfields in ast_type_qualifier.Eric Anholt2013-08-011-0/+2
| | | | | | | | | We do some tests of qualifiers using a union containing an int and the struct full of bitfields, so make sure the bitfields don't spill outside the int. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/linker: Fail to link geometry shader without vertex shader.Fabian Bieler2013-08-011-0/+8
| | | | | | | | | | | From section 2.15 (Geometry Shaders) the OpenGL 3.2 spec: A program object that includes a geometry shader must also include a vertex shader; otherwise a link error will occur. Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Properly pack GS output varyingsPaul Berry2013-08-011-2/+57
| | | | | | | | | | | | | | In geometry shaders, outputs are consumed at the time of a call to EmitVertex() (as opposed to all other shader types, where outputs are consumed when the shader exits). Therefore, when packing geometry shader output varyings using lower_packed_varyings, we need to do the packing at the time of the EmitVertex() call. This patch accomplishes that by adding a new visitor class, lower_packed_varyings_gs_splicer, which is responsible for splicing the varying packing code into place wherever EmitVertex() is found. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Modify varying packing to use a temporary exec_list.Paul Berry2013-08-011-10/+18
| | | | | | | | | | | | | | This patch modifies lower_packed_varyings to store the packing code it generates in a temporary exec_list, and then splice that list into the shader's main() function when it's done. This paves the way for supporting geometry shader outputs, where we'll have to splice a clone of the packing code before every call to EmitVertex(). As a side benefit, varying packing code is now emitted in the same order for inputs and outputs; this should make debug output a little easier to read. Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Properly pack GS input varyings.Paul Berry2013-08-015-35/+199
| | | | | | | | Since geometry shader inputs are arrays (where the array index indicates which vertex is being examined), varying packing needs to treat them differently. Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Properly error check VS-GS linkage.Paul Berry2013-08-011-1/+10
| | | | | | | | | | | | | | | | From section 4.3.4 (Inputs) of the GLSL 1.50 spec: Geometry shader input variables get the per-vertex values written out by vertex shader output variables of the same names. Since a geometry shader operates on a set of vertices, each input varying variable (or input block, see interface blocks below) needs to be declared as an array. Therefore, the element type of each geometry shader input array should match the type of the corresponding vertex shader output. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>