diff --git a/CMakeLists.txt b/CMakeLists.txt index b8a66a65..772fffb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,11 @@ option(BUILD_XDSP "Build XDSP math" OFF) option(BUILD_SHMATH "Build Spherical Harmonics math" OFF) +string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" DIRECTXMATH_SYSTEM_PROCESSOR_LOWER) +if(DIRECTXMATH_SYSTEM_PROCESSOR_LOWER MATCHES "^riscv") + message(STATUS "RISC-V target detected; DirectXMath will use the scalar no-intrinsics backend") +endif() + include(GNUInstallDirs) #--- Library diff --git a/Extensions/DirectXMathAVX.h b/Extensions/DirectXMathAVX.h index 964a9a48..39a7386e 100644 --- a/Extensions/DirectXMathAVX.h +++ b/Extensions/DirectXMathAVX.h @@ -9,8 +9,8 @@ #pragma once -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ -#error AVX not supported on ARM platform +#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ || defined(__riscv) +#error AVX not supported on this platform #endif #include diff --git a/Extensions/DirectXMathAVX2.h b/Extensions/DirectXMathAVX2.h index 3ee88065..9824bd32 100644 --- a/Extensions/DirectXMathAVX2.h +++ b/Extensions/DirectXMathAVX2.h @@ -9,8 +9,8 @@ #pragma once -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ -#error AVX2 not supported on ARM platform +#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ || defined(__riscv) +#error AVX2 not supported on this platform #endif #include diff --git a/Extensions/DirectXMathF16C.h b/Extensions/DirectXMathF16C.h index cf0995d5..4c28e5c1 100644 --- a/Extensions/DirectXMathF16C.h +++ b/Extensions/DirectXMathF16C.h @@ -9,8 +9,8 @@ #pragma once -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ -#error F16C not supported on ARM platform +#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ || defined(__riscv) +#error F16C not supported on this platform #endif #include diff --git a/Extensions/DirectXMathFMA3.h b/Extensions/DirectXMathFMA3.h index a991d3f8..616634cd 100644 --- a/Extensions/DirectXMathFMA3.h +++ b/Extensions/DirectXMathFMA3.h @@ -9,8 +9,8 @@ #pragma once -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ -#error FMA3 not supported on ARM platform +#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ || defined(__riscv) +#error FMA3 not supported on this platform #endif #include diff --git a/Extensions/DirectXMathFMA4.h b/Extensions/DirectXMathFMA4.h index c6394faf..ceba2d9e 100644 --- a/Extensions/DirectXMathFMA4.h +++ b/Extensions/DirectXMathFMA4.h @@ -9,8 +9,8 @@ #pragma once -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ -#error FMA4 not supported on ARM platform +#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ || defined(__riscv) +#error FMA4 not supported on this platform #endif #include diff --git a/Extensions/DirectXMathSSE3.h b/Extensions/DirectXMathSSE3.h index 667d1d91..58717c5f 100644 --- a/Extensions/DirectXMathSSE3.h +++ b/Extensions/DirectXMathSSE3.h @@ -9,8 +9,8 @@ #pragma once -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ -#error SSE3 not supported on ARM platform +#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ || defined(__riscv) +#error SSE3 not supported on this platform #endif #include diff --git a/Extensions/DirectXMathSSE4.h b/Extensions/DirectXMathSSE4.h index c20eafd1..ad842c92 100644 --- a/Extensions/DirectXMathSSE4.h +++ b/Extensions/DirectXMathSSE4.h @@ -9,8 +9,8 @@ #pragma once -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ -#error SSE4 not supported on ARM platform +#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ || defined(__riscv) +#error SSE4 not supported on this platform #endif #include diff --git a/Inc/DirectXMath.h b/Inc/DirectXMath.h index bc7451fc..f672f43c 100644 --- a/Inc/DirectXMath.h +++ b/Inc/DirectXMath.h @@ -86,6 +86,9 @@ #define _XM_SSE_INTRINSICS_ #elif defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ #define _XM_ARM_NEON_INTRINSICS_ +#elif defined(__riscv) +// RISC-V currently uses the existing scalar no-intrinsics implementation. +#define _XM_NO_INTRINSICS_ #elif !defined(_XM_NO_INTRINSICS_) #error DirectX Math does not support this target #endif diff --git a/README.md b/README.md index 60cabff6..1093def9 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,8 @@ copilot Officially the library is supported with Microsoft Visual C++ 2019 (16.11) or later, clang/LLVM v12 or later, and GCC 10 or later. It should also compile with the Intel C++ and MinGW compilers. +On `riscv64`, DirectXMath currently uses its existing scalar `_XM_NO_INTRINSICS_` backend. This provides a conservative portability path for the core headers, but it does not add any RISC-V vector or assembly implementation. The x86-specific extension headers under `Extensions/` remain unsupported there. + When building with clang/LLVM or other GNU C compilers, the ``_XM_NO_XMVECTOR_OVERLOADS_`` control define is set because these compilers do not support creating operator overloads for the ``XMVECTOR`` type. You can choose to enable this preprocessor define explicitly to do the same thing with Visual C++ for improved portability. To build for non-Windows platforms, you need to provide a ``sal.h`` header in your include path. You can obtain an open source version from [GitHub](https://raw.githubusercontent.com/dotnet/runtime/main/src/coreclr/pal/inc/rt/sal.h).