mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 18:29:28 +00:00
ddraw: Allow texture without DDSCAPS_TEXTURE for ddraw4 and earlier on software device.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
944014afb4
commit
13ffebc728
|
@ -4858,19 +4858,21 @@ static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface,
|
|||
{
|
||||
struct d3d_device *device = impl_from_IDirect3DDevice3(iface);
|
||||
struct ddraw_surface *tex = unsafe_impl_from_IDirect3DTexture2(texture);
|
||||
HRESULT hr;
|
||||
struct wined3d_texture *wined3d_texture = NULL;
|
||||
|
||||
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
|
||||
hr = IDirect3DDevice7_SetTexture(&device->IDirect3DDevice7_iface, stage, &tex->IDirectDrawSurface7_iface);
|
||||
if (tex && ((tex->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) || !device->hardware_device))
|
||||
wined3d_texture = tex->draw_texture ? tex->draw_texture : tex->wined3d_texture;
|
||||
|
||||
wined3d_stateblock_set_texture(device->state, stage, wined3d_texture);
|
||||
fixup_texture_alpha_op(device);
|
||||
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static const struct tss_lookup
|
||||
|
|
|
@ -14332,6 +14332,122 @@ static void run_for_each_device_type(void (*test_func)(const GUID *))
|
|||
test_func(&IID_IDirect3DRGBDevice);
|
||||
}
|
||||
|
||||
static void test_texture_wrong_caps(const GUID *device_guid)
|
||||
{
|
||||
static D3DTLVERTEX quad[] =
|
||||
{
|
||||
{{ 0.0f}, {480.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {0.0f}, {0.0f}},
|
||||
{{ 0.0f}, { 0.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {0.0f}, {1.0f}},
|
||||
{{640.0f}, {480.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {1.0f}, {0.0f}},
|
||||
{{640.0f}, { 0.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {1.0f}, {1.0f}},
|
||||
};
|
||||
static DDPIXELFORMAT fmt =
|
||||
{
|
||||
sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_ALPHAPIXELS, 0,
|
||||
{32}, {0x00ff0000}, {0x0000ff00}, {0x000000ff}, {0xff000000}
|
||||
};
|
||||
D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
|
||||
IDirect3DExecuteBuffer *execute_buffer;
|
||||
IDirectDrawSurface *surface, *rt;
|
||||
D3DTEXTUREHANDLE texture_handle;
|
||||
D3DCOLOR color, expected_color;
|
||||
D3DEXECUTEBUFFERDESC exec_desc;
|
||||
IDirect3DMaterial *background;
|
||||
IDirect3DViewport *viewport;
|
||||
IDirect3DTexture *texture;
|
||||
unsigned int inst_length;
|
||||
IDirect3DDevice *device;
|
||||
IDirectDraw *ddraw;
|
||||
DDSURFACEDESC ddsd;
|
||||
ULONG refcount;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
void *ptr;
|
||||
|
||||
window = create_window();
|
||||
ddraw = create_ddraw();
|
||||
ok(!!ddraw, "Failed to create a ddraw object.\n");
|
||||
if (!(device = create_device_ex(ddraw, window, DDSCL_NORMAL, device_guid)))
|
||||
{
|
||||
skip("Failed to create a 3D device, skipping test.\n");
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
viewport = create_viewport(device, 0, 0, 640, 480);
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
|
||||
ddsd.dwHeight = 16;
|
||||
ddsd.dwWidth = 16;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
U4(ddsd).ddpfPixelFormat = fmt;
|
||||
hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
|
||||
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
|
||||
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
fill_surface(surface, 0xff00ff00);
|
||||
|
||||
background = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
viewport_set_background(device, viewport, background);
|
||||
|
||||
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
if (is_software_device_type(device_guid))
|
||||
fill_surface(rt, 0xffff0000);
|
||||
|
||||
memset(&exec_desc, 0, sizeof(exec_desc));
|
||||
exec_desc.dwSize = sizeof(exec_desc);
|
||||
exec_desc.dwFlags = D3DDEB_BUFSIZE | D3DDEB_CAPS;
|
||||
exec_desc.dwBufferSize = 1024;
|
||||
exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
|
||||
hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
memcpy(exec_desc.lpData, quad, sizeof(quad));
|
||||
ptr = (BYTE *)exec_desc.lpData + sizeof(quad);
|
||||
emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 4);
|
||||
emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
|
||||
emit_tquad(&ptr, 0);
|
||||
emit_end(&ptr);
|
||||
inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData - sizeof(quad);
|
||||
hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
set_execute_data(execute_buffer, 4, sizeof(quad), inst_length);
|
||||
|
||||
hr = IDirect3DDevice_BeginScene(device);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice_EndScene(device);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
expected_color = is_software_device_type(device_guid) ? 0x0000ff00 : 0x00ffffff;
|
||||
color = get_surface_color(rt, 320, 240);
|
||||
ok(compare_color(color, expected_color, 1), "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
|
||||
|
||||
IDirect3DTexture_Release(texture);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
IDirectDrawSurface_Release(rt);
|
||||
IDirect3DExecuteBuffer_Release(execute_buffer);
|
||||
destroy_material(background);
|
||||
destroy_viewport(device, viewport);
|
||||
|
||||
IDirect3DDevice_Release(device);
|
||||
refcount = IDirectDraw_Release(ddraw);
|
||||
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(ddraw1)
|
||||
{
|
||||
DDDEVICEIDENTIFIER identifier;
|
||||
|
@ -14448,4 +14564,5 @@ START_TEST(ddraw1)
|
|||
test_vtbl_protection();
|
||||
test_window_position();
|
||||
test_get_display_mode();
|
||||
run_for_each_device_type(test_texture_wrong_caps);
|
||||
}
|
||||
|
|
|
@ -15285,6 +15285,101 @@ done:
|
|||
IDirectDraw2_Release(ddraw);
|
||||
}
|
||||
|
||||
static void test_texture_wrong_caps(const GUID *device_guid)
|
||||
{
|
||||
static D3DLVERTEX quad[] =
|
||||
{
|
||||
{{-1.0f}, {-1.0f}, {0.0f}, 0, {0xffffffff}, {0}, {0.0f}, {1.0f}},
|
||||
{{-1.0f}, { 1.0f}, {0.0f}, 0, {0xffffffff}, {0}, {0.0f}, {0.0f}},
|
||||
{{ 1.0f}, {-1.0f}, {0.0f}, 0, {0xffffffff}, {0}, {1.0f}, {1.0f}},
|
||||
{{ 1.0f}, { 1.0f}, {0.0f}, 0, {0xffffffff}, {0}, {1.0f}, {0.0f}},
|
||||
};
|
||||
static DDPIXELFORMAT fmt =
|
||||
{
|
||||
sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_ALPHAPIXELS, 0,
|
||||
{32}, {0x00ff0000}, {0x0000ff00}, {0x000000ff}, {0xff000000}
|
||||
};
|
||||
D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
|
||||
IDirectDrawSurface *surface, *rt;
|
||||
D3DTEXTUREHANDLE texture_handle;
|
||||
D3DCOLOR color, expected_color;
|
||||
IDirect3DMaterial2 *background;
|
||||
IDirect3DViewport2 *viewport;
|
||||
IDirect3DTexture2 *texture;
|
||||
IDirect3DDevice2 *device;
|
||||
IDirectDraw2 *ddraw;
|
||||
DDSURFACEDESC ddsd;
|
||||
ULONG refcount;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
|
||||
window = create_window();
|
||||
ddraw = create_ddraw();
|
||||
ok(!!ddraw, "Failed to create a ddraw object.\n");
|
||||
if (!(device = create_device_ex(ddraw, window, DDSCL_NORMAL, device_guid)))
|
||||
{
|
||||
skip("Failed to create a 3D device, skipping test.\n");
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
viewport = create_viewport(device, 0, 0, 640, 480);
|
||||
hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
|
||||
ddsd.dwHeight = 16;
|
||||
ddsd.dwWidth = 16;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
U4(ddsd).ddpfPixelFormat = fmt;
|
||||
hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
|
||||
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
|
||||
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
fill_surface(surface, 0xff00ff00);
|
||||
|
||||
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
background = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
viewport_set_background(device, viewport, background);
|
||||
|
||||
hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
if (is_software_device_type(device_guid))
|
||||
fill_surface(rt, 0xffff0000);
|
||||
|
||||
hr = IDirect3DDevice2_BeginScene(device);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, ARRAY_SIZE(quad), 0);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice2_EndScene(device);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
expected_color = is_software_device_type(device_guid) ? 0x0000ff00 : 0x00ffffff;
|
||||
color = get_surface_color(rt, 320, 240);
|
||||
ok(compare_color(color, expected_color, 1), "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
|
||||
|
||||
IDirect3DTexture2_Release(texture);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
IDirectDrawSurface_Release(rt);
|
||||
destroy_viewport(device, viewport);
|
||||
destroy_material(background);
|
||||
IDirectDraw2_Release(ddraw);
|
||||
refcount = IDirect3DDevice2_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void run_for_each_device_type(void (*test_func)(const GUID *))
|
||||
{
|
||||
test_func(&IID_IDirect3DHALDevice);
|
||||
|
@ -15413,4 +15508,5 @@ START_TEST(ddraw2)
|
|||
test_cursor_clipping();
|
||||
test_window_position();
|
||||
test_get_display_mode();
|
||||
run_for_each_device_type(test_texture_wrong_caps);
|
||||
}
|
||||
|
|
|
@ -18326,6 +18326,109 @@ static void run_for_each_device_type(void (*test_func)(const GUID *))
|
|||
test_func(&IID_IDirect3DRGBDevice);
|
||||
}
|
||||
|
||||
static void test_texture_wrong_caps(const GUID *device_guid)
|
||||
{
|
||||
static struct
|
||||
{
|
||||
struct vec3 position;
|
||||
struct vec2 texcoord;
|
||||
}
|
||||
quad[] =
|
||||
{
|
||||
{{-1.0f, -1.0f, 0.0f}, {0.0f, 1.0f}},
|
||||
{{-1.0f, 1.0f, 0.0f}, {0.0f, 0.0f}},
|
||||
{{ 1.0f, -1.0f, 0.0f}, {1.0f, 1.0f}},
|
||||
{{ 1.0f, 1.0f, 0.0f}, {1.0f, 0.0f}},
|
||||
};
|
||||
static DDPIXELFORMAT fmt =
|
||||
{
|
||||
sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_ALPHAPIXELS, 0,
|
||||
{32}, {0x00ff0000}, {0x0000ff00}, {0x000000ff}, {0xff000000}
|
||||
};
|
||||
D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
|
||||
IDirectDrawSurface4 *surface, *rt;
|
||||
D3DCOLOR color, expected_color;
|
||||
IDirect3DViewport3 *viewport;
|
||||
IDirect3DTexture2 *texture;
|
||||
IDirect3DDevice3 *device;
|
||||
IDirectDraw4 *ddraw;
|
||||
DDSURFACEDESC2 ddsd;
|
||||
IDirect3D3 *d3d;
|
||||
ULONG refcount;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
|
||||
window = create_window();
|
||||
if (!(device = create_device_ex(window, DDSCL_NORMAL, device_guid)))
|
||||
{
|
||||
skip("Failed to create a 3D device, skipping test.\n");
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
viewport = create_viewport(device, 0, 0, 640, 480);
|
||||
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
|
||||
ddsd.dwHeight = 16;
|
||||
ddsd.dwWidth = 16;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
U4(ddsd).ddpfPixelFormat = fmt;
|
||||
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
|
||||
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
|
||||
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
fill_surface(surface, 0xff00ff00);
|
||||
|
||||
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_SetTexture(device, 0, texture);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_BeginScene(device);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
|
||||
D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_EndScene(device);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
expected_color = is_software_device_type(device_guid) ? 0x0000ff00 : 0x00ffffff;
|
||||
color = get_surface_color(rt, 320, 240);
|
||||
ok(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
|
||||
|
||||
IDirect3DTexture2_Release(texture);
|
||||
IDirectDrawSurface4_Release(surface);
|
||||
IDirectDrawSurface4_Release(rt);
|
||||
destroy_viewport(device, viewport);
|
||||
IDirectDraw4_Release(ddraw);
|
||||
IDirect3D3_Release(d3d);
|
||||
refcount = IDirect3DDevice3_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(ddraw4)
|
||||
{
|
||||
DDDEVICEIDENTIFIER identifier;
|
||||
|
@ -18464,4 +18567,5 @@ START_TEST(ddraw4)
|
|||
test_cursor_clipping();
|
||||
test_window_position();
|
||||
test_get_display_mode();
|
||||
run_for_each_device_type(test_texture_wrong_caps);
|
||||
}
|
||||
|
|
|
@ -18587,6 +18587,101 @@ done:
|
|||
IDirectDraw7_Release(ddraw);
|
||||
}
|
||||
|
||||
static void test_texture_wrong_caps(const GUID *device_guid)
|
||||
{
|
||||
static struct
|
||||
{
|
||||
struct vec3 position;
|
||||
struct vec2 texcoord;
|
||||
}
|
||||
quad[] =
|
||||
{
|
||||
{{-1.0f, -1.0f, 0.0f}, {0.0f, 1.0f}},
|
||||
{{-1.0f, 1.0f, 0.0f}, {0.0f, 0.0f}},
|
||||
{{ 1.0f, -1.0f, 0.0f}, {1.0f, 1.0f}},
|
||||
{{ 1.0f, 1.0f, 0.0f}, {1.0f, 0.0f}},
|
||||
};
|
||||
static DDPIXELFORMAT fmt =
|
||||
{
|
||||
sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_ALPHAPIXELS, 0,
|
||||
{32}, {0x00ff0000}, {0x0000ff00}, {0x000000ff}, {0xff000000}
|
||||
};
|
||||
IDirectDrawSurface7 *surface, *rt;
|
||||
IDirect3DDevice7 *device;
|
||||
IDirectDraw7 *ddraw;
|
||||
DDSURFACEDESC2 ddsd;
|
||||
IDirect3D7 *d3d;
|
||||
D3DCOLOR color;
|
||||
ULONG refcount;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
|
||||
window = create_window();
|
||||
if (!(device = create_device_ex(window, DDSCL_NORMAL, device_guid)))
|
||||
{
|
||||
skip("Failed to create a 3D device, skipping test.\n");
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
|
||||
ddsd.dwHeight = 16;
|
||||
ddsd.dwWidth = 16;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
U4(ddsd).ddpfPixelFormat = fmt;
|
||||
hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
|
||||
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
fill_surface(surface, 0xff00ff00);
|
||||
|
||||
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice7_SetTexture(device, 0, surface);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
|
||||
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
||||
if (is_software_device_type(device_guid))
|
||||
fill_surface(rt, 0x000000ff);
|
||||
|
||||
hr = IDirect3DDevice7_BeginScene(device);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
|
||||
D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice7_EndScene(device);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
color = get_surface_color(rt, 320, 240);
|
||||
ok(color == 0, "Got unexpected color 0x%08x.\n", color);
|
||||
|
||||
IDirectDrawSurface7_Release(surface);
|
||||
IDirectDrawSurface7_Release(rt);
|
||||
IDirectDraw7_Release(ddraw);
|
||||
IDirect3D7_Release(d3d);
|
||||
refcount = IDirect3DDevice3_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void run_for_each_device_type(void (*test_func)(const GUID *))
|
||||
{
|
||||
test_func(hw_device_guid);
|
||||
|
@ -18763,4 +18858,5 @@ START_TEST(ddraw7)
|
|||
test_cursor_clipping();
|
||||
test_window_position();
|
||||
test_get_display_mode();
|
||||
run_for_each_device_type(test_texture_wrong_caps);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue