gpu: Change the meson code for how SPIR-V is built

This does the same thing, but in a way that's a bit more flexible.
And it prepares the next commit...
This commit is contained in:
Benjamin Otte 2023-11-03 06:48:00 +01:00
parent 96e579501f
commit 94063cbe92
2 changed files with 31 additions and 36 deletions

View File

@ -25,8 +25,7 @@ gsk_private_gpu_shaders = files([
gsk_private_gpu_shader_headers = [] gsk_private_gpu_shader_headers = []
gsk_private_gpu_gl_shaders = [] gsk_private_gpu_gl_shaders = []
gsk_private_gpu_vulkan_vertex_shaders = [] gsk_private_gpu_vulkan_shaders = []
gsk_private_gpu_vulkan_fragment_shaders = []
generate_header = find_program('generate-header.py') generate_header = find_program('generate-header.py')
process_includes = find_program('process-glsl-includes.py') process_includes = find_program('process-glsl-includes.py')
@ -56,36 +55,34 @@ foreach shader: gsk_private_gpu_shaders
gsk_private_gpu_gl_shaders += gl_shader gsk_private_gpu_gl_shaders += gl_shader
if (have_vulkan) if (have_vulkan)
vert_spv = fs.name (fs.replace_suffix (shader, '')) + '.vert.spv' glslc_options = [
frag_spv = fs.name (fs.replace_suffix (shader, '')) + '.frag.spv' [ fs.name (fs.replace_suffix (shader, '')) + '.vert.spv',
vert_target = custom_target(vert_spv, [ '--target-env=vulkan1.2',
input: shader, '-fshader-stage=vertex',
output: vert_spv, '-DGSK_VERTEX_SHADER=1',
depend_files: gsk_private_gpu_include_shaders, ]
command: [ ],
glslc, [ fs.name (fs.replace_suffix (shader, '')) + '.frag.spv',
'-std=450', [ '--target-env=vulkan1.2',
'--target-env=vulkan1.2', '-fshader-stage=fragment',
'-fshader-stage=vertex', '-DGSK_FRAGMENT_SHADER=1',
'-DGSK_VERTEX_SHADER=1', ]
'@INPUT@', ]
'-o', '@OUTPUT@' ]
]) foreach option: glslc_options
frag_target = custom_target(frag_spv, target = custom_target(option.get(0),
input: shader, input: shader,
output: frag_spv, output: option.get(0),
depend_files: gsk_private_gpu_include_shaders, depend_files: gsk_private_gpu_include_shaders,
command: [ command: [
glslc, glslc,
'-std=450', '-std=450',
'--target-env=vulkan1.2', option.get(1),
'-fshader-stage=fragment', '@INPUT@',
'-DGSK_FRAGMENT_SHADER=1', '-o', '@OUTPUT@'
'@INPUT@', ])
'-o', '@OUTPUT@' gsk_private_gpu_vulkan_shaders += target
]) endforeach
gsk_private_gpu_vulkan_vertex_shaders += vert_target
gsk_private_gpu_vulkan_fragment_shaders += frag_target
endif endif
endforeach endforeach

View File

@ -181,8 +181,7 @@ gsk_resources_xml = custom_target(output: 'gsk.resources.xml',
gsk_private_vulkan_compiled_shaders, gsk_private_vulkan_compiled_shaders,
gsk_private_vulkan_shaders, gsk_private_vulkan_shaders,
gsk_private_gpu_gl_shaders, gsk_private_gpu_gl_shaders,
gsk_private_gpu_vulkan_vertex_shaders, gsk_private_gpu_vulkan_shaders,
gsk_private_gpu_vulkan_fragment_shaders,
], ],
) )
@ -200,8 +199,7 @@ gskresources = gnome.compile_resources('gskresources',
gsk_resources_xml, gsk_resources_xml,
dependencies: [ dependencies: [
gsk_private_vulkan_compiled_shaders_deps, gsk_private_vulkan_compiled_shaders_deps,
gsk_private_gpu_vulkan_fragment_shaders, gsk_private_gpu_vulkan_shaders,
gsk_private_gpu_vulkan_vertex_shaders,
], ],
source_dir: [meson.current_build_dir(), meson.current_source_dir()], source_dir: [meson.current_build_dir(), meson.current_source_dir()],
c_name: '_gsk', c_name: '_gsk',