Skip to content

ID3D12Device::GetAdapterLuid crashes. #1436

@Tape-Worm

Description

@Tape-Worm

Actual behavior

When calling the GetAdapterLuid method on the ID3D12Device interface, I get this:

Image

It errors on ID3D12Device and ID3D12Device14 (latest). I tried the code in C++ and it worked perfectly, so it's an issue with the generated code.

Expected behavior

It should return a populated LUID structure.

Repro steps

  1. NativeMethods.txt content:
DXGI_ERROR_*
D3D_FEATURE_LEVEL
D3D12_*

DXGI_MODE_DESC1

CreateDXGIFactory2
D3D12CreateDevice
IDXGIFactory2
IDXGIFactory7
IDXGIAdapter4
IDXGIOutput6
ID3D12Device
ID3D12Device14
  1. NativeMethods.json content (if present):
{
    "$schema": "https://aka.ms/CsWin32.schema.json",
    "emitSingleFile": false,
    "useSafeHandles": false,
    "allowMarshaling": false
}
  1. Any of your own code that should be shared?

Try something along these lines.

IDXGIFactory7* factory = null;
IDXGIAdapter1* adapter1 = null;
IDXGIAdapter4* adapter4 = null;
ID3D12Device14* d3dDevice = null;


PInvoke.CreateDXGIFactory2(flags, typeof(IDXGIFactory7).GUID, out void* obj);
factory = (IDXGIFactory7*)obj;
factory->EnumAdapters1((uint)devices.Count, &adapter1);
adapter1->QueryInterface(out adapter4);

PInvoke.D3D12CreateDevice((IUnknown*)adapter4, Windows.Win32.Graphics.Direct3D.D3D_FEATURE_LEVEL.D3D_FEATURE_LEVEL_12_0, typeof(ID3D12Device14).GUID, (void**)&d3dDevice);

LUID luid = d3dDevice->GetAdapterLuid();

Context

  • CsWin32 version: 0.3.183
  • Target Framework: .net 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions