Skip to content

Commit 5627c77

Browse files
authored
Minor code review and CoPilot instructions update (#243)
1 parent 8c8a352 commit 5627c77

File tree

8 files changed

+68
-12
lines changed

8 files changed

+68
-12
lines changed

.azuredevops/pipelines/DirectXMesh-GitHub-CMake-Dev17.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ variables:
5757
Codeql.Enabled: false
5858
VS_GENERATOR: 'Visual Studio 17 2022'
5959
WIN10_SDK: '10.0.19041.0'
60-
WIN11_SDK: '10.0.22000.0'
60+
WIN11_SDK: '10.0.26100.0'
6161

6262
pool:
6363
vmImage: windows-2022

.azuredevops/pipelines/DirectXMesh-GitHub-CMake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ variables:
5757
Codeql.Enabled: false
5858
VS_GENERATOR: 'Visual Studio 17 2022'
5959
WIN10_SDK: '10.0.19041.0'
60-
WIN11_SDK: '10.0.22000.0'
60+
WIN11_SDK: '10.0.26100.0'
6161

6262
pool:
6363
vmImage: windows-2022

.azuredevops/pipelines/DirectXMesh-OneFuzz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
3232
variables:
3333
Codeql.Enabled: false
3434
VS_GENERATOR: 'Visual Studio 17 2022'
35-
WIN11_SDK: '10.0.22000.0'
35+
WIN11_SDK: '10.0.26100.0'
3636

3737
pool:
3838
vmImage: windows-2022

.github/copilot-instructions.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ These instructions define how GitHub Copilot should assist with this project. Th
2323
- **Documentation**: The project provides documentation in the form of wiki pages available at [Documentation](https://github.com/microsoft/DirectXMesh/wiki/).
2424
- **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.
2525
- **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).
26-
- **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. Functions that read input from geometry files are subject to OneFuzz testing to ensure they are secure against malformed files.
26+
- **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. Functions that read input from geometry files are subject to OneFuzz fuzz testing to ensure they are secure against malformed files.
2727
- **Dependencies**: The project uses CMake and VCPKG for managing dependencies, making optional use of DirectXMath and DirectX-Headers. The project can be built without these dependencies, relying on the Windows SDK for core functionality.
2828
- **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 a subset of unit tests, and static code analysis including GitHub super-linter, CodeQL, and MSVC Code Analysis.
2929
- **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.
@@ -61,11 +61,13 @@ Tests/ # Tests are designed to be cloned from a separate repository at th
6161

6262
## References
6363

64+
- [Source git repository on GitHub](https://github.com/microsoft/DirectXMesh.git)
65+
- [DirectXMesh documentation git repository on GitHub](https://github.com/microsoft/DirectXMesh.wiki.git)
66+
- [DirectXMesh test suite git repository on GitHub](https://github.com/walbourn/directxmeshtest.wiki.git).
6467
- [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)
6568
- [Microsoft Secure Coding Guidelines](https://learn.microsoft.com/en-us/security/develop/secure-coding-guidelines)
6669
- [CMake Documentation](https://cmake.org/documentation/)
67-
- [VCPK Documentation](https://learn.microsoft.com/vcpkg/)
68-
- [DirectXMesh Wiki](https://github.com/microsoft/DirectXMesh/wiki/)
70+
- [VCPKG Documentation](https://learn.microsoft.com/vcpkg/)
6971
- [Games for Windows and the DirectX SDK blog - June 2014](https://walbourn.github.io/directxmesh/)
7072
- [Games for Windows and the DirectX SDK blog - April 2025](https://walbourn.github.io/github-project-updates-2025/)
7173

@@ -96,3 +98,41 @@ When creating documentation:
9698
- Review each documented item against source code whenever related to the task.
9799
- Remove any speculative content.
98100
- Ensure all documentation is verifiable against the current state of the codebase.
101+
102+
## Cross-platform Support Notes
103+
104+
- The code supports building for Windows and Linux.
105+
- Portability and conformance of the code is validated by building with Visual C++, clang/LLVM for Windows, MinGW, and GCC for Linux.
106+
107+
The following symbols are not custom error codes, but aliases for `HRESULT_FROM_WIN32` error values.
108+
109+
| Symbol | Standard Win32 HRESULT |
110+
|--------|-------------|
111+
| `HRESULT_E_ARITHMETIC_OVERFLOW` | `HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)` |
112+
| `HRESULT_E_NOT_SUPPORTED` | `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)` |
113+
| `HRESULT_E_INVALID_NAME` | `HRESULT_FROM_WIN32(ERROR_INVALID_NAME)` |
114+
115+
## Code Review Instructions
116+
117+
When reviewing code, focus on the following aspects:
118+
119+
- Adherence to coding standards defined in `.editorconfig` and on the [wiki](https://github.com/microsoft/DirectXTK/wiki/Implementation).
120+
- Make coding recommendations based on the *C++ Core Guidelines*.
121+
- Proper use of RAII and smart pointers.
122+
- Correct error handling practices and C++ Exception safety.
123+
- Clarity and maintainability of the code.
124+
- Adequate comments where necessary.
125+
- Public interfaces located in `DirectXMesh.h` should be clearly defined and documented on the GitHub wiki.
126+
- Compliance with the project's architecture and design patterns.
127+
- Ensure that all public functions and classes are covered by unit tests located on [GitHub](https://github.com/walbourn/directxmeshtest.git) where applicable. Report any gaps in test coverage.
128+
- Check for performance implications, especially in geometry processing algorithms.
129+
- Provide brutally honest feedback on code quality, design, and potential improvements as needed.
130+
131+
## Documentation Review Instructions
132+
133+
When reviewing documentation, do the following:
134+
135+
- Read the code located in [this git repository](https://github.com/microsoft/DirectXMesh.git) in the main branch.
136+
- Review the public interface defined in `DirectXMesh.h`, as well as the headers in the `Utilities` folder.
137+
- Read the documentation on the wiki located in [this git repository](https://github.com/microsoft/DirectXMesh.wiki.git).
138+
- Report any specific gaps in the documentation compared to the public interface.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*.VC.db
1919
*.nupkg
2020
.vs
21+
.vscode
2122
[Bb]in
2223
/ipch
2324
Debug

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
3131

3232
option(ENABLE_CODE_COVERAGE "Build with code-coverage" OFF)
3333

34+
option(ENABLE_CODE_PROFILING "Build for profiling" OFF)
35+
3436
option(BUILD_FUZZING "Build for fuzz testing" OFF)
3537

3638
set(CMAKE_CXX_STANDARD 17)
@@ -286,6 +288,13 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
286288
endforeach()
287289
endif()
288290

291+
if(ENABLE_CODE_PROFILING)
292+
message(STATUS "Building with /PROFILE")
293+
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
294+
target_link_options(${t} PRIVATE /profile)
295+
endforeach()
296+
endif()
297+
289298
if(ENABLE_SPECTRE_MITIGATION
290299
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.13)
291300
AND (NOT WINDOWS_STORE))

DirectXMesh/DirectXMeshUtil.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ void DirectX::ComputeInputLayout(
270270
{
271271
assert(IsValid(vbDecl, nDecl));
272272

273+
if (!vbDecl || !nDecl)
274+
return;
275+
273276
if (offsets)
274277
memset(offsets, 0, sizeof(uint32_t) * nDecl);
275278

@@ -334,6 +337,9 @@ void DirectX::ComputeInputLayout(const D3D12_INPUT_LAYOUT_DESC& vbDecl,
334337
{
335338
assert(IsValid(vbDecl));
336339

340+
if (!vbDecl.pInputElementDescs || !vbDecl.NumElements)
341+
return;
342+
337343
if (offsets)
338344
memset(offsets, 0, sizeof(uint32_t) * vbDecl.NumElements);
339345

Utilities/FlexibleVertexFormat.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace FVF
4242

4343
static_assert(std::size(g_declTypeSizes) == D3DDECLTYPE_UNUSED, "Mismatch of array size");
4444

45-
inline size_t ComputeVertexSize(uint32_t fvfCode)
45+
inline size_t ComputeVertexSize(uint32_t fvfCode) noexcept
4646
{
4747
if ((fvfCode & ((D3DFVF_RESERVED0 | D3DFVF_RESERVED2) & ~D3DFVF_POSITION_MASK)) != 0)
4848
return 0;
@@ -109,7 +109,7 @@ namespace FVF
109109
return vertexSize;
110110
}
111111

112-
inline size_t ComputeVertexSize(const D3DVERTEXELEMENT9* pDecl, uint32_t stream)
112+
inline size_t ComputeVertexSize(const D3DVERTEXELEMENT9* pDecl, uint32_t stream) noexcept
113113
{
114114
if (!pDecl || stream >= 16u /*D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT*/)
115115
return 0;
@@ -145,7 +145,7 @@ namespace FVF
145145

146146
// More secure version
147147
inline size_t ComputeVertexSize(
148-
_In_reads_(maxDeclLength) const D3DVERTEXELEMENT9* pDecl, size_t maxDeclLength, uint32_t stream)
148+
_In_reads_(maxDeclLength) const D3DVERTEXELEMENT9* pDecl, size_t maxDeclLength, uint32_t stream) noexcept
149149
{
150150
if (!pDecl || stream >= 16u /*D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT*/)
151151
return 0;
@@ -182,7 +182,7 @@ namespace FVF
182182
return currentSize;
183183
}
184184

185-
inline size_t GetDeclLength(const D3DVERTEXELEMENT9* pDecl)
185+
inline size_t GetDeclLength(const D3DVERTEXELEMENT9* pDecl) noexcept
186186
{
187187
if (!pDecl)
188188
return 0;
@@ -639,7 +639,7 @@ namespace FVF
639639
}
640640
#endif // __d3d12_h__
641641

642-
inline uint32_t ComputeFVF(const D3DVERTEXELEMENT9* pDecl)
642+
inline uint32_t ComputeFVF(const D3DVERTEXELEMENT9* pDecl) noexcept
643643
{
644644
if (!pDecl)
645645
return 0;
@@ -832,7 +832,7 @@ namespace FVF
832832

833833
// More secure version
834834
inline uint32_t ComputeFVF(
835-
_In_reads_(maxDeclLength) const D3DVERTEXELEMENT9* pDecl, size_t maxDeclLength)
835+
_In_reads_(maxDeclLength) const D3DVERTEXELEMENT9* pDecl, size_t maxDeclLength) noexcept
836836
{
837837
if (!pDecl)
838838
return 0;

0 commit comments

Comments
 (0)