aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
...
* glsl: Add callback_leave to ir_hierarchical_visitor.Matt Turner2014-07-153-73/+126
|
* glsl: Fix aggregates with dynamic initializers.Cody Northrop2014-07-141-3/+14
| | | | | | | | | | | | | | | | | | | | | Vectors are falling in to the ir_dereference_array() path. Without this change, the following glsl aborts the debug driver, or gets the wrong answer in release: mat2x2 a = mat2( vec2( 1.0, vertex.x ), vec2( 0.0, 1.0 ) ); Also submitting piglit tests, will reference in bug. v2: Rebase on Mesa master. v3: Remove unneeded check for arrays, which are covered by process_array_constructor(), recommended by Timothy Arceri. Signed-off-by: Cody Northrop <[email protected]> Reviewed-by: Courtney Goeltzenleuchter <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79373
* glsl: add new interpolateAt* builtin functionsChris Forbes2014-07-121-0/+67
| | | | | | | | | | | | V2: - Don't assume everyone wants interpolateAtSample() lowered to interpolateAtOffset. It turns out this isn't what we want most of the time for i965. Lowering can be added later in an ir pass which drivers opt into, rather than bolting it straight into the builtin definition. - Only expose the interpolateAt* builtins in the fragment language. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: add new expression types for interpolateAt*Chris Forbes2014-07-126-2/+73
| | | | | | | Will be used to implement interpolateAt*() from ARB_gpu_shader5 Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* allow builtin functions to require parameters to be shader inputsChris Forbes2014-07-122-0/+24
| | | | | | | | | | | | | The new interpolateAt* builtins have strange restrictions on the <interpolant> parameter. - It must be a shader input, or an element of a shader input array. - It must not include a swizzle. V2: Don't abuse ir_var_mode_shader_in for this; make a new flag. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/glcpp: move macro declaration before code to fix MSVC buildBrian Paul2014-07-101-1/+2
| | | | Reviewed-by: Carl Worth <[email protected]>
* glsl/glcpp: Don't choke on an empty pragmaCarl Worth2014-07-093-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | The lexer was insisting that there be at least one character after "#pragma" and before the end of the line. This caused an error for a line consisting only of "#pragma" which volates at least the following sentence from the GLSL ES Specification 3.00.4: The scope as well as the effect of the optimize and debug pragmas is implementation-dependent except that their use must not generate an error. [Page 12 (Page 28 of PDF)] and likely the following sentence from that specification and also in GLSLangSpec 4.30.6: If an implementation does not recognize the tokens following #pragma, then it will ignore that pragma. Add a "make check" test to ensure no future regressions. This change fixes at least part of the following Khronos GLES3 CTS test: preprocessor.pragmas.pragma_vertex Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/glcpp: Promote "extra token at end of directive" from warning to errorCarl Worth2014-07-093-1/+14
| | | | | | | | | | | | | | | | We've always warned about this case, but a recent confromance test expects this to be an error that causes compilation to fail. Make it so. Also add a "make check" test to ensure these errors are generated. This fixes the following Khronos GLES3 conformance tests: invalid_conditionals.tokens_after_ifdef_vertex invalid_conditionals.tokens_after_ifdef_fragment invalid_conditionals.tokens_after_ifndef_vertex invalid_conditionals.tokens_after_ifndef_fragment Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/glcpp: Once again report undefined macro name in error message.Carl Worth2014-07-093-38/+86
| | | | | | | | | | | While writing the previous commit message, I just felt bad documenting the shortcoming of the change, (that undefined macro names would not be reported in error messages). Fix this by preserving the first-encounterd undefined macro name and reporting that in any resulting error message. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/glcpp: Add short-circuiting for || and && in #if/#elif for OpenGL ES.Carl Worth2014-07-094-30/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GLSL ES Specification 3.00.4 says: #if, #ifdef, #ifndef, #else, #elif, and #endif are defined to operate as for C++ except for the following: ... • Undefined identifiers not consumed by the defined operator do not default to '0'. Use of such identifiers causes an error. [Page 11 (page 127 of the PDF file)] as well as: The semantics of applying operators in the preprocessor match those standard in the C++ preprocessor with the following exceptions: • The 2nd operand in a logical and ('&&') operation is evaluated if and only if the 1st operand evaluates to non-zero. • The 2nd operand in a logical or ('||') operation is evaluated if and only if the 1st operand evaluates to zero. If an operand is not evaluated, the presence of undefined identifiers in the operand will not cause an error. (Note that neither of these deviations from C++ preprocessor behavior apply to non-ES GLSL, at least as of specfication version 4.30.6). The first portion of this, (generating an error for an undefined macro in an (short-circuiting to squelch errors), was not implemented previously, but is implemented in this commit. A test is added for "make check" to ensure this behavior. Note: The change as implemented does make the error message a bit less precise, (it just states that an undefined macro was encountered, but not the name of the macro). This commit fixes the following Khronos GLES3 conformance test: undefined_identifiers.valid_undefined_identifier_1_vertex undefined_identifiers.valid_undefined_identifier_1_fragment undefined_identifiers.valid_undefined_identifier_2_vertex undefined_identifiers.valid_undefined_identifier_2_fragment Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/glcpp: Fix glcpp to properly lex entire "preprocessing numbers"Carl Worth2014-07-093-0/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The preprocessor defines a notions of a "preprocessing number" that starts with either a digit or a decimal point, and continues with zero or more of digits, decimal points, identifier characters, or the sign symbols, ('-' and '+'). Prior to this change, preprocessing numbers were lexed as some combination of OTHER and IDENTIFIER tokens. This had the problem of causing undesired macro expansion in some cases. We add tests to ensure that the undesired macro expansion does not happen in cases such as: #define e +1 #define xyz -2 int n = 1e; int p = 1xyz; In either case these macro definitions have no effect after this change, so that the numeric literals, (whether valid or not), will be passed on as-is from the preprocessor to the compiler proper. This fixes the following Khronos GLES3 CTS tests: preprocessor.basic.correct_phases_vertex preprocessor.basic.correct_phases_fragment v2. Thanks to Anuj Phogat for improving the original regular expression, (which accepted a '+' or '-', where these are only allowed after one of [eEpP]. I also expanded the test to exercise this. v3. Also fixed regular expression to require at least one digit at the beginning (after an optional period). Otherwise, a string such as ".xyz" was getting sucked up as a preprocessing number, (where obviously this should be a field access). Again, I expanded the test to exercise this. Reviewed-by: Anuj Phogat <[email protected]>
* glsl/glcpp: Fix glcpp to catch garbage after #if 1 ... #elseCarl Worth2014-07-097-16/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, a line such as: #else garbage would flag an error if it followed "#if 0", but not if it followed "#if 1". We fix this by setting a new bit of state (lexing_else) that allows the lexer to defer switching to the <SKIP> start state until after the NEWLINE following the #else directive. A new test case is added for: #if 1 #else garbage #endif which was untested before, (and did not generate the desired error). This fixes the following Khronos GLES3 CTS tests: tokens_after_else_vertex tokens_after_else_fragment Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl/glcpp: Fixup glcpp tests for redefining a macro with whitespace changes.Carl Worth2014-07-093-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the test suite was expecting the compiler to allow a redefintion of a macro with whitespace added, but gcc is more strict and allows only for changes in the amounts of whitespace, (but insists that whitespace exist or not in exactly the same places). See: https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html: These definitions are effectively the same: #define FOUR (2 + 2) #define FOUR (2 + 2) #define FOUR (2 /* two */ + 2) but these are not: #define FOUR (2 + 2) #define FOUR ( 2+2 ) #define FOUR (2 * 2) #define FOUR(score,and,seven,years,ago) (2 + 2) This change adjusts the existing "redefine-macro-legitimate" test to work with the more strict understanding, and adds a new "redefine-whitespace" test to verify that changes in the position of whitespace are flagged as errors. Reviewed-by: Anuj Phogat <[email protected]>
* glsl/glcpp: Fix preprocessor error condition for macro redefinitionAnuj Phogat2014-07-091-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch specifically fixes redefinition condition for white space changes. #define and #undef functionality in GLSL follows the standard for C++ preprocessors for macro definitions. From https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html: These definitions are effectively the same: #define FOUR (2 + 2) #define FOUR (2 + 2) #define FOUR (2 /* two */ + 2) but these are not: #define FOUR (2 + 2) #define FOUR ( 2+2 ) #define FOUR (2 * 2) #define FOUR(score,and,seven,years,ago) (2 + 2) Fixes Khronos GLES3 CTS tests; invalid_object_whitespace_vertex invalid_object_whitespace_fragment Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Carl Worth <[email protected]>
* glsl/glcpp: Add test to ensure compiler won't allow #undef for some builtinsCarl Worth2014-07-092-0/+10
| | | | | | | Currently verifying that an #undef of __FILE__, __LINE__, or __VERSION__ will generate an error. Reviewed-by: Anuj Phogat <[email protected]>
* glsl/glcpp: Do not allow undefining the built-in macrosAnuj Phogat2014-07-091-0/+6
| | | | | | | | | | | | | | | | | Fixes piglit tests in spec/glsl-es-3.00/compile: undef-__FILE__.vert undef-GL_ES.vert undef-__LINE__.vert undef-__VERSION__.vert Also, fixes Khronos GLES3 CTS tests: undefine_invalid_object_1_vertex undefine_invalid_object_1_fragment undefine_invalid_object_2_vertex undefine_invalid_object_2_fragment Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Carl Worth <[email protected]>
* glsl: Fix the foreach_in_list_reverse macro.Kenneth Graunke2014-07-081-3/+3
| | | | | | | | | | | We clearly don't want to start at the head and walk backwards; we want to start at the last real element before the tail sentinel. If the list is empty, tail_pred will be the head sentinel, and we'll stop. Nothing uses this function, so I guess nobody noticed it was broken. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Fix merging of layout(invocations) with other qualifiersChris Forbes2014-07-051-0/+10
| | | | | | | | | | | | | | | | | If another layout qualifier appeared to the left of `invocations` in the GS input layout declaration, the invocation count would be dropped on the floor. Fixes the piglit tests: spec/ARB_transform_feedback3/arb_transform_feedback3-ext_interleaved_two_bufs_gs_max spec/ARB_gpu_shader5/arb_gpu_shader5-invocation-id spec/ARB_gpu_shader5/compiler/correct-multiple-layout-qualifier-invocations.geom spec/ARB_gpu_shader5/execution/invocations-conflicting Signed-off-by: Chris Forbes <[email protected]> Tested-by: Ilia Mirkin <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: fix duplicated layout qualifier detection for GSSamuel Iglesias Gonsalvez2014-07-031-6/+16
| | | | | | | | | | | | This patch fixes the duplicated layout qualifier detection for geometry shader's layout qualifiers. Also it makes the detection code more legible by defining allowed_duplicates_mask variable. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80778 Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: add support for AMD_vertex_shader_viewport_indexIlia Mirkin2014-07-024-0/+8
| | | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Tested-by: Tobias Droste <[email protected]>
* mesa: Make unreachable macro take a string argument.Matt Turner2014-07-011-2/+1
| | | | | | To aid in debugging. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove now unused foreach_list* macros.Matt Turner2014-07-011-24/+0
| | | | | | foreach_list_typed_const was never used as far as I can tell. Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add and use foreach_list_typed_safe.Matt Turner2014-07-011-0/+9
| | | | Acked-by: Ian Romanick <[email protected]>
* mesa: Add and use foreach_in_list_use_after.Matt Turner2014-07-011-0/+5
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Replace uses of foreach_list_const.Matt Turner2014-07-012-17/+6
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Replace another couple uses of foreach_list.Matt Turner2014-07-011-6/+4
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use foreach_list_typed when possible.Matt Turner2014-07-013-31/+18
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use typed foreach_in_list_safe instead of foreach_list_safe.Matt Turner2014-07-0120-87/+41
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use typed foreach_in_list instead of foreach_list.Matt Turner2014-07-0139-291/+184
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add typed foreach_in_list_safe macro.Matt Turner2014-07-011-0/+9
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add typed foreach_in_list/_reverse macros.Matt Turner2014-07-011-0/+10
| | | | Reviewed-by: Ian Romanick <[email protected]>
* Remove the ATI_envmap_bumpmap extensionJason Ekstrand2014-06-301-12/+0
| | | | | | | | | | | As far as I can tell, the Intel mesa driver is the only driver in the world still supporting this legacy extension. If someone wants to do bump mapping, they can use shaders. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> [v1] Reviewed-by: Chris Forbes <[email protected]> [v2] Reviewed-by: Ian Romanick <[email protected]> [v3]
* glsl: include streamId when reading/printing ir_variable IR.Samuel Iglesias Gonsalvez2014-06-302-2/+11
| | | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: include streamId when reading/printing emit-vertex and end-primitive IR.Iago Toral Quiroga2014-06-302-8/+27
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Validate vertex emission in geometry shaders.Iago Toral Quiroga2014-06-301-14/+134
| | | | | | | Check if non-zero streams are used. Fail to link if emitting to unsupported streams or emitting to non-zero streams with output type other than GL_POINTS. Reviewed-by: Chris Forbes <[email protected]>
* glsl: Add support for EmitStreamVertex() and EndStreamPrimitive().Iago Toral Quiroga2014-06-301-0/+58
| | | | Reviewed-by: Chris Forbes <[email protected]>
* glsl: Modify ir_end_primitive to have a stream.Iago Toral Quiroga2014-06-307-16/+64
| | | | | | | This will be necessary to implement EndStreamPrimitive(). EndPrimitive() will produce an ir_end_primitive with the default stream 0. Reviewed-by: Chris Forbes <[email protected]>
* glsl: Modify ir_emit_vertex to have a stream.Iago Toral Quiroga2014-06-3010-21/+68
| | | | | | | This will be necessary to implement EmitStreamVertex(). EmitVertex() will produce an ir_emit_vertex with the default stream 0. Reviewed-by: Chris Forbes <[email protected]>
* glsl: Only geometry shader outputs can be associated with non-zero streams.Iago Toral Quiroga2014-06-301-0/+5
| | | | | | | This should be ensured by the parser, so assert on that. Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Two varyings can't write to the same buffer from different streams.Iago Toral Quiroga2014-06-301-0/+17
| | | | | | | If this is detected, fail to link. Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add methods to retrive a varying's name and streamId.Iago Toral Quiroga2014-06-301-0/+10
| | | | | Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fail to link if inter-stage input/outputs are not assigned to stream 0Iago Toral Quiroga2014-06-301-0/+8
| | | | | | | Outputs that are linked to inputs in the next stage must be output to stream 0, otherwise we should fail to link. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Assign GLSL StreamIds to transform feedback outputs.Iago Toral Quiroga2014-06-302-3/+16
| | | | | | Inter-shader outputs must be on stream 0, which is the default. Reviewed-by: Chris Forbes <[email protected]>
* mesa: add StreamId information to transform feedback outputs.Iago Toral Quiroga2014-06-301-0/+1
| | | | | | | For now initialized to the default stream 0. Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add parsing support for multi-stream output in geometry shaders.Samuel Iglesias Gonsalvez2014-06-307-1/+144
| | | | | | | | This implements parsing requirements for multi-stream support in geometry shaders as defined in ARB_gpu_shader5. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add missing null check in push_back()Juha-Pekka Heikkila2014-06-261-2/+11
| | | | | | | Report memory error on realloc failure and don't leak any memory. Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: check _mesa_hash_table_create return value in link_uniform_blocksJuha-Pekka Heikkila2014-06-262-0/+8
| | | | | Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Treat an interface block specifier as a level of struct nestingChris Forbes2014-06-261-0/+8
| | | | | | | | | Fixes the piglit test: spec/glsl-1.50/compiler/interface-blocks-structs-defined-within-block-instanced.vert Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Disallow primitive type layout qualifier on variables.Chris Forbes2014-06-261-0/+7
| | | | | | | | | | | | | | | | This only makes any sense on the GS input or output layout declaration, nowhere else. Fixes the piglit tests: * spec/glsl-1.50/compiler/incorrect-in-layout-qualifiers-with-variable-declarations.geom * spec/glsl-1.50/compiler/incorrect-out-layout-qualifiers-with-variable-declarations.geom * spec/glsl-1.50/compiler/layout-fs-no-output.frag * spec/glsl-1.50/compiler/layout-vs-no-input.vert * spec/glsl-1.50/compiler/layout-vs-no-output.vert Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Relax combinations of layout qualifiers with other qualifiers.Chris Forbes2014-06-261-28/+8
| | | | | | | | | | | | | | | | | | | Previously we disallowed any combination of layout with interpolation, invariant, or precise qualifiers. There is very little spec guidance on exactly which combinations should be allowed, but with ARB_sso it's useful to allow these qualifiers with rendezvous-by-location. Since it's unclear exactly where the layout qualifier should appear when combined with other qualifiers, we will allow it anywhere before the auxiliary storage qualifier. This allows enough flexibility for all examples I've seen, while keeping the auxiliary-storage-qualifier / storage-qualifier pair together (as they are a single qualifier in the spec prior to ARB_shading_language_420pack) Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>