Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Extensions/DirectXMathAVX.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DirectXMath.h>
Expand Down
4 changes: 2 additions & 2 deletions Extensions/DirectXMathAVX2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DirectXMath.h>
Expand Down
4 changes: 2 additions & 2 deletions Extensions/DirectXMathF16C.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DirectXMath.h>
Expand Down
4 changes: 2 additions & 2 deletions Extensions/DirectXMathFMA3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DirectXMath.h>
Expand Down
4 changes: 2 additions & 2 deletions Extensions/DirectXMathFMA4.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DirectXMath.h>
Expand Down
4 changes: 2 additions & 2 deletions Extensions/DirectXMathSSE3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pmmintrin.h>
Expand Down
4 changes: 2 additions & 2 deletions Extensions/DirectXMathSSE4.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <smmintrin.h>
Expand Down
3 changes: 3 additions & 0 deletions Inc/DirectXMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down