ReactOS 0.4.15-dev-7918-g2a2556c
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_uint (unsigned int x, unsigned int y, unsigned int max_diff)
 
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 test_D3DXCreateVolumeTextureFromFileInMemoryEx (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_dxt1
 
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 BYTE dds_dxt5 []
 
static const BYTE dds_dxt5_8_8 []
 
static const unsigned char png_grayscale []
 

Macro Definition Documentation

◆ ADMITTED_ERROR

#define ADMITTED_ERROR   0.0001f

Definition at line 130 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 137 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 1333 of file texture.c.

1334{
1335 XCOORD = 0,
1336 XCOORDINV = 1,
1337 YCOORD = 2,
1338 YCOORDINV = 3,
1339 ZERO = 4,
1340 ONE = 5
1341};
@ XCOORDINV
Definition: texture.c:1666
@ ONE
Definition: texture.c:1670
@ YCOORDINV
Definition: texture.c:1668
@ XCOORD
Definition: texture.c:1665
@ ZERO
Definition: texture.c:1669
@ YCOORD
Definition: texture.c:1667

Function Documentation

◆ color_match()

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

Definition at line 1061 of file texture.c.

1062{
1063 int i;
1064
1065 for (i = 0; i < 4; i++)
1066 {
1067 DWORD diff = value[i] > expected[i] ? value[i] - expected[i] : expected[i] - value[i];
1068 if (diff > 1) return FALSE;
1069 }
1070 return TRUE;
1071}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
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
BOOL expected
Definition: store.c:2063
Definition: pdh_main.c:94

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 156 of file texture.c.

157{
158 return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
159 && compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff)
160 && compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff)
161 && compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff);
162}
static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
Definition: texture.c:149

Referenced by test_D3DXCreateTextureFromFileInMemory(), and test_texture_shader().

◆ compare_uint()

static BOOL compare_uint ( unsigned int  x,
unsigned int  y,
unsigned int  max_diff 
)
static

Definition at line 149 of file texture.c.

150{
151 unsigned int diff = x > y ? x - y : y - x;
152
153 return diff <= max_diff;
154}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by compare_color().

◆ expect_vec4_()

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

Definition at line 138 of file texture.c.

139{
140 ok_(__FILE__, line)(relative_error(expected->x, got->x) < ADMITTED_ERROR
144 "Expected (%f, %f, %f, %f), got (%f, %f, %f, %f)\n",
145 expected->x, expected->y, expected->z, expected->w,
146 got->x, got->y, got->z, got->w);
147}
#define ok_(x1, x2)
Definition: atltest.h:61
#define relative_error(exp, out)
Definition: line.c:24
#define ADMITTED_ERROR
Definition: texture.c:130
Definition: parser.c:49

◆ 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 2144 of file texture.c.

2145{
2146 memset(out, 0, sizeof(*out));
2147 if (tex_coord->x > 0 && fabs(tex_coord->x) > fabs(tex_coord->y) && fabs(tex_coord->x) > fabs(tex_coord->z))
2148 out->x = 1;
2149}
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Definition: fabs.c:17
static FILE * out
Definition: regtests2xml.c:44
#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 1073 of file texture.c.

1075{
1076 value->x = texcoord->x;
1077 value->y = texcoord->y;
1078 value->z = texelsize->x;
1079 value->w = 1.0f;
1080}
FLOAT x
Definition: d3dx9math.h:64
FLOAT y
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 1324 of file texture.c.

1326{
1327 value->x = (texcoord->x + 1.0f) / 2.0f;
1328 value->y = (texcoord->y + 1.0f) / 2.0f;
1329 value->z = (texcoord->z + 1.0f) / 2.0f;
1330 value->w = texelsize->x;
1331}

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 1480 of file texture.c.

1482{
1483 value->x = texcoord->x;
1484 value->y = texcoord->y;
1485 value->z = texcoord->z;
1486 value->w = texelsize->x;
1487}

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 1343 of file texture.c.

1344{
1345 switch (coord)
1346 {
1347 case XCOORD:
1348 return x + 0.5f;
1349 case XCOORDINV:
1350 return size - x - 0.5f;
1351 case YCOORD:
1352 return y + 0.5f;
1353 case YCOORDINV:
1354 return size - y - 0.5f;
1355 case ZERO:
1356 return 0.0f;
1357 case ONE:
1358 return size;
1359 default:
1360 trace("Unexpected coordinate value\n");
1361 return 0.0f;
1362 }
1363}
#define trace
Definition: atltest.h:70
GLsizeiptr size
Definition: glext.h:5919
GLuint coord
Definition: glext.h:9511

◆ is_autogenmipmap_supported()

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

Definition at line 164 of file texture.c.

165{
166 HRESULT hr;
167 D3DCAPS9 caps;
168 IDirect3D9 *d3d9;
171
176
177 if (!(caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP))
178 return FALSE;
179
180 hr = IDirect3D9_CheckDeviceFormat(d3d9, params.AdapterOrdinal, params.DeviceType,
181 mode.Format, D3DUSAGE_AUTOGENMIPMAP, resource_type, D3DFMT_A8R8G8B8);
182
184 return hr == D3D_OK;
185}
@ D3DFMT_A8R8G8B8
Definition: d3d8types.h:604
#define IDirect3DDevice9_GetDirect3D(p, a)
Definition: d3d9.h:1513
#define IDirect3DDevice9_GetCreationParameters(p, a)
Definition: d3d9.h:1516
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
#define IDirect3D9_CheckDeviceFormat(p, a, b, c, d, e, f)
Definition: d3d9.h:229
#define IDirect3DDevice9_GetDisplayMode(p, a, b)
Definition: d3d9.h:1515
#define D3DCAPS2_CANAUTOGENMIPMAP
Definition: d3d9caps.h:22
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define D3D_OK
Definition: d3d.h:106
GLenum mode
Definition: glext.h:6217
GLenum const GLfloat * params
Definition: glext.h:5645
HRESULT hr
Definition: shlfolder.c:183
DWORD Caps2
Definition: d3d9caps.h:267
Definition: devices.h:37

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 132 of file texture.c.

133{
134 return expected == 0.0f ? fabs(expected - got) : fabs(1.0f - got / expected);
135}

◆ START_TEST()

START_TEST ( texture  )

Definition at line 2557 of file texture.c.

2558{
2559 HWND wnd;
2560 IDirect3D9 *d3d;
2561 IDirect3DDevice9 *device;
2563 HRESULT hr;
2564 ULONG ref;
2565
2566 if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
2567 640, 480, NULL, NULL, NULL, NULL)))
2568 {
2569 skip("Couldn't create application window\n");
2570 return;
2571 }
2573 if (!d3d) {
2574 skip("Couldn't create IDirect3D9 object\n");
2575 DestroyWindow(wnd);
2576 return;
2577 }
2578
2579 ZeroMemory(&d3dpp, sizeof(d3dpp));
2580 d3dpp.Windowed = TRUE;
2583 if (FAILED(hr)) {
2584 skip("Failed to create IDirect3DDevice9 object %#x\n", hr);
2585 IDirect3D9_Release(d3d);
2586 DestroyWindow(wnd);
2587 return;
2588 }
2589
2590 /* Check whether DXTn textures are supported. */
2601 trace("DXTn texture support: 2D DXT1 %#x, 2D DXT3 %#x, 2D DXT5 %#x, cube DXT5 %#x, 3D dxt3 %#x.\n",
2603
2619
2621 ok(!ref, "Device has %u references left.\n", ref);
2622
2623 IDirect3D9_Release(d3d);
2624 DestroyWindow(wnd);
2625
2627}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
@ D3DFMT_DXT5
Definition: d3d8types.h:638
@ D3DFMT_DXT1
Definition: d3d8types.h:634
@ D3DFMT_DXT3
Definition: d3d8types.h:636
@ D3DFMT_X8R8G8B8
Definition: d3d8types.h:605
@ D3DRTYPE_TEXTURE
Definition: d3d8types.h:812
@ D3DRTYPE_VOLUMETEXTURE
Definition: d3d8types.h:813
@ D3DRTYPE_CUBETEXTURE
Definition: d3d8types.h:814
@ D3DSWAPEFFECT_DISCARD
Definition: d3d8types.h:851
@ D3DDEVTYPE_HAL
Definition: d3d8types.h:576
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
#define NULL
Definition: types.h:112
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static void test_D3DXSaveTextureToFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:2151
static int has_2d_dxt5
Definition: texture.c:28
static void test_D3DXCheckCubeTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:486
static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:2025
static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:187
static int has_3d_dxt3
Definition: texture.c:28
static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:2085
static void test_D3DXCreateTexture(IDirect3DDevice9 *device)
Definition: texture.c:708
static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
Definition: texture.c:2127
static int has_cube_dxt5
Definition: texture.c:28
static void test_D3DXFilterTexture(IDirect3DDevice9 *device)
Definition: texture.c:915
static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
Definition: texture.c:1897
static void test_D3DXCheckVolumeTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:587
static void test_texture_shader(void)
Definition: texture.c:2333
static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:1601
static int has_2d_dxt3
Definition: texture.c:28
static int has_2d_dxt1
Definition: texture.c:28
static void test_D3DXFillCubeTexture(IDirect3DDevice9 *device)
Definition: texture.c:1365
static void test_D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
Definition: texture.c:2061
static void test_D3DXFillVolumeTexture(IDirect3DDevice9 *device)
Definition: texture.c:1489
static void test_D3DXFillTexture(IDirect3DDevice9 *device)
Definition: texture.c:1082
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
#define D3D_SDK_VERSION
Definition: d3d8.h:56
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING
Definition: d3d8.h:44
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
#define ZeroMemory
Definition: winbase.h:1712
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ test_D3DXCheckCubeTextureRequirements()

