ReactOS 0.4.17-dev-1190-g4c812f4
volume.c File Reference
#include "wine/test.h"
#include "d3dx9tex.h"
#include "d3dx9_test_images.h"
Include dependency graph for volume.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define check_pixel_4bpp(box, x, y, z, color)   _check_pixel_4bpp(__LINE__, box, x, y, z, color)
 
#define check_pixel_8bpp(box, x, y, z, color)   _check_pixel_8bpp(__LINE__, box, x, y, z, color)
 

Functions

static void _check_pixel_4bpp (unsigned int line, const D3DLOCKED_BOX *box, int x, int y, int z, DWORD expected_color)
 
static void _check_pixel_8bpp (unsigned int line, const D3DLOCKED_BOX *box, int x, int y, int z, uint64_t expected_color)
 
static void set_box (D3DBOX *box, UINT left, UINT top, UINT right, UINT bottom, UINT front, UINT back)
 
static void test_D3DXLoadVolumeFromMemory (IDirect3DDevice9 *device)
 
static void test_D3DXLoadVolumeFromFileInMemory (IDirect3DDevice9 *device)
 
 START_TEST (volume)
 

Macro Definition Documentation

◆ check_pixel_4bpp

#define check_pixel_4bpp (   box,
  x,
  y,
  z,
  color 
)    _check_pixel_4bpp(__LINE__, box, x, y, z, color)

Definition at line 26 of file volume.c.

◆ check_pixel_8bpp

#define check_pixel_8bpp (   box,
  x,
  y,
  z,
  color 
)    _check_pixel_8bpp(__LINE__, box, x, y, z, color)

Definition at line 33 of file volume.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file volume.c.

Function Documentation

◆ _check_pixel_4bpp()

static void _check_pixel_4bpp ( unsigned int  line,
const D3DLOCKED_BOX *  box,
int  x,
int  y,
int  z,
DWORD  expected_color 
)
inlinestatic

Definition at line 27 of file volume.c.

28{
29 DWORD color = ((DWORD *)box->pBits)[x + (y * box->RowPitch + z * box->SlicePitch) / 4];
30 ok_(__FILE__, line)(color == expected_color, "Got color 0x%08lx, expected 0x%08lx\n", color, expected_color);
31}
#define ok_(x1, x2)
Definition: atltest.h:61
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint color
Definition: glext.h:6243
GLdouble GLdouble z
Definition: glext.h:5874
Definition: palette.c:466
Definition: parser.c:49

◆ _check_pixel_8bpp()

static void _check_pixel_8bpp ( unsigned int  line,
const D3DLOCKED_BOX *  box,
int  x,
int  y,
int  z,
uint64_t  expected_color 
)
inlinestatic

Definition at line 34 of file volume.c.

35{
36 uint64_t color = ((uint64_t *)box->pBits)[x + (y * box->RowPitch + z * box->SlicePitch) / 8];
37 ok_(__FILE__, line)(color == expected_color, "Got color %#I64x, expected %#I64x.\n", color, expected_color);
38}
UINT64 uint64_t
Definition: types.h:77

◆ set_box()

static void set_box ( D3DBOX *  box,
UINT  left,
UINT  top,
UINT  right,
UINT  bottom,
UINT  front,
UINT  back 
)
inlinestatic

Definition at line 40 of file volume.c.

41{
42 box->Left = left;
43 box->Top = top;
44 box->Right = right;
45 box->Bottom = bottom;
46 box->Front = front;
47 box->Back = back;
48}
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLint GLint bottom
Definition: glext.h:7726
static struct address_cache * front
Definition: rpcb_clnt.c:83

Referenced by test_D3DXLoadVolumeFromFileInMemory(), and test_D3DXLoadVolumeFromMemory().

◆ START_TEST()

START_TEST ( volume  )

Definition at line 395 of file volume.c.

396{
397 HWND wnd;
398 IDirect3D9 *d3d;
401 HRESULT hr;
402
403 if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
404 640, 480, NULL, NULL, NULL, NULL)))
405 {
406 skip("Couldn't create application window\n");
407 return;
408 }
410 if (!d3d)
411 {
412 skip("Couldn't create IDirect3D9 object\n");
413 DestroyWindow(wnd);
414 return;
415 }
416
417 ZeroMemory(&d3dpp, sizeof(d3dpp));
418 d3dpp.Windowed = TRUE;
421 if(FAILED(hr))
422 {
423 skip("Failed to create IDirect3DDevice9 object %#lx\n", hr);
425 DestroyWindow(wnd);
426 return;
427 }
428
431
434 DestroyWindow(wnd);
435}
#define skip(...)
Definition: atltest.h:64
@ D3DSWAPEFFECT_DISCARD
Definition: d3d8types.h:851
@ D3DDEVTYPE_HAL
Definition: d3d8types.h:576
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:224
#define IDirect3D9_Release(p)
Definition: d3d9.h:209
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1336
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
DWORD IDirect3DDevice9
Definition: dxva2api.idl:22
#define FAILED(hr)
Definition: intsafe.h:51
#define ZeroMemory
Definition: minwinbase.h:31
static void test_D3DXLoadVolumeFromMemory(IDirect3DDevice9 *device)
Definition: volume.c:50
static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device)
Definition: volume.c:216
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
BOOL WINAPI DestroyWindow(_In_ HWND)
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:53
#define D3D_SDK_VERSION
Definition: d3d8.h:52
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING
Definition: d3d8.h:40
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
Definition: devices.h:37

◆ test_D3DXLoadVolumeFromFileInMemory()

static void test_D3DXLoadVolumeFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 216 of file volume.c.

217{
218 HRESULT hr;
219 D3DBOX src_box;
220 uint32_t x, y, z, i;
222 D3DXIMAGE_INFO img_info;
223 IDirect3DVolume9 *volume;
224 D3DLOCKED_BOX locked_box;
225 struct volume_readback volume_rb;
226 IDirect3DVolumeTexture9 *volume_texture;
227 static const uint32_t bmp_32bpp_4_4_argb_expected[] =
228 {
229 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000,
230 };
231
233 &volume_texture, NULL);
234 if (FAILED(hr))
235 {
236 skip("Failed to create volume texture\n");
237 return;
238 }
239
241
243 ok(hr == D3D_OK, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
244
246 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
247
249 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
250
252 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
253
255 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
256
257 set_box(&src_box, 0, 0, 4, 4, 0, 2);
259 ok(hr == D3D_OK, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
260
261 set_box(&src_box, 0, 0, 0, 0, 0, 0);
263 ok(hr == E_FAIL, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, E_FAIL);
264
265 set_box(&src_box, 0, 0, 5, 4, 0, 2);
267 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
268
269 set_box(&src_box, 0, 0, 4, 4, 0, 3);
271 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
272
274 IDirect3DVolumeTexture9_Release(volume_texture);
275
276 /* Load 2D DDS image into a volume. */
278 &volume_texture, NULL);
279 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
280
282 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
283 {
284 winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
285
288 ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
289
291 }
292
294 D3DX_FILTER_POINT, 0, &img_info);
295 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
297
298 IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc);
299 get_texture_volume_readback(device, volume_texture, 0, &volume_rb);
300 for (z = 0; z < desc.Depth; ++z)
301 {
302 for (y = 0; y < desc.Height; ++y)
303 {
304 for (x = 0; x < desc.Width; ++x)
305 {
306 check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, 0xffff0000, FALSE);
307 }
308 }
309 }
310 release_volume_readback(&volume_rb);
311
313 IDirect3DVolumeTexture9_Release(volume_texture);
314
315 /* Load a BMP image into a volume. */
317 &volume_texture, NULL);
318 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
319
322 D3DX_FILTER_POINT, 0, &img_info);
323 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
325
326 IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc);
327 get_texture_volume_readback(device, volume_texture, 0, &volume_rb);
328 for (z = 0; z < desc.Depth; ++z)
329 {
330 for (y = 0; y < desc.Height; ++y)
331 {
332 const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2];
333
334 for (x = 0; x < desc.Width; ++x)
335 {
336 if (x < (desc.Width / 2))
337 check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE);
338 else
339 check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE);
340 }
341 }
342 }
343 release_volume_readback(&volume_rb);
344
346 IDirect3DVolumeTexture9_Release(volume_texture);
347
348 /* PNG tests. */
350 &volume_texture, NULL);
351 if (FAILED(hr))
352 {
353 skip("Failed to create volume texture\n");
354 return;
355 }
356
358
361 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
362
364
365 for (i = 0; i < 2; ++i)
366 {
367 check_pixel_8bpp(&locked_box, 0, 0, i, 0xffff202010100000);
368 check_pixel_8bpp(&locked_box, 1, 0, i, 0xffff505040403030);
369 check_pixel_8bpp(&locked_box, 0, 1, i, 0xffff808070706060);
370 check_pixel_8bpp(&locked_box, 1, 1, i, 0xffffb0b0a0a09090);
371 }
372
374
377 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
378
380
381 for (i = 0; i < 2; ++i)
382 {
383 check_pixel_8bpp(&locked_box, 0, 0, i, 0x3030202010100000);
384 check_pixel_8bpp(&locked_box, 1, 0, i, 0x7070606050504040);
385 check_pixel_8bpp(&locked_box, 0, 1, i, 0xb0b0a0a090908080);
386 check_pixel_8bpp(&locked_box, 1, 1, i, 0xf0f0e0e0d0d0c0c0);
387 }
388
390
392 IDirect3DVolumeTexture9_Release(volume_texture);
393}
#define ok(value,...)
Definition: atltest.h:57
#define ARRAY_SIZE(A)
Definition: main.h:20
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
@ D3DFMT_R8G8B8
Definition: d3d8types.h:603
@ D3DFMT_A8R8G8B8
Definition: d3d8types.h:604
@ D3DFMT_DXT3
Definition: d3d8types.h:636
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
@ D3DRTYPE_TEXTURE
Definition: d3d8types.h:812
@ D3DPOOL_DEFAULT
Definition: d3d8types.h:709
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define IDirect3DVolumeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:955
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:937
#define IDirect3DVolume9_UnlockBox(p)
Definition: d3d9.h:286
#define IDirect3DVolume9_LockBox(p, a, b, c)
Definition: d3d9.h:285
#define IDirect3DVolume9_Release(p)
Definition: d3d9.h:277
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1359
#define IDirect3DVolumeTexture9_GetVolumeLevel(p, a, b)
Definition: d3d9.h:956
@ D3DFMT_A16B16G16R16
Definition: d3d9types.h:806
#define D3D_OK
Definition: d3d.h:106
#define check_volume_readback_pixel_4bpp(rb, x, y, z, color, todo)
static const uint8_t bmp_32bpp_4_4_argb[]
#define check_image_info(info, width, height, depth, mip_levels, format, resource_type, image_file_format, wine_todo)
static const uint8_t dds_24bit_8_8[]
#define get_texture_volume_readback(device, volume_tex, mip_level, rb)
static const uint8_t png_2_2_64bpp_rgba[]
static const uint8_t png_2_2_48bpp_rgb[]
static const uint8_t dds_volume_map[]
static const struct @1926 test_filter_values[]
#define release_volume_readback(rb)
HRESULT expected_hr
#define E_FAIL
Definition: ddrawi.h:102
#define FALSE
Definition: types.h:117
UINT32 uint32_t
Definition: types.h:75
HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, UINT src_data_size, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info)
Definition: volume.c:179
@ D3DXIFF_DDS
Definition: dx8vb.idl:66
@ D3DXIFF_BMP
Definition: dx8vb.idl:62
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DX_FILTER_POINT
Definition: d3dx9tex.h:28
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:539
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
static void set_box(D3DBOX *box, UINT left, UINT top, UINT right, UINT bottom, UINT front, UINT back)
Definition: volume.c:40
#define check_pixel_8bpp(box, x, y, z, color)
Definition: volume.c:33
Definition: filter.c:165
D3DLOCKED_BOX locked_box

Referenced by START_TEST().

◆ test_D3DXLoadVolumeFromMemory()

static void test_D3DXLoadVolumeFromMemory ( IDirect3DDevice9 *  device)
static

Definition at line 50 of file volume.c.

51{
52 int i, x, y, z;
53 HRESULT hr;
54 D3DBOX src_box, dst_box;
55 D3DLOCKED_BOX locked_box;
56 IDirect3DVolume9 *volume;
57 IDirect3DVolumeTexture9 *volume_texture;
58 const DWORD pixels[] = { 0xc3394cf0, 0x235ae892, 0x09b197fd, 0x8dc32bf6,
59 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
60 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
61 0xffffffff, 0x00000000, 0xffffffff, 0x00000000 };
62
64 &volume_texture, NULL);
65 if (FAILED(hr))
66 {
67 skip("Failed to create volume texture.\n");
68 return;
69 }
70
72
73 set_box(&src_box, 0, 0, 4, 1, 0, 4);
74 set_box(&dst_box, 0, 0, 4, 1, 0, 4);
75
76 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
77 if (FAILED(hr))
78 {
79 win_skip("D3DXLoadVolumeFromMemory failed with error %#lx, skipping some tests.\n", hr);
80 return;
81 }
82
83 IDirect3DVolume9_LockBox(volume, &locked_box, &dst_box, D3DLOCK_READONLY);
84 for (i = 0; i < 16; i++) check_pixel_4bpp(&locked_box, i % 4, 0, i / 4, pixels[i]);
86
87 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_UNKNOWN, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
88 ok(hr == E_FAIL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, E_FAIL);
89
91 ok(hr == D3D_OK, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
92
93 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, NULL, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
94 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
95
97 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
98
99 set_box(&src_box, 0, 0, 4, 4, 0, 1);
100 set_box(&dst_box, 0, 0, 4, 4, 0, 1);
101 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, sizeof(pixels), NULL, &src_box, D3DX_DEFAULT, 0);
102 ok(hr == D3D_OK, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
103
104 IDirect3DVolume9_LockBox(volume, &locked_box, &dst_box, D3DLOCK_READONLY);
105 for (i = 0; i < 16; i++) check_pixel_4bpp(&locked_box, i % 4, i / 4, 0, pixels[i]);
107
109 ok(hr == D3D_OK, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
110
112 for (i = 0; i < 16; i++) check_pixel_4bpp(&locked_box, i % 4, i / 4, 0, pixels[i]);
113 for (z = 0; z < 4; z++)
114 {
115 for (y = 0; y < 256; y++)
116 {
117 for (x = 0; x < 256; x++)
118 if (z != 0 || y >= 4 || x >= 4) check_pixel_4bpp(&locked_box, x, y, z, 0);
119 }
120 }
122
123 set_box(&src_box, 0, 0, 2, 2, 1, 2);
124 set_box(&dst_box, 0, 0, 2, 2, 0, 1);
125 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 8, 16, NULL, &src_box, D3DX_DEFAULT, 0);
126 ok(hr == D3D_OK, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
127
128 IDirect3DVolume9_LockBox(volume, &locked_box, &dst_box, D3DLOCK_READONLY);
129 for (i = 0; i < 4; i++) check_pixel_4bpp(&locked_box, i % 2, i / 2, 0, pixels[i + 4]);
131
132 set_box(&src_box, 0, 0, 2, 2, 2, 3);
133 set_box(&dst_box, 0, 0, 2, 2, 1, 2);
134 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 8, 16, NULL, &src_box, D3DX_DEFAULT, 0);
135 ok(hr == D3D_OK, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
136
137 IDirect3DVolume9_LockBox(volume, &locked_box, &dst_box, D3DLOCK_READONLY);
138 for (i = 0; i < 4; i++) check_pixel_4bpp(&locked_box, i % 2, i / 2, 0, pixels[i + 8]);
140
141 set_box(&src_box, 0, 0, 4, 1, 0, 4);
142
143 set_box(&dst_box, -1, -1, 3, 0, 0, 4);
144 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
145 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
146
147 set_box(&dst_box, 254, 254, 258, 255, 0, 4);
148 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
149 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
150
151 set_box(&dst_box, 4, 1, 0, 0, 0, 4);
152 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
153 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
154
155 set_box(&dst_box, 0, 0, 0, 0, 0, 0);
156 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
157 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
158
159 set_box(&dst_box, 0, 0, 0, 0, 0, 1);
160 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
161 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
162
163 set_box(&dst_box, 300, 300, 300, 300, 0, 0);
164 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
165 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
166
168 IDirect3DVolumeTexture9_Release(volume_texture);
169
170 hr = IDirect3DDevice9_CreateVolumeTexture(device, 256, 256, 4, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &volume_texture, NULL);
171 if (FAILED(hr))
172 {
173 skip("Failed to create volume texture\n");
174 return;
175 }
176
178
179 set_box(&src_box, 0, 0, 4, 1, 0, 4);
180 set_box(&dst_box, 0, 0, 4, 1, 0, 4);
181 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 16, NULL, &src_box, D3DX_DEFAULT, 0);
182 ok(hr == D3DERR_INVALIDCALL, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
183
185 IDirect3DVolumeTexture9_Release(volume_texture);
186
188 if (FAILED(hr))
189 {
190 skip("Failed to create volume texture\n");
191 return;
192 }
193
195
196 set_box(&src_box, 1, 1, 7, 7, 0, 1);
197 set_box(&dst_box, 1, 1, 7, 7, 0, 1);
198 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 32, NULL, &src_box, D3DX_DEFAULT, 0);
199 ok(hr == D3D_OK, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
200
201 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
202 {
203 winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
204
205 hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 32, NULL, &src_box,
207 ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
208
210 }
211
213 IDirect3DVolumeTexture9_Release(volume_texture);
214}
@ D3DFMT_DXT1
Definition: d3d8types.h:634
@ D3DFMT_UNKNOWN
Definition: d3d8types.h:601
HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_memory, D3DFORMAT src_format, UINT src_row_pitch, UINT src_slice_pitch, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
Definition: volume.c:146
#define D3DX_FILTER_NONE
Definition: d3dx9tex.h:27
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
#define win_skip
Definition: minitest.h:67
#define check_pixel_4bpp(box, x, y, z, color)
Definition: volume.c:26

Referenced by START_TEST().