[PATCH] d3d9: Set the initial scissorrect to the dimesions of the backbuffer from the first swapchain of the device

Rico Schüller kgbricola at web.de
Sat Aug 30 05:26:11 CDT 2008


---
 dlls/d3d9/directx.c      |   11 ++++++
 dlls/d3d9/tests/device.c |   84 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index 78244ec..426e907 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -468,6 +468,7 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
     IDirect3DDevice9Impl *object = NULL;
     WINED3DPRESENT_PARAMETERS localParameters;
     HRESULT hr;
+    RECT scissorrect;
     TRACE("(%p) Relay\n", This);
 
     /* Check the validity range of the adapter parameter */
@@ -547,6 +548,16 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
      * can be used without further checking
      */
     object->convertedDecls = HeapAlloc(GetProcessHeap(), 0, 0);
+
+    /* Set the default scissor rect values.
+     * The scissorrect doesn't exist in ddraw and d3d8 and it is tricky to set in wined3d because the backbuffer,
+     * which is needed to get the size, isn't necessarily there. */
+    scissorrect.left = 0;
+    scissorrect.right = localParameters.BackBufferWidth;;
+    scissorrect.top = 0;
+    scissorrect.bottom = localParameters.BackBufferHeight;
+    IWineD3DDevice_SetScissorRect(*ppReturnedDeviceInterface, &scissorrect);
+
     LeaveCriticalSection(&d3d9_cs);
 
     return hr;
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 3164b81..224e547 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -2016,6 +2016,89 @@ static void test_display_formats()
     if(d3d9) IDirect3D9_Release(d3d9);
 }
 
+static void test_scissor_size(void)
+{
+    IDirect3D9 *d3d9_ptr = 0;
+    int i;
+    static const struct {
+        int winx; int winy; int backx; int backy; BOOL window;
+    } scts[] = { /* scissor tests */
+        {800, 600, 640, 480, TRUE},
+        {800, 600, 640, 480, FALSE},
+        {640, 480, 800, 600, TRUE},
+        {640, 480, 800, 600, FALSE},
+    };
+
+    d3d9_ptr = pDirect3DCreate9(D3D_SDK_VERSION);
+    ok(d3d9_ptr != NULL, "Failed to create IDirect3D9 object\n");
+    if (!d3d9_ptr){
+        skip("Failed to create IDirect3D9 object\n");
+        return;
+    }
+
+    for(i=0; i<sizeof(scts)/sizeof(scts[0]); i++) {
+        IDirect3DDevice9 *device_ptr = 0;
+        D3DPRESENT_PARAMETERS present_parameters;
+        HRESULT hr;
+        WNDCLASS wc = {0};
+        HWND hwnd = 0;
+        IDirect3DSwapChain9 *swapchain1 = 0;
+        RECT scissorrect;
+
+        wc.lpfnWndProc = DefWindowProc;
+        wc.lpszClassName = "d3d9_test_wc";
+        RegisterClass(&wc);
+
+        hwnd = CreateWindow("d3d9_test_wc", "d3d9_test",
+                        WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, scts[i].winx, scts[i].winy, 0, 0, 0, 0);
+
+        ZeroMemory(&present_parameters, sizeof(present_parameters));
+        present_parameters.Windowed = scts[i].window;
+        present_parameters.hDeviceWindow = hwnd;
+        present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
+        present_parameters.BackBufferWidth = scts[i].backx;
+        present_parameters.BackBufferHeight = scts[i].backy;
+        present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
+        present_parameters.EnableAutoDepthStencil = TRUE;
+        present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
+
+        hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
+        if(FAILED(hr)) {
+            present_parameters.AutoDepthStencilFormat = D3DFMT_D16;
+            hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
+            if(FAILED(hr)) {
+                hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
+            }
+        }
+        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "IDirect3D_CreateDevice returned: %08x\n", hr);
+
+        if (!device_ptr)
+        {
+            DestroyWindow(hwnd);
+            skip("Creating the device failed\n");
+            goto err_out;
+        }
+
+        /* Check for the default scissor rect size */
+        hr = IDirect3DDevice9_GetScissorRect(device_ptr, &scissorrect);
+        ok(hr == D3D_OK, "IDirect3DDevice9_GetScissorRect failed with: %08x\n", hr);
+        ok(scissorrect.right == scts[i].backx && scissorrect.bottom == scts[i].backy && scissorrect.top == 0 && scissorrect.left == 0, "Scissorrect missmatch (%d, %d) should be (%d, %d)\n", scissorrect.right, scissorrect.bottom, scts[i].backx, scts[i].backy);
+
+        if(device_ptr) {
+            ULONG ref;
+
+            ref = IDirect3DDevice9_Release(device_ptr);
+            DestroyWindow(hwnd);
+            ok(ref == 0, "The device was not properly freed: refcount %u\n", ref);
+        }
+    }
+
+err_out:
+    if(d3d9_ptr) IDirect3D9_Release(d3d9_ptr);
+    return;
+}
+
+
 START_TEST(device)
 {
     HMODULE d3d9_handle = LoadLibraryA( "d3d9.dll" );
@@ -2045,5 +2128,6 @@ START_TEST(device)
         test_vertex_buffer_alignment();
         test_lights();
         test_set_stream_source();
+        test_scissor_size();
     }
 }
-- 
1.5.5.1


--------------090506020201020302080009--



More information about the wine-patches mailing list