static void test_D3DXCheckCubeTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 486 of file texture.c.

487{
488 UINT size, mipmaps, expected;
490 D3DCAPS9 caps;
491 HRESULT hr;
492
494
496 {
497 skip("No cube textures support\n");
498 return;
499 }
500
501 /* general tests */
503 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
504
506 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
507
509 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
510
511 /* size */
514 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
515 ok(size == 256, "Returned size %d, expected %d\n", size, 256);
516
517 /* mipmaps */
518 size = 64;
519 mipmaps = 9;
521 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
522 ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
523
524 size = 284;
525 mipmaps = 20;
529 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
530 ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
531
532 size = 63;
533 mipmaps = 9;
537 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
538 ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
539
540 mipmaps = 0;
542 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
543 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
544
546 {
547 mipmaps = 3;
549 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
550 ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
551 }
552 else
553 skip("No D3DUSAGE_AUTOGENMIPMAP support for cube textures\n");
554
555 /* usage */
557 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
559 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
561 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
563 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
565 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
566
567 /* format */
569 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
570
573 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
574 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
575
578 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
579 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
580
583 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
584 ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
585}
#define D3DPTEXTURECAPS_CUBEMAP_POW2
Definition: d3d8caps.h:126
#define D3DPTEXTURECAPS_CUBEMAP
Definition: d3d8caps.h:121
#define D3DPTEXTURECAPS_MIPCUBEMAP
Definition: d3d8caps.h:125
#define D3DUSAGE_NPATCHES
Definition: d3d8types.h:98
#define D3DUSAGE_POINTS
Definition: d3d8types.h:96
#define D3DUSAGE_DONOTCLIP
Definition: d3d8types.h:95
@ D3DFMT_R8G8B8
Definition: d3d8types.h:603
@ D3DFMT_UNKNOWN
Definition: d3d8types.h:601
#define D3DUSAGE_WRITEONLY
Definition: d3d8types.h:93
@ D3DPOOL_DEFAULT
Definition: d3d8types.h:709
enum _D3DFORMAT D3DFORMAT
#define D3DUSAGE_RTPATCHES
Definition: d3d8types.h:97
#define D3DERR_INVALIDCALL
#define D3DX_DEFAULT
Definition: d3dx9.h:24
HRESULT WINAPI D3DXCheckCubeTextureRequirements(struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:421
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
Definition: texture.c:164
unsigned int UINT
Definition: ndis.h:50
DWORD TextureCaps
Definition: d3d9caps.h:279

Referenced by START_TEST().

◆ test_D3DXCheckTextureRequirements()

static void test_D3DXCheckTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 187 of file texture.c.

188{
189 UINT width, height, mipmaps;
191 D3DCAPS9 caps;
192 HRESULT hr;
193 IDirect3D9 *d3d;
196
198
199 /* general tests */
201 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
202
204 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
205
207 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
208
209 /* width & height */
212 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
213 ok(width == 256, "Returned width %d, expected %d\n", width, 256);
214 ok(height == 256, "Returned height %d, expected %d\n", height, 256);
215
218 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
219 ok(width == 256, "Returned width %d, expected %d\n", width, 256);
220
222 skip("Hardware only supports pow2 textures\n");
223 else
224 {
225 width = 62;
227 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
228 ok(width == 62, "Returned width %d, expected %d\n", width, 62);
229
230 width = D3DX_DEFAULT; height = 63;
232 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
233 ok(width == height, "Returned width %d, expected %d\n", width, height);
234 ok(height == 63, "Returned height %d, expected %d\n", height, 63);
235 }
236
239 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
240 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
241 ok(height == 1, "Returned height %d, expected %d\n", height, 1);
242
243 width = 0; height = 0;
245 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
246 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
247 ok(height == 1, "Returned height %d, expected %d\n", height, 1);
248
249 width = 0;
251 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
252 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
253
254 width = 0xFFFFFFFE;
256 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
257 ok(width == caps.MaxTextureWidth, "Returned width %d, expected %d\n", width, caps.MaxTextureWidth);
258
259 width = caps.MaxTextureWidth-1;
261 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
263 ok(width == caps.MaxTextureWidth, "Returned width %d, expected %d\n", width, caps.MaxTextureWidth);
264 else
265 ok(width == caps.MaxTextureWidth-1, "Returned width %d, expected %d\n", width, caps.MaxTextureWidth-1);
266
267 /* mipmaps */
268 width = 64; height = 63;
269 mipmaps = 9;
271 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
272 ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
273
274 if (!(caps.TextureCaps & D3DPTEXTURECAPS_POW2))
275 {
276 width = 284; height = 137;
277 mipmaps = 20;
279 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
280 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
281
282 width = height = 63;
283 mipmaps = 9;
285 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
286 ok(mipmaps == 6, "Returned mipmaps %d, expected %d\n", mipmaps, 6);
287 }
288 else
289 skip("Skipping some tests, npot2 textures unsupported\n");
290
291 mipmaps = 20;
293 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
294 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
295
296 mipmaps = 0;
298 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
299 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
300
301 /* mipmaps when D3DUSAGE_AUTOGENMIPMAP is set */
303 {
304 mipmaps = 0;
306 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
307 ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
308 mipmaps = 1;
310 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
311 ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
312 mipmaps = 2;
314 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
315 ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
316 mipmaps = 6;
318 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
319 ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
320 }
321 else
322 skip("No D3DUSAGE_AUTOGENMIPMAP support for textures\n");
323
324 /* usage */
326 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
328 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
330 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
332 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
334 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
335
336 /* format */
338 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
339
342 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
343 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
344
347 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
348 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
349
352 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
353 ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
354
358
359 if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
360 mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_R3G3B2)))
362 else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
365 else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
368 else
370
373 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
374 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
375
376 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
379 else
381
384 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
385 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
386
387 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
388 mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_P8)))
390 else
392
395 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
396 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
397
398 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
401 else
403
406 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
407 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
408
409 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
412 else
414
417 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
418 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
419
420 /* Block-based texture formats and size < block size. */
422 width = 2; height = 2;
423 mipmaps = 1;
425 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
426 ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
427 if (has_2d_dxt1)
428 {
429 ok(width == 4, "Got unexpected width %d.\n", width);
430 ok(height == 4, "Got unexpected height %d.\n", height);
431 ok(format == D3DFMT_DXT1, "Got unexpected format %u.\n", format);
432 }
433 else
434 {
435 ok(width == 2, "Got unexpected width %d.\n", width);
436 ok(height == 2, "Got unexpected height %d.\n", height);
437 ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
438 }
439
441 width = 2; height = 2;
443 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
444 ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
445 if (has_2d_dxt5)
446 {
447 ok(width == 4, "Got unexpected width %d.\n", width);
448 ok(height == 4, "Got unexpected height %d.\n", height);
449 ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
450
451 width = 9;
452 height = 9;
454 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
455 ok(width == 12, "Got unexpected width %u.\n", width);
456 ok(height == 12, "Got unexpected height %u.\n", height);
457 ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
458 ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
459 }
460 else
461 {
462 ok(width == 2, "Got unexpected width %d.\n", width);
463 ok(height == 2, "Got unexpected height %d.\n", height);
464 ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
465 }
466 width = 4;
467 height = 2;
469 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
470 ok(width == 4, "Got unexpected width %u.\n", width);
471 ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
472 if (has_2d_dxt5)
473 {
474 ok(height == 4, "Got unexpected height %u.\n", height);
475 ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
476 }
477 else
478 {
479 ok(height == 2, "Got unexpected height %u.\n", height);
480 ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
481 }
482
484}
#define D3DPTEXTURECAPS_POW2
Definition: d3d8caps.h:114
@ D3DFMT_X1R5G5B5
Definition: d3d8types.h:607
@ D3DFMT_R3G3B2
Definition: d3d8types.h:610
@ D3DFMT_X4R4G4B4
Definition: d3d8types.h:613
@ D3DFMT_R5G6B5
Definition: d3d8types.h:606
@ D3DFMT_A8R3G3B2
Definition: d3d8types.h:612
@ D3DFMT_P8
Definition: d3d8types.h:618
@ D3DFMT_L8
Definition: d3d8types.h:620
#define D3DUSAGE_RENDERTARGET
Definition: d3d8types.h:91
@ D3DFMT_A16B16G16R16
Definition: d3d9types.h:780
@ D3DFMT_L16
Definition: d3d9types.h:815
HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:412
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
DWORD MaxTextureWidth
Definition: d3d9caps.h:286

Referenced by START_TEST().

◆ test_D3DXCheckVolumeTextureRequirements()

static void test_D3DXCheckVolumeTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 587 of file texture.c.

588{
589 UINT width, height, depth, mipmaps, expected;
591 D3DCAPS9 caps;
592 HRESULT hr;
593
595
596 if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) || (caps.MaxVolumeExtent < 256))
597 {
598 skip("Limited or no volume textures support.\n");
599 return;
600 }
601
602 /* general tests */
604 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
605
607 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
608
610 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
611
612 /* width, height, depth */
615 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
616 ok(width == 256, "Returned width %d, expected %d\n", width, 256);
617 ok(height == 256, "Returned height %d, expected %d\n", height, 256);
618 ok(depth == 1, "Returned depth %d, expected %d\n", depth, 1);
619
622 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
623 ok(width == 256, "Returned width %d, expected %d\n", width, 256);
624
625 width = D3DX_DEFAULT; height = 0; depth = 0;
627 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
628 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
629 ok(height == 1, "Returned height %d, expected %d\n", height, 1);
630 ok(depth == 1, "Returned height %d, expected %d\n", depth, 1);
631
632 width = 0; height = 0; depth = 0;
634 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
635 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
636 ok(height == 1, "Returned height %d, expected %d\n", height, 1);
637 ok(depth == 1, "Returned height %d, expected %d\n", depth, 1);
638
639 width = 0;
641 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
642 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
643
644 width = 0xFFFFFFFE;
646 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
647 ok(width == caps.MaxVolumeExtent, "Returned width %d, expected %d\n", width, caps.MaxVolumeExtent);
648
649 /* format */
651 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
652
655 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
656 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
657
660 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
661 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
662
665 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
666 ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
667
670 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
671 if (has_3d_dxt3)
672 ok(format == D3DFMT_DXT3, "Returned format %u, expected %u\n", format, D3DFMT_DXT3);
673 else
674 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
675
676 /* mipmaps */
678 {
679 skip("No volume textures mipmapping support\n");
680 return;
681 }
682
683 width = height = depth = 64;
684 mipmaps = 9;
686 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
687 ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
688
689 width = 284;
690 height = 143;
691 depth = 55;
692 mipmaps = 20;
693 expected = (caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP_POW2 && caps.MaxVolumeExtent >= 512) ? 10 : 9;
695 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
696 ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
697
698 mipmaps = 0;
700 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
701 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
702
703 /* D3DUSAGE_AUTOGENMIPMAP is never supported for volume textures. */
705 "D3DUSAGE_AUTOGENMIPMAP is unexpectedly supported on volume textures.\n");
706}
#define D3DPTEXTURECAPS_VOLUMEMAP
Definition: d3d8caps.h:122
#define D3DPTEXTURECAPS_VOLUMEMAP_POW2
Definition: d3d8caps.h:127
#define D3DPTEXTURECAPS_MIPVOLUMEMAP
Definition: d3d8caps.h:124
HRESULT WINAPI D3DXCheckVolumeTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:456
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
DWORD MaxVolumeExtent
Definition: d3d9caps.h:288

Referenced by START_TEST().

◆ test_D3DXCreateCubeTextureFromFileInMemory()

static void test_D3DXCreateCubeTextureFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 2025 of file texture.c.

2026{
2027 HRESULT hr;
2028 ULONG ref;
2029 DWORD levelcount;
2030 IDirect3DCubeTexture9 *cube_texture;
2031 D3DSURFACE_DESC surface_desc;
2032
2034 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2035
2037 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2038
2040 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2041
2043 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2044
2046 if (SUCCEEDED(hr))
2047 {
2048 levelcount = IDirect3DCubeTexture9_GetLevelCount(cube_texture);
2049 ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
2050
2051 hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &surface_desc);
2052 ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
2053 ok(surface_desc.Width == 4, "Got width %u, expected 4\n", surface_desc.Width);
2054 ok(surface_desc.Height == 4, "Got height %u, expected 4\n", surface_desc.Height);
2055
2056 ref = IDirect3DCubeTexture9_Release(cube_texture);
2057 ok(ref == 0, "Invalid reference count. Got %u, expected 0\n", ref);
2058 } else skip("Couldn't create cube texture\n");
2059}
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:919
#define IDirect3DCubeTexture9_GetLevelCount(p)
Definition: d3d9.h:932
#define IDirect3DCubeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:937
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory(struct IDirect3DDevice9 *device, const void *data, UINT datasize, struct IDirect3DCubeTexture9 **texture)
Definition: texture.c:935
static const unsigned char dds_cube_map[]
Definition: texture.c:57

Referenced by START_TEST().

◆ test_D3DXCreateCubeTextureFromFileInMemoryEx()

static void test_D3DXCreateCubeTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device)
static

Definition at line 2061 of file texture.c.

2062{
2063 IDirect3DCubeTexture9 *cube_texture;
2064 HRESULT hr;
2065
2068 D3DX_DEFAULT, 0, NULL, NULL, &cube_texture);
2069 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
2070 IDirect3DCubeTexture9_Release(cube_texture);
2071
2073 {
2074 skip("No D3DUSAGE_AUTOGENMIPMAP support for cube textures\n");
2075 return;
2076 }
2077
2080 D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &cube_texture);
2081 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
2082 IDirect3DCubeTexture9_Release(cube_texture);
2083}
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
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:1400

Referenced by START_TEST().

◆ test_D3DXCreateTexture()

static void test_D3DXCreateTexture ( IDirect3DDevice9 *  device)
static

Definition at line 708 of file texture.c.

709{
710 IDirect3DTexture9 *texture;
712 D3DCAPS9 caps;
713 UINT mipmaps;
714 HRESULT hr;
715
717
719 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
720
721 /* width and height tests */
722
724 ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
725
726 if (texture)
727 {
729 ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
730 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
731
732 ok(desc.Width == 256, "Returned width %d, expected %d\n", desc.Width, 256);
733 ok(desc.Height == 256, "Returned height %d, expected %d\n", desc.Height, 256);
734
736 }
737
738
740 ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
741
742 if (texture)
743 {
745 ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
746 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
747
748 ok(desc.Width == 1, "Returned width %d, expected %d\n", desc.Width, 1);
749 ok(desc.Height == 1, "Returned height %d, expected %d\n", desc.Height, 1);
750
752 }
753
754
756 skip("Hardware only supports pow2 textures\n");
757 else
758 {
760 ok((hr == D3D_OK) ||
761 /* may not work with conditional NPOT */
763 "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
764
765 if (texture)
766 {
768 ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
769 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
770
771 /* Conditional NPOT may create a texture with different dimensions, so allow those
772 situations instead of returning a fail */
773
774 ok(desc.Width == 63 ||
776 "Returned width %d, expected %d\n", desc.Width, 63);
777
778 ok(desc.Height == 63 ||
780 "Returned height %d, expected %d\n", desc.Height, 63);
781
783 }
784 }
785
786 /* mipmaps */
787
788 hr = D3DXCreateTexture(device, 64, 63, 9, 0, 0, D3DPOOL_DEFAULT, &texture);
789 ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
790
791 if (texture)
792 {
794 ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
795
797 }
798
799
800 hr = D3DXCreateTexture(device, 284, 137, 9, 0, 0, D3DPOOL_DEFAULT, &texture);
801 ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
802
803 if (texture)
804 {
806 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
807
809 }
810
811
812 hr = D3DXCreateTexture(device, 0, 0, 20, 0, 0, D3DPOOL_DEFAULT, &texture);
813 ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
814
815 if (texture)
816 {
818 ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
819
821 }
822
823
824 hr = D3DXCreateTexture(device, 64, 64, 1, 0, 0, D3DPOOL_DEFAULT, &texture);
825 ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
826
827 if (texture)
828 {
830 ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
831
833 }
834
835 /* usage */
836
838 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
840 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
842 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
844 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
846 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
847
848 /* format */
849
851 ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
852
853 if (texture)
854 {
856 ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
857 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
858
860 }
861
862
864 ok(hr == D3D_OK, "D3DXCreateTexture returned %#x, expected %#x\n", hr, D3D_OK);
865
866 if (texture)
867 {
869 ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
870 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
871
873 }
874
875 /* D3DXCreateTextureFromResource */
877 ok(hr == D3D_OK, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3D_OK);
879
881 ok(hr == D3D_OK, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3D_OK);
883
885 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
886
888 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
889
891 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
892
894 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
895
896
897 /* D3DXCreateTextureFromResourceEx */
899 ok(hr == D3D_OK, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3D_OK);
901
903 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
904
906 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
907
909 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
910
912 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
913}
#define IDS_STRING
Definition: resource.h:17
#define D3DXERR_INVALIDDATA
Definition: compiler.c:30
#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL
Definition: d3d8caps.h:119
@ D3DPOOL_MANAGED
Definition: d3d8types.h:710
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:1027
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
HRESULT WINAPI D3DXCreateTextureFromResourceA(struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, struct IDirect3DTexture9 **texture)
Definition: texture.c:837
HRESULT WINAPI D3DXCreateTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
Definition: texture.c:528
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
GLenum GLuint texture
Definition: glext.h:6295
static const WCHAR desc[]
Definition: protectdata.c:36
#define IDB_BITMAP_1x1
Definition: resources.h:22
#define IDD_BITMAPDATA_1x1
Definition: resources.h:23
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

Referenced by START_TEST().

◆ test_D3DXCreateTextureFromFileInMemory()

static void test_D3DXCreateTextureFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 1601 of file texture.c.

1602{
1603 static const DWORD dds_dxt5_expected[] =
1604 {
1605 0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
1606 0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
1607 0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
1608 0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
1609 };
1610 static const DWORD dds_dxt5_8_8_expected[] =
1611 {
1612 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x3f00ffff, 0x3f00ffff, 0x3fff0000, 0x3fff0000,
1613 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x3f00ffff, 0x3f00ffff, 0x3fff0000, 0x3fff0000,
1614 0x000000ff, 0x000000ff, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3f00ffff, 0x3f00ffff,
1615 0x000000ff, 0x000000ff, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3f00ffff, 0x3f00ffff,
1616 0x7fffff00, 0x7fffff00, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xffffffff, 0xffffffff,
1617 0x7fffff00, 0x7fffff00, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xffffffff, 0xffffffff,
1618 0x7fff00ff, 0x7fff00ff, 0x7fffff00, 0x7fffff00, 0xffffffff, 0xffffffff, 0xff000000, 0xff000000,
1619 0x7fff00ff, 0x7fff00ff, 0x7fffff00, 0x7fffff00, 0xffffffff, 0xffffffff, 0xff000000, 0xff000000,
1620 };
1621 static const DWORD dds_dxt5_8_8_expected_misaligned_1[] =
1622 {
1623 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3fff0000, 0x3fff0000,
1624 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3fff0000, 0x3fff0000,
1625 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3fff0000, 0x3fff0000,
1626 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3fff0000, 0x3fff0000,
1627 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1628 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1629 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1630 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1631 };
1632 static const DWORD dds_dxt5_8_8_expected_misaligned_3[] =
1633 {
1634 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1635 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1636 0x00000000, 0x00000000, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x00000000, 0x00000000,
1637 0x00000000, 0x00000000, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x00000000, 0x00000000,
1638 0x00000000, 0x00000000, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0x00000000, 0x00000000,
1639 0x00000000, 0x00000000, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0x00000000, 0x00000000,
1640 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1641 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1642 };
1643 IDirect3DSurface9 *surface, *uncompressed_surface;
1644 IDirect3DTexture9 *texture;
1645 D3DLOCKED_RECT lock_rect;
1648 unsigned int i, x, y;
1649 DWORD level_count;
1650 HRESULT hr;
1651 RECT rect;
1652
1654 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1656
1658 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
1660
1662 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
1663
1664 /* Check that D3DXCreateTextureFromFileInMemory accepts cube texture dds file (only first face texture is loaded) */
1666 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
1668 ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u.\n", type, D3DRTYPE_TEXTURE);
1670 ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
1671 ok(desc.Width == 4, "Width is %u, expected 4.\n", desc.Width);
1672 ok(desc.Height == 4, "Height is %u, expected 4.\n", desc.Height);
1673 if (has_cube_dxt5)
1674 {
1675 ok(desc.Format == D3DFMT_DXT5, "Unexpected texture format %#x.\n", desc.Format);
1677 ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %#x, expected %#x\n", hr, D3D_OK);
1678 if (SUCCEEDED(hr))
1679 {
1680 for (i = 0; i < 16; i++)
1681 ok(((BYTE *)lock_rect.pBits)[i] == dds_cube_map[128 + i],
1682 "Byte at index %u is 0x%02x, expected 0x%02x.\n",
1683 i, ((BYTE *)lock_rect.pBits)[i], dds_cube_map[128 + i]);
1685 }
1686 }
1687 else
1688 {
1689 ok(desc.Format == D3DFMT_A8R8G8B8, "Unexpected texture format %#x.\n", desc.Format);
1690 skip("D3DFMT_DXT5 textures are not supported, skipping a test.\n");
1691 }
1693
1694 /* Test with a DXT5 texture smaller than the block size. */
1696 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1697 if (SUCCEEDED(hr) && has_2d_dxt5)
1698 {
1700 ok(type == D3DRTYPE_TEXTURE, "Got unexpected type %u.\n", type);
1702 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1703 ok(desc.Width == 4, "Got unexpected width %u.\n", desc.Width);
1704 ok(desc.Height == 4, "Got unexpected height %u.\n", desc.Height);
1705
1708 D3DPOOL_DEFAULT, &uncompressed_surface, NULL);
1709 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1710 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
1711 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1712 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1713 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1714 for (y = 0; y < 4; ++y)
1715 {
1716 for (x = 0; x < 4; ++x)
1717 {
1718 /* Use a large tolerance, decompression + stretching +
1719 * compression + decompression again introduce quite a bit of
1720 * precision loss. */
1721 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1722 dds_dxt5_expected[y * 4 + x], 32),
1723 "Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
1724 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1725 dds_dxt5_expected[y * 4 + x]);
1726 }
1727 }
1728 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
1729 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1730
1731 IDirect3DSurface9_Release(uncompressed_surface);
1733 }
1734 if (SUCCEEDED(hr))
1736
1737 /* Test with a larger DXT5 texture. */
1739 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1741 ok(type == D3DRTYPE_TEXTURE, "Got unexpected type %u.\n", type);
1743 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1744 ok(desc.Width == 8, "Got unexpected width %u.\n", desc.Width);
1745 ok(desc.Height == 8, "Got unexpected height %u.\n", desc.Height);
1747
1749 D3DPOOL_DEFAULT, &uncompressed_surface, NULL);
1750 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1751 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
1752 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1753 if (SUCCEEDED(hr))
1754 {
1755 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1756 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1757 for (y = 0; y < 8; ++y)
1758 {
1759 for (x = 0; x < 8; ++x)
1760 {
1761 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1762 dds_dxt5_8_8_expected[y * 8 + x], 0),
1763 "Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
1764 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1765 dds_dxt5_8_8_expected[y * 8 + x]);
1766 }
1767 }
1768 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
1769 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1770 }
1771
1772 hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, D3DLOCK_READONLY);
1773 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1774 for (y = 0; y < 2; ++y)
1775 memset(&((BYTE *)lock_rect.pBits)[y * lock_rect.Pitch], 0, 16 * 2);
1777 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1778
1779 SetRect(&rect, 2, 2, 6, 6);
1781 D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0);
1782 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1783 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
1784 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1785
1786 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1787 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1788 for (y = 0; y < 8; ++y)
1789 {
1790 for (x = 0; x < 8; ++x)
1791 {
1792 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1793 dds_dxt5_8_8_expected_misaligned_1[y * 8 + x], 0),
1794 "Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
1795 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1796 dds_dxt5_8_8_expected_misaligned_1[y * 8 + x]);
1797 }
1798 }
1799 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
1800 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1801
1802 hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, D3DLOCK_READONLY);
1803 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1804 for (y = 0; y < 2; ++y)
1805 memset(&((BYTE *)lock_rect.pBits)[y * lock_rect.Pitch], 0, 16 * 2);
1807 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1808
1810 D3DFMT_DXT5, 16 * 2, NULL, NULL, D3DX_FILTER_POINT, 0);
1811 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
1812
1814 D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0);
1815 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1816 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
1817 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1818
1819 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1820 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1821 for (y = 0; y < 8; ++y)
1822 {
1823 for (x = 0; x < 8; ++x)
1824 {
1825 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1826 dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0),
1827 "Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
1828 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1829 dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]);
1830 }
1831 }
1832 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
1833 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1834
1836 sizeof(dds_dxt5_8_8), &rect, D3DX_FILTER_POINT, 0, NULL);
1837 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1838 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
1839 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1840
1841 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1842 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1843 for (y = 0; y < 8; ++y)
1844 {
1845 for (x = 0; x < 8; ++x)
1846 {
1847 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1848 dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0),
1849 "Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
1850 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1851 dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]);
1852 }
1853 }
1854 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
1855 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
1856
1857 IDirect3DSurface9_Release(uncompressed_surface);
1860
1861 /* Volume textures work too. */
1863 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
1865 ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u.\n", type, D3DRTYPE_TEXTURE);
1866 level_count = IDirect3DBaseTexture9_GetLevelCount((IDirect3DBaseTexture9 *)texture);
1867 todo_wine ok(level_count == 3, "Texture has %u mip levels, 3 expected.\n", level_count);
1869 ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
1870 ok(desc.Width == 4, "Width is %u, expected 4.\n", desc.Width);
1871 ok(desc.Height == 4, "Height is %u, expected 4.\n", desc.Height);
1872
1873 if (has_2d_dxt3)
1874 {
1875 ok(desc.Format == D3DFMT_DXT3, "Unexpected texture format %#x.\n", desc.Format);
1877 ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %#x, expected %#x.\n", hr, D3D_OK);
1878 if (SUCCEEDED(hr))
1879 {
1880 for (i = 0; i < 16; ++i)
1881 ok(((BYTE *)lock_rect.pBits)[i] == dds_volume_map[128 + i],
1882 "Byte at index %u is 0x%02x, expected 0x%02x.\n",
1883 i, ((BYTE *)lock_rect.pBits)[i], dds_volume_map[128 + i]);
1885 }
1886 }
1887 else
1888 {
1889 ok(desc.Format == D3DFMT_A8R8G8B8, "Unexpected texture format %#x.\n", desc.Format);
1890 skip("D3DFMT_DXT3 volume textures are not supported, skipping a test.\n");
1891 }
1892 /* The lower texture levels are apparently generated by filtering the level 0 surface
1893 * I.e. following levels from the file are ignored. */
1895}
enum _D3DRESOURCETYPE D3DRESOURCETYPE
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:1033
#define IDirect3DTexture9_GetType(p)
Definition: d3d9.h:1023
#define IDirect3DSurface9_LockRect(p, a, b, c)
Definition: d3d9.h:635
#define IDirect3DTexture9_UnlockRect(p, a)
Definition: d3d9.h:1035
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:848
#define IDirect3DTexture9_LockRect(p, a, b, c, d)
Definition: d3d9.h:1034
#define IDirect3DSurface9_UnlockRect(p)
Definition: d3d9.h:636
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
#define IDirect3DDevice9_CreateOffscreenPlainSurface(p, a, b, c, d, e, f)
Definition: d3d9.h:1543
#define D3DX_FILTER_POINT
Definition: d3dx9tex.h:28
#define D3DX_FILTER_NONE
Definition: d3dx9tex.h:27
HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, const void *src_memory, D3DFORMAT src_format, UINT src_pitch, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key)
Definition: surface.c:1963
HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, IDirect3DSurface9 *src_surface, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key)
Definition: surface.c:2233
HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface, const PALETTEENTRY *pDestPalette, const RECT *pDestRect, const void *pSrcData, UINT SrcDataSize, const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo)
Definition: surface.c:1245
HRESULT WINAPI D3DXCreateTextureFromFileInMemory(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, struct IDirect3DTexture9 **texture)
Definition: texture.c:748
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static const unsigned char dds_volume_map[]
Definition: texture.c:75
static const BYTE dds_dxt5[]
Definition: texture.c:91
static const unsigned char dds_16bit[]
Definition: texture.c:31
static const BYTE dds_dxt5_8_8[]
Definition: texture.c:104
static BOOL compare_color(DWORD c1, DWORD c2, BYTE max_diff)
Definition: texture.c:156
static const unsigned char dds_24bit[]
Definition: texture.c:44
#define todo_wine
Definition: custom.c:79
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_D3DXCreateTextureFromFileInMemoryEx()

static void test_D3DXCreateTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device)
static

Definition at line 1897 of file texture.c.

1898{
1899 HRESULT hr;
1900 IDirect3DTexture9 *texture;
1901 unsigned int miplevels;
1902 IDirect3DSurface9 *surface;
1904
1907 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
1909
1912 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
1914
1918 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
1920 ok(miplevels == 1, "Got miplevels %u, expected %u.\n", miplevels, 1);
1923 ok(desc.Width == 1 && desc.Height == 1,
1924 "Surface dimensions are %ux%u, expected 1x1.\n", desc.Width, desc.Height);
1927
1929 {
1930 skip("No D3DUSAGE_AUTOGENMIPMAP support for textures\n");
1931 return;
1932 }
1933
1936 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
1938
1939 /* Checking for color key format overrides. */
1943 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1946 ok(desc.Format == D3DFMT_X1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X1R5G5B5);
1951 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1952 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1955 ok(desc.Format == D3DFMT_A1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A1R5G5B5);
1960 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1961 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1964 ok(desc.Format == D3DFMT_X1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X1R5G5B5);
1967
1971 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1974 ok(desc.Format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X8R8G8B8);
1979 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1980 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1983 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A8R8G8B8);
1988 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
1989 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
1992 ok(desc.Format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X8R8G8B8);
1995
1999 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
2002 ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_L8);
2007 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
2008 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
2011 ok(desc.Format == D3DFMT_A8L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A8L8);
2016 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
2017 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
2020 ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_L8);
2023}
@ D3DFMT_A1R5G5B5
Definition: d3d8types.h:608
@ D3DFMT_A8L8
Definition: d3d8types.h:621
#define IDirect3DSurface9_GetDesc(p, a)
Definition: d3d9.h:634
#define D3DX_SKIP_DDS_MIP_LEVELS(l, f)
Definition: d3dx9tex.h:44
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:568
static const unsigned char png_grayscale[]
Definition: texture.c:120

Referenced by START_TEST().

◆ test_D3DXCreateVolumeTextureFromFileInMemory()

static void test_D3DXCreateVolumeTextureFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 2085 of file texture.c.

2086{
2087 HRESULT hr;
2088 ULONG ref;
2089 DWORD levelcount;
2090 IDirect3DVolumeTexture9 *volume_texture;
2091 D3DVOLUME_DESC volume_desc;
2092
2094 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2095
2097 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2098
2100 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2101
2103 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2104
2106 ok(hr == D3D_OK, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
2107 levelcount = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
2108 ok(levelcount == 3, "GetLevelCount returned %u, expected 3.\n", levelcount);
2109
2110 hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &volume_desc);
2111 ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
2112 ok(volume_desc.Width == 4, "Got width %u, expected 4.\n", volume_desc.Width);
2113 ok(volume_desc.Height == 4, "Got height %u, expected 4.\n", volume_desc.Height);
2114 ok(volume_desc.Depth == 2, "Got depth %u, expected 2.\n", volume_desc.Depth);
2115 ok(volume_desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected D3DPOOL_MANAGED.\n", volume_desc.Pool);
2116
2117 hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 1, &volume_desc);
2118 ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
2119 ok(volume_desc.Width == 2, "Got width %u, expected 2.\n", volume_desc.Width);
2120 ok(volume_desc.Height == 2, "Got height %u, expected 2.\n", volume_desc.Height);
2121 ok(volume_desc.Depth == 1, "Got depth %u, expected 1.\n", volume_desc.Depth);
2122
2123 ref = IDirect3DVolumeTexture9_Release(volume_texture);
2124 ok(ref == 0, "Invalid reference count. Got %u, expected 0.\n", ref);
2125}
#define IDirect3DVolumeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1127
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:1109
#define IDirect3DVolumeTexture9_GetLevelCount(p)
Definition: d3d9.h:1122
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *device, const void *data, UINT data_size, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1106

Referenced by START_TEST().

◆ test_D3DXCreateVolumeTextureFromFileInMemoryEx()

static void test_D3DXCreateVolumeTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device)
static

Definition at line 2127 of file texture.c.

2128{
2129 IDirect3DVolumeTexture9 *volume_texture;
2130 HRESULT hr;
2131
2134 D3DX_DEFAULT, 0, NULL, NULL, &volume_texture);
2135 ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
2136
2139 D3DX_DEFAULT, 0, NULL, NULL, &volume_texture);
2140 ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
2141}
#define D3DUSAGE_DEPTHSTENCIL
Definition: d3d8types.h:92
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *data, UINT data_size, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1118
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84

Referenced by START_TEST().

◆ test_D3DXFillCubeTexture()

static void test_D3DXFillCubeTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1365 of file texture.c.

1366{
1367 IDirect3DCubeTexture9 *tex;
1368 HRESULT hr;
1369 D3DLOCKED_RECT lock_rect;
1370 DWORD x, y, f, m;
1371 DWORD v[4], e[4];
1372 DWORD value, expected, size, pitch;
1373 enum cube_coord coordmap[6][3] =
1374 {
1376 {ZERO, YCOORDINV, XCOORD},
1377 {XCOORD, ONE, YCOORD},
1378 {XCOORD, ZERO, YCOORDINV},
1379 {XCOORD, YCOORDINV, ONE},
1381 };
1382
1383 size = 4;
1385 D3DPOOL_MANAGED, &tex, NULL);
1386
1387 if (SUCCEEDED(hr))
1388 {
1390 ok(hr == D3D_OK, "D3DXFillCubeTexture returned %#x, expected %#x\n", hr, D3D_OK);
1391
1392 for (m = 0; m < 3; m++)
1393 {
1394 for (f = 0; f < 6; f++)
1395 {
1397 ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1398 if (SUCCEEDED(hr))
1399 {
1400 pitch = lock_rect.Pitch / sizeof(DWORD);
1401 for (y = 0; y < size; y++)
1402 {
1403 for (x = 0; x < size; x++)
1404 {
1405 value = ((DWORD *)lock_rect.pBits)[y * pitch + x];
1406 v[0] = (value >> 24) & 0xff;
1407 v[1] = (value >> 16) & 0xff;
1408 v[2] = (value >> 8) & 0xff;
1409 v[3] = value & 0xff;
1410
1411 e[0] = (f == 0) || (f == 1) ?
1412 0 : (BYTE)(255.0f / size * 2.0f + 0.5f);
1413 e[1] = get_cube_coord(coordmap[f][0], x, y, size) / size * 255.0f + 0.5f;
1414 e[2] = get_cube_coord(coordmap[f][1], x, y, size) / size * 255.0f + 0.5f;
1415 e[3] = get_cube_coord(coordmap[f][2], x, y, size) / size * 255.0f + 0.5f;
1416 expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3];
1417
1418 ok(color_match(v, e),
1419 "Texel at face %u (%u, %u) doesn't match: %#x, expected %#x\n",
1420 f, x, y, value, expected);
1421 }
1422 }
1424 }
1425 }
1426 size >>= 1;
1427 }
1428
1430 }
1431 else
1432 skip("Failed to create texture\n");
1433
1435 D3DPOOL_MANAGED, &tex, NULL);
1436
1437 if (SUCCEEDED(hr))
1438 {
1440 ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1441 for (f = 0; f < 6; f++)
1442 {
1443 hr = IDirect3DCubeTexture9_LockRect(tex, f, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1444 ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1445 if (SUCCEEDED(hr))
1446 {
1447 pitch = lock_rect.Pitch / sizeof(WORD);
1448 for (y = 0; y < 4; y++)
1449 {
1450 for (x = 0; x < 4; x++)
1451 {
1452 value = ((WORD *)lock_rect.pBits)[y * pitch + x];
1453 v[0] = value >> 15;
1454 v[1] = value >> 10 & 0x1f;
1455 v[2] = value >> 5 & 0x1f;
1456 v[3] = value & 0x1f;
1457
1458 e[0] = (f == 0) || (f == 1) ?
1459 0 : (BYTE)(1.0f / size * 2.0f + 0.5f);
1460 e[1] = get_cube_coord(coordmap[f][0], x, y, 4) / 4 * 31.0f + 0.5f;
1461 e[2] = get_cube_coord(coordmap[f][1], x, y, 4) / 4 * 31.0f + 0.5f;
1462 e[3] = get_cube_coord(coordmap[f][2], x, y, 4) / 4 * 31.0f + 0.5f;
1463 expected = e[0] << 15 | e[1] << 10 | e[2] << 5 | e[3];
1464
1465 ok(color_match(v, e),
1466 "Texel at face %u (%u, %u) doesn't match: %#x, expected %#x\n",
1467 f, x, y, value, expected);
1468 }
1469 }
1471 }
1472 }
1473
1475 }
1476 else
1477 skip("Failed to create texture\n");
1478}
#define IDirect3DCubeTexture9_UnlockRect(p, a, b)
Definition: d3d9.h:940
#define IDirect3DCubeTexture9_LockRect(p, a, b, c, d, e)
Definition: d3d9.h:939
#define IDirect3DDevice9_CreateCubeTexture(p, a, b, c, d, e, f, g)
Definition: d3d9.h:1532
static float get_cube_coord(enum cube_coord coord, unsigned int x, unsigned int y, unsigned int size)
Definition: texture.c:1673
cube_coord
Definition: texture.c:1664
HRESULT WINAPI D3DXFillCubeTexture(struct IDirect3DCubeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
Definition: texture.c:1695
unsigned short WORD
Definition: ntddk_ex.h:93
const GLdouble * v
Definition: gl.h:2040
GLfloat f
Definition: glext.h:7540
const GLfloat * m
Definition: glext.h:10848
#define e
Definition: ke_i.h:82
#define f
Definition: ke_i.h:83
static void WINAPI fillfunc_cube(D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
Definition: texture.c:1324
static BOOL color_match(const DWORD *value, const DWORD *expected)
Definition: texture.c:1061
#define DWORD
Definition: nt_native.h:44

Referenced by START_TEST().

◆ test_D3DXFillTexture()

static void test_D3DXFillTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1082 of file texture.c.

1083{
1084 static const struct
1085 {
1086 DWORD usage;
1087 D3DPOOL pool;
1088 }
1089 test_access_types[] =
1090 {
1091 {0, D3DPOOL_MANAGED},
1092 {0, D3DPOOL_DEFAULT},
1094 };
1095
1096 IDirect3DTexture9 *tex;
1097 HRESULT hr;
1098 D3DLOCKED_RECT lock_rect;
1099 DWORD x, y, m;
1100 DWORD v[4], e[4];
1101 DWORD value, expected, size, pitch;
1102 unsigned int i;
1103
1104 for (i = 0; i < ARRAY_SIZE(test_access_types); ++i)
1105 {
1106 size = 4;
1107 hr = IDirect3DDevice9_CreateTexture(device, size, size, 0, test_access_types[i].usage,
1108 D3DFMT_A8R8G8B8, test_access_types[i].pool, &tex, NULL);
1109 ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i);
1110
1112 ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i);
1113
1114 for (m = 0; m < 3; m++)
1115 {
1116 IDirect3DSurface9 *src_surface, *temp_surface;
1117
1118 hr = IDirect3DTexture9_GetSurfaceLevel(tex, m, &src_surface);
1119 ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m);
1120 temp_surface = src_surface;
1121
1122 if (FAILED(hr = IDirect3DSurface9_LockRect(src_surface, &lock_rect, NULL, D3DLOCK_READONLY)))
1123 {
1125 D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &temp_surface, NULL);
1126 ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m);
1127 hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL, temp_surface, NULL, D3DTEXF_NONE);
1128 ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m);
1129 hr = IDirect3DSurface9_LockRect(temp_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1130 ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m);
1131 }
1132
1133 pitch = lock_rect.Pitch / sizeof(DWORD);
1134 for (y = 0; y < size; y++)
1135 {
1136 for (x = 0; x < size; x++)
1137 {
1138 value = ((DWORD *)lock_rect.pBits)[y * pitch + x];
1139 v[0] = (value >> 24) & 0xff;
1140 v[1] = (value >> 16) & 0xff;
1141 v[2] = (value >> 8) & 0xff;
1142 v[3] = value & 0xff;
1143
1144 e[0] = 0xff;
1145 e[1] = (x + 0.5f) / size * 255.0f + 0.5f;
1146 e[2] = (y + 0.5f) / size * 255.0f + 0.5f;
1147 e[3] = 255.0f / size + 0.5f;
1148 expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3];
1149
1150 ok(color_match(v, e),
1151 "Texel at (%u, %u) doesn't match: %#x, expected %#x, i %u, m %u.\n",
1152 x, y, value, expected, i, m);
1153 }
1154 }
1155 IDirect3DSurface9_UnlockRect(temp_surface);
1156 if (temp_surface != src_surface)
1157 IDirect3DSurface9_Release(temp_surface);
1158 IDirect3DSurface9_Release(src_surface);
1159 size >>= 1;
1160 }
1162 }
1163
1166 if (hr == D3D_OK)
1167 {
1169 todo_wine ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
1171 }
1172
1175 if (hr == D3D_OK)
1176 {
1178 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
1180 }
1181
1183 D3DPOOL_MANAGED, &tex, NULL);
1184
1185 if (SUCCEEDED(hr))
1186 {
1188 ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1189
1190 hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1191 ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1192 if (SUCCEEDED(hr))
1193 {
1194 pitch = lock_rect.Pitch / sizeof(WORD);
1195 for (y = 0; y < 4; y++)
1196 {
1197 for (x = 0; x < 4; x++)
1198 {
1199 value = ((WORD *)lock_rect.pBits)[y * pitch + x];
1200 v[0] = value >> 15;
1201 v[1] = value >> 10 & 0x1f;
1202 v[2] = value >> 5 & 0x1f;
1203 v[3] = value & 0x1f;
1204
1205 e[0] = 1;
1206 e[1] = (x + 0.5f) / 4.0f * 31.0f + 0.5f;
1207 e[2] = (y + 0.5f) / 4.0f * 31.0f + 0.5f;
1208 e[3] = 8;
1209 expected = e[0] << 15 | e[1] << 10 | e[2] << 5 | e[3];
1210
1211 ok(color_match(v, e),
1212 "Texel at (%u, %u) doesn't match: %#x, expected %#x\n",
1213 x, y, value, expected);
1214 }
1215 }
1217 }
1218
1220 }
1221 else
1222 skip("Failed to create texture\n");
1223
1224 /* test floating-point textures */
1226 D3DPOOL_MANAGED, &tex, NULL);
1227
1228 if (SUCCEEDED(hr))
1229 {
1231 ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1232
1233 hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1234 if (SUCCEEDED(hr))
1235 {
1236 pitch = lock_rect.Pitch / sizeof(WORD);
1237 for (y = 0; y < 4; y++)
1238 {
1239 WORD *ptr = (WORD *)lock_rect.pBits + y * pitch;
1240 for (x = 0; x < 4; x++)
1241 {
1242 D3DXVECTOR4 got, expected;
1243
1244 D3DXFloat16To32Array((FLOAT *)&got, (D3DXFLOAT16 *)ptr, 4);
1245 ptr += 4;
1246
1247 expected.x = (x + 0.5f) / 4.0f;
1248 expected.y = (y + 0.5f) / 4.0f;
1249 expected.z = 1.0f / 4.0f;
1250 expected.w = 1.0f;
1251
1252 expect_vec4(&expected, &got);
1253 }
1254 }
1255
1257 }
1258 else
1259 skip("Failed to lock texture\n");
1260
1262 }
1263 else
1264 skip("Failed to create D3DFMT_A16B16G16R16F texture\n");
1265
1267 D3DPOOL_MANAGED, &tex, NULL);
1268
1269 if (SUCCEEDED(hr))
1270 {
1272 ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1273
1274 hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1275 if (SUCCEEDED(hr))
1276 {
1277 pitch = lock_rect.Pitch / sizeof(float);
1278 for (y = 0; y < 4; y++)
1279 {
1280 float *ptr = (float *)lock_rect.pBits + y * pitch;
1281 for (x = 0; x < 4; x++)
1282 {
1283 D3DXVECTOR4 got, expected;
1284
1285 got.x = *ptr++;
1286 got.y = *ptr++;
1287 got.z = *ptr++;
1288 got.w = *ptr++;
1289
1290 expected.x = (x + 0.5f) / 4.0f;
1291 expected.y = (y + 0.5f) / 4.0f;
1292 expected.z = 1.0f / 4.0f;
1293 expected.w = 1.0f;
1294
1295 expect_vec4(&expected, &got);
1296 }
1297 }
1298
1300 }
1301 else
1302 skip("Failed to lock texture\n");
1303
1305 }
1306 else
1307 skip("Failed to create D3DFMT_A32B32G32R32F texture\n");
1308
1309 /* test a compressed texture */
1311 D3DPOOL_MANAGED, &tex, NULL);
1312
1313 if (SUCCEEDED(hr))
1314 {
1316 todo_wine ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1317
1319 }
1320 else
1321 skip("Failed to create D3DFMT_DXT1 texture\n");
1322}
#define ARRAY_SIZE(A)
Definition: main.h:33
@ D3DTEXF_NONE
Definition: d3d8types.h:870
@ D3DMULTISAMPLE_NONE
Definition: d3d8types.h:672
@ D3DFMT_D16
Definition: d3d8types.h:644
@ D3DFMT_D16_LOCKABLE
Definition: d3d8types.h:640
enum _D3DPOOL D3DPOOL
#define IDirect3DDevice9_StretchRect(p, a, b, c, d, e)
Definition: d3d9.h:1541
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1530
#define IDirect3DDevice9_CreateRenderTarget(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1535
@ D3DFMT_A32B32G32R32F
Definition: d3d9types.h:836
@ D3DFMT_A16B16G16R16F
Definition: d3d9types.h:831
FLOAT *WINAPI D3DXFloat16To32Array(FLOAT *pout, const D3DXFLOAT16 *pin, UINT n)
Definition: math.c:2221
HRESULT WINAPI D3DXFillTexture(struct IDirect3DTexture9 *texture, LPD3DXFILL2D function, void *funcdata)
Definition: texture.c:1323
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define for
Definition: utility.h:88
static PVOID ptr
Definition: dispmode.c:27
static void WINAPI fillfunc(D3DXVECTOR4 *value, const D3DXVECTOR2 *texcoord, const D3DXVECTOR2 *texelsize, void *data)
Definition: texture.c:1073
#define expect_vec4(expected, got)
Definition: texture.c:137
static float(__cdecl *square_half_float)(float x
float FLOAT
Definition: typedefs.h:69

Referenced by START_TEST().

◆ test_D3DXFillVolumeTexture()

static void test_D3DXFillVolumeTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1489 of file texture.c.

1490{
1491 IDirect3DVolumeTexture9 *tex;
1492 HRESULT hr;
1493 D3DLOCKED_BOX lock_box;
1494 DWORD x, y, z, m;
1495 DWORD v[4], e[4];
1496 DWORD value, expected, size, row_pitch, slice_pitch;
1497
1498 size = 4;
1500 D3DPOOL_DEFAULT, &tex, NULL);
1501 ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
1503 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
1505
1507 D3DPOOL_MANAGED, &tex, NULL);
1508 if (SUCCEEDED(hr))
1509 {
1511 ok(hr == D3D_OK, "D3DXFillVolumeTexture returned %#x, expected %#x\n", hr, D3D_OK);
1512
1513 for (m = 0; m < 3; m++)
1514 {
1516 ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1517 if (SUCCEEDED(hr))
1518 {
1519 row_pitch = lock_box.RowPitch / sizeof(DWORD);
1520 slice_pitch = lock_box.SlicePitch / sizeof(DWORD);
1521 for (z = 0; z < size; z++)
1522 {
1523 for (y = 0; y < size; y++)
1524 {
1525 for (x = 0; x < size; x++)
1526 {
1527 value = ((DWORD *)lock_box.pBits)[z * slice_pitch + y * row_pitch + x];
1528 v[0] = (value >> 24) & 0xff;
1529 v[1] = (value >> 16) & 0xff;
1530 v[2] = (value >> 8) & 0xff;
1531 v[3] = value & 0xff;
1532
1533 e[0] = 255.0f / size + 0.5f;
1534 e[1] = (x + 0.5f) / size * 255.0f + 0.5f;
1535 e[2] = (y + 0.5f) / size * 255.0f + 0.5f;
1536 e[3] = (z + 0.5f) / size * 255.0f + 0.5f;
1537 expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3];
1538
1539 ok(color_match(v, e),
1540 "Texel at (%u, %u, %u) doesn't match: %#x, expected %#x\n",
1541 x, y, z, value, expected);
1542 }
1543 }
1544 }
1546 }
1547 size >>= 1;
1548 }
1549
1551 }
1552 else
1553 skip("Failed to create texture\n");
1554
1556 D3DPOOL_MANAGED, &tex, NULL);
1557
1558 if (SUCCEEDED(hr))
1559 {
1561 ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK);
1563 ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr);
1564 if (SUCCEEDED(hr))
1565 {
1566 row_pitch = lock_box.RowPitch / sizeof(WORD);
1567 slice_pitch = lock_box.SlicePitch / sizeof(WORD);
1568 for (z = 0; z < 4; z++)
1569 {
1570 for (y = 0; y < 4; y++)
1571 {
1572 for (x = 0; x < 4; x++)
1573 {
1574 value = ((WORD *)lock_box.pBits)[z * slice_pitch + y * row_pitch + x];
1575 v[0] = value >> 15;
1576 v[1] = value >> 10 & 0x1f;
1577 v[2] = value >> 5 & 0x1f;
1578 v[3] = value & 0x1f;
1579
1580 e[0] = 1;
1581 e[1] = (x + 0.5f) / 4 * 31.0f + 0.5f;
1582 e[2] = (y + 0.5f) / 4 * 31.0f + 0.5f;
1583 e[3] = (z + 0.5f) / 4 * 31.0f + 0.5f;
1584 expected = e[0] << 15 | e[1] << 10 | e[2] << 5 | e[3];
1585
1586 ok(color_match(v, e),
1587 "Texel at (%u, %u, %u) doesn't match: %#x, expected %#x\n",
1588 x, y, z, value, expected);
1589 }
1590 }
1591 }
1593 }
1594
1596 }
1597 else
1598 skip("Failed to create texture\n");
1599}
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1531
#define IDirect3DVolumeTexture9_LockBox(p, a, b, c, d)
Definition: d3d9.h:1129
#define IDirect3DVolumeTexture9_UnlockBox(p, a)
Definition: d3d9.h:1130
HRESULT WINAPI D3DXFillVolumeTexture(struct IDirect3DVolumeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
Definition: texture.c:1769
GLdouble GLdouble z
Definition: glext.h:5874
static void WINAPI fillfunc_volume(D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
Definition: texture.c:1480

Referenced by START_TEST().

◆ test_D3DXFilterTexture()

static void test_D3DXFilterTexture ( IDirect3DDevice9 *  device)
static

Definition at line 915 of file texture.c.

916{
917 IDirect3DTexture9 *tex;
918 IDirect3DCubeTexture9 *cubetex;
919 IDirect3DVolumeTexture9 *voltex;
920 HRESULT hr;
921
923
924 if (SUCCEEDED(hr))
925 {
926 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, D3DX_DEFAULT, D3DX_FILTER_NONE);
927 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
928
929 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
930 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
931
932 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_BOX + 1); /* Invalid filter */
933 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
934
935 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 5, D3DX_FILTER_NONE); /* Invalid miplevel */
936 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
937
939 }
940 else
941 skip("Failed to create texture\n");
942
944 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
945
946 /* Test different pools */
948
949 if (SUCCEEDED(hr))
950 {
951 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
952 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
954 }
955 else
956 skip("Failed to create texture\n");
957
959
960 if (SUCCEEDED(hr))
961 {
962 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
963 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
965 }
966 else
967 skip("Failed to create texture\n");
968
970 if (SUCCEEDED(hr))
971 {
972 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_POINT);
973 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
975 }
976 else
977 skip("Failed to create texture\n");
978
980 if (SUCCEEDED(hr))
981 {
982 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_POINT);
983 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
985 }
986 else
987 skip("Failed to create texture\n");
988
989 /* Cube texture test */
991
992 if (SUCCEEDED(hr))
993 {
994 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 0, D3DX_FILTER_NONE);
995 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
996
997 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 0, D3DX_FILTER_BOX + 1); /* Invalid filter */
998 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
999
1000 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 5, D3DX_FILTER_NONE); /* Invalid miplevel */
1001 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1003 }
1004 else
1005 skip("Failed to create texture\n");
1006
1007 /* Volume texture test */
1009 if (SUCCEEDED(hr))
1010 {
1011 DWORD level_count = IDirect3DVolumeTexture9_GetLevelCount(voltex);
1012
1013 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_NONE);
1014 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
1015
1016 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_DEFAULT);
1017 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
1018
1019 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_BOX);
1020 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
1021
1022 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count - 1, D3DX_DEFAULT);
1023 ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
1024
1025 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count, D3DX_DEFAULT);
1026 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1027
1029 }
1030 else
1031 skip("Failed to create volume texture\n");
1032
1033 /* Test textures with D3DUSAGE_AUTOGENMIPMAP usage */
1035 {
1036 skip("No D3DUSAGE_AUTOGENMIPMAP supported for textures\n");
1037 return;
1038 }
1039
1041 if (SUCCEEDED(hr))
1042 {
1043 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
1044 ok(hr == D3D_OK, "D3dXFilteTexture returned %#x, expected %#x\n", hr, D3D_OK);
1046 }
1047 else
1048 skip("Failed to create texture\n");
1049
1051 if (SUCCEEDED(hr))
1052 {
1053 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
1054 ok(hr == D3D_OK, "D3dXFilteTexture returned %#x, expected %#x\n", hr, D3D_OK);
1056 }
1057 else
1058 skip("Failed to create texture\n");
1059}
@ D3DPOOL_SCRATCH
Definition: d3d8types.h:712
@ D3DPOOL_SYSTEMMEM
Definition: d3d8types.h:711
#define D3DX_FILTER_BOX
Definition: d3dx9tex.h:31
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
Definition: texture.c:52

Referenced by START_TEST().

◆ test_D3DXSaveTextureToFileInMemory()

static void test_D3DXSaveTextureToFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 2151 of file texture.c.

2152{
2153 HRESULT hr;
2154 IDirect3DTexture9 *texture;
2155 IDirect3DCubeTexture9 *cube_texture;
2156 IDirect3DVolumeTexture9 *volume_texture;
2158 void *buffer_pointer;
2161 D3DXIMAGE_FILEFORMAT file_format;
2162
2163 /* textures */
2165 if (FAILED(hr))
2166 {
2167 skip("Failed to create texture\n");
2168 return;
2169 }
2170
2171 for (file_format = D3DXIFF_BMP; file_format <= D3DXIFF_JPG; file_format++)
2172 {
2173 hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, (IDirect3DBaseTexture9 *)texture, NULL);
2174 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2175 if (SUCCEEDED(hr))
2176 {
2177 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
2180 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2181
2182 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
2183 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
2184 ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
2185 ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
2186 ok(info.ImageFileFormat == file_format, "Got file format %#x, expected %#x\n", info.ImageFileFormat, file_format);
2188 }
2189 }
2190
2191 todo_wine {
2192 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)texture, NULL);
2193 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2194 if (SUCCEEDED(hr))
2195 {
2196 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
2199 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2200
2201 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
2202 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
2203 ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
2204 ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
2205 ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
2207 }
2208 }
2209
2211
2212 /* cube textures */
2214 if (FAILED(hr))
2215 {
2216 skip("Failed to create cube texture\n");
2217 return;
2218 }
2219
2221 ok(hr == D3D_OK, "D3DXFillCubeTexture returned %#x, expected %#x\n", hr, D3D_OK);
2222
2223 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_BMP, (IDirect3DBaseTexture9 *)cube_texture, NULL);
2224 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2225 if (SUCCEEDED(hr))
2226 {
2227 IDirect3DSurface9 *surface;
2228
2229 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
2232 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2233
2234 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
2235 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
2236 ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
2237 ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
2238 ok(info.ImageFileFormat == D3DXIFF_BMP, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_BMP);
2239
2240 /* positive x face is saved */
2242 if (SUCCEEDED(hr))
2243 {
2244 D3DLOCKED_RECT locked_rect;
2245
2247 ok(hr == D3D_OK, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2248
2249 hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, D3DLOCK_READONLY);
2250 if (SUCCEEDED(hr))
2251 {
2252 DWORD *color = locked_rect.pBits;
2253 ok(*color == 0x00ff0000, "Got color %#x, expected %#x\n", *color, 0x00ff0000);
2255 }
2256
2258 } else skip("Failed to create surface\n");
2259
2261 }
2262
2263 todo_wine {
2264 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)cube_texture, NULL);
2265 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2266 if (SUCCEEDED(hr))
2267 {
2268 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
2271 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2272
2273 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
2274 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
2275 ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
2276 ok(info.ResourceType == D3DRTYPE_CUBETEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_CUBETEXTURE);
2277 ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
2279 }
2280 }
2281
2282 IDirect3DCubeTexture9_Release(cube_texture);
2283
2284 /* volume textures */
2285 hr = IDirect3DDevice9_CreateVolumeTexture(device, 256, 256, 256, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &volume_texture, NULL);
2286 if (FAILED(hr))
2287 {
2288 skip("Failed to create volume texture\n");
2289 return;
2290 }
2291
2292 todo_wine {
2293 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_BMP, (IDirect3DBaseTexture9 *)volume_texture, NULL);
2294 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2295 if (SUCCEEDED(hr))
2296 {
2297 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
2300 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2301
2302 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
2303 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
2304 ok(info.Depth == 1, "Got depth %u, expected %u\n", info.Depth, 1);
2305 ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
2306 ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
2307 ok(info.ImageFileFormat == D3DXIFF_BMP, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_BMP);
2309 }
2310
2311 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)volume_texture, NULL);
2312 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2313 if (SUCCEEDED(hr))
2314 {
2315 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
2318 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
2319
2320 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
2321 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
2322 ok(info.Depth == 256, "Got depth %u, expected %u\n", info.Depth, 256);
2323 ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
2324 ok(info.ResourceType == D3DRTYPE_VOLUMETEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_VOLUMETEXTURE);
2325 ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
2327 }
2328 }
2329
2330 IDirect3DVolumeTexture9_Release(volume_texture);
2331}
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
enum _D3DXIMAGE_FILEFORMAT D3DXIMAGE_FILEFORMAT
@ D3DXIFF_JPG
Definition: d3dx9tex.h:65
@ D3DXIFF_DDS
Definition: d3dx9tex.h:68
@ D3DXIFF_BMP
Definition: d3dx9tex.h:64
HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, D3DXIMAGE_INFO *info)
Definition: surface.c:985
HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
Definition: texture.c:1889
GLuint buffer
Definition: glext.h:5915
GLuint color
Definition: glext.h:6243
static void WINAPI fill_cube_positive_x(D3DXVECTOR4 *out, const D3DXVECTOR3 *tex_coord, const D3DXVECTOR3 *texel_size, void *data)
Definition: texture.c:2144
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888

Referenced by START_TEST().

◆ test_texture_shader()

static void test_texture_shader ( void  )
static

Definition at line 2333 of file texture.c.

2334{
2335 static const DWORD shader_zero[] = {0x0};
2336 static const DWORD shader_invalid[] = {0xeeee0100};
2337 static const DWORD shader_empty[] = {0xfffe0200, 0x0000ffff};
2338#if 0
2339float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR
2340{
2341 return float4(pos, 1.0);
2342}
2343#endif
2344 static const DWORD shader_code[] =
2345 {
2346 0x54580100, 0x0015fffe, 0x42415443, 0x0000001c, 0x0000001f, 0x54580100, 0x00000000, 0x00000000,
2347 0x00000100, 0x0000001c, 0x4d007874, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
2348 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072, 0x392e3932, 0x332e3235, 0x00313131, 0x000afffe,
2349 0x54494c43, 0x00000004, 0x00000000, 0x3ff00000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2350 0x00000000, 0x00000000, 0x0014fffe, 0x434c5846, 0x00000002, 0x10000003, 0x00000001, 0x00000000,
2351 0x00000003, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x10000001, 0x00000001, 0x00000000,
2352 0x00000001, 0x00000000, 0x00000000, 0x00000004, 0x00000003, 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff,
2353 };
2354 IDirect3DVolumeTexture9 *volume_texture;
2355 IDirect3DCubeTexture9 *cube_texture;
2357 IDirect3DTexture9 *texture;
2358 IDirect3DDevice9 *device;
2359 ID3DXTextureShader *tx;
2360 unsigned int x, y, z;
2362 unsigned int *data;
2363 D3DLOCKED_RECT lr;
2364 D3DLOCKED_BOX lb;
2365 IDirect3D9 *d3d;
2366 D3DCAPS9 caps;
2367 HRESULT hr;
2368 HWND wnd;
2369
2371 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
2372
2374 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
2375
2377 todo_wine ok(hr == D3DXERR_INVALIDDATA, "Got unexpected hr %#x.\n", hr);
2378
2380 todo_wine ok(hr ==