diff --git a/CMakeLists.txt b/CMakeLists.txt index 34c0a480..b5248543 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,7 @@ function(build_shader_target ADDON ADDON_PATH) set(EMBED_FOLDER ${CMAKE_CURRENT_BINARY_DIR}/${ADDON}.include/embed) unset(SHADER_BINARIES) - file(GLOB_RECURSE SHADER_SOURCES ${ADDON_PATH}/*.hlsl ) + file(GLOB_RECURSE SHADER_SOURCES ${ADDON_PATH}/*.hlsl) foreach(FILE ${SHADER_SOURCES}) cmake_path(GET FILE FILENAME FILENAME) cmake_path(GET FILE PARENT_PATH TARGET_PATH) @@ -93,17 +93,22 @@ function(build_shader_target ADDON ADDON_PATH) if(SHADER_TARGET AND (SHADER_HASH OR SHADER_NAME)) string(SUBSTRING ${SHADER_TARGET} 3 1 SHADER_TARGET_MAJOR) + string(SUBSTRING ${SHADER_TARGET} 5 1 SHADER_TARGET_MINOR) set(SHADER_COMPILER ${FXC_BIN}) unset(SHADER_FLAGS) - if(SHADER_TARGET_MAJOR EQUAL "6") + if(SHADER_TARGET_MAJOR GREATER_EQUAL "6") set(SHADER_COMPILER ${DXC_BIN}) - set(SHADER_FLAGS "/HV 2021") - elseif(SHADER_TARGET_MAJOR EQUAL "5") - if(SHADER_TARGET_MINOR EQUAL "0") - set(SHADER_FLAGS "/Gec") - endif() + set(SHADER_FLAGS "/HV 2021") # Ovewrite flags else() - set(SHADER_FLAGS "/Gec") # Compatibility mode + set(SHADER_FLAGS ${SHADER_FLAGS} /D __SHADER_TARGET_MAJOR=${SHADER_TARGET_MAJOR}) + set(SHADER_FLAGS ${SHADER_FLAGS} /D __SHADER_TARGET_MINOR=${SHADER_TARGET_MINOR}) + if(SHADER_TARGET_MAJOR EQUAL "5") + if(SHADER_TARGET_MINOR EQUAL "0") + set(SHADER_FLAGS ${SHADER_FLAGS} /Gec) + endif() + else() + set(SHADER_FLAGS ${SHADER_FLAGS} /Gec) + endif() endif() unset(HLSL_DEPENDENCIES) diff --git a/src/shaders/math.hlsl b/src/shaders/math.hlsl index b678c957..5d97e41c 100644 --- a/src/shaders/math.hlsl +++ b/src/shaders/math.hlsl @@ -10,16 +10,16 @@ static const float FLT10_MAX = 64512.f; static const float FLT11_MAX = 65024.f; static const float FLT16_MAX = 65504.f; -#if __SHADER_TARGET_MAJOR >= 6 -#define SIGN_FUNCTION_GENERATOR(T) \ - T Sign(T x) { \ - return sign(x); \ - } -#else +#if __SHADER_TARGET_MAJOR <= 5 #define SIGN_FUNCTION_GENERATOR(T) \ T Sign(T x) { \ return mad(saturate(mad(x, FLT_MAX, 0.5f)), 2.f, -1.f); \ } +#else +#define SIGN_FUNCTION_GENERATOR(T) \ + T Sign(T x) { \ + return sign(x); \ + } #endif SIGN_FUNCTION_GENERATOR(float);