Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add windows.graphics.directx.direct3d11.interop.h #106

Merged
merged 3 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion generation/remap.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ ID3D12InfoQueue.GetMessageW=GetMessage
IDWriteFontFace.GetGlyphIndicesW=GetGlyphIndices
IDxDiagContainer.GetPropW=GetProp
IDXGIInfoQueue.GetMessageW=GetMessage
IInspectable*=void*
ima_adpcmwaveformat_tag=IMAADPCMWAVEFORMAT
IMediaSeeking.GetTimeFormatW=GetTimeFormat
IMFAsyncResult.GetObjectW=GetObject
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@../../settings.rsp
@../../remap.rsp
--file
um-windows.graphics.directx.direct3d11.interop.h
--output
../../../sources/Interop/Windows/um/windows.graphics.directx.direct3d11.interop
--test-output
../../../tests/Interop/Windows/um/windows.graphics.directx.direct3d11.interop
--traverse
C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/um/windows.graphics.directx.direct3d11.interop.h
--with-attribute
IDirect3DDxgiInterfaceAccess=Guid("A9B3D012-3DF2-4EE3-B8D1-8695F457D3C1")
--with-librarypath
*=d3d11
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/windows.graphics.directx.direct3d11.interop.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <Windows.h>
#include <windows.graphics.directx.direct3d11.interop.h>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/windows.graphics.directx.direct3d11.interop.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace TerraFX.Interop
{
[Guid("A9B3D012-3DF2-4EE3-B8D1-8695F457D3C1")]
public unsafe partial struct IDirect3DDxgiInterfaceAccess
{
public void** lpVtbl;

[return: NativeTypeName("HRESULT")]
public int QueryInterface([NativeTypeName("const IID &")] Guid* riid, [NativeTypeName("void **")] void** ppvObject)
{
return ((delegate* stdcall<IDirect3DDxgiInterfaceAccess*, Guid*, void**, int>)(lpVtbl[0]))((IDirect3DDxgiInterfaceAccess*)Unsafe.AsPointer(ref this), riid, ppvObject);
}

[return: NativeTypeName("ULONG")]
public uint AddRef()
{
return ((delegate* stdcall<IDirect3DDxgiInterfaceAccess*, uint>)(lpVtbl[1]))((IDirect3DDxgiInterfaceAccess*)Unsafe.AsPointer(ref this));
}

[return: NativeTypeName("ULONG")]
public uint Release()
{
return ((delegate* stdcall<IDirect3DDxgiInterfaceAccess*, uint>)(lpVtbl[2]))((IDirect3DDxgiInterfaceAccess*)Unsafe.AsPointer(ref this));
}

[return: NativeTypeName("HRESULT")]
public int GetInterface([NativeTypeName("const IID &")] Guid* iid, [NativeTypeName("void **")] void** p)
{
return ((delegate* stdcall<IDirect3DDxgiInterfaceAccess*, Guid*, void**, int>)(lpVtbl[3]))((IDirect3DDxgiInterfaceAccess*)Unsafe.AsPointer(ref this), iid, p);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/windows.graphics.directx.direct3d11.interop.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.

using System;
using System.Runtime.InteropServices;

namespace TerraFX.Interop
{
public static unsafe partial class Windows
{
public static readonly Guid IID_IDirect3DDxgiInterfaceAccess = new Guid(0xA9B3D012, 0x3DF2, 0x4EE3, 0xB8, 0xD1, 0x86, 0x95, 0xF4, 0x57, 0xD3, 0xC1);

public static IInspectable* CreateDirect3DDevice(IDXGISurface* dxgiSurface)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an exclusion missing for this or did ClangSharp ignore it due to __cplusplus_winrt not being defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is ignored since it's under that define. Clang would have choked on the C++/CX if it was being processed.

{
IInspectable* inspectableSurface;
Marshal.ThrowExceptionForHR(CreateDirect3D11SurfaceFromDXGISurface(dxgiSurface, &inspectableSurface));
return inspectableSurface;
}

public static int GetDXGIInterfaceFromObject(IInspectable* @object, Guid* iid, void** p)
{
IDirect3DDxgiInterfaceAccess* dxgiInterfaceAccess;

var dxgi_iid = IID_IDirect3DDxgiInterfaceAccess;
int hr = @object->QueryInterface(&dxgi_iid, (void**) &dxgiInterfaceAccess);

if (SUCCEEDED(hr))
{
hr = dxgiInterfaceAccess->GetInterface(iid, p);
}

dxgiInterfaceAccess->Release();
return hr;
}

public static int GetDXGIInterface<DXGI_TYPE>(IInspectable* @object, DXGI_TYPE** dxgi)
where DXGI_TYPE : unmanaged
{
var guid = typeof(DXGI_TYPE).GUID;
return GetDXGIInterfaceFromObject(@object, &guid, (void**) dxgi);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/windows.graphics.directx.direct3d11.interop.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.

using System.Runtime.InteropServices;

namespace TerraFX.Interop
{
public static unsafe partial class Windows
{
[DllImport("d3d11", EntryPoint = "CreateDirect3D11DeviceFromDXGIDevice", ExactSpelling = true)]
[return: NativeTypeName("HRESULT")]
public static extern int CreateDirect3D11DeviceFromDXGIDevice([NativeTypeName("IDXGIDevice *")] IDXGIDevice* dxgiDevice, [NativeTypeName("IInspectable **")] IInspectable** graphicsDevice);

[DllImport("d3d11", EntryPoint = "CreateDirect3D11SurfaceFromDXGISurface", ExactSpelling = true)]
[return: NativeTypeName("HRESULT")]
public static extern int CreateDirect3D11SurfaceFromDXGISurface([NativeTypeName("IDXGISurface *")] IDXGISurface* dgxiSurface, [NativeTypeName("IInspectable **")] IInspectable** graphicsSurface);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/windows.graphics.directx.direct3d11.interop.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.

using NUnit.Framework;
using System;
using System.Runtime.InteropServices;
using static TerraFX.Interop.Windows;

namespace TerraFX.Interop.UnitTests
{
/// <summary>Provides validation of the <see cref="IDirect3DDxgiInterfaceAccess" /> struct.</summary>
public static unsafe class IDirect3DDxgiInterfaceAccessTests
{
/// <summary>Validates that the <see cref="Guid" /> of the <see cref="IDirect3DDxgiInterfaceAccess" /> struct is correct.</summary>
[Test]
public static void GuidOfTest()
{
Assert.That(typeof(IDirect3DDxgiInterfaceAccess).GUID, Is.EqualTo(IID_IDirect3DDxgiInterfaceAccess));
}

/// <summary>Validates that the <see cref="IDirect3DDxgiInterfaceAccess" /> struct is blittable.</summary>
[Test]
public static void IsBlittableTest()
{
Assert.That(Marshal.SizeOf<IDirect3DDxgiInterfaceAccess>(), Is.EqualTo(sizeof(IDirect3DDxgiInterfaceAccess)));
}

/// <summary>Validates that the <see cref="IDirect3DDxgiInterfaceAccess" /> struct has the right <see cref="LayoutKind" />.</summary>
[Test]
public static void IsLayoutSequentialTest()
{
Assert.That(typeof(IDirect3DDxgiInterfaceAccess).IsLayoutSequential, Is.True);
}

/// <summary>Validates that the <see cref="IDirect3DDxgiInterfaceAccess" /> struct has the correct size.</summary>
[Test]
public static void SizeOfTest()
{
if (Environment.Is64BitProcess)
{
Assert.That(sizeof(IDirect3DDxgiInterfaceAccess), Is.EqualTo(8));
}
else
{
Assert.That(sizeof(IDirect3DDxgiInterfaceAccess), Is.EqualTo(4));
}
}
}
}