Compare commits

...

2 commits

Author SHA1 Message Date
Santiago
c18ab59e77
Merge 073a8fbf66 into cea072b59b 2025-07-24 13:22:55 -07:00
Santiago
073a8fbf66 Fix MSVC build 2025-05-12 22:37:36 +02:00
3 changed files with 23 additions and 12 deletions

View file

@ -4,6 +4,7 @@ project(librecomp)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 11)
# Define the library # Define the library
add_library(librecomp STATIC add_library(librecomp STATIC
@ -46,11 +47,13 @@ target_include_directories(librecomp PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include/librecomp" "${CMAKE_CURRENT_SOURCE_DIR}/include/librecomp"
) )
target_compile_options(librecomp PRIVATE if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# -Wall target_compile_options(librecomp PRIVATE
# -Wextra # -Wall
-Wno-unused-parameter # -Wextra
) -Wno-unused-parameter
)
endif()
if (WIN32) if (WIN32)
add_compile_definitions(NOMINMAX) add_compile_definitions(NOMINMAX)

View file

@ -36,6 +36,12 @@ using u32 = uint32_t;
#define DIVOUT vpu.divout #define DIVOUT vpu.divout
#define DIVDP vpu.divdp #define DIVDP vpu.divdp
#ifdef _MSC_VER
#define COUNT_LEADING_ZEROES __lzcnt
#else
#define COUNT_LEADING_ZEROES __builtin_clz
#endif
auto RSP::r128::operator()(u32 index) const -> r128 { auto RSP::r128::operator()(u32 index) const -> r128 {
if constexpr (Accuracy::RSP::SISD) { if constexpr (Accuracy::RSP::SISD) {
r128 v{ *this }; r128 v{ *this };
@ -1348,7 +1354,7 @@ auto RSP::VRCP(r128& vd, u8 de, cr128& vt) -> void {
} else if (input == -32768) { } else if (input == -32768) {
result = 0xffff'0000; result = 0xffff'0000;
} else { } else {
u32 shift = __builtin_clz(data); u32 shift = COUNT_LEADING_ZEROES(data);
u32 index = (u64(data) << shift & 0x7fc0'0000) >> 22; u32 index = (u64(data) << shift & 0x7fc0'0000) >> 22;
result = rspReciprocals[index]; result = rspReciprocals[index];
result = (0x10000 | result) << 14; result = (0x10000 | result) << 14;
@ -1400,7 +1406,7 @@ auto RSP::VRSQ(r128& vd, u8 de, cr128& vt) -> void {
} else if (input == -32768) { } else if (input == -32768) {
result = 0xffff'0000; result = 0xffff'0000;
} else { } else {
u32 shift = __builtin_clz(data); u32 shift = COUNT_LEADING_ZEROES(data);
u32 index = (u64(data) << shift & 0x7fc0'0000) >> 22; u32 index = (u64(data) << shift & 0x7fc0'0000) >> 22;
result = rspInverseSquareRoots[index & 0x1fe | shift & 1]; result = rspInverseSquareRoots[index & 0x1fe | shift & 1];
result = (0x10000 | result) << 14; result = (0x10000 | result) << 14;

View file

@ -29,11 +29,13 @@ target_include_directories(ultramodern PUBLIC
"${PROJECT_SOURCE_DIR}/../thirdparty/sse2neon" "${PROJECT_SOURCE_DIR}/../thirdparty/sse2neon"
) )
target_compile_options(ultramodern PRIVATE if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# -Wall target_compile_options(ultramodern PRIVATE
# -Wextra # -Wall
-Wno-unused-parameter # -Wextra
) -Wno-unused-parameter
)
endif()
if (WIN32) if (WIN32)
add_compile_definitions(NOMINMAX) add_compile_definitions(NOMINMAX)