-
Notifications
You must be signed in to change notification settings - Fork 31
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
generation/um/windows.graphics.directx.direct3d11.interop/generate.rsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
4 changes: 4 additions & 0 deletions
4
generation/um/windows.graphics.directx.direct3d11.interop/header.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
2 changes: 2 additions & 0 deletions
2
...dows.graphics.directx.direct3d11.interop/um-windows.graphics.directx.direct3d11.interop.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include <Windows.h> | ||
#include <windows.graphics.directx.direct3d11.interop.h> |
41 changes: 41 additions & 0 deletions
41
...op/Windows/um/windows.graphics.directx.direct3d11.interop/IDirect3DDxgiInterfaceAccess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
sources/Interop/Windows/um/windows.graphics.directx.direct3d11.interop/Windows.Manual.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
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); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
sources/Interop/Windows/um/windows.graphics.directx.direct3d11.interop/Windows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...ndows/um/windows.graphics.directx.direct3d11.interop/IDirect3DDxgiInterfaceAccessTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.