diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 15:13:43 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 15:13:43 -0500 |
| commit | ec6847a7f776374fc5987bce4570d3bfb609d119 (patch) | |
| tree | 4e920357a5576f34b121a6f4321b3f5fa4854c2a /runtime/shims/dxgi_com.cpp | |
| parent | 89872800a7011c472013a5cd407da0083798c40a (diff) | |
| parent | ed8528885b9b94361c341a8bdd8543f8d1bca373 (diff) | |
Merge pull request #2974 from Ryderadzeee
Diffstat (limited to 'runtime/shims/dxgi_com.cpp')
| -rw-r--r-- | runtime/shims/dxgi_com.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/runtime/shims/dxgi_com.cpp b/runtime/shims/dxgi_com.cpp index 6c20e1504..e41f81e9f 100644 --- a/runtime/shims/dxgi_com.cpp +++ b/runtime/shims/dxgi_com.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "dxgi_com.h" | 1 | #include "dxgi_com.h" |
| 2 | #include "d3d12_stubs.h" | 2 | #include "d3d12_stubs.h" |
| 3 | 3 | ||
| 4 | #include <algorithm> | ||
| 4 | #include <atomic> | 5 | #include <atomic> |
| 5 | #include <cstdio> | 6 | #include <cstdio> |
| 6 | #include <cstring> | 7 | #include <cstring> |
| @@ -26,6 +27,14 @@ bool valid_flip_buffer_count(UINT count) { | |||
| 26 | return count >= 2 && count <= DXGI_MAX_SWAP_CHAIN_BUFFERS; | 27 | return count >= 2 && count <= DXGI_MAX_SWAP_CHAIN_BUFFERS; |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 30 | bool is_direct_present_queue(IUnknown* candidate) { | ||
| 31 | ID3D12CommandQueue* queue = nullptr; | ||
| 32 | if (!candidate || FAILED(candidate->QueryInterface(IID_PPV_ARGS(&queue))) || !queue) return false; | ||
| 33 | const bool direct = queue->GetDesc().Type == D3D12_COMMAND_LIST_TYPE_DIRECT; | ||
| 34 | queue->Release(); | ||
| 35 | return direct; | ||
| 36 | } | ||
| 37 | |||
| 29 | VkFormat dxgi_to_vk_format(DXGI_FORMAT fmt) { | 38 | VkFormat dxgi_to_vk_format(DXGI_FORMAT fmt) { |
| 30 | switch (fmt) { | 39 | switch (fmt) { |
| 31 | case DXGI_FORMAT_B8G8R8A8_UNORM: return VK_FORMAT_B8G8R8A8_UNORM; | 40 | case DXGI_FORMAT_B8G8R8A8_UNORM: return VK_FORMAT_B8G8R8A8_UNORM; |
| @@ -239,6 +248,11 @@ public: | |||
| 239 | } | 248 | } |
| 240 | 249 | ||
| 241 | HRESULT STDMETHODCALLTYPE ResizeBuffers(UINT count, UINT width, UINT height, DXGI_FORMAT fmt, UINT flags) override { | 250 | HRESULT STDMETHODCALLTYPE ResizeBuffers(UINT count, UINT width, UINT height, DXGI_FORMAT fmt, UINT flags) override { |
| 251 | return resize_buffers(count, width, height, fmt, flags, nullptr, nullptr); | ||
| 252 | } | ||
| 253 | |||
| 254 | HRESULT resize_buffers(UINT count, UINT width, UINT height, DXGI_FORMAT fmt, UINT flags, | ||
| 255 | const UINT* node_masks, IUnknown* const* present_queues) { | ||
| 242 | if (count != 0 && !valid_flip_buffer_count(count)) return E_INVALIDARG; | 256 | if (count != 0 && !valid_flip_buffer_count(count)) return E_INVALIDARG; |
| 243 | VkFormat vk_fmt = VK_FORMAT_UNDEFINED; | 257 | VkFormat vk_fmt = VK_FORMAT_UNDEFINED; |
| 244 | if (fmt != DXGI_FORMAT_UNKNOWN) { | 258 | if (fmt != DXGI_FORMAT_UNKNOWN) { |
| @@ -251,6 +265,11 @@ public: | |||
| 251 | // DXGI refuses to resize while the app still holds a back buffer reference. | 265 | // DXGI refuses to resize while the app still holds a back buffer reference. |
| 252 | for (auto* bb : buffers_) | 266 | for (auto* bb : buffers_) |
| 253 | if (bb->held_by_app()) return DXGI_ERROR_INVALID_CALL; | 267 | if (bb->held_by_app()) return DXGI_ERROR_INVALID_CALL; |
| 268 | const std::size_t target_count = count ? count : buffers_.size(); | ||
| 269 | if (node_masks && !std::all_of(node_masks, node_masks + target_count, [](UINT mask) { return mask <= 1; })) | ||
| 270 | return DXGI_ERROR_INVALID_CALL; | ||
| 271 | if (present_queues && !std::all_of(present_queues, present_queues + target_count, is_direct_present_queue)) | ||
| 272 | return DXGI_ERROR_INVALID_CALL; | ||
| 254 | unregister_buffers(); | 273 | unregister_buffers(); |
| 255 | const VkExtent2D size = size_or_client(width, height, swapchain_.extent()); | 274 | const VkExtent2D size = size_or_client(width, height, swapchain_.extent()); |
| 256 | const std::uint32_t w = size.width; | 275 | const std::uint32_t w = size.width; |
| @@ -413,9 +432,9 @@ public: | |||
| 413 | return S_OK; | 432 | return S_OK; |
| 414 | } | 433 | } |
| 415 | HRESULT STDMETHODCALLTYPE SetColorSpace1(DXGI_COLOR_SPACE_TYPE) override { return S_OK; } | 434 | HRESULT STDMETHODCALLTYPE SetColorSpace1(DXGI_COLOR_SPACE_TYPE) override { return S_OK; } |
| 416 | HRESULT STDMETHODCALLTYPE ResizeBuffers1(UINT count, UINT w, UINT h, DXGI_FORMAT fmt, UINT flags, const UINT*, | 435 | HRESULT STDMETHODCALLTYPE ResizeBuffers1(UINT count, UINT w, UINT h, DXGI_FORMAT fmt, UINT flags, |
| 417 | IUnknown* const*) override { | 436 | const UINT* node_masks, IUnknown* const* present_queues) override { |
| 418 | return ResizeBuffers(count, w, h, fmt, flags); | 437 | return resize_buffers(count, w, h, fmt, flags, node_masks, present_queues); |
| 419 | } | 438 | } |
| 420 | 439 | ||
| 421 | private: | 440 | private: |