webgpu-native / webgpu-headers

https://webgpu-native.github.io/webgpu-headers/
BSD 3-Clause "New" or "Revised" License
341 stars 38 forks source link

Add windows association flags to WGPUSurfaceDescriptorFromWindowsHWND #298

Open austinEng opened 1 month ago

austinEng commented 1 month ago

This PR https://github.com/google/dawn/pull/16 adds DXGI_MWA_NO_ALT_ENTER always to Dawn.

Probably the better thing would be for an application to be able to configure the window association when creating the WGPUSurface.

Concretely, something like:

typedef struct WGPUSurfaceDescriptorFromWindowsHWND {
    WGPUChainedStruct chain;
    void * hinstance;
    void * hwnd;
+   uint32_t windowAssocationFlags;
} WGPUSurfaceDescriptorFromWindowsHWND WGPU_STRUCTURE_ATTRIBUTE;

For reference, valid flags are:

#define DXGI_MWA_NO_WINDOW_CHANGES  0x1
#define DXGI_MWA_NO_ALT_ENTER       0x2
#define DXGI_MWA_NO_PRINT_SCREEN    0x4
kainino0x commented 1 month ago

Jun 6 meeting:

Kangz commented 1 month ago

I have slight concerns with adding the flags directly in this descriptor because it is only useful on the D3D11 and D3D12 backend, but the HWND descriptor can also be used to Vulkan and OpenGL/ES, so the flags would do nothing there. At the minimum we'll need docs to cover that.

austinEng commented 1 month ago

We hadn't considered HWND on Vulkan / GL - do you think this would be better as an independent feature?

I think if the feature isn't enabled, you'd get a validation error during surface.Configure(..) (need to know the device first)

kainino0x commented 1 month ago

I guess if MakeWindowAssociation gets called in Configure we could make this an extension to Configure?

austinEng commented 1 month ago

Moving to an extension to Configure sounds fine to me. @SoapyMan would you like to champion adding this since it seems important for your use case?

SoapyMan commented 1 month ago

Sounds good to me