]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
D3D11 updates.
authorToni Wilen <twilen@winuae.net>
Sat, 2 Dec 2017 16:38:36 +0000 (18:38 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 2 Dec 2017 16:38:36 +0000 (18:38 +0200)
od-win32/direct3d.cpp
od-win32/direct3d.h
od-win32/direct3d11.cpp
od-win32/picasso96_win.cpp
od-win32/win32gfx.cpp

index 5ed59d401ffeb35a97cb33868c6108d71e0ab3cc..f0eda871820976c1e670bfff4726be5ed3092d99 100644 (file)
@@ -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)
index e33594905bb4dd8dfbafce61031daecf7c4540b1..16b30afd84f00507f92fa40938d0f5c85494d3d0 100644 (file)
@@ -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);
index fb96ac8d64b1e893a5b2ef5236bfe1ed3572f288..652a6f7cc3377b9e121a8f4b7ad423c88b4ae3f0 100644 (file)
@@ -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;
index 3b11ef7c267245b1b00c9b0089d07488e6028717..83b9b1e0e69e51310c8331fdb1c5eb8e7141f822 100644 (file)
@@ -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"));
index b5a13257c0d7baf20e5c2c4a43e54956433e8c50..99661e71c75bb7b32c2275674e513794325869af 100644 (file)
@@ -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, &currentmode->freq, screen_is_picasso ? 1 : currprefs.gf[picasso_on].gfx_filter_filtermode + 1);
                        }
                        if (err) {