Commit c0efc3eb authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw/tests: Port D3D1_TextureMapBlendTest to ddraw1.c.

parent edb5ccc3
......@@ -5918,6 +5918,391 @@ static void test_surface_desc_lock(void)
DestroyWindow(window);
}
static void test_texturemapblend(void)
{
HRESULT hr;
DDSURFACEDESC ddsd;
D3DEXECUTEBUFFERDESC exec_desc;
DDBLTFX fx;
static RECT rect = {0, 0, 64, 128};
static D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
DDCOLORKEY ckey;
IDirectDrawSurface *surface, *rt;
IDirect3DTexture *texture;
D3DTEXTUREHANDLE texture_handle;
HWND window;
IDirectDraw *ddraw;
IDirect3DDevice *device;
IDirect3DMaterial *material;
IDirect3DViewport *viewport;
IDirect3DExecuteBuffer *execute_buffer;
UINT inst_length;
void *ptr;
ULONG ref;
D3DCOLOR color;
static const D3DTLVERTEX test1_quads[] =
{
{{0.0f}, {0.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0}, {0.0f}, {0.0f}},
{{0.0f}, {240.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0}, {0.0f}, {1.0f}},
{{640.0f}, {0.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0}, {1.0f}, {0.0f}},
{{640.0f}, {240.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0}, {1.0f}, {1.0f}},
{{0.0f}, {240.0f}, {0.0f}, {1.0f}, {0x80ffffff}, {0}, {0.0f}, {0.0f}},
{{0.0f}, {480.0f}, {0.0f}, {1.0f}, {0x80ffffff}, {0}, {0.0f}, {1.0f}},
{{640.0f}, {240.0f}, {0.0f}, {1.0f}, {0x80ffffff}, {0}, {1.0f}, {0.0f}},
{{640.0f}, {480.0f}, {0.0f}, {1.0f}, {0x80ffffff}, {0}, {1.0f}, {1.0f}},
},
test2_quads[] =
{
{{0.0f}, {0.0f}, {0.0f}, {1.0f}, {0x00ff0080}, {0}, {0.0f}, {0.0f}},
{{0.0f}, {240.0f}, {0.0f}, {1.0f}, {0x00ff0080}, {0}, {0.0f}, {1.0f}},
{{640.0f}, {0.0f}, {0.0f}, {1.0f}, {0x00ff0080}, {0}, {1.0f}, {0.0f}},
{{640.0f}, {240.0f}, {0.0f}, {1.0f}, {0x00ff0080}, {0}, {1.0f}, {1.0f}},
{{0.0f}, {240.0f}, {0.0f}, {1.0f}, {0x008000ff}, {0}, {0.0f}, {0.0f}},
{{0.0f}, {480.0f}, {0.0f}, {1.0f}, {0x008000ff}, {0}, {0.0f}, {1.0f}},
{{640.0f}, {240.0f}, {0.0f}, {1.0f}, {0x008000ff}, {0}, {1.0f}, {0.0f}},
{{640.0f}, {480.0f}, {0.0f}, {1.0f}, {0x008000ff}, {0}, {1.0f}, {1.0f}},
};
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
{
skip("Failed to create a 3D device, skipping test.\n");
DestroyWindow(window);
IDirectDraw_Release(ddraw);
return;
}
hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
material = create_diffuse_material(device, 0.0f, 0.0f, 0.0f, 1.0f);
viewport = create_viewport(device, 0, 0, 640, 480);
viewport_set_background(device, viewport, material);
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(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
/* Test alpha with DDPF_ALPHAPIXELS texture - should be taken from texture alpha channel.
*
* The vertex alpha is completely ignored in this case, so case 1 and 2 combined are not
* a D3DTOP_MODULATE with texture alpha = 0xff in case 2 (no alpha in texture). */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
U5(ddsd.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
U5(fx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
U5(fx).dwFillColor = 0x800000ff;
hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
memcpy(exec_desc.lpData, test1_quads, sizeof(test1_quads));
ptr = ((BYTE *)exec_desc.lpData) + sizeof(test1_quads);
emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 8);
emit_set_rs(&ptr, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
emit_set_rs(&ptr, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
emit_set_rs(&ptr, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
emit_set_rs(&ptr, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
emit_set_rs(&ptr, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
emit_tquad(&ptr, 0);
emit_tquad(&ptr, 4);
emit_end(&ptr);
inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
inst_length -= sizeof(test1_quads);
hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
set_execute_data(execute_buffer, 8, sizeof(test1_quads), inst_length);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 5, 5);
ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 400, 5);
ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 5, 245);
ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 400, 245);
ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
IDirect3DTexture_Release(texture);
ref = IDirectDrawSurface_Release(surface);
ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
/* Test alpha with texture that has no alpha channel - alpha should be taken from diffuse vertex color. */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
U5(fx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
U5(fx).dwFillColor = 0x800000ff;
hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
ptr = ((BYTE *)exec_desc.lpData) + sizeof(test1_quads);
emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 8);
emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
emit_tquad(&ptr, 0);
emit_tquad(&ptr, 4);
emit_end(&ptr);
inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
inst_length -= sizeof(test1_quads);
hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
set_execute_data(execute_buffer, 8, sizeof(test1_quads), inst_length);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 5, 5);
ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 400, 5);
ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 5, 245);
ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 400, 245);
ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
IDirect3DTexture_Release(texture);
ref = IDirectDrawSurface_Release(surface);
ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
/* Test RGB - should multiply color components from diffuse vertex color and texture. */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
U5(ddsd.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
U5(fx).dwFillColor = 0x00ffffff;
hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
U5(fx).dwFillColor = 0x00ffff80;
hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
memcpy(exec_desc.lpData, test2_quads, sizeof(test2_quads));
ptr = ((BYTE *)exec_desc.lpData) + sizeof(test1_quads);
emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 8);
emit_set_rs(&ptr, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
emit_tquad(&ptr, 0);
emit_tquad(&ptr, 4);
emit_end(&ptr);
inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
inst_length -= sizeof(test2_quads);
hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
set_execute_data(execute_buffer, 8, sizeof(test1_quads), inst_length);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 5, 5);
ok(compare_color(color, 0x00ff0040, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 400, 5);
ok(compare_color(color, 0x00ff0080, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 5, 245);
ok(compare_color(color, 0x00800080, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 400, 245);
ok(compare_color(color, 0x008000ff, 2), "Got unexpected color 0x%08x.\n", color);
IDirect3DTexture_Release(texture);
ref = IDirectDrawSurface_Release(surface);
ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
/* Test alpha again, now with color keyed texture (colorkey emulation in wine can interfere). */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 16;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xf800;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x07e0;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001f;
hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
U5(fx).dwFillColor = 0xf800;
hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
U5(fx).dwFillColor = 0x001f;
hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
ckey.dwColorSpaceLowValue = 0x001f;
ckey.dwColorSpaceHighValue = 0x001f;
hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
memcpy(exec_desc.lpData, test1_quads, sizeof(test1_quads));
ptr = ((BYTE *)exec_desc.lpData) + sizeof(test1_quads);
emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 8);
emit_set_rs(&ptr, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
emit_tquad(&ptr, 0);
emit_tquad(&ptr, 4);
emit_end(&ptr);
inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
inst_length -= sizeof(test1_quads);
hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
set_execute_data(execute_buffer, 8, sizeof(test1_quads), inst_length);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 5, 5);
ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 400, 5);
ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 5, 245);
ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(rt, 400, 245);
ok(compare_color(color, 0x00800000, 2), "Got unexpected color 0x%08x.\n", color);
IDirect3DTexture_Release(texture);
ref = IDirectDrawSurface_Release(surface);
ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
ref = IDirect3DExecuteBuffer_Release(execute_buffer);
ok(ref == 0, "Execute buffer not properly released, refcount %u.\n", ref);
destroy_viewport(device, viewport);
ref = IDirect3DMaterial_Release(material);
ok(ref == 0, "Material not properly released, refcount %u.\n", ref);
IDirectDrawSurface_Release(rt);
IDirect3DDevice_Release(device);
ref = IDirectDraw_Release(ddraw);
ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
DestroyWindow(window);
}
START_TEST(ddraw1)
{
IDirectDraw *ddraw;
......@@ -5983,4 +6368,5 @@ START_TEST(ddraw1)
test_palette_alpha();
test_lost_device();
test_surface_desc_lock();
test_texturemapblend();
}
......@@ -1326,744 +1326,6 @@ out:
return ret;
}
#define EXEBUF_START_RENDER_STATES(count, ptr) do {\
((D3DINSTRUCTION*)(ptr))->bOpcode = D3DOP_STATERENDER;\
((D3DINSTRUCTION*)(ptr))->bSize = sizeof(D3DSTATE);\
((D3DINSTRUCTION*)(ptr))->wCount = count;\
ptr = ((D3DINSTRUCTION*)(ptr))+1; } while (0)
#define EXEBUF_PUT_RENDER_STATE(state, value, ptr) do {\
U1(*((D3DSTATE*)(ptr))).drstRenderStateType = state; \
U2(*((D3DSTATE*)(ptr))).dwArg[0] = value; \
ptr = ((D3DSTATE*)(ptr))+1; } while (0)
#define EXEBUF_PUT_PROCESSVERTICES(nvertices, ptr) do {\
((D3DINSTRUCTION*)(ptr))->bOpcode = D3DOP_PROCESSVERTICES;\
((D3DINSTRUCTION*)(ptr))->bSize = sizeof(D3DPROCESSVERTICES);\
((D3DINSTRUCTION*)(ptr))->wCount = 1;\
ptr = ((D3DINSTRUCTION*)(ptr))+1;\
((D3DPROCESSVERTICES*)(ptr))->dwFlags = D3DPROCESSVERTICES_COPY;\
((D3DPROCESSVERTICES*)(ptr))->wStart = 0;\
((D3DPROCESSVERTICES*)(ptr))->wDest = 0;\
((D3DPROCESSVERTICES*)(ptr))->dwCount = nvertices;\
((D3DPROCESSVERTICES*)(ptr))->dwReserved = 0;\
ptr = ((D3DPROCESSVERTICES*)(ptr))+1; } while (0)
#define EXEBUF_END(ptr) do {\
((D3DINSTRUCTION*)(ptr))->bOpcode = D3DOP_EXIT;\
((D3DINSTRUCTION*)(ptr))->bSize = 0;\
((D3DINSTRUCTION*)(ptr))->wCount = 0;\
ptr = ((D3DINSTRUCTION*)(ptr))+1; } while (0)
#define EXEBUF_PUT_QUAD(base_idx, ptr) do {\
((D3DINSTRUCTION*)(ptr))->bOpcode = D3DOP_TRIANGLE;\
((D3DINSTRUCTION*)(ptr))->bSize = sizeof(D3DTRIANGLE);\
((D3DINSTRUCTION*)(ptr))->wCount = 2;\
ptr = ((D3DINSTRUCTION*)(ptr))+1;\
U1(*((D3DTRIANGLE*)(ptr))).v1 = base_idx;\
U2(*((D3DTRIANGLE*)(ptr))).v2 = (base_idx) + 1; \
U3(*((D3DTRIANGLE*)(ptr))).v3 = (base_idx) + 3; \
((D3DTRIANGLE*)(ptr))->wFlags = 0;\
ptr = ((D3DTRIANGLE*)ptr)+1;\
U1(*((D3DTRIANGLE*)(ptr))).v1 = (base_idx) + 1; \
U2(*((D3DTRIANGLE*)(ptr))).v2 = (base_idx) + 2; \
U3(*((D3DTRIANGLE*)(ptr))).v3 = (base_idx) + 3; \
((D3DTRIANGLE*)(ptr))->wFlags = 0;\
ptr = ((D3DTRIANGLE*)(ptr))+1;\
} while (0)
static HRESULT CALLBACK TextureFormatEnumCallback(DDSURFACEDESC *lpDDSD, void *lpContext)
{
if (lpDDSD->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) {
*(BOOL*)lpContext = TRUE;
}
return DDENUMRET_OK;
}
static void D3D1_TextureMapBlendTest(void)
{
HRESULT hr;
DDSURFACEDESC ddsd;
D3DEXECUTEBUFFERDESC exdesc;
D3DEXECUTEDATA exdata;
DDBLTFX ddbltfx;
RECT rect = { 0, 0, 64, 128 };
DWORD color, red, blue, green;
void *exe_buffer_ptr;
DWORD exe_length;
D3DTEXTUREHANDLE htex;
DDCOLORKEY clrKey;
IDirectDrawSurface *TexSurface = NULL;
IDirect3DTexture *Texture = NULL;
IDirectDrawPalette *Palette = NULL;
PALETTEENTRY table1[256];
BOOL p8_textures_supported = FALSE;
struct {
float x, y, z;
float rhw;
DWORD diffuse;
DWORD specular;
float tu, tv;
} test1_quads[] =
{
{0.0f, 0.0f, 0.0f, 1.0f, 0xffffffff, 0, 0.0f, 0.0f},
{640.0f, 0.0f, 0.0f, 1.0f, 0xffffffff, 0, 1.0f, 0.0f},
{640.0f, 240.0f, 0.0f, 1.0f, 0xffffffff, 0, 1.0f, 1.0f},
{0.0f, 240.0f, 0.0f, 1.0f, 0xffffffff, 0, 0.0f, 1.0f},
{0.0f, 240.0f, 0.0f, 1.0f, 0x80ffffff, 0, 0.0f, 0.0f},
{640.0f, 240.0f, 0.0f, 1.0f, 0x80ffffff, 0, 1.0f, 0.0f},
{640.0f, 480.0f, 0.0f, 1.0f, 0x80ffffff, 0, 1.0f, 1.0f},
{0.0f, 480.0f, 0.0f, 1.0f, 0x80ffffff, 0, 0.0f, 1.0f}
}, test2_quads[] =
{
{0.0f, 0.0f, 0.0f, 1.0f, 0x00ff0080, 0, 0.0f, 0.0f},
{640.0f, 0.0f, 0.0f, 1.0f, 0x00ff0080, 0, 1.0f, 0.0f},
{640.0f, 240.0f, 0.0f, 1.0f, 0x00ff0080, 0, 1.0f, 1.0f},
{0.0f, 240.0f, 0.0f, 1.0f, 0x00ff0080, 0, 0.0f, 1.0f},
{0.0f, 240.0f, 0.0f, 1.0f, 0x008000ff, 0, 0.0f, 0.0f},
{640.0f, 240.0f, 0.0f, 1.0f, 0x008000ff, 0, 1.0f, 0.0f},
{640.0f, 480.0f, 0.0f, 1.0f, 0x008000ff, 0, 1.0f, 1.0f},
{0.0f, 480.0f, 0.0f, 1.0f, 0x008000ff, 0, 0.0f, 1.0f}
};
/* 1) Test alpha with DDPF_ALPHAPIXELS texture - should be taken from texture alpha channel*/
memset (&ddsd, 0, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
U5(ddsd.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &TexSurface, NULL);
ok(hr==D3D_OK, "CreateSurface returned: %x\n", hr);
if (FAILED(hr)) {
skip("IDirectDraw_CreateSurface failed; skipping further tests\n");
goto out;
}
hr = IDirectDrawSurface_QueryInterface(TexSurface, &IID_IDirect3DTexture,
(void *)&Texture);
ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %x\n", hr);
if (FAILED(hr)) {
skip("Can't get IDirect3DTexture interface; skipping further tests\n");
goto out;
}
memset(&ddbltfx, 0, sizeof(ddbltfx));
ddbltfx.dwSize = sizeof(ddbltfx);
U5(ddbltfx).dwFillColor = 0;
hr = IDirectDrawSurface_Blt(Surface1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface_Blt(TexSurface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0x800000ff;
hr = IDirectDrawSurface_Blt(TexSurface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
memset(&exdesc, 0, sizeof(D3DEXECUTEBUFFERDESC));
exdesc.dwSize = sizeof(D3DEXECUTEBUFFERDESC);
hr = IDirect3DExecuteBuffer_Lock(ExecuteBuffer, &exdesc);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed with %08x\n", hr);
if (FAILED(hr)) {
skip("IDirect3DExecuteBuffer_Lock failed; skipping further tests\n");
goto out;
}
memcpy(exdesc.lpData, test1_quads, sizeof(test1_quads));
exe_buffer_ptr = sizeof(test1_quads) + (char*)exdesc.lpData;
EXEBUF_PUT_PROCESSVERTICES(8, exe_buffer_ptr);
EXEBUF_START_RENDER_STATES(12, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_ZENABLE, FALSE, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_FOGENABLE, FALSE, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_SPECULARENABLE, FALSE, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_TEXTUREMAG, D3DFILTER_NEAREST, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_TEXTUREMIN, D3DFILTER_NEAREST, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_FILLMODE , D3DFILL_SOLID, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE, exe_buffer_ptr);
hr = IDirect3DTexture_GetHandle(Texture, Direct3DDevice1, &htex);
ok(hr == D3D_OK, "IDirect3DTexture_GetHandle failed with %08x\n", hr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_TEXTUREHANDLE, htex, exe_buffer_ptr);
EXEBUF_PUT_QUAD(0, exe_buffer_ptr);
EXEBUF_PUT_QUAD(4, exe_buffer_ptr);
EXEBUF_END(exe_buffer_ptr);
exe_length = ((char*)exe_buffer_ptr - (char*)exdesc.lpData) - sizeof(test1_quads);
hr = IDirect3DExecuteBuffer_Unlock(ExecuteBuffer);
if (FAILED(hr)) {
trace("IDirect3DExecuteBuffer_Unlock failed with %08x\n", hr);
}
memset(&exdata, 0, sizeof(exdata));
exdata.dwSize = sizeof(exdata);
exdata.dwVertexCount = 8;
exdata.dwInstructionOffset = sizeof(test1_quads);
exdata.dwInstructionLength = exe_length;
hr = IDirect3DExecuteBuffer_SetExecuteData(ExecuteBuffer, &exdata);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_SetExecuteData failed with %08x\n", hr);
hr = IDirect3DDevice_BeginScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_BeginScene failed with %08x\n", hr);
if (SUCCEEDED(hr)) {
hr = IDirect3DDevice_Execute(Direct3DDevice1, ExecuteBuffer, Viewport, D3DEXECUTE_UNCLIPPED);
ok(hr == D3D_OK, "IDirect3DDevice_Execute failed, hr = %08x\n", hr);
hr = IDirect3DDevice_EndScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_EndScene failed, hr = %08x\n", hr);
}
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 5);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue >= 0x7e && blue <= 0x82, "Got color %08x, expected 00000080 or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 5);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue == 0xff, "Got color %08x, expected 000000ff or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 245);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue >= 0x7e && blue <= 0x82, "Got color %08x, expected 00000080 or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 245);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue == 0xff, "Got color %08x, expected 000000ff or near\n", color);
/* 2) Test alpha with texture that has no alpha channel - alpha should be taken from diffuse color */
if(Texture) IDirect3DTexture_Release(Texture);
Texture = NULL;
if(TexSurface) IDirectDrawSurface_Release(TexSurface);
TexSurface = NULL;
memset (&ddsd, 0, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &TexSurface, NULL);
ok(hr==D3D_OK, "CreateSurface returned: %x\n", hr);
if (FAILED(hr)) {
skip("IDirectDraw_CreateSurface failed; skipping further tests\n");
goto out;
}
hr = IDirectDrawSurface_QueryInterface(TexSurface, &IID_IDirect3DTexture,
(void *)&Texture);
ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %x\n", hr);
if (FAILED(hr)) {
skip("Can't get IDirect3DTexture interface; skipping further tests\n");
goto out;
}
memset(&ddbltfx, 0, sizeof(ddbltfx));
ddbltfx.dwSize = sizeof(ddbltfx);
U5(ddbltfx).dwFillColor = 0;
hr = IDirectDrawSurface_Blt(Surface1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface_Blt(TexSurface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0x800000ff;
hr = IDirectDrawSurface_Blt(TexSurface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
memset(&exdesc, 0, sizeof(D3DEXECUTEBUFFERDESC));
exdesc.dwSize = sizeof(D3DEXECUTEBUFFERDESC);
hr = IDirect3DExecuteBuffer_Lock(ExecuteBuffer, &exdesc);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed with %08x\n", hr);
if (FAILED(hr)) {
skip("IDirect3DExecuteBuffer_Lock failed; skipping further tests\n");
goto out;
}
memcpy(exdesc.lpData, test1_quads, sizeof(test1_quads));
exe_buffer_ptr = sizeof(test1_quads) + (char*)exdesc.lpData;
EXEBUF_PUT_PROCESSVERTICES(8, exe_buffer_ptr);
EXEBUF_START_RENDER_STATES(1, exe_buffer_ptr);
hr = IDirect3DTexture_GetHandle(Texture, Direct3DDevice1, &htex);
ok(hr == D3D_OK, "IDirect3DTexture_GetHandle failed with %08x\n", hr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_TEXTUREHANDLE, htex, exe_buffer_ptr);
EXEBUF_PUT_QUAD(0, exe_buffer_ptr);
EXEBUF_PUT_QUAD(4, exe_buffer_ptr);
EXEBUF_END(exe_buffer_ptr);
exe_length = ((char*)exe_buffer_ptr - (char*)exdesc.lpData) - sizeof(test1_quads);
hr = IDirect3DExecuteBuffer_Unlock(ExecuteBuffer);
if (FAILED(hr)) {
trace("IDirect3DExecuteBuffer_Unlock failed with %08x\n", hr);
}
memset(&exdata, 0, sizeof(exdata));
exdata.dwSize = sizeof(exdata);
exdata.dwVertexCount = 8;
exdata.dwInstructionOffset = sizeof(test1_quads);
exdata.dwInstructionLength = exe_length;
hr = IDirect3DExecuteBuffer_SetExecuteData(ExecuteBuffer, &exdata);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_SetExecuteData failed with %08x\n", hr);
hr = IDirect3DDevice_BeginScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_BeginScene failed with %08x\n", hr);
if (SUCCEEDED(hr)) {
hr = IDirect3DDevice_Execute(Direct3DDevice1, ExecuteBuffer, Viewport, D3DEXECUTE_UNCLIPPED);
ok(hr == D3D_OK, "IDirect3DDevice_Execute failed, hr = %08x\n", hr);
hr = IDirect3DDevice_EndScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_EndScene failed, hr = %08x\n", hr);
}
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 5);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue == 0xff, "Got color %08x, expected 000000ff or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 5);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue == 0xff, "Got color %08x, expected 000000ff or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 245);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue >= 0x7e && blue <= 0x82, "Got color %08x, expected 00000080 or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 245);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue >= 0x7e && blue <= 0x82, "Got color %08x, expected 00000080 or near\n", color);
/* 3) Test RGB - should multiply color components from diffuse color and texture */
if(Texture) IDirect3DTexture_Release(Texture);
Texture = NULL;
if(TexSurface) IDirectDrawSurface_Release(TexSurface);
TexSurface = NULL;
memset (&ddsd, 0, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
U5(ddsd.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &TexSurface, NULL);
ok(hr==D3D_OK, "CreateSurface returned: %x\n", hr);
if (FAILED(hr)) {
skip("IDirectDraw_CreateSurface failed; skipping further tests\n");
goto out;
}
hr = IDirectDrawSurface_QueryInterface(TexSurface, &IID_IDirect3DTexture,
(void *)&Texture);
ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %x\n", hr);
if (FAILED(hr)) {
skip("Can't get IDirect3DTexture interface; skipping further tests\n");
goto out;
}
memset(&ddbltfx, 0, sizeof(ddbltfx));
ddbltfx.dwSize = sizeof(ddbltfx);
U5(ddbltfx).dwFillColor = 0;
hr = IDirectDrawSurface_Blt(Surface1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0x00ffffff;
hr = IDirectDrawSurface_Blt(TexSurface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0x00ffff80;
hr = IDirectDrawSurface_Blt(TexSurface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
memset(&exdesc, 0, sizeof(D3DEXECUTEBUFFERDESC));
exdesc.dwSize = sizeof(D3DEXECUTEBUFFERDESC);
hr = IDirect3DExecuteBuffer_Lock(ExecuteBuffer, &exdesc);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed with %08x\n", hr);
if (FAILED(hr)) {
skip("IDirect3DExecuteBuffer_Lock failed; skipping further tests\n");
goto out;
}
memcpy(exdesc.lpData, test2_quads, sizeof(test2_quads));
exe_buffer_ptr = sizeof(test2_quads) + (char*)exdesc.lpData;
EXEBUF_PUT_PROCESSVERTICES(8, exe_buffer_ptr);
EXEBUF_START_RENDER_STATES(2, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE, exe_buffer_ptr);
hr = IDirect3DTexture_GetHandle(Texture, Direct3DDevice1, &htex);
ok(hr == D3D_OK, "IDirect3DTexture_GetHandle failed with %08x\n", hr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_TEXTUREHANDLE, htex, exe_buffer_ptr);
EXEBUF_PUT_QUAD(0, exe_buffer_ptr);
EXEBUF_PUT_QUAD(4, exe_buffer_ptr);
EXEBUF_END(exe_buffer_ptr);
exe_length = ((char*)exe_buffer_ptr - (char*)exdesc.lpData) - sizeof(test2_quads);
hr = IDirect3DExecuteBuffer_Unlock(ExecuteBuffer);
if (FAILED(hr)) {
trace("IDirect3DExecuteBuffer_Unlock failed with %08x\n", hr);
}
memset(&exdata, 0, sizeof(exdata));
exdata.dwSize = sizeof(exdata);
exdata.dwVertexCount = 8;
exdata.dwInstructionOffset = sizeof(test2_quads);
exdata.dwInstructionLength = exe_length;
hr = IDirect3DExecuteBuffer_SetExecuteData(ExecuteBuffer, &exdata);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_SetExecuteData failed with %08x\n", hr);
hr = IDirect3DDevice_BeginScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_BeginScene failed with %08x\n", hr);
if (SUCCEEDED(hr)) {
hr = IDirect3DDevice_Execute(Direct3DDevice1, ExecuteBuffer, Viewport, D3DEXECUTE_UNCLIPPED);
ok(hr == D3D_OK, "IDirect3DDevice_Execute failed, hr = %08x\n", hr);
hr = IDirect3DDevice_EndScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_EndScene failed, hr = %08x\n", hr);
}
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 5);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0xff && green == 0 && blue >= 0x3e && blue <= 0x42, "Got color %08x, expected 00ff0040 or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 5);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0xff && green == 0 && blue == 0x80, "Got color %08x, expected 00ff0080 or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 245);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red >= 0x7e && red <= 0x82 && green == 0 && blue == 0x80, "Got color %08x, expected 00800080 or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 245);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red >= 0x7e && red <= 0x82 && green == 0 && blue == 0xff, "Got color %08x, expected 008000ff or near\n", color);
/* 4) Test alpha again, now with color keyed texture (colorkey emulation in wine can interfere) */
if(Texture) IDirect3DTexture_Release(Texture);
Texture = NULL;
if(TexSurface) IDirectDrawSurface_Release(TexSurface);
TexSurface = NULL;
memset (&ddsd, 0, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 16;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xf800;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x07e0;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001f;
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &TexSurface, NULL);
ok(hr==D3D_OK, "CreateSurface returned: %x\n", hr);
if (FAILED(hr)) {
skip("IDirectDraw_CreateSurface failed; skipping further tests\n");
goto out;
}
hr = IDirectDrawSurface_QueryInterface(TexSurface, &IID_IDirect3DTexture,
(void *)&Texture);
ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %x\n", hr);
if (FAILED(hr)) {
skip("Can't get IDirect3DTexture interface; skipping further tests\n");
goto out;
}
memset(&ddbltfx, 0, sizeof(ddbltfx));
ddbltfx.dwSize = sizeof(ddbltfx);
U5(ddbltfx).dwFillColor = 0;
hr = IDirectDrawSurface_Blt(Surface1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0xf800;
hr = IDirectDrawSurface_Blt(TexSurface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0x001f;
hr = IDirectDrawSurface_Blt(TexSurface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
clrKey.dwColorSpaceLowValue = 0x001f;
clrKey.dwColorSpaceHighValue = 0x001f;
hr = IDirectDrawSurface_SetColorKey(TexSurface, DDCKEY_SRCBLT, &clrKey);
ok(hr==D3D_OK, "IDirectDrawSurfac_SetColorKey returned: %x\n", hr);
memset(&exdesc, 0, sizeof(D3DEXECUTEBUFFERDESC));
exdesc.dwSize = sizeof(D3DEXECUTEBUFFERDESC);
hr = IDirect3DExecuteBuffer_Lock(ExecuteBuffer, &exdesc);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed with %08x\n", hr);
if (FAILED(hr)) {
skip("IDirect3DExecuteBuffer_Lock failed; skipping further tests\n");
goto out;
}
memcpy(exdesc.lpData, test1_quads, sizeof(test1_quads));
exe_buffer_ptr = sizeof(test1_quads) + (char*)exdesc.lpData;
EXEBUF_PUT_PROCESSVERTICES(8, exe_buffer_ptr);
EXEBUF_START_RENDER_STATES(2, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE, exe_buffer_ptr);
hr = IDirect3DTexture_GetHandle(Texture, Direct3DDevice1, &htex);
ok(hr == D3D_OK, "IDirect3DTexture_GetHandle failed with %08x\n", hr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_TEXTUREHANDLE, htex, exe_buffer_ptr);
EXEBUF_PUT_QUAD(0, exe_buffer_ptr);
EXEBUF_PUT_QUAD(4, exe_buffer_ptr);
EXEBUF_END(exe_buffer_ptr);
exe_length = ((char*)exe_buffer_ptr - (char*)exdesc.lpData) - sizeof(test1_quads);
hr = IDirect3DExecuteBuffer_Unlock(ExecuteBuffer);
if (FAILED(hr)) {
trace("IDirect3DExecuteBuffer_Unlock failed with %08x\n", hr);
}
memset(&exdata, 0, sizeof(exdata));
exdata.dwSize = sizeof(exdata);
exdata.dwVertexCount = 8;
exdata.dwInstructionOffset = sizeof(test1_quads);
exdata.dwInstructionLength = exe_length;
hr = IDirect3DExecuteBuffer_SetExecuteData(ExecuteBuffer, &exdata);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_SetExecuteData failed with %08x\n", hr);
hr = IDirect3DDevice_BeginScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_BeginScene failed with %08x\n", hr);
if (SUCCEEDED(hr)) {
hr = IDirect3DDevice_Execute(Direct3DDevice1, ExecuteBuffer, Viewport, D3DEXECUTE_UNCLIPPED);
ok(hr == D3D_OK, "IDirect3DDevice_Execute failed, hr = %08x\n", hr);
hr = IDirect3DDevice_EndScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_EndScene failed, hr = %08x\n", hr);
}
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 5);
ok(color == 0, "Got color %08x, expected 00000000\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 5);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0xff && green == 0 && blue == 0, "Got color %08x, expected 00ff0000 or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 245);
ok(color == 0, "Got color %08x, expected 00000000\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 245);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red >= 0x7e && red <= 0x82 && green == 0 && blue == 0, "Got color %08x, expected 00800000 or near\n", color);
/* 5) Test alpha again, now with color keyed P8 texture */
if(Texture) IDirect3DTexture_Release(Texture);
Texture = NULL;
if(TexSurface) IDirectDrawSurface_Release(TexSurface);
TexSurface = NULL;
hr = IDirect3DDevice_EnumTextureFormats(Direct3DDevice1, TextureFormatEnumCallback,
&p8_textures_supported);
ok(hr == DD_OK, "IDirect3DDevice_EnumTextureFormats returned %08x\n", hr);
if (!p8_textures_supported) {
skip("device has no P8 texture support, skipping test\n");
} else {
memset (&ddsd, 0, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwHeight = 128;
ddsd.dwWidth = 128;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 8;
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &TexSurface, NULL);
ok(hr==D3D_OK, "CreateSurface returned: %x\n", hr);
if (FAILED(hr)) {
skip("IDirectDraw_CreateSurface failed; skipping further tests\n");
goto out;
}
memset(table1, 0, sizeof(table1));
table1[0].peBlue = 0xff;
table1[1].peRed = 0xff;
hr = IDirectDraw_CreatePalette(DirectDraw1, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, table1, &Palette, NULL);
ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
if (FAILED(hr)) {
skip("IDirectDraw_CreatePalette failed; skipping further tests\n");
goto out;
}
hr = IDirectDrawSurface_SetPalette(TexSurface, Palette);
ok(hr==D3D_OK, "IDirectDrawSurface_SetPalette returned: %x\n", hr);
hr = IDirectDrawSurface_QueryInterface(TexSurface, &IID_IDirect3DTexture,
(void *)&Texture);
ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %x\n", hr);
if (FAILED(hr)) {
skip("Can't get IDirect3DTexture interface; skipping further tests\n");
goto out;
}
memset(&ddbltfx, 0, sizeof(ddbltfx));
ddbltfx.dwSize = sizeof(ddbltfx);
U5(ddbltfx).dwFillColor = 0;
hr = IDirectDrawSurface_Blt(Surface1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 0;
hr = IDirectDrawSurface_Blt(TexSurface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
U5(ddbltfx).dwFillColor = 1;
hr = IDirectDrawSurface_Blt(TexSurface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == D3D_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
clrKey.dwColorSpaceLowValue = 1;
clrKey.dwColorSpaceHighValue = 1;
hr = IDirectDrawSurface_SetColorKey(TexSurface, DDCKEY_SRCBLT, &clrKey);
ok(hr==D3D_OK, "IDirectDrawSurfac_SetColorKey returned: %x\n", hr);
memset(&exdesc, 0, sizeof(D3DEXECUTEBUFFERDESC));
exdesc.dwSize = sizeof(D3DEXECUTEBUFFERDESC);
hr = IDirect3DExecuteBuffer_Lock(ExecuteBuffer, &exdesc);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed with %08x\n", hr);
if (FAILED(hr)) {
skip("IDirect3DExecuteBuffer_Lock failed; skipping further tests\n");
goto out;
}
memcpy(exdesc.lpData, test1_quads, sizeof(test1_quads));
exe_buffer_ptr = sizeof(test1_quads) + (char*)exdesc.lpData;
EXEBUF_PUT_PROCESSVERTICES(8, exe_buffer_ptr);
EXEBUF_START_RENDER_STATES(2, exe_buffer_ptr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE, exe_buffer_ptr);
hr = IDirect3DTexture_GetHandle(Texture, Direct3DDevice1, &htex);
ok(hr == D3D_OK, "IDirect3DTexture_GetHandle failed with %08x\n", hr);
EXEBUF_PUT_RENDER_STATE(D3DRENDERSTATE_TEXTUREHANDLE, htex, exe_buffer_ptr);
EXEBUF_PUT_QUAD(0, exe_buffer_ptr);
EXEBUF_PUT_QUAD(4, exe_buffer_ptr);
EXEBUF_END(exe_buffer_ptr);
exe_length = ((char*)exe_buffer_ptr - (char*)exdesc.lpData) - sizeof(test1_quads);
hr = IDirect3DExecuteBuffer_Unlock(ExecuteBuffer);
if (FAILED(hr)) {
trace("IDirect3DExecuteBuffer_Unlock failed with %08x\n", hr);
}
memset(&exdata, 0, sizeof(exdata));
exdata.dwSize = sizeof(exdata);
exdata.dwVertexCount = 8;
exdata.dwInstructionOffset = sizeof(test1_quads);
exdata.dwInstructionLength = exe_length;
hr = IDirect3DExecuteBuffer_SetExecuteData(ExecuteBuffer, &exdata);
ok(hr == D3D_OK, "IDirect3DExecuteBuffer_SetExecuteData failed with %08x\n", hr);
hr = IDirect3DDevice_BeginScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_BeginScene failed with %08x\n", hr);
if (SUCCEEDED(hr)) {
hr = IDirect3DDevice_Execute(Direct3DDevice1, ExecuteBuffer, Viewport, D3DEXECUTE_UNCLIPPED);
ok(hr == D3D_OK, "IDirect3DDevice_Execute failed, hr = %08x\n", hr);
hr = IDirect3DDevice_EndScene(Direct3DDevice1);
ok(hr == D3D_OK, "IDirect3DDevice_EndScene failed, hr = %08x\n", hr);
}
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 5);
ok(color == 0, "Got color %08x, expected 00000000\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 5);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue == 0xff, "Got color %08x, expected 000000ff or near\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 5, 245);
ok(color == 0, "Got color %08x, expected 00000000\n", color);
color = D3D1_getPixelColor(DirectDraw1, Surface1, 400, 245);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff);
ok(red == 0 && green == 0 && blue >= 0x7e && blue <= 0x82, "Got color %08x, expected 00000080 or near\n", color);
}
out:
if (Palette) IDirectDrawPalette_Release(Palette);
if (TexSurface) IDirectDrawSurface_Release(TexSurface);
if (Texture) IDirect3DTexture_Release(Texture);
}
static void D3D1_ViewportClearTest(void)
{
HRESULT hr;
......@@ -3283,13 +2545,11 @@ START_TEST(visual)
releaseObjects(); /* release DX7 interfaces to test D3D1 */
if(!D3D1_createObjects()) {
if(!D3D1_createObjects())
skip("Cannot initialize D3D1, skipping\n");
}
else {
D3D1_TextureMapBlendTest();
else
D3D1_ViewportClearTest();
}
D3D1_releaseObjects();
D3D3_ViewportClearTest();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment