d3d8/tests: Add a test for ATI1N and ATI2N texture formats.
This commit is contained in:
parent
da54670a94
commit
8f3477e106
|
@ -4367,9 +4367,10 @@ static void test_surface_blocks(void)
|
|||
{D3DFMT_DXT3, "D3DFMT_DXT3", 4, 4, FALSE, TRUE, TRUE },
|
||||
{D3DFMT_DXT4, "D3DFMT_DXT4", 4, 4, FALSE, TRUE, TRUE },
|
||||
{D3DFMT_DXT5, "D3DFMT_DXT5", 4, 4, FALSE, TRUE, TRUE },
|
||||
/* ATI2N has 2x2 blocks on all AMD cards and Geforce 7 cards,
|
||||
/* ATI1N and ATI2N have 2x2 blocks on all AMD cards and Geforce 7 cards,
|
||||
* which doesn't match the format spec. On newer Nvidia cards
|
||||
* it has the correct 4x4 block size */
|
||||
* they have the correct 4x4 block size */
|
||||
{MAKEFOURCC('A','T','I','1'), "ATI1N", 4, 4, TRUE, FALSE, FALSE},
|
||||
{MAKEFOURCC('A','T','I','2'), "ATI2N", 4, 4, TRUE, FALSE, FALSE},
|
||||
/* Windows drivers generally enforce block-aligned locks for
|
||||
* YUY2 and UYVY. The notable exception is the AMD r500 driver
|
||||
|
|
|
@ -5058,6 +5058,165 @@ done:
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_3dc_formats(void)
|
||||
{
|
||||
static const char ati1n_data[] =
|
||||
{
|
||||
/* A 4x4 texture with the color component at 50%. */
|
||||
0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const char ati2n_data[] =
|
||||
{
|
||||
/* A 8x4 texture consisting of 2 4x4 blocks. The first block has 50% first color component,
|
||||
* 0% second component. Second block is the opposite. */
|
||||
0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const struct
|
||||
{
|
||||
struct vec3 position;
|
||||
struct vec2 texcoord;
|
||||
}
|
||||
quads[] =
|
||||
{
|
||||
{{-1.0f, -1.0f, 0.0f}, {0.0f, 0.0f}},
|
||||
{{-1.0f, 1.0f, 0.0f}, {0.0f, 1.0f}},
|
||||
{{ 0.0f, -1.0f, 1.0f}, {1.0f, 0.0f}},
|
||||
{{ 0.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
||||
|
||||
{{ 0.0f, -1.0f, 0.0f}, {0.0f, 0.0f}},
|
||||
{{ 0.0f, 1.0f, 0.0f}, {0.0f, 1.0f}},
|
||||
{{ 1.0f, -1.0f, 1.0f}, {1.0f, 0.0f}},
|
||||
{{ 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
||||
};
|
||||
static const DWORD ati1n_fourcc = MAKEFOURCC('A','T','I','1');
|
||||
static const DWORD ati2n_fourcc = MAKEFOURCC('A','T','I','2');
|
||||
static const struct
|
||||
{
|
||||
struct vec2 position;
|
||||
D3DCOLOR amd;
|
||||
D3DCOLOR nvidia;
|
||||
}
|
||||
expected_colors[] =
|
||||
{
|
||||
{{ 80, 240}, 0x003f3f3f, 0x007f0000},
|
||||
{{240, 240}, 0x003f3f3f, 0x007f0000},
|
||||
{{400, 240}, 0x00007fff, 0x00007fff},
|
||||
{{560, 240}, 0x007f00ff, 0x007f00ff},
|
||||
};
|
||||
IDirect3D8 *d3d;
|
||||
IDirect3DDevice8 *device;
|
||||
IDirect3DTexture8 *ati1n_texture, *ati2n_texture;
|
||||
D3DCAPS8 caps;
|
||||
D3DLOCKED_RECT rect;
|
||||
D3DCOLOR color;
|
||||
ULONG refcount;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
unsigned int i;
|
||||
|
||||
window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
0, 0, 640, 480, NULL, NULL, NULL, NULL);
|
||||
d3d = Direct3DCreate8(D3D_SDK_VERSION);
|
||||
ok(!!d3d, "Failed to create a D3D object.\n");
|
||||
if (FAILED(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
|
||||
D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, ati1n_fourcc)))
|
||||
{
|
||||
skip("ATI1N textures are not supported, skipping test.\n");
|
||||
goto done;
|
||||
}
|
||||
if (FAILED(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
|
||||
D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, ati2n_fourcc)))
|
||||
{
|
||||
skip("ATI2N textures are not supported, skipping test.\n");
|
||||
goto done;
|
||||
}
|
||||
if (!(device = create_device(d3d, window, window, TRUE)))
|
||||
{
|
||||
skip("Failed to create a D3D device, skipping tests.\n");
|
||||
goto done;
|
||||
}
|
||||
hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
|
||||
ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
|
||||
if (!(caps.PrimitiveMiscCaps & D3DPMISCCAPS_TSSARGTEMP))
|
||||
{
|
||||
skip("D3DTA_TEMP not supported, skipping tests.\n");
|
||||
IDirect3DDevice8_Release(device);
|
||||
goto done;
|
||||
}
|
||||
|
||||
hr = IDirect3DDevice8_CreateTexture(device, 4, 4, 1, 0, ati1n_fourcc,
|
||||
D3DPOOL_MANAGED, &ati1n_texture);
|
||||
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DTexture8_LockRect(ati1n_texture, 0, &rect, NULL, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
|
||||
memcpy(rect.pBits, ati1n_data, sizeof(ati1n_data));
|
||||
hr = IDirect3DTexture8_UnlockRect(ati1n_texture, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice8_CreateTexture(device, 8, 4, 1, 0, ati2n_fourcc,
|
||||
D3DPOOL_MANAGED, &ati2n_texture);
|
||||
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DTexture8_LockRect(ati2n_texture, 0, &rect, NULL, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
|
||||
memcpy(rect.pBits, ati2n_data, sizeof(ati2n_data));
|
||||
hr = IDirect3DTexture8_UnlockRect(ati2n_texture, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0));
|
||||
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
|
||||
ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TEMP);
|
||||
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
|
||||
ok(SUCCEEDED(hr), "Failed to set mag filter, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff00ff, 1.0f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_BeginScene(device);
|
||||
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)ati1n_texture);
|
||||
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[0], sizeof(*quads));
|
||||
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)ati2n_texture);
|
||||
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[4], sizeof(*quads));
|
||||
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice8_EndScene(device);
|
||||
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
color = getPixelColor(device, expected_colors[i].position.x, expected_colors[i].position.y);
|
||||
ok (color_match(color, expected_colors[i].amd, 1) || color_match(color, expected_colors[i].nvidia, 1),
|
||||
"Expected color 0x%08x or 0x%08x, got 0x%08x, case %u.\n",
|
||||
expected_colors[i].amd, expected_colors[i].nvidia, color, i);
|
||||
}
|
||||
|
||||
IDirect3DTexture8_Release(ati2n_texture);
|
||||
IDirect3DTexture8_Release(ati1n_texture);
|
||||
refcount = IDirect3DDevice8_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
|
||||
done:
|
||||
IDirect3D8_Release(d3d);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(visual)
|
||||
{
|
||||
D3DADAPTER_IDENTIFIER8 identifier;
|
||||
|
@ -5107,4 +5266,5 @@ START_TEST(visual)
|
|||
volume_dxt5_test();
|
||||
volume_v16u16_test();
|
||||
add_dirty_rect_test();
|
||||
test_3dc_formats();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue