ReactOS  0.4.15-dev-985-gd905dd5
texture.c File Reference
#include "wine/test.h"
#include "d3dx9tex.h"
#include "resources.h"
Include dependency graph for texture.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define ADMITTED_ERROR   0.0001f
 
#define expect_vec4(expected, got)   expect_vec4_(__LINE__, expected, got)
 

Enumerations

enum  cube_coord {
  XCOORD = 0, XCOORDINV = 1, YCOORD = 2, YCOORDINV = 3,
  ZERO = 4, ONE = 5, XCOORD = 0, XCOORDINV = 1,
  YCOORD = 2, YCOORDINV = 3, ZERO = 4, ONE = 5
}
 

Functions

static float relative_error (float expected, float got)
 
static void expect_vec4_ (unsigned int line, const D3DXVECTOR4 *expected, const D3DXVECTOR4 *got)
 
static BOOL compare_color (DWORD c1, DWORD c2, BYTE max_diff)
 
static BOOL is_autogenmipmap_supported (IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
 
static void test_D3DXCheckTextureRequirements (IDirect3DDevice9 *device)
 
static void test_D3DXCheckCubeTextureRequirements (IDirect3DDevice9 *device)
 
static void test_D3DXCheckVolumeTextureRequirements (IDirect3DDevice9 *device)
 
static void test_D3DXCreateTexture (IDirect3DDevice9 *device)
 
static void test_D3DXFilterTexture (IDirect3DDevice9 *device)
 
static BOOL color_match (const DWORD *value, const DWORD *expected)
 
static void WINAPI fillfunc (D3DXVECTOR4 *value, const D3DXVECTOR2 *texcoord, const D3DXVECTOR2 *texelsize, void *data)
 
static void test_D3DXFillTexture (IDirect3DDevice9 *device)
 
static void WINAPI fillfunc_cube (D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
 
static float get_cube_coord (enum cube_coord coord, unsigned int x, unsigned int y, unsigned int size)
 
static void test_D3DXFillCubeTexture (IDirect3DDevice9 *device)
 
static void WINAPI fillfunc_volume (D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
 
static void test_D3DXFillVolumeTexture (IDirect3DDevice9 *device)
 
static void test_D3DXCreateTextureFromFileInMemory (IDirect3DDevice9 *device)
 
static void test_D3DXCreateTextureFromFileInMemoryEx (IDirect3DDevice9 *device)
 
static void test_D3DXCreateCubeTextureFromFileInMemory (IDirect3DDevice9 *device)
 
static void test_D3DXCreateCubeTextureFromFileInMemoryEx (IDirect3DDevice9 *device)
 
static void test_D3DXCreateVolumeTextureFromFileInMemory (IDirect3DDevice9 *device)
 
static void WINAPI fill_cube_positive_x (D3DXVECTOR4 *out, const D3DXVECTOR3 *tex_coord, const D3DXVECTOR3 *texel_size, void *data)
 
static void test_D3DXSaveTextureToFileInMemory (IDirect3DDevice9 *device)
 
static void test_texture_shader (void)
 
 START_TEST (texture)
 

Variables

static int has_2d_dxt3
 
static int has_2d_dxt5
 
static int has_cube_dxt5
 
static int has_3d_dxt3
 
static const unsigned char dds_16bit []
 
static const unsigned char dds_24bit []
 
static const unsigned char dds_cube_map []
 
static const unsigned char dds_volume_map []
 
static const unsigned char png_grayscale []
 

Macro Definition Documentation

◆ ADMITTED_ERROR

#define ADMITTED_ERROR   0.0001f

Definition at line 100 of file texture.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file texture.c.

◆ expect_vec4

#define expect_vec4 (   expected,
  got 
)    expect_vec4_(__LINE__, expected, got)

Definition at line 107 of file texture.c.

Enumeration Type Documentation

◆ cube_coord

Enumerator
XCOORD 
XCOORDINV 
YCOORD 
YCOORDINV 
ZERO 
ONE 
XCOORD 
XCOORDINV 
YCOORD 
YCOORDINV 
ZERO 
ONE 

Definition at line 1269 of file texture.c.

1270 {
1271  XCOORD = 0,
1272  XCOORDINV = 1,
1273  YCOORD = 2,
1274  YCOORDINV = 3,
1275  ZERO = 4,
1276  ONE = 5
1277 };
Definition: texture.c:1677
Definition: texture.c:1676

Function Documentation

◆ color_match()

static BOOL color_match ( const DWORD value,
const DWORD expected 
)
static

Definition at line 997 of file texture.c.

998 {
999  int i;
1000 
1001  for (i = 0; i < 4; i++)
1002  {
1003  DWORD diff = value[i] > expected[i] ? value[i] - expected[i] : expected[i] - value[i];
1004  if (diff > 1) return FALSE;
1005  }
1006  return TRUE;
1007 }
#define TRUE
Definition: types.h:120
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
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL expected
Definition: store.c:2063

Referenced by test_D3DXFillCubeTexture(), test_D3DXFillTexture(), and test_D3DXFillVolumeTexture().

◆ compare_color()

static BOOL compare_color ( DWORD  c1,
DWORD  c2,
BYTE  max_diff 
)
static

Definition at line 119 of file texture.c.

120 {
121  if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff)
122  return FALSE;
123  c1 >>= 8; c2 >>= 8;
124  if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff)
125  return FALSE;
126  c1 >>= 8; c2 >>= 8;
127  if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff)
128  return FALSE;
129  c1 >>= 8; c2 >>= 8;
130  if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff)
131  return FALSE;
132  return TRUE;
133 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Referenced by test_texture_shader().

◆ expect_vec4_()

static void expect_vec4_ ( unsigned int  line,
const D3DXVECTOR4 expected,
const D3DXVECTOR4 got 
)
inlinestatic

Definition at line 108 of file texture.c.

109 {
110  ok_(__FILE__, line)(relative_error(expected->x, got->x) < ADMITTED_ERROR
111  && relative_error(expected->y, got->y) < ADMITTED_ERROR
112  && relative_error(expected->z, got->z) < ADMITTED_ERROR
113  && relative_error(expected->w, got->w) < ADMITTED_ERROR,
114  "Expected (%f, %f, %f, %f), got (%f, %f, %f, %f)\n",
115  expected->x, expected->y, expected->z, expected->w,
116  got->x, got->y, got->z, got->w);
117 }
#define ADMITTED_ERROR
Definition: texture.c:100
Definition: parser.c:48
static float relative_error(float expected, float got)
Definition: texture.c:102
BOOL expected
Definition: store.c:2063
#define ok_(x1, x2)
Definition: atltest.h:61

◆ fill_cube_positive_x()

static void WINAPI fill_cube_positive_x ( D3DXVECTOR4 out,
const D3DXVECTOR3 tex_coord,
const D3DXVECTOR3 texel_size,
void data 
)
static

Definition at line 1844 of file texture.c.

1845 {
1846  memset(out, 0, sizeof(*out));
1847  if (tex_coord->x > 0 && fabs(tex_coord->x) > fabs(tex_coord->y) && fabs(tex_coord->x) > fabs(tex_coord->z))
1848  out->x = 1;
1849 }
static FILE * out
Definition: regtests2xml.c:44
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_D3DXSaveTextureToFileInMemory().

◆ fillfunc()

static void WINAPI fillfunc ( D3DXVECTOR4 value,
const D3DXVECTOR2 texcoord,
const D3DXVECTOR2 texelsize,
void data 
)
static

Definition at line 1009 of file texture.c.

1011 {
1012  value->x = texcoord->x;
1013  value->y = texcoord->y;
1014  value->z = texelsize->x;
1015  value->w = 1.0f;
1016 }
FLOAT y
Definition: d3dx9math.h:64
FLOAT x
Definition: d3dx9math.h:64

Referenced by test_D3DXFillTexture().

◆ fillfunc_cube()

static void WINAPI fillfunc_cube ( D3DXVECTOR4 value,
const D3DXVECTOR3 texcoord,
const D3DXVECTOR3 texelsize,
void data 
)
static

Definition at line 1260 of file texture.c.

1262 {
1263  value->x = (texcoord->x + 1.0f) / 2.0f;
1264  value->y = (texcoord->y + 1.0f) / 2.0f;
1265  value->z = (texcoord->z + 1.0f) / 2.0f;
1266  value->w = texelsize->x;
1267 }
GLfloat f
Definition: glext.h:7540

Referenced by test_D3DXFillCubeTexture().

◆ fillfunc_volume()

static void WINAPI fillfunc_volume ( D3DXVECTOR4 value,
const D3DXVECTOR3 texcoord,
const D3DXVECTOR3 texelsize,
void data 
)
static

Definition at line 1416 of file texture.c.

1418 {
1419  value->x = texcoord->x;
1420  value->y = texcoord->y;
1421  value->z = texcoord->z;
1422  value->w = texelsize->x;
1423 }

Referenced by test_D3DXFillVolumeTexture().

◆ get_cube_coord()

static float get_cube_coord ( enum cube_coord  coord,
unsigned int  x,
unsigned int  y,
unsigned int  size 
)
static

Definition at line 1279 of file texture.c.

1280 {
1281  switch (coord)
1282  {
1283  case XCOORD:
1284  return x + 0.5f;
1285  case XCOORDINV:
1286  return size - x - 0.5f;
1287  case YCOORD:
1288  return y + 0.5f;
1289  case YCOORDINV:
1290  return size - y - 0.5f;
1291  case ZERO:
1292  return 0.0f;
1293  case ONE:
1294  return size;
1295  default:
1296  trace("Unexpected coordinate value\n");
1297  return 0.0f;
1298  }
1299 }
Definition: texture.c:1677
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
Definition: texture.c:1676
GLuint coord
Definition: glext.h:9511
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by test_D3DXFillCubeTexture().

◆ is_autogenmipmap_supported()

static BOOL is_autogenmipmap_supported ( IDirect3DDevice9 *  device,
D3DRESOURCETYPE  resource_type 
)
static

Definition at line 135 of file texture.c.

136 {
137  HRESULT hr;
138  D3DCAPS9 caps;
139  IDirect3D9 *d3d9;
142 
147 
148  if (!(caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP))
149  return FALSE;
150 
151  hr = IDirect3D9_CheckDeviceFormat(d3d9, params.AdapterOrdinal, params.DeviceType,
152  mode.Format, D3DUSAGE_AUTOGENMIPMAP, resource_type, D3DFMT_A8R8G8B8);
153 
155  return hr == D3D_OK;
156 }
#define IDirect3D9_CheckDeviceFormat(p, a, b, c, d, e, f)
Definition: d3d9.h:229
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DDevice9_GetCreationParameters(p, a)
Definition: d3d9.h:1516
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
#define FALSE
Definition: types.h:117
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: devices.h:37
#define IDirect3DDevice9_GetDisplayMode(p, a, b)
Definition: d3d9.h:1515
#define IDirect3DDevice9_GetDirect3D(p, a)
Definition: d3d9.h:1513
DWORD Caps2
Definition: d3d9caps.h:267
LONG HRESULT
Definition: typedefs.h:79
GLenum mode
Definition: glext.h:6217
#define D3DCAPS2_CANAUTOGENMIPMAP
Definition: d3d9caps.h:22
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514

Referenced by test_D3DXCheckCubeTextureRequirements(), test_D3DXCheckTextureRequirements(), test_D3DXCheckVolumeTextureRequirements(), test_D3DXCreateCubeTextureFromFileInMemoryEx(), test_D3DXCreateTextureFromFileInMemoryEx(), and test_D3DXFilterTexture().

◆ relative_error()

static float relative_error ( float  expected,
float  got 
)
inlinestatic

Definition at line 102 of file texture.c.

103 {
104  return expected == 0.0f ? fabs(expected - got) : fabs(1.0f - got / expected);
105 }
GLfloat f
Definition: glext.h:7540
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
BOOL expected
Definition: store.c:2063

Referenced by expect_vec4_().

◆ START_TEST()

START_TEST ( texture  )

Definition at line 2257 of file texture.c.

2258 {
2259  HWND wnd;
2260  IDirect3D9 *d3d;
2261  IDirect3DDevice9 *device;
2262  D3DPRESENT_PARAMETERS d3dpp;
2263  HRESULT hr;
2264  ULONG ref;
2265 
2266  if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
2267  640, 480, NULL, NULL, NULL, NULL)))
2268  {
2269  skip("Couldn't create application window\n");
2270  return;
2271  }
2273  if (!d3d) {
2274  skip("Couldn't create IDirect3D9 object\n");
2275  DestroyWindow(wnd);
2276  return;
2277  }
2278 
2279  ZeroMemory(&d3dpp, sizeof(d3dpp));
2280  d3dpp.Windowed = TRUE;
2283  if (FAILED(hr)) {
2284  skip("Failed to create IDirect3DDevice9 object %#x\n", hr);
2285  IDirect3D9_Release(d3d);
2286  DestroyWindow(wnd);
2287  return;
2288  }
2289 
2290  /* Check whether DXTn textures are supported. */
2301 
2316 
2318  ok(!ref, "Device has %u references left.\n", ref);
2319 
2320  IDirect3D9_Release(d3d);
2321  DestroyWindow(wnd);
2322 
2324 }
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
static void test_D3DXCheckCubeTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:422
static void test_D3DXSaveTextureToFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:1851
#define IDirect3D9_CheckDeviceFormat(p, a, b, c, d, e, f)
Definition: d3d9.h:229
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING
Definition: d3d8.h:44
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:1537
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DestroyWindow(_In_ HWND)
Definition: send.c:48
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
static void test_D3DXFillTexture(IDirect3DDevice9 *device)
Definition: texture.c:1018
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
static void test_texture_shader(void)
Definition: texture.c:2033
static void test_D3DXCreateTexture(IDirect3DDevice9 *device)
Definition: texture.c:644
static int has_2d_dxt3
Definition: texture.c:28
Definition: devices.h:37
GLenum GLint ref
Definition: glext.h:6028
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
static int has_cube_dxt5
Definition: texture.c:28
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
smooth NULL
Definition: ftsmooth.c:416
static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:1743
static void test_D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
Definition: texture.c:1779
static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:158
static void test_D3DXFilterTexture(IDirect3DDevice9 *device)
Definition: texture.c:851
#define D3D_SDK_VERSION
Definition: d3d8.h:56
LONG HRESULT
Definition: typedefs.h:79
static void test_D3DXFillVolumeTexture(IDirect3DDevice9 *device)
Definition: texture.c:1425
static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
Definition: texture.c:1615
static void test_D3DXFillCubeTexture(IDirect3DDevice9 *device)
Definition: texture.c:1301
static int has_2d_dxt5
Definition: texture.c:28
static int has_3d_dxt3
Definition: texture.c:28
#define ok(value,...)
Definition: atltest.h:57
static void test_D3DXCheckVolumeTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:523
#define skip(...)
Definition: atltest.h:64
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
unsigned int ULONG
Definition: retypes.h:1
static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:1797
#define SUCCEEDED(hr)
Definition: intsafe.h:57
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128

◆ test_D3DXCheckCubeTextureRequirements()

static void test_D3DXCheckCubeTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 422 of file texture.c.

423 {
424  UINT size, mipmaps, expected;
426  D3DCAPS9 caps;
427  HRESULT hr;
428 
430 
431  if (!(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP))
432  {
433  skip("No cube textures support\n");
434  return;
435  }
436 
437  /* general tests */
439  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
440 
442  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
443 
445  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
446 
447  /* size */
448  size = D3DX_DEFAULT;
450  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
451  ok(size == 256, "Returned size %d, expected %d\n", size, 256);
452 
453  /* mipmaps */
454  size = 64;
455  mipmaps = 9;
457  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
458  ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
459 
460  size = 284;
461  mipmaps = 20;
465  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
466  ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
467 
468  size = 63;
469  mipmaps = 9;
473  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
474  ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
475 
476  mipmaps = 0;
478  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
479  ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
480 
482  {
483  mipmaps = 3;
485  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
486  ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
487  }
488  else
489  skip("No D3DUSAGE_AUTOGENMIPMAP support for cube textures\n");
490 
491  /* usage */
493  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
495  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
497  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
499  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
501  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
502 
503  /* format */
505  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
506 
509  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
510  ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
511 
514  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
515  ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
516 
519  ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
520  ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
521 }
HRESULT WINAPI D3DXCheckCubeTextureRequirements(struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:417
DWORD TextureCaps
Definition: d3d9caps.h:279
HRESULT hr
Definition: shlfolder.c:183
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define D3DPTEXTURECAPS_CUBEMAP_POW2
Definition: d3d8caps.h:126
#define D3DUSAGE_POINTS
Definition: d3d8types.h:96
#define D3DUSAGE_DONOTCLIP
Definition: d3d8types.h:95
#define D3DERR_INVALIDCALL
#define D3DUSAGE_WRITEONLY
Definition: d3d8types.h:93
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
smooth NULL
Definition: ftsmooth.c:416
enum _D3DFORMAT D3DFORMAT
#define D3DUSAGE_NPATCHES
Definition: d3d8types.h:98
#define D3DPTEXTURECAPS_CUBEMAP
Definition: d3d8caps.h:121
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
#define D3DUSAGE_RTPATCHES
Definition: d3d8types.h:97
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
Definition: texture.c:135
#define skip(...)
Definition: atltest.h:64
#define D3DPTEXTURECAPS_MIPCUBEMAP
Definition: d3d8caps.h:125
BOOL expected
Definition: store.c:2063

Referenced by START_TEST().

◆ test_D3DXCheckTextureRequirements()

static void test_D3DXCheckTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 158 of file texture.c.

159 {
160  UINT width, height, mipmaps;
162  D3DCAPS9 caps;
163  HRESULT hr;
164  IDirect3D9 *d3d;
167 
169 
170  /* general tests */
172  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
173 
175  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
176 
178  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
179 
180  /* width & height */
183  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
184  ok(width == 256, "Returned width %d, expected %d\n", width, 256);
185  ok(height == 256, "Returned height %d, expected %d\n", height, 256);
186 
189  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
190  ok(width == 256, "Returned width %d, expected %d\n", width, 256);
191 
193  skip("Hardware only supports pow2 textures\n");
194  else
195  {
196  width = 62;
198  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
199  ok(width == 62, "Returned width %d, expected %d\n", width, 62);
200 
201  width = D3DX_DEFAULT; height = 63;
203  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
204  ok(width == height, "Returned width %d, expected %d\n", width, height);
205  ok(height == 63, "Returned height %d, expected %d\n", height, 63);
206  }
207 
208  width = D3DX_DEFAULT; height = 0;
210  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
211  ok(width == 1, "Returned width %d, expected %d\n", width, 1);
212  ok(height == 1, "Returned height %d, expected %d\n", height, 1);
213 
214  width = 0; height = 0;
216  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
217  ok(width == 1, "Returned width %d, expected %d\n", width, 1);
218  ok(height == 1, "Returned height %d, expected %d\n", height, 1);
219 
220  width = 0;
222  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
223  ok(width == 1, "Returned width %d, expected %d\n", width, 1);
224 
225  width = 0xFFFFFFFE;
227  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
228  ok(width == caps.MaxTextureWidth, "Returned width %d, expected %d\n", width, caps.MaxTextureWidth);
229 
230  width = caps.MaxTextureWidth-1;
232  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
234  ok(width == caps.MaxTextureWidth, "Returned width %d, expected %d\n", width, caps.MaxTextureWidth);
235  else
236  ok(width == caps.MaxTextureWidth-1, "Returned width %d, expected %d\n", width, caps.MaxTextureWidth-1);
237 
238  /* mipmaps */
239  width = 64; height = 63;
240  mipmaps = 9;
242  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
243  ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
244 
245  if (!(caps.TextureCaps & D3DPTEXTURECAPS_POW2))
246  {
247  width = 284; height = 137;
248  mipmaps = 20;
250  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
251  ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
252 
253  width = height = 63;
254  mipmaps = 9;
256  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
257  ok(mipmaps == 6, "Returned mipmaps %d, expected %d\n", mipmaps, 6);
258  }
259  else
260  skip("Skipping some tests, npot2 textures unsupported\n");
261 
262  mipmaps = 20;
264  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
265  ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
266 
267  mipmaps = 0;
269  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
270  ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
271 
272  /* mipmaps when D3DUSAGE_AUTOGENMIPMAP is set */
274  {
275  mipmaps = 0;
277  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
278  ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
279  mipmaps = 1;
281  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
282  ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
283  mipmaps = 2;
285  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
286  ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
287  mipmaps = 6;
289  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
290  ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
291  }
292  else
293  skip("No D3DUSAGE_AUTOGENMIPMAP support for textures\n");
294 
295  /* usage */
297  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
299  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
301  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
303  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
305  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
306 
307  /* format */
309  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
310 
313  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
314  ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
315 
318  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
319  ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
320 
323  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
324  ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
325 
329 
330  if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
331  mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_R3G3B2)))
333  else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
334  mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_X4R4G4B4)))
336  else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
337  mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_X1R5G5B5)))
339  else
341 
344  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
345  ok(format == expected, "Returned format %u, expected %u\n", format, expected);
346 
347  if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
348  mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R3G3B2)))
350  else
352 
355  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
356  ok(format == expected, "Returned format %u, expected %u\n", format, expected);
357 
358  if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
359  mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_P8)))
361  else
363 
364  format = D3DFMT_P8;
366  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
367  ok(format == expected, "Returned format %u, expected %u\n", format, expected);
368 
369  if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
372  else
374 
375  format = D3DFMT_L8;
377  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
378  ok(format == expected, "Returned format %u, expected %u\n", format, expected);
379 
380  if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
383  else
385 
386  format = D3DFMT_L16;
388  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
389  ok(format == expected, "Returned format %u, expected %u\n", format, expected);
390 
391  /* Block-based texture formats and size < block size. */
392  if (has_2d_dxt5)
393  {
395  width = 2; height = 2;
396  mipmaps = 1;
398  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
399  ok(width == 4, "Returned width %d, expected %d\n", width, 4);
400  ok(height == 4, "Returned height %d, expected %d\n", height, 4);
401  ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
402  ok(format == D3DFMT_DXT5, "Returned format %u, expected %u\n", format, D3DFMT_DXT5);
403 
405  width = 5; height = 5;
406  mipmaps = 1;
408  ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
409  ok(width == 8, "Returned width %d, expected %d\n", width, 8);
410  ok(height == 8, "Returned height %d, expected %d\n", height, 8);
411  ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
412  ok(format == D3DFMT_DXT5, "Returned format %u, expected %u\n", format, D3DFMT_DXT5);
413  }
414  else
415  {
416  skip("D3DFMT_DXT5 textures are not supported, skipping a test.\n");
417  }
418 
419  IDirect3D9_Release(d3d);
420 }
#define IDirect3D9_CheckDeviceFormat(p, a, b, c, d, e, f)
Definition: d3d9.h:229
GLint GLint GLsizei width
Definition: gl.h:1546
#define D3DPTEXTURECAPS_POW2
Definition: d3d8caps.h:114
DWORD TextureCaps
Definition: d3d9caps.h:279
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DDevice9_GetCreationParameters(p, a)
Definition: d3d9.h:1516
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define D3DUSAGE_POINTS
Definition: d3d8types.h:96
#define D3DUSAGE_DONOTCLIP
Definition: d3d8types.h:95
#define D3DERR_INVALIDCALL
#define D3DUSAGE_WRITEONLY
Definition: d3d8types.h:93
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: devices.h:37
DWORD MaxTextureWidth
Definition: d3d9caps.h:286
#define D3DX_DEFAULT
Definition: d3dx9.h:24
smooth NULL
Definition: ftsmooth.c:416
enum _D3DFORMAT D3DFORMAT
#define IDirect3DDevice9_GetDisplayMode(p, a, b)
Definition: d3d9.h:1515
#define D3DUSAGE_NPATCHES
Definition: d3d8types.h:98
#define IDirect3DDevice9_GetDirect3D(p, a)
Definition: d3d9.h:1513
LONG HRESULT
Definition: typedefs.h:79
#define D3DUSAGE_RENDERTARGET
Definition: d3d8types.h:91
#define D3DUSAGE_RTPATCHES
Definition: d3d8types.h:97
GLenum mode
Definition: glext.h:6217
static int has_2d_dxt5
Definition: texture.c:28
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
Definition: texture.c:135
HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:209
#define skip(...)
Definition: atltest.h:64
BOOL expected
Definition: store.c:2063
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXCheckVolumeTextureRequirements()

static void test_D3DXCheckVolumeTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 523 of file texture.c.

524 {
525  UINT width, height, depth, mipmaps, expected;
527  D3DCAPS9 caps;
528  HRESULT hr;
529 
531 
532  if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) || (caps.MaxVolumeExtent < 256))
533  {
534  skip("Limited or no volume textures support.\n");
535  return;
536  }
537 
538  /* general tests */
540  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
541 
543  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
544 
546  ok(hr == D3DERR_INVALIDCALL, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
547 
548  /* width, height, depth */
551  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
552  ok(width == 256, "Returned width %d, expected %d\n", width, 256);
553  ok(height == 256, "Returned height %d, expected %d\n", height, 256);
554  ok(depth == 1, "Returned depth %d, expected %d\n", depth, 1);
555 
558  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
559  ok(width == 256, "Returned width %d, expected %d\n", width, 256);
560 
561  width = D3DX_DEFAULT; height = 0; depth = 0;
563  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
564  ok(width == 1, "Returned width %d, expected %d\n", width, 1);
565  ok(height == 1, "Returned height %d, expected %d\n", height, 1);
566  ok(depth == 1, "Returned height %d, expected %d\n", depth, 1);
567 
568  width = 0; height = 0; depth = 0;
570  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
571  ok(width == 1, "Returned width %d, expected %d\n", width, 1);
572  ok(height == 1, "Returned height %d, expected %d\n", height, 1);
573  ok(depth == 1, "Returned height %d, expected %d\n", depth, 1);
574 
575  width = 0;
577  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
578  ok(width == 1, "Returned width %d, expected %d\n", width, 1);
579 
580  width = 0xFFFFFFFE;
582  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
583  ok(width == caps.MaxVolumeExtent, "Returned width %d, expected %d\n", width, caps.MaxVolumeExtent);
584 
585  /* format */
587  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
588 
591  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
592  ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
593 
596  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
597  ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
598 
601  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
602  ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
603 
606  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
607  if (has_3d_dxt3)
608  ok(format == D3DFMT_DXT3, "Returned format %u, expected %u\n", format, D3DFMT_DXT3);
609  else
610  todo_wine ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
611 
612  /* mipmaps */
614  {
615  skip("No volume textures mipmapping support\n");
616  return;
617  }
618 
619  width = height = depth = 64;
620  mipmaps = 9;
622  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
623  ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
624 
625  width = 284;
626  height = 143;
627  depth = 55;
628  mipmaps = 20;
629  expected = (caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP_POW2 && caps.MaxVolumeExtent >= 512) ? 10 : 9;
631  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
632  ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
633 
634  mipmaps = 0;
636  ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
637  ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
638 
639  /* D3DUSAGE_AUTOGENMIPMAP is never supported for volume textures. */
641  "D3DUSAGE_AUTOGENMIPMAP is unexpectedly supported on volume textures.\n");
642 }
GLint GLint GLsizei width
Definition: gl.h:1546
DWORD TextureCaps
Definition: d3d9caps.h:279
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
#define D3DPTEXTURECAPS_MIPVOLUMEMAP
Definition: d3d8caps.h:124
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
DWORD MaxVolumeExtent
Definition: d3d9caps.h:288
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
smooth NULL
Definition: ftsmooth.c:416
enum _D3DFORMAT D3DFORMAT
LONG HRESULT
Definition: typedefs.h:79
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define todo_wine
Definition: test.h:162
HRESULT WINAPI D3DXCheckVolumeTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:453
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
static int has_3d_dxt3
Definition: texture.c:28
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
Definition: texture.c:135
#define skip(...)
Definition: atltest.h:64
#define D3DPTEXTURECAPS_VOLUMEMAP_POW2
Definition: d3d8caps.h:127
#define D3DPTEXTURECAPS_VOLUMEMAP
Definition: d3d8caps.h:122
BOOL expected
Definition: store.c:2063

Referenced by START_TEST().

◆ test_D3DXCreateCubeTextureFromFileInMemory()

static void test_D3DXCreateCubeTextureFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 1743 of file texture.c.

1744 {
1745  HRESULT hr;
1746  ULONG ref;
1747  DWORD levelcount;
1748  IDirect3DCubeTexture9 *cube_texture;
1749  D3DSURFACE_DESC surface_desc;
1750 
1752  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1753 
1754  hr = D3DXCreateCubeTextureFromFileInMemory(device, NULL, sizeof(dds_cube_map), &cube_texture);
1755  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1756 
1758  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1759 
1761  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1762 
1764  if (SUCCEEDED(hr))
1765  {
1766  levelcount = IDirect3DCubeTexture9_GetLevelCount(cube_texture);
1767  todo_wine ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
1768 
1769  hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &surface_desc);
1770  ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
1771  ok(surface_desc.Width == 4, "Got width %u, expected 4\n", surface_desc.Width);
1772  ok(surface_desc.Height == 4, "Got height %u, expected 4\n", surface_desc.Height);
1773 
1774  ref = IDirect3DCubeTexture9_Release(cube_texture);
1775  ok(ref == 0, "Invalid reference count. Got %u, expected 0\n", ref);
1776  } else skip("Couldn't create cube texture\n");
1777 }
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory(struct IDirect3DDevice9 *device, const void *data, UINT datasize, struct IDirect3DCubeTexture9 **texture)
Definition: texture.c:935
#define IDirect3DCubeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:937
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DCubeTexture9_GetLevelCount(p)
Definition: d3d9.h:932
#define D3DERR_INVALIDCALL
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:919
Definition: send.c:48
Definition: devices.h:37
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
static const unsigned char dds_cube_map[]
Definition: texture.c:57
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define todo_wine
Definition: test.h:162
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXCreateCubeTextureFromFileInMemoryEx()

static void test_D3DXCreateCubeTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device)
static

Definition at line 1779 of file texture.c.

1780 {
1781  HRESULT hr;
1782  IDirect3DCubeTexture9 *cube_texture;
1783 
1785  {
1786  skip("No D3DUSAGE_AUTOGENMIPMAP support for cube textures\n");
1787  return;
1788  }
1789 
1793  ok(hr == D3D_OK, "D3DXCreateCubeTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1794  if (SUCCEEDED(hr)) IDirect3DCubeTexture9_Release(cube_texture);
1795 }
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
HRESULT hr
Definition: shlfolder.c:183
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:919
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
static int has_cube_dxt5
Definition: texture.c:28
smooth NULL
Definition: ftsmooth.c:416
static const unsigned char dds_cube_map[]
Definition: texture.c:57
#define todo_wine_if(is_todo)
Definition: test.h:163
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
Definition: texture.c:135
#define skip(...)
Definition: atltest.h:64
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *src_data, UINT src_data_size, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
Definition: texture.c:1401
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXCreateTexture()

static void test_D3DXCreateTexture ( IDirect3DDevice9 *  device)
static

Definition at line 644 of file texture.c.

645 {
646  IDirect3DTexture9 *texture;
648  D3DCAPS9 caps;
649  UINT mipmaps;
650  HRESULT hr;
651 
653 
655  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
656 
657  /* width and height tests */
658 
660  ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
661 
662  if (texture)
663  {
665  ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
666  ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
667 
668  ok(desc.Width == 256, "Returned width %d, expected %d\n", desc.Width, 256);
669  ok(desc.Height == 256, "Returned height %d, expected %d\n", desc.Height, 256);
670 
672  }
673 
674 
675  hr = D3DXCreateTexture(device, 0, 0, 0, 0, 0, D3DPOOL_DEFAULT, &texture);
676  ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
677 
678  if (texture)
679  {
681  ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
682  ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
683 
684  ok(desc.Width == 1, "Returned width %d, expected %d\n", desc.Width, 1);
685  ok(desc.Height == 1, "Returned height %d, expected %d\n", desc.Height, 1);
686 
688  }
689 
690 
692  skip("Hardware only supports pow2 textures\n");
693  else
694  {
696  ok((hr == D3D_OK) ||
697  /* may not work with conditional NPOT */
699  "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
700 
701  if (texture)
702  {
704  ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
705  ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
706 
707  /* Conditional NPOT may create a texture with different dimensions, so allow those
708  situations instead of returning a fail */
709 
710  ok(desc.Width == 63 ||
712  "Returned width %d, expected %d\n", desc.Width, 63);
713 
714  ok(desc.Height == 63 ||
716  "Returned height %d, expected %d\n", desc.Height, 63);
717 
719  }
720  }
721 
722  /* mipmaps */
723 
724  hr = D3DXCreateTexture(device, 64, 63, 9, 0, 0, D3DPOOL_DEFAULT, &texture);
725  ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
726 
727  if (texture)
728  {
730  ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
731 
733  }
734 
735 
736  hr = D3DXCreateTexture(device, 284, 137, 9, 0, 0, D3DPOOL_DEFAULT, &texture);
737  ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
738 
739  if (texture)
740  {
742  ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
743 
745  }
746 
747 
748  hr = D3DXCreateTexture(device, 0, 0, 20, 0, 0, D3DPOOL_DEFAULT, &texture);
749  ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
750 
751  if (texture)
752  {
754  ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
755 
757  }
758 
759 
760  hr = D3DXCreateTexture(device, 64, 64, 1, 0, 0, D3DPOOL_DEFAULT, &texture);
761  ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
762 
763  if (texture)
764  {
766  ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
767 
769  }
770 
771  /* usage */
772 
774  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
776  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
778  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
780  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
782  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
783 
784  /* format */
785 
787  ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
788 
789  if (texture)
790  {
792  ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
793  ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
794 
796  }
797 
798 
799  hr = D3DXCreateTexture(device, 0, 0, 0, 0, 0, D3DPOOL_DEFAULT, &texture);
800  ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
801 
802  if (texture)
803  {
805  ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
806  ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
807 
809  }
810 
811  /* D3DXCreateTextureFromResource */
813  ok(hr == D3D_OK, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3D_OK);
815 
817  ok(hr == D3D_OK, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3D_OK);
819 
821  ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
822 
824  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
825 
827  ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
828 
830  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
831 
832 
833  /* D3DXCreateTextureFromResourceEx */
835  ok(hr == D3D_OK, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3D_OK);
837 
839  ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
840 
842  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
843 
845  ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
846 
848  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
849 }
#define D3DPTEXTURECAPS_POW2
Definition: d3d8caps.h:114
DWORD TextureCaps
Definition: d3d9caps.h:279
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI D3DXCreateTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
Definition: texture.c:526
#define IDS_STRING
Definition: resource.h:11
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
#define D3DUSAGE_POINTS
Definition: d3d8types.h:96
#define D3DUSAGE_DONOTCLIP
Definition: d3d8types.h:95
#define D3DERR_INVALIDCALL
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:1027
#define D3DUSAGE_WRITEONLY
Definition: d3d8types.h:93
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
HRESULT WINAPI D3DXCreateTextureFromResourceExA(struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:855
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
#define D3DX_DEFAULT
Definition: d3dx9.h:24
smooth NULL
Definition: ftsmooth.c:416
#define D3DUSAGE_NPATCHES
Definition: d3d8types.h:98
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL
Definition: d3d8caps.h:119
#define D3DUSAGE_RTPATCHES
Definition: d3d8types.h:97
#define IDB_BITMAP_1x1
Definition: resources.h:22
HRESULT WINAPI D3DXCreateTextureFromResourceA(struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, struct IDirect3DTexture9 **texture)
Definition: texture.c:837
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define IDD_BITMAPDATA_1x1
Definition: resources.h:23
#define skip(...)
Definition: atltest.h:64
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXCreateTextureFromFileInMemory()

static void test_D3DXCreateTextureFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 1537 of file texture.c.

1538 {
1539  HRESULT hr;
1540  IDirect3DTexture9 *texture;
1543  D3DLOCKED_RECT lock_rect;
1544  int i;
1545  DWORD level_count;
1546 
1548  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1550 
1552  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1554 
1556  ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
1557 
1558  /* Check that D3DXCreateTextureFromFileInMemory accepts cube texture dds file (only first face texture is loaded) */
1561  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
1562  if (SUCCEEDED(hr))
1563  {
1565  ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u\n", type, D3DRTYPE_TEXTURE);
1567  ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
1568  ok(desc.Width == 4, "Width is %u, expected 4\n", desc.Width);
1569  ok(desc.Height == 4, "Height is %u, expected 4\n", desc.Height);
1571  ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %#x, expected %#x\n", hr, D3D_OK);
1572  if (SUCCEEDED(hr))
1573  {
1574  for (i = 0; i < 16; i++)
1575  ok(((BYTE *)lock_rect.pBits)[i] == dds_cube_map[128 + i],
1576  "Byte at index %u is 0x%02x, expected 0x%02x.\n",
1577  i, ((BYTE *)lock_rect.pBits)[i], dds_cube_map[128 + i]);
1579  }
1581 
1582  }
1583 
1584  /* Volume textures work too. */
1587  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
1588  if (SUCCEEDED(hr))
1589  {
1591  ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u.\n", type, D3DRTYPE_TEXTURE);
1592  level_count = IDirect3DBaseTexture9_GetLevelCount((IDirect3DBaseTexture9 *)texture);
1593  todo_wine ok(level_count == 3, "Texture has %u mip levels, 3 expected.\n", level_count);
1595  ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
1596  ok(desc.Width == 4, "Width is %u, expected 4.\n", desc.Width);
1597  ok(desc.Height == 4, "Height is %u, expected 4.\n", desc.Height);
1598 
1600  ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %#x, expected %#x.\n", hr, D3D_OK);
1601  if (SUCCEEDED(hr))
1602  {
1603  for (i = 0; i < 16; ++i)
1604  ok(((BYTE *)lock_rect.pBits)[i] == dds_volume_map[128 + i],
1605  "Byte at index %u is 0x%02x, expected 0x%02x.\n",
1606  i, ((BYTE *)lock_rect.pBits)[i], dds_volume_map[128 + i]);
1608  }
1609  /* The lower texture levels are apparently generated by filtering the level 0 surface
1610  * I.e. following levels from the file are ignored. */
1612  }
1613 }
#define IDirect3DTexture9_UnlockRect(p, a)
Definition: d3d9.h:1035
HRESULT hr
Definition: shlfolder.c:183
static const unsigned char dds_volume_map[]
Definition: texture.c:75
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static const unsigned char dds_16bit[]
Definition: texture.c:31
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
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
static int has_2d_dxt3
Definition: texture.c:28
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
static const unsigned char dds_24bit[]
Definition: texture.c:44
smooth NULL
Definition: ftsmooth.c:416
static const unsigned char dds_cube_map[]
Definition: texture.c:57
#define todo_wine_if(is_todo)
Definition: test.h:163
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
HRESULT WINAPI D3DXCreateTextureFromFileInMemory(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, struct IDirect3DTexture9 **texture)
Definition: texture.c:751
unsigned long DWORD
Definition: ntddk_ex.h:95
#define todo_wine
Definition: test.h:162
static int has_2d_dxt5
Definition: texture.c:28
unsigned char BYTE
Definition: xxhash.c:193
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define IDirect3DTexture9_LockRect(p, a, b, c, d)
Definition: d3d9.h:1034
#define IDirect3DTexture9_GetType(p)
Definition: d3d9.h:1023
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:848
enum _D3DRESOURCETYPE D3DRESOURCETYPE
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXCreateTextureFromFileInMemoryEx()

static void test_D3DXCreateTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device)
static

Definition at line 1615 of file texture.c.

1616 {
1617  HRESULT hr;
1618  IDirect3DTexture9 *texture;
1619  unsigned int miplevels;
1620  IDirect3DSurface9 *surface;
1622 
1625  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
1627 
1630  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
1632 
1636  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
1638  ok(miplevels == 1, "Got miplevels %u, expected %u.\n", miplevels, 1);
1640  IDirect3DSurface9_GetDesc(surface, &desc);
1641  ok(desc.Width == 1 && desc.Height == 1,
1642  "Surface dimensions are %ux%u, expected 1x1.\n", desc.Width, desc.Height);
1643  IDirect3DSurface9_Release(surface);
1645 
1647  {
1648  skip("No D3DUSAGE_AUTOGENMIPMAP support for textures\n");
1649  return;
1650  }
1651 
1654  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
1656 
1657  /* Checking for color key format overrides. */
1661  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1663  IDirect3DSurface9_GetDesc(surface, &desc);
1664  ok(desc.Format == D3DFMT_X1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X1R5G5B5);
1665  IDirect3DSurface9_Release(surface);
1669  D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1670  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1672  IDirect3DSurface9_GetDesc(surface, &desc);
1673  ok(desc.Format == D3DFMT_A1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A1R5G5B5);
1674  IDirect3DSurface9_Release(surface);
1678  D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1679  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1681  IDirect3DSurface9_GetDesc(surface, &desc);
1682  ok(desc.Format == D3DFMT_X1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X1R5G5B5);
1683  IDirect3DSurface9_Release(surface);
1685 
1689  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1691  IDirect3DSurface9_GetDesc(surface, &desc);
1692  ok(desc.Format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X8R8G8B8);
1693  IDirect3DSurface9_Release(surface);
1697  D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1698  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1700  IDirect3DSurface9_GetDesc(surface, &desc);
1701  ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A8R8G8B8);
1702  IDirect3DSurface9_Release(surface);
1706  D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1707  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1709  IDirect3DSurface9_GetDesc(surface, &desc);
1710  ok(desc.Format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X8R8G8B8);
1711  IDirect3DSurface9_Release(surface);
1713 
1717  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1719  IDirect3DSurface9_GetDesc(surface, &desc);
1720  ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_L8);
1721  IDirect3DSurface9_Release(surface);
1725  D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1726  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1728  IDirect3DSurface9_GetDesc(surface, &desc);
1729  ok(desc.Format == D3DFMT_A8L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A8L8);
1730  IDirect3DSurface9_Release(surface);
1734  D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1735  ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1737  IDirect3DSurface9_GetDesc(surface, &desc);
1738  ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_L8);
1739  IDirect3DSurface9_Release(surface);
1741 }
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:1033
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:566
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:1027
static const unsigned char dds_16bit[]
Definition: texture.c:31
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
#define D3DX_DEFAULT
Definition: d3dx9.h:24
static const unsigned char dds_24bit[]
Definition: texture.c:44
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
static const unsigned char png_grayscale[]
Definition: texture.c:90
#define IDirect3DSurface9_GetDesc(p, a)
Definition: d3d9.h:634
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define D3DX_SKIP_DDS_MIP_LEVELS(l, f)
Definition: d3dx9tex.h:44
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
Definition: texture.c:135
#define skip(...)
Definition: atltest.h:64
#define D3DX_FILTER_POINT
Definition: d3dx9tex.h:28

Referenced by START_TEST().

◆ test_D3DXCreateVolumeTextureFromFileInMemory()

static void test_D3DXCreateVolumeTextureFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 1797 of file texture.c.

1798 {
1799  HRESULT hr;
1800  ULONG ref;
1801  DWORD levelcount;
1802  IDirect3DVolumeTexture9 *volume_texture;
1803  D3DVOLUME_DESC volume_desc;
1804 
1806  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1807 
1809  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1810 
1812  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1813 
1815  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1816 
1819  ok(hr == D3D_OK, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1820  if (SUCCEEDED(hr))
1821  {
1822  levelcount = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
1823  ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
1824 
1825  hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &volume_desc);
1826  ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
1827  ok(volume_desc.Width == 4, "Got width %u, expected 4\n", volume_desc.Width);
1828  ok(volume_desc.Height == 4, "Got height %u, expected 4\n", volume_desc.Height);
1829  ok(volume_desc.Depth == 2, "Got depth %u, expected 2\n", volume_desc.Depth);
1830  ok(volume_desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected D3DPOOL_MANAGED\n", volume_desc.Pool);
1831 
1832  hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 1, &volume_desc);
1833  ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
1834  ok(volume_desc.Width == 2, "Got width %u, expected 2\n", volume_desc.Width);
1835  ok(volume_desc.Height == 2, "Got height %u, expected 2\n", volume_desc.Height);
1836  ok(volume_desc.Depth == 1, "Got depth %u, expected 1\n", volume_desc.Depth);
1837 
1838  ref = IDirect3DVolumeTexture9_Release(volume_texture);
1839  ok(ref == 0, "Invalid reference count. Got %u, expected 0\n", ref);
1840  }
1841 }
#define IDirect3DVolumeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1127
HRESULT hr
Definition: shlfolder.c:183
static const unsigned char dds_volume_map[]
Definition: texture.c:75
#define IDirect3DVolumeTexture9_GetLevelCount(p)
Definition: d3d9.h:1122
#define D3DERR_INVALIDCALL
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:1109
Definition: send.c:48
Definition: devices.h:37
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
#define todo_wine_if(is_todo)
Definition: test.h:163
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
static int has_3d_dxt3
Definition: texture.c:28
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *device, const void *data, UINT data_size, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1106
unsigned int ULONG
Definition: retypes.h:1
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXFillCubeTexture()

static void test_D3DXFillCubeTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1301 of file texture.c.

1302 {
1303  IDirect3DCubeTexture9 *tex;
1304  HRESULT hr;
1305  D3DLOCKED_RECT lock_rect;
1306  DWORD x, y, f, m;
1307  DWORD v[4], e[4];
1308  DWORD value, expected, size, pitch;
1309  enum cube_coord coordmap[6][3] =
1310  {
1311  {ONE, YCOORDINV, XCOORDINV},
1312  {ZERO, YCOORDINV, XCOORD},
1313  {XCOORD, ONE, YCOORD},
1314  {XCOORD, ZERO, YCOORDINV},
1315  {XCOORD, YCOORDINV, ONE},
1317  };
1318 
1319  size = 4;
1321  D3DPOOL_MANAGED, &tex, NULL);
1322 
1323  if (SUCCEEDED(hr))
1324  {
1326  ok(hr == D3D_OK, "D3DXFillCubeTexture returned %#x, expected %#x\n", hr, D3D_OK);
1327 
1328  for (m = 0; m < 3; m++)
1329  {
1330  for (f = 0; f < 6; f++)
1331  {
1332  hr = IDirect3DCubeTexture9_LockRect(tex, f, m, &lock_rect, NULL, D3DLOCK_READONLY);
1333  ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1334  if (SUCCEEDED(hr))
1335  {
1336  pitch = lock_rect.Pitch / sizeof(DWORD);
1337  for (y = 0; y < size; y++)
1338  {
1339  for (x = 0; x < size; x++)
1340  {
1341  value = ((DWORD *)lock_rect.pBits)[y * pitch + x];
1342  v[0] = (value >> 24) & 0xff;
1343  v[1] = (value >> 16) & 0xff;
1344  v[2] = (value >> 8) & 0xff;
1345  v[3] = value & 0xff;
1346 
1347  e[0] = (f == 0) || (f == 1) ?
1348  0 : (BYTE)(255.0f / size * 2.0f + 0.5f);
1349  e[1] = get_cube_coord(coordmap[f][0], x, y, size) / size * 255.0f + 0.5f;
1350  e[2] = get_cube_coord(coordmap[f][1], x, y, size) / size * 255.0f + 0.5f;
1351  e[3] = get_cube_coord(coordmap[f][2], x, y, size) / size * 255.0f + 0.5f;
1352  expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3];
1353 
1354  ok(color_match(v, e),
1355  "Texel at face %u (%u, %u) doesn't match: %#x, expected %#x\n",
1356  f, x, y, value, expected);
1357  }
1358  }
1360  }
1361  }
1362  size >>= 1;
1363  }
1364 
1366  }
1367  else
1368  skip("Failed to create texture\n");
1369 
1371  D3DPOOL_MANAGED, &tex, NULL);
1372 
1373  if (SUCCEEDED(hr))
1374  {
1376  ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1377  for (f = 0; f < 6; f++)
1378  {
1379  hr = IDirect3DCubeTexture9_LockRect(tex, f, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1380  ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1381  if (SUCCEEDED(hr))
1382  {
1383  pitch = lock_rect.Pitch / sizeof(WORD);
1384  for (y = 0; y < 4; y++)
1385  {
1386  for (x = 0; x < 4; x++)
1387  {
1388  value = ((WORD *)lock_rect.pBits)[y * pitch + x];
1389  v[0] = value >> 15;
1390  v[1] = value >> 10 & 0x1f;
1391  v[2] = value >> 5 & 0x1f;
1392  v[3] = value & 0x1f;
1393 
1394  e[0] = (f == 0) || (f == 1) ?
1395  0 : (BYTE)(1.0f / size * 2.0f + 0.5f);
1396  e[1] = get_cube_coord(coordmap[f][0], x, y, 4) / 4 * 31.0f + 0.5f;
1397  e[2] = get_cube_coord(coordmap[f][1], x, y, 4) / 4 * 31.0f + 0.5f;
1398  e[3] = get_cube_coord(coordmap[f][2], x, y, 4) / 4 * 31.0f + 0.5f;
1399  expected = e[0] << 15 | e[1] << 10 | e[2] << 5 | e[3];
1400 
1401  ok(color_match(v, e),
1402  "Texel at face %u (%u, %u) doesn't match: %#x, expected %#x\n",
1403  f, x, y, value, expected);
1404  }
1405  }
1407  }
1408  }
1409 
1411  }
1412  else
1413  skip("Failed to create texture\n");
1414 }
HRESULT hr
Definition: shlfolder.c:183
Definition: texture.c:1677
static BOOL color_match(const DWORD *value, const DWORD *expected)
Definition: texture.c:997
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:919
Definition: texture.c:1676
#define DWORD
Definition: nt_native.h:44
const GLfloat * m
Definition: glext.h:10848
#define IDirect3DCubeTexture9_LockRect(p, a, b, c, d, e)
Definition: d3d9.h:939
Definition: devices.h:37
#define e
Definition: ke_i.h:82
smooth NULL
Definition: ftsmooth.c:416
cube_coord
Definition: texture.c:1670
GLfloat f
Definition: glext.h:7540
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei const GLfloat * value
Definition: glext.h:6069
unsigned char BYTE
Definition: xxhash.c:193
#define D3D_OK
Definition: d3d.h:106
const GLdouble * v
Definition: gl.h:2040
#define f
Definition: ke_i.h:83
#define ok(value,...)
Definition: atltest.h:57
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static float get_cube_coord(enum cube_coord coord, unsigned int x, unsigned int y, unsigned int size)
Definition: texture.c:1279
#define IDirect3DCubeTexture9_UnlockRect(p, a, b)
Definition: d3d9.h:940
#define skip(...)
Definition: atltest.h:64
static void WINAPI fillfunc_cube(D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
Definition: texture.c:1260
HRESULT WINAPI D3DXFillCubeTexture(struct IDirect3DCubeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
Definition: texture.c:1702
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define IDirect3DDevice9_CreateCubeTexture(p, a, b, c, d, e, f, g)
Definition: d3d9.h:1532
BOOL expected
Definition: store.c:2063
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXFillTexture()

static void test_D3DXFillTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1018 of file texture.c.

1019 {
1020  static const struct
1021  {
1022  DWORD usage;
1023  D3DPOOL pool;
1024  }
1025  test_access_types[] =
1026  {
1027  {0, D3DPOOL_MANAGED},
1028  {0, D3DPOOL_DEFAULT},
1030  };
1031 
1032  IDirect3DTexture9 *tex;
1033  HRESULT hr;
1034  D3DLOCKED_RECT lock_rect;
1035  DWORD x, y, m;
1036  DWORD v[4], e[4];
1037  DWORD value, expected, size, pitch;
1038  unsigned int i;
1039 
1040  for (i = 0; i < ARRAY_SIZE(test_access_types); ++i)
1041  {
1042  size = 4;
1043  hr = IDirect3DDevice9_CreateTexture(device, size, size, 0, test_access_types[i].usage,
1044  D3DFMT_A8R8G8B8, test_access_types[i].pool, &tex, NULL);
1045  ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i);
1046 
1047  hr = D3DXFillTexture(tex, fillfunc, NULL);
1048  ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i);
1049 
1050  for (m = 0; m < 3; m++)
1051  {
1052  IDirect3DSurface9 *src_surface, *temp_surface;
1053 
1054  hr = IDirect3DTexture9_GetSurfaceLevel(tex, m, &src_surface);
1055  ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m);
1056  temp_surface = src_surface;
1057 
1058  if (FAILED(hr = IDirect3DSurface9_LockRect(src_surface, &lock_rect, NULL, D3DLOCK_READONLY)))
1059  {
1061  D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &temp_surface, NULL);
1062  ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m);
1063  hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL, temp_surface, NULL, D3DTEXF_NONE);
1064  ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m);
1065  hr = IDirect3DSurface9_LockRect(temp_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1066  ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m);
1067  }
1068 
1069  pitch = lock_rect.Pitch / sizeof(DWORD);
1070  for (y = 0; y < size; y++)
1071  {
1072  for (x = 0; x < size; x++)
1073  {
1074  value = ((DWORD *)lock_rect.pBits)[y * pitch + x];
1075  v[0] = (value >> 24) & 0xff;
1076  v[1] = (value >> 16) & 0xff;
1077  v[2] = (value >> 8) & 0xff;
1078  v[3] = value & 0xff;
1079 
1080  e[0] = 0xff;
1081  e[1] = (x + 0.5f) / size * 255.0f + 0.5f;
1082  e[2] = (y + 0.5f) / size * 255.0f + 0.5f;
1083  e[3] = 255.0f / size + 0.5f;
1084  expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3];
1085 
1086  ok(color_match(v, e),
1087  "Texel at (%u, %u) doesn't match: %#x, expected %#x, i %u, m %u.\n",
1088  x, y, value, expected, i, m);
1089  }
1090  }
1091  IDirect3DSurface9_UnlockRect(temp_surface);
1092  if (temp_surface != src_surface)
1093  IDirect3DSurface9_Release(temp_surface);
1094  IDirect3DSurface9_Release(src_surface);
1095  size >>= 1;
1096  }
1098  }
1099 
1102  if (hr == D3D_OK)
1103  {
1104  hr = D3DXFillTexture(tex, fillfunc, NULL);
1105  todo_wine ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
1107  }
1108 
1110  D3DFMT_D16, D3DPOOL_DEFAULT, &tex, NULL);
1111  if (hr == D3D_OK)
1112  {
1113  hr = D3DXFillTexture(tex, fillfunc, NULL);
1114  ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
1116  }
1117 
1119  D3DPOOL_MANAGED, &tex, NULL);
1120 
1121  if (SUCCEEDED(hr))
1122  {
1123  hr = D3DXFillTexture(tex, fillfunc, NULL);
1124  ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1125 
1126  hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1127  ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1128  if (SUCCEEDED(hr))
1129  {
1130  pitch = lock_rect.Pitch / sizeof(WORD);
1131  for (y = 0; y < 4; y++)
1132  {
1133  for (x = 0; x < 4; x++)
1134  {
1135  value = ((WORD *)lock_rect.pBits)[y * pitch + x];
1136  v[0] = value >> 15;
1137  v[1] = value >> 10 & 0x1f;
1138  v[2] = value >> 5 & 0x1f;
1139  v[3] = value & 0x1f;
1140 
1141  e[0] = 1;
1142  e[1] = (x + 0.5f) / 4.0f * 31.0f + 0.5f;
1143  e[2] = (y + 0.5f) / 4.0f * 31.0f + 0.5f;
1144  e[3] = 8;
1145  expected = e[0] << 15 | e[1] << 10 | e[2] << 5 | e[3];
1146 
1147  ok(color_match(v, e),
1148  "Texel at (%u, %u) doesn't match: %#x, expected %#x\n",
1149  x, y, value, expected);
1150  }
1151  }
1153  }
1154 
1156  }
1157  else
1158  skip("Failed to create texture\n");
1159 
1160  /* test floating-point textures */
1162  D3DPOOL_MANAGED, &tex, NULL);
1163 
1164  if (SUCCEEDED(hr))
1165  {
1166  hr = D3DXFillTexture(tex, fillfunc, NULL);
1167  ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1168 
1169  hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1170  if (SUCCEEDED(hr))
1171  {
1172  pitch = lock_rect.Pitch / sizeof(WORD);
1173  for (y = 0; y < 4; y++)
1174  {
1175  WORD *ptr = (WORD *)lock_rect.pBits + y * pitch;
1176  for (x = 0; x < 4; x++)
1177  {
1178  D3DXVECTOR4 got, expected;
1179 
1180  D3DXFloat16To32Array((FLOAT *)&got, (D3DXFLOAT16 *)ptr, 4);
1181  ptr += 4;
1182 
1183  expected.x = (x + 0.5f) / 4.0f;
1184  expected.y = (y + 0.5f) / 4.0f;
1185  expected.z = 1.0f / 4.0f;
1186  expected.w = 1.0f;
1187 
1188  expect_vec4(&expected, &got);
1189  }
1190  }
1191 
1193  }
1194  else
1195  skip("Failed to lock texture\n");
1196 
1198  }
1199  else
1200  skip("Failed to create D3DFMT_A16B16G16R16F texture\n");
1201 
1203  D3DPOOL_MANAGED, &tex, NULL);
1204 
1205  if (SUCCEEDED(hr))
1206  {
1207  hr = D3DXFillTexture(tex, fillfunc, NULL);
1208  ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1209 
1210  hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1211  if (SUCCEEDED(hr))
1212  {
1213  pitch = lock_rect.Pitch / sizeof(float);
1214  for (y = 0; y < 4; y++)
1215  {
1216  float *ptr = (float *)lock_rect.pBits + y * pitch;
1217  for (x = 0; x < 4; x++)
1218  {
1219  D3DXVECTOR4 got, expected;
1220 
1221  got.x = *ptr++;
1222  got.y = *ptr++;
1223  got.z = *ptr++;
1224  got.w = *ptr++;
1225 
1226  expected.x = (x + 0.5f) / 4.0f;
1227  expected.y = (y + 0.5f) / 4.0f;
1228  expected.z = 1.0f / 4.0f;
1229  expected.w = 1.0f;
1230 
1231  expect_vec4(&expected, &got);
1232  }
1233  }
1234 
1236  }
1237  else
1238  skip("Failed to lock texture\n");
1239 
1241  }
1242  else
1243  skip("Failed to create D3DFMT_A32B32G32R32F texture\n");
1244 
1245  /* test a compressed texture */
1247  D3DPOOL_MANAGED, &tex, NULL);
1248 
1249  if (SUCCEEDED(hr))
1250  {
1251  hr = D3DXFillTexture(tex, fillfunc, NULL);
1252  todo_wine ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1253 
1255  }
1256  else
1257  skip("Failed to create D3DFMT_DXT1 texture\n");
1258 }
#define IDirect3DTexture9_UnlockRect(p, a)
Definition: d3d9.h:1035
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:1033
static BOOL color_match(const DWORD *value, const DWORD *expected)
Definition: texture.c:997
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
enum _D3DPOOL D3DPOOL
#define D3DERR_INVALIDCALL
FLOAT *WINAPI D3DXFloat16To32Array(FLOAT *pout, const D3DXFLOAT16 *pin, UINT n)
Definition: math.c:2217
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define IDirect3DDevice9_CreateRenderTarget(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1535
#define DWORD
Definition: nt_native.h:44
const GLfloat * m
Definition: glext.h:10848
#define D3DUSAGE_DEPTHSTENCIL
Definition: d3d8types.h:92
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
Definition: devices.h:37
#define e
Definition: ke_i.h:82
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
GLfloat f
Definition: glext.h:7540
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
#define D3DUSAGE_RENDERTARGET
Definition: d3d8types.h:91
unsigned short WORD
Definition: ntddk_ex.h:93
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
#define todo_wine
Definition: test.h:162
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLsizei const GLfloat * value
Definition: glext.h:6069
#define D3D_OK
Definition: d3d.h:106
const GLdouble * v
Definition: gl.h:2040
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1530
static float(__cdecl *square_half_float)(float x
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define expect_vec4(expected, got)
Definition: texture.c:107
#define IDirect3DSurface9_UnlockRect(p)
Definition: d3d9.h:636
#define skip(...)
Definition: atltest.h:64
float FLOAT
Definition: typedefs.h:69
#define IDirect3DTexture9_LockRect(p, a, b, c, d)
Definition: d3d9.h:1034
#define IDirect3DSurface9_LockRect(p, a, b, c)
Definition: d3d9.h:635
static void WINAPI fillfunc(D3DXVECTOR4 *value, const D3DXVECTOR2 *texcoord, const D3DXVECTOR2 *texelsize, void *data)
Definition: texture.c:1009
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define IDirect3DDevice9_StretchRect(p, a, b, c, d, e)
Definition: d3d9.h:1541
BOOL expected
Definition: store.c:2063
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT WINAPI D3DXFillTexture(struct IDirect3DTexture9 *texture, LPD3DXFILL2D function, void *funcdata)
Definition: texture.c:1324

Referenced by START_TEST().

◆ test_D3DXFillVolumeTexture()

static void test_D3DXFillVolumeTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1425 of file texture.c.

1426 {
1427  IDirect3DVolumeTexture9 *tex;
1428  HRESULT hr;
1429  D3DLOCKED_BOX lock_box;
1430  DWORD x, y, z, m;
1431  DWORD v[4], e[4];
1432  DWORD value, expected, size, row_pitch, slice_pitch;
1433 
1434  size = 4;
1436  D3DPOOL_DEFAULT, &tex, NULL);
1437  ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
1439  ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
1441 
1443  D3DPOOL_MANAGED, &tex, NULL);
1444  if (SUCCEEDED(hr))
1445  {
1447  ok(hr == D3D_OK, "D3DXFillVolumeTexture returned %#x, expected %#x\n", hr, D3D_OK);
1448 
1449  for (m = 0; m < 3; m++)
1450  {
1452  ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1453  if (SUCCEEDED(hr))
1454  {
1455  row_pitch = lock_box.RowPitch / sizeof(DWORD);
1456  slice_pitch = lock_box.SlicePitch / sizeof(DWORD);
1457  for (z = 0; z < size; z++)
1458  {
1459  for (y = 0; y < size; y++)
1460  {
1461  for (x = 0; x < size; x++)
1462  {
1463  value = ((DWORD *)lock_box.pBits)[z * slice_pitch + y * row_pitch + x];
1464  v[0] = (value >> 24) & 0xff;
1465  v[1] = (value >> 16) & 0xff;
1466  v[2] = (value >> 8) & 0xff;
1467  v[3] = value & 0xff;
1468 
1469  e[0] = 255.0f / size + 0.5f;
1470  e[1] = (x + 0.5f) / size * 255.0f + 0.5f;
1471  e[2] = (y + 0.5f) / size * 255.0f + 0.5f;
1472  e[3] = (z + 0.5f) / size * 255.0f + 0.5f;
1473  expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3];
1474 
1475  ok(color_match(v, e),
1476  "Texel at (%u, %u, %u) doesn't match: %#x, expected %#x\n",
1477  x, y, z, value, expected);
1478  }
1479  }
1480  }
1482  }
1483  size >>= 1;
1484  }
1485 
1487  }
1488  else
1489  skip("Failed to create texture\n");
1490 
1492  D3DPOOL_MANAGED, &tex, NULL);
1493 
1494  if (SUCCEEDED(hr))
1495  {
1497  ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1499  ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1500  if (SUCCEEDED(hr))
1501  {
1502  row_pitch = lock_box.RowPitch / sizeof(WORD);
1503  slice_pitch = lock_box.SlicePitch / sizeof(WORD);
1504  for (z = 0; z < 4; z++)
1505  {
1506  for (y = 0; y < 4; y++)
1507  {
1508  for (x = 0; x < 4; x++)
1509  {
1510  value = ((WORD *)lock_box.pBits)[z * slice_pitch + y * row_pitch + x];
1511  v[0] = value >> 15;
1512  v[1] = value >> 10 & 0x1f;
1513  v[2] = value >> 5 & 0x1f;
1514  v[3] = value & 0x1f;
1515 
1516  e[0] = 1;
1517  e[1] = (x + 0.5f) / 4 * 31.0f + 0.5f;
1518  e[2] = (y + 0.5f) / 4 * 31.0f + 0.5f;
1519  e[3] = (z + 0.5f) / 4 * 31.0f + 0.5f;
1520  expected = e[0] << 15 | e[1] << 10 | e[2] << 5 | e[3];
1521 
1522  ok(color_match(v, e),
1523  "Texel at (%u, %u, %u) doesn't match: %#x, expected %#x\n",
1524  x, y, z, value, expected);
1525  }
1526  }
1527  }
1529  }
1530 
1532  }
1533  else
1534  skip("Failed to create texture\n");
1535 }
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1531
HRESULT hr
Definition: shlfolder.c:183
static BOOL color_match(const DWORD *value, const DWORD *expected)
Definition: texture.c:997
#define D3DERR_INVALIDCALL
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:1109
static void WINAPI fillfunc_volume(D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
Definition: texture.c:1416
#define DWORD
Definition: nt_native.h:44
const GLfloat * m
Definition: glext.h:10848
#define IDirect3DVolumeTexture9_UnlockBox(p, a)
Definition: d3d9.h:1130
Definition: devices.h:37
#define e
Definition: ke_i.h:82
GLdouble GLdouble z
Definition: glext.h:5874
smooth NULL
Definition: ftsmooth.c:416
GLfloat f
Definition: glext.h:7540
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei const GLfloat * value
Definition: glext.h:6069
#define IDirect3DVolumeTexture9_LockBox(p, a, b, c, d)
Definition: d3d9.h:1129
#define D3D_OK
Definition: d3d.h:106
const GLdouble * v
Definition: gl.h:2040
#define ok(value,...)
Definition: atltest.h:57
HRESULT WINAPI D3DXFillVolumeTexture(struct IDirect3DVolumeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
Definition: texture.c:1776
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define skip(...)
Definition: atltest.h:64
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
BOOL expected
Definition: store.c:2063
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXFilterTexture()

static void test_D3DXFilterTexture ( IDirect3DDevice9 *  device)
static

Definition at line 851 of file texture.c.

852 {
853  IDirect3DTexture9 *tex;
854  IDirect3DCubeTexture9 *cubetex;
855  IDirect3DVolumeTexture9 *voltex;
856  HRESULT hr;
857 
859 
860  if (SUCCEEDED(hr))
861  {
862  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, D3DX_DEFAULT, D3DX_FILTER_NONE);
863  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
864 
865  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
866  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
867 
868  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_BOX + 1); /* Invalid filter */
869  ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
870 
871  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 5, D3DX_FILTER_NONE); /* Invalid miplevel */
872  ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
873 
875  }
876  else
877  skip("Failed to create texture\n");
878 
880  ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
881 
882  /* Test different pools */
884 
885  if (SUCCEEDED(hr))
886  {
887  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
888  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
890  }
891  else
892  skip("Failed to create texture\n");
893 
895 
896  if (SUCCEEDED(hr))
897  {
898  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
899  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
901  }
902  else
903  skip("Failed to create texture\n");
904 
906  if (SUCCEEDED(hr))
907  {
908  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_POINT);
909  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
911  }
912  else
913  skip("Failed to create texture\n");
914 
916  if (SUCCEEDED(hr))
917  {
918  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_POINT);
919  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
921  }
922  else
923  skip("Failed to create texture\n");
924 
925  /* Cube texture test */
927 
928  if (SUCCEEDED(hr))
929  {
930  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 0, D3DX_FILTER_NONE);
931  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
932 
933  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 0, D3DX_FILTER_BOX + 1); /* Invalid filter */
934  ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
935 
936  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 5, D3DX_FILTER_NONE); /* Invalid miplevel */
937  ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
939  }
940  else
941  skip("Failed to create texture\n");
942 
943  /* Volume texture test */
945  if (SUCCEEDED(hr))
946  {
947  DWORD level_count = IDirect3DVolumeTexture9_GetLevelCount(voltex);
948 
949  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_NONE);
950  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
951 
952  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_DEFAULT);
953  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
954 
955  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_BOX);
956  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
957 
958  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count - 1, D3DX_DEFAULT);
959  ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
960 
961  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count, D3DX_DEFAULT);
962  ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
963 
965  }
966  else
967  skip("Failed to create volume texture\n");
968 
969  /* Test textures with D3DUSAGE_AUTOGENMIPMAP usage */
971  {
972  skip("No D3DUSAGE_AUTOGENMIPMAP supported for textures\n");
973  return;
974  }
975 
977  if (SUCCEEDED(hr))
978  {
979  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
980  ok(hr == D3D_OK, "D3dXFilteTexture returned %#x, expected %#x\n", hr, D3D_OK);
982  }
983  else
984  skip("Failed to create texture\n");
985 
987  if (SUCCEEDED(hr))
988  {
989  hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
990  ok(hr == D3D_OK, "D3dXFilteTexture returned %#x, expected %#x\n", hr, D3D_OK);
992  }
993  else
994  skip("Failed to create texture\n");
995 }
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1531
HRESULT hr
Definition: shlfolder.c:183
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define IDirect3DVolumeTexture9_GetLevelCount(p)
Definition: d3d9.h:1122
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
#define D3DX_FILTER_NONE
Definition: d3dx9tex.h:27
#define D3DERR_INVALIDCALL
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:1109
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:919
Definition: devices.h:37
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DX_FILTER_BOX
Definition: d3dx9tex.h:31
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
Definition: texture.c:65
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1530
#define ok(value,...)
Definition: atltest.h:57
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
Definition: texture.c:135
#define skip(...)
Definition: atltest.h:64
#define D3DX_FILTER_POINT
Definition: d3dx9tex.h:28
#define IDirect3DDevice9_CreateCubeTexture(p, a, b, c, d, e, f, g)
Definition: d3d9.h:1532
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_D3DXSaveTextureToFileInMemory()

static void test_D3DXSaveTextureToFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 1851 of file texture.c.

1852 {
1853  HRESULT hr;
1854  IDirect3DTexture9 *texture;
1855  IDirect3DCubeTexture9 *cube_texture;
1856  IDirect3DVolumeTexture9 *volume_texture;
1858  void *buffer_pointer;
1861  D3DXIMAGE_FILEFORMAT file_format;
1862 
1863  /* textures */
1865  if (FAILED(hr))
1866  {
1867  skip("Failed to create texture\n");
1868  return;
1869  }
1870 
1871  for (file_format = D3DXIFF_BMP; file_format <= D3DXIFF_JPG; file_format++)
1872  {
1873  hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, (IDirect3DBaseTexture9 *)texture, NULL);
1874  ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1875  if (SUCCEEDED(hr))
1876  {
1877  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
1879  hr = D3DXGetImageInfoFromFileInMemory(buffer_pointer, buffer_size, &info);
1880  ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1881 
1882  ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
1883  ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
1884  ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
1885  ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
1886  ok(info.ImageFileFormat == file_format, "Got file format %#x, expected %#x\n", info.ImageFileFormat, file_format);
1888  }
1889  }
1890 
1891  todo_wine {
1892  hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)texture, NULL);
1893  ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1894  if (SUCCEEDED(hr))
1895  {
1896  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
1898  hr = D3DXGetImageInfoFromFileInMemory(buffer_pointer, buffer_size, &info);
1899  ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1900 
1901  ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
1902  ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
1903  ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
1904  ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
1905  ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
1907  }
1908  }
1909 
1911 
1912  /* cube textures */
1914  if (FAILED(hr))
1915  {
1916  skip("Failed to create cube texture\n");
1917  return;
1918  }
1919 
1920  hr = D3DXFillCubeTexture(cube_texture, fill_cube_positive_x, NULL);
1921  ok(hr == D3D_OK, "D3DXFillCubeTexture returned %#x, expected %#x\n", hr, D3D_OK);
1922 
1923  hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_BMP, (IDirect3DBaseTexture9 *)cube_texture, NULL);
1924  ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1925  if (SUCCEEDED(hr))
1926  {
1927  IDirect3DSurface9 *surface;
1928 
1929  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
1931  hr = D3DXGetImageInfoFromFileInMemory(buffer_pointer, buffer_size, &info);
1932  ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1933 
1934  ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
1935  ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
1936  ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
1937  ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
1938  ok(info.ImageFileFormat == D3DXIFF_BMP, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_BMP);
1939 
1940  /* positive x face is saved */
1942  if (SUCCEEDED(hr))
1943  {
1944  D3DLOCKED_RECT locked_rect;
1945 
1946  hr = D3DXLoadSurfaceFromFileInMemory(surface, NULL, NULL, buffer_pointer, buffer_size, NULL, D3DX_FILTER_NONE, 0, NULL);
1947  ok(hr == D3D_OK, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1948 
1949  hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, D3DLOCK_READONLY);
1950  if (SUCCEEDED(hr))
1951  {
1952  DWORD *color = locked_rect.pBits;
1953  ok(*color == 0x00ff0000, "Got color %#x, expected %#x\n", *color, 0x00ff0000);
1955  }
1956 
1957  IDirect3DSurface9_Release(surface);
1958  } else skip("Failed to create surface\n");
1959 
1961  }
1962 
1963  todo_wine {
1964  hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)cube_texture, NULL);
1965  ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1966  if (SUCCEEDED(hr))
1967  {
1968  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
1970  hr = D3DXGetImageInfoFromFileInMemory(buffer_pointer, buffer_size, &info);
1971  ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1972 
1973  ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
1974  ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
1975  ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
1976  ok(info.ResourceType == D3DRTYPE_CUBETEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_CUBETEXTURE);
1977  ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
1979  }
1980  }
1981 
1982  IDirect3DCubeTexture9_Release(cube_texture);
1983 
1984  /* volume textures */
1985  hr = IDirect3DDevice9_CreateVolumeTexture(device, 256, 256, 256, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &volume_texture, NULL);
1986  if (FAILED(hr))
1987  {
1988  skip("Failed to create volume texture\n");
1989  return;
1990  }
1991 
1992  todo_wine {
1993  hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_BMP, (IDirect3DBaseTexture9 *)volume_texture, NULL);
1994  ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1995  if (SUCCEEDED(hr))
1996  {
1997  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
1999  hr = D3DXGetImageInfoFromFileInMemory(buffer_pointer, buffer_size, &info);
2000  ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2001 
2002  ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
2003  ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
2004  ok(info.Depth == 1, "Got depth %u, expected %u\n", info.Depth, 1);
2005  ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
2006  ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
2007  ok(info.ImageFileFormat == D3DXIFF_BMP, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_BMP);
2009  }
2010 
2011  hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)volume_texture, NULL);
2012  ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2013  if (SUCCEEDED(hr))
2014  {
2015  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
2017  hr = D3DXGetImageInfoFromFileInMemory(buffer_pointer, buffer_size, &info);
2018  ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2019 
2020  ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
2021  ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
2022  ok(info.Depth == 256, "Got depth %u, expected %u\n", info.Depth, 256);
2023  ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
2024  ok(info.ResourceType == D3DRTYPE_VOLUMETEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_VOLUMETEXTURE);
2025  ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
2027  }
2028  }
2029 
2030  IDirect3DVolumeTexture9_Release(volume_texture);
2031 }
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1531
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
#define D3DX_FILTER_NONE
Definition: d3dx9tex.h:27
GLuint buffer
Definition: glext.h:5915
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:1109
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:919
enum _D3DXIMAGE_FILEFORMAT D3DXIMAGE_FILEFORMAT
struct _test_info info[]
Definition: SetCursorPos.c:19
#define IDirect3DDevice9_CreateOffscreenPlainSurface(p, a, b, c, d, e, f)
Definition: d3d9.h:1543
GLuint color
Definition: glext.h:6243
Definition: devices.h:37
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
smooth NULL<