microsoft / microsoft/wdkmetadata
D3D12UMDDI Metadata
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 110
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
I am working on a Direct3D user mode driver in Rust. Currently I'm just generating bindings with bindgen from the WDK's d3d12umddi.h and d3d10umddi.h headers.
It would be nice to have the metadata for these APIs so they're available through the windows-sys crate.
I tried modyfing generation/WDK/Partitions/Direct3D/main.cpp and generation/WDK/Partitions/Direct3D/settings.rsp.
diff --git a/generation/WDK/Partitions/Direct3D/main.cpp b/generation/WDK/Partitions/Direct3D/main.cpp
index fa23b29..3c6f0a8 100644
--- a/generation/WDK/Partitions/Direct3D/main.cpp
+++ b/generation/WDK/Partitions/Direct3D/main.cpp
@@ -4,4 +4,9 @@
#include <d3d9.h>
#include <d3dhal.h>
-#include <d3dnthal.h>
\ No newline at end of file
+#include <d3dnthal.h>
+#include <dxgiddi.h>
+#include <d3d11TokenizedProgramFormat.hpp>
+#include <d3dumddi.h>
+#include <d3d10umddi.h>
+#include <d3d12umddi.h>
\ No newline at end of file
diff --git a/generation/WDK/Partitions/Direct3D/settings.rsp b/generation/WDK/Partitions/Direct3D/settings.rsp
index 2b42324..3383cf8 100644
--- a/generation/WDK/Partitions/Direct3D/settings.rsp
+++ b/generation/WDK/Partitions/Direct3D/settings.rsp
@@ -4,5 +4,10 @@
<IncludeRoot>/shared/d3dukmdt.h
<IncludeRoot>/um/d3dhal.h
<IncludeRoot>/um/d3dnthal.h
+<IncludeRoot>/um/dxgiddi.h
+<IncludeRoot>/um/d3d11TokenizedProgramFormat.hpp
+<IncludeRoot>/um/d3dumddi.h
+<IncludeRoot>/um/d3d10umddi.h
+<IncludeRoot>/um/d3d12umddi.h
--namespace
Windows.Wdk.Graphics.Direct3D
\ No newline at end of file
I got this far with including the necessary headers. But I get some errors from the generated C# code:
C:\Users\serranok\.nuget\packages\microsoft.windows.winmdgenerator\0.63.31-preview\Sdk\Sdk.targets(271,5): error : C:\git\wdkmetadata\generation\WDK\obj\generated\obj\crossarch\common\Direct3D.modified.cs(42678,198): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context [C:\git\wdkmetadata\generation\WDK\Windows.Wdk.proj]
C:\Users\serranok\.nuget\packages\microsoft.windows.winmdgenerator\0.63.31-preview\Sdk\Sdk.targets(271,5): error : C:\git\wdkmetadata\generation\WDK\obj\generated\obj\crossarch\common\Direct3D.modified.cs(42688,200): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context [C:\git\wdkmetadata\generation\WDK\Windows.Wdk.proj]
C:\Users\serranok\.nuget\packages\microsoft.windows.winmdgenerator\0.63.31-preview\Sdk\Sdk.targets(271,5): error : C:\git\wdkmetadata\generation\WDK\obj\generated\obj\crossarch\common\Direct3D.modified.cs(43491,221): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context [C:\git\wdkmetadata\generation\WDK\Windows.Wdk.proj]
C:\Users\serranok\.nuget\packages\microsoft.windows.winmdgenerator\0.63.31-preview\Sdk\Sdk.targets(271,5): error : C:\git\wdkmetadata\generation\WDK\obj\generated\obj\crossarch\common\Direct3D.modified.cs(43492,223): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context [C:\git\wdkmetadata\generation\WDK\Windows.Wdk.proj]
C:\Users\serranok\.nuget\packages\microsoft.windows.winmdgenerator\0.63.31-preview\Sdk\Sdk.targets(271,5): error : C:\git\wdkmetadata\generation\WDK\obj\generated\obj\crossarch\common\Direct3D.modified.cs(50592,178): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context [C:\git\wdkmetadata\generation\WDK\Windows.Wdk.proj]
C:\Users\serranok\.nuget\packages\microsoft.windows.winmdgenerator\0.63.31-preview\Sdk\Sdk.targets(271,5): error : [C:\git\wdkmetadata\generation\WDK\Windows.Wdk.proj]
0 Warning(s)
6 Error(s)
Looking at the last error in the generated C# file and it seems like it's not adding the unsafe keyword to the PFND3D12DDI_OM_SETBLENDFACTOR function. Some functions before it do have the unsafe keyword.
Direct3D.modified.cs(50591-50593):
[UnmanagedFunctionPointer(CallingConvention.Winapi)] public unsafe delegate void PFND3D12DDI_RS_SETSCISSORRECTS_0003(D3D12DDI_HCOMMANDLIST param0, uint Count, [NativeTypeName("const D3D12DDI_RECT *"),Const][NativeArrayInfo(CountParamIndex = 1),In]RECT* param2);
[UnmanagedFunctionPointer(CallingConvention.Winapi)] public delegate void PFND3D12DDI_OM_SETBLENDFACTOR(D3D12DDI_HCOMMANDLIST param0, [NativeTypeName("const FLOAT[4]"),Const]float* param1);
[UnmanagedFunctionPointer(CallingConvention.Winapi)] public delegate void PFND3D12DDI_OM_SETSTENCILREF(D3D12DDI_HCOMMANDLIST param0, uint param1);
So maybe something needs to be changed in the code generator so that it adds this unsafe keyword.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with generation/WDK/Partitions/Direct3D/main.cpp and settings.rsp, then reproduce the Windows.Wdk.proj generation using the added Direct3D headers. Inspect the reported lines in Direct3D.modified.cs and compare the unsafe delegates with PFND3D12DDI_OM_SETBLENDFACTOR. Done means the generated C# compiles without CS0214 errors and exposes the requested metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp, rust
- Domain
- computer-graphics, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100