2006-05-20 18:36:13 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Vitaliy Margolen
|
2006-12-20 13:44:08 +01:00
|
|
|
* Copyright (C) 2006 Chris Robinson
|
2006-05-20 18:36:13 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-05-20 18:36:13 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
2008-07-08 16:17:17 +02:00
|
|
|
#include <initguid.h>
|
2006-05-20 18:36:13 +02:00
|
|
|
#include <d3d8.h>
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
static IDirect3D8 *(WINAPI *pDirect3DCreate8)(UINT);
|
|
|
|
|
2007-08-14 11:18:01 +02:00
|
|
|
static BOOL (WINAPI *pGetCursorInfo)(PCURSORINFO);
|
|
|
|
|
2007-02-12 19:21:45 +01:00
|
|
|
static const DWORD simple_vs[] = {0xFFFE0101, /* vs_1_1 */
|
|
|
|
0x00000009, 0xC0010000, 0x90E40000, 0xA0E40000, /* dp4 oPos.x, v0, c0 */
|
|
|
|
0x00000009, 0xC0020000, 0x90E40000, 0xA0E40001, /* dp4 oPos.y, v0, c1 */
|
|
|
|
0x00000009, 0xC0040000, 0x90E40000, 0xA0E40002, /* dp4 oPos.z, v0, c2 */
|
|
|
|
0x00000009, 0xC0080000, 0x90E40000, 0xA0E40003, /* dp4 oPos.w, v0, c3 */
|
|
|
|
0x0000FFFF}; /* END */
|
|
|
|
static const DWORD simple_ps[] = {0xFFFF0101, /* ps_1_1 */
|
|
|
|
0x00000051, 0xA00F0001, 0x3F800000, 0x00000000, 0x00000000, 0x00000000, /* def c1 = 1.0, 0.0, 0.0, 0.0 */
|
|
|
|
0x00000042, 0xB00F0000, /* tex t0 */
|
|
|
|
0x00000008, 0x800F0000, 0xA0E40001, 0xA0E40000, /* dp3 r0, c1, c0 */
|
|
|
|
0x00000005, 0x800F0000, 0x90E40000, 0x80E40000, /* mul r0, v0, r0 */
|
|
|
|
0x00000005, 0x800F0000, 0xB0E40000, 0x80E40000, /* mul r0, t0, r0 */
|
|
|
|
0x0000FFFF}; /* END */
|
|
|
|
|
2006-05-20 18:36:13 +02:00
|
|
|
static int get_refcount(IUnknown *object)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef( object );
|
|
|
|
return IUnknown_Release( object );
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECK_CALL(r,c,d,rc) \
|
|
|
|
if (SUCCEEDED(r)) {\
|
|
|
|
int tmp1 = get_refcount( (IUnknown *)d ); \
|
2006-07-07 15:31:56 +02:00
|
|
|
int rc_new = rc; \
|
|
|
|
ok(tmp1 == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, tmp1); \
|
2006-05-20 18:36:13 +02:00
|
|
|
} else {\
|
2007-08-09 17:23:01 +02:00
|
|
|
trace("%s failed: %#08x\n", c, r); \
|
2006-05-20 18:36:13 +02:00
|
|
|
}
|
2006-11-10 10:23:03 +01:00
|
|
|
|
2006-07-07 15:31:56 +02:00
|
|
|
#define CHECK_RELEASE(obj,d,rc) \
|
|
|
|
if (obj) { \
|
|
|
|
int tmp1, rc_new = rc; \
|
|
|
|
IUnknown_Release( obj ); \
|
|
|
|
tmp1 = get_refcount( (IUnknown *)d ); \
|
|
|
|
ok(tmp1 == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, tmp1); \
|
|
|
|
}
|
2006-11-10 10:23:03 +01:00
|
|
|
|
2006-11-09 16:06:34 +01:00
|
|
|
#define CHECK_REFCOUNT(obj,rc) \
|
|
|
|
{ \
|
|
|
|
int rc_new = rc; \
|
|
|
|
int count = get_refcount( (IUnknown *)obj ); \
|
|
|
|
ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECK_RELEASE_REFCOUNT(obj,rc) \
|
|
|
|
{ \
|
|
|
|
int rc_new = rc; \
|
|
|
|
int count = IUnknown_Release( (IUnknown *)obj ); \
|
|
|
|
ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
|
|
|
|
}
|
2006-05-20 18:36:13 +02:00
|
|
|
|
2006-11-15 00:53:40 +01:00
|
|
|
#define CHECK_ADDREF_REFCOUNT(obj,rc) \
|
|
|
|
{ \
|
|
|
|
int rc_new = rc; \
|
|
|
|
int count = IUnknown_AddRef( (IUnknown *)obj ); \
|
|
|
|
ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
|
|
|
|
}
|
|
|
|
|
2006-11-10 10:23:03 +01:00
|
|
|
#define CHECK_SURFACE_CONTAINER(obj,iid,expected) \
|
|
|
|
{ \
|
|
|
|
void *container_ptr = (void *)0x1337c0d3; \
|
|
|
|
hr = IDirect3DSurface8_GetContainer(obj, &iid, &container_ptr); \
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr) && container_ptr == expected, "GetContainer returned: hr %#08x, container_ptr %p. " \
|
|
|
|
"Expected hr %#08x, container_ptr %p\n", hr, container_ptr, S_OK, expected); \
|
2006-11-10 10:23:03 +01:00
|
|
|
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr); \
|
|
|
|
}
|
|
|
|
|
2009-03-10 09:19:04 +01:00
|
|
|
static void check_mipmap_levels(IDirect3DDevice8 *device, UINT width, UINT height, UINT count)
|
2006-11-09 02:38:29 +01:00
|
|
|
{
|
|
|
|
IDirect3DBaseTexture8* texture = NULL;
|
2009-08-31 09:57:52 +02:00
|
|
|
HRESULT hr = IDirect3DDevice8_CreateTexture( device, width, height, 0, 0,
|
|
|
|
D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, (IDirect3DTexture8**) &texture );
|
|
|
|
|
2006-11-09 02:38:29 +01:00
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
DWORD levels = IDirect3DBaseTexture8_GetLevelCount(texture);
|
|
|
|
ok(levels == count, "Invalid level count. Expected %d got %u\n", count, levels);
|
2009-08-31 09:57:52 +02:00
|
|
|
} else
|
2007-08-09 17:23:01 +02:00
|
|
|
trace("CreateTexture failed: %#08x\n", hr);
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
if (texture) IUnknown_Release( texture );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_mipmap_levels(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd = NULL;
|
|
|
|
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
IDirect3DDevice8 *pDevice = NULL;
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
2009-08-31 09:57:52 +02:00
|
|
|
|
2006-11-09 02:38:29 +01:00
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!pD3d || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
|
2006-12-31 15:28:28 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2007-08-09 17:23:01 +02:00
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#08x\n", hr);
|
2006-12-31 15:28:28 +01:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
check_mipmap_levels(pDevice, 32, 32, 6);
|
|
|
|
check_mipmap_levels(pDevice, 256, 1, 9);
|
|
|
|
check_mipmap_levels(pDevice, 1, 256, 9);
|
|
|
|
check_mipmap_levels(pDevice, 1, 1, 1);
|
|
|
|
|
2009-06-23 09:05:33 +02:00
|
|
|
cleanup:
|
|
|
|
if (pDevice)
|
|
|
|
{
|
|
|
|
UINT refcount = IUnknown_Release( pDevice );
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (pD3d) IUnknown_Release( pD3d );
|
2006-11-09 02:38:29 +01:00
|
|
|
DestroyWindow( hwnd );
|
|
|
|
}
|
|
|
|
|
2006-06-10 23:48:36 +02:00
|
|
|
static void test_swapchain(void)
|
2006-05-30 23:30:21 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd = NULL;
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
IDirect3DDevice8 *pDevice = NULL;
|
|
|
|
IDirect3DSwapChain8 *swapchain1 = NULL;
|
|
|
|
IDirect3DSwapChain8 *swapchain2 = NULL;
|
|
|
|
IDirect3DSwapChain8 *swapchain3 = NULL;
|
|
|
|
IDirect3DSurface8 *backbuffer = NULL;
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!pD3d || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
d3dpp.BackBufferCount = 0;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
|
2006-12-31 15:28:28 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2007-08-09 17:23:01 +02:00
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#08x\n", hr);
|
2006-12-31 15:28:28 +01:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-05-30 23:30:21 +02:00
|
|
|
|
|
|
|
/* Check if the back buffer count was modified */
|
|
|
|
ok(d3dpp.BackBufferCount == 1, "The back buffer count in the presentparams struct is %d\n", d3dpp.BackBufferCount);
|
|
|
|
|
|
|
|
/* Create a bunch of swapchains */
|
|
|
|
d3dpp.BackBufferCount = 0;
|
|
|
|
hr = IDirect3DDevice8_CreateAdditionalSwapChain(pDevice, &d3dpp, &swapchain1);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr), "Failed to create a swapchain (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(d3dpp.BackBufferCount == 1, "The back buffer count in the presentparams struct is %d\n", d3dpp.BackBufferCount);
|
|
|
|
|
|
|
|
d3dpp.BackBufferCount = 1;
|
|
|
|
hr = IDirect3DDevice8_CreateAdditionalSwapChain(pDevice, &d3dpp, &swapchain2);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr), "Failed to create a swapchain (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
|
|
|
|
d3dpp.BackBufferCount = 2;
|
|
|
|
hr = IDirect3DDevice8_CreateAdditionalSwapChain(pDevice, &d3dpp, &swapchain3);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr), "Failed to create a swapchain (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
if(SUCCEEDED(hr)) {
|
|
|
|
/* Swapchain 3, created with backbuffercount 2 */
|
|
|
|
backbuffer = (void *) 0xdeadbeef;
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain3, 0, 0, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr), "Failed to get the 1st back buffer (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(backbuffer != NULL && backbuffer != (void *) 0xdeadbeef, "The back buffer is %p\n", backbuffer);
|
|
|
|
if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
|
|
|
|
backbuffer = (void *) 0xdeadbeef;
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain3, 1, 0, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr), "Failed to get the 2nd back buffer (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(backbuffer != NULL && backbuffer != (void *) 0xdeadbeef, "The back buffer is %p\n", backbuffer);
|
|
|
|
if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
|
|
|
|
backbuffer = (void *) 0xdeadbeef;
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain3, 2, 0, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "GetBackBuffer returned %#08x\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
|
|
|
|
if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
|
|
|
|
backbuffer = (void *) 0xdeadbeef;
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain3, 3, 0, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(FAILED(hr), "Failed to get the back buffer (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
|
|
|
|
if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the back buffers of the swapchains */
|
|
|
|
/* Swapchain 1, created with backbuffercount 0 */
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain1, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr), "Failed to get the back buffer (%#08x)\n", hr);
|
|
|
|
ok(backbuffer != NULL, "The back buffer is NULL (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
if(backbuffer) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
|
|
|
|
backbuffer = (void *) 0xdeadbeef;
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain1, 1, 0, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(FAILED(hr), "Failed to get the back buffer (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
|
|
|
|
if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
|
|
|
|
/* Swapchain 2 - created with backbuffercount 1 */
|
|
|
|
backbuffer = (void *) 0xdeadbeef;
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain2, 0, 0, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr), "Failed to get the back buffer (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(backbuffer != NULL && backbuffer != (void *) 0xdeadbeef, "The back buffer is %p\n", backbuffer);
|
|
|
|
if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
|
|
|
|
backbuffer = (void *) 0xdeadbeef;
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain2, 1, 0, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "GetBackBuffer returned %#08x\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
|
|
|
|
if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
|
|
|
|
backbuffer = (void *) 0xdeadbeef;
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(swapchain2, 2, 0, &backbuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(FAILED(hr), "Failed to get the back buffer (%#08x)\n", hr);
|
2006-05-30 23:30:21 +02:00
|
|
|
ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
|
|
|
|
if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface8_Release(backbuffer);
|
|
|
|
|
2009-06-23 09:05:33 +02:00
|
|
|
cleanup:
|
2006-05-30 23:30:21 +02:00
|
|
|
if(swapchain1) IDirect3DSwapChain8_Release(swapchain1);
|
|
|
|
if(swapchain2) IDirect3DSwapChain8_Release(swapchain2);
|
|
|
|
if(swapchain3) IDirect3DSwapChain8_Release(swapchain3);
|
2009-06-23 09:05:33 +02:00
|
|
|
if (pDevice)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(pDevice);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (pD3d) IDirect3D8_Release(pD3d);
|
2006-05-30 23:30:21 +02:00
|
|
|
DestroyWindow( hwnd );
|
|
|
|
}
|
|
|
|
|
2006-06-10 23:48:36 +02:00
|
|
|
static void test_refcount(void)
|
2006-05-20 18:36:13 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd = NULL;
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
IDirect3DDevice8 *pDevice = NULL;
|
|
|
|
IDirect3DVertexBuffer8 *pVertexBuffer = NULL;
|
|
|
|
IDirect3DIndexBuffer8 *pIndexBuffer = NULL;
|
2006-07-07 15:31:56 +02:00
|
|
|
DWORD dVertexShader = -1;
|
|
|
|
DWORD dPixelShader = -1;
|
2006-05-20 18:36:13 +02:00
|
|
|
IDirect3DCubeTexture8 *pCubeTexture = NULL;
|
|
|
|
IDirect3DTexture8 *pTexture = NULL;
|
|
|
|
IDirect3DVolumeTexture8 *pVolumeTexture = NULL;
|
2006-11-15 00:53:40 +01:00
|
|
|
IDirect3DVolume8 *pVolumeLevel = NULL;
|
2006-05-20 18:36:13 +02:00
|
|
|
IDirect3DSurface8 *pStencilSurface = NULL;
|
2006-07-07 15:31:56 +02:00
|
|
|
IDirect3DSurface8 *pImageSurface = NULL;
|
2006-05-20 18:36:13 +02:00
|
|
|
IDirect3DSurface8 *pRenderTarget = NULL;
|
2006-11-15 23:32:57 +01:00
|
|
|
IDirect3DSurface8 *pRenderTarget2 = NULL;
|
|
|
|
IDirect3DSurface8 *pRenderTarget3 = NULL;
|
2006-05-20 18:36:13 +02:00
|
|
|
IDirect3DSurface8 *pTextureLevel = NULL;
|
2006-11-09 16:06:34 +01:00
|
|
|
IDirect3DSurface8 *pBackBuffer = NULL;
|
2006-07-07 15:31:56 +02:00
|
|
|
DWORD dStateBlock = -1;
|
2006-05-20 18:36:13 +02:00
|
|
|
IDirect3DSwapChain8 *pSwapChain = NULL;
|
2007-07-24 15:33:37 +02:00
|
|
|
D3DCAPS8 caps;
|
2006-05-20 18:36:13 +02:00
|
|
|
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
2006-07-07 15:31:56 +02:00
|
|
|
int refcount = 0, tmp;
|
2006-05-20 18:36:13 +02:00
|
|
|
|
|
|
|
DWORD decl[] =
|
|
|
|
{
|
|
|
|
D3DVSD_STREAM(0),
|
|
|
|
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3), /* D3DVSDE_POSITION, Register v0 */
|
|
|
|
D3DVSD_REG(D3DVSDE_DIFFUSE, D3DVSDT_D3DCOLOR), /* D3DVSDE_DIFFUSE, Register v5 */
|
2009-08-25 08:17:13 +02:00
|
|
|
D3DVSD_END()
|
2006-05-20 18:36:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!pD3d || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
2006-11-09 16:06:34 +01:00
|
|
|
d3dpp.EnableAutoDepthStencil = TRUE;
|
|
|
|
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
|
2006-05-20 18:36:13 +02:00
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
|
2006-12-31 15:28:28 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2007-08-09 17:23:01 +02:00
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#08x\n", hr);
|
2006-12-31 15:28:28 +01:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2007-07-24 15:33:37 +02:00
|
|
|
IDirect3DDevice8_GetDeviceCaps(pDevice, &caps);
|
2006-05-20 18:36:13 +02:00
|
|
|
|
2006-07-07 15:31:56 +02:00
|
|
|
refcount = get_refcount( (IUnknown *)pDevice );
|
|
|
|
ok(refcount == 1, "Invalid device RefCount %d\n", refcount);
|
2006-05-20 18:36:13 +02:00
|
|
|
|
2006-11-09 16:06:34 +01:00
|
|
|
/**
|
|
|
|
* Check refcount of implicit surfaces. Findings:
|
2006-11-10 10:23:03 +01:00
|
|
|
* - the container is the device
|
2008-03-26 22:23:36 +01:00
|
|
|
* - they hold a reference to the device
|
|
|
|
* - they are created with a refcount of 0 (Get/Release returns original refcount)
|
2006-11-15 23:32:57 +01:00
|
|
|
* - they are not freed if refcount reaches 0.
|
2006-11-15 00:53:40 +01:00
|
|
|
* - the refcount is not forwarded to the container.
|
2006-11-09 16:06:34 +01:00
|
|
|
*/
|
|
|
|
hr = IDirect3DDevice8_GetRenderTarget(pDevice, &pRenderTarget);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_CALL( hr, "GetRenderTarget", pDevice, ++refcount);
|
2006-11-09 16:06:34 +01:00
|
|
|
if(pRenderTarget)
|
|
|
|
{
|
2006-12-18 00:17:38 +01:00
|
|
|
CHECK_SURFACE_CONTAINER( pRenderTarget, IID_IDirect3DDevice8, pDevice);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_REFCOUNT( pRenderTarget, 1);
|
2006-11-15 00:53:40 +01:00
|
|
|
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_ADDREF_REFCOUNT(pRenderTarget, 2);
|
|
|
|
CHECK_REFCOUNT(pDevice, refcount);
|
|
|
|
CHECK_RELEASE_REFCOUNT(pRenderTarget, 1);
|
|
|
|
CHECK_REFCOUNT(pDevice, refcount);
|
2006-11-15 00:53:40 +01:00
|
|
|
|
2006-11-09 16:06:34 +01:00
|
|
|
hr = IDirect3DDevice8_GetRenderTarget(pDevice, &pRenderTarget);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_CALL( hr, "GetRenderTarget", pDevice, refcount);
|
|
|
|
CHECK_REFCOUNT( pRenderTarget, 2);
|
|
|
|
CHECK_RELEASE_REFCOUNT( pRenderTarget, 1);
|
|
|
|
CHECK_RELEASE_REFCOUNT( pRenderTarget, 0);
|
2006-11-15 00:54:17 +01:00
|
|
|
CHECK_REFCOUNT( pDevice, --refcount);
|
|
|
|
|
|
|
|
/* The render target is released with the device, so AddRef with refcount=0 is fine here. */
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_ADDREF_REFCOUNT(pRenderTarget, 1);
|
|
|
|
CHECK_REFCOUNT(pDevice, ++refcount);
|
|
|
|
CHECK_RELEASE_REFCOUNT(pRenderTarget, 0);
|
2006-11-15 00:54:17 +01:00
|
|
|
CHECK_REFCOUNT(pDevice, --refcount);
|
2006-11-09 16:06:34 +01:00
|
|
|
}
|
|
|
|
|
2006-11-15 00:53:18 +01:00
|
|
|
/* Render target and back buffer are identical. */
|
|
|
|
hr = IDirect3DDevice8_GetBackBuffer(pDevice, 0, 0, &pBackBuffer);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_CALL( hr, "GetBackBuffer", pDevice, ++refcount);
|
2006-11-15 00:53:18 +01:00
|
|
|
if(pBackBuffer)
|
|
|
|
{
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_RELEASE_REFCOUNT(pBackBuffer, 0);
|
2006-11-15 00:53:18 +01:00
|
|
|
ok(pRenderTarget == pBackBuffer, "RenderTarget=%p and BackBuffer=%p should be the same.\n",
|
|
|
|
pRenderTarget, pBackBuffer);
|
|
|
|
pBackBuffer = NULL;
|
|
|
|
}
|
|
|
|
CHECK_REFCOUNT( pDevice, --refcount);
|
|
|
|
|
2006-11-09 16:06:34 +01:00
|
|
|
hr = IDirect3DDevice8_GetDepthStencilSurface(pDevice, &pStencilSurface);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_CALL( hr, "GetDepthStencilSurface", pDevice, ++refcount);
|
2006-11-09 16:06:34 +01:00
|
|
|
if(pStencilSurface)
|
|
|
|
{
|
2006-11-10 10:23:03 +01:00
|
|
|
CHECK_SURFACE_CONTAINER( pStencilSurface, IID_IDirect3DDevice8, pDevice);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_REFCOUNT( pStencilSurface, 1);
|
2006-11-15 00:53:40 +01:00
|
|
|
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_ADDREF_REFCOUNT(pStencilSurface, 2);
|
|
|
|
CHECK_REFCOUNT(pDevice, refcount);
|
|
|
|
CHECK_RELEASE_REFCOUNT(pStencilSurface, 1);
|
|
|
|
CHECK_REFCOUNT(pDevice, refcount);
|
2006-11-15 00:53:40 +01:00
|
|
|
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_RELEASE_REFCOUNT( pStencilSurface, 0);
|
2006-11-15 00:54:17 +01:00
|
|
|
CHECK_REFCOUNT( pDevice, --refcount);
|
|
|
|
|
|
|
|
/* The stencil surface is released with the device, so AddRef with refcount=0 is fine here. */
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_ADDREF_REFCOUNT(pStencilSurface, 1);
|
|
|
|
CHECK_REFCOUNT(pDevice, ++refcount);
|
|
|
|
CHECK_RELEASE_REFCOUNT(pStencilSurface, 0);
|
2006-11-15 00:54:17 +01:00
|
|
|
CHECK_REFCOUNT(pDevice, --refcount);
|
2006-11-09 16:06:34 +01:00
|
|
|
pStencilSurface = NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Buffers */
|
|
|
|
hr = IDirect3DDevice8_CreateIndexBuffer( pDevice, 16, 0, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &pIndexBuffer );
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_CALL( hr, "CreateIndexBuffer", pDevice, ++refcount );
|
2006-11-09 02:38:29 +01:00
|
|
|
if(pIndexBuffer)
|
|
|
|
{
|
|
|
|
tmp = get_refcount( (IUnknown *)pIndexBuffer );
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_SetIndices(pDevice, pIndexBuffer, 0);
|
|
|
|
CHECK_CALL( hr, "SetIndices", pIndexBuffer, tmp);
|
|
|
|
hr = IDirect3DDevice8_SetIndices(pDevice, NULL, 0);
|
|
|
|
CHECK_CALL( hr, "SetIndices", pIndexBuffer, tmp);
|
|
|
|
}
|
|
|
|
|
2006-05-20 18:36:13 +02:00
|
|
|
hr = IDirect3DDevice8_CreateVertexBuffer( pDevice, 16, 0, D3DFVF_XYZ, D3DPOOL_DEFAULT, &pVertexBuffer );
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_CALL( hr, "CreateVertexBuffer", pDevice, ++refcount );
|
2006-11-09 02:38:29 +01:00
|
|
|
if(pVertexBuffer)
|
|
|
|
{
|
2006-12-24 10:00:05 +01:00
|
|
|
IDirect3DVertexBuffer8 *pVBuf = (void*)~0;
|
|
|
|
UINT stride = ~0;
|
|
|
|
|
2006-11-09 02:38:29 +01:00
|
|
|
tmp = get_refcount( (IUnknown *)pVertexBuffer );
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_SetStreamSource(pDevice, 0, pVertexBuffer, 3 * sizeof(float));
|
|
|
|
CHECK_CALL( hr, "SetStreamSource", pVertexBuffer, tmp);
|
|
|
|
hr = IDirect3DDevice8_SetStreamSource(pDevice, 0, NULL, 0);
|
|
|
|
CHECK_CALL( hr, "SetStreamSource", pVertexBuffer, tmp);
|
2006-12-24 10:00:05 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDevice8_GetStreamSource(pDevice, 0, &pVBuf, &stride);
|
|
|
|
ok(SUCCEEDED(hr), "GetStreamSource did not succeed with NULL stream!\n");
|
|
|
|
ok(pVBuf==NULL, "pVBuf not NULL (%p)!\n", pVBuf);
|
2006-12-29 12:41:32 +01:00
|
|
|
ok(stride==3*sizeof(float), "stride not 3 floats (got %u)!\n", stride);
|
2006-11-09 02:38:29 +01:00
|
|
|
}
|
2006-12-24 10:00:05 +01:00
|
|
|
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Shaders */
|
|
|
|
hr = IDirect3DDevice8_CreateVertexShader( pDevice, decl, simple_vs, &dVertexShader, 0 );
|
|
|
|
CHECK_CALL( hr, "CreateVertexShader", pDevice, refcount );
|
2007-07-24 15:33:37 +02:00
|
|
|
if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 0))
|
|
|
|
{
|
|
|
|
hr = IDirect3DDevice8_CreatePixelShader( pDevice, simple_ps, &dPixelShader );
|
|
|
|
CHECK_CALL( hr, "CreatePixelShader", pDevice, refcount );
|
|
|
|
}
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Textures */
|
|
|
|
hr = IDirect3DDevice8_CreateTexture( pDevice, 32, 32, 3, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pTexture );
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_CALL( hr, "CreateTexture", pDevice, ++refcount );
|
2006-05-20 18:36:13 +02:00
|
|
|
if (pTexture)
|
|
|
|
{
|
|
|
|
tmp = get_refcount( (IUnknown *)pTexture );
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
/* SetTexture should not increase refcounts */
|
|
|
|
hr = IDirect3DDevice8_SetTexture(pDevice, 0, (IDirect3DBaseTexture8 *) pTexture);
|
|
|
|
CHECK_CALL( hr, "SetTexture", pTexture, tmp);
|
|
|
|
hr = IDirect3DDevice8_SetTexture(pDevice, 0, NULL);
|
|
|
|
CHECK_CALL( hr, "SetTexture", pTexture, tmp);
|
|
|
|
|
2006-05-20 18:36:13 +02:00
|
|
|
/* This should not increment device refcount */
|
|
|
|
hr = IDirect3DTexture8_GetSurfaceLevel( pTexture, 1, &pTextureLevel );
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_CALL( hr, "GetSurfaceLevel", pDevice, refcount );
|
2006-05-20 18:36:13 +02:00
|
|
|
/* But should increment texture's refcount */
|
2006-11-15 00:53:40 +01:00
|
|
|
CHECK_REFCOUNT( pTexture, tmp+1 );
|
|
|
|
/* Because the texture and surface refcount are identical */
|
|
|
|
if (pTextureLevel)
|
|
|
|
{
|
|
|
|
CHECK_REFCOUNT ( pTextureLevel, tmp+1 );
|
|
|
|
CHECK_ADDREF_REFCOUNT ( pTextureLevel, tmp+2 );
|
|
|
|
CHECK_REFCOUNT ( pTexture , tmp+2 );
|
|
|
|
CHECK_RELEASE_REFCOUNT( pTextureLevel, tmp+1 );
|
|
|
|
CHECK_REFCOUNT ( pTexture , tmp+1 );
|
|
|
|
CHECK_RELEASE_REFCOUNT( pTexture , tmp );
|
|
|
|
CHECK_REFCOUNT ( pTextureLevel, tmp );
|
|
|
|
}
|
2006-05-20 18:36:13 +02:00
|
|
|
}
|
2007-07-24 15:35:08 +02:00
|
|
|
if(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP)
|
|
|
|
{
|
|
|
|
hr = IDirect3DDevice8_CreateCubeTexture( pDevice, 32, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pCubeTexture );
|
|
|
|
CHECK_CALL( hr, "CreateCubeTexture", pDevice, ++refcount );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("Cube textures not supported\n");
|
|
|
|
}
|
2007-07-24 15:36:15 +02:00
|
|
|
if(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)
|
|
|
|
{
|
|
|
|
hr = IDirect3DDevice8_CreateVolumeTexture( pDevice, 32, 32, 2, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pVolumeTexture );
|
|
|
|
CHECK_CALL( hr, "CreateVolumeTexture", pDevice, ++refcount );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("Volume textures not supported\n");
|
|
|
|
}
|
|
|
|
|
2006-11-15 00:53:40 +01:00
|
|
|
if (pVolumeTexture)
|
|
|
|
{
|
|
|
|
tmp = get_refcount( (IUnknown *)pVolumeTexture );
|
|
|
|
|
|
|
|
/* This should not increment device refcount */
|
|
|
|
hr = IDirect3DVolumeTexture8_GetVolumeLevel(pVolumeTexture, 0, &pVolumeLevel);
|
|
|
|
CHECK_CALL( hr, "GetVolumeLevel", pDevice, refcount );
|
|
|
|
/* But should increment volume texture's refcount */
|
|
|
|
CHECK_REFCOUNT( pVolumeTexture, tmp+1 );
|
|
|
|
/* Because the volume texture and volume refcount are identical */
|
|
|
|
if (pVolumeLevel)
|
|
|
|
{
|
|
|
|
CHECK_REFCOUNT ( pVolumeLevel , tmp+1 );
|
|
|
|
CHECK_ADDREF_REFCOUNT ( pVolumeLevel , tmp+2 );
|
|
|
|
CHECK_REFCOUNT ( pVolumeTexture, tmp+2 );
|
|
|
|
CHECK_RELEASE_REFCOUNT( pVolumeLevel , tmp+1 );
|
|
|
|
CHECK_REFCOUNT ( pVolumeTexture, tmp+1 );
|
|
|
|
CHECK_RELEASE_REFCOUNT( pVolumeTexture, tmp );
|
|
|
|
CHECK_REFCOUNT ( pVolumeLevel , tmp );
|
|
|
|
}
|
|
|
|
}
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Surfaces */
|
2007-07-24 15:38:17 +02:00
|
|
|
hr = IDirect3DDevice8_CreateDepthStencilSurface( pDevice, 32, 32, D3DFMT_D16, D3DMULTISAMPLE_NONE, &pStencilSurface );
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_CALL( hr, "CreateDepthStencilSurface", pDevice, ++refcount );
|
2006-12-14 01:55:48 +01:00
|
|
|
CHECK_REFCOUNT( pStencilSurface, 1);
|
2006-05-20 18:36:13 +02:00
|
|
|
hr = IDirect3DDevice8_CreateImageSurface( pDevice, 32, 32, D3DFMT_X8R8G8B8, &pImageSurface );
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_CALL( hr, "CreateImageSurface", pDevice, ++refcount );
|
2006-12-14 01:55:48 +01:00
|
|
|
CHECK_REFCOUNT( pImageSurface, 1);
|
2006-11-15 23:32:57 +01:00
|
|
|
hr = IDirect3DDevice8_CreateRenderTarget( pDevice, 32, 32, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONE, TRUE, &pRenderTarget3 );
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_CALL( hr, "CreateRenderTarget", pDevice, ++refcount );
|
2006-12-14 01:55:48 +01:00
|
|
|
CHECK_REFCOUNT( pRenderTarget3, 1);
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Misc */
|
|
|
|
hr = IDirect3DDevice8_CreateStateBlock( pDevice, D3DSBT_ALL, &dStateBlock );
|
|
|
|
CHECK_CALL( hr, "CreateStateBlock", pDevice, refcount );
|
|
|
|
hr = IDirect3DDevice8_CreateAdditionalSwapChain( pDevice, &d3dpp, &pSwapChain );
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_CALL( hr, "CreateAdditionalSwapChain", pDevice, ++refcount );
|
2006-11-09 16:06:34 +01:00
|
|
|
if(pSwapChain)
|
|
|
|
{
|
|
|
|
/* check implicit back buffer */
|
|
|
|
hr = IDirect3DSwapChain8_GetBackBuffer(pSwapChain, 0, 0, &pBackBuffer);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_CALL( hr, "GetBackBuffer", pDevice, ++refcount);
|
2006-12-05 00:29:37 +01:00
|
|
|
CHECK_REFCOUNT( pSwapChain, 1);
|
2006-11-09 16:06:34 +01:00
|
|
|
if(pBackBuffer)
|
|
|
|
{
|
2006-12-18 00:17:38 +01:00
|
|
|
CHECK_SURFACE_CONTAINER( pBackBuffer, IID_IDirect3DDevice8, pDevice);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_REFCOUNT( pBackBuffer, 1);
|
|
|
|
CHECK_RELEASE_REFCOUNT( pBackBuffer, 0);
|
2006-11-15 00:54:17 +01:00
|
|
|
CHECK_REFCOUNT( pDevice, --refcount);
|
|
|
|
|
|
|
|
/* The back buffer is released with the swapchain, so AddRef with refcount=0 is fine here. */
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_ADDREF_REFCOUNT(pBackBuffer, 1);
|
|
|
|
CHECK_REFCOUNT(pDevice, ++refcount);
|
|
|
|
CHECK_RELEASE_REFCOUNT(pBackBuffer, 0);
|
2006-11-15 00:54:17 +01:00
|
|
|
CHECK_REFCOUNT(pDevice, --refcount);
|
2006-11-09 16:06:34 +01:00
|
|
|
pBackBuffer = NULL;
|
|
|
|
}
|
|
|
|
CHECK_REFCOUNT( pSwapChain, 1);
|
|
|
|
}
|
2006-05-20 18:36:13 +02:00
|
|
|
|
2006-06-27 13:11:13 +02:00
|
|
|
if(pVertexBuffer)
|
|
|
|
{
|
|
|
|
BYTE *data;
|
|
|
|
/* Vertex buffers can be locked multiple times */
|
|
|
|
hr = IDirect3DVertexBuffer8_Lock(pVertexBuffer, 0, 0, &data, 0);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DVertexBuffer8::Lock failed with %#08x\n", hr);
|
2006-06-27 13:11:13 +02:00
|
|
|
hr = IDirect3DVertexBuffer8_Lock(pVertexBuffer, 0, 0, &data, 0);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DVertexBuffer8::Lock failed with %#08x\n", hr);
|
2006-06-27 13:11:13 +02:00
|
|
|
hr = IDirect3DVertexBuffer8_Unlock(pVertexBuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DVertexBuffer8::Unlock failed with %#08x\n", hr);
|
2006-06-27 13:11:13 +02:00
|
|
|
hr = IDirect3DVertexBuffer8_Unlock(pVertexBuffer);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DVertexBuffer8::Unlock failed with %#08x\n", hr);
|
2006-06-27 13:11:13 +02:00
|
|
|
}
|
|
|
|
|
2006-11-15 23:32:57 +01:00
|
|
|
/* The implicit render target is not freed if refcount reaches 0.
|
|
|
|
* Otherwise GetRenderTarget would re-allocate it and the pointer would change.*/
|
|
|
|
hr = IDirect3DDevice8_GetRenderTarget(pDevice, &pRenderTarget2);
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_CALL( hr, "GetRenderTarget", pDevice, ++refcount);
|
2006-11-15 23:32:57 +01:00
|
|
|
if(pRenderTarget2)
|
|
|
|
{
|
2006-12-05 00:29:48 +01:00
|
|
|
CHECK_RELEASE_REFCOUNT(pRenderTarget2, 0);
|
2006-11-15 23:32:57 +01:00
|
|
|
ok(pRenderTarget == pRenderTarget2, "RenderTarget=%p and RenderTarget2=%p should be the same.\n",
|
|
|
|
pRenderTarget, pRenderTarget2);
|
|
|
|
CHECK_REFCOUNT( pDevice, --refcount);
|
|
|
|
pRenderTarget2 = NULL;
|
|
|
|
}
|
|
|
|
pRenderTarget = NULL;
|
|
|
|
|
2006-05-20 18:36:13 +02:00
|
|
|
cleanup:
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_RELEASE(pDevice, pDevice, --refcount);
|
2006-05-20 18:36:13 +02:00
|
|
|
|
|
|
|
/* Buffers */
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_RELEASE(pVertexBuffer, pDevice, --refcount);
|
|
|
|
CHECK_RELEASE(pIndexBuffer, pDevice, --refcount);
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Shaders */
|
2009-03-10 09:19:04 +01:00
|
|
|
if (dVertexShader != ~0U) IDirect3DDevice8_DeleteVertexShader( pDevice, dVertexShader );
|
|
|
|
if (dPixelShader != ~0U) IDirect3DDevice8_DeletePixelShader( pDevice, dPixelShader );
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Textures */
|
2006-11-15 00:53:40 +01:00
|
|
|
CHECK_RELEASE(pTexture, pDevice, --refcount);
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_RELEASE(pCubeTexture, pDevice, --refcount);
|
|
|
|
CHECK_RELEASE(pVolumeTexture, pDevice, --refcount);
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Surfaces */
|
2006-07-07 15:31:56 +02:00
|
|
|
CHECK_RELEASE(pStencilSurface, pDevice, --refcount);
|
|
|
|
CHECK_RELEASE(pImageSurface, pDevice, --refcount);
|
2006-11-15 23:32:57 +01:00
|
|
|
CHECK_RELEASE(pRenderTarget3, pDevice, --refcount);
|
2006-05-20 18:36:13 +02:00
|
|
|
/* Misc */
|
2009-03-10 09:19:04 +01:00
|
|
|
if (dStateBlock != ~0U) IDirect3DDevice8_DeleteStateBlock( pDevice, dStateBlock );
|
2006-07-07 15:31:56 +02:00
|
|
|
/* This will destroy device - cannot check the refcount here */
|
2006-11-09 16:06:34 +01:00
|
|
|
if (pSwapChain) CHECK_RELEASE_REFCOUNT( pSwapChain, 0);
|
2006-05-20 18:36:13 +02:00
|
|
|
|
2006-11-09 16:06:34 +01:00
|
|
|
if (pD3d) CHECK_RELEASE_REFCOUNT( pD3d, 0);
|
2006-05-20 18:36:13 +02:00
|
|
|
|
|
|
|
DestroyWindow( hwnd );
|
|
|
|
}
|
|
|
|
|
2006-11-09 02:38:29 +01:00
|
|
|
static void test_cursor(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd = NULL;
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
IDirect3DDevice8 *pDevice = NULL;
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
|
|
|
CURSORINFO info;
|
|
|
|
IDirect3DSurface8 *cursor = NULL;
|
|
|
|
HCURSOR cur;
|
2007-08-14 11:18:01 +02:00
|
|
|
HMODULE user32_handle = GetModuleHandleA("user32.dll");
|
|
|
|
|
|
|
|
pGetCursorInfo = (void *)GetProcAddress(user32_handle, "GetCursorInfo");
|
|
|
|
if (!pGetCursorInfo)
|
|
|
|
{
|
2009-02-25 10:27:18 +01:00
|
|
|
win_skip("GetCursorInfo is not available\n");
|
2007-08-14 11:18:01 +02:00
|
|
|
return;
|
|
|
|
}
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
info.cbSize = sizeof(info);
|
2008-10-31 16:21:22 +01:00
|
|
|
ok(pGetCursorInfo(&info), "GetCursorInfo failed\n");
|
2006-11-09 02:38:29 +01:00
|
|
|
cur = info.hCursor;
|
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!pD3d || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
|
2006-12-31 15:28:28 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2007-08-09 17:23:01 +02:00
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#08x\n", hr);
|
2006-12-31 15:28:28 +01:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
IDirect3DDevice8_CreateImageSurface(pDevice, 32, 32, D3DFMT_A8R8G8B8, &cursor);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(cursor != NULL, "IDirect3DDevice8_CreateOffscreenPlainSurface failed with %#08x\n", hr);
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
/* Initially hidden */
|
|
|
|
hr = IDirect3DDevice8_ShowCursor(pDevice, TRUE);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == FALSE, "IDirect3DDevice8_ShowCursor returned %#08x\n", hr);
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
/* Not enabled without a surface*/
|
|
|
|
hr = IDirect3DDevice8_ShowCursor(pDevice, TRUE);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == FALSE, "IDirect3DDevice8_ShowCursor returned %#08x\n", hr);
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
/* Fails */
|
|
|
|
hr = IDirect3DDevice8_SetCursorProperties(pDevice, 0, 0, NULL);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_SetCursorProperties returned %#08x\n", hr);
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDevice8_SetCursorProperties(pDevice, 0, 0, cursor);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetCursorProperties returned %#08x\n", hr);
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
IDirect3DSurface8_Release(cursor);
|
|
|
|
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
info.cbSize = sizeof(info);
|
2008-10-31 16:21:22 +01:00
|
|
|
ok(pGetCursorInfo(&info), "GetCursorInfo failed\n");
|
2006-11-09 02:38:29 +01:00
|
|
|
ok(info.flags & CURSOR_SHOWING, "The gdi cursor is hidden (%08x)\n", info.flags);
|
|
|
|
ok(info.hCursor == cur, "The cursor handle is %p\n", info.hCursor); /* unchanged */
|
|
|
|
|
|
|
|
/* Still hidden */
|
|
|
|
hr = IDirect3DDevice8_ShowCursor(pDevice, TRUE);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == FALSE, "IDirect3DDevice8_ShowCursor returned %#08x\n", hr);
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
/* Enabled now*/
|
|
|
|
hr = IDirect3DDevice8_ShowCursor(pDevice, TRUE);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == TRUE, "IDirect3DDevice8_ShowCursor returned %#08x\n", hr);
|
2006-11-09 02:38:29 +01:00
|
|
|
|
|
|
|
/* GDI cursor unchanged */
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
info.cbSize = sizeof(info);
|
2008-10-31 16:21:22 +01:00
|
|
|
ok(pGetCursorInfo(&info), "GetCursorInfo failed\n");
|
2006-11-09 02:38:29 +01:00
|
|
|
ok(info.flags & CURSOR_SHOWING, "The gdi cursor is hidden (%08x)\n", info.flags);
|
|
|
|
ok(info.hCursor == cur, "The cursor handle is %p\n", info.hCursor); /* unchanged */
|
|
|
|
|
|
|
|
cleanup:
|
2009-06-23 09:05:33 +02:00
|
|
|
if (pDevice)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(pDevice);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (pD3d) IDirect3D8_Release(pD3d);
|
2006-11-09 02:38:29 +01:00
|
|
|
}
|
|
|
|
|
2006-12-14 20:48:09 +01:00
|
|
|
static void test_states(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd = NULL;
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
IDirect3DDevice8 *pDevice = NULL;
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!pD3d || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferWidth = 640;
|
2009-03-26 10:43:38 +01:00
|
|
|
d3dpp.BackBufferHeight = 480;
|
2006-12-14 20:48:09 +01:00
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
|
2006-12-31 15:28:28 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2007-08-09 17:23:01 +02:00
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#08x\n", hr);
|
2006-12-31 15:28:28 +01:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-12-14 20:48:09 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDevice8_SetRenderState(pDevice, D3DRS_ZVISIBLE, TRUE);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState(D3DRS_ZVISIBLE, TRUE) returned %#08x\n", hr);
|
2006-12-14 20:48:09 +01:00
|
|
|
hr = IDirect3DDevice8_SetRenderState(pDevice, D3DRS_ZVISIBLE, FALSE);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState(D3DRS_ZVISIBLE, FALSE) returned %#08x\n", hr);
|
2006-12-14 20:48:09 +01:00
|
|
|
|
|
|
|
cleanup:
|
2009-06-23 09:05:33 +02:00
|
|
|
if (pDevice)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(pDevice);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (pD3d) IDirect3D8_Release(pD3d);
|
2006-12-14 20:48:09 +01:00
|
|
|
}
|
|
|
|
|
2006-12-23 14:41:53 +01:00
|
|
|
static void test_shader_versions(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
D3DCAPS8 d3dcaps;
|
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
if (pD3d != NULL) {
|
|
|
|
hr = IDirect3D8_GetDeviceCaps(pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dcaps);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(SUCCEEDED(hr) || hr == D3DERR_NOTAVAILABLE, "Failed to get D3D8 caps (%#08x)\n", hr);
|
2006-12-23 14:41:53 +01:00
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
ok(d3dcaps.VertexShaderVersion <= D3DVS_VERSION(1,1), "Unexpected VertexShaderVersion (%#x > %#x)\n", d3dcaps.VertexShaderVersion, D3DVS_VERSION(1,1));
|
|
|
|
ok(d3dcaps.PixelShaderVersion <= D3DPS_VERSION(1,4), "Unexpected PixelShaderVersion (%#x > %#x)\n", d3dcaps.PixelShaderVersion, D3DPS_VERSION(1,4));
|
2007-07-24 21:56:03 +02:00
|
|
|
} else {
|
|
|
|
skip("No Direct3D support\n");
|
2006-12-23 14:41:53 +01:00
|
|
|
}
|
|
|
|
IDirect3D8_Release(pD3d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-20 13:44:08 +01:00
|
|
|
/* Test adapter display modes */
|
|
|
|
static void test_display_modes(void)
|
|
|
|
{
|
|
|
|
UINT max_modes, i;
|
|
|
|
D3DDISPLAYMODE dmode;
|
|
|
|
HRESULT res;
|
|
|
|
IDirect3D8 *pD3d;
|
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
if(!pD3d) return;
|
|
|
|
|
|
|
|
max_modes = IDirect3D8_GetAdapterModeCount(pD3d, D3DADAPTER_DEFAULT);
|
2009-02-25 12:06:02 +01:00
|
|
|
ok(max_modes > 0 ||
|
|
|
|
broken(max_modes == 0), /* VMware */
|
|
|
|
"GetAdapterModeCount(D3DADAPTER_DEFAULT) returned 0!\n");
|
2006-12-20 13:44:08 +01:00
|
|
|
|
|
|
|
for(i=0; i<max_modes;i++) {
|
|
|
|
res = IDirect3D8_EnumAdapterModes(pD3d, D3DADAPTER_DEFAULT, i, &dmode);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(res==D3D_OK, "EnumAdapterModes returned %#08x for mode %u!\n", res, i);
|
2006-12-20 13:44:08 +01:00
|
|
|
if(res != D3D_OK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ok(dmode.Format==D3DFMT_X8R8G8B8 || dmode.Format==D3DFMT_R5G6B5,
|
|
|
|
"Unexpected display mode returned for mode %u: %#x\n", i , dmode.Format);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirect3D8_Release(pD3d);
|
|
|
|
}
|
|
|
|
|
2007-02-09 16:35:45 +01:00
|
|
|
static void test_scene(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd = NULL;
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
IDirect3DDevice8 *pDevice = NULL;
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!pD3d || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferWidth = 800;
|
2009-03-26 10:43:38 +01:00
|
|
|
d3dpp.BackBufferHeight = 600;
|
2007-02-09 16:35:45 +01:00
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
|
2009-01-27 02:17:58 +01:00
|
|
|
ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL || broken(hr == D3DERR_NOTAVAILABLE), "IDirect3D8_CreateDevice failed with %#08x\n", hr);
|
2007-07-24 21:56:03 +02:00
|
|
|
if(!pDevice)
|
|
|
|
{
|
2007-08-09 17:23:01 +02:00
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#08x\n", hr);
|
2007-07-24 21:56:03 +02:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2007-02-09 16:35:45 +01:00
|
|
|
|
|
|
|
/* Test an EndScene without beginscene. Should return an error */
|
|
|
|
hr = IDirect3DDevice8_EndScene(pDevice);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_EndScene returned %#08x\n", hr);
|
2007-02-09 16:35:45 +01:00
|
|
|
|
|
|
|
/* Test a normal BeginScene / EndScene pair, this should work */
|
|
|
|
hr = IDirect3DDevice8_BeginScene(pDevice);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed with %#08x\n", hr);
|
2007-02-09 16:35:45 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IDirect3DDevice8_EndScene(pDevice);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed with %#08x\n", hr);
|
2007-02-09 16:35:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Test another EndScene without having begun a new scene. Should return an error */
|
|
|
|
hr = IDirect3DDevice8_EndScene(pDevice);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_EndScene returned %#08x\n", hr);
|
2007-02-09 16:35:45 +01:00
|
|
|
|
|
|
|
/* Two nested BeginScene and EndScene calls */
|
|
|
|
hr = IDirect3DDevice8_BeginScene(pDevice);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed with %#08x\n", hr);
|
2007-02-09 16:35:45 +01:00
|
|
|
hr = IDirect3DDevice8_BeginScene(pDevice);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_BeginScene returned %#08x\n", hr);
|
2007-02-09 16:35:45 +01:00
|
|
|
hr = IDirect3DDevice8_EndScene(pDevice);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed with %#08x\n", hr);
|
2007-02-09 16:35:45 +01:00
|
|
|
hr = IDirect3DDevice8_EndScene(pDevice);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_EndScene returned %#08x\n", hr);
|
2007-02-09 16:35:45 +01:00
|
|
|
|
|
|
|
/* StretchRect does not exit in Direct3D8, so no equivalent to the d3d9 stretchrect tests */
|
|
|
|
|
|
|
|
cleanup:
|
2009-06-23 09:05:33 +02:00
|
|
|
if (pDevice)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(pDevice);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (pD3d) IDirect3D8_Release(pD3d);
|
2007-02-09 16:35:45 +01:00
|
|
|
if(hwnd) DestroyWindow(hwnd);
|
|
|
|
}
|
2006-12-20 13:44:08 +01:00
|
|
|
|
2007-02-12 19:21:45 +01:00
|
|
|
static void test_shader(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd = NULL;
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
IDirect3DDevice8 *pDevice = NULL;
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
|
|
|
DWORD hPixelShader = 0, hVertexShader = 0;
|
|
|
|
DWORD hPixelShader2 = 0, hVertexShader2 = 0;
|
|
|
|
DWORD hTempHandle;
|
2007-07-24 15:43:23 +02:00
|
|
|
D3DCAPS8 caps;
|
2008-12-15 16:35:15 +01:00
|
|
|
DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE;
|
2007-03-08 01:16:16 +01:00
|
|
|
DWORD data_size;
|
|
|
|
void *data;
|
2007-02-12 19:21:45 +01:00
|
|
|
|
|
|
|
static DWORD dwVertexDecl[] =
|
|
|
|
{
|
|
|
|
D3DVSD_STREAM(0),
|
|
|
|
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3),
|
|
|
|
D3DVSD_END()
|
|
|
|
};
|
2008-03-27 20:11:36 +01:00
|
|
|
DWORD decl_normal_float2[] =
|
|
|
|
{
|
|
|
|
D3DVSD_STREAM(0),
|
|
|
|
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3), /* D3DVSDE_POSITION, Register v0 */
|
|
|
|
D3DVSD_REG(D3DVSDE_NORMAL, D3DVSDT_FLOAT2), /* D3DVSDE_NORMAL, Register v1 */
|
|
|
|
D3DVSD_END()
|
|
|
|
};
|
|
|
|
DWORD decl_normal_float4[] =
|
|
|
|
{
|
|
|
|
D3DVSD_STREAM(0),
|
|
|
|
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3), /* D3DVSDE_POSITION, Register v0 */
|
|
|
|
D3DVSD_REG(D3DVSDE_NORMAL, D3DVSDT_FLOAT4), /* D3DVSDE_NORMAL, Register v1 */
|
|
|
|
D3DVSD_END()
|
|
|
|
};
|
|
|
|
DWORD decl_normal_d3dcolor[] =
|
|
|
|
{
|
|
|
|
D3DVSD_STREAM(0),
|
|
|
|
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3), /* D3DVSDE_POSITION, Register v0 */
|
|
|
|
D3DVSD_REG(D3DVSDE_NORMAL, D3DVSDT_D3DCOLOR),/* D3DVSDE_NORMAL, Register v1 */
|
|
|
|
D3DVSD_END()
|
|
|
|
};
|
2007-03-08 01:16:16 +01:00
|
|
|
const DWORD vertex_decl_size = sizeof(dwVertexDecl);
|
|
|
|
const DWORD simple_vs_size = sizeof(simple_vs);
|
|
|
|
const DWORD simple_ps_size = sizeof(simple_ps);
|
2007-02-12 19:21:45 +01:00
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!pD3d || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferWidth = 800;
|
2009-03-26 10:43:38 +01:00
|
|
|
d3dpp.BackBufferHeight = 600;
|
2007-02-12 19:21:45 +01:00
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
|
2009-01-27 02:17:58 +01:00
|
|
|
ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL || broken(hr == D3DERR_NOTAVAILABLE), "IDirect3D8_CreateDevice failed with %#08x\n", hr);
|
2007-07-24 21:56:03 +02:00
|
|
|
if(!pDevice)
|
|
|
|
{
|
2007-08-09 17:23:01 +02:00
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#08x\n", hr);
|
2007-07-24 21:56:03 +02:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2007-07-24 15:43:23 +02:00
|
|
|
IDirect3DDevice8_GetDeviceCaps(pDevice, &caps);
|
2007-02-12 19:21:45 +01:00
|
|
|
|
2008-12-15 16:35:15 +01:00
|
|
|
/* Test setting and retrieving a FVF */
|
|
|
|
hr = IDirect3DDevice8_SetVertexShader(pDevice, fvf);
|
|
|
|
ok(SUCCEEDED(hr), "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
|
|
|
|
hr = IDirect3DDevice8_GetVertexShader(pDevice, &hTempHandle);
|
|
|
|
ok(SUCCEEDED(hr), "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
|
|
|
|
ok(hTempHandle == fvf, "Vertex shader %#08x is set, expected %#08x\n", hTempHandle, fvf);
|
|
|
|
|
2007-02-12 19:21:45 +01:00
|
|
|
/* First create a vertex shader */
|
2008-12-15 16:35:15 +01:00
|
|
|
hr = IDirect3DDevice8_SetVertexShader(pDevice, 0);
|
|
|
|
ok(SUCCEEDED(hr), "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
|
2007-03-08 01:16:16 +01:00
|
|
|
hr = IDirect3DDevice8_CreateVertexShader(pDevice, dwVertexDecl, simple_vs, &hVertexShader, 0);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
/* Msdn says that the new vertex shader is set immediately. This is wrong, apparently */
|
|
|
|
hr = IDirect3DDevice8_GetVertexShader(pDevice, &hTempHandle);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
ok(hTempHandle == 0, "Vertex Shader %d is set, expected shader %d\n", hTempHandle, 0);
|
|
|
|
/* Assign the shader, then verify that GetVertexShader works */
|
|
|
|
hr = IDirect3DDevice8_SetVertexShader(pDevice, hVertexShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
hr = IDirect3DDevice8_GetVertexShader(pDevice, &hTempHandle);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
ok(hTempHandle == hVertexShader, "Vertex Shader %d is set, expected shader %d\n", hTempHandle, hVertexShader);
|
2007-03-08 01:16:16 +01:00
|
|
|
/* Verify that we can retrieve the declaration */
|
|
|
|
hr = IDirect3DDevice8_GetVertexShaderDeclaration(pDevice, hVertexShader, NULL, &data_size);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShaderDeclaration returned %#08x\n", hr);
|
2007-03-08 01:16:16 +01:00
|
|
|
ok(data_size == vertex_decl_size, "Got data_size %u, expected %u\n", data_size, vertex_decl_size);
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, vertex_decl_size);
|
|
|
|
data_size = 1;
|
|
|
|
hr = IDirect3DDevice8_GetVertexShaderDeclaration(pDevice, hVertexShader, data, &data_size);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_GetVertexShaderDeclaration returned (%#08x), "
|
|
|
|
"expected D3DERR_INVALIDCALL\n", hr);
|
2007-03-08 01:16:16 +01:00
|
|
|
ok(data_size == 1, "Got data_size %u, expected 1\n", data_size);
|
|
|
|
data_size = vertex_decl_size;
|
|
|
|
hr = IDirect3DDevice8_GetVertexShaderDeclaration(pDevice, hVertexShader, data, &data_size);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShaderDeclaration returned %#08x\n", hr);
|
2007-03-08 01:16:16 +01:00
|
|
|
ok(data_size == vertex_decl_size, "Got data_size %u, expected %u\n", data_size, vertex_decl_size);
|
|
|
|
ok(!memcmp(data, dwVertexDecl, vertex_decl_size), "data not equal to shader declaration\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
/* Verify that we can retrieve the shader function */
|
|
|
|
hr = IDirect3DDevice8_GetVertexShaderFunction(pDevice, hVertexShader, NULL, &data_size);
|
2008-02-13 22:11:01 +01:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShaderFunction returned %#08x\n", hr);
|
2007-03-08 01:16:16 +01:00
|
|
|
ok(data_size == simple_vs_size, "Got data_size %u, expected %u\n", data_size, simple_vs_size);
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, simple_vs_size);
|
|
|
|
data_size = 1;
|
|
|
|
hr = IDirect3DDevice8_GetVertexShaderFunction(pDevice, hVertexShader, data, &data_size);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_GetVertexShaderFunction returned (%#08x), "
|
|
|
|
"expected D3DERR_INVALIDCALL\n", hr);
|
2007-03-08 01:16:16 +01:00
|
|
|
ok(data_size == 1, "Got data_size %u, expected 1\n", data_size);
|
|
|
|
data_size = simple_vs_size;
|
|
|
|
hr = IDirect3DDevice8_GetVertexShaderFunction(pDevice, hVertexShader, data, &data_size);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShaderFunction returned %#08x\n", hr);
|
2007-03-08 01:16:16 +01:00
|
|
|
ok(data_size == simple_vs_size, "Got data_size %u, expected %u\n", data_size, simple_vs_size);
|
|
|
|
ok(!memcmp(data, simple_vs, simple_vs_size), "data not equal to shader function\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
2007-02-12 19:21:45 +01:00
|
|
|
/* Delete the assigned shader. This is supposed to work */
|
|
|
|
hr = IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
/* The shader should be unset now */
|
|
|
|
hr = IDirect3DDevice8_GetVertexShader(pDevice, &hTempHandle);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
ok(hTempHandle == 0, "Vertex Shader %d is set, expected shader %d\n", hTempHandle, 0);
|
|
|
|
|
2008-03-27 20:11:36 +01:00
|
|
|
/* Test a broken declaration. 3DMark2001 tries to use normals with 2 components
|
|
|
|
* First try the fixed function shader function, then a custom one
|
|
|
|
*/
|
|
|
|
hr = IDirect3DDevice8_CreateVertexShader(pDevice, decl_normal_float2, 0, &hVertexShader, 0);
|
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader);
|
|
|
|
hr = IDirect3DDevice8_CreateVertexShader(pDevice, decl_normal_float4, 0, &hVertexShader, 0);
|
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader);
|
|
|
|
hr = IDirect3DDevice8_CreateVertexShader(pDevice, decl_normal_d3dcolor, 0, &hVertexShader, 0);
|
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_CreateVertexShader(pDevice, decl_normal_float2, simple_vs, &hVertexShader, 0);
|
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader);
|
|
|
|
|
2007-07-24 15:43:23 +02:00
|
|
|
if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 0))
|
|
|
|
{
|
|
|
|
/* The same with a pixel shader */
|
|
|
|
hr = IDirect3DDevice8_CreatePixelShader(pDevice, simple_ps, &hPixelShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
/* Msdn says that the new pixel shader is set immediately. This is wrong, apparently */
|
|
|
|
hr = IDirect3DDevice8_GetPixelShader(pDevice, &hTempHandle);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
ok(hTempHandle == 0, "Pixel Shader %d is set, expected shader %d\n", hTempHandle, 0);
|
|
|
|
/* Assign the shader, then verify that GetPixelShader works */
|
|
|
|
hr = IDirect3DDevice8_SetPixelShader(pDevice, hPixelShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
hr = IDirect3DDevice8_GetPixelShader(pDevice, &hTempHandle);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
ok(hTempHandle == hPixelShader, "Pixel Shader %d is set, expected shader %d\n", hTempHandle, hPixelShader);
|
|
|
|
/* Verify that we can retrieve the shader function */
|
|
|
|
hr = IDirect3DDevice8_GetPixelShaderFunction(pDevice, hPixelShader, NULL, &data_size);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShaderFunction returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
ok(data_size == simple_ps_size, "Got data_size %u, expected %u\n", data_size, simple_ps_size);
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, simple_ps_size);
|
|
|
|
data_size = 1;
|
|
|
|
hr = IDirect3DDevice8_GetPixelShaderFunction(pDevice, hPixelShader, data, &data_size);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_GetPixelShaderFunction returned (%#08x), "
|
|
|
|
"expected D3DERR_INVALIDCALL\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
ok(data_size == 1, "Got data_size %u, expected 1\n", data_size);
|
|
|
|
data_size = simple_ps_size;
|
|
|
|
hr = IDirect3DDevice8_GetPixelShaderFunction(pDevice, hPixelShader, data, &data_size);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShaderFunction returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
ok(data_size == simple_ps_size, "Got data_size %u, expected %u\n", data_size, simple_ps_size);
|
|
|
|
ok(!memcmp(data, simple_ps, simple_ps_size), "data not equal to shader function\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
/* Delete the assigned shader. This is supposed to work */
|
|
|
|
hr = IDirect3DDevice8_DeletePixelShader(pDevice, hPixelShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
/* The shader should be unset now */
|
|
|
|
hr = IDirect3DDevice8_GetPixelShader(pDevice, &hTempHandle);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
ok(hTempHandle == 0, "Pixel Shader %d is set, expected shader %d\n", hTempHandle, 0);
|
|
|
|
|
|
|
|
/* What happens if a non-bound shader is deleted? */
|
|
|
|
hr = IDirect3DDevice8_CreatePixelShader(pDevice, simple_ps, &hPixelShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
hr = IDirect3DDevice8_CreatePixelShader(pDevice, simple_ps, &hPixelShader2);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDevice8_SetPixelShader(pDevice, hPixelShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
hr = IDirect3DDevice8_DeletePixelShader(pDevice, hPixelShader2);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
hr = IDirect3DDevice8_GetPixelShader(pDevice, &hTempHandle);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
ok(hTempHandle == hPixelShader, "Pixel Shader %d is set, expected shader %d\n", hTempHandle, hPixelShader);
|
|
|
|
hr = IDirect3DDevice8_DeletePixelShader(pDevice, hPixelShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
|
2009-06-16 09:38:25 +02:00
|
|
|
|
|
|
|
/* Check for double delete. */
|
|
|
|
hr = IDirect3DDevice8_DeletePixelShader(pDevice, hPixelShader2);
|
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
|
|
|
|
hr = IDirect3DDevice8_DeletePixelShader(pDevice, hPixelShader);
|
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
|
2007-07-24 15:43:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("Pixel shaders not supported\n");
|
|
|
|
}
|
2007-02-12 19:21:45 +01:00
|
|
|
|
|
|
|
/* What happens if a non-bound shader is deleted? */
|
|
|
|
hr = IDirect3DDevice8_CreateVertexShader(pDevice, dwVertexDecl, NULL, &hVertexShader, 0);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
hr = IDirect3DDevice8_CreateVertexShader(pDevice, dwVertexDecl, NULL, &hVertexShader2, 0);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDevice8_SetVertexShader(pDevice, hVertexShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
hr = IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader2);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
hr = IDirect3DDevice8_GetVertexShader(pDevice, &hTempHandle);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
ok(hTempHandle == hVertexShader, "Vertex Shader %d is set, expected shader %d\n", hTempHandle, hVertexShader);
|
|
|
|
hr = IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
|
2007-02-12 19:21:45 +01:00
|
|
|
|
2009-06-16 09:38:25 +02:00
|
|
|
/* Check for double delete. */
|
|
|
|
hr = IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader2);
|
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
|
|
|
|
hr = IDirect3DDevice8_DeleteVertexShader(pDevice, hVertexShader);
|
|
|
|
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
|
|
|
|
|
2007-02-12 19:21:45 +01:00
|
|
|
cleanup:
|
2009-06-23 09:05:33 +02:00
|
|
|
if (pDevice)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(pDevice);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (pD3d) IDirect3D8_Release(pD3d);
|
2007-02-12 19:21:45 +01:00
|
|
|
if(hwnd) DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2007-02-19 15:24:48 +01:00
|
|
|
static void test_limits(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd = NULL;
|
|
|
|
IDirect3D8 *pD3d = NULL;
|
|
|
|
IDirect3DDevice8 *pDevice = NULL;
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
|
|
|
IDirect3DTexture8 *pTexture = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
pD3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(pD3d != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!pD3d || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferWidth = 800;
|
2009-03-26 10:43:38 +01:00
|
|
|
d3dpp.BackBufferHeight = 600;
|
2007-02-19 15:24:48 +01:00
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
d3dpp.EnableAutoDepthStencil = TRUE;
|
|
|
|
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
|
2009-01-27 02:17:58 +01:00
|
|
|
ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL || broken(hr == D3DERR_NOTAVAILABLE), "IDirect3D8_CreateDevice failed with %#08x\n", hr);
|
2007-07-24 21:56:03 +02:00
|
|
|
if(!pDevice)
|
|
|
|
{
|
2007-08-09 17:23:01 +02:00
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#08x\n", hr);
|
2007-07-24 21:56:03 +02:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2007-02-19 15:24:48 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDevice8_CreateTexture(pDevice, 16, 16, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &pTexture);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_CreateTexture failed with %#08x\n", hr);
|
2007-02-19 15:24:48 +01:00
|
|
|
if(!pTexture) goto cleanup;
|
|
|
|
|
|
|
|
/* There are 8 texture stages. We should be able to access all of them */
|
|
|
|
for(i = 0; i < 8; i++) {
|
|
|
|
hr = IDirect3DDevice8_SetTexture(pDevice, i, (IDirect3DBaseTexture8 *) pTexture);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture for sampler %d failed with %#08x\n", i, hr);
|
2007-02-19 15:24:48 +01:00
|
|
|
hr = IDirect3DDevice8_SetTexture(pDevice, i, NULL);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture for sampler %d failed with %#08x\n", i, hr);
|
2007-02-19 15:24:48 +01:00
|
|
|
hr = IDirect3DDevice8_SetTextureStageState(pDevice, i, D3DTSS_COLOROP, D3DTOP_ADD);
|
2007-08-09 17:23:01 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetTextureStageState for texture %d failed with %#08x\n", i, hr);
|
2007-02-19 15:24:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Investigations show that accessing higher textures stage states does not return an error either. Writing
|
|
|
|
* to too high texture stages(approximately texture 40) causes memory corruption in windows, so there is no
|
|
|
|
* bounds checking but how do I test that?
|
|
|
|
*/
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if(pTexture) IDirect3DTexture8_Release(pTexture);
|
2009-06-23 09:05:33 +02:00
|
|
|
if (pDevice)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(pDevice);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (pD3d) IDirect3D8_Release(pD3d);
|
2007-02-19 15:24:48 +01:00
|
|
|
if(hwnd) DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2007-11-29 13:22:47 +01:00
|
|
|
static void test_lights(void)
|
|
|
|
{
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
IDirect3DDevice8 *device = NULL;
|
|
|
|
IDirect3D8 *d3d8;
|
|
|
|
HWND hwnd;
|
|
|
|
HRESULT hr;
|
|
|
|
unsigned int i;
|
|
|
|
BOOL enabled;
|
|
|
|
D3DCAPS8 caps;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
|
|
|
|
|
|
|
d3d8 = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(d3d8 != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!d3d8 || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( d3d8, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferWidth = 800;
|
2009-03-26 10:43:38 +01:00
|
|
|
d3dpp.BackBufferHeight = 600;
|
2007-11-29 13:22:47 +01:00
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
d3dpp.EnableAutoDepthStencil = TRUE;
|
|
|
|
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */, hwnd,
|
|
|
|
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE, &d3dpp, &device );
|
2008-04-25 03:36:04 +02:00
|
|
|
ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE || hr == D3DERR_INVALIDCALL,
|
2008-07-08 17:48:44 +02:00
|
|
|
"IDirect3D8_CreateDevice failed with %08x\n", hr);
|
2007-11-29 13:22:47 +01:00
|
|
|
if(!device)
|
|
|
|
{
|
|
|
|
skip("Failed to create a d3d device\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&caps, 0, sizeof(caps));
|
|
|
|
hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
|
2008-07-08 17:48:44 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_GetDeviceCaps failed with %08x\n", hr);
|
2007-11-29 13:22:47 +01:00
|
|
|
|
|
|
|
for(i = 1; i <= caps.MaxActiveLights; i++) {
|
|
|
|
hr = IDirect3DDevice8_LightEnable(device, i, TRUE);
|
2008-07-08 17:48:44 +02:00
|
|
|
ok(hr == D3D_OK, "Enabling light %u failed with %08x\n", i, hr);
|
2007-11-29 13:22:47 +01:00
|
|
|
hr = IDirect3DDevice8_GetLightEnable(device, i, &enabled);
|
2008-10-13 01:33:13 +02:00
|
|
|
ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL),
|
|
|
|
"GetLightEnable on light %u failed with %08x\n", i, hr);
|
2007-11-29 13:22:47 +01:00
|
|
|
ok(enabled, "Light %d is %s\n", i, enabled ? "enabled" : "disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: Test the rendering results in this situation */
|
|
|
|
hr = IDirect3DDevice8_LightEnable(device, i + 1, TRUE);
|
2009-02-25 12:12:50 +01:00
|
|
|
ok(hr == D3D_OK ||
|
|
|
|
broken(hr == D3DERR_INVALIDCALL), /* Some Win9x and WinME */
|
|
|
|
"Enabling one light more than supported returned %08x\n", hr);
|
2007-11-29 13:22:47 +01:00
|
|
|
hr = IDirect3DDevice8_GetLightEnable(device, i + 1, &enabled);
|
2009-10-15 21:14:18 +02:00
|
|
|
ok(hr == D3D_OK ||
|
|
|
|
broken(hr == D3DERR_INVALIDCALL), /* Some Win9x and WinME */
|
|
|
|
"GetLightEnable on light %u failed with %08x\n", i + 1, hr);
|
2007-11-29 13:22:47 +01:00
|
|
|
ok(enabled, "Light %d is %s\n", i + 1, enabled ? "enabled" : "disabled");
|
|
|
|
hr = IDirect3DDevice8_LightEnable(device, i + 1, FALSE);
|
2008-07-08 17:48:44 +02:00
|
|
|
ok(hr == D3D_OK, "Disabling the additional returned %08x\n", hr);
|
2007-11-29 13:22:47 +01:00
|
|
|
|
|
|
|
for(i = 1; i <= caps.MaxActiveLights; i++) {
|
|
|
|
hr = IDirect3DDevice8_LightEnable(device, i, FALSE);
|
2008-07-08 17:48:44 +02:00
|
|
|
ok(hr == D3D_OK, "Disabling light %u failed with %08x\n", i, hr);
|
2007-11-29 13:22:47 +01:00
|
|
|
}
|
|
|
|
|
2009-06-23 09:05:33 +02:00
|
|
|
cleanup:
|
|
|
|
if (device)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(device);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (d3d8) IDirect3D8_Release(d3d8);
|
2007-11-29 13:22:47 +01:00
|
|
|
}
|
|
|
|
|
2008-03-23 01:00:01 +01:00
|
|
|
static void test_render_zero_triangles(void)
|
|
|
|
{
|
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
IDirect3DDevice8 *device = NULL;
|
|
|
|
IDirect3D8 *d3d8;
|
|
|
|
HWND hwnd;
|
|
|
|
HRESULT hr;
|
|
|
|
D3DDISPLAYMODE d3ddm;
|
|
|
|
|
|
|
|
struct nvertex
|
|
|
|
{
|
|
|
|
float x, y, z;
|
|
|
|
float nx, ny, nz;
|
|
|
|
DWORD diffuse;
|
|
|
|
} quad[] =
|
|
|
|
{
|
|
|
|
{ 0.0f, -1.0f, 0.1f, 1.0f, 1.0f, 1.0f, 0xff0000ff},
|
|
|
|
{ 0.0f, 0.0f, 0.1f, 1.0f, 1.0f, 1.0f, 0xff0000ff},
|
|
|
|
{ 1.0f, 0.0f, 0.1f, 1.0f, 1.0f, 1.0f, 0xff0000ff},
|
|
|
|
{ 1.0f, -1.0f, 0.1f, 1.0f, 1.0f, 1.0f, 0xff0000ff},
|
|
|
|
};
|
|
|
|
|
|
|
|
d3d8 = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
ok(d3d8 != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow( "static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!d3d8 || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( d3d8, D3DADAPTER_DEFAULT, &d3ddm );
|
|
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|
|
|
d3dpp.Windowed = TRUE;
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp.BackBufferWidth = 800;
|
2009-03-26 10:43:38 +01:00
|
|
|
d3dpp.BackBufferHeight = 600;
|
2008-03-23 01:00:01 +01:00
|
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|
|
|
d3dpp.EnableAutoDepthStencil = TRUE;
|
|
|
|
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */, hwnd,
|
|
|
|
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE, &d3dpp, &device );
|
2008-04-25 03:36:04 +02:00
|
|
|
ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE || hr == D3DERR_INVALIDCALL,
|
2008-07-08 17:48:44 +02:00
|
|
|
"IDirect3D8_CreateDevice failed with %08x\n", hr);
|
2008-03-23 01:00:01 +01:00
|
|
|
if(!device)
|
|
|
|
{
|
|
|
|
skip("Failed to create a d3d device\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
|
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_BeginScene(device);
|
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed with %#08x\n", hr);
|
|
|
|
if(hr == D3D_OK)
|
|
|
|
{
|
|
|
|
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 0 /* NumVerts */,
|
|
|
|
0 /*PrimCount */, NULL, D3DFMT_INDEX16, quad, sizeof(quad[0]));
|
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %#08x\n", hr);
|
|
|
|
|
|
|
|
IDirect3DDevice8_EndScene(device);
|
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed with %#08x\n", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
|
|
|
|
|
2009-06-23 09:05:33 +02:00
|
|
|
cleanup:
|
|
|
|
if (device)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(device);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (d3d8) IDirect3D8_Release(d3d8);
|
2008-03-23 01:00:01 +01:00
|
|
|
}
|
|
|
|
|
2008-09-10 11:08:58 +02:00
|
|
|
static void test_depth_stencil_reset(void)
|
|
|
|
{
|
|
|
|
D3DPRESENT_PARAMETERS present_parameters;
|
|
|
|
D3DDISPLAYMODE display_mode;
|
|
|
|
IDirect3DSurface8 *surface;
|
2008-10-05 18:52:52 +02:00
|
|
|
IDirect3DDevice8 *device = NULL;
|
2008-09-10 11:08:58 +02:00
|
|
|
IDirect3D8 *d3d8;
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
d3d8 = pDirect3DCreate8(D3D_SDK_VERSION);
|
|
|
|
ok(d3d8 != NULL, "Failed to create IDirect3D8 object\n");
|
|
|
|
hwnd = CreateWindow("static", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL);
|
|
|
|
ok(hwnd != NULL, "Failed to create window\n");
|
|
|
|
if (!d3d8 || !hwnd) goto cleanup;
|
|
|
|
|
|
|
|
IDirect3D8_GetAdapterDisplayMode(d3d8, D3DADAPTER_DEFAULT, &display_mode);
|
|
|
|
memset(&present_parameters, 0, sizeof(present_parameters));
|
|
|
|
present_parameters.Windowed = TRUE;
|
|
|
|
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
present_parameters.BackBufferFormat = display_mode.Format;
|
|
|
|
present_parameters.EnableAutoDepthStencil = TRUE;
|
|
|
|
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device);
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#x\n", hr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_TestCooperativeLevel(device);
|
|
|
|
ok(SUCCEEDED(hr), "TestCooperativeLevel failed with %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_SetRenderTarget(device, NULL, NULL);
|
|
|
|
ok(hr == D3D_OK, "SetRenderTarget failed with 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_GetRenderTarget(device, &surface);
|
|
|
|
ok(hr == D3D_OK, "GetRenderTarget failed with 0x%08x\n", hr);
|
|
|
|
ok(surface != NULL, "Render target should not be NULL\n");
|
|
|
|
if (surface) IDirect3DSurface8_Release(surface);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surface);
|
|
|
|
ok(hr == D3DERR_NOTFOUND, "GetDepthStencilSurface returned 0x%08x, expected D3DERR_NOTFOUND\n", hr);
|
|
|
|
ok(surface == NULL, "Depth stencil should be NULL\n");
|
|
|
|
|
|
|
|
present_parameters.EnableAutoDepthStencil = TRUE;
|
|
|
|
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
|
|
|
|
hr = IDirect3DDevice8_Reset(device, &present_parameters);
|
|
|
|
ok(hr == D3D_OK, "Reset failed with 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surface);
|
|
|
|
ok(hr == D3D_OK, "GetDepthStencilSurface failed with 0x%08x\n", hr);
|
|
|
|
ok(surface != NULL, "Depth stencil should not be NULL\n");
|
|
|
|
if (surface) IDirect3DSurface8_Release(surface);
|
|
|
|
|
|
|
|
present_parameters.EnableAutoDepthStencil = FALSE;
|
|
|
|
hr = IDirect3DDevice8_Reset(device, &present_parameters);
|
|
|
|
ok(hr == D3D_OK, "Reset failed with 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surface);
|
|
|
|
ok(hr == D3DERR_NOTFOUND, "GetDepthStencilSurface returned 0x%08x, expected D3DERR_NOTFOUND\n", hr);
|
|
|
|
ok(surface == NULL, "Depth stencil should be NULL\n");
|
|
|
|
|
2009-04-21 15:22:29 +02:00
|
|
|
device = NULL;
|
|
|
|
IDirect3D8_GetAdapterDisplayMode( d3d8, D3DADAPTER_DEFAULT, &display_mode );
|
|
|
|
|
|
|
|
ZeroMemory( &present_parameters, sizeof(present_parameters) );
|
|
|
|
present_parameters.Windowed = TRUE;
|
|
|
|
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
present_parameters.BackBufferFormat = display_mode.Format;
|
|
|
|
present_parameters.EnableAutoDepthStencil = FALSE;
|
|
|
|
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
|
|
|
|
|
|
|
|
hr = IDirect3D8_CreateDevice( d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
|
|
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device );
|
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("could not create device, IDirect3D8_CreateDevice returned %#x\n", hr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_TestCooperativeLevel(device);
|
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_TestCooperativeLevel after creation returned %#x\n", hr);
|
|
|
|
|
|
|
|
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
present_parameters.Windowed = TRUE;
|
|
|
|
present_parameters.BackBufferWidth = 400;
|
|
|
|
present_parameters.BackBufferHeight = 300;
|
|
|
|
present_parameters.EnableAutoDepthStencil = TRUE;
|
|
|
|
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_Reset(device, &present_parameters);
|
2009-04-23 08:33:21 +02:00
|
|
|
ok(hr == D3D_OK, "IDirect3DDevice8_Reset failed with 0x%08x\n", hr);
|
2009-04-21 15:22:29 +02:00
|
|
|
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surface);
|
2009-04-23 08:33:21 +02:00
|
|
|
ok(hr == D3D_OK, "GetDepthStencilSurface failed with 0x%08x\n", hr);
|
|
|
|
ok(surface != NULL, "Depth stencil should not be NULL\n");
|
2009-04-21 15:22:29 +02:00
|
|
|
if (surface) IDirect3DSurface8_Release(surface);
|
|
|
|
|
2008-09-10 11:08:58 +02:00
|
|
|
cleanup:
|
2009-06-23 09:05:33 +02:00
|
|
|
if (device)
|
|
|
|
{
|
|
|
|
UINT refcount = IDirect3DDevice8_Release(device);
|
|
|
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
|
|
|
}
|
|
|
|
if (d3d8) IDirect3D8_Release(d3d8);
|
2008-09-10 11:08:58 +02:00
|
|
|
}
|
|
|
|
|
2006-05-20 18:36:13 +02:00
|
|
|
START_TEST(device)
|
|
|
|
{
|
|
|
|
HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" );
|
2007-01-11 15:38:11 +01:00
|
|
|
if (!d3d8_handle)
|
|
|
|
{
|
|
|
|
skip("Could not load d3d8.dll\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-05-20 18:36:13 +02:00
|
|
|
|
|
|
|
pDirect3DCreate8 = (void *)GetProcAddress( d3d8_handle, "Direct3DCreate8" );
|
2007-01-11 15:38:11 +01:00
|
|
|
ok(pDirect3DCreate8 != NULL, "Failed to get address of Direct3DCreate8\n");
|
2006-05-20 18:36:13 +02:00
|
|
|
if (pDirect3DCreate8)
|
|
|
|
{
|
2008-12-03 18:00:24 +01:00
|
|
|
IDirect3D8 *d3d8;
|
|
|
|
d3d8 = pDirect3DCreate8( D3D_SDK_VERSION );
|
|
|
|
if(!d3d8)
|
|
|
|
{
|
|
|
|
skip("could not create D3D8\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
IDirect3D8_Release(d3d8);
|
|
|
|
|
2006-12-20 13:44:08 +01:00
|
|
|
test_display_modes();
|
2006-12-23 14:41:53 +01:00
|
|
|
test_shader_versions();
|
2006-05-30 23:30:21 +02:00
|
|
|
test_swapchain();
|
2006-11-09 02:38:29 +01:00
|
|
|
test_refcount();
|
|
|
|
test_mipmap_levels();
|
|
|
|
test_cursor();
|
2006-12-14 20:48:09 +01:00
|
|
|
test_states();
|
2007-02-09 16:35:45 +01:00
|
|
|
test_scene();
|
2007-02-12 19:21:45 +01:00
|
|
|
test_shader();
|
2007-02-19 15:24:48 +01:00
|
|
|
test_limits();
|
2007-11-29 13:22:47 +01:00
|
|
|
test_lights();
|
2008-03-23 01:00:01 +01:00
|
|
|
test_render_zero_triangles();
|
2008-09-10 11:08:58 +02:00
|
|
|
test_depth_stencil_reset();
|
2006-05-20 18:36:13 +02:00
|
|
|
}
|
|
|
|
}
|