hello-tool: automatically build spir shaders
This commit is contained in:
parent
828f43701a
commit
7fd225c0f1
@ -11,6 +11,11 @@ find_package (Vulkan REQUIRED)
|
||||
find_package (PythonInterp 3 REQUIRED)
|
||||
find_package (glfw3 REQUIRED)
|
||||
|
||||
find_program (GLSLANG glslangValidator)
|
||||
if (NOT GLSLANG)
|
||||
message (FATAL_ERROR "could not locate glslangValidator")
|
||||
endif ()
|
||||
|
||||
|
||||
###############################################################################
|
||||
include_directories ("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
@ -86,6 +91,34 @@ add_library (cruft-vk STATIC ${sources})
|
||||
target_link_libraries (cruft-vk cruft-util vulkan)
|
||||
|
||||
|
||||
###############################################################################
|
||||
list (APPEND shaders
|
||||
tools/hello/shader.vert
|
||||
tools/hello/shader.frag
|
||||
)
|
||||
|
||||
foreach (src ${shaders})
|
||||
set(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
||||
get_filename_component(ext ${src} EXT)
|
||||
|
||||
get_filename_component(name ${src} DIRECTORY)
|
||||
get_filename_component(name ${name} NAME)
|
||||
|
||||
set(label "${name}${ext}.spv")
|
||||
set(dst "${CMAKE_CURRENT_BINARY_DIR}/tools/${label}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${dst}
|
||||
COMMAND ${GLSLANG} -s -o ${dst} -V100 ${src}
|
||||
DEPENDS ${src}
|
||||
COMMENT "[glslang] ${label}"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(${label} DEPENDS ${dst})
|
||||
endforeach ()
|
||||
|
||||
|
||||
###############################################################################
|
||||
get_directory_property (HAS_PARENT PARENT_DIRECTORY)
|
||||
if (HAS_PARENT)
|
||||
@ -105,6 +138,11 @@ foreach (t info hello)
|
||||
target_link_libraries (vk_${t} cruft-vk glfw)
|
||||
endforeach ()
|
||||
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
add_dependencies (vk_hello hello.vert.spv hello.frag.spv)
|
||||
|
||||
|
||||
###############################################################################
|
||||
configure_file(libcruft-vk-system.pc.in libcruft-vk.pc)
|
||||
configure_file(Doxyfile.in Doxyfile)
|
||||
|
@ -288,8 +288,8 @@ main (void)
|
||||
auto graphics_queue = ldevice.queue (graphics_queue_id);
|
||||
auto present_queue = ldevice.queue (present_queue_id);
|
||||
|
||||
auto vert_module = create_shader (ldevice, "./hello/shader.vert");
|
||||
auto frag_module = create_shader (ldevice, "./hello/shader.frag");
|
||||
auto vert_module = create_shader (ldevice, "./hello.vert.spv");
|
||||
auto frag_module = create_shader (ldevice, "./hello.frag.spv");
|
||||
|
||||
VkBufferCreateInfo buffer_info {};
|
||||
buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
||||
|
Loading…
Reference in New Issue
Block a user