From 05bc0d562acc3d4c050cb6633e49403cf111a3a1 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 2 Dec 2017 18:38:36 +0200 Subject: [PATCH] D3D11 updates. --- od-win32/direct3d.cpp | 6 +++++- od-win32/direct3d.h | 2 +- od-win32/direct3d11.cpp | 40 +++++++++++++++++++++++++++++--------- od-win32/picasso96_win.cpp | 2 +- od-win32/win32gfx.cpp | 1 + 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index 5ed59d40..f0eda871 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -3288,10 +3288,13 @@ static void D3D_render2 (struct d3dstruct *d3d) write_log (_T("%s: EndScene() %s\n"), D3DHEAD, D3D_ErrorString (hr)); } -static void xD3D_setcursor (int x, int y, int width, int height, bool visible, bool noscale) +static bool xD3D_setcursor (int x, int y, int width, int height, bool visible, bool noscale) { struct d3dstruct *d3d = &d3ddata[0]; + if (width < 0 || height < 0) + return true; + if (width && height) { d3d->cursor_offset2_x = d3d->cursor_offset_x * d3d->window_w / width; d3d->cursor_offset2_y = d3d->cursor_offset_y * d3d->window_h / height; @@ -3303,6 +3306,7 @@ static void xD3D_setcursor (int x, int y, int width, int height, bool visible, b } d3d->cursor_scale = !noscale; d3d->cursor_v = visible; + return true; } static void xD3D_unlocktexture (void) diff --git a/od-win32/direct3d.h b/od-win32/direct3d.h index e3359490..16b30afd 100644 --- a/od-win32/direct3d.h +++ b/od-win32/direct3d.h @@ -15,7 +15,7 @@ extern int(*D3D_isenabled)(void); extern void(*D3D_clear)(void); extern int(*D3D_canshaders)(void); extern int(*D3D_goodenough)(void); -extern void(*D3D_setcursor)(int x, int y, int width, int height, bool visible, bool noscale); +extern bool(*D3D_setcursor)(int x, int y, int width, int height, bool visible, bool noscale); extern bool(*D3D_getvblankpos)(int *vpos); extern double(*D3D_getrefreshrate)(void); extern void(*D3D_vblank_reset)(double freq); diff --git a/od-win32/direct3d11.cpp b/od-win32/direct3d11.cpp index fb96ac8d..652a6f7c 100644 --- a/od-win32/direct3d11.cpp +++ b/od-win32/direct3d11.cpp @@ -42,7 +42,7 @@ int (*D3D_isenabled)(void); void (*D3D_clear)(void); int (*D3D_canshaders)(void); int (*D3D_goodenough)(void); -void (*D3D_setcursor)(int x, int y, int width, int height, bool visible, bool noscale); +bool (*D3D_setcursor)(int x, int y, int width, int height, bool visible, bool noscale); bool (*D3D_getvblankpos)(int *vpos); double (*D3D_getrefreshrate)(void); void (*D3D_vblank_reset)(double freq); @@ -371,8 +371,8 @@ static void setupscenecoords(struct d3d11struct *d3d) float sw = dw / d3d->m_screenWidth; float sh = dh / d3d->m_screenHeight; - int xshift = -zr.left - sr.left; // - (tin_w - 2 * zr.left - w), - int yshift = +zr.top + sr.top - (d3d->m_bitmapHeight - h); + int xshift = -zr.left - sr.left; + int yshift = -zr.top - sr.top; xshift -= ((sr.right - sr.left) - d3d->m_screenWidth) / 2; yshift -= ((sr.bottom - sr.top) - d3d->m_screenHeight) / 2; @@ -1506,6 +1506,7 @@ static void setswapchainmode(struct d3d11struct *d3d, int fs) } d3d->fsSwapChainDesc.Windowed = TRUE; + //d3d->swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE; } bool can_D3D11(bool checkdevice) @@ -1573,6 +1574,9 @@ static bool xxD3D11_init(HWND ahwnd, int w_w, int w_h, int depth, int *freq, int filterd3didx = picasso_on; filterd3d = &currprefs.gf[filterd3didx]; + if (depth != 32 && depth != 16) + return false; + if (!can_D3D11(false)) return false; @@ -1581,7 +1585,7 @@ static bool xxD3D11_init(HWND ahwnd, int w_w, int w_h, int depth, int *freq, int d3d->m_screenWidth = w_w; d3d->m_screenHeight = w_h; d3d->ahwnd = ahwnd; - d3d->format = DXGI_FORMAT_B8G8R8A8_UNORM; + d3d->format = depth == 32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; struct MultiDisplay *md = getdisplay(&currprefs); POINT pt; @@ -1745,7 +1749,6 @@ static bool xxD3D11_init(HWND ahwnd, int w_w, int w_h, int depth, int *freq, int adapter->Release(); adapter = 0; - static const D3D_FEATURE_LEVEL levels1[] = { D3D_FEATURE_LEVEL_11_1 }; UINT cdflags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; #ifdef _DEBUG @@ -1821,9 +1824,14 @@ static bool xxD3D11_init(HWND ahwnd, int w_w, int w_h, int depth, int *freq, int return false; } - result = factory2->MakeWindowAssociation(ahwnd, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN); - if (FAILED(result)) { - write_log(_T("IDXGIFactory2 MakeWindowAssociation %08x\n"), result); + IDXGIFactory1 *pFactory = NULL; + result = d3d->m_swapChain->GetParent(__uuidof (IDXGIFactory1), (void **)&pFactory); + if (SUCCEEDED(result)) { + result = pFactory->MakeWindowAssociation(ahwnd, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN); + if (FAILED(result)) { + write_log(_T("IDXGIFactory2 MakeWindowAssociation %08x\n"), result); + } + pFactory->Release(); } d3d->invalidmode = false; @@ -2386,6 +2394,15 @@ static void xD3D11_resize(int activate) return; } + if (d3d->m_swapChain && quit_program) { + d3d->m_swapChain->SetFullscreenState(FALSE, NULL); + FreeTexture(d3d); + d3d->fsmode = 0; + d3d->invalidmode = true; + d3d->fsmodechange = 0; + return; + } + if (recursive) return; recursive++; @@ -2509,6 +2526,11 @@ bool D3D11_capture(void **data, int *w, int *h, int *pitch) } } +static bool xD3D_setcursor(int x, int y, int width, int height, bool visible, bool noscale) +{ + return false; +} + void d3d11_select(void) { D3D_free = xD3D11_free; @@ -2530,7 +2552,7 @@ void d3d11_select(void) D3D_clear = xD3D11_clear; D3D_canshaders = xD3D11_canshaders; D3D_goodenough = xD3D11_goodenough; - D3D_setcursor = NULL; + D3D_setcursor = xD3D_setcursor; D3D_getvblankpos = xD3D_getvblankpos; D3D_getrefreshrate = NULL; D3D_vblank_reset = xD3D11_vblank_reset; diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index 3b11ef7c..83b9b1e0 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -2418,7 +2418,7 @@ static void inituaegfx(TrapContext *ctx, uaecptr ABI) } flags |= BIF_NOMEMORYMODEMIX; flags &= ~BIF_HARDWARESPRITE; - if (currprefs.gfx_api && D3D_goodenough () > 0 && USE_HARDWARESPRITE && currprefs.rtg_hardwaresprite) { + if (currprefs.gfx_api && D3D_goodenough () > 0 && D3D_setcursor(-1, -1, -1, -1, false, false) && USE_HARDWARESPRITE && currprefs.rtg_hardwaresprite) { hwsprite = 1; flags |= BIF_HARDWARESPRITE; write_log (_T("P96: Hardware sprite support enabled\n")); diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index b5a13257..99661e71 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -4654,6 +4654,7 @@ static BOOL doInit (void) if (currprefs.gfx_api == 2) { D3D_free(true); changed_prefs.gfx_api = currprefs.gfx_api = 1; + d3d_select(&currprefs); err = D3D_init(hAmigaWnd, currentmode->native_width, currentmode->native_height, currentmode->current_depth, ¤tmode->freq, screen_is_picasso ? 1 : currprefs.gf[picasso_on].gfx_filter_filtermode + 1); } if (err) { -- 2.47.3