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
+147-2Lines changed: 147 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,8 @@ These instructions define how GitHub Copilot should assist with this project. Th
19
19
20
20
## General Guidelines
21
21
22
-
-**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/DirectXTK/wiki/Implementation). The code requires C++11/C++14 features.
22
+
-**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/DirectXTK/wiki/Implementation). The library implementation is written to be compatible with C++14 features, but C++17 is required to build the project for the command-line tools which utilize C++17 filesystem for long file path support.
23
+
> 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
24
-**Documentation**: The project provides documentation in the form of wiki pages available at [Documentation](https://github.com/microsoft/DirectXMesh/wiki/).
24
25
-**Error Handling**: Use C++ exceptions for error handling and uses RAII smart pointers to ensure resources are properly managed. For some functions that return HRESULT error codes, they are marked `noexcept`, use `std::nothrow` for memory allocation, and should not throw exceptions.
25
26
-**Testing**: Unit tests for this project are implemented in this repository [Test Suite](https://github.com/walbourn/directxmeshtest/) and can be run using CTest per the instructions at [Test Documentation](https://github.com/walbourn/directxmeshtest/wiki).
Utilities/ # Utility headers such as a WaveFront .obj file loader and a FVF converter.
40
41
Meshconvert/ # CLI tool for importing WaveFront .obj files and converting to CMO, SDKMESH, or VBO formats.
41
42
Tests/ # Tests are designed to be cloned from a separate repository at this location.
43
+
wiki/ # Local clone of the GitHub wiki documentation repository.
42
44
```
43
45
44
46
## Patterns
@@ -51,6 +53,90 @@ Tests/ # Tests are designed to be cloned from a separate repository at th
51
53
- Use `Microsoft::WRL::ComPtr` for COM object management.
52
54
- Make use of anonymous namespaces to limit scope of functions and variables.
53
55
- Make use of `assert` for debugging checks, but be sure to validate input parameters in release builds.
56
+
- Explicitly `= delete` copy constructors and copy-assignment operators on all classes that use the pImpl idiom.
57
+
- Explicitly utilize `= default` or `=delete` for copy constructors, assignment operators, move constructors and move-assignment operators where appropriate.
58
+
- Use 16-byte alignment (`_aligned_malloc` / `_aligned_free`) to support SIMD operations in the implementation, but do not expose this requirement in public APIs.
59
+
> For non-Windows support, the implementation uses C++17 `aligned_alloc` instead of `_aligned_malloc`.
60
+
61
+
#### SAL Annotations
62
+
63
+
All public API functions must use SAL annotations on every parameter. Use `_Use_decl_annotations_` at the top of each implementation that has SAL in the header declaration — never repeat the annotations in the `.cpp` or `.inl` file.
64
+
65
+
Common annotations:
66
+
67
+
| Annotation | Meaning |
68
+
| --- | --- |
69
+
|`_In_`| Input parameter |
70
+
|`_In_opt_`| Optional input pointer |
71
+
|`_In_z_`| Null-terminated input string |
72
+
|`_In_reads_(n)`| Input array with element count |
73
+
|`_In_reads_bytes_(n)`| Input buffer with byte count |
74
+
|`_In_reads_opt_(n)`| Optional input array with element count |
75
+
|`_Out_`| Output parameter |
76
+
|`_Out_opt_`| Optional output pointer |
77
+
|`_Out_writes_(n)`| Output array with element count |
78
+
|`_Out_writes_opt_(n)`| Optional output array with element count |
79
+
|`_Out_writes_bytes_(n)`| Output buffer with byte count |
80
+
|`_Inout_`| Bidirectional parameter |
81
+
|`_Inout_updates_all_(n)`| In-place update of entire array |
- All public functions use `__cdecl` explicitly for ABI stability.
108
+
- All public function declarations are prefixed with `DIRECTX_MESH_API`, which wraps `__declspec(dllexport)` / `__declspec(dllimport)` (or the MinGW `__attribute__` equivalent) when the `DIRECTX_MESH_EXPORT` or `DIRECTX_MESH_IMPORT` preprocessor symbols are defined. CMake sets these automatically when `BUILD_SHARED_LIBS=ON`.
109
+
110
+
#### `noexcept` Rules
111
+
112
+
- All query and utility functions that cannot fail (e.g., `IsValidVB`, `IsValidIB`) are marked `noexcept`.
113
+
- All HRESULT-returning I/O and processing functions are also `noexcept` — errors are communicated via return code, never via exceptions.
114
+
- Constructors and functions that perform heap allocation or utilize Standard C++ containers that may throw are marked `noexcept(false)`.
115
+
116
+
#### Enum Flags Pattern
117
+
118
+
Flags enums follow this pattern — a `uint32_t`-based unscoped enum with a `_NONE = 0x0` base case, followed by a call to `DEFINE_ENUM_FLAG_OPERATORS` (defined in `DirectXMesh.inl`) to enable `|`, `&`, and `~` operators:
119
+
120
+
```cpp
121
+
enum CNORM_FLAGS : uint32_t
122
+
{
123
+
CNORM_DEFAULT = 0x0,
124
+
// Default is to compute normals using weight-by-angle
125
+
126
+
CNORM_WEIGHT_BY_AREA = 0x1,
127
+
// Computes normals using weight-by-area
128
+
129
+
CNORM_WEIGHT_EQUAL = 0x2,
130
+
// Compute normals with equal weights
131
+
132
+
CNORM_WIND_CW = 0x4,
133
+
// Vertices are clock-wise (defaults to CCW)
134
+
};
135
+
136
+
DEFINE_ENUM_FLAG_OPERATORS(CNORM_FLAGS);
137
+
```
138
+
139
+
See [this blog post](https://walbourn.github.io/modern-c++-bitmask-types/) for more information on this pattern.
54
140
55
141
### Patterns to Avoid
56
142
@@ -59,6 +145,40 @@ Tests/ # Tests are designed to be cloned from a separate repository at th
59
145
- Don’t put implementation logic in header files unless using templates, although the SimpleMath library does use an .inl file for performance.
60
146
- Avoid using `using namespace` in header files to prevent polluting the global namespace.
|`USING_DIRECTX_HEADERS`| External DirectX-Headers package in use |
245
+
246
+
> `_M_ARM`/ `__arm__` is legacy 32-bit ARM which is deprecated.
247
+
248
+
Non-Windows builds (Linux/WSL) omit WIC entirely and use `<directx/dxgiformat.h>` and `<wsl/winadapter.h>` from the DirectX-Headers package instead of the Windows SDK.
249
+
250
+
### Error Codes
106
251
107
252
The following symbols are not custom error codes, but aliases for `HRESULT_FROM_WIN32` error values.
0 commit comments