It seems that one of the overloads of the ID3D12Device1.CreateRootSignature(...) method throws an exception
Aycon3296 opened this issue · 1 comments
Summary
One of the signatures throws an exception
InternalException: "ArgumentException: Value does not fall within the expected range."
while the other does not:
unsafe
{
// This is work
_hResult = s_device1.CreateRootSignature(nodeMask: 0, _signature.GetBufferPointer(), _signature.GetBufferSize(), out s_rootSignature);
SilkMarshal.ThrowHResult(_hResult);
}
unsafe
{
// This is NOT work
_hResult = s_device1.CreateRootSignature(nodeMask: 0, in _signature, _signature.GetBufferSize(), out s_rootSignature);
SilkMarshal.ThrowHResult(_hResult);
}
It seems the function is being called with different parameters pBlobWithRootSignature:

Steps to reproduce
- Platform: Desktop
- Framework Version: .NET Core 8.0
- API: DirectX 3D
- API Version: Direct3D 12
Call the "ID3D12Device1.CreateRootSignature" overload (line 5841 in Silk.NET.Direct3D12.ID3D12Device1VtblExtentions.cs):
public unsafe static int CreateRootSignature<T0, TI0>(this ComPtr<ID3D12Device1> thisVtbl, uint nodeMask, [Flow(FlowDirection.In)][RequiresLocation] in T0 pBlobWithRootSignature, nuint blobLengthInBytes, out ComPtr<TI0> ppvRootSignature) where T0 : unmanaged where TI0 : unmanaged, IComVtbl<TI0>
Full example of usage:
private static void CreateRootSignature()
{
HResult _hResult;
RootSignatureDesc _signatureDesc = new()
{
NumParameters = 0,
PParameters = null,
NumStaticSamplers = 0,
PStaticSamplers = null,
Flags = RootSignatureFlags.AllowInputAssemblerInputLayout
};
ComPtr<ID3D10Blob> _signature = new();
ComPtr<ID3D10Blob> _error = new();
_hResult = s_d3d12.SerializeRootSignature(ref _signatureDesc, D3DRootSignatureVersion.Version1, ref _signature, ref _error);
SilkMarshal.ThrowHResult(_hResult);
// Error handling...
_hResult = s_device1.CreateRootSignature(nodeMask: 0, in _signature, _signature.GetBufferSize(), out s_rootSignature);
SilkMarshal.ThrowHResult(_hResult);
}
Comments
The third line here looks quite suspicious (call nested):
fixed (T0* ptr2 = &pBlobWithRootSignature)
{
void* ptr3 = ptr2;
result = ((delegate* unmanaged[Stdcall]<ID3D12Device1*, uint, void*, UIntPtr, Guid*, void**, int>)ptr->LpVtbl[16])(ptr, nodeMask, ptr3, blobLengthInBytes, riid, ppvRootSignature);
}
This is expected, in _signature and _signature.GetBufferPointer() are not equal.