2017-09-14 17:57:17 -07:00
|
|
|
# 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.
|
|
|
|
|
2017-09-20 20:11:32 -07:00
|
|
|
subdir('glcpp')
|
2017-09-14 17:57:17 -07:00
|
|
|
|
2021-01-27 14:16:08 +00:00
|
|
|
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
|
|
|
|
|
2017-09-20 20:11:32 -07:00
|
|
|
glsl_parser = custom_target(
|
|
|
|
'glsl_parser',
|
|
|
|
input : 'glsl_parser.yy',
|
|
|
|
output : ['glsl_parser.cpp', 'glsl_parser.h'],
|
2021-01-27 14:16:08 +00:00
|
|
|
command : bison_command
|
2017-09-20 20:11:32 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
glsl_lexer_cpp = custom_target(
|
|
|
|
'glsl_lexer_cpp',
|
|
|
|
input : 'glsl_lexer.ll',
|
|
|
|
output : 'glsl_lexer.cpp',
|
2021-04-12 15:09:57 -07:00
|
|
|
command : [prog_flex_cpp, '-o', '@OUTPUT@', '@INPUT@'],
|
2017-09-20 20:11:32 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
ir_expression_operation_constant_h = custom_target(
|
|
|
|
'ir_expression_operation_constant.h',
|
2017-09-14 17:57:17 -07:00
|
|
|
input : 'ir_expression_operation.py',
|
2017-09-20 20:11:32 -07:00
|
|
|
output : 'ir_expression_operation_constant.h',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@', 'constant'],
|
2017-09-14 17:57:17 -07:00
|
|
|
capture : true,
|
|
|
|
)
|
2017-09-20 20:11:32 -07:00
|
|
|
|
|
|
|
ir_expression_operation_strings_h = custom_target(
|
|
|
|
'ir_expression_operation_strings.h',
|
|
|
|
input : 'ir_expression_operation.py',
|
|
|
|
output : 'ir_expression_operation_strings.h',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@', 'strings'],
|
2017-09-20 20:11:32 -07:00
|
|
|
capture : true,
|
|
|
|
)
|
|
|
|
|
2018-11-15 10:18:12 -08:00
|
|
|
float64_glsl_h = custom_target(
|
|
|
|
'float64_glsl.h',
|
2020-03-31 14:05:59 -07:00
|
|
|
input : [files_xxd, 'float64.glsl'],
|
2018-11-15 10:18:12 -08:00
|
|
|
output : 'float64_glsl.h',
|
|
|
|
command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'float64_source'],
|
|
|
|
)
|
|
|
|
|
2017-09-20 20:11:32 -07:00
|
|
|
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',
|
2018-04-30 20:39:43 +10:00
|
|
|
'gl_nir_lower_atomics.c',
|
2020-01-23 10:42:15 -08:00
|
|
|
'gl_nir_lower_images.c',
|
2019-03-09 10:12:46 -06:00
|
|
|
'gl_nir_lower_buffers.c',
|
2021-11-23 12:43:18 +11:00
|
|
|
'gl_nir_lower_packed_varyings.c',
|
2018-04-30 20:39:43 +10:00
|
|
|
'gl_nir_lower_samplers.c',
|
|
|
|
'gl_nir_lower_samplers_as_deref.c',
|
2017-11-28 13:39:44 +01:00
|
|
|
'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',
|
2018-02-23 17:09:22 +01:00
|
|
|
'gl_nir_link_uniform_initializers.c',
|
nir/linker: Add gl_nir_link_uniforms()
This function will be the entry point for linking the uniforms from
the nir_shader objects associated with the gl_linked_shaders of a
program.
This patch includes initial support for linking uniforms from NIR
shaders. It is tailored for the ARB_gl_spirv needs, and it is far from
complete, but it should handle most cases of uniforms, array
uniforms, structs, samplers and images.
There are some FIXMEs related to specific features that will be
implemented in following patches, like atomic counters, UBOs and
SSBOs.
Also, note that ARB_gl_spirv makes mandatory explicit location for
normal uniforms, so this code only handles uniforms with explicit
location. But there are cases, like uniform atomic counters, that
doesn't have a location from the OpenGL point of view (they have a
binding), but that Mesa assign internally a location. That will be
handled on following patches.
A nir_linker.h file is also added. More NIR-linking related API will
be added in subsequent patches and those will include stuff from Mesa,
so reusing nir.h didn't seem a good idea.
v2: move from compiler/nir to compiler/glsl (Timothy Arceri)
v3: sets var->driver.location if the uniform was found from a previous
stage (Neil Roberts).
Signed-off-by: Eduardo Lima <elima@igalia.com>
Signed-off-by: Neil Roberts <nroberts@igalia.com
Signed-off-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-11-14 12:25:47 +01:00
|
|
|
'gl_nir_link_uniforms.c',
|
2017-12-12 17:27:44 +01:00
|
|
|
'gl_nir_link_xfb.c',
|
2017-11-15 00:29:28 +01:00
|
|
|
'gl_nir_linker.c',
|
nir/linker: Add gl_nir_link_uniforms()
This function will be the entry point for linking the uniforms from
the nir_shader objects associated with the gl_linked_shaders of a
program.
This patch includes initial support for linking uniforms from NIR
shaders. It is tailored for the ARB_gl_spirv needs, and it is far from
complete, but it should handle most cases of uniforms, array
uniforms, structs, samplers and images.
There are some FIXMEs related to specific features that will be
implemented in following patches, like atomic counters, UBOs and
SSBOs.
Also, note that ARB_gl_spirv makes mandatory explicit location for
normal uniforms, so this code only handles uniforms with explicit
location. But there are cases, like uniform atomic counters, that
doesn't have a location from the OpenGL point of view (they have a
binding), but that Mesa assign internally a location. That will be
handled on following patches.
A nir_linker.h file is also added. More NIR-linking related API will
be added in subsequent patches and those will include stuff from Mesa,
so reusing nir.h didn't seem a good idea.
v2: move from compiler/nir to compiler/glsl (Timothy Arceri)
v3: sets var->driver.location if the uniform was found from a previous
stage (Neil Roberts).
Signed-off-by: Eduardo Lima <elima@igalia.com>
Signed-off-by: Neil Roberts <nroberts@igalia.com
Signed-off-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-11-14 12:25:47 +01:00
|
|
|
'gl_nir_linker.h',
|
2018-04-30 20:39:43 +10:00
|
|
|
'gl_nir.h',
|
2017-09-20 20:11:32 -07:00
|
|
|
'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_set_program_inouts.cpp',
|
|
|
|
'ir_uniform.h',
|
|
|
|
'ir_validate.cpp',
|
|
|
|
'ir_variable_refcount.cpp',
|
|
|
|
'ir_variable_refcount.h',
|
|
|
|
'ir_visitor.h',
|
|
|
|
'linker.cpp',
|
|
|
|
'linker.h',
|
2018-03-28 14:59:26 +02:00
|
|
|
'linker_util.h',
|
2018-05-12 09:59:32 +02:00
|
|
|
'linker_util.cpp',
|
2017-09-20 20:11:32 -07:00
|
|
|
'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',
|
|
|
|
'loop_analysis.cpp',
|
|
|
|
'loop_analysis.h',
|
|
|
|
'loop_unroll.cpp',
|
|
|
|
'lower_blend_equation_advanced.cpp',
|
|
|
|
'lower_buffer_access.cpp',
|
|
|
|
'lower_buffer_access.h',
|
2019-10-15 16:20:26 +02:00
|
|
|
'lower_builtins.cpp',
|
2017-09-20 20:11:32 -07:00
|
|
|
'lower_const_arrays_to_uniforms.cpp',
|
2017-10-21 15:15:41 -04:00
|
|
|
'lower_cs_derived.cpp',
|
2017-09-20 20:11:32 -07:00
|
|
|
'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_offset_array.cpp',
|
|
|
|
'lower_packed_varyings.cpp',
|
|
|
|
'lower_named_interface_blocks.cpp',
|
|
|
|
'lower_packing_builtins.cpp',
|
2019-04-19 15:36:58 +02:00
|
|
|
'lower_precision.cpp',
|
2017-09-20 20:11:32 -07:00
|
|
|
'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',
|
|
|
|
'lower_vertex_id.cpp',
|
|
|
|
'lower_output_reads.cpp',
|
|
|
|
'lower_shared_reference.cpp',
|
2019-10-12 00:19:50 -04:00
|
|
|
'lower_xfb_varying.cpp',
|
2017-09-20 20:11:32 -07:00
|
|
|
'opt_algebraic.cpp',
|
|
|
|
'opt_array_splitting.cpp',
|
|
|
|
'opt_conditional_discard.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_builtin_varyings.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',
|
2017-10-31 23:37:14 -07:00
|
|
|
'opt_swizzle.cpp',
|
2017-09-20 20:11:32 -07:00
|
|
|
'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',
|
2017-10-27 01:04:53 -07:00
|
|
|
'serialize.cpp',
|
|
|
|
'serialize.h',
|
2017-09-20 20:11:32 -07:00
|
|
|
'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,
|
2018-11-15 10:18:12 -08:00
|
|
|
ir_expression_operation_strings_h, ir_expression_operation_constant_h,
|
|
|
|
float64_glsl_h],
|
2020-04-24 13:10:41 -07:00
|
|
|
c_args : [c_msvc_compat_args, no_override_init_args],
|
|
|
|
cpp_args : [cpp_msvc_compat_args],
|
|
|
|
gnu_symbol_visibility : 'hidden',
|
2017-12-12 12:22:56 -08:00
|
|
|
link_with : libglcpp,
|
2019-03-05 16:21:47 +00:00
|
|
|
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_compiler],
|
2017-12-12 12:22:56 -08:00
|
|
|
dependencies : idep_nir,
|
2017-09-20 20:11:32 -07:00
|
|
|
build_by_default : false,
|
|
|
|
)
|
|
|
|
|
|
|
|
libglsl_standalone = static_library(
|
|
|
|
'glsl_standalone',
|
|
|
|
[files_libglsl_standalone, ir_expression_operation_h],
|
2020-04-24 13:10:41 -07:00
|
|
|
c_args : [c_msvc_compat_args, no_override_init_args],
|
|
|
|
cpp_args : [cpp_msvc_compat_args],
|
|
|
|
gnu_symbol_visibility : 'hidden',
|
2019-03-05 16:21:47 +00:00
|
|
|
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
|
2020-03-10 17:26:35 +00:00
|
|
|
link_with : [libglsl, libglsl_util, libglcpp_standalone],
|
2018-05-22 14:57:14 -07:00
|
|
|
dependencies : [idep_mesautil, idep_getopt],
|
2017-09-20 20:11:32 -07:00
|
|
|
build_by_default : false,
|
|
|
|
)
|
|
|
|
|
|
|
|
glsl_compiler = executable(
|
|
|
|
'glsl_compiler',
|
|
|
|
'main.cpp',
|
2020-04-24 13:10:41 -07:00
|
|
|
c_args : [c_msvc_compat_args, no_override_init_args],
|
|
|
|
cpp_args : [cpp_msvc_compat_args],
|
|
|
|
gnu_symbol_visibility : 'hidden',
|
2020-11-17 11:29:52 -08:00
|
|
|
dependencies : [dep_clock, dep_thread, idep_getopt, idep_mesautil],
|
2019-03-05 16:21:47 +00:00
|
|
|
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
|
2017-09-20 20:11:32 -07:00
|
|
|
link_with : [libglsl_standalone],
|
2018-02-07 16:55:24 -08:00
|
|
|
build_by_default : with_tools.contains('glsl'),
|
|
|
|
install : with_tools.contains('glsl'),
|
2017-09-20 20:11:32 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
glsl_test = executable(
|
|
|
|
'glsl_test',
|
|
|
|
['test.cpp', 'test_optpass.cpp', 'test_optpass.h',
|
|
|
|
ir_expression_operation_h],
|
2020-04-24 13:10:41 -07:00
|
|
|
c_args : [c_msvc_compat_args, no_override_init_args],
|
|
|
|
cpp_args : [cpp_msvc_compat_args],
|
|
|
|
gnu_symbol_visibility : 'hidden',
|
2019-03-05 16:21:47 +00:00
|
|
|
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
|
2020-11-17 11:29:52 -08:00
|
|
|
dependencies : [dep_clock, dep_thread, idep_getopt, idep_mesautil],
|
2017-09-20 20:11:32 -07:00
|
|
|
link_with : [libglsl, libglsl_standalone, libglsl_util],
|
2018-02-07 16:55:24 -08:00
|
|
|
build_by_default : with_tools.contains('glsl'),
|
|
|
|
install : with_tools.contains('glsl'),
|
2017-09-20 20:11:32 -07:00
|
|
|
)
|
|
|
|
|
2018-10-05 09:37:32 -07:00
|
|
|
if with_any_opengl and with_tests
|
2017-09-20 20:11:32 -07:00
|
|
|
subdir('tests')
|
|
|
|
endif
|