Skip to content

Commit

Permalink
Make bgfx_compile_shaders more generic
Browse files Browse the repository at this point in the history
Allow compiling as header or as binaries
  • Loading branch information
bwrsandman committed Jul 20, 2024
1 parent 79e4993 commit 68fcdd4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmake/bgfxToolUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -551,17 +551,18 @@ if(TARGET bgfx::shaderc)
set(${PROFILE_EXT} ${PROFILE} PARENT_SCOPE)
endfunction()

# bgfx_compile_shader_to_header(
# bgfx_compile_shaders(
# TYPE VERTEX|FRAGMENT|COMPUTE
# SHADERS filenames
# VARYING_DEF filename
# OUTPUT_DIR directory
# OUT_FILES_VAR variable name
# INCLUDE_DIRS directories
# [AS_HEADER]
# )
#
function(bgfx_compile_shader_to_header)
set(options "")
function(bgfx_compile_shaders)
set(options AS_HEADER)
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR OUT_FILES_VAR)
set(multiValueArgs SHADERS INCLUDE_DIRS)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
Expand Down Expand Up @@ -599,7 +600,7 @@ if(TARGET bgfx::shaderc)
set(COMMANDS "")
foreach(PROFILE ${PROFILES})
_bgfx_get_profile_ext(${PROFILE} PROFILE_EXT)
set(OUTPUT ${ARGS_OUTPUT_DIR}/${SHADER_FILE_BASENAME}.${PROFILE_EXT}.bin.h)
set(OUTPUT ${ARGS_OUTPUT_DIR}/${SHADER_FILE_BASENAME}.${PROFILE_EXT}.bin$<ARGS_AS_HEADER:.h>)
set(PLATFORM_I ${PLATFORM})
if(PROFILE STREQUAL "spirv")
set(PLATFORM_I LINUX)
Expand All @@ -613,7 +614,7 @@ if(TARGET bgfx::shaderc)
O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
VARYINGDEF ${ARGS_VARYING_DEF}
INCLUDES ${BGFX_SHADER_INCLUDE_PATH} ${ARGS_INCLUDE_DIRS}
BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
$<ARGS_AS_HEADER:BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}>
)
list(APPEND OUTPUTS ${OUTPUT})
list(APPEND ALL_OUTPUTS ${OUTPUT})
Expand Down

0 comments on commit 68fcdd4

Please sign in to comment.