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 Presentation.h and PresentationTypes.h (Win11 Composition Swapchain API) #403

Merged
merged 6 commits into from
Dec 23, 2024

Conversation

rickbrew
Copy link
Contributor

@rickbrew rickbrew commented Dec 19, 2024

This looks right except that Windows.CreatePresentationFactory has a blank DLL name: [DllImport("", ...)]. It should be dcomp.dll as per https://learn.microsoft.com/en-us/windows/win32/api/presentation/nf-presentation-createpresentationfactory

Edit: Fixed the DLL name for the [DllImport] on CreatePresentationFactory

…in API)

This looks right except that `Windows.CreatePresentationFactory` has a blank DLL name: `[DllImport("", ...)]`
@rickbrew rickbrew changed the title [Draft] Add Presentation.h and PresentationTypes.h (Win11 Composition Swapchain API) Add Presentation.h and PresentationTypes.h (Win11 Composition Swapchain API) Dec 20, 2024
@rickbrew
Copy link
Contributor Author

ResolveDllImportTests is probably failing because the CI server isn't running on a build of Windows that has these APIs? A whole bunch of other APIs are failing the same test, too.

@rickbrew
Copy link
Contributor Author

The unresolved TaskDialogIndirect is because there's neither a manifest nor an activation context that specifies to use version 6 of the DLL instead of 5.82. Normal stuff.

Comment on lines 17 to 21
--with-using
CompositionFrameDisplayInstance=TerraFX.Interop.DirectX
ICompositionFramePresentStatistics=TerraFX.Interop.DirectX
IPresentationSurface=TerraFX.Interop.DirectX
IPresentationSurface2=TerraFX.Interop.DirectX
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to get these automatic by adding the type it uses to https://github.com/terrafx/terrafx.interop.windows/blob/main/generation/remap-namespaces.rsp, which should just tell the system that DXGI_COLOR_SPACE_TYPE is in TerraFX.Interop.DirectX

@tannergooding
Copy link
Member

ResolveDllImportTests is probably failing because the CI server isn't running on a build of Windows that has these APIs? A whole bunch of other APIs are failing the same test, too.

You should be able to add the entries to the handler in https://github.com/terrafx/terrafx.interop.windows/blob/main/tests/Interop/Windows/ResolveDllImportTests.cs#L53

There's an existing grouping for cases that simply aren't on server, but if its instead relegated to a particular version of Windows then you can place it in a separate grouping with the relevant guard.

@tannergooding
Copy link
Member

The unresolved TaskDialogIndirect is because there's neither a manifest nor an activation context that specifies to use version 6 of the DLL instead of 5.82. Normal stuff.

That is already be getting handled via https://github.com/terrafx/terrafx.interop.windows/blob/main/tests/Interop/Windows/ResolveDllImportTests.cs#L218 and warning, not erroring.

The only actual failure is CreatePresentationFactory

@rickbrew
Copy link
Contributor Author

The unresolved TaskDialogIndirect is because there's neither a manifest nor an activation context that specifies to use version 6 of the DLL instead of 5.82. Normal stuff.

That is already be getting handled via https://github.com/terrafx/terrafx.interop.windows/blob/main/tests/Interop/Windows/ResolveDllImportTests.cs#L218 and warning, not erroring.

It should be possible to test the comctl32.dll exports without a manifest by using an activation context. Might not be worth the trouble though.

@rickbrew
Copy link
Contributor Author

CreatePresentationFactory does indeed work :)

image

using static TerraFX.Interop.Windows.Windows;

unsafe void Main()
{
    using ComPtr<IDXGIFactory7> spDxgiFactory = default;
    HRESULT hr = DirectX.CreateDXGIFactory2(
        0,
        __uuidof<IDXGIFactory7>(),
        (void**)spDxgiFactory.GetAddressOf());    

    D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL.D3D_FEATURE_LEVEL_11_0;
    using ComPtr<ID3D11Device> spWarpDevice = default;
    hr = DirectX.D3D11CreateDevice(
        null,
        D3D_DRIVER_TYPE.D3D_DRIVER_TYPE_WARP,
        HMODULE.NULL,
        (uint)D3D11_CREATE_DEVICE_FLAG.D3D11_CREATE_DEVICE_BGRA_SUPPORT,
        &featureLevel,
        1,
        D3D11.D3D11_SDK_VERSION,
        spWarpDevice.GetAddressOf(),
        null,
        null);
    
    using ComPtr<IPresentationFactory> spPresentationFactory = default;
    hr = CreatePresentationFactory(
        (IUnknown*)spWarpDevice.Get(),
        __uuidof<IPresentationFactory>(),
        (void**)spPresentationFactory.GetAddressOf());
        
    bool isPresentationSupported = (BOOL)spPresentationFactory.Get()->IsPresentationSupported();
    bool isPresentationSupportedWithIFlip = (BOOL)spPresentationFactory.Get()->IsPresentationSupportedWithIndependentFlip();
    
    (isPresentationSupported, isPresentationSupportedWithIFlip).Dump();
}

@tannergooding tannergooding merged commit a059458 into terrafx:main Dec 23, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants