summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* spirv: Stop warning about input attachmentsJason Ekstrand2016-11-221-1/+1
| | | | | Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* spirv: Handle the InputAttachmentIndex decorationJason Ekstrand2016-11-222-0/+5
| | | | | Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler: Add the rest of the subpassInput typesJason Ekstrand2016-11-223-6/+22
| | | | | | | There are actually 6 of them according to the GL_KHR_vulkan_glsl spec. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: add gl_linked_shader::SourceChecksumMarek Olšák2016-11-221-0/+10
| | | | | | | | for debugging v2: wrap all checksums in #ifdef DEBUG Reviewed-by: Timothy Arceri <[email protected]>
* mesa/glsl: remove unused uses_builtin_functions fieldTimothy Arceri2016-11-231-1/+0
| | | | | | This has been unused since 943b69cddd Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* spirv: Silence unsupported capability warnings for Clip/CullDistance.Kenneth Graunke2016-11-221-2/+2
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: add a pass to compact clip/cull distances.Kenneth Graunke2016-11-223-0/+190
| | | | | | | v2: Use nir_is_per_vertex_io() rather than is_arrays_of_arrays(). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add a "compact array" flag and IO lowering code.Kenneth Graunke2016-11-227-18/+67
| | | | | | | | | | | | | | | | | | | | Certain built-in arrays, such as gl_ClipDistance[], gl_CullDistance[], gl_TessLevelInner[], and gl_TessLevelOuter[] are specified as scalar arrays. Normal scalar arrays are sparse - each array element usually occupies a whole vec4 slot. However, most hardware assumes these built-in arrays are tightly packed. The new var->data.compact flag indicates that a scalar array should be tightly packed, so a float[4] array would take up a single vec4 slot, and a float[8] array would take up two slots. They are still arrays, not vec4s, however. nir_lower_io will generate intrinsics using ARB_enhanced_layouts style component qualifiers. v2: Add nir_validate code to enforce type restrictions. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: fix NULL checkTimothy Arceri2016-11-221-1/+1
| | | | Fixes copy and paste error in 9d96d3803ab
* glsl/lower_output_reads: remove unused mem_ctxNicolai Hähnle2016-11-211-4/+0
| | | | | Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl/lower_output_reads: bail early in tessellation control shadersNicolai Hähnle2016-11-211-2/+6
| | | | | | | | This whole pass is a no-op. Acked-by: Edward O'Callaghan <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl/lower_output_reads: fix geometry shader output handling with ↵Nicolai Hähnle2016-11-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | conditional emit Consider a geometry shader that contains code like this: some_out = expr; if (cond) { ... EmitVertex(); } else { ... EmitVertex(); } Both branches should see the correct value of some_out. Since this is a rather subtle and rare case, I'm submitting a piglit test for this as well. GLSL says that the values of output variables are undefined after EmitVertex(). With this change, the values will now be defined and unmodified. This may reduce optimization opportunities in the probably quite rare case where subsequent compiler passes cannot prove that the value of the output variable is overwritten. Cc: 13.0 <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl: don't flatten if-blocks with dynamic array indicesNicolai Hähnle2016-11-211-2/+17
| | | | | | | | | This fixes the regression of radeonsi in glsl-1.10/execution/variable-indexing/vs-output-array-vec3-index-wr caused by commit 74e39de9324d2d2333cda6adca50ae2a3fc36de2. Acked-by: Edward O'Callaghan <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* nir: Add a C wrapper for glsl_type::is_array_of_arrays().Kenneth Graunke2016-11-192-0/+7
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* compiler: Store the clip/cull distance array sizes in shader_info.Kenneth Graunke2016-11-192-4/+7
| | | | | | | We switched from a boolean to array lengths in gl_program a while back. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* st/mesa/glsl/nir/i965: make use of new gl_shader_program_data in ↵Timothy Arceri2016-11-199-164/+176
| | | | | | gl_shader_program Reviewed-by: Emil Velikov <[email protected]>
* glsl: add new program driver function to standalone compilerTimothy Arceri2016-11-191-18/+43
| | | | | | | | | | | This fixes a regression with the standalone compiler caused by 9d96d3803ab5dc Note that we change standalone_compiler_cleanup() to no longer explicitly free the linked shaders as the will be freed when we free the parent ctx whole_program. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98774
* glsl: tidy up entries temporaryTimothy Arceri2016-11-191-6/+8
| | | | | | | Here we just move initialisation of entries to where it is needed i.e. outside the loop and after the continue checks. Reviewed-by: Emil Velikov <[email protected]>
* glsl/i965: move per stage AtomicBuffers list to gl_programTimothy Arceri2016-11-191-4/+4
| | | | Reviewed-by: Emil Velikov <[email protected]>
* glsl: create gl_program at the start of linking rather than the endTimothy Arceri2016-11-191-0/+16
| | | | | | | | | | | | | | | | | | This will allow us to directly store metadata we want to retain in gl_program this metadata is currently stored in gl_linked_shader and will be lost if relinking fails even though the program will remain in use and is still valid according to the spec. "If a program object that is active for any shader stage is re-linked unsuccessfully, the link status will be set to FALSE, but any existing executables and associated state will remain part of the current rendering state until a subsequent call to UseProgram, UseProgramStages, or BindProgramPipeline removes them from use." This change will also help avoid the double handing that happens in _mesa_copy_linked_program_data(). Reviewed-by: Emil Velikov <[email protected]>
* mesa: add NV_image_formats extension supportLionel Landwerlin2016-11-183-41/+49
| | | | | | | | | | | | | | | This extension can be enabled automatically as it is a subset of ARB_shader_image_load_store. v2: Replace helper function by qualifier struct field (Ilia) Enable NV_image_formats using ARB_shader_image_load_store (Ilia) v3: Drop extension field from gl_extensions (Ilia) Release notes (Ilia) Signed-off-by: Lionel Landwerlin <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98480 Reviewed-by: Ilia Mirkin <[email protected]>
* nir/spirv: Fix handling of gl_PrimitiveIdJason Ekstrand2016-11-161-2/+6
| | | | | | | | | | Before, we were always treating it as an output which bogus. The only stage in which this it can be an output is the geometry stage. In all other stages, it's an input which, in the back-end, we actually want to be a system value. Cc: "13.0" <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* nir: Avoid an extra NIR op in integer divide lowering.Eric Anholt2016-11-161-2/+1
| | | | | | NIR bools are ~0 for true, so ((unsigned)a >> 31) != 0 -> ((int)a >> 31). Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: stub out _mesa_reference_program() in standalone compilerTimothy Arceri2016-11-172-0/+12
| | | | | The follow patch will call this directly from the linker, the shader cache will also start calling these from the compiler.
* mesa/glsl: copy num_abos to gl_programTimothy Arceri2016-11-171-1/+0
| | | | | | | We should be able to free gl_linked_shader after linking in order to do so we need to switch to getting values from gl_program instead. Reviewed-by: Emil Velikov <[email protected]>
* mesa/glsl: copy num_images to gl_programTimothy Arceri2016-11-171-1/+0
| | | | | | | We should be able to free gl_linked_shader after linking in order to do so we need to switch to getting values from gl_program instead. Reviewed-by: Emil Velikov <[email protected]>
* nir: add support for counting AoA uniforms in nir_shader_gather_info()Timothy Arceri2016-11-171-2/+2
| | | | Reviewed-by: Emil Velikov <[email protected]>
* compiler: remove now unused copy_shader_info() declarationTimothy Arceri2016-11-171-7/+0
| | | | | | Left over from 4ac66861 Reviewed-by: Jason Ekstrand <[email protected]>
* compiler: include shader_enums.h in shader_info.hTimothy Arceri2016-11-171-0/+2
| | | | | | We make use of some enums here. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl/lower_if: conditionally lower if-branches based on their sizeMarek Olšák2016-11-152-7/+50
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/lower_if: don't lower branches touching tess control outputsMarek Olšák2016-11-153-5/+23
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/lower_if: check more node types in check_control_flow -> check_ir_nodeMarek Olšák2016-11-151-3/+6
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/lower_if: move and rename found_control_flowMarek Olšák2016-11-151-7/+10
| | | | | | | I'll want to update more variables in check_control_flow, so using the visitor is convenient. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: use unambiguous namingMarek Olšák2016-11-151-70/+70
| | | | Reviewed-by: Emil Velikov <[email protected]>
* util: import cache.c/h from glslMarek Olšák2016-11-155-916/+1
| | | | | | | | | | It's not dependent on GLSL and it can be useful for shader caches that don't deal with GLSL. v2: address review comments v3: keep the other 3 lines in configure.ac Reviewed-by: Emil Velikov <[email protected]>
* glsl: Don't crash on function names with invalid identifiers.Kenneth Graunke2016-11-121-2/+4
| | | | | | | | | | | | | | | | Karol Herbst's fuzzing efforts noticed that we would segfault on: void bug() { 2(0); } We just need to bail if the function name isn't an identifier. Based on a bug fix by Karol Herbst. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97422 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Fix assert fails when assignment expressions are in array sizes.Kenneth Graunke2016-11-121-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Karol Herbst's fuzzing efforts discovered that we would hit the following assert: assert(dummy_instructions.is_empty()); when processing an illegal array size expression of float[(1=1)?1:1] t; In do_assignment, we realized we needed an rvalue for (1 = 1), and generated a temporary variable and assignment from the RHS. We've already flagged an error (non-lvalue in assignment), and return a bogus value as the rvalue. But process_array_size sees the bogus value, which happened to be a constant expression, and rightly assumes that processing a constant expression shouldn't have generated any code. instructions. To handle this, make do_assignment not generate any temps or assignments when it's already raised an error - just return an error value directly. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98694 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: define __STDC_FORMAT_MACROS to get PRIx64 macroBrian Paul2016-11-111-0/+1
| | | | | | | Otherwise, inttypes.h may not define the macro for C++ on MinGW. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98681 Reviewed-by: Emil Velikov <[email protected]>
* glsl: automake: add opt_add_neg_to_sub.h to the sources listEmil Velikov2016-11-111-0/+1
| | | | | | Otherwise it'll be missing in the release tarball. Signed-off-by: Emil Velikov <[email protected]>
* 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]>