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
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+277-3Lines changed: 277 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,9 @@ These instructions define how GitHub Copilot should assist with this project. Th
6
6
7
7
-**Project Type**: Math Library / DirectX / Direct3D
8
8
-**Project Name**: DirectXMath SIMD C++ linear algebra library
9
-
-**Language**: C++
9
+
-**Language**: C++ (minimum C++11; C++14, C++17, and C++20 features used conditionally)
10
10
-**Framework / Libraries**: STL / CMake / CTest
11
+
-**Compiler Requirement**: Visual C++ 2017 or later (`_MSC_VER >= 1910`) when using MSVC
11
12
12
13
## Getting Started
13
14
@@ -20,6 +21,7 @@ These instructions define how GitHub Copilot should assist with this project. Th
20
21
## General Guidelines
21
22
22
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`.
23
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
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.
25
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).
@@ -34,18 +36,274 @@ These instructions define how GitHub Copilot should assist with this project. Th
34
36
.azuredevops/ # Azure DevOps pipeline configuration and policy files.
35
37
.github/ # GitHub Actions workflow files and linter configuration files.
Inc/ # DirectXMath public and implementation files. The library is header-only, so all files are in this directory.
39
41
Extensions/ # Extensions to the DirectXMath library with standalone SSE-level specific functions for runtime selection of SIMD instruction set.
40
42
MatrixStack/ # D3DX9-like matrix stack implementation for DirectXMath.
41
43
SHMath/ # Spherical harmonic functions using DirectXMath.
42
44
Stereo3D/ # Stereo 3D projection matrix functions using DirectXMath created for HoloLens.
43
45
XDSP/ # Digital Signal Processing (DSP) functions using DirectXMath.
44
46
Tests/ # Tests are designed to be cloned from a separate repository at this location.
47
+
wiki/ # Local clone of the GitHub wiki documentation repository.
45
48
```
46
49
47
50
> The `Extensions` are not needed if building the library using `/arch:AVX` or `/arch:AVX2` which causes the DirectXMath library to build utilizing the additional SIMD instructions.
48
51
52
+
### Public Header Files (`Inc/`)
53
+
54
+
| File | Purpose |
55
+
| --- | --- |
56
+
|`DirectXMath.h`| Core library: types, constants, vector and matrix math functions |
57
+
|`DirectXMathConvert.inl`| Implementation of type conversion / load / store functions |
58
+
|`DirectXMathMatrix.inl`| Implementation of matrix math functions |
59
+
|`DirectXMathMisc.inl`| Implementation of miscellaneous functions (quaternion, color, plane, etc.) |
60
+
|`DirectXMathVector.inl`| Implementation of vector math functions |
Each extension header provides optimized overrides for a specific instruction set tier. They must be included **after**`DirectXMath.h` and live in their own sub-namespace:
_XM_ARM_NEON_INTRINSICS_ (auto-enabled for ARM/ARM64)
104
+
_XM_NO_INTRINSICS_ (pure C++ fallback; force with this define)
105
+
```
106
+
107
+
Optional macros:
108
+
- `_XM_SVML_INTRINSICS_` — Intel Short Vector Math Library (auto-enabled with MSVC 2019+; opt-out with `_XM_DISABLE_INTEL_SVML_`)
109
+
- `_XM_NO_MOVNT_` — Disables non-temporal store instructions (`_mm_stream_ps`, etc.)
110
+
- `_XM_FAVOR_INTEL_` — Uses `_mm_permute_ps` (AVX) over `_mm_shuffle_ps` when available
111
+
- `_XM_NO_XMVECTOR_OVERLOADS_` — Disables `XMVECTOR` arithmetic operators (auto-set for GCC/Clang)
112
+
113
+
When writing multi-path implementations, follow this pattern:
114
+
115
+
```cpp
116
+
#if defined(_XM_NO_INTRINSICS_)
117
+
// Pure C++ path
118
+
#elif defined(_XM_ARM_NEON_INTRINSICS_)
119
+
// ARM NEON path
120
+
#elif defined(_XM_AVX2_INTRINSICS_)
121
+
// AVX2 path
122
+
#elif defined(_XM_SSE4_INTRINSICS_)
123
+
// SSE4.1 path
124
+
#elif defined(_XM_SSE_INTRINSICS_)
125
+
// SSE/SSE2 path (baseline for x86/x64)
126
+
#endif
127
+
```
128
+
129
+
## Core Type System
130
+
131
+
### Computation Type
132
+
133
+
`XMVECTOR` is the fundamental 128-bit SIMD register type. It maps to `__m128` (SSE), `float32x4_t` (ARM NEON), or a plain struct (no-intrinsics). It must be **16-byte aligned**.
134
+
135
+
### Storage Types
136
+
137
+
Storage types hold data in memory. Use `XMLoad*` / `XMStore*` to move between storage and `XMVECTOR`.
XMVECTOR and XMMATRIX have special parameter-passing typedefs to maximize register usage. **Always use these instead of raw `XMVECTOR`/`XMMATRIX` for function parameters.**
162
+
163
+
| Typedef | Purpose |
164
+
| --- | --- |
165
+
|`FXMVECTOR`| 1st–3rd `XMVECTOR` parameters (in-register on x86/ARM/ARM64/vectorcall) |
166
+
|`GXMVECTOR`| 4th `XMVECTOR` parameter (in-register on ARM/ARM64/vectorcall) |
167
+
|`HXMVECTOR`| 5th–6th `XMVECTOR` parameters (in-register on ARM64/vectorcall) |
168
+
|`CXMVECTOR`| 7th+ `XMVECTOR` parameters (always by `const` reference) |
169
+
|`FXMMATRIX`| 1st `XMMATRIX` parameter (in-register on ARM64/vectorcall) |
170
+
|`CXMMATRIX`| 2nd+ `XMMATRIX` parameters (always by `const` reference) |
171
+
172
+
All functions that take or return `XMVECTOR`/`XMMATRIX` must use `XM_CALLCONV`:
0 commit comments