From 94063cbe92a7e96c17042ae44c629683ab292e4d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 3 Nov 2023 06:48:00 +0100 Subject: [PATCH] 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... --- gsk/gpu/shaders/meson.build | 61 ++++++++++++++++++------------------- gsk/meson.build | 6 ++-- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/gsk/gpu/shaders/meson.build b/gsk/gpu/shaders/meson.build index ded7d3453d..85164792ed 100644 --- a/gsk/gpu/shaders/meson.build +++ b/gsk/gpu/shaders/meson.build @@ -25,8 +25,7 @@ gsk_private_gpu_shaders = files([ gsk_private_gpu_shader_headers = [] gsk_private_gpu_gl_shaders = [] -gsk_private_gpu_vulkan_vertex_shaders = [] -gsk_private_gpu_vulkan_fragment_shaders = [] +gsk_private_gpu_vulkan_shaders = [] generate_header = find_program('generate-header.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 if (have_vulkan) - vert_spv = fs.name (fs.replace_suffix (shader, '')) + '.vert.spv' - frag_spv = fs.name (fs.replace_suffix (shader, '')) + '.frag.spv' - vert_target = custom_target(vert_spv, - input: shader, - output: vert_spv, - depend_files: gsk_private_gpu_include_shaders, - command: [ - glslc, - '-std=450', - '--target-env=vulkan1.2', - '-fshader-stage=vertex', - '-DGSK_VERTEX_SHADER=1', - '@INPUT@', - '-o', '@OUTPUT@' - ]) - frag_target = custom_target(frag_spv, - input: shader, - output: frag_spv, - depend_files: gsk_private_gpu_include_shaders, - command: [ - glslc, - '-std=450', - '--target-env=vulkan1.2', - '-fshader-stage=fragment', - '-DGSK_FRAGMENT_SHADER=1', - '@INPUT@', - '-o', '@OUTPUT@' - ]) - gsk_private_gpu_vulkan_vertex_shaders += vert_target - gsk_private_gpu_vulkan_fragment_shaders += frag_target + glslc_options = [ + [ fs.name (fs.replace_suffix (shader, '')) + '.vert.spv', + [ '--target-env=vulkan1.2', + '-fshader-stage=vertex', + '-DGSK_VERTEX_SHADER=1', + ] + ], + [ fs.name (fs.replace_suffix (shader, '')) + '.frag.spv', + [ '--target-env=vulkan1.2', + '-fshader-stage=fragment', + '-DGSK_FRAGMENT_SHADER=1', + ] + ] + ] + foreach option: glslc_options + target = custom_target(option.get(0), + input: shader, + output: option.get(0), + depend_files: gsk_private_gpu_include_shaders, + command: [ + glslc, + '-std=450', + option.get(1), + '@INPUT@', + '-o', '@OUTPUT@' + ]) + gsk_private_gpu_vulkan_shaders += target + endforeach endif endforeach diff --git a/gsk/meson.build b/gsk/meson.build index cdd46b7e5a..65689526cd 100644 --- a/gsk/meson.build +++ b/gsk/meson.build @@ -181,8 +181,7 @@ gsk_resources_xml = custom_target(output: 'gsk.resources.xml', gsk_private_vulkan_compiled_shaders, gsk_private_vulkan_shaders, gsk_private_gpu_gl_shaders, - gsk_private_gpu_vulkan_vertex_shaders, - gsk_private_gpu_vulkan_fragment_shaders, + gsk_private_gpu_vulkan_shaders, ], ) @@ -200,8 +199,7 @@ gskresources = gnome.compile_resources('gskresources', gsk_resources_xml, dependencies: [ gsk_private_vulkan_compiled_shaders_deps, - gsk_private_gpu_vulkan_fragment_shaders, - gsk_private_gpu_vulkan_vertex_shaders, + gsk_private_gpu_vulkan_shaders, ], source_dir: [meson.current_build_dir(), meson.current_source_dir()], c_name: '_gsk',