diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 09:15:08 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 09:15:08 -0500 |
| commit | 4d6febbde39066a06ef03cae4432df49a49b26a0 (patch) | |
| tree | 3fe8c5bdec0b5a25270648ae33feabbf547b3142 /runtime/shims/dxgi_com.cpp | |
| parent | 2fc613a32a7b784367c8ea3573bcf034b742199f (diff) | |
| parent | 0904055f3ac50b6be614f13032a271b29862cf13 (diff) | |
Merge pull request #1761 from SHAURYASANYAL3
Diffstat (limited to 'runtime/shims/dxgi_com.cpp')
| -rw-r--r-- | runtime/shims/dxgi_com.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/runtime/shims/dxgi_com.cpp b/runtime/shims/dxgi_com.cpp index 17449fefc..1e50bad2d 100644 --- a/runtime/shims/dxgi_com.cpp +++ b/runtime/shims/dxgi_com.cpp | |||
| @@ -790,16 +790,46 @@ public: | |||
| 790 | *out = static_cast<IDXGISwapChain1*>(sc); | 790 | *out = static_cast<IDXGISwapChain1*>(sc); |
| 791 | return S_OK; | 791 | return S_OK; |
| 792 | } | 792 | } |
| 793 | HRESULT STDMETHODCALLTYPE CreateSwapChainForCoreWindow(IUnknown*, IUnknown*, const DXGI_SWAP_CHAIN_DESC1*, | 793 | HRESULT STDMETHODCALLTYPE CreateSwapChainForCoreWindow(IUnknown* device, IUnknown* window, |
| 794 | IDXGIOutput*, IDXGISwapChain1**) override { | 794 | const DXGI_SWAP_CHAIN_DESC1* desc, |
| 795 | return E_NOTIMPL; | 795 | IDXGIOutput* restrict_to_output, |
| 796 | IDXGISwapChain1** out) override { | ||
| 797 | if (!out) return E_POINTER; | ||
| 798 | *out = nullptr; | ||
| 799 | if (!device || !window || !desc) return E_INVALIDARG; | ||
| 800 | // UWP / Game Core Scarlett titles present to an ICoreWindow. Extract the underlying | ||
| 801 | // Win32 HWND via ICoreWindowInterop. | ||
| 802 | static constexpr GUID kIID_ICoreWindowInterop = { | ||
| 803 | 0x45D64A29, 0xA63E, 0x4CB6, {0xB4, 0x98, 0x57, 0x81, 0xD2, 0x98, 0xCB, 0x4F}}; | ||
| 804 | struct ICoreWindowInterop : public IUnknown { | ||
| 805 | virtual HRESULT STDMETHODCALLTYPE get_WindowHandle(HWND* hwnd) = 0; | ||
| 806 | virtual HRESULT STDMETHODCALLTYPE put_MessageHandled(unsigned char value) = 0; | ||
| 807 | }; | ||
| 808 | ICoreWindowInterop* interop = nullptr; | ||
| 809 | if (FAILED(window->QueryInterface(kIID_ICoreWindowInterop, reinterpret_cast<void**>(&interop))) || !interop) { | ||
| 810 | return DXGI_ERROR_INVALID_CALL; | ||
| 811 | } | ||
| 812 | HWND hwnd = nullptr; | ||
| 813 | const HRESULT hr = interop->get_WindowHandle(&hwnd); | ||
| 814 | interop->Release(); | ||
| 815 | if (FAILED(hr) || !hwnd) return DXGI_ERROR_INVALID_CALL; | ||
| 816 | return CreateSwapChainForHwnd(device, hwnd, desc, nullptr, restrict_to_output, out); | ||
| 796 | } | 817 | } |
| 797 | HRESULT STDMETHODCALLTYPE GetSharedResourceAdapterLuid(HANDLE, LUID*) override { return E_NOTIMPL; } | 818 | HRESULT STDMETHODCALLTYPE GetSharedResourceAdapterLuid(HANDLE, LUID*) override { return E_NOTIMPL; } |
| 798 | HRESULT STDMETHODCALLTYPE RegisterStereoStatusWindow(HWND, UINT, DWORD*) override { return E_NOTIMPL; } | 819 | HRESULT STDMETHODCALLTYPE RegisterStereoStatusWindow(HWND, UINT, DWORD*) override { return E_NOTIMPL; } |
| 799 | HRESULT STDMETHODCALLTYPE RegisterStereoStatusEvent(HANDLE, DWORD*) override { return E_NOTIMPL; } | 820 | HRESULT STDMETHODCALLTYPE RegisterStereoStatusEvent(HANDLE, DWORD*) override { return E_NOTIMPL; } |
| 800 | void STDMETHODCALLTYPE UnregisterStereoStatus(DWORD) override {} | 821 | void STDMETHODCALLTYPE UnregisterStereoStatus(DWORD) override {} |
| 801 | HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusWindow(HWND, UINT, DWORD*) override { return E_NOTIMPL; } | 822 | HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusWindow(HWND hwnd, UINT msg, DWORD* cookie) override { |
| 802 | HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusEvent(HANDLE, DWORD*) override { return E_NOTIMPL; } | 823 | (void)msg; |
| 824 | if (!hwnd || !cookie) return DXGI_ERROR_INVALID_CALL; | ||
| 825 | *cookie = next_occlusion_cookie_.fetch_add(1, std::memory_order_relaxed); | ||
| 826 | return S_OK; | ||
| 827 | } | ||
| 828 | HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusEvent(HANDLE event, DWORD* cookie) override { | ||
| 829 | if (!event || !cookie) return DXGI_ERROR_INVALID_CALL; | ||
| 830 | *cookie = next_occlusion_cookie_.fetch_add(1, std::memory_order_relaxed); | ||
| 831 | return S_OK; | ||
| 832 | } | ||
| 803 | void STDMETHODCALLTYPE UnregisterOcclusionStatus(DWORD) override {} | 833 | void STDMETHODCALLTYPE UnregisterOcclusionStatus(DWORD) override {} |
| 804 | HRESULT STDMETHODCALLTYPE CreateSwapChainForComposition(IUnknown*, const DXGI_SWAP_CHAIN_DESC1*, IDXGIOutput*, | 834 | HRESULT STDMETHODCALLTYPE CreateSwapChainForComposition(IUnknown*, const DXGI_SWAP_CHAIN_DESC1*, IDXGIOutput*, |
| 805 | IDXGISwapChain1**) override { | 835 | IDXGISwapChain1**) override { |
| @@ -885,6 +915,7 @@ private: | |||
| 885 | HWND assoc_hwnd_ = nullptr; | 915 | HWND assoc_hwnd_ = nullptr; |
| 886 | mutable std::once_flag tearing_once_; | 916 | mutable std::once_flag tearing_once_; |
| 887 | bool tearing_supported_ = false; | 917 | bool tearing_supported_ = false; |
| 918 | std::atomic<DWORD> next_occlusion_cookie_{1}; | ||
| 888 | }; | 919 | }; |
| 889 | 920 | ||
| 890 | } // namespace | 921 | } // namespace |