You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -21,13 +21,13 @@ These instructions define how GitHub Copilot should assist with this project. Th
21
21
## General Guidelines
22
22
23
23
-**Code Style**: The project uses an .editorconfig file to enforce coding standards. Follow the rules defined in `.editorconfig` for indentation, line endings, and other formatting. Additional information can be found on the wiki at [Implementation](https://github.com/microsoft/DirectXMath/wiki/Implementation). The code requires C++11/C++14 features.
24
-
> Notable `.editorconfig` rules: C/C++ files use 4-space indentation, `crlf` line endings, and `latin1` charset — avoid non-ASCII characters in source files. HLSL files have separate indent/spacing rules defined in `.editorconfig`.
25
-
-**Documentation**: The project provides documentation on [Microsoft Learn](https://learn.microsoft.com/windows/win32/dxmath/directxmath-portal) with additional wiki pages available on [GitHub](https://github.com/microsoft/DirectXMath/wiki/).
24
+
> Notable `.editorconfig` rules: C/C++ files use 4-space indentation, `crlf` line endings, and `latin1` charset — avoid non-ASCII characters in source files.
25
+
-**Documentation**: The project provides documentation on [Microsoft Learn](https://learn.microsoft.com/windows/win32/dxmath/directxmath-portal) with additional wiki pages available on [GitHub](https://github.com/microsoft/DirectXMath/wiki/). The project does **not** use Doxygen.
26
26
-**Error Handling**: The majority of functions have no error conditions and do not throw C++ exceptions which is why they are marked `noexcept`. A few functions have `bool` results to indicate success or failure.
27
-
-**Testing**: Unit tests for this project are implemented in this repository [Test Suite](https://github.com/walbourn/directxmathtest/) and can be run using CTest per the instructions at [Test Documentation](https://github.com/walbourn/directxmathtest/wiki).
27
+
-**Testing**: Unit tests for this project are implemented in this repository [Test Suite](https://github.com/walbourn/directxmathtest/) and can be run using CTest per the instructions at [Test Documentation](https://github.com/walbourn/directxmathtest/wiki). See [test copilot instructions](https://github.com/walbourn/directxmathtest/blob/main/.github/copilot-instructions.md) for additional information on the tests.
28
28
-**Security**: This project uses secure coding practices from the Microsoft Secure Coding Guidelines, and is subject to the `SECURITY.md` file in the root of the repository.
29
29
-**Dependencies**: The project has minimal dependencies, primarily relying on compiler intrinsics. It is designed to be self-contained and portable across different platforms and toolsets.
30
-
-**Continuous Integration**: This project implements GitHub Actions for continuous integration, ensuring that all code changes are tested and validated before merging. This includes building the project for a number of configurations and toolsets, running unit tests, and static code analysis including GitHub super-linter, CodeQL, and MSVC Code Analysis.
30
+
-**Continuous Integration**: This project has 18 GitHub Actions workflows covering MSVC, Clang/LLVM, GCC (WSL), ARM64, Address Sanitizer, CodeQL, and super-linter. Workflows are in `.github/workflows/` and include compiler-specific builds (`msvc.yml`, `clangcl.yml`, `cxx.yml`), platform-specific builds (`arm64.yml`, `wsl.yml`), extension tests (`shmath.yml`, `xdsp.yml`), and static analysis (`codeql.yml`, `lint.yml`, `asan.yml`). Azure DevOps pipeline configurations are in `.azuredevops/`.
31
31
-**Code of Conduct**: The project adheres to the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). All contributors are expected to follow this code of conduct in all interactions related to the project.
32
32
33
33
## File Structure
@@ -87,7 +87,7 @@ All types and functions are in the `DirectX` namespace. Sub-namespaces are used
87
87
|`DirectX::PackedVector`| GPU-friendly packed types from `DirectXPackedVector.h`|
88
88
|`DirectX::Colors`| sRGB named color constants from `DirectXColors.h`|
89
89
|`DirectX::ColorsLinear`| Linear-space color constants from `DirectXColors.h`|
90
-
|`DirectX::MathInternal`| Private implementation details (do not use directly) |
90
+
|`DirectX::MathInternal`| Private implementation details (do not use directly); renamed from `DirectX::Internal` in v3.20|
_XM_ARM_NEON_INTRINSICS_ (auto-enabled for ARM/ARM64)
102
+
_XM_SSE_INTRINSICS_ (auto-enabled for x86/x64/PowerPC64)
103
+
_XM_ARM_NEON_INTRINSICS_ (auto-enabled for ARM/ARM64/ARM64EC)
104
104
_XM_NO_INTRINSICS_ (pure C++ fallback; force with this define)
105
105
```
106
106
107
107
Optional macros:
108
-
- `_XM_SVML_INTRINSICS_` — Intel Short Vector Math Library (auto-enabled with MSVC 2019+; opt-out with `_XM_DISABLE_INTEL_SVML_`)
108
+
- `_XM_SVML_INTRINSICS_` — Intel Short Vector Math Library (auto-enabled for SSE paths with MSVC 2019+ / `_MSC_VER >= 1920`, excluding Clang and IntelLLVM; opt-out with `_XM_DISABLE_INTEL_SVML_`)
109
109
- `_XM_NO_MOVNT_` — Disables non-temporal store instructions (`_mm_stream_ps`, etc.)
110
110
- `_XM_FAVOR_INTEL_` — Uses `_mm_permute_ps` (AVX) over `_mm_shuffle_ps` when available
111
111
- `_XM_NO_XMVECTOR_OVERLOADS_` — Disables `XMVECTOR` arithmetic operators (auto-set for GCC/Clang)
@@ -141,8 +141,8 @@ Storage types hold data in memory. Use `XMLoad*` / `XMStore*` to move between st
void XM_CALLCONV XMStoreFloat4x4(_Out_ XMFLOAT4X4* pDestination, _In_ FXMMATRIX M) noexcept;
230
230
```
231
231
232
-
SAL annotations compile to no-ops unless `/analyze` is used; they never affect code generation.
232
+
SAL annotations compile to no-ops unless `/analyze` is used; they never affect code generation. On non-Windows platforms, a `sal.h` compatibility header must be provided (e.g., from the DirectX-Headers package).
233
233
234
234
## Key Macros
235
235
@@ -244,6 +244,8 @@ SAL annotations compile to no-ops unless `/analyze` is used; they never affect c
244
244
|`XM_STREAM_PS` / `XM_SFENCE`| Non-temporal stores (controlled by `_XM_NO_MOVNT_`) |
245
245
|`XM_FMADD_PS` / `XM_FNMADD_PS`| FMA ops when `_XM_FMA3_INTRINSICS_` is active, else expanded to mul+add |
246
246
|`XM_PERMUTE_PS`|`_mm_permute_ps` (AVX) or `_mm_shuffle_ps` (SSE) |
247
+
|`XM_LOADU_SI16`| SSE: loads 16-bit integer; workaround for GCC < 11 and PowerPC64 |
248
+
|`XM_PREFETCH`| ARM NEON only: `__builtin_prefetch` (Clang/GCC) or `__prefetch` (MSVC) |
247
249
248
250
## CMake Build Options
249
251
@@ -256,9 +258,12 @@ SAL annotations compile to no-ops unless `/analyze` is used; they never affect c
256
258
|`BUILD_AVX2_TEST`|`OFF`| Test preset: enable AVX2 instruction set |
257
259
|`BUILD_F16C_TEST`|`OFF`| Test preset: enable F16C instruction set |
258
260
|`BUILD_NO_INTRINSICS`|`OFF`| Test preset: force `_XM_NO_INTRINSICS_` mode |
261
+
|`BUILD_FOR_ONECORE`|`OFF`| Build for OneCore using APISets |
259
262
260
263
The CMake library exports as `Microsoft::DirectXMath` and requires **CMake 3.21+**.
261
264
265
+
Standardized build configurations are provided in `CMakePresets.json` with 20+ presets covering MSVC, Clang, MinGW, and Intel compilers across x86, x64, ARM64, and ARM64EC architectures. Use `cmake --preset <name>` to configure (e.g., `cmake --preset x64-Debug`).
266
+
262
267
## C++ Standard Feature Usage
263
268
264
269
The library uses conditional C++ standard feature guards:
@@ -273,10 +278,11 @@ The library uses conditional C++ standard feature guards:
273
278
#endif
274
279
275
280
#if (__cplusplus >= 202002L)
276
-
// C++20 features (e.g., spaceship <=> operator on XMFLOAT2/3/4)
281
+
// C++20 features (e.g., spaceship <=> operator on storage types)
**Floating-point precision** (MSVC-only, for mathematically sensitive code):
370
+
371
+
```cpp
372
+
#ifdef _MSC_VER
373
+
#pragma float_control(push)
374
+
#pragma float_control(precise, on)
375
+
// sensitive floating-point calculations
376
+
#pragma float_control(pop)
377
+
#endif
378
+
```
379
+
380
+
**PREfast static analysis suppression**:
381
+
382
+
```cpp
383
+
#ifdef _PREFAST_
384
+
#pragma prefast(push)
385
+
#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes")
386
+
// code
387
+
#pragma prefast(pop)
388
+
#endif
389
+
```
390
+
391
+
## Template Specialization Patterns
392
+
393
+
Performance-critical functions like `XMVectorPermute` and `XMVectorSwizzle` use template specialization to map compile-time constants to optimal SIMD instructions:
The following packed vector types in `DirectXPackedVector.h` are deprecated and should not be used in new code. They are marked with `XM_DEPRECATED`:
426
+
427
+
-`XMXDEC4`
428
+
-`XMDECN4`
429
+
-`XMDEC4`
430
+
431
+
These were legacy types originally from xboxmath on the Xbox 360 which no longer have any GPU format equivalents.
432
+
433
+
## XNAMath Compatibility
434
+
435
+
`DirectXMath.h` contains a block of `#undef` statements (guarded by `__XNAMATH_H__`) that prevent macro conflicts with the legacy XNA Math library. Do not remove these.
436
+
307
437
## References
308
438
309
439
-[Source git repository on GitHub](https://github.com/microsoft/DirectXMath.git)
@@ -361,7 +491,7 @@ Use these established guards — do not invent new ones:
0 commit comments