• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Shaders
2gst_vulkan_shader_sources = [
3  'identity.frag',
4  'identity.vert',
5  'swizzle.frag',
6  'swizzle_and_clobber_alpha.frag',
7  'yuy2_to_rgb.frag',
8  'rgb_to_yuy2.frag',
9  'ayuv_to_rgb.frag',
10  'rgb_to_ayuv.frag',
11  'nv12_to_rgb.frag',
12  'rgb_to_nv12.frag',
13  'view_convert.frag',
14]
15
16bin2array = find_program('bin2array.py')
17
18# FIXME: meson compiler class instead?
19glslc_build_options = []
20optimization = get_option('optimization')
21if get_option('debug')
22  glslc_build_options += ['-g']
23endif
24if get_option('werror')
25  glslc_build_options += ['-Werror']
26endif
27if optimization == 's'
28  glslc_build_options += ['-Os']
29endif
30if optimization in ['1', '2', '3']
31  glslc_build_options += ['-O']
32endif
33
34vulkan_compiled_shader_sources = []
35foreach shader: gst_vulkan_shader_sources
36  basefn = shader.split('.').get(0)
37  suffix = shader.split('.').get(1)
38
39  stage_arg = suffix == 'frag' ? '-fshader-stage=fragment' : '-fshader-stage=vertex'
40  basename = '@0@.@1@'.format(basefn, suffix)
41  spv_shader = basename + '.spv'
42  c_shader_source = basename + '.c'
43  c_shader_header = basename + '.h'
44
45  compiled_shader = custom_target(spv_shader,
46                                  input: shader,
47                                  output: spv_shader,
48                                  depfile: '@PLAINNAME@.d',
49                                  command: [glslc] + glslc_build_options + [
50                                    stage_arg,
51                                    '--target-env=vulkan1.0',
52                                    '-MD', '-MF', '@DEPFILE@',
53                                    '@INPUT@',
54                                    '-o', '@OUTPUT@'
55                                  ])
56
57  c_shader = custom_target (c_shader_source,
58      input: compiled_shader,
59      output: [c_shader_source, c_shader_header],
60      command: [ bin2array,
61        '--array-name=' + basename.underscorify(),
62        '--c-include=gst/gst.h',
63        '--element-type=gchar',
64        '--element-size=1',
65        '--linebreak=8',
66        '--input', '@INPUT@',
67        '--output', '@OUTPUT0@',
68        '--header-output', '@OUTPUT1@'])
69
70  vulkan_compiled_shader_sources += [c_shader]
71endforeach
72