mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-09 13:37:48 +00:00
D3D12 bug fixes
This commit is contained in:
@@ -35,8 +35,8 @@ struct D3D12Context
|
||||
struct Window
|
||||
{
|
||||
ComPtr<IDXGISwapChain3> m_swapChain;
|
||||
ComPtr<ID3D12Resource> m_fb[2]; /* Double-buffered */
|
||||
UINT m_backBuf = 0;
|
||||
bool m_needsResize = false;
|
||||
size_t width, height;
|
||||
};
|
||||
std::unordered_map<boo::IWindow*, Window> m_windows;
|
||||
@@ -57,6 +57,7 @@ struct D3D11Context
|
||||
struct Window
|
||||
{
|
||||
IDXGISwapChain1* m_swapChain;
|
||||
bool m_needsResize = false;
|
||||
size_t width, height;
|
||||
};
|
||||
std::unordered_map<boo::IWindow*, Window> m_windows;
|
||||
@@ -68,6 +69,24 @@ struct D3DAppContext
|
||||
#if _WIN32_WINNT_WIN10
|
||||
D3D12Context m_ctx12;
|
||||
#endif
|
||||
|
||||
void resize(boo::IWindow* window, size_t width, size_t height)
|
||||
{
|
||||
#if _WIN32_WINNT_WIN10
|
||||
if (m_ctx12.m_dev)
|
||||
{
|
||||
m_ctx12.m_windows[window].width = width;
|
||||
m_ctx12.m_windows[window].height = height;
|
||||
m_ctx12.m_windows[window].m_needsResize = true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
m_ctx11.m_windows[window].width = width;
|
||||
m_ctx11.m_windows[window].height = height;
|
||||
m_ctx11.m_windows[window].m_needsResize = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct HWNDEvent
|
||||
|
||||
@@ -63,10 +63,10 @@ public:
|
||||
Log.report(LogVisor::FatalError, "unable to create swap chain");
|
||||
|
||||
m_swapChain.As<IDXGISwapChain3>(&w.m_swapChain);
|
||||
m_swapChain->GetBuffer(0, __uuidof(ID3D12Resource), &w.m_fb[0]);
|
||||
m_swapChain->GetBuffer(1, __uuidof(ID3D12Resource), &w.m_fb[1]);
|
||||
ComPtr<ID3D12Resource> fb;
|
||||
m_swapChain->GetBuffer(0, __uuidof(ID3D12Resource), &fb);
|
||||
w.m_backBuf = w.m_swapChain->GetCurrentBackBufferIndex();
|
||||
D3D12_RESOURCE_DESC resDesc = w.m_fb[0]->GetDesc();
|
||||
D3D12_RESOURCE_DESC resDesc = fb->GetDesc();
|
||||
w.width = resDesc.Width;
|
||||
w.height = resDesc.Height;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
void getWindowFrame(float& xOut, float& yOut, float& wOut, float& hOut) const
|
||||
{
|
||||
RECT rct;
|
||||
GetWindowRect(m_hwnd, &rct);
|
||||
GetClientRect(m_hwnd, &rct);
|
||||
xOut = rct.left;
|
||||
yOut = rct.top;
|
||||
wOut = rct.right;
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
void getWindowFrame(int& xOut, int& yOut, int& wOut, int& hOut) const
|
||||
{
|
||||
RECT rct;
|
||||
GetWindowRect(m_hwnd, &rct);
|
||||
GetClientRect(m_hwnd, &rct);
|
||||
xOut = rct.left;
|
||||
yOut = rct.top;
|
||||
wOut = rct.right;
|
||||
@@ -374,17 +374,13 @@ public:
|
||||
{
|
||||
case WM_SIZE:
|
||||
{
|
||||
SWindowRect rect;
|
||||
getWindowFrame(rect.location[0], rect.location[1], rect.size[0], rect.size[1]);
|
||||
if (!rect.size[0] || !rect.size[1])
|
||||
return;
|
||||
m_gfxCtx->m_d3dCtx.resize(this, rect.size[0], rect.size[1]);
|
||||
if (m_callback)
|
||||
{
|
||||
SWindowRect rect;
|
||||
int x, y, w, h;
|
||||
getWindowFrame(x, y, w, h);
|
||||
rect.location[0] = x;
|
||||
rect.location[1] = y;
|
||||
rect.size[0] = LOWORD(e.lParam);
|
||||
rect.size[1] = HIWORD(e.lParam);
|
||||
m_callback->resized(rect);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case WM_KEYDOWN:
|
||||
|
||||
Reference in New Issue
Block a user