Files
third_party_mesa3d/src/compiler/glsl/meson.build

270 lines
7.9 KiB
Meson
Raw Normal View History

# Copyright © 2017 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
subdir('glcpp')
bison_command = []
if yacc_is_bison
bison_command = [
prog_bison, '-o', '@OUTPUT0@', '-p', '_mesa_glsl_', '--defines=@OUTPUT1@',
'@INPUT@',
]
else
bison_command = [
prog_bison, '-o', '@OUTPUT0@', '-p', '_mesa_glsl_', '-H', '@OUTPUT1@',
'@INPUT@',
]
endif
glsl_parser = custom_target(
'glsl_parser',
input : 'glsl_parser.yy',
output : ['glsl_parser.cpp', 'glsl_parser.h'],
command : bison_command
)
glsl_lexer_cpp = custom_target(
'glsl_lexer_cpp',
input : 'glsl_lexer.ll',
output : 'glsl_lexer.cpp',
command : [prog_flex_cpp, '-o', '@OUTPUT@', '@INPUT@'],
)
ir_expression_operation_constant_h = custom_target(
'ir_expression_operation_constant.h',
input : 'ir_expression_operation.py',
output : 'ir_expression_operation_constant.h',
command : [prog_python, '@INPUT@', 'constant'],
capture : true,
)
ir_expression_operation_strings_h = custom_target(
'ir_expression_operation_strings.h',
input : 'ir_expression_operation.py',
output : 'ir_expression_operation_strings.h',
command : [prog_python, '@INPUT@', 'strings'],
capture : true,
)
float64_glsl_h = custom_target(
'float64_glsl.h',
input : [files_xxd, 'float64.glsl'],
output : 'float64_glsl.h',
command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'float64_source'],
)
files_libglsl = files(
'ast.h',
'ast_array_index.cpp',
'ast_expr.cpp',
'ast_function.cpp',
'ast_to_hir.cpp',
'ast_type.cpp',
'builtin_functions.cpp',
'builtin_functions.h',
'builtin_int64.h',
'builtin_types.cpp',
'builtin_variables.cpp',
'generate_ir.cpp',
'gl_nir_lower_atomics.c',
'gl_nir_lower_images.c',
'gl_nir_lower_buffers.c',
'gl_nir_lower_packed_varyings.c',
'gl_nir_lower_samplers.c',
'gl_nir_lower_samplers_as_deref.c',
'gl_nir_lower_xfb_varying.c',
'gl_nir_link_atomics.c',
nir/linker: add gl_nir_link_uniform_blocks.c Adding the ability to link uniform blocks and shader storage blocks using NIR, intended for ARB_gl_spirv support. Among other things, this linking needs to take into account that everything should work without names, as they could be not present, while the GLSL IR uniform block linking was wrote with the names on its core. The other major difference compared with the GLSL IR linker is that we don't deal with layouts. There are no references to std140, std430, etc. Layouts are expressed through explicit offset, array stride and matrix stride. That simplifies how the buffer size are computed. But also means that we couldn't use the existing methods at glsl_types, so we needed to implement new methods. It is worth to note that this linking do a iteration over the glsl_types, similarly to what the linking uniforms do. A possible future improvement would be refactor both cases to try to share more code that it sharing right now. On GLSL IR there are a class visitor, specialized on each case, for that sharing. As adding a class visitor on C would more complicated, for now we are just iterating on both. Signed-off-by: Alejandro Piñeiro <apinheiro@igalia.com> Signed-off-by: Neil Roberts <nroberts@igalia.com> Signed-off-by: Antia Puentes <apuentes@igalia.com> v2: (from Timothy review) * Fix variable name convention * Stop to use _function_name convention * Don't use // for comments * "nir/linker: Keep track of the stages referencing an UBO/SSBO" squashed with this patch v3: (from Caio review) * Don't delete the linked shader on failure * Use rzalloc_array to avoid some explicit initializations Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
2017-11-30 12:01:52 +01:00
'gl_nir_link_uniform_blocks.c',
'gl_nir_link_uniform_initializers.c',
'gl_nir_link_uniforms.c',
'gl_nir_link_varyings.c',
'gl_nir_link_varyings.h',
'gl_nir_link_xfb.c',
'gl_nir_linker.c',
'gl_nir_linker.h',
'gl_nir_opt_dead_builtin_varyings.c',
'gl_nir.h',
'glsl_parser_extras.cpp',
'glsl_parser_extras.h',
'glsl_symbol_table.cpp',
'glsl_symbol_table.h',
'glsl_to_nir.cpp',
'glsl_to_nir.h',
'hir_field_selection.cpp',
'ir_array_refcount.cpp',
'ir_array_refcount.h',
'ir_basic_block.cpp',
'ir_basic_block.h',
'ir_builder.cpp',
'ir_builder.h',
'ir_clone.cpp',
'ir_constant_expression.cpp',
'ir.cpp',
'ir.h',
'ir_equals.cpp',
'ir_expression_flattening.cpp',
'ir_expression_flattening.h',
'ir_function_can_inline.cpp',
'ir_function_detect_recursion.cpp',
'ir_function_inlining.h',
'ir_function.cpp',
'ir_hierarchical_visitor.cpp',
'ir_hierarchical_visitor.h',
'ir_hv_accept.cpp',
'ir_optimization.h',
'ir_print_visitor.cpp',
'ir_print_visitor.h',
'ir_reader.cpp',
'ir_reader.h',
'ir_rvalue_visitor.cpp',
'ir_rvalue_visitor.h',
'ir_uniform.h',
'ir_validate.cpp',
'ir_variable_refcount.cpp',
'ir_variable_refcount.h',
'ir_visitor.h',
'linker.cpp',
'linker.h',
'linker_util.h',
'linker_util.cpp',
'link_functions.cpp',
'link_interface_blocks.cpp',
'link_uniforms.cpp',
'link_uniform_block_active_visitor.cpp',
'link_uniform_block_active_visitor.h',
'link_uniform_blocks.cpp',
'link_varyings.cpp',
'link_varyings.h',
'list.h',
'lower_blend_equation_advanced.cpp',
'lower_builtins.cpp',
'lower_discard.cpp',
'lower_discard_flow.cpp',
'lower_distance.cpp',
'lower_instructions.cpp',
'lower_int64.cpp',
'lower_jumps.cpp',
'lower_mat_op_to_vec.cpp',
'lower_named_interface_blocks.cpp',
'lower_packing_builtins.cpp',
glsl: Add an IR lowering pass to convert mediump operations to 16-bit This works by finding the first rvalue that it can lower using an ir_rvalue_visitor. In that case it adds a conversion to float16 after each rvalue and a conversion back to float before storing the assignment. Also it uses a set to keep track of rvalues that have been lowred already. The handle_rvalue method of the rvalue visitor doesn’t provide any way to stop iteration. If we handle a value in find_precision_visitor we want to be able to stop it from descending into the lowered rvalue again. Additionally this pass disallows converting nodes containing non-float. The can_lower_rvalue function explicitly excludes any branches that have non-float types except bools. This avoids the need to have special handling for functions that convert to int or double. Co-authored-by: Hyunjun Ko <zzoon@igalia.com> v2. Adds lowering for texture samples v3. Instead of checking whether each node can be lowered while walking the tree, a separate tree walk is now done to check all of the nodes in a single pass. The lowerable nodes are added to a set which is checked during find_precision_visitor instead of calling can_lower_rvalue. v4. Move the special case for temporaries to find_lowerable_rvalues. This needs to be handled while checking for lowerable rvalues so that any later dereferences of the variable will see the right precision. v5. Add an override to visit ir_call instructions and apply the same technique to override the precision of the temporary variable in the same way as done for builtin temporaries and ir_assignment calls. v6. Changes the pass so that it doesn’t need to lower an entire subtree in order do perform a lowering. Instead, certain instructions can be marked as being indepedent of their child instructions. For example, this is the case with array dereferences. The precision of the array index doesn’t have any bearing on whether things using the result of the array deref can be lowered. Now, only toplevel lowerable nodes are added to the lowerable_rvalues instead instead of additionally adding all of the subnodes. It now also only needs one hash table instead of two. v7. Don’t try to lower sampler types. Instead, the sample instruction is now treated as an independent point where the result of the sample can be used in a lowered section. The precision of the sampler type determines the precision of the sample instruction. This also means the coordinates to the sampler can be lowered. v8. Use f2fmp instead of f2f16. v9. Disable lowering derivatives calcualtions, which might not work properly on some hw backends. Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
2019-04-19 15:36:58 +02:00
'lower_precision.cpp',
'lower_subroutine.cpp',
'lower_tess_level.cpp',
'lower_vec_index_to_cond_assign.cpp',
'lower_vec_index_to_swizzle.cpp',
'lower_vector_derefs.cpp',
'lower_vector_insert.cpp',
'opt_algebraic.cpp',
'opt_array_splitting.cpp',
'opt_constant_folding.cpp',
'opt_constant_propagation.cpp',
'opt_constant_variable.cpp',
'opt_copy_propagation_elements.cpp',
'opt_dead_builtin_variables.cpp',
'opt_dead_code.cpp',
'opt_dead_code_local.cpp',
'opt_dead_functions.cpp',
'opt_flatten_nested_if_blocks.cpp',
'opt_flip_matrices.cpp',
'opt_function_inlining.cpp',
'opt_if_simplification.cpp',
'opt_minmax.cpp',
'opt_rebalance_tree.cpp',
'opt_structure_splitting.cpp',
'opt_tree_grafting.cpp',
'program.h',
'propagate_invariance.cpp',
's_expression.cpp',
's_expression.h',
'string_to_uint_map.cpp',
'string_to_uint_map.h',
'serialize.cpp',
'serialize.h',
'shader_cache.cpp',
'shader_cache.h',
)
files_libglsl_standalone = files(
'ir_builder_print_visitor.cpp',
'ir_builder_print_visitor.h',
'opt_add_neg_to_sub.h',
'standalone_scaffolding.cpp',
'standalone_scaffolding.h',
'standalone.cpp',
'standalone.h',
)
libglsl = static_library(
'glsl',
[files_libglsl, glsl_parser, glsl_lexer_cpp, ir_expression_operation_h,
ir_expression_operation_strings_h, ir_expression_operation_constant_h,
float64_glsl_h],
c_args : [c_msvc_compat_args, no_override_init_args],
cpp_args : [cpp_msvc_compat_args],
gnu_symbol_visibility : 'hidden',
link_with : libglcpp,
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_compiler],
dependencies : idep_nir,
build_by_default : false,
)
libglsl_standalone = static_library(
'glsl_standalone',
[files_libglsl_standalone, ir_expression_operation_h],
c_args : [c_msvc_compat_args, no_override_init_args],
cpp_args : [cpp_msvc_compat_args],
gnu_symbol_visibility : 'hidden',
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
link_with : [libglsl, libglsl_util, libglcpp_standalone],
dependencies : [idep_mesautil, idep_getopt],
build_by_default : false,
)
glsl_compiler = executable(
'glsl_compiler',
'main.cpp',
c_args : [c_msvc_compat_args, no_override_init_args],
cpp_args : [cpp_msvc_compat_args],
gnu_symbol_visibility : 'hidden',
dependencies : [dep_clock, dep_thread, idep_getopt, idep_mesautil],
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
link_with : [libglsl_standalone],
build_by_default : with_tools.contains('glsl'),
install : with_tools.contains('glsl'),
)
glsl_test = executable(
'glsl_test',
['test.cpp', 'test_optpass.cpp', 'test_optpass.h',
ir_expression_operation_h],
c_args : [c_msvc_compat_args, no_override_init_args],
cpp_args : [cpp_msvc_compat_args],
gnu_symbol_visibility : 'hidden',
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
dependencies : [dep_clock, dep_thread, idep_getopt, idep_mesautil],
link_with : [libglsl, libglsl_standalone, libglsl_util],
build_by_default : with_tools.contains('glsl'),
install : with_tools.contains('glsl'),
)
if with_any_opengl and with_tests
subdir('tests')
endif