summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* android: add SPIRV_FILES to libmesa_nirTapani Pälli2016-11-111-1/+2
| | | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: include inttypes.h for PRIx64 macroBrian Paul2016-11-101-0/+1
| | | | | | To fix MinGW build. Reviewed-by: Roland Scheidegger <[email protected]>
* glsl/standalone: Add the ability to generate ir_builder codeIan Romanick2016-11-103-0/+14
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: Add a C++ code generator that uses ir_builder to rebuild a programIan Romanick2016-11-103-0/+790
| | | | | | | | | | | | | This is only in libstandalone currently because it will only be used in the stand-alone compiler. v2: Change the signature of the generated function. The ir_factory is created in the generator, and an availability predicate is taken as a parameter. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Generate strings that are the enum names without the ir_*op_ prefixIan Romanick2016-11-102-0/+7
| | | | | | | | | | For many expressions, this is different from the printable name. The printable name for ir_binop_add is "+", but we want "add". This is needed for ir_builder_print_visitor. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/standalone: Enable par-linkingIan Romanick2016-11-104-2/+49
| | | | | | | | | | | | | | | | | | | | | | If the user did not request full linking, link the shader with the built-in functions, inline them, and eliminate them. Previous to this you'd see all these calls to "dot" and "max" in the output. This prevented a lot of expected optimizations and cluttered the output. This gives it some chance of being useful. v2: Rebase on top of Ken's "built-ins now" work. v3: Don't do_common_optimizations if par-linking fails. Update expected output of warnings tests to prevent 'make check' regressions. v4: Optimize harder. Most important, do function inlining. Otherwise it's quite impractical for one function in a file to call another function in the same file. v5: Add some code simplifications and an assertion suggested by Iago. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl/standalone: Optimize dead variable declarationsIan Romanick2016-11-101-0/+61
| | | | | | | | | | | | | We didn't bother with this in the regular compiler because it doesn't change the generated code. In the stand-alone compiler, this can clutter the output with useless variables. It's especially bad after functions are inlined but the foo_retval declarations remain. v2: Use set_foreach. Suggested by Tapani. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl/standalone: Optimize add-of-neg to subtractIan Romanick2016-11-104-0/+276
| | | | | | | | | | | | | This just makes the output of the standalone compiler a little more compact. v2: Fix indexing typo noticed by Iago. Move the add_neg_to_sub_visitor to it's own header file. Add a unit test that exercises the visitor. Both the neg_a_plus_b and neg_a_plus_neg_b tests reproduced the bug that Iago discovered. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/linker: Allow link_intrastage_shaders when there is no main()Ian Romanick2016-11-102-11/+26
| | | | | | | | This enables a sort of par-linking. The primary use for this feature is resolving built-in functions in the stand-alone compiler. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: update nir_gather_info to only mark used array/matrix elementsTimothy Arceri2016-11-111-53/+207
| | | | | | | | | | This is based on the code from the GLSL IR pass however unlike the GLSL IR pass it also supports arrays of arrays. As well as implementing the logic from the GLSL IR pass we add some additional intrinsic cases to catch more system values. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa/compiler: move MAX_VARYING to shader_enums.hKenneth Graunke2016-11-111-0/+1
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* nir: add more helpers to nir_types.cppTimothy Arceri2016-11-112-0/+21
| | | | | | These new helpers will be used in nir_gather_info.c in a following patch. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Generalize the "is per-vertex variable?" helpers and export them.Kenneth Graunke2016-11-112-18/+17
| | | | | | | | I want this function for nir_gather_info(), and realized it's basically the same as the ones in nir_lower_io(). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Parse 0 as a preprocessor INTCONSTANTIan Romanick2016-11-101-0/+4
| | | | | | | | | | | | | | | | | This allows a more reasonable error message for '#version 0' of 0:1(10): error: GLSL 0.00 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES instead of 0:1(10): error: syntax error, unexpected $undefined, expecting INTCONSTANT Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97420 Reviewed-by: Nicolai Hähnle <[email protected]> Cc: [email protected] Cc: Juan A. Suarez Romero <[email protected]> Cc: Karol Herbst <[email protected]>
* glcpp: Handle '#version 0' and other invalid valuesIan Romanick2016-11-102-6/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The #version directive can only handle decimal constants. Enforce that the value is a decimal constant. Section 3.3 (Preprocessor) of the GLSL 4.50 spec says: The language version a shader is written to is specified by #version number profile opt where number must be a version of the language, following the same convention as __VERSION__ above. The same section also says: __VERSION__ will substitute a decimal integer reflecting the version number of the OpenGL shading language. Use a separate flag to track whether or not the #version line has been encountered. Any possible sentinel (0 is currently used) could be specified in a #version directive. This would lead to trying to (internally) redefine __VERSION__. Since there is no parser location for this addition, NULL is passed. This eventually results in a NULL dereference and a segfault. Attempts to use -1 as the sentinel would also fail if '#version 4294967295' or '#version 18446744073709551615' were used. We should have piglit tests for both of these. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97420 Reviewed-by: Nicolai Hähnle <[email protected]> Cc: [email protected] Cc: Juan A. Suarez Romero <[email protected]> Cc: Karol Herbst <[email protected]>
* linker: Remove unnecessary overload of program_resource_visitor::visit_fieldIan Romanick2016-11-104-47/+15
| | | | | | | | | | | | | It looks like I added this version as a short-hand for users that didn't need the fuller version. I don't think there's any real utility in that. I'm not sure what my thinking was there. Maybe if those users overloaded the recursion function could just call the compact version to avoid passing some parameters? None of the users do that. Either way, having this extra overload is not useful. Delete it. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* mesa: remove LowerShaderSharedVariablesMarek Olšák2016-11-101-1/+1
| | | | | | always true for compute shaders Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: handle partial swizzles in opt_dead_code_local correctlyMarek Olšák2016-11-101-3/+6
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: don't run loop passes if loop unrolling is disabledMarek Olšák2016-11-101-5/+7
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: validate output blocks against input blocksIago Toral Quiroga2016-11-101-11/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now were validating in/out blocks by listing the inputs in the consumer stage and then, for each output of the producer, we checked that it was a match if it was consumed. This method does not catch the case where the consumer has an input that is not present as an output in the producer stage, because it only generates link errors for outputs present in the producer stage that don't match the inputs in the consumer stage. The current method does catch the case were an output from the producer stage is not consumed, which is irrelevant and is ignored. By reversing the way we do this, we can detect this situation, so this patch lists the outputs of the producer stage and then validates inputs of the consumer stage against them. If we see an input in the consumer for which there is no associated output in the producer, we produce a link error. The only exception to this is the special built-in input block gl_in[], since this is implicitly generated for geometry and tessellation stages, but we don't generate it if the producer stage does not write to any of the pre-defined outputs (for example, if the vertex shader does not write to gl_Position, etc). Since writing to these is not mandatory, do not produce a link error in that case. There is a CTS tessellation test (GL45-CTS.tessellation_shader.program_object_properties) that has an empty vertex shader (so it does not produce gl_in[]) and would fail to link if we don't do this. This fixes the following dEQP test: dEQP-GLES31.functional.shaders.linkage.io_block.missing_output_block Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98245 Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: record number of components used in each slot for varying packingIlia Mirkin2016-11-093-9/+32
| | | | | | | | | | | | | | Instead of packing varyings into vec4's, keep track of how many components each slot uses and create varyings with matching types. This ensures that we don't end up using more components than the orginal shader, which is especially important for geometry shader output limits. This comes up for NVIDIA hw, where the limit is 1024 output components for a GS, and the hardware complains *loudly* if you even think about going over. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: fix slot_end calculations and simplify reserved_slots checkIlia Mirkin2016-11-091-26/+20
| | | | | | | | | | | The previous code was confused about whether slot_end was inclusive or exclusive. Make it so that it is inclusive consistently, and use it for setting the new location. This also avoids discrepancies in how num_components is calculated vs the more manual approach taken for the former reserved_slots check. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* linker: Accurately track gl_uniform_block::stagerefIan Romanick2016-11-092-9/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As the linked per-stage shaders are processed, mark any block that has a field that is accessed as referenced. When combining all the linked shaders, combine the per-stage stageref masks. This fixes a number of GLES CTS tests: ES31-CTS.core.geometry_shader.program_resource.program_resource ES32-CTS.core.geometry_shader.program_resource.program_resource ESEXT-CTS.geometry_shader.program_resource.program_resource piglit.gl45-cts.geometry_shader.program_resource.program_resource However, it makes quite a few more fail: ES31-CTS.functional.program_interface_query.buffer_variable.random.6 ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.compute.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.separable_fragment.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment_only_fragment.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment_only_fragment.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment_only_fragment.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment_only_fragment.unnamed_block.float ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.random.6 ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.compute.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.separable_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment_only_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment_only_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment_only_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment_only_fragment.unnamed_block.float ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment.unnamed_block.float I have diagnosed the failures, but I'm not sure whether we or the tests are wrong. After optimizations are applied, all of the tests are of the form: buffer X { float f; } x; void main() { x.f = x.f; } The test then queries that x is referenced by that shader stage. We eliminate the assignment of x.f to itself, and that removes the last reference to x. We report that x is not referenced, and the test fails. I do not know whether or not we are allowed to eliminate that assignment of x.f to itself. After discussions with the OpenGL ES group in Khronos, we believe that Mesa's behavior is correct. I will provide patches to the CTS tests to Khronos. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* linker: Slight code rearrange to prevent duplication in the next commitIan Romanick2016-11-091-7/+6
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* linker: Trivial coding standards fixesIan Romanick2016-11-091-15/+13
| | | | | | | | | v2: Revert the unreachable to assert in parcel_out_uniform_storage::visit_field. Suggested by Ilia. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Add some comments to methods of ir_variable_refcount_visitorIan Romanick2016-11-091-0/+6
| | | | | | | | | | It was not obvious from the just the .h file what the hash table contained. It was also not obvious that get_variable_entry would create a new entry in the hash table. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* nir: add conditional discard optimisation (v4)Dave Airlie2016-11-103-0/+128
| | | | | | | | | | | | | | | | | | | | | | | This is ported from GLSL and converts if (cond) discard; into discard_if(cond); This removes a block, but also is needed by radv to workaround a bug in the LLVM backend. v2: handle if (a) discard_if(b) (nha) cleanup and drop pointless loop (Matt) make sure there are no dependent phis (Eric) v3: make sure only one instruction in the then block. v4: remove sneaky tabs, add cursor init (Eric) Reviewed-by: Eric Anholt <[email protected]> Cc: "13.0" <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/cache: correct asprintf error handlingNicolai Hähnle2016-11-041-3/+3
| | | | | | | | | | | From the manpage of asprintf: "If memory allocation wasn't possible, or some other error occurs, these functions will return -1, and the contents of strp are undefined." Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* nir: Make sure to set the texsrc type in nir drawpixels/bitmap lowering.Eric Anholt2016-11-032-0/+4
| | | | | | | | | We were leaving an undefined value since the ralloc zeroing changes. Fixes nir_validate() failures on vc4. v2: Fix the color-index case of drawpixels as well. Reviewed-by: Rob Clark <[email protected]> (v1)
* nir: Flip gl_SamplePosition in nir_lower_wpos_ytransform().Francisco Jerez2016-11-031-0/+24
| | | | | | | | | | | | | | | | | | Assuming the hardware is set up to use a screen coordinate system flipped vertically with respect to the GL's window coordinate system, the SYSTEM_VALUE_SAMPLE_POS vector will also be flipped vertically with respect to the value expected by the GL, so we need to give it the same treatment as gl_FragCoord. Fixes the following CTS tests on i965: ES31-CTS.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.default_framebuffer ES31-CTS.functional.shaders.sample_variables.sample_pos.correctness.default_framebuffer when run with any multisample configuration, e.g. rgba8888d24s8ms4. Cc: <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: fix lowering of UBO references of named blocksNicolai Hähnle2016-11-031-5/+5
| | | | | | | | | | | | | | When a UBO reference has the form block_name.foo where block_name refers to a block where the first member has a non-zero offset, the base offset was incorrectly added to the reference. Fixes an assertion triggered in debug builds by GL45-CTS.enhanced_layouts.uniform_block_layout_qualifier_conflict. That test doesn't properly check for correct execution in this case, so I am also going to send out a piglit test. Cc: 13.0 <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: Update deref types when resizing implicitly sized arrays.Kenneth Graunke2016-11-031-23/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | At link time, we resolve the size of implicitly sized arrays. When doing so, we update the type of the ir_variables. However, we neglected to update the type of ir_dereference nodes which reference those variables. It turns out array_resize_visitor (for GS/TCS/TES interface array handling) already did 2/3 of the cases for this, so we can simply refactor the code and reuse it. This fixes: GL45-CTS.shader_storage_buffer_object.basic-syntax GL45-CTS.shader_storage_buffer_object.basic-syntaxSSO which have an SSBO containing an implicitly sized array, followed by some other members. setup_buffer_access uses the dereference types to compute offsets to fields, and it had a stale type where the implicitly sized array's length was still 0 instead of the actual length. While we're here, we can also fix update_array_sizes to properly update deref types as well, fixing a FINISHME from 2010. Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa/glsl: delete previously linked shaders earlier when linkingTimothy Arceri2016-11-034-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This moves the delete linked shaders call to _mesa_clear_shader_program_data() which makes sure we delete them before returning due to any validation problems. It also reduces some code duplication. From the OpenGL 4.5 Core spec: "If LinkProgram failed, any information about a previous link of that program object is lost. Thus, a failed link does not restore the old state of program. ... If one of these commands is called with a program for which LinkProgram failed, no error is generated unless otherwise noted. Implementations may return information on variables and interface blocks that would have been active had the program been linked successfully. In cases where the link failed because the program required too many resources, these commands may help applications determine why limits were exceeded." Therefore it's expected that we shouldn't be able to query the program that failed to link and retrieve information about a previously successful link. Before this change the linker was doing validation before freeing the previously linked shaders and therefore could exit on failure before they were freed. This change also fixes an issue in compat profile where a program with no shaders attached is expect to fall back to fixed function but was instead trying to relink IR from a previous link. Reviewed-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97715 Cc: "13.0" <[email protected]>
* nir: fix nir_shader_clone() and nir_sweep()Timothy Arceri2016-11-032-1/+9
| | | | | | | | | | These were broken in e1af20f18a8 when the info field in nir_shader was turned into a pointer. Clone was copying the pointer rather than the data and nir_sweep was cleaning up shader_info rather than claiming it. Reviewed-by: Eric Anholt <[email protected]>
* glsl: compute lvalues of [in]out parameters before inlined function bodyNicolai Hähnle2016-11-021-10/+81
| | | | | | | | | | | | | | | This is required when an out argument involves an array index that is either a global variable modified by the function or another out argument in the same function call. Fixes the shaders/out-parameter-indexing/vs-inout-index-inout-* tests. v2: - modify the ir_dereference_array nodes in place - use ir_hierarchical_visitor v3: use base_ir (Ian Romanick) Reviewed-by: Ian Romanick <[email protected]>
* glsl: use a non-malloc'd storage for short ir_variable namesMarek Olšák2016-10-313-3/+22
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_constant_propagationMarek Olšák2016-10-311-3/+11
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_copy_propagationMarek Olšák2016-10-311-1/+6
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_copy_propagation_elementsMarek Olšák2016-10-311-4/+11
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in opt_dead_code_localMarek Olšák2016-10-311-3/+9
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator in glsl_symbol_tableMarek Olšák2016-10-311-8/+8
| | | | | | | no ralloc_free occurences Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the linear allocator for ast_node and derived classesMarek Olšák2016-10-316-113/+114
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/lexer: use the linear allocatorMarek Olšák2016-10-313-8/+12
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glcpp: use the linear allocator for most objectsMarek Olšák2016-10-313-118/+91
| | | | | | | v2: cosmetic changes Tested-by: Edmondo Tommasina <[email protected]> (v1) Reviewed-by: Nicolai Hähnle <[email protected]> (v1)
* ralloc: use rzalloc where it's necessaryMarek Olšák2016-10-317-10/+13
| | | | | | | | | | | | | | | | | No change in behavior. ralloc_size is equivalent to rzalloc_size. That will change though. Calls not switched to rzalloc_size: - ralloc_vasprintf - glsl_type::name allocation (it's filled with snprintf) - C++ classes where valgrind didn't show uninitialized values I switched most of non-glsl stuff to rzalloc without checking whether it's really needed. Reviewed-by: Edward O'Callaghan <[email protected]> Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* nir: zero allocated memory where neededJuha-Pekka Heikkila2016-10-316-7/+7
| | | | Signed-off-by: Marek Olšák <[email protected]>
* glsl/glcpp: initialize all fields of glcpp_parser_t on creationTapani Pälli2016-10-311-0/+3
| | | | | | | | this fixes some of the regressions with "ralloc: remove memset from ralloc_size" Signed-off-by: Tapani Pälli <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl: Fix reading of uninitialized memoryJuha-Pekka Heikkila2016-10-312-4/+4
| | | | | | | | | | Switch to use memory allocations which zero memory for places where needed. v2: modify and rebase on top of Marek's series (Tapani) Signed-off-by: Juha-Pekka Heikkila <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl: initialize glsl_struct_field properlyMarek Olšák2016-10-312-38/+6
| | | | | | | | | don't rely on ralloc doing memset Reviewed-by: Edward O'Callaghan <[email protected]> Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Improve accuracy of alpha scaling in advanced blend lowering.Kenneth Graunke2016-10-281-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When blending with GL_COLORBURN_KHR and these colors: dst = <0.372549027, 0.372549027, 0.372549027, 0.372549027> src = <0.09375, 0.046875, 0.0, 0.375> the normalized dst value became 0.99999994 (due to precision problems in the floating point divide of rgb by alpha). This caused the color burn equation to fail the dst >= 1.0 comparison. The blue channel would then fall through to the dst < 1.0 && src >= 0 comparison, which was true, since src.b == 0. This produced a factor of 0.0 instead of 1.0. This is an inherent numerical instability in the color burn and dodge equations - depending on the precision of alpha scaling, the value can be either 0.0 or 1.0. Technically, GLSL floating point division doesn't even guarantee that 0.372549027 / 0.372549027 = 1.0. So arguably, the CTS should allow either value. I've filed a bug at Khronos for further discussion (linked below). In the meantime, this patch improves the precision of alpha scaling by replacing the division with (rgb == alpha ? 1.0 : rgb / alpha). We may not need this long term, but for now, it fixes the following CTS tests: ES31-CTS.blend_equation_advanced.blend_specific.GL_COLORBURN_KHR ES31-CTS.blend_equation_advanced.blend_all.GL_COLORBURN_KHR_all_qualifier Cc: [email protected] Cc: [email protected] Bugzilla: https://cvs.khronos.org/bugzilla/show_bug.cgi?id=16042 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>