Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve shader profile extension to be more compatible with bgfx #247

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions cmake/bgfxToolUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ if(TARGET bgfx::texturec)
add_custom_command(
OUTPUT ${ARG_OUTPUT} #
COMMAND bgfx::texturec ${CLI} #
MAIN_DEPENDENCY ${ARG_INPUT} #
MAIN_DEPENDENCY ${ARG_FILE} #
)
endfunction()
endif()
Expand Down Expand Up @@ -279,12 +279,12 @@ if(TARGET bgfx::geometryc)

# --packnormal
if(ARG_PACKNORMAL)
list(APPEND CLI "--packnormal ${ARG_PACKNORMAL}")
list(APPEND CLI "--packnormal" "${ARG_PACKNORMAL}")
endif()

# --packuv
if(ARG_PACKUV)
list(APPEND CLI "--packuv" ${ARG_PACKUV})
list(APPEND CLI "--packuv" "${ARG_PACKUV}")
endif()

# --tangent
Expand Down Expand Up @@ -352,7 +352,7 @@ if(TARGET bgfx::geometryc)
add_custom_command(
OUTPUT ${ARG_OUTPUT} #
COMMAND bgfx::geometryc ${CLI} #
MAIN_DEPENDENCY ${ARG_INPUT} #
MAIN_DEPENDENCY ${ARG_FILE} #
)
endfunction()
endif()
Expand Down Expand Up @@ -539,15 +539,23 @@ if(TARGET bgfx::shaderc)
set(${ARG_OUT} ${CLI} PARENT_SCOPE)
endfunction()

# extensions consistent with those listed under bgfx/runtime/shaders
function(_bgfx_get_profile_path_ext PROFILE PROFILE_PATH_EXT)
string(REPLACE 300_es essl PROFILE ${PROFILE})
string(REPLACE 120 glsl PROFILE ${PROFILE})
string(REPLACE s_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE s_5_0 dx11 PROFILE ${PROFILE})
set(${PROFILE_PATH_EXT} ${PROFILE} PARENT_SCOPE)
endfunction()

# extensions consistent with embedded_shader.h
function(_bgfx_get_profile_ext PROFILE PROFILE_EXT)
string(REPLACE 300_es essl PROFILE ${PROFILE})
string(REPLACE 120 glsl PROFILE ${PROFILE})
string(REPLACE spirv spv PROFILE ${PROFILE})
string(REPLACE metal mtl PROFILE ${PROFILE})
string(REPLACE s_3_0 dx9 PROFILE ${PROFILE})
string(REPLACE s_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE s_5_0 dx11 PROFILE ${PROFILE})

set(${PROFILE_EXT} ${PROFILE} PARENT_SCOPE)
endfunction()

Expand Down Expand Up @@ -602,11 +610,12 @@ if(TARGET bgfx::shaderc)
set(COMMANDS "")
set(MKDIR_COMMANDS "")
foreach(PROFILE ${PROFILES})
_bgfx_get_profile_path_ext(${PROFILE} PROFILE_PATH_EXT)
_bgfx_get_profile_ext(${PROFILE} PROFILE_EXT)
if(ARGS_AS_HEADERS)
set(HEADER_PREFIX .h)
endif()
set(OUTPUT ${ARGS_OUTPUT_DIR}/${PROFILE_EXT}/${SHADER_FILE_BASENAME}.bin${HEADER_PREFIX})
set(OUTPUT ${ARGS_OUTPUT_DIR}/${PROFILE_PATH_EXT}/${SHADER_FILE_BASENAME}.bin${HEADER_PREFIX})
set(PLATFORM_I ${PLATFORM})
if(PROFILE STREQUAL "spirv")
set(PLATFORM_I LINUX)
Expand Down Expand Up @@ -635,7 +644,7 @@ if(TARGET bgfx::shaderc)
${CMAKE_COMMAND}
-E
make_directory
${ARGS_OUTPUT_DIR}/${PROFILE_EXT}
${ARGS_OUTPUT_DIR}/${PROFILE_PATH_EXT}
)
list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI})
endforeach()
Expand Down
Loading