ReactOS 0.4.17-dev-966-gf06eace
texture.c File Reference
#include "wine/test.h"
#include "d3dx9tex.h"
#include "resources.h"
#include <stdint.h>
#include "d3dx9_test_images.h"
Include dependency graph for texture.c:

Go to the source code of this file.

Classes

struct  surface_readback
 

Macros

#define COBJMACROS
 
#define ADMITTED_ERROR   0.0001f
 
#define expect_vec4(expected, got)   expect_vec4_(__LINE__, expected, got)
 
#define check_texture_level_desc(tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, width, height, wine_todo)
 
#define check_cube_texture_level_desc(tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, size, wine_todo)
 
#define check_volume_texture_level_desc(tex, level, format, usage, pool, width, height, depth, wine_todo)    check_volume_texture_level_desc_(__LINE__, tex, level, format, usage, pool, width, height, depth, wine_todo)
 
#define check_texture_mip_levels(tex, expected_mip_levels, wine_todo)    check_texture_mip_levels_(__LINE__, ((IDirect3DBaseTexture9 *)tex), expected_mip_levels, wine_todo)
 
#define check_readback_pixel_4bpp(rb, x, y, color, todo)   _check_readback_pixel_4bpp(__LINE__, rb, x, y, color, todo)
 
#define compare_cube_texture(t, f, d)   compare_cube_texture_(t,f,d,__LINE__)
 

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 void check_surface_desc (uint32_t line, D3DFORMAT format, uint32_t usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multi_sample_type, uint32_t multi_sample_quality, uint32_t width, uint32_t height, const D3DSURFACE_DESC *desc, BOOL wine_todo)
 
static void check_texture_level_desc_ (uint32_t line, IDirect3DTexture9 *tex, uint32_t level, D3DFORMAT format, uint32_t usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multi_sample_type, uint32_t multi_sample_quality, uint32_t width, uint32_t height, BOOL wine_todo)
 
static void check_cube_texture_level_desc_ (uint32_t line, IDirect3DCubeTexture9 *tex, uint32_t level, D3DFORMAT format, uint32_t usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multi_sample_type, uint32_t multi_sample_quality, uint32_t size, BOOL wine_todo)
 
static void check_volume_texture_level_desc_ (uint32_t line, IDirect3DVolumeTexture9 *tex, uint32_t level, D3DFORMAT format, uint32_t usage, D3DPOOL pool, uint32_t width, uint32_t height, uint32_t depth, BOOL wine_todo)
 
static void check_texture_mip_levels_ (uint32_t line, IDirect3DBaseTexture9 *tex, uint32_t expected_mip_levels, BOOL wine_todo)
 
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 uint32_t get_readback_color (struct surface_readback *rb, uint32_t x, uint32_t y)
 
static void release_surface_readback (struct surface_readback *rb)
 
static void get_surface_readback (IDirect3DDevice9 *device, IDirect3DSurface9 *surface, struct surface_readback *rb)
 
static void get_texture_surface_readback (IDirect3DDevice9 *device, IDirect3DTexture9 *texture, uint32_t mip_level, struct surface_readback *rb)
 
static void get_cube_texture_surface_readback (IDirect3DDevice9 *device, IDirect3DCubeTexture9 *texture, uint32_t face, uint32_t mip_level, struct surface_readback *rb)
 
static void _check_readback_pixel_4bpp (uint32_t line, struct surface_readback *rb, uint32_t x, uint32_t y, uint32_t expected_color, BOOL todo)
 
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 void WINAPI fillfunc_cube_coord (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 DWORD get_argb_color (D3DFORMAT format, DWORD x, DWORD y, const D3DLOCKED_RECT *lock_rect)
 
static BYTE get_s8_clipped (float v)
 
static DWORD get_expected_argb_color (D3DFORMAT format, const D3DXVECTOR4 *v)
 
static void compare_cube_texture_ (IDirect3DCubeTexture9 *texture, LPD3DXFILL3D func, BYTE diff, unsigned int line)
 
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
 

Macro Definition Documentation

◆ ADMITTED_ERROR

#define ADMITTED_ERROR   0.0001f

Definition at line 32 of file texture.c.

◆ check_cube_texture_level_desc

#define check_cube_texture_level_desc (   tex,
  level,
  format,
  usage,
  pool,
  multi_sample_type,
  multi_sample_quality,
  size,
  wine_todo 
)
Value:
check_cube_texture_level_desc_(__LINE__, tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, \
size, wine_todo)
GLint level
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
static void check_cube_texture_level_desc_(uint32_t line, IDirect3DCubeTexture9 *tex, uint32_t level, D3DFORMAT format, uint32_t usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multi_sample_type, uint32_t multi_sample_quality, uint32_t size, BOOL wine_todo)
Definition: texture.c:108

Definition at line 104 of file texture.c.

◆ check_readback_pixel_4bpp

#define check_readback_pixel_4bpp (   rb,
  x,
  y,
  color,
  todo 
)    _check_readback_pixel_4bpp(__LINE__, rb, x, y, color, todo)

Definition at line 285 of file texture.c.

◆ check_texture_level_desc

#define check_texture_level_desc (   tex,
  level,
  format,
  usage,
  pool,
  multi_sample_type,
  multi_sample_quality,
  width,
  height,
  wine_todo 
)
Value:
check_texture_level_desc_(__LINE__, tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, \
width, height, wine_todo)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
static void check_texture_level_desc_(uint32_t line, IDirect3DTexture9 *tex, uint32_t level, D3DFORMAT format, uint32_t usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multi_sample_type, uint32_t multi_sample_quality, uint32_t width, uint32_t height, BOOL wine_todo)
Definition: texture.c:87

Definition at line 83 of file texture.c.

◆ check_texture_mip_levels

#define check_texture_mip_levels (   tex,
  expected_mip_levels,
  wine_todo 
)     check_texture_mip_levels_(__LINE__, ((IDirect3DBaseTexture9 *)tex), expected_mip_levels, wine_todo)

Definition at line 160 of file texture.c.

◆ check_volume_texture_level_desc

#define check_volume_texture_level_desc (   tex,
  level,
  format,
  usage,
  pool,
  width,
  height,
  depth,
  wine_todo 
)     check_volume_texture_level_desc_(__LINE__, tex, level, format, usage, pool, width, height, depth, wine_todo)

Definition at line 124 of file texture.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file texture.c.

◆ compare_cube_texture

#define compare_cube_texture (   t,
  f,
  d 
)    compare_cube_texture_(t,f,d,__LINE__)

Definition at line 1593 of file texture.c.

◆ expect_vec4

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

Definition at line 39 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 1510 of file texture.c.

1511{
1512 XCOORD = 0,
1513 XCOORDINV = 1,
1514 YCOORD = 2,
1515 YCOORDINV = 3,
1516 ZERO = 4,
1517 ONE = 5
1518};
@ XCOORDINV
Definition: texture.c:1628
@ ONE
Definition: texture.c:1632
@ YCOORDINV
Definition: texture.c:1630
@ XCOORD
Definition: texture.c:1627
@ ZERO
Definition: texture.c:1631
@ YCOORD
Definition: texture.c:1629

Function Documentation

◆ _check_readback_pixel_4bpp()

static void _check_readback_pixel_4bpp ( uint32_t  line,
struct surface_readback *  rb,
uint32_t  x,
uint32_t  y,
uint32_t  expected_color,
BOOL  todo 
)
inlinestatic

Definition at line 286 of file texture.c.

288{
290 todo_wine_if(todo) ok_(__FILE__, line)(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
291}
#define ok_(x1, x2)
Definition: atltest.h:61
UINT32 uint32_t
Definition: types.h:75
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint color
Definition: glext.h:6243
#define todo_wine_if(is_todo)
Definition: minitest.h:81
BOOL todo
Definition: filedlg.c:313
static uint32_t get_readback_color(struct surface_readback *rb, uint32_t x, uint32_t y)
Definition: texture.c:192
Definition: parser.c:49

◆ check_cube_texture_level_desc_()

static void check_cube_texture_level_desc_ ( uint32_t  line,
IDirect3DCubeTexture9 *  tex,
uint32_t  level,
D3DFORMAT  format,
uint32_t  usage,
D3DPOOL  pool,
D3DMULTISAMPLE_TYPE  multi_sample_type,
uint32_t  multi_sample_quality,
uint32_t  size,
BOOL  wine_todo 
)
inlinestatic

Definition at line 108 of file texture.c.

111{
113 HRESULT hr;
114
116 todo_wine_if(wine_todo && FAILED(hr))
117 ok_(__FILE__, line)(hr == S_OK, "Failed to get cube texture level desc with hr %#lx.\n", hr);
118 if (FAILED(hr))
119 return;
120
121 check_surface_desc(line, format, usage, pool, multi_sample_type, multi_sample_quality, size, size, &desc, wine_todo);
122}
#define IDirect3DCubeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:765
HRESULT hr
Definition: delayimp.cpp:582
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
static void check_surface_desc(uint32_t line, D3DFORMAT format, uint32_t usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multi_sample_type, uint32_t multi_sample_quality, uint32_t width, uint32_t height, const D3DSURFACE_DESC *desc, BOOL wine_todo)
Definition: texture.c:51

◆ check_surface_desc()

static void check_surface_desc ( uint32_t  line,
D3DFORMAT  format,
uint32_t  usage,
D3DPOOL  pool,
D3DMULTISAMPLE_TYPE  multi_sample_type,
uint32_t  multi_sample_quality,
uint32_t  width,
uint32_t  height,
const D3DSURFACE_DESC *  desc,
BOOL  wine_todo 
)
inlinestatic

Definition at line 51 of file texture.c.

54{
55 const D3DSURFACE_DESC expected_desc = { format, D3DRTYPE_SURFACE, usage, pool, multi_sample_type,
56 multi_sample_quality, width, height };
58
59 matched = !memcmp(&expected_desc, desc, sizeof(*desc));
60 todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected surface desc values.\n");
61 if (matched)
62 return;
63
64 todo_wine_if(wine_todo && desc->Format != format)
65 ok_(__FILE__, line)(desc->Format == format, "Expected surface format %d, got %d.\n", format, desc->Format);
66 ok_(__FILE__, line)(desc->Type == D3DRTYPE_SURFACE, "Expected D3DRTYPE_SURFACE, got %d.\n", desc->Type);
67 todo_wine_if(wine_todo && desc->Usage != usage)
68 ok_(__FILE__, line)(desc->Usage == usage, "Expected usage %u, got %lu.\n", usage, desc->Usage);
69 todo_wine_if(wine_todo && desc->Pool != pool)
70 ok_(__FILE__, line)(desc->Pool == pool, "Expected pool %d, got %d.\n", pool, desc->Pool);
71 todo_wine_if(wine_todo && desc->MultiSampleType != multi_sample_type)
72 ok_(__FILE__, line)(desc->MultiSampleType == multi_sample_type, "Expected multi sample type %d, got %d.\n",
73 multi_sample_type, desc->MultiSampleType);
74 todo_wine_if(wine_todo && desc->MultiSampleQuality != multi_sample_quality)
75 ok_(__FILE__, line)(desc->MultiSampleQuality == multi_sample_quality, "Expected multi sample quality %u, got %lu.\n",
76 multi_sample_quality, desc->MultiSampleQuality);
77 todo_wine_if(wine_todo && desc->Width != width)
78 ok_(__FILE__, line)(desc->Width == width, "Expected width %d, got %d.\n", width, desc->Width);
79 todo_wine_if(wine_todo && desc->Height != height)
80 ok_(__FILE__, line)(desc->Height == height, "Expected height %d, got %d.\n", height, desc->Height);
81}
@ D3DRTYPE_SURFACE
Definition: d3d8types.h:810
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL matched
Definition: taskkill.c:46

Referenced by check_cube_texture_level_desc_(), and check_texture_level_desc_().

◆ check_texture_level_desc_()

static void check_texture_level_desc_ ( uint32_t  line,
IDirect3DTexture9 *  tex,
uint32_t  level,
D3DFORMAT  format,
uint32_t  usage,
D3DPOOL  pool,
D3DMULTISAMPLE_TYPE  multi_sample_type,
uint32_t  multi_sample_quality,
uint32_t  width,
uint32_t  height,
BOOL  wine_todo 
)
inlinestatic

Definition at line 87 of file texture.c.

90{
92 HRESULT hr;
93
95 todo_wine_if(wine_todo && FAILED(hr))
96 ok_(__FILE__, line)(hr == S_OK, "Failed to get texture level desc with hr %#lx.\n", hr);
97 if (FAILED(hr))
98 return;
99
100 check_surface_desc(line, format, usage, pool, multi_sample_type, multi_sample_quality, width, height, &desc,
101 wine_todo);
102}
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:860

◆ check_texture_mip_levels_()

static void check_texture_mip_levels_ ( uint32_t  line,
IDirect3DBaseTexture9 *  tex,
uint32_t  expected_mip_levels,
BOOL  wine_todo 
)
inlinestatic

Definition at line 162 of file texture.c.

164{
166
167 todo_wine_if(wine_todo) ok_(__FILE__, line)(mip_levels == expected_mip_levels, "Got miplevels %u, expected %u.\n",
168 mip_levels, expected_mip_levels);
169}
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:676

◆ check_volume_texture_level_desc_()

static void check_volume_texture_level_desc_ ( uint32_t  line,
IDirect3DVolumeTexture9 *  tex,
uint32_t  level,
D3DFORMAT  format,
uint32_t  usage,
D3DPOOL  pool,
uint32_t  width,
uint32_t  height,
uint32_t  depth,
BOOL  wine_todo 
)
inlinestatic

Definition at line 126 of file texture.c.

128{
129 const D3DVOLUME_DESC expected_desc = { format, D3DRTYPE_VOLUME, usage, pool, width, height, depth };
132 HRESULT hr;
133
135 todo_wine_if(wine_todo && FAILED(hr))
136 ok_(__FILE__, line)(hr == S_OK, "Failed to get texture level desc with hr %#lx.\n", hr);
137 if (FAILED(hr))
138 return;
139
140 matched = !memcmp(&expected_desc, &desc, sizeof(desc));
141 todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected volume desc values.\n");
142 if (matched)
143 return;
144
145 todo_wine_if(wine_todo && desc.Format != format)
146 ok_(__FILE__, line)(desc.Format == format, "Expected volume format %d, got %d.\n", format, desc.Format);
147 ok_(__FILE__, line)(desc.Type == D3DRTYPE_VOLUME, "Expected D3DRTYPE_VOLUME, got %d.\n", desc.Type);
148 todo_wine_if(wine_todo && desc.Usage != usage)
149 ok_(__FILE__, line)(desc.Usage == usage, "Expected usage %u, got %lu.\n", usage, desc.Usage);
150 todo_wine_if(wine_todo && desc.Pool != pool)
151 ok_(__FILE__, line)(desc.Pool == pool, "Expected pool %d, got %d.\n", pool, desc.Pool);
152 todo_wine_if(wine_todo && desc.Width != width)
153 ok_(__FILE__, line)(desc.Width == width, "Expected width %u, got %u.\n", width, desc.Width);
154 todo_wine_if(wine_todo && desc.Height != height)
155 ok_(__FILE__, line)(desc.Height == height, "Expected height %u, got %u.\n", height, desc.Height);
156 todo_wine_if(wine_todo && desc.Depth != depth)
157 ok_(__FILE__, line)(desc.Depth == depth, "Expected depth %u, got %u.\n", depth, desc.Depth);
158}
@ D3DRTYPE_VOLUME
Definition: d3d8types.h:811
#define IDirect3DVolumeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:955
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546

◆ color_match()

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

Definition at line 1229 of file texture.c.

1230{
1231 int i;
1232
1233 for (i = 0; i < 4; i++)
1234 {
1235 DWORD diff = value[i] > expected[i] ? value[i] - expected[i] : expected[i] - value[i];
1236 if (diff > 1) return FALSE;
1237 }
1238 return TRUE;
1239}
#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:2000
Definition: pdh_main.c:64

Referenced by test_D3DXFillTexture(), and test_D3DXFillVolumeTexture().

◆ compare_color()

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

Definition at line 178 of file texture.c.

179{
180 return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
181 && compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff)
182 && compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff)
183 && compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff);
184}
static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
Definition: texture.c:171

Referenced by compare_cube_texture_(), test_D3DXCreateTextureFromFileInMemory(), and test_texture_shader().

◆ compare_cube_texture_()

static void compare_cube_texture_ ( IDirect3DCubeTexture9 *  texture,
LPD3DXFILL3D  func,
BYTE  diff,
unsigned int  line 
)
static

Definition at line 1594 of file texture.c.

1596{
1597 static const enum cube_coord coordmap[6][3] =
1598 {
1600 {ZERO, YCOORDINV, XCOORD},
1601 {XCOORD, ONE, YCOORD},
1602 {XCOORD, ZERO, YCOORDINV},
1603 {XCOORD, YCOORDINV, ONE},
1605 };
1606
1607 DWORD x, y, m, f, levels, size, value, expected;
1608 D3DXVECTOR3 coord, texelsize;
1609 D3DLOCKED_RECT lock_rect;
1612 HRESULT hr;
1613
1615
1616 for (m = 0; m < levels; ++m)
1617 {
1619 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1620
1621 size = desc.Width;
1622
1623 for (f = 0; f < 6; f++)
1624 {
1625 texelsize.x = (f == 0) || (f == 1) ? 0.0f : 2.0f / size;
1626 texelsize.y = (f == 2) || (f == 3) ? 0.0f : 2.0f / size;
1627 texelsize.z = (f == 4) || (f == 5) ? 0.0f : 2.0f / size;
1628
1630 ok(hr == D3D_OK, "Couldn't lock the texture, error %#lx.\n", hr);
1631
1632 for (y = 0; y < size; y++)
1633 {
1634 for (x = 0; x < size; x++)
1635 {
1636 coord.x = get_cube_coord(coordmap[f][0], x, y, size) / size * 2.0f - 1.0f;
1637 coord.y = get_cube_coord(coordmap[f][1], x, y, size) / size * 2.0f - 1.0f;
1638 coord.z = get_cube_coord(coordmap[f][2], x, y, size) / size * 2.0f - 1.0f;
1639
1640 func(&out, &coord, &texelsize, NULL);
1641
1642 value = get_argb_color(desc.Format, x, y, &lock_rect);
1644
1645 ok_(__FILE__, line)(compare_color(value, expected, diff),
1646 "Texel at face %lu (%lu, %lu) doesn't match: %08lx, expected %08lx.\n",
1647 f, x, y, value, expected);
1648 }
1649 }
1651 }
1652 }
1653}
#define ok(value,...)
Definition: atltest.h:57
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define IDirect3DCubeTexture9_UnlockRect(p, a, b)
Definition: d3d9.h:768
#define IDirect3DCubeTexture9_LockRect(p, a, b, c, d, e)
Definition: d3d9.h:767
#define IDirect3DCubeTexture9_GetLevelCount(p)
Definition: d3d9.h:760
#define D3D_OK
Definition: d3d.h:106
#define NULL
Definition: types.h:112
static float get_cube_coord(enum cube_coord coord, unsigned int x, unsigned int y, unsigned int size)
Definition: texture.c:1635
cube_coord
Definition: texture.c:1626
GLenum func
Definition: glext.h:6028
GLenum GLuint texture
Definition: glext.h:6295
GLuint coord
Definition: glext.h:9511
GLfloat f
Definition: glext.h:7540
GLsizei levels
Definition: glext.h:7884
const GLfloat * m
Definition: glext.h:10848
#define f
Definition: ke_i.h:83
static DWORD get_expected_argb_color(D3DFORMAT format, const D3DXVECTOR4 *v)
Definition: texture.c:1573
static BOOL compare_color(DWORD c1, DWORD c2, BYTE max_diff)
Definition: texture.c:178
static DWORD get_argb_color(D3DFORMAT format, DWORD x, DWORD y, const D3DLOCKED_RECT *lock_rect)
Definition: texture.c:1542
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ compare_uint()

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

Definition at line 171 of file texture.c.

172{
173 unsigned int diff = x > y ? x - y : y - x;
174
175 return diff <= max_diff;
176}

Referenced by compare_color().

◆ expect_vec4_()

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

Definition at line 40 of file texture.c.

41{
42 ok_(__FILE__, line)(relative_error(expected->x, got->x) < ADMITTED_ERROR
46 "Expected (%f, %f, %f, %f), got (%f, %f, %f, %f)\n",
47 expected->x, expected->y, expected->z, expected->w,
48 got->x, got->y, got->z, got->w);
49}
#define relative_error(exp, out)
Definition: line.c:25
#define ADMITTED_ERROR
Definition: texture.c:32

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

3093{
3094 memset(out, 0, sizeof(*out));
3095 if (tex_coord->x > 0 && fabs(tex_coord->x) > fabs(tex_coord->y) && fabs(tex_coord->x) > fabs(tex_coord->z))
3096 out->x = 1;
3097}
_ACRTIMP double __cdecl fabs(double)
#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 1241 of file texture.c.

1243{
1244 value->x = texcoord->x;
1245 value->y = texcoord->y;
1246 value->z = texelsize->x;
1247 value->w = 1.0f;
1248}
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 1492 of file texture.c.

1494{
1495 value->x = (texcoord->x + 1.0f) / 2.0f;
1496 value->y = (texcoord->y + 1.0f) / 2.0f;
1497 value->z = (texcoord->z + 1.0f) / 2.0f;
1498 value->w = texelsize->x;
1499}

Referenced by test_D3DXFillCubeTexture().

◆ fillfunc_cube_coord()

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

Definition at line 1501 of file texture.c.

1503{
1504 value->x = texcoord->x;
1505 value->y = texcoord->y;
1506 value->z = texcoord->z;
1507 value->w = 1.0f;
1508}

Referenced by test_D3DXFillCubeTexture(), and test_texture_shader().

◆ fillfunc_volume()

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

Definition at line 1690 of file texture.c.

1692{
1693 value->x = texcoord->x;
1694 value->y = texcoord->y;
1695 value->z = texcoord->z;
1696 value->w = texelsize->x;
1697}

Referenced by test_D3DXFillVolumeTexture().

◆ get_argb_color()

static DWORD get_argb_color ( D3DFORMAT  format,
DWORD  x,
DWORD  y,
const D3DLOCKED_RECT *  lock_rect 
)
static

Definition at line 1542 of file texture.c.

1543{
1544 DWORD value, ret;
1545 int pitch;
1546
1547 switch (format)
1548 {
1549 case D3DFMT_A8R8G8B8:
1550 pitch = lock_rect->Pitch / sizeof(DWORD);
1551 return ((DWORD *)lock_rect->pBits)[y * pitch + x];
1552 case D3DFMT_A1R5G5B5:
1553 pitch = lock_rect->Pitch / sizeof(WORD);
1554 value = ((WORD *)lock_rect->pBits)[y * pitch + x];
1555
1556 ret = (value >> 15 & 0x1) << 24
1557 | (value >> 10 & 0x1f) << 16
1558 | (value >> 5 & 0x1f) << 8
1559 | (value & 0x1f);
1560
1561 return ret;
1562
1563 default:
1564 return 0;
1565 }
1566}
@ D3DFMT_A1R5G5B5
Definition: d3d8types.h:608
@ D3DFMT_A8R8G8B8
Definition: d3d8types.h:604
return ret
Definition: mutex.c:147
unsigned short WORD
Definition: ntddk_ex.h:93
#define DWORD
Definition: nt_native.h:44

Referenced by compare_cube_texture_().

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

1521{
1522 switch (coord)
1523 {
1524 case XCOORD:
1525 return x + 0.5f;
1526 case XCOORDINV:
1527 return size - x - 0.5f;
1528 case YCOORD:
1529 return y + 0.5f;
1530 case YCOORDINV:
1531 return size - y - 0.5f;
1532 case ZERO:
1533 return 0.0f;
1534 case ONE:
1535 return size;
1536 default:
1537 trace("Unexpected coordinate value\n");
1538 return 0.0f;
1539 }
1540}
#define trace
Definition: atltest.h:70

◆ get_cube_texture_surface_readback()

static void get_cube_texture_surface_readback ( IDirect3DDevice9 *  device,
IDirect3DCubeTexture9 *  texture,
uint32_t  face,
uint32_t  mip_level,
struct surface_readback *  rb 
)
static

Definition at line 267 of file texture.c.

269{
270 IDirect3DSurface9 *surface;
271 HRESULT hr;
272
273 memset(rb, 0, sizeof(*rb));
275 if (FAILED(hr))
276 {
277 trace("Failed to get surface for face %d mip level %d, hr %#lx.\n", face, mip_level, hr);
278 return;
279 }
280
281 get_surface_readback(device, surface, rb);
283}
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:450
#define IDirect3DCubeTexture9_GetCubeMapSurface(p, a, b, c)
Definition: d3d9.h:766
DWORD IDirect3DSurface9
Definition: dxva2api.idl:23
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
static void get_surface_readback(IDirect3DDevice9 *device, IDirect3DSurface9 *surface, struct surface_readback *rb)
Definition: texture.c:209
Definition: devices.h:37

Referenced by test_D3DXCreateCubeTextureFromFileInMemoryEx().

◆ get_expected_argb_color()

static DWORD get_expected_argb_color ( D3DFORMAT  format,
const D3DXVECTOR4 *  v 
)
static

Definition at line 1573 of file texture.c.

1574{
1575 switch (format)
1576 {
1577 case D3DFMT_A8R8G8B8:
1578 return get_s8_clipped(v->w) << 24
1579 | get_s8_clipped(v->x) << 16
1580 | get_s8_clipped(v->y) << 8
1581 | get_s8_clipped(v->z);
1582
1583 case D3DFMT_A1R5G5B5:
1584 return (BYTE)(v->w + 0.5f) << 24
1585 | (BYTE)(v->x * 31 + 0.5f) << 16
1586 | (BYTE)(v->y * 31 + 0.5f) << 8
1587 | (BYTE)(v->z * 31 + 0.5f);
1588 default:
1589 return 0;
1590 }
1591}
const GLdouble * v
Definition: gl.h:2040
static BYTE get_s8_clipped(float v)
Definition: texture.c:1568
unsigned char BYTE
Definition: xxhash.c:193

Referenced by compare_cube_texture_().

◆ get_readback_color()

static uint32_t get_readback_color ( struct surface_readback *  rb,
uint32_t  x,
uint32_t  y 
)
static

Definition at line 192 of file texture.c.

193{
194 return rb->locked_rect.pBits
195 ? ((uint32_t *)rb->locked_rect.pBits)[y * rb->locked_rect.Pitch / sizeof(uint32_t) + x] : 0xdeadbeef;
196}
#define uint32_t
Definition: nsiface.idl:61
D3DLOCKED_RECT locked_rect
Definition: shader.c:419

Referenced by _check_readback_pixel_4bpp().

◆ get_s8_clipped()

static BYTE get_s8_clipped ( float  v)
static

Definition at line 1568 of file texture.c.

1569{
1570 return (BYTE)(v >= 0.0f ? v * 255 + 0.5f : 0.0f);
1571}

Referenced by get_expected_argb_color().

◆ get_surface_readback()

static void get_surface_readback ( IDirect3DDevice9 *  device,
IDirect3DSurface9 *  surface,
struct surface_readback *  rb 
)
static

Definition at line 209 of file texture.c.

210{
212 HRESULT hr;
213
214 hr = IDirect3DSurface9_GetDesc(surface, &desc);
215 if (FAILED(hr))
216 {
217 trace("Failed to get surface description, hr %#lx.\n", hr);
218 goto exit;
219 }
220
222 &rb->surface, NULL);
223 if (FAILED(hr))
224 {
225 trace("Can't create the readback surface, hr %#lx.\n", hr);
226 goto exit;
227 }
228
230 if (FAILED(hr))
231 {
232 trace("Can't load the readback surface, hr %#lx.\n", hr);
233 goto exit;
234 }
235
237 if (FAILED(hr))
238 trace("Can't lock the readback surface, hr %#lx.\n", hr);
239
240exit:
241 if (FAILED(hr))
242 {
243 if (rb->surface)
245 rb->surface = NULL;
246 }
247}
@ D3DPOOL_SYSTEMMEM
Definition: d3d8types.h:711
#define IDirect3DSurface9_LockRect(p, a, b, c)
Definition: d3d9.h:463
#define IDirect3DSurface9_GetDesc(p, a)
Definition: d3d9.h:462
#define IDirect3DDevice9_CreateOffscreenPlainSurface(p, a, b, c, d, e, f)
Definition: d3d9.h:1371
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:2765
#define D3DX_FILTER_NONE
Definition: d3dx9tex.h:27
#define exit(n)
Definition: config.h:202
IDirect3DSurface9 * surface
Definition: shader.c:418

Referenced by get_cube_texture_surface_readback(), and get_texture_surface_readback().

◆ get_texture_surface_readback()

static void get_texture_surface_readback ( IDirect3DDevice9 *  device,
IDirect3DTexture9 *  texture,
uint32_t  mip_level,
struct surface_readback *  rb 
)
static

Definition at line 249 of file texture.c.

251{
252 IDirect3DSurface9 *surface;
253 HRESULT hr;
254
255 memset(rb, 0, sizeof(*rb));
256 hr = IDirect3DTexture9_GetSurfaceLevel(texture, mip_level, &surface);
257 if (FAILED(hr))
258 {
259 trace("Failed to get surface for mip level %d, hr %#lx.\n", mip_level, hr);
260 return;
261 }
262
263 get_surface_readback(device, surface, rb);
265}
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:861

Referenced by test_D3DXCreateTextureFromFileInMemory(), and test_D3DXCreateTextureFromFileInMemoryEx().

◆ is_autogenmipmap_supported()

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

Definition at line 293 of file texture.c.

294{
295 HRESULT hr;
296 D3DCAPS9 caps;
297 IDirect3D9 *d3d9;
300
305
306 if (!(caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP))
307 return FALSE;
308
309 hr = IDirect3D9_CheckDeviceFormat(d3d9, params.AdapterOrdinal, params.DeviceType,
310 mode.Format, D3DUSAGE_AUTOGENMIPMAP, resource_type, D3DFMT_A8R8G8B8);
311
313 return hr == D3D_OK;
314}
#define IDirect3DDevice9_GetDirect3D(p, a)
Definition: d3d9.h:1341
#define IDirect3DDevice9_GetCreationParameters(p, a)
Definition: d3d9.h:1344
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1342
#define IDirect3D9_Release(p)
Definition: d3d9.h:209
#define IDirect3D9_CheckDeviceFormat(p, a, b, c, d, e, f)
Definition: d3d9.h:218
#define IDirect3DDevice9_GetDisplayMode(p, a, b)
Definition: d3d9.h:1343
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define D3DCAPS2_CANAUTOGENMIPMAP
Definition: d3d9caps.h:22
GLenum mode
Definition: glext.h:6217
GLenum const GLfloat * params
Definition: glext.h:5645
DWORD Caps2
Definition: d3d9caps.h:267

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

35{
36 return expected == 0.0f ? fabs(expected - got) : fabs(1.0f - got / expected);
37}

◆ release_surface_readback()

static void release_surface_readback ( struct surface_readback *  rb)
static

Definition at line 198 of file texture.c.

199{
200 HRESULT hr;
201
202 if (!rb->surface)
203 return;
205 trace("Can't unlock the readback surface, hr %#lx.\n", hr);
207}
#define IDirect3DSurface9_UnlockRect(p)
Definition: d3d9.h:464

Referenced by test_D3DXCreateCubeTextureFromFileInMemoryEx(), test_D3DXCreateTextureFromFileInMemory(), and test_D3DXCreateTextureFromFileInMemoryEx().

◆ START_TEST()

START_TEST ( texture  )

Definition at line 3691 of file texture.c.

3692{
3693 HWND wnd;
3694 IDirect3D9 *d3d;
3697 HRESULT hr;
3698 ULONG ref;
3699
3700 if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
3701 640, 480, NULL, NULL, NULL, NULL)))
3702 {
3703 skip("Couldn't create application window\n");
3704 return;
3705 }
3707 if (!d3d) {
3708 skip("Couldn't create IDirect3D9 object\n");
3709 DestroyWindow(wnd);
3710 return;
3711 }
3712
3713 ZeroMemory(&d3dpp, sizeof(d3dpp));
3714 d3dpp.Windowed = TRUE;
3717 if (FAILED(hr)) {
3718 skip("Failed to create IDirect3DDevice9 object %#lx\n", hr);
3719 IDirect3D9_Release(d3d);
3720 DestroyWindow(wnd);
3721 return;
3722 }
3723
3724 /* Check whether DXTn textures are supported. */
3735 trace("DXTn texture support: 2D DXT1 %#x, 2D DXT3 %#x, 2D DXT5 %#x, cube DXT5 %#x, 3D dxt3 %#x.\n",
3737
3753
3755 ok(!ref, "Device has %lu references left.\n", ref);
3756
3757 IDirect3D9_Release(d3d);
3758 DestroyWindow(wnd);
3759
3761}
#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:224
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1336
DWORD IDirect3DDevice9
Definition: dxva2api.idl:22
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define ZeroMemory
Definition: minwinbase.h:31
static void test_D3DXSaveTextureToFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:3099
static int has_2d_dxt5
Definition: texture.c:30
static void test_D3DXCheckCubeTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:623
static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:2521
static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:316
static int has_3d_dxt3
Definition: texture.c:30
static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:2814
static void test_D3DXCreateTexture(IDirect3DDevice9 *device)
Definition: texture.c:845
static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
Definition: texture.c:2856
static int has_cube_dxt5
Definition: texture.c:30
static void test_D3DXFilterTexture(IDirect3DDevice9 *device)
Definition: texture.c:1052
static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
Definition: texture.c:2150
static void test_D3DXCheckVolumeTextureRequirements(IDirect3DDevice9 *device)
Definition: texture.c:724
static void test_texture_shader(void)
Definition: texture.c:3281
static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
Definition: texture.c:1811
static int has_2d_dxt3
Definition: texture.c:30
static int has_2d_dxt1
Definition: texture.c:30
static void test_D3DXFillCubeTexture(IDirect3DDevice9 *device)
Definition: texture.c:1655
static void test_D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
Definition: texture.c:2563
static void test_D3DXFillVolumeTexture(IDirect3DDevice9 *device)
Definition: texture.c:1699
static void test_D3DXFillTexture(IDirect3DDevice9 *device)
Definition: texture.c:1250
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
BOOL WINAPI DestroyWindow(_In_ HWND)
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:53
#define D3D_SDK_VERSION
Definition: d3d8.h:52
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING
Definition: d3d8.h:40
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ test_D3DXCheckCubeTextureRequirements()

static void test_D3DXCheckCubeTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 623 of file texture.c.

624{
625 UINT size, mipmaps, expected;
627 D3DCAPS9 caps;
628 HRESULT hr;
629
631
633 {
634 skip("No cube textures support\n");
635 return;
636 }
637
638 /* general tests */
640 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
641
643 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
644
646 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
647
648 /* size */
651 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
652 ok(size == 256, "Returned size %d, expected %d\n", size, 256);
653
654 /* mipmaps */
655 size = 64;
656 mipmaps = 9;
658 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
659 ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
660
661 size = 284;
662 mipmaps = 20;
666 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
667 ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
668
669 size = 63;
670 mipmaps = 9;
674 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
675 ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
676
677 mipmaps = 0;
679 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
680 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
681
683 {
684 mipmaps = 3;
686 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
687 ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
688 }
689 else
690 skip("No D3DUSAGE_AUTOGENMIPMAP support for cube textures\n");
691
692 /* usage */
694 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
696 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
698 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
700 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
702 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
703
704 /* format */
706 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
707
710 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
711 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
712
715 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
716 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
717
720 ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
721 ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
722}
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
#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
HRESULT WINAPI D3DXCheckCubeTextureRequirements(struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:420
#define D3DPTEXTURECAPS_CUBEMAP_POW2
Definition: d3d8caps.h:126
#define D3DPTEXTURECAPS_CUBEMAP
Definition: d3d8caps.h:121
#define D3DPTEXTURECAPS_MIPCUBEMAP
Definition: d3d8caps.h:125
#define D3DX_DEFAULT
Definition: d3dx9.h:24
unsigned int UINT
Definition: sysinfo.c:13
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
Definition: texture.c:293
DWORD TextureCaps
Definition: d3d9caps.h:279

Referenced by START_TEST().

◆ test_D3DXCheckTextureRequirements()

static void test_D3DXCheckTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 316 of file texture.c.

317{
318 UINT width, height, mipmaps;
320 unsigned int expected_size;
321 D3DCAPS9 caps;
322 HRESULT hr;
323 IDirect3D9 *d3d;
326
328
329 /* general tests */
331 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
332
334 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
335
337 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
338
339 /* width & height */
342 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
343 ok(width == 256, "Returned width %d, expected %d\n", width, 256);
344 ok(height == 256, "Returned height %d, expected %d\n", height, 256);
345
348 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
349 ok(width == 256, "Returned width %d, expected %d\n", width, 256);
350
352 skip("Hardware only supports pow2 textures\n");
353 else
354 {
355 width = 62;
357 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
358 ok(width == 62, "Returned width %d, expected %d\n", width, 62);
359
360 width = D3DX_DEFAULT; height = 63;
362 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
363 ok(width == height, "Returned width %d, expected %d\n", width, height);
364 ok(height == 63, "Returned height %d, expected %d\n", height, 63);
365 }
366
369 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
370 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
371 ok(height == 1, "Returned height %d, expected %d\n", height, 1);
372
373 width = 0; height = 0;
375 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
376 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
377 ok(height == 1, "Returned height %d, expected %d\n", height, 1);
378
379 width = 0;
381 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
382 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
383
384 width = 0xFFFFFFFE;
386 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
387 ok(width == caps.MaxTextureWidth, "Returned width %d, expected %ld\n", width, caps.MaxTextureWidth);
388
389 width = caps.MaxTextureWidth-1;
391 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
393 ok(width == caps.MaxTextureWidth, "Returned width %d, expected %ld\n", width, caps.MaxTextureWidth);
394 else
395 ok(width == caps.MaxTextureWidth-1, "Returned width %d, expected %ld\n", width, caps.MaxTextureWidth-1);
396
397 /* mipmaps */
398 width = 64; height = 63;
399 mipmaps = 9;
401 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
402 ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
403
404 if (!(caps.TextureCaps & D3DPTEXTURECAPS_POW2))
405 {
406 width = 284; height = 137;
407 mipmaps = 20;
409 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
410 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
411
412 width = height = 63;
413 mipmaps = 9;
415 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
416 ok(mipmaps == 6, "Returned mipmaps %d, expected %d\n", mipmaps, 6);
417 }
418 else
419 skip("Skipping some tests, npot2 textures unsupported\n");
420
421 mipmaps = 20;
423 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
424 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
425
426 mipmaps = 0;
428 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
429 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
430
431 /* mipmaps when D3DUSAGE_AUTOGENMIPMAP is set */
433 {
434 mipmaps = 0;
436 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
437 ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
438 mipmaps = 1;
440 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
441 ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
442 mipmaps = 2;
444 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
445 ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
446 mipmaps = 6;
448 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
449 ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
450 }
451 else
452 skip("No D3DUSAGE_AUTOGENMIPMAP support for textures\n");
453
454 /* usage */
456 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
458 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
460 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
462 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
464 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
465
466 /* format */
468 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
469
472 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
473 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
474
477 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
478 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
479
482 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
483 ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
484
488
489 if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
490 mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_R3G3B2)))
492 else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
495 else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
498 else
500
503 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
504 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
505
506 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
509 else
511
514 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
515 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
516
517 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
518 mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_P8)))
520 else
522
525 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
526 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
527
528 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
531 else
533
536 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
537 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
538
539 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
542 else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
545 else
547
550 ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
551 ok(format == expected, "Returned format %u, expected %u\n", format, expected);
552
553 /* Block-based texture formats and size < block size. */
555 width = 2; height = 2;
556 mipmaps = 1;
558 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
559 ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
560 if (has_2d_dxt1)
561 {
562 ok(width == 4, "Got unexpected width %d.\n", width);
563 ok(height == 4, "Got unexpected height %d.\n", height);
564 ok(format == D3DFMT_DXT1, "Got unexpected format %u.\n", format);
565 }
566 else
567 {
568 ok(width == 2, "Got unexpected width %d.\n", width);
569 ok(height == 2, "Got unexpected height %d.\n", height);
570 ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
571 }
572
574 width = 2; height = 2;
576 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
577 ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
578 if (has_2d_dxt5)
579 {
580 ok(width == 4, "Got unexpected width %d.\n", width);
581 ok(height == 4, "Got unexpected height %d.\n", height);
582 ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
583
584 width = 9;
585 height = 9;
587 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
589 expected_size = 16;
590 else
591 expected_size = 12;
592 ok(width == expected_size, "Unexpected width %u, expected %u.\n", width, expected_size);
593 ok(height == expected_size, "Unexpected height %u, expected %u.\n", height, expected_size);
594 ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
595 ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
596 }
597 else
598 {
599 ok(width == 2, "Got unexpected width %d.\n", width);
600 ok(height == 2, "Got unexpected height %d.\n", height);
601 ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
602 }
603 width = 4;
604 height = 2;
606 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
607 ok(width == 4, "Got unexpected width %u.\n", width);
608 ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
609 if (has_2d_dxt5)
610 {
611 ok(height == 4, "Got unexpected height %u.\n", height);
612 ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
613 }
614 else
615 {
616 ok(height == 2, "Got unexpected height %u.\n", height);
617 ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
618 }
619
621}
@ 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_A2R10G10B10
Definition: d3d9types.h:805
@ D3DFMT_A16B16G16R16
Definition: d3d9types.h:806
@ D3DFMT_L16
Definition: d3d9types.h:841
HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:411
#define D3DPTEXTURECAPS_POW2
Definition: d3d8caps.h:114
DWORD MaxTextureWidth
Definition: d3d9caps.h:286

Referenced by START_TEST().

◆ test_D3DXCheckVolumeTextureRequirements()

static void test_D3DXCheckVolumeTextureRequirements ( IDirect3DDevice9 *  device)
static

Definition at line 724 of file texture.c.

725{
726 UINT width, height, depth, mipmaps, expected;
728 D3DCAPS9 caps;
729 HRESULT hr;
730
732
733 if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) || (caps.MaxVolumeExtent < 256))
734 {
735 skip("Limited or no volume textures support.\n");
736 return;
737 }
738
739 /* general tests */
741 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
742
744 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
745
747 ok(hr == D3DERR_INVALIDCALL, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
748
749 /* width, height, depth */
752 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
753 ok(width == 256, "Returned width %d, expected %d\n", width, 256);
754 ok(height == 256, "Returned height %d, expected %d\n", height, 256);
755 ok(depth == 1, "Returned depth %d, expected %d\n", depth, 1);
756
759 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
760 ok(width == 256, "Returned width %d, expected %d\n", width, 256);
761
762 width = D3DX_DEFAULT; height = 0; depth = 0;
764 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
765 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
766 ok(height == 1, "Returned height %d, expected %d\n", height, 1);
767 ok(depth == 1, "Returned height %d, expected %d\n", depth, 1);
768
769 width = 0; height = 0; depth = 0;
771 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
772 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
773 ok(height == 1, "Returned height %d, expected %d\n", height, 1);
774 ok(depth == 1, "Returned height %d, expected %d\n", depth, 1);
775
776 width = 0;
778 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
779 ok(width == 1, "Returned width %d, expected %d\n", width, 1);
780
781 width = 0xFFFFFFFE;
783 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
784 ok(width == caps.MaxVolumeExtent, "Returned width %d, expected %ld\n", width, caps.MaxVolumeExtent);
785
786 /* format */
788 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
789
792 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
793 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
794
797 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
798 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
799
802 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
803 ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
804
807 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
808 if (has_3d_dxt3)
809 ok(format == D3DFMT_DXT3, "Returned format %u, expected %u\n", format, D3DFMT_DXT3);
810 else
811 ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
812
813 /* mipmaps */
815 {
816 skip("No volume textures mipmapping support\n");
817 return;
818 }
819
820 width = height = depth = 64;
821 mipmaps = 9;
823 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
824 ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
825
826 width = 284;
827 height = 143;
828 depth = 55;
829 mipmaps = 20;
830 expected = (caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP_POW2 && caps.MaxVolumeExtent >= 512) ? 10 : 9;
832 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
833 ok(mipmaps == expected, "Returned mipmaps %d, expected %d\n", mipmaps, expected);
834
835 mipmaps = 0;
837 ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#lx, expected %#lx\n", hr, D3D_OK);
838 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
839
840 /* D3DUSAGE_AUTOGENMIPMAP is never supported for volume textures. */
842 "D3DUSAGE_AUTOGENMIPMAP is unexpectedly supported on volume textures.\n");
843}
HRESULT WINAPI D3DXCheckVolumeTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:456
#define D3DPTEXTURECAPS_VOLUMEMAP
Definition: d3d8caps.h:122
#define D3DPTEXTURECAPS_VOLUMEMAP_POW2
Definition: d3d8caps.h:127
#define D3DPTEXTURECAPS_MIPVOLUMEMAP
Definition: d3d8caps.h:124
DWORD MaxVolumeExtent
Definition: d3d9caps.h:288

Referenced by START_TEST().

◆ test_D3DXCreateCubeTextureFromFileInMemory()

static void test_D3DXCreateCubeTextureFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 2521 of file texture.c.

2522{
2523 HRESULT hr;
2524 ULONG ref;
2525 DWORD levelcount;
2526 IDirect3DCubeTexture9 *cube_texture;
2527 D3DSURFACE_DESC surface_desc;
2528
2530 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
2531
2533 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
2534
2536 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
2537
2539 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
2540
2542 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
2543
2545 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
2546
2548 if (SUCCEEDED(hr))
2549 {
2550 levelcount = IDirect3DCubeTexture9_GetLevelCount(cube_texture);
2551 ok(levelcount == 3, "GetLevelCount returned %lu, expected 3\n", levelcount);
2552
2553 hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &surface_desc);
2554 ok(hr == D3D_OK, "GetLevelDesc returned %#lx, expected %#lx\n", hr, D3D_OK);
2555 ok(surface_desc.Width == 4, "Got width %u, expected 4\n", surface_desc.Width);
2556 ok(surface_desc.Height == 4, "Got height %u, expected 4\n", surface_desc.Height);
2557
2558 ref = IDirect3DCubeTexture9_Release(cube_texture);
2559 ok(ref == 0, "Invalid reference count. Got %lu, expected 0\n", ref);
2560 } else skip("Couldn't create cube texture\n");
2561}
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:747
static const uint8_t bmp_32bpp_4_4_argb[]
static const uint8_t dds_24bit[]
static const uint8_t dds_cube_map[]
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory(struct IDirect3DDevice9 *device, const void *data, UINT datasize, struct IDirect3DCubeTexture9 **texture)
Definition: texture.c:927

Referenced by START_TEST().

◆ test_D3DXCreateCubeTextureFromFileInMemoryEx()

static void test_D3DXCreateCubeTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device)
static

Definition at line 2563 of file texture.c.

2564{
2565 static const uint32_t dds_cube_map_non_square_expected[] =
2566 {
2567 0xffff0000, 0xff00ff00, 0xff0000ff, 0xffffff00, 0xffff00ff, 0xff000000,
2568 };
2569 static const uint32_t dds_cube_map_4_4_expected[] =
2570 {
2571 0xffff0000, 0xff00ff00, 0xff0000ff, 0xffffff00, 0xffff00ff, 0xff00ffff,
2572 0xffffffff, 0xff000000, 0xff800000, 0xff008000, 0xff000080, 0xff808000
2573 };
2574 IDirect3DCubeTexture9 *cube_texture;
2575 struct surface_readback surface_rb;
2578 uint32_t i, x, y;
2579 HRESULT hr;
2580
2583 D3DX_DEFAULT, 0, NULL, NULL, &cube_texture);
2584 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2585 IDirect3DCubeTexture9_Release(cube_texture);
2586
2589 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2590 IDirect3DCubeTexture9_Release(cube_texture);
2591 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
2592 {
2593 winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
2594
2595 cube_texture = NULL;
2598 0, NULL, NULL, &cube_texture);
2599 ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
2600 if (cube_texture)
2601 IDirect3DCubeTexture9_Release(cube_texture);
2602
2604 }
2605
2606 /* Mip filter argument values never cause failure. */
2607 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
2608 {
2609 winetest_push_context("Mip filter %d (%#x)", i, test_filter_values[i].filter);
2610
2611 cube_texture = NULL;
2614 0, NULL, NULL, &cube_texture);
2615 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2616 if (cube_texture)
2617 IDirect3DCubeTexture9_Release(cube_texture);
2618
2620 }
2621
2622 /* Mip skip bits are 30-26, 25-23 are unused, setting them does nothing. */
2623 cube_texture = NULL;
2626 0, NULL, NULL, &cube_texture);
2627 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2628 if (cube_texture)
2629 IDirect3DCubeTexture9_Release(cube_texture);
2630
2632 {
2633 skip("No D3DUSAGE_AUTOGENMIPMAP support for cube textures\n");
2634 return;
2635 }
2636
2639 D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &cube_texture);
2640 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2641 IDirect3DCubeTexture9_Release(cube_texture);
2642
2643 /*
2644 * Cubemap file with a width of 4 and a height of 2. The largest value is
2645 * used for the size of the created cubemap.
2646 */
2649 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2650
2651 check_texture_mip_levels(cube_texture, 1, FALSE);
2654
2655 IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &desc);
2656 for (i = 0; i < 6; ++i)
2657 {
2658 const uint32_t expected_color = dds_cube_map_non_square_expected[i];
2659
2660 winetest_push_context("Face %u", i);
2661 get_cube_texture_surface_readback(device, cube_texture, i, 0, &surface_rb);
2662 for (y = 0; y < desc.Height; ++y)
2663 {
2664 for (x = 0; x < desc.Width; ++x)
2665 {
2666 if (y < info.Height)
2667 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2668 else
2669 check_readback_pixel_4bpp(&surface_rb, x, y, 0xff000000, FALSE);
2670 }
2671 }
2672 release_surface_readback(&surface_rb);
2674 }
2675 IDirect3DCubeTexture9_Release(cube_texture);
2676
2677 /*
2678 * Load the same cubemap, but this time with a point filter. Source image
2679 * is scaled to cover the entire 4x4 cubemap texture faces.
2680 */
2683 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2684
2685 check_texture_mip_levels(cube_texture, 1, FALSE);
2688
2689 IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &desc);
2690 for (i = 0; i < 6; ++i)
2691 {
2692 const uint32_t expected_color = dds_cube_map_non_square_expected[i];
2693
2694 winetest_push_context("Face %u", i);
2695 get_cube_texture_surface_readback(device, cube_texture, i, 0, &surface_rb);
2696 for (y = 0; y < desc.Height; ++y)
2697 {
2698 for (x = 0; x < desc.Width; ++x)
2699 {
2700 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2701 }
2702 }
2703 release_surface_readback(&surface_rb);
2705 }
2706 IDirect3DCubeTexture9_Release(cube_texture);
2707
2708 /*
2709 * Cubemap file with a width of 2 and a height of 4.
2710 */
2713 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2714
2715 check_texture_mip_levels(cube_texture, 1, FALSE);
2718
2719 IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &desc);
2720 for (i = 0; i < 6; ++i)
2721 {
2722 const uint32_t expected_color = dds_cube_map_non_square_expected[i];
2723
2724 winetest_push_context("Face %u", i);
2725 get_cube_texture_surface_readback(device, cube_texture, i, 0, &surface_rb);
2726 for (y = 0; y < desc.Height; ++y)
2727 {
2728 for (x = 0; x < desc.Width; ++x)
2729 {
2730 if (x < info.Width)
2731 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2732 else
2733 check_readback_pixel_4bpp(&surface_rb, x, y, 0xff000000, FALSE);
2734 }
2735 }
2736 release_surface_readback(&surface_rb);
2738 }
2739 IDirect3DCubeTexture9_Release(cube_texture);
2740
2741 /* Multi-mip cubemap DDS file. */
2744 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2745
2746 check_texture_mip_levels(cube_texture, 2, FALSE);
2750
2751 for (i = 0; i < 6; ++i)
2752 {
2753 uint32_t mip_level;
2754
2755 for (mip_level = 0; mip_level < 2; ++mip_level)
2756 {
2757 const uint32_t expected_color = dds_cube_map_4_4_expected[(i * 2) + mip_level];
2758
2759 winetest_push_context("Face %u, mip level %u", i, mip_level);
2760 IDirect3DCubeTexture9_GetLevelDesc(cube_texture, mip_level, &desc);
2761 get_cube_texture_surface_readback(device, cube_texture, i, mip_level, &surface_rb);
2762 for (y = 0; y < desc.Height; ++y)
2763 {
2764 for (x = 0; x < desc.Width; ++x)
2765 {
2766 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2767 }
2768 }
2769 release_surface_readback(&surface_rb);
2771 }
2772 }
2773 IDirect3DCubeTexture9_Release(cube_texture);
2774
2775 /* Skip level bits are bits 30-26. Bit 31 needs to be ignored. */
2778 D3DX_FILTER_POINT | (0x20u << D3DX_SKIP_DDS_MIP_LEVELS_SHIFT), 0, &info, NULL, &cube_texture);
2779 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2780
2782 IDirect3DCubeTexture9_Release(cube_texture);
2783
2784 /* Multi-mip cubemap DDS file with mip skipping. */
2787 D3DX_SKIP_DDS_MIP_LEVELS(1, D3DX_DEFAULT), 0, &info, NULL, &cube_texture);
2788 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2789
2790 check_texture_mip_levels(cube_texture, 1, FALSE);
2793
2794 for (i = 0; i < 6; ++i)
2795 {
2796 const uint32_t expected_color = dds_cube_map_4_4_expected[(i * 2) + 1];
2797
2798 winetest_push_context("Face %u", i);
2799 IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &desc);
2800 get_cube_texture_surface_readback(device, cube_texture, i, 0, &surface_rb);
2801 for (y = 0; y < desc.Height; ++y)
2802 {
2803 for (x = 0; x < desc.Width; ++x)
2804 {
2805 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2806 }
2807 }
2808 release_surface_readback(&surface_rb);
2810 }
2811 IDirect3DCubeTexture9_Release(cube_texture);
2812}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
static const uint8_t dds_cube_map_4_4[]
static const uint8_t dds_cube_map_2_4[]
#define check_image_info(info, width, height, depth, mip_levels, format, resource_type, image_file_format, wine_todo)
static const uint8_t dds_cube_map_4_2[]
static const struct @1911 test_filter_values[]
HRESULT expected_hr
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:1342
@ D3DXIFF_DDS
Definition: dx8vb.idl:66
#define D3DX_FROM_FILE
Definition: d3dx9.h:27
#define D3DX_SKIP_DDS_MIP_LEVELS(l, f)
Definition: d3dx9tex.h:44
#define D3DX_FILTER_POINT
Definition: d3dx9tex.h:28
#define D3DX_SKIP_DDS_MIP_LEVELS_SHIFT
Definition: d3dx9tex.h:43
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:539
static void get_cube_texture_surface_readback(IDirect3DDevice9 *device, IDirect3DCubeTexture9 *texture, uint32_t face, uint32_t mip_level, struct surface_readback *rb)
Definition: texture.c:267
#define check_readback_pixel_4bpp(rb, x, y, color, todo)
Definition: texture.c:285
static void release_surface_readback(struct surface_readback *rb)
Definition: texture.c:198
#define check_cube_texture_level_desc(tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, size, wine_todo)
Definition: texture.c:104
#define check_texture_mip_levels(tex, expected_mip_levels, wine_todo)
Definition: texture.c:160
Definition: filter.c:165

Referenced by START_TEST().

◆ test_D3DXCreateTexture()

static void test_D3DXCreateTexture ( IDirect3DDevice9 *  device)
static

Definition at line 845 of file texture.c.

846{
847 IDirect3DTexture9 *texture;
849 D3DCAPS9 caps;
850 UINT mipmaps;
851 HRESULT hr;
852
854
856 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
857
858 /* width and height tests */
859
861 ok(hr == D3D_OK, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
862
863 if (texture)
864 {
866 ok(hr == D3D_OK, "GetLevelDesc returned %#lx, expected %#lx\n", hr, D3D_OK);
867 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
868
869 ok(desc.Width == 256, "Returned width %d, expected %d\n", desc.Width, 256);
870 ok(desc.Height == 256, "Returned height %d, expected %d\n", desc.Height, 256);
871
873 }
874
875
877 ok(hr == D3D_OK, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
878
879 if (texture)
880 {
882 ok(hr == D3D_OK, "GetLevelDesc returned %#lx, expected %#lx\n", hr, D3D_OK);
883 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
884
885 ok(desc.Width == 1, "Returned width %d, expected %d\n", desc.Width, 1);
886 ok(desc.Height == 1, "Returned height %d, expected %d\n", desc.Height, 1);
887
889 }
890
891
893 skip("Hardware only supports pow2 textures\n");
894 else
895 {
897 ok((hr == D3D_OK) ||
898 /* may not work with conditional NPOT */
900 "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
901
902 if (texture)
903 {
905 ok(hr == D3D_OK, "GetLevelDesc returned %#lx, expected %#lx\n", hr, D3D_OK);
906 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
907
908 /* Conditional NPOT may create a texture with different dimensions, so allow those
909 situations instead of returning a fail */
910
911 ok(desc.Width == 63 ||
913 "Returned width %d, expected %d\n", desc.Width, 63);
914
915 ok(desc.Height == 63 ||
917 "Returned height %d, expected %d\n", desc.Height, 63);
918
920 }
921 }
922
923 /* mipmaps */
924
925 hr = D3DXCreateTexture(device, 64, 63, 9, 0, 0, D3DPOOL_DEFAULT, &texture);
926 ok(hr == D3D_OK, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
927
928 if (texture)
929 {
931 ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
932
934 }
935
936
937 hr = D3DXCreateTexture(device, 284, 137, 9, 0, 0, D3DPOOL_DEFAULT, &texture);
938 ok(hr == D3D_OK, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
939
940 if (texture)
941 {
943 ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
944
946 }
947
948
949 hr = D3DXCreateTexture(device, 0, 0, 20, 0, 0, D3DPOOL_DEFAULT, &texture);
950 ok(hr == D3D_OK, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
951
952 if (texture)
953 {
955 ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
956
958 }
959
960
961 hr = D3DXCreateTexture(device, 64, 64, 1, 0, 0, D3DPOOL_DEFAULT, &texture);
962 ok(hr == D3D_OK, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
963
964 if (texture)
965 {
967 ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
968
970 }
971
972 /* usage */
973
975 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
977 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
979 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
981 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
983 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTexture succeeded, but should have failed.\n");
984
985 /* format */
986
988 ok(hr == D3D_OK, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
989
990 if (texture)
991 {
993 ok(hr == D3D_OK, "GetLevelDesc returned %#lx, expected %#lx\n", hr, D3D_OK);
994 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
995
997 }
998
999
1000 hr = D3DXCreateTexture(device, 0, 0, 0, 0, 0, D3DPOOL_DEFAULT, &texture);
1001 ok(hr == D3D_OK, "D3DXCreateTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1002
1003 if (texture)
1004 {
1006 ok(hr == D3D_OK, "GetLevelDesc returned %#lx, expected %#lx\n", hr, D3D_OK);
1007 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
1008
1010 }
1011
1012 /* D3DXCreateTextureFromResource */
1014 ok(hr == D3D_OK, "D3DXCreateTextureFromResource returned %#lx, expected %#lx\n", hr, D3D_OK);
1016
1018 ok(hr == D3D_OK, "D3DXCreateTextureFromResource returned %#lx, expected %#lx\n", hr, D3D_OK);
1020
1022 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResource returned %#lx, expected %#x\n", hr, D3DXERR_INVALIDDATA);
1023
1025 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResource returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1026
1028 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResource returned %#lx, expected %#x\n", hr, D3DXERR_INVALIDDATA);
1029
1031 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResource returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1032
1033
1034 /* D3DXCreateTextureFromResourceEx */
1036 ok(hr == D3D_OK, "D3DXCreateTextureFromResourceEx returned %#lx, expected %#lx\n", hr, D3D_OK);
1038
1040 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResourceEx returned %#lx, expected %#x\n", hr, D3DXERR_INVALIDDATA);
1041
1043 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResourceEx returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1044
1046 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromResourceEx returned %#lx, expected %#x\n", hr, D3DXERR_INVALIDDATA);
1047
1049 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateTextureFromResourceEx returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1050}
#define IDS_STRING
Definition: resource.h:17
@ D3DPOOL_MANAGED
Definition: d3d8types.h:710
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:855
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:842
#define D3DXERR_INVALIDDATA
Definition: compiler.c:53
HRESULT WINAPI D3DXCreateTextureFromResourceA(struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, struct IDirect3DTexture9 **texture)
Definition: texture.c:825
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:847
#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL
Definition: d3d8caps.h:119
#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 1811 of file texture.c.

1812{
1813 static const DWORD dds_dxt5_expected[] =
1814 {
1815 0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
1816 0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
1817 0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
1818 0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
1819 };
1820 static const DWORD dds_dxt5_8_8_expected[] =
1821 {
1822 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x3f00ffff, 0x3f00ffff, 0x3fff0000, 0x3fff0000,
1823 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x3f00ffff, 0x3f00ffff, 0x3fff0000, 0x3fff0000,
1824 0x000000ff, 0x000000ff, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3f00ffff, 0x3f00ffff,
1825 0x000000ff, 0x000000ff, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3f00ffff, 0x3f00ffff,
1826 0x7fffff00, 0x7fffff00, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xffffffff, 0xffffffff,
1827 0x7fffff00, 0x7fffff00, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xffffffff, 0xffffffff,
1828 0x7fff00ff, 0x7fff00ff, 0x7fffff00, 0x7fffff00, 0xffffffff, 0xffffffff, 0xff000000, 0xff000000,
1829 0x7fff00ff, 0x7fff00ff, 0x7fffff00, 0x7fffff00, 0xffffffff, 0xffffffff, 0xff000000, 0xff000000,
1830 };
1831 static const DWORD dds_dxt5_8_8_expected_misaligned_1[] =
1832 {
1833 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3fff0000, 0x3fff0000,
1834 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3fff0000, 0x3fff0000,
1835 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3fff0000, 0x3fff0000,
1836 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3fff0000, 0x3fff0000,
1837 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1838 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1839 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1840 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1841 };
1842 static const DWORD dds_dxt5_8_8_expected_misaligned_3[] =
1843 {
1844 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1845 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1846 0x00000000, 0x00000000, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x00000000, 0x00000000,
1847 0x00000000, 0x00000000, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x00000000, 0x00000000,
1848 0x00000000, 0x00000000, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0x00000000, 0x00000000,
1849 0x00000000, 0x00000000, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0x00000000, 0x00000000,
1850 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1851 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1852 };
1853 static const uint32_t dds_volume_dxt3_4_4_4_expected_uncompressed[] =
1854 {
1855 0xffff0000, 0xff00ff00, 0xff0000ff,
1856 };
1857 IDirect3DSurface9 *surface, *uncompressed_surface;
1858 IDirect3DTexture9 *texture;
1859 D3DLOCKED_RECT lock_rect;
1862 unsigned int i, x, y;
1863 DWORD level_count;
1864 HRESULT hr;
1865 RECT rect;
1866
1868 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
1870
1872 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
1874
1876 ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromFileInMemory returned %#lx, expected %#x\n", hr, D3DXERR_INVALIDDATA);
1877
1878 /* Check that D3DXCreateTextureFromFileInMemory accepts cube texture dds file (only first face texture is loaded) */
1880 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#lx, expected %#lx.\n", hr, D3D_OK);
1882 ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u.\n", type, D3DRTYPE_TEXTURE);
1884 ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#lx, expected %#lx.\n", hr, D3D_OK);
1885 ok(desc.Width == 4, "Width is %u, expected 4.\n", desc.Width);
1886 ok(desc.Height == 4, "Height is %u, expected 4.\n", desc.Height);
1887 if (has_cube_dxt5)
1888 {
1889 ok(desc.Format == D3DFMT_DXT5, "Unexpected texture format %#x.\n", desc.Format);
1891 ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %#lx, expected %#lx\n", hr, D3D_OK);
1892 if (SUCCEEDED(hr))
1893 {
1894 for (i = 0; i < 16; i++)
1895 ok(((BYTE *)lock_rect.pBits)[i] == dds_cube_map[128 + i],
1896 "Byte at index %u is 0x%02x, expected 0x%02x.\n",
1897 i, ((BYTE *)lock_rect.pBits)[i], dds_cube_map[128 + i]);
1899 }
1900 }
1901 else
1902 {
1903 ok(desc.Format == D3DFMT_A8R8G8B8, "Unexpected texture format %#x.\n", desc.Format);
1904 skip("D3DFMT_DXT5 textures are not supported, skipping a test.\n");
1905 }
1907
1908 /* Test with a DXT5 texture smaller than the block size. */
1910 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1911 if (SUCCEEDED(hr) && has_2d_dxt5)
1912 {
1914 ok(type == D3DRTYPE_TEXTURE, "Got unexpected type %u.\n", type);
1916 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1917 ok(desc.Width == 4, "Got unexpected width %u.\n", desc.Width);
1918 ok(desc.Height == 4, "Got unexpected height %u.\n", desc.Height);
1919
1922 D3DPOOL_DEFAULT, &uncompressed_surface, NULL);
1923 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1924 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
1925 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1926 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1927 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1928 for (y = 0; y < 4; ++y)
1929 {
1930 for (x = 0; x < 4; ++x)
1931 {
1932 /* Use a large tolerance, decompression + stretching +
1933 * compression + decompression again introduce quite a bit of
1934 * precision loss. */
1935 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1936 dds_dxt5_expected[y * 4 + x], 32),
1937 "Color at position %u, %u is 0x%08lx, expected 0x%08lx.\n",
1938 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1939 dds_dxt5_expected[y * 4 + x]);
1940 }
1941 }
1942 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
1943 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1944
1945 IDirect3DSurface9_Release(uncompressed_surface);
1947 }
1948 if (SUCCEEDED(hr))
1950
1951 /* Test with a larger DXT5 texture. */
1953 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1955 ok(type == D3DRTYPE_TEXTURE, "Got unexpected type %u.\n", type);
1957 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1958 ok(desc.Width == 8, "Got unexpected width %u.\n", desc.Width);
1959 ok(desc.Height == 8, "Got unexpected height %u.\n", desc.Height);
1961
1963 D3DPOOL_DEFAULT, &uncompressed_surface, NULL);
1964 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1965 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
1966 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1967 if (SUCCEEDED(hr))
1968 {
1969 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1970 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1971 for (y = 0; y < 8; ++y)
1972 {
1973 for (x = 0; x < 8; ++x)
1974 {
1975 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1976 dds_dxt5_8_8_expected[y * 8 + x], 0),
1977 "Color at position %u, %u is 0x%08lx, expected 0x%08lx.\n",
1978 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
1979 dds_dxt5_8_8_expected[y * 8 + x]);
1980 }
1981 }
1982 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
1983 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1984 }
1985
1986 hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, D3DLOCK_READONLY);
1987 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1988 for (y = 0; y < 2; ++y)
1989 memset(&((BYTE *)lock_rect.pBits)[y * lock_rect.Pitch], 0, 16 * 2);
1991 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1992
1993 SetRect(&rect, 2, 2, 6, 6);
1995 D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0);
1996 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1997 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
1998 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
1999
2000 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
2001 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2002 for (y = 0; y < 8; ++y)
2003 {
2004 for (x = 0; x < 8; ++x)
2005 {
2006 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
2007 dds_dxt5_8_8_expected_misaligned_1[y * 8 + x], 0),
2008 "Color at position %u, %u is 0x%08lx, expected 0x%08lx.\n",
2009 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
2010 dds_dxt5_8_8_expected_misaligned_1[y * 8 + x]);
2011 }
2012 }
2013 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
2014 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2015
2016 hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, D3DLOCK_READONLY);
2017 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2018 for (y = 0; y < 2; ++y)
2019 memset(&((BYTE *)lock_rect.pBits)[y * lock_rect.Pitch], 0, 16 * 2);
2021 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2022
2024 D3DFMT_DXT5, 16 * 2, NULL, NULL, D3DX_FILTER_POINT, 0);
2025 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
2026
2028 D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0);
2029 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2030 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
2031 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2032
2033 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
2034 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2035 for (y = 0; y < 8; ++y)
2036 {
2037 for (x = 0; x < 8; ++x)
2038 {
2039 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
2040 dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0),
2041 "Color at position %u, %u is 0x%08lx, expected 0x%08lx.\n",
2042 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
2043 dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]);
2044 }
2045 }
2046 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
2047 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2048
2050 sizeof(dds_dxt5_8_8), &rect, D3DX_FILTER_POINT, 0, NULL);
2051 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2052 hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
2053 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2054
2055 hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
2056 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2057 for (y = 0; y < 8; ++y)
2058 {
2059 for (x = 0; x < 8; ++x)
2060 {
2061 ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
2062 dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0),
2063 "Color at position %u, %u is 0x%08lx, expected 0x%08lx.\n",
2064 x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
2065 dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]);
2066 }
2067 }
2068 hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
2069 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2070
2071 IDirect3DSurface9_Release(uncompressed_surface);
2074
2075 /* Volume textures work too. */
2077 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#lx, expected %#lx.\n", hr, D3D_OK);
2079 ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u.\n", type, D3DRTYPE_TEXTURE);
2080 level_count = IDirect3DBaseTexture9_GetLevelCount((IDirect3DBaseTexture9 *)texture);
2081 ok(level_count == 3, "Texture has %lu mip levels, 3 expected.\n", level_count);
2083 ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#lx, expected %#lx.\n", hr, D3D_OK);
2084 ok(desc.Width == 4, "Width is %u, expected 4.\n", desc.Width);
2085 ok(desc.Height == 4, "Height is %u, expected 4.\n", desc.Height);
2086
2087 if (has_2d_dxt3)
2088 {
2089 ok(desc.Format == D3DFMT_DXT3, "Unexpected texture format %#x.\n", desc.Format);
2091 ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %#lx, expected %#lx.\n", hr, D3D_OK);
2092 if (SUCCEEDED(hr))
2093 {
2094 for (i = 0; i < 16; ++i)
2095 ok(((BYTE *)lock_rect.pBits)[i] == dds_volume_map[128 + i],
2096 "Byte at index %u is 0x%02x, expected 0x%02x.\n",
2097 i, ((BYTE *)lock_rect.pBits)[i], dds_volume_map[128 + i]);
2099 }
2100 }
2101 else
2102 {
2103 ok(desc.Format == D3DFMT_A8R8G8B8, "Unexpected texture format %#x.\n", desc.Format);
2104 skip("D3DFMT_DXT3 volume textures are not supported, skipping a test.\n");
2105 }
2106
2108
2109 /*
2110 * All mip levels are pulled from the texture file, even in the case of a
2111 * volume texture file.
2112 */
2114 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2116 if (has_2d_dxt3)
2117 {
2118 struct surface_readback surface_rb;
2119 uint32_t mip_level;
2120
2124 for (mip_level = 0; mip_level < ARRAY_SIZE(dds_volume_dxt3_4_4_4_expected_uncompressed); ++mip_level)
2125 {
2126 const uint32_t expected_color = dds_volume_dxt3_4_4_4_expected_uncompressed[mip_level];
2127 uint32_t x, y;
2128
2130 get_texture_surface_readback(device, texture, mip_level, &surface_rb);
2131 for (y = 0; y < desc.Height; ++y)
2132 {
2133 for (x = 0; x < desc.Width; ++x)
2134 {
2135 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2136 }
2137 }
2138 release_surface_readback(&surface_rb);
2139 }
2140 }
2141 else
2142 {
2144 skip("D3DFMT_DXT3 textures are not supported, skipping a test.\n");
2145 }
2146
2148}
RECT rect
Definition: combotst.c:67
enum _D3DRESOURCETYPE D3DRESOURCETYPE
#define IDirect3DTexture9_GetType(p)
Definition: d3d9.h:851
#define IDirect3DTexture9_UnlockRect(p, a)
Definition: d3d9.h:863
#define IDirect3DTexture9_LockRect(p, a, b, c, d)
Definition: d3d9.h:862
static const uint8_t dds_16bit[]
static const uint8_t dds_dxt5_8_8[]
static const uint8_t dds_volume_map[]
static const uint8_t dds_volume_dxt3_4_4_4[]
static const uint8_t dds_dxt5[]
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:2702
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:1700
HRESULT WINAPI D3DXCreateTextureFromFileInMemory(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, struct IDirect3DTexture9 **texture)
Definition: texture.c:736
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define check_texture_level_desc(tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, width, height, wine_todo)
Definition: texture.c:83
static void get_texture_surface_readback(IDirect3DDevice9 *device, IDirect3DTexture9 *texture, uint32_t mip_level, struct surface_readback *rb)
Definition: texture.c:249
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
Definition: dcommon.idl:28

Referenced by START_TEST().

◆ test_D3DXCreateTextureFromFileInMemoryEx()

static void test_D3DXCreateTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device)
static

Definition at line 2150 of file texture.c.

2151{
2152 static const uint32_t dds_24bit_8_8_expected[] =
2153 {
2154 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000,
2155 };
2156 static const uint32_t dds_volume_24bit_4_4_4_expected[] =
2157 {
2158 0xffff0000, 0xff00ff00, 0xff0000ff,
2159 };
2160 static const uint32_t dds_volume_dxt3_4_4_4_expected_uncompressed[] =
2161 {
2162 0xffff0000, 0xff00ff00, 0xff0000ff,
2163 };
2164 HRESULT hr;
2165 struct surface_readback surface_rb;
2166 uint32_t miplevels, mip_level, i;
2167 IDirect3DTexture9 *texture;
2169 D3DXIMAGE_INFO img_info;
2171
2174 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx\n", hr, D3D_OK);
2176
2177 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
2178 {
2179 winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
2180
2181 texture = NULL;
2184 ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
2185 if (texture)
2187
2189 }
2190
2191 /* Mip filter argument values never cause failure. */
2192 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
2193 {
2194 winetest_push_context("Mip filter %d (%#x)", i, test_filter_values[i].filter);
2195
2196 texture = NULL;
2199 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2200 if (texture)
2202
2204 }
2205
2206 /* Mip skip bits are 30-26, 25-23 are unused, setting them does nothing. */
2207 texture = NULL;
2210 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2211 if (texture)
2213
2216 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx\n", hr, D3D_OK);
2218
2222 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx\n", hr, D3D_OK);
2224 ok(miplevels == 1, "Got miplevels %u, expected %u.\n", miplevels, 1);
2227 ok(desc.Width == 1 && desc.Height == 1,
2228 "Surface dimensions are %ux%u, expected 1x1.\n", desc.Width, desc.Height);
2231
2233 {
2234 skip("No D3DUSAGE_AUTOGENMIPMAP support for textures\n");
2235 return;
2236 }
2237
2240 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx\n", hr, D3D_OK);
2242
2243 /* Checking for color key format overrides. */
2247 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2250 ok(desc.Format == D3DFMT_X1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X1R5G5B5);
2255 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
2256 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2259 ok(desc.Format == D3DFMT_A1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A1R5G5B5);
2264 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
2265 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2268 ok(desc.Format == D3DFMT_X1R5G5B5, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X1R5G5B5);
2271
2275 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2278 ok(desc.Format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X8R8G8B8);
2283 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
2284 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2287 ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A8R8G8B8);
2292 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
2293 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2296 ok(desc.Format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_X8R8G8B8);
2299
2303 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2306 ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_L8);
2311 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
2312 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2315 ok(desc.Format == D3DFMT_A8L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_A8L8);
2320 D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
2321 ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx.\n", hr, D3D_OK);
2324 ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_L8);
2327
2328 /* Test values returned in the D3DXIMAGE_INFO structure. */
2332 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2333
2338
2340
2341 /* Skip level bits are bits 30-26. Bit 31 needs to be ignored. */
2345 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2346
2349
2350 /*
2351 * The values returned in the D3DXIMAGE_INFO structure represent the mip
2352 * level the texture data was retrieved from, i.e if we skip the first mip
2353 * level, we will get the values of the second mip level.
2354 */
2358 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2359
2363
2365
2366 /*
2367 * Request skipping 3 mip levels in a file that only has 2 mip levels. In this
2368 * case, it stops at the final mip level.
2369 */
2373 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2374
2378
2380
2381 /*
2382 * Load multiple mip levels from a file and check the resulting pixel
2383 * values.
2384 */
2387 D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
2388 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2389
2396
2397 for (mip_level = 0; mip_level < ARRAY_SIZE(dds_24bit_8_8_expected); ++mip_level)
2398 {
2399 const uint32_t expected_color = dds_24bit_8_8_expected[mip_level];
2400 uint32_t x, y;
2401
2403 get_texture_surface_readback(device, texture, mip_level, &surface_rb);
2404 for (y = 0; y < desc.Height; ++y)
2405 {
2406 for (x = 0; x < desc.Width; ++x)
2407 {
2408 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2409 }
2410 }
2411 release_surface_readback(&surface_rb);
2412 }
2413
2415
2416 /* Volume DDS with mips into regular texture tests. */
2419 D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
2420 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2421
2427
2428 for (mip_level = 0; mip_level < ARRAY_SIZE(dds_volume_24bit_4_4_4_expected); ++mip_level)
2429 {
2430 const uint32_t expected_color = dds_volume_24bit_4_4_4_expected[mip_level];
2431 uint32_t x, y;
2432
2434 get_texture_surface_readback(device, texture, mip_level, &surface_rb);
2435 for (y = 0; y < desc.Height; ++y)
2436 {
2437 for (x = 0; x < desc.Width; ++x)
2438 {
2439 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2440 }
2441 }
2442 release_surface_readback(&surface_rb);
2443 }
2444
2446
2447 /* DXT3 volume DDS with mips into a regular texture. */
2448 if (has_2d_dxt3)
2449 {
2452 D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
2453 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2454
2460
2461 for (mip_level = 0; mip_level < ARRAY_SIZE(dds_volume_dxt3_4_4_4_expected_uncompressed); ++mip_level)
2462 {
2463 const uint32_t expected_color = dds_volume_dxt3_4_4_4_expected_uncompressed[mip_level];
2464 uint32_t x, y;
2465
2467 get_texture_surface_readback(device, texture, mip_level, &surface_rb);
2468 for (y = 0; y < desc.Height; ++y)
2469 {
2470 for (x = 0; x < desc.Width; ++x)
2471 {
2472 check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
2473 }
2474 }
2475 release_surface_readback(&surface_rb);
2476 }
2477
2479 }
2480 else
2481 {
2482 skip("D3DFMT_DXT3 textures are not supported, skipping tests.\n");
2483 }
2484
2485 /* Create texture from JPG. */
2488 D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
2489 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2490
2495
2497
2498 /* Create texture from PNG. */
2501 D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
2502 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2508
2511 D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
2512 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2513
2519}
@ D3DFMT_A8L8
Definition: d3d8types.h:621
static const uint8_t dds_24bit_8_8[]
static const uint8_t dds_volume_24bit_4_4_4[]
static const uint8_t png_2_2_64bpp_rgba[]
static const uint8_t jpg_rgb_2_2[]
static const uint8_t png_2_2_48bpp_rgb[]
static const uint8_t png_grayscale[]
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:579
@ D3DXIFF_JPG
Definition: dx8vb.idl:63
@ D3DXIFF_PNG
Definition: dx8vb.idl:65

Referenced by START_TEST().

◆ test_D3DXCreateVolumeTextureFromFileInMemory()

static void test_D3DXCreateVolumeTextureFromFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 2814 of file texture.c.

2815{
2816 HRESULT hr;
2817 ULONG ref;
2818 DWORD levelcount;
2819 IDirect3DVolumeTexture9 *volume_texture;
2820 D3DVOLUME_DESC volume_desc;
2821
2823 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
2824
2826 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
2827
2829 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
2830
2832 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
2833
2835 ok(hr == D3D_OK, "D3DXCreateVolumeTextureFromFileInMemory returned %#lx, expected %#lx.\n", hr, D3D_OK);
2836 levelcount = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
2837 ok(levelcount == 3, "GetLevelCount returned %lu, expected 3.\n", levelcount);
2838
2839 hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &volume_desc);
2840 ok(hr == D3D_OK, "GetLevelDesc returned %#lx, expected %#lx.\n", hr, D3D_OK);
2841 ok(volume_desc.Width == 4, "Got width %u, expected 4.\n", volume_desc.Width);
2842 ok(volume_desc.Height == 4, "Got height %u, expected 4.\n", volume_desc.Height);
2843 ok(volume_desc.Depth == 2, "Got depth %u, expected 2.\n", volume_desc.Depth);
2844 ok(volume_desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected D3DPOOL_MANAGED.\n", volume_desc.Pool);
2845
2846 hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 1, &volume_desc);
2847 ok(hr == D3D_OK, "GetLevelDesc returned %#lx, expected %#lx.\n", hr, D3D_OK);
2848 ok(volume_desc.Width == 2, "Got width %u, expected 2.\n", volume_desc.Width);
2849 ok(volume_desc.Height == 2, "Got height %u, expected 2.\n", volume_desc.Height);
2850 ok(volume_desc.Depth == 1, "Got depth %u, expected 1.\n", volume_desc.Depth);
2851
2852 ref = IDirect3DVolumeTexture9_Release(volume_texture);
2853 ok(ref == 0, "Invalid reference count. Got %lu, expected 0.\n", ref);
2854}
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:937
#define IDirect3DVolumeTexture9_GetLevelCount(p)
Definition: d3d9.h:950
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *device, const void *data, UINT data_size, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1098

Referenced by START_TEST().

◆ test_D3DXCreateVolumeTextureFromFileInMemoryEx()

static void test_D3DXCreateVolumeTextureFromFileInMemoryEx ( IDirect3DDevice9 *  device)
static

Definition at line 2856 of file texture.c.

2857{
2858 static const uint32_t dds_volume_dxt3_4_4_4_expected_uncompressed[] =
2859 {
2860 0xffff0000, 0xff00ff00, 0xff0000ff,
2861 };
2862 static const uint32_t dds_24bit_8_8_expected[] =
2863 {
2864 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000,
2865 };
2866 static const uint32_t bmp_32bpp_4_4_argb_expected[] =
2867 {
2868 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000,
2869 };
2870 IDirect3DVolumeTexture9 *volume_texture, *texture;
2871 struct volume_readback volume_rb;
2872 uint32_t mip_level, x, y, z, i;
2873 D3DXIMAGE_INFO img_info;
2875 HRESULT hr;
2876
2879 D3DX_DEFAULT, 0, NULL, NULL, &volume_texture);
2880 ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
2881
2884 D3DX_DEFAULT, 0, NULL, NULL, &volume_texture);
2885 ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
2886
2887 /* Skip level bits are bits 30-26. Bit 31 needs to be ignored. */
2891 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2892
2895
2896 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
2897 {
2898 winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
2899
2900 texture = NULL;
2904 ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
2905 if (texture)
2907
2909 }
2910
2911 /* Mip filter argument values never cause failure. */
2912 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
2913 {
2914 winetest_push_context("Mip filter %d (%#x)", i, test_filter_values[i].filter);
2915
2916 texture = NULL;
2920 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2921 if (texture)
2923
2925 }
2926
2927 /* Mip skip bits are 30-26, 25-23 are unused, setting them does nothing. */
2928 texture = NULL;
2931 D3DX_DEFAULT, 0x03800001, 0, NULL, NULL, &texture);
2932 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2933 if (texture)
2935
2939 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2940
2943
2944 /* Load a 2D texture DDS file with multiple mips into a volume texture. */
2947 D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
2948 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2949
2956
2957 for (mip_level = 0; mip_level < 4; ++mip_level)
2958 {
2959 const uint32_t expected_color = dds_24bit_8_8_expected[mip_level];
2960 uint32_t x, y, z;
2961
2963 get_texture_volume_readback(device, texture, mip_level, &volume_rb);
2964 for (z = 0; z < desc.Depth; ++z)
2965 {
2966 for (y = 0; y < desc.Height; ++y)
2967 {
2968 for (x = 0; x < desc.Width; ++x)
2969 {
2970 check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color, FALSE);
2971 }
2972 }
2973 }
2974 release_volume_readback(&volume_rb);
2975 }
2977
2978 /* Multi-mip compressed volume texture file. */
2979 if (has_3d_dxt3)
2980 {
2984 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
2990
2991 for (mip_level = 0; mip_level < 3; ++mip_level)
2992 {
2993 const uint32_t expected_color = dds_volume_dxt3_4_4_4_expected_uncompressed[mip_level];
2994 uint32_t x, y, z;
2995
2997 get_texture_volume_readback(device, texture, mip_level, &volume_rb);
2998 for (z = 0; z < desc.Depth; ++z)
2999 {
3000 for (y = 0; y < desc.Height; ++y)
3001 {
3002 for (x = 0; x < desc.Width; ++x)
3003 {
3004 check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color, FALSE);
3005 }
3006 }
3007 }
3008 release_volume_readback(&volume_rb);
3009 }
3011 }
3012 else
3013 {
3014 skip("D3DFMT_DXT3 volume textures are not supported, skipping tests.\n");
3015 }
3016
3017 /* Load a BMP file into a volume texture. */
3020 D3DX_DEFAULT, D3DX_FILTER_POINT, 0, &img_info, NULL, &texture);
3021 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
3022
3028
3029 for (mip_level = 0; mip_level < 3; ++mip_level)
3030 {
3032 get_texture_volume_readback(device, texture, mip_level, &volume_rb);
3033 for (z = 0; z < desc.Depth; ++z)
3034 {
3035 for (y = 0; y < desc.Height; ++y)
3036 {
3037 const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(desc.Height == 1 || y < (desc.Height / 2)) ? 0 : 2];
3038
3039 for (x = 0; x < desc.Width; ++x)
3040 {
3041 if (desc.Width == 1 || x < (desc.Width / 2))
3042 check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE);
3043 else
3044 check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE);
3045 }
3046 }
3047 }
3048 release_volume_readback(&volume_rb);
3049 }
3051
3052 /* Create texture from JPG. */
3055 D3DX_DEFAULT, D3DX_FILTER_POINT, 0, &img_info, NULL, &texture);
3056 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
3057
3062
3064
3065 /* Create texture from PNG. */
3068 D3DX_DEFAULT, D3DX_FILTER_POINT, 0, &img_info, NULL, &texture);
3069 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3070
3075
3077
3080 D3DX_DEFAULT, D3DX_FILTER_POINT, 0, &img_info, NULL, &texture);
3081 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3082
3087
3089}
#define D3DUSAGE_DEPTHSTENCIL
Definition: d3d8types.h:92
#define check_volume_readback_pixel_4bpp(rb, x, y, z, color, todo)
#define get_texture_volume_readback(device, volume_tex, mip_level, rb)
#define release_volume_readback(rb)
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:1110
@ D3DXIFF_BMP
Definition: dx8vb.idl:62
GLdouble GLdouble z
Definition: glext.h:5874
#define check_volume_texture_level_desc(tex, level, format, usage, pool, width, height, depth, wine_todo)
Definition: texture.c:124
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:80

Referenced by START_TEST().

◆ test_D3DXFillCubeTexture()

static void test_D3DXFillCubeTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1655 of file texture.c.

1656{
1657 IDirect3DCubeTexture9 *tex;
1658 HRESULT hr;
1659
1660 /* A8R8G8B8 */
1662 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1663
1665 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1667
1669 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1671
1673
1674 /* A1R5G5B5 */
1676 D3DPOOL_MANAGED, &tex, NULL);
1677 if (SUCCEEDED(hr))
1678 {
1680 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1683 }
1684 else
1685 {
1686 skip("Texture format D3DFMT_A1R5G5B5 unsupported.\n");
1687 }
1688}
#define IDirect3DDevice9_CreateCubeTexture(p, a, b, c, d, e, f, g)
Definition: d3d9.h:1360
HRESULT WINAPI D3DXFillCubeTexture(struct IDirect3DCubeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
Definition: texture.c:1657
static void WINAPI fillfunc_cube(D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
Definition: texture.c:1492
#define compare_cube_texture(t, f, d)
Definition: texture.c:1593
static void WINAPI fillfunc_cube_coord(D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
Definition: texture.c:1501

Referenced by START_TEST().

◆ test_D3DXFillTexture()

static void test_D3DXFillTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1250 of file texture.c.

1251{
1252 static const struct
1253 {
1254 DWORD usage;
1255 D3DPOOL pool;
1256 }
1257 test_access_types[] =
1258 {
1259 {0, D3DPOOL_MANAGED},
1260 {0, D3DPOOL_DEFAULT},
1262 };
1263
1264 IDirect3DTexture9 *tex;
1265 HRESULT hr;
1266 D3DLOCKED_RECT lock_rect;
1267 DWORD x, y, m;
1268 DWORD v[4], e[4];
1269 DWORD value, expected, size, pitch;
1270 unsigned int i;
1271
1272 for (i = 0; i < ARRAY_SIZE(test_access_types); ++i)
1273 {
1274 size = 4;
1275 hr = IDirect3DDevice9_CreateTexture(device, size, size, 0, test_access_types[i].usage,
1276 D3DFMT_A8R8G8B8, test_access_types[i].pool, &tex, NULL);
1277 ok(hr == D3D_OK, "Unexpected hr %#lx, i %u.\n", hr, i);
1278
1280 ok(hr == D3D_OK, "Unexpected hr %#lx, i %u.\n", hr, i);
1281
1282 for (m = 0; m < 3; m++)
1283 {
1284 IDirect3DSurface9 *src_surface, *temp_surface;
1285
1286 hr = IDirect3DTexture9_GetSurfaceLevel(tex, m, &src_surface);
1287 ok(hr == D3D_OK, "Unexpected hr %#lx, i %u, m %lu.\n", hr, i, m);
1288 temp_surface = src_surface;
1289
1290 if (FAILED(hr = IDirect3DSurface9_LockRect(src_surface, &lock_rect, NULL, D3DLOCK_READONLY)))
1291 {
1293 D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &temp_surface, NULL);
1294 ok(hr == D3D_OK, "Unexpected hr %#lx, i %u, m %lu.\n", hr, i, m);
1295 hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL, temp_surface, NULL, D3DTEXF_NONE);
1296 ok(hr == D3D_OK, "Unexpected hr %#lx, i %u, m %lu.\n", hr, i, m);
1297 hr = IDirect3DSurface9_LockRect(temp_surface, &lock_rect, NULL, D3DLOCK_READONLY);
1298 ok(hr == D3D_OK, "Unexpected hr %#lx, i %u, m %lu.\n", hr, i, m);
1299 }
1300
1301 pitch = lock_rect.Pitch / sizeof(DWORD);
1302 for (y = 0; y < size; y++)
1303 {
1304 for (x = 0; x < size; x++)
1305 {
1306 value = ((DWORD *)lock_rect.pBits)[y * pitch + x];
1307 v[0] = (value >> 24) & 0xff;
1308 v[1] = (value >> 16) & 0xff;
1309 v[2] = (value >> 8) & 0xff;
1310 v[3] = value & 0xff;
1311
1312 e[0] = 0xff;
1313 e[1] = (x + 0.5f) / size * 255.0f + 0.5f;
1314 e[2] = (y + 0.5f) / size * 255.0f + 0.5f;
1315 e[3] = 255.0f / size + 0.5f;
1316 expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3];
1317
1318 ok(color_match(v, e),
1319 "Texel at (%lu, %lu) doesn't match: %#lx, expected %#lx, i %u, m %lu.\n",
1320 x, y, value, expected, i, m);
1321 }
1322 }
1323 IDirect3DSurface9_UnlockRect(temp_surface);
1324 if (temp_surface != src_surface)
1325 IDirect3DSurface9_Release(temp_surface);
1326 IDirect3DSurface9_Release(src_surface);
1327 size >>= 1;
1328 }
1330 }
1331
1334 if (hr == D3D_OK)
1335 {
1337 todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1339 }
1340
1343 if (hr == D3D_OK)
1344 {
1346 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1348 }
1349
1351 D3DPOOL_MANAGED, &tex, NULL);
1352
1353 if (SUCCEEDED(hr))
1354 {
1356 ok(hr == D3D_OK, "D3DXFillTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1357
1358 hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1359 ok(hr == D3D_OK, "Couldn't lock the texture, error %#lx\n", hr);
1360 if (SUCCEEDED(hr))
1361 {
1362 pitch = lock_rect.Pitch / sizeof(WORD);
1363 for (y = 0; y < 4; y++)
1364 {
1365 for (x = 0; x < 4; x++)
1366 {
1367 value = ((WORD *)lock_rect.pBits)[y * pitch + x];
1368 v[0] = value >> 15;
1369 v[1] = value >> 10 & 0x1f;
1370 v[2] = value >> 5 & 0x1f;
1371 v[3] = value & 0x1f;
1372
1373 e[0] = 1;
1374 e[1] = (x + 0.5f) / 4.0f * 31.0f + 0.5f;
1375 e[2] = (y + 0.5f) / 4.0f * 31.0f + 0.5f;
1376 e[3] = 8;
1377 expected = e[0] << 15 | e[1] << 10 | e[2] << 5 | e[3];
1378
1379 ok(color_match(v, e),
1380 "Texel at (%lu, %lu) doesn't match: %#lx, expected %#lx\n",
1381 x, y, value, expected);
1382 }
1383 }
1385 }
1386
1388 }
1389 else
1390 skip("Failed to create texture\n");
1391
1392 /* test floating-point textures */
1394 D3DPOOL_MANAGED, &tex, NULL);
1395
1396 if (SUCCEEDED(hr))
1397 {
1399 ok(hr == D3D_OK, "D3DXFillTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1400
1401 hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1402 if (SUCCEEDED(hr))
1403 {
1404 pitch = lock_rect.Pitch / sizeof(WORD);
1405 for (y = 0; y < 4; y++)
1406 {
1407 WORD *ptr = (WORD *)lock_rect.pBits + y * pitch;
1408 for (x = 0; x < 4; x++)
1409 {
1410 D3DXVECTOR4 got, expected;
1411
1412 D3DXFloat16To32Array((FLOAT *)&got, (D3DXFLOAT16 *)ptr, 4);
1413 ptr += 4;
1414
1415 expected.x = (x + 0.5f) / 4.0f;
1416 expected.y = (y + 0.5f) / 4.0f;
1417 expected.z = 1.0f / 4.0f;
1418 expected.w = 1.0f;
1419
1420 expect_vec4(&expected, &got);
1421 }
1422 }
1423
1425 }
1426 else
1427 skip("Failed to lock texture\n");
1428
1430 }
1431 else
1432 skip("Failed to create D3DFMT_A16B16G16R16F texture\n");
1433
1435 D3DPOOL_MANAGED, &tex, NULL);
1436
1437 if (SUCCEEDED(hr))
1438 {
1440 ok(hr == D3D_OK, "D3DXFillTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1441
1442 hr = IDirect3DTexture9_LockRect(tex, 0, &lock_rect, NULL, D3DLOCK_READONLY);
1443 if (SUCCEEDED(hr))
1444 {
1445 pitch = lock_rect.Pitch / sizeof(float);
1446 for (y = 0; y < 4; y++)
1447 {
1448 float *ptr = (float *)lock_rect.pBits + y * pitch;
1449 for (x = 0; x < 4; x++)
1450 {
1451 D3DXVECTOR4 got, expected;
1452
1453 got.x = *ptr++;
1454 got.y = *ptr++;
1455 got.z = *ptr++;
1456 got.w = *ptr++;
1457
1458 expected.x = (x + 0.5f) / 4.0f;
1459 expected.y = (y + 0.5f) / 4.0f;
1460 expected.z = 1.0f / 4.0f;
1461 expected.w = 1.0f;
1462
1463 expect_vec4(&expected, &got);
1464 }
1465 }
1466
1468 }
1469 else
1470 skip("Failed to lock texture\n");
1471
1473 }
1474 else
1475 skip("Failed to create D3DFMT_A32B32G32R32F texture\n");
1476
1477 /* test a compressed texture */
1479 D3DPOOL_MANAGED, &tex, NULL);
1480
1481 if (SUCCEEDED(hr))
1482 {
1484 todo_wine ok(hr == D3D_OK, "D3DXFillTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1485
1487 }
1488 else
1489 skip("Failed to create D3DFMT_DXT1 texture\n");
1490}
@ 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:1369
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1358
#define IDirect3DDevice9_CreateRenderTarget(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1363
@ D3DFMT_A32B32G32R32F
Definition: d3d9types.h:861
@ D3DFMT_A16B16G16R16F
Definition: d3d9types.h:856
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:1267
#define e
Definition: ke_i.h:82
#define todo_wine
Definition: minitest.h:80
static PVOID ptr
Definition: dispmode.c:27
static void WINAPI fillfunc(D3DXVECTOR4 *value, const D3DXVECTOR2 *texcoord, const D3DXVECTOR2 *texelsize, void *data)
Definition: texture.c:1241
#define expect_vec4(expected, got)
Definition: texture.c:39
static BOOL color_match(const DWORD *value, const DWORD *expected)
Definition: texture.c:1229
static float(__cdecl *square_half_float)(float x
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
float FLOAT
Definition: typedefs.h:69

Referenced by START_TEST().

◆ test_D3DXFillVolumeTexture()

static void test_D3DXFillVolumeTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1699 of file texture.c.

1700{
1701 IDirect3DVolumeTexture9 *tex;
1702 HRESULT hr;
1703 D3DLOCKED_BOX lock_box;
1704 DWORD x, y, z, m;
1705 DWORD v[4], e[4];
1706 DWORD value, expected, size, row_pitch, slice_pitch;
1707
1708 size = 4;
1710 D3DPOOL_DEFAULT, &tex, NULL);
1711 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1713 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1715
1717 D3DPOOL_MANAGED, &tex, NULL);
1718 if (SUCCEEDED(hr))
1719 {
1721 ok(hr == D3D_OK, "D3DXFillVolumeTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1722
1723 for (m = 0; m < 3; m++)
1724 {
1726 ok(hr == D3D_OK, "Couldn't lock the texture, error %#lx\n", hr);
1727 if (SUCCEEDED(hr))
1728 {
1729 row_pitch = lock_box.RowPitch / sizeof(DWORD);
1730 slice_pitch = lock_box.SlicePitch / sizeof(DWORD);
1731 for (z = 0; z < size; z++)
1732 {
1733 for (y = 0; y < size; y++)
1734 {
1735 for (x = 0; x < size; x++)
1736 {
1737 value = ((DWORD *)lock_box.pBits)[z * slice_pitch + y * row_pitch + x];
1738 v[0] = (value >> 24) & 0xff;
1739 v[1] = (value >> 16) & 0xff;
1740 v[2] = (value >> 8) & 0xff;
1741 v[3] = value & 0xff;
1742
1743 e[0] = 255.0f / size + 0.5f;
1744 e[1] = (x + 0.5f) / size * 255.0f + 0.5f;
1745 e[2] = (y + 0.5f) / size * 255.0f + 0.5f;
1746 e[3] = (z + 0.5f) / size * 255.0f + 0.5f;
1747 expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3];
1748
1749 ok(color_match(v, e),
1750 "Texel at (%lu, %lu, %lu) doesn't match: %#lx, expected %#lx\n",
1751 x, y, z, value, expected);
1752 }
1753 }
1754 }
1756 }
1757 size >>= 1;
1758 }
1759
1761 }
1762 else
1763 skip("Failed to create texture\n");
1764
1766 D3DPOOL_MANAGED, &tex, NULL);
1767
1768 if (SUCCEEDED(hr))
1769 {
1771 ok(hr == D3D_OK, "D3DXFillTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1773 ok(hr == D3D_OK, "Couldn't lock the texture, error %#lx\n", hr);
1774 if (SUCCEEDED(hr))
1775 {
1776 row_pitch = lock_box.RowPitch / sizeof(WORD);
1777 slice_pitch = lock_box.SlicePitch / sizeof(WORD);
1778 for (z = 0; z < 4; z++)
1779 {
1780 for (y = 0; y < 4; y++)
1781 {
1782 for (x = 0; x < 4; x++)
1783 {
1784 value = ((WORD *)lock_box.pBits)[z * slice_pitch + y * row_pitch + x];
1785 v[0] = value >> 15;
1786 v[1] = value >> 10 & 0x1f;
1787 v[2] = value >> 5 & 0x1f;
1788 v[3] = value & 0x1f;
1789
1790 e[0] = 1;
1791 e[1] = (x + 0.5f) / 4 * 31.0f + 0.5f;
1792 e[2] = (y + 0.5f) / 4 * 31.0f + 0.5f;
1793 e[3] = (z + 0.5f) / 4 * 31.0f + 0.5f;
1794 expected = e[0] << 15 | e[1] << 10 | e[2] << 5 | e[3];
1795
1796 ok(color_match(v, e),
1797 "Texel at (%lu, %lu, %lu) doesn't match: %#lx, expected %#lx\n",
1798 x, y, z, value, expected);
1799 }
1800 }
1801 }
1803 }
1804
1806 }
1807 else
1808 skip("Failed to create texture\n");
1809}
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1359
#define IDirect3DVolumeTexture9_LockBox(p, a, b, c, d)
Definition: d3d9.h:957
#define IDirect3DVolumeTexture9_UnlockBox(p, a)
Definition: d3d9.h:958
HRESULT WINAPI D3DXFillVolumeTexture(struct IDirect3DVolumeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
Definition: texture.c:1731
static void WINAPI fillfunc_volume(D3DXVECTOR4 *value, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
Definition: texture.c:1690

Referenced by START_TEST().

◆ test_D3DXFilterTexture()

static void test_D3DXFilterTexture ( IDirect3DDevice9 *  device)
static

Definition at line 1052 of file texture.c.

1053{
1054 IDirect3DTexture9 *tex;
1055 IDirect3DCubeTexture9 *cubetex;
1056 IDirect3DVolumeTexture9 *voltex;
1057 HRESULT hr;
1058 uint32_t i;
1059
1061
1062 if (SUCCEEDED(hr))
1063 {
1064 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, D3DX_DEFAULT, D3DX_FILTER_NONE);
1065 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1066
1067 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
1068 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1069
1070 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
1071 {
1072 winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
1073
1074 hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)tex, NULL, 0, test_filter_values[i].filter);
1075 ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
1076
1078 }
1079
1080 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_BOX + 1); /* Invalid filter */
1081 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1082
1083 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 5, D3DX_FILTER_NONE); /* Invalid miplevel */
1084 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1085
1087 }
1088 else
1089 skip("Failed to create texture\n");
1090
1092 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1093
1094 /* Test different pools */
1096
1097 if (SUCCEEDED(hr))
1098 {
1099 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
1100 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1102 }
1103 else
1104 skip("Failed to create texture\n");
1105
1107
1108 if (SUCCEEDED(hr))
1109 {
1110 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
1111 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1113 }
1114 else
1115 skip("Failed to create texture\n");
1116
1118 if (SUCCEEDED(hr))
1119 {
1120 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_POINT);
1121 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1123 }
1124 else
1125 skip("Failed to create texture\n");
1126
1128 if (SUCCEEDED(hr))
1129 {
1130 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_POINT);
1131 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1133 }
1134 else
1135 skip("Failed to create texture\n");
1136
1137 /* Cube texture test */
1139
1140 if (SUCCEEDED(hr))
1141 {
1142 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 0, D3DX_FILTER_NONE);
1143 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1144
1145 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 0, D3DX_FILTER_BOX + 1); /* Invalid filter */
1146 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1147
1148 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
1149 {
1150 winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
1151
1152 hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)cubetex, NULL, 0, test_filter_values[i].filter);
1153 ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
1154
1156 }
1157
1158 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 5, D3DX_FILTER_NONE); /* Invalid miplevel */
1159 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1161 }
1162 else
1163 skip("Failed to create texture\n");
1164
1165 /* Volume texture test */
1167 if (SUCCEEDED(hr))
1168 {
1169 DWORD level_count = IDirect3DVolumeTexture9_GetLevelCount(voltex);
1170
1171 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_NONE);
1172 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1173
1174 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_DEFAULT);
1175 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1176
1177 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_BOX);
1178 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1179
1180 for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i)
1181 {
1182 winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
1183
1184 hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)voltex, NULL, 0, test_filter_values[i].filter);
1185 ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
1186
1188 }
1189
1190 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count - 1, D3DX_DEFAULT);
1191 ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1192
1193 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count, D3DX_DEFAULT);
1194 ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
1195
1197 }
1198 else
1199 skip("Failed to create volume texture\n");
1200
1201 /* Test textures with D3DUSAGE_AUTOGENMIPMAP usage */
1203 {
1204 skip("No D3DUSAGE_AUTOGENMIPMAP supported for textures\n");
1205 return;
1206 }
1207
1209 if (SUCCEEDED(hr))
1210 {
1211 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
1212 ok(hr == D3D_OK, "D3dXFilteTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1214 }
1215 else
1216 skip("Failed to create texture\n");
1217
1219 if (SUCCEEDED(hr))
1220 {
1221 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE);
1222 ok(hr == D3D_OK, "D3dXFilteTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
1224 }
1225 else
1226 skip("Failed to create texture\n");
1227}
@ D3DPOOL_SCRATCH
Definition: d3d8types.h:712
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
Definition: texture.c:48
#define D3DX_FILTER_BOX
Definition: d3dx9tex.h:31

Referenced by START_TEST().

◆ test_D3DXSaveTextureToFileInMemory()

static void test_D3DXSaveTextureToFileInMemory ( IDirect3DDevice9 *  device)
static

Definition at line 3099 of file texture.c.

3100{
3101 HRESULT hr;
3102 IDirect3DTexture9 *texture;
3103 IDirect3DCubeTexture9 *cube_texture;
3104 IDirect3DVolumeTexture9 *volume_texture;
3106 void *buffer_pointer;
3109 D3DXIMAGE_FILEFORMAT file_format;
3110
3111 /* textures */
3113 if (FAILED(hr))
3114 {
3115 skip("Failed to create texture\n");
3116 return;
3117 }
3118
3119 for (file_format = D3DXIFF_BMP; file_format <= D3DXIFF_JPG; file_format++)
3120 {
3121 hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, (IDirect3DBaseTexture9 *)texture, NULL);
3122 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3123 if (SUCCEEDED(hr))
3124 {
3125 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
3128 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3129
3130 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
3131 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
3132 ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
3133 ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
3134 ok(info.ImageFileFormat == file_format, "Got file format %#x, expected %#x\n", info.ImageFileFormat, file_format);
3136 }
3137 }
3138
3139 todo_wine {
3140 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)texture, NULL);
3141 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3142 if (SUCCEEDED(hr))
3143 {
3144 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
3147 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3148
3149 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
3150 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
3151 ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
3152 ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
3153 ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
3155 }
3156 }
3157
3159
3160 /* cube textures */
3162 if (FAILED(hr))
3163 {
3164 skip("Failed to create cube texture\n");
3165 return;
3166 }
3167
3169 ok(hr == D3D_OK, "D3DXFillCubeTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
3170
3171 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_BMP, (IDirect3DBaseTexture9 *)cube_texture, NULL);
3172 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3173 if (SUCCEEDED(hr))
3174 {
3175 IDirect3DSurface9 *surface;
3176
3177 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
3180 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3181
3182 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
3183 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
3184 ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
3185 ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
3186 ok(info.ImageFileFormat == D3DXIFF_BMP, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_BMP);
3187
3188 /* positive x face is saved */
3190 if (SUCCEEDED(hr))
3191 {
3192 D3DLOCKED_RECT locked_rect;
3193
3195 ok(hr == D3D_OK, "D3DXLoadSurfaceFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3196
3197 hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, D3DLOCK_READONLY);
3198 if (SUCCEEDED(hr))
3199 {
3200 DWORD *color = locked_rect.pBits;
3201 ok(*color == 0x00ff0000, "Got color %#lx, expected %#x\n", *color, 0x00ff0000);
3203 }
3204
3206 } else skip("Failed to create surface\n");
3207
3209 }
3210
3211 todo_wine {
3212 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)cube_texture, NULL);
3213 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3214 if (SUCCEEDED(hr))
3215 {
3216 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
3219 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3220
3221 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
3222 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
3223 ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
3224 ok(info.ResourceType == D3DRTYPE_CUBETEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_CUBETEXTURE);
3225 ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
3227 }
3228 }
3229
3230 IDirect3DCubeTexture9_Release(cube_texture);
3231
3232 /* volume textures */
3233 hr = IDirect3DDevice9_CreateVolumeTexture(device, 256, 256, 256, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &volume_texture, NULL);
3234 if (FAILED(hr))
3235 {
3236 skip("Failed to create volume texture\n");
3237 return;
3238 }
3239
3240 todo_wine {
3241 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_BMP, (IDirect3DBaseTexture9 *)volume_texture, NULL);
3242 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3243 if (SUCCEEDED(hr))
3244 {
3245 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
3248 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3249
3250 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
3251 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
3252 ok(info.Depth == 1, "Got depth %u, expected %u\n", info.Depth, 1);
3253 ok(info.MipLevels == 1, "Got miplevels %u, expected %u\n", info.MipLevels, 1);
3254 ok(info.ResourceType == D3DRTYPE_TEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_TEXTURE);
3255 ok(info.ImageFileFormat == D3DXIFF_BMP, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_BMP);
3257 }
3258
3259 hr = D3DXSaveTextureToFileInMemory(&buffer, D3DXIFF_DDS, (IDirect3DBaseTexture9 *)volume_texture, NULL);
3260 ok(hr == D3D_OK, "D3DXSaveTextureToFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3261 if (SUCCEEDED(hr))
3262 {
3263 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
3266 ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
3267
3268 ok(info.Width == 256, "Got width %u, expected %u\n", info.Width, 256);
3269 ok(info.Height == 256, "Got height %u, expected %u\n", info.Height, 256);
3270 ok(info.Depth == 256, "Got depth %u, expected %u\n", info.Depth, 256);
3271 ok(info.MipLevels == 9, "Got miplevels %u, expected %u\n", info.MipLevels, 9);
3272 ok(info.ResourceType == D3DRTYPE_VOLUMETEXTURE, "Got resource type %#x, expected %#x\n", info.ResourceType, D3DRTYPE_VOLUMETEXTURE);
3273 ok(info.ImageFileFormat == D3DXIFF_DDS, "Got file format %#x, expected %#x\n", info.ImageFileFormat, D3DXIFF_DDS);
3275 }
3276 }
3277
3278 IDirect3DVolumeTexture9_Release(volume_texture);
3279}
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, D3DXIMAGE_INFO *info)
Definition: surface.c:1489
HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
Definition: texture.c:1856
D3DXIMAGE_FILEFORMAT
Definition: dx8vb.idl:61
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
GLuint buffer
Definition: glext.h:5915
static void WINAPI fill_cube_positive_x(D3DXVECTOR4 *out, const D3DXVECTOR3 *tex_coord, const D3DXVECTOR3 *texel_size, void *data)
Definition: texture.c:3092
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95

Referenced by START_TEST().

◆ test_texture_shader()

static void test_texture_shader ( void  )
static

Definition at line 3281 of file texture.c.

3282{
3283 static const DWORD shader_zero[] = {0x0};
3284 static const DWORD shader_invalid[] = {0xeeee0100};
3285 static const DWORD shader_empty[] = {0xfffe0200, 0x0000ffff};
3286#if 0
3287float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR
3288{
3289 return float4(pos, 1.0);
3290}
3291#endif
3292 static const DWORD shader_code[] =
3293 {
3294 0x54580100, 0x0015fffe, 0x42415443, 0x0000001c, 0x0000001f, 0x54580100, 0x00000000, 0x00000000,
3295 0x00000100, 0x0000001c, 0x4d007874, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
3296 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072, 0x392e3932, 0x332e3235, 0x00313131, 0x000afffe,
3297 0x54494c43, 0x00000004, 0x00000000, 0x3ff00000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3298 0x00000000, 0x00000000, 0x0014fffe, 0x434c5846, 0x00000002, 0x10000003, 0x00000001, 0x00000000,
3299 0x00000003, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x10000001, 0x00000001, 0x00000000,
3300 0x00000001, 0x00000000, 0x00000000, 0x00000004, 0x00000003, 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff,
3301 };
3302#if 0
3303float f1[2] = { 0.4f, 0.1f };
3304bool b1 = false;
3305float4 f2;
3306bool b2[2];
3307
3308struct s
3309{
3310 bool b3;
3311 float f3;
3312 float4 f4;
3313 uint i1;
3314 int i2;
3315};
3316
3317struct s s1;
3318
3319float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR
3320{
3321 float t = b2[0] * b2[1] * f2.x + s1.i2;
3322 return float4(pos, f1[0] + f1[1] + b1 * 0.6f + t);
3323}
3324#endif
3325 static const DWORD shader_code2[] =
3326 {
3327 0x54580100, 0x0074fffe, 0x42415443, 0x0000001c, 0x000001a3, 0x54580100, 0x00000005, 0x0000001c,
3328 0x00000100, 0x000001a0, 0x00000080, 0x00090002, 0x00000001, 0x00000084, 0x00000094, 0x000000a4,
3329 0x00070002, 0x00000002, 0x000000a8, 0x00000000, 0x000000b8, 0x00050002, 0x00000002, 0x000000bc,
3330 0x000000cc, 0x000000ec, 0x000a0002, 0x00000001, 0x000000f0, 0x00000000, 0x00000100, 0x00000002,
3331 0x00000005, 0x00000190, 0x00000000, 0xab003162, 0x00010000, 0x00010001, 0x00000001, 0x00000000,
3332 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xab003262, 0x00010000, 0x00010001, 0x00000002,
3333 0x00000000, 0xab003166, 0x00030000, 0x00010001, 0x00000002, 0x00000000, 0x3ecccccd, 0x00000000,
3334 0x00000000, 0x00000000, 0x3dcccccd, 0x00000000, 0x00000000, 0x00000000, 0xab003266, 0x00030001,
3335 0x00040001, 0x00000001, 0x00000000, 0x62003173, 0xabab0033, 0x00010000, 0x00010001, 0x00000001,
3336 0x00000000, 0xab003366, 0x00030000, 0x00010001, 0x00000001, 0x00000000, 0xab003466, 0x00030001,
3337 0x00040001, 0x00000001, 0x00000000, 0xab003169, 0x00020000, 0x00010001, 0x00000001, 0x00000000,
3338 0xab003269, 0x00020000, 0x00010001, 0x00000001, 0x00000000, 0x00000103, 0x00000108, 0x00000118,
3339 0x0000011c, 0x0000012c, 0x00000130, 0x00000140, 0x00000144, 0x00000154, 0x00000158, 0x00000005,
3340 0x00080001, 0x00050001, 0x00000168, 0x4d007874, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820,
3341 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, 0x0062fffe, 0x54494c43,
3342 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3343 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3344 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3345 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3346 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3347 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3348 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3349 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3350 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3351 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3352 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3353 0x00000000, 0x40000000, 0x3fe33333, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3354 0x00000000, 0x0059fffe, 0x434c5846, 0x00000008, 0xa0500001, 0x00000002, 0x00000000, 0x00000002,
3355 0x0000001c, 0x00000000, 0x00000002, 0x00000020, 0x00000000, 0x00000007, 0x00000000, 0xa0500001,
3356 0x00000002, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000002, 0x00000028, 0x00000000,
3357 0x00000007, 0x00000004, 0xa0400001, 0x00000002, 0x00000000, 0x00000007, 0x00000004, 0x00000000,
3358 0x00000002, 0x00000010, 0x00000000, 0x00000007, 0x00000000, 0xa0400001, 0x00000002, 0x00000000,
3359 0x00000002, 0x00000014, 0x00000000, 0x00000002, 0x00000018, 0x00000000, 0x00000007, 0x00000001,
3360 0xa0500001, 0x00000002, 0x00000000, 0x00000002, 0x00000024, 0x00000000, 0x00000001, 0x0000002c,
3361 0x00000000, 0x00000007, 0x00000002, 0xa0400001, 0x00000002, 0x00000000, 0x00000007, 0x00000002,
3362 0x00000000, 0x00000007, 0x00000001, 0x00000000, 0x00000007, 0x00000004, 0xa0400001, 0x00000002,
3363 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000007, 0x00000004, 0x00000000, 0x00000004,
3364 0x00000003, 0x10000003, 0x00000001, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000004,
3365 0x00000000, 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff,
3366 };
3367 IDirect3DVolumeTexture9 *volume_texture;
3368 IDirect3DCubeTexture9 *cube_texture;
3369 D3DXCONSTANTTABLE_DESC ctab_desc;
3370 ID3DXBuffer *buffer, *buffer2;
3371 D3DXCONSTANT_DESC const_desc;
3372 unsigned int x, y, z, count;
3374 IDirect3DTexture9 *texture;
3376 ID3DXTextureShader *tx;
3377 unsigned int *data;
3378 D3DLOCKED_RECT lr;
3379 D3DLOCKED_BOX lb;
3380 D3DXHANDLE h, h2;
3381 IDirect3D9 *d3d;
3382 D3DCAPS9 caps;
3383 DWORD size;
3384 HRESULT hr;
3385 HWND wnd;
3386
3388 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
3389
3390 tx = (void *)0xdeadbeef;
3392 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
3393 ok(tx == (void *)0xdeadbeef, "Unexpected pointer %p.\n", tx);
3394
3395 tx = (void *)0xdeadbeef;
3397 ok(hr == D3DXERR_INVALIDDATA, "Got unexpected hr %#lx.\n", hr);
3398 ok(tx == (void *)0xdeadbeef, "Unexpected pointer %p.\n", tx);
3399
3400 tx = (void *)0xdeadbeef;
3402 ok(hr == D3DXERR_INVALIDDATA, "Got unexpected hr %#lx.\n", hr);
3403 ok(tx == (void *)0xdeadbeef, "Unexpected pointer %p.\n", tx);
3404
3405 tx = (void *)0xdeadbeef;
3407 ok(hr == D3DXERR_INVALIDDATA, "Got unexpected hr %#lx.\n", hr);
3408 ok(tx == (void *)0xdeadbeef, "Unexpected pointer %p.\n", tx);
3409
3410 hr = D3DXCreateTextureShader(shader_code, &tx);
3411 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
3412
3413 hr = tx->lpVtbl->GetFunction(tx, &buffer);
3414 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3415
3416 hr = tx->lpVtbl->GetFunction(tx, &buffer2);
3417 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3418 ok(buffer2 == buffer, "Unexpected buffer object.\n");
3419 ID3DXBuffer_Release(buffer2);
3420
3422 ok(size == 224, "Unexpected buffer size %lu.\n", size);
3423
3425
3426 /* Constant buffer */
3427 hr = tx->lpVtbl->GetConstantBuffer(tx, &buffer);
3428 todo_wine
3429 ok(SUCCEEDED(hr), "Failed to get texture shader constant buffer.\n");
3430
3431 if (SUCCEEDED(hr))
3432 {
3434 ok(!size, "Unexpected buffer size %lu.\n", size);
3435
3437 }
3438
3439 hr = tx->lpVtbl->GetDesc(tx, &ctab_desc);
3440 todo_wine
3441 ok(hr == S_OK, "Failed to get constant description, hr %#lx.\n", hr);
3442 if (SUCCEEDED(hr))
3443 ok(!ctab_desc.Constants, "Unexpected number of constants %u.\n", ctab_desc.Constants);
3444
3445 /* Constant table access calls, without constant table. */
3446 h = tx->lpVtbl->GetConstant(tx, NULL, 0);
3447 ok(!h, "Unexpected handle %p.\n", h);
3448
3449 if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
3450 640, 480, NULL, NULL, NULL, NULL)))
3451 {
3452 skip("Couldn't create application window.\n");
3453 IUnknown_Release(tx);
3454 return;
3455 }
3457 if (!d3d)
3458 {
3459 skip("Couldn't create IDirect3D9 object.\n");
3460 DestroyWindow(wnd);
3461 IUnknown_Release(tx);
3462 return;
3463 }
3464
3465 ZeroMemory(&d3dpp, sizeof(d3dpp));
3466 d3dpp.Windowed = TRUE;
3470 if (FAILED(hr))
3471 {
3472 skip("Failed to create IDirect3DDevice9 object, hr %#lx.\n", hr);
3473 IDirect3D9_Release(d3d);
3474 DestroyWindow(wnd);
3475 IUnknown_Release(tx);
3476 return;
3477 }
3478
3480
3482 &texture, NULL);
3483 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
3484
3486 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
3487
3489 ok(SUCCEEDED(hr), "Locking texture failed, hr %#lx.\n", hr);
3490 data = lr.pBits;
3491 for (y = 0; y < 256; ++y)
3492 {
3493 for (x = 0; x < 256; ++x)
3494 {
3495 unsigned int expected = 0xff000000 | x << 16 | y << 8;
3496 /* The third position coordinate is apparently undefined for 2D textures. */
3497 unsigned int color = data[y * lr.Pitch / sizeof(*data) + x] & 0xffffff00;
3498
3499 ok(compare_color(color, expected, 1), "Unexpected color %08x at (%u, %u).\n", color, x, y);
3500 }
3501 }
3503 ok(SUCCEEDED(hr), "Unlocking texture failed, hr %#lx.\n", hr);
3504
3506
3508 {
3509 skip("Cube textures not supported, skipping tests.\n");
3510 goto cleanup;
3511 }
3512
3514 &cube_texture, NULL);
3515 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
3516
3517 hr = D3DXFillCubeTextureTX(cube_texture, tx);
3518 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
3519 compare_cube_texture(cube_texture, fillfunc_cube_coord, 1);
3520 IDirect3DCubeTexture9_Release(cube_texture);
3521
3522 if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) || caps.MaxVolumeExtent < 64)
3523 {
3524 skip("Volume textures not supported, skipping test.\n");
3525 goto cleanup;
3526 }
3528 D3DPOOL_SYSTEMMEM, &volume_texture, NULL);
3529 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
3530
3531 hr = D3DXFillVolumeTextureTX(volume_texture, tx);
3532 todo_wine
3533 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
3534
3535 hr = IDirect3DVolumeTexture9_LockBox(volume_texture, 0, &lb, NULL, D3DLOCK_READONLY);
3536 ok(SUCCEEDED(hr), "Locking texture failed, hr %#lx.\n", hr);
3537 data = lb.pBits;
3538 for (z = 0; z < 64; ++z)
3539 {
3540 for (y = 0; y < 64; ++y)
3541 {
3542 for (x = 0; x < 64; ++x)
3543 {
3544 unsigned int expected = 0xff000000 | ((x * 4 + 2) << 16) | ((y * 4 + 2) << 8) | (z * 4 + 2);
3545 unsigned int color = data[z * lb.SlicePitch / sizeof(*data) + y * lb.RowPitch / sizeof(*data) + x];
3546
3547 todo_wine
3548 ok(compare_color(color, expected, 1), "Unexpected color %08x at (%u, %u, %u).\n",
3549 color, x, y, z);
3550 }
3551 }
3552 }
3553 hr = IDirect3DVolumeTexture9_UnlockBox(volume_texture, 0);
3554 ok(SUCCEEDED(hr), "Unlocking texture failed, hr %#lx.\n", hr);
3555
3556 IDirect3DVolumeTexture9_Release(volume_texture);
3557
3558 IUnknown_Release(tx);
3559
3560 /* With constant table */
3561 tx = NULL;
3562 hr = D3DXCreateTextureShader(shader_code2, &tx);
3563 todo_wine
3564 ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
3565 if (FAILED(hr))
3566 goto cleanup;
3567
3568 hr = tx->lpVtbl->GetConstantBuffer(tx, &buffer);
3569 todo_wine
3570 ok(SUCCEEDED(hr), "Failed to get texture shader constant buffer.\n");
3571 if (FAILED(hr))
3572 {
3573 skip("Texture shaders not supported, skipping further tests.\n");
3574 IUnknown_Release(tx);
3575 return;
3576 }
3577
3579 ok(size == 176, "Unexpected buffer size %lu.\n", size);
3580
3581 hr = tx->lpVtbl->GetDesc(tx, &ctab_desc);
3582 ok(hr == S_OK, "Failed to get constant description, hr %#lx.\n", hr);
3583 ok(ctab_desc.Constants == 5, "Unexpected number of constants %u.\n", ctab_desc.Constants);
3584
3585 h = tx->lpVtbl->GetConstant(tx, NULL, 0);
3586 ok(!!h, "Unexpected handle %p.\n", h);
3587 hr = tx->lpVtbl->GetConstantDesc(tx, h, &const_desc, &count);
3588 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3589 ok(!strcmp(const_desc.Name, "b1"), "Unexpected name %s.\n", const_desc.Name);
3590 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3591 ok(const_desc.RegisterIndex == 9, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3592 ok(const_desc.RegisterCount == 1, "Unexpected register count %u.\n", const_desc.RegisterCount);
3593
3594 h = tx->lpVtbl->GetConstant(tx, NULL, 1);
3595 ok(!!h, "Unexpected handle %p.\n", h);
3596 hr = tx->lpVtbl->GetConstantDesc(tx, h, &const_desc, &count);
3597 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3598 ok(!strcmp(const_desc.Name, "b2"), "Unexpected name %s.\n", const_desc.Name);
3599 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3600 ok(const_desc.RegisterIndex == 7, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3601 ok(const_desc.RegisterCount == 2, "Unexpected register count %u.\n", const_desc.RegisterCount);
3602
3603 h = tx->lpVtbl->GetConstant(tx, NULL, 2);
3604 ok(!!h, "Unexpected handle %p.\n", h);
3605 hr = tx->lpVtbl->GetConstantDesc(tx, h, &const_desc, &count);
3606 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3607 ok(!strcmp(const_desc.Name, "f1"), "Unexpected name %s.\n", const_desc.Name);
3608 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3609 ok(const_desc.RegisterIndex == 5, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3610 ok(const_desc.RegisterCount == 2, "Unexpected register count %u.\n", const_desc.RegisterCount);
3611 ok(const_desc.Elements == 2, "Unexpected elements count %u.\n", const_desc.Elements);
3612
3613 /* Array */
3614 h2 = tx->lpVtbl->GetConstantElement(tx, h, 0);
3615 ok(!!h2, "Unexpected handle %p.\n", h);
3616 hr = tx->lpVtbl->GetConstantDesc(tx, h2, &const_desc, &count);
3617 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3618 ok(!strcmp(const_desc.Name, "f1"), "Unexpected name %s.\n", const_desc.Name);
3619 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3620 ok(const_desc.RegisterIndex == 5, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3621 ok(const_desc.RegisterCount == 1, "Unexpected register count %u.\n", const_desc.RegisterCount);
3622 ok(const_desc.Elements == 1, "Unexpected elements count %u.\n", const_desc.Elements);
3623
3624 h2 = tx->lpVtbl->GetConstantElement(tx, h, 1);
3625 ok(!!h2, "Unexpected handle %p.\n", h);
3626 hr = tx->lpVtbl->GetConstantDesc(tx, h2, &const_desc, &count);
3627 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3628 ok(!strcmp(const_desc.Name, "f1"), "Unexpected name %s.\n", const_desc.Name);
3629 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3630 ok(const_desc.RegisterIndex == 6, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3631 ok(const_desc.RegisterCount == 1, "Unexpected register count %u.\n", const_desc.RegisterCount);
3632 ok(const_desc.Elements == 1, "Unexpected elements count %u.\n", const_desc.Elements);
3633
3634 h2 = tx->lpVtbl->GetConstantElement(tx, h, 2);
3635 ok(!h2, "Unexpected handle %p.\n", h);
3636
3637 h = tx->lpVtbl->GetConstant(tx, NULL, 3);
3638 ok(!!h, "Unexpected handle %p.\n", h);
3639 hr = tx->lpVtbl->GetConstantDesc(tx, h, &const_desc, &count);
3640 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3641 ok(!strcmp(const_desc.Name, "f2"), "Unexpected name %s.\n", const_desc.Name);
3642 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3643 ok(const_desc.RegisterIndex == 10, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3644 ok(const_desc.RegisterCount == 1, "Unexpected register count %u.\n", const_desc.RegisterCount);
3645
3646 /* Structure */
3647 h = tx->lpVtbl->GetConstant(tx, NULL, 4);
3648 ok(!!h, "Unexpected handle %p.\n", h);
3649 hr = tx->lpVtbl->GetConstantDesc(tx, h, &const_desc, &count);
3650 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3651 ok(!strcmp(const_desc.Name, "s1"), "Unexpected name %s.\n", const_desc.Name);
3652 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3653 ok(const_desc.RegisterIndex == 0, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3654 ok(const_desc.RegisterCount == 5, "Unexpected register count %u.\n", const_desc.RegisterCount);
3655 ok(const_desc.Class == D3DXPC_STRUCT, "Unexpected class %u.\n", const_desc.Class);
3656 ok(const_desc.StructMembers == 5, "Unexpected member count %u.\n", const_desc.StructMembers);
3657
3658 h2 = tx->lpVtbl->GetConstant(tx, h, 0);
3659 ok(!!h2, "Unexpected handle %p.\n", h);
3660 hr = tx->lpVtbl->GetConstantDesc(tx, h2, &const_desc, &count);
3661 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3662 ok(!strcmp(const_desc.Name, "b3"), "Unexpected name %s.\n", const_desc.Name);
3663 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3664 ok(const_desc.RegisterIndex == 0, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3665 ok(const_desc.RegisterCount == 1, "Unexpected register count %u.\n", const_desc.RegisterCount);
3666 ok(const_desc.Elements == 1, "Unexpected elements count %u.\n", const_desc.Elements);
3667
3668 h2 = tx->lpVtbl->GetConstant(tx, h, 1);
3669 ok(!!h2, "Unexpected handle %p.\n", h);
3670 hr = tx->lpVtbl->GetConstantDesc(tx, h2, &const_desc, &count);
3671 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3672 ok(!strcmp(const_desc.Name, "f3"), "Unexpected name %s.\n", const_desc.Name);
3673 ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Unexpected register set %u.\n", const_desc.RegisterSet);
3674 ok(const_desc.RegisterIndex == 1, "Unexpected register index %u.\n", const_desc.RegisterIndex);
3675 ok(const_desc.RegisterCount == 1, "Unexpected register count %u.\n", const_desc.RegisterCount);
3676 ok(const_desc.Elements == 1, "Unexpected elements count %u.\n", const_desc.Elements);
3677
3678 h2 = tx->lpVtbl->GetConstant(tx, h, 10);
3679 ok(!h2, "Unexpected handle %p.\n", h);
3680
3682
3683 cleanup:
3685 IDirect3D9_Release(d3d);
3686 DestroyWindow(wnd);
3687 if (tx)
3688 IUnknown_Release(tx);
3689}
UINT32 uint
Definition: types.h:83
HRESULT WINAPI D3DXFillCubeTextureTX(struct IDirect3DCubeTexture9 *cube, ID3DXTextureShader *texture_shader)
Definition: shader.c:2749
HRESULT WINAPI D3DXFillTextureTX(struct IDirect3DTexture9 *texture, ID3DXTextureShader *texture_shader)
Definition: shader.c:2740
HRESULT WINAPI D3DXCreateTextureShader(const DWORD *function, ID3DXTextureShader **texture_shader)
Definition: shader.c:2644
HRESULT WINAPI D3DXFillVolumeTextureTX(struct IDirect3DVolumeTexture9 *texture, ID3DXTextureShader *texture_shader)
Definition: texture.c:1800
static void cleanup(void)
Definition: main.c:1335
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
int main()
Definition: test.c:6
@ D3DXPC_STRUCT
Definition: d3dx9shader.h:67
@ D3DXRS_FLOAT4
Definition: d3dx9shader.h:55
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble t
Definition: gl.h:2047
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
struct S1 s1
static CRYPT_DATA_BLOB b3[]
Definition: msg.c:548
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:538
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:529
static const DWORD shader_invalid[]
Definition: shader.c:31
static const DWORD shader_empty[]
Definition: shader.c:33
static const DWORD shader_zero[]
Definition: shader.c:29
#define f2(x, y, z)
Definition: sha1.c:31
#define f1(x, y, z)
Definition: sha1.c:30
#define f4(x, y, z)
Definition: sha1.c:33
#define f3(x, y, z)
Definition: sha1.c:32
const char * Name
Definition: d3dx9shader.h:105
D3DXPARAMETER_CLASS Class
Definition: d3dx9shader.h:109
D3DXREGISTER_SET RegisterSet
Definition: d3dx9shader.h:106
Definition: icm.h:105

Referenced by START_TEST().

Variable Documentation

◆ has_2d_dxt1

int has_2d_dxt1
static

Definition at line 30 of file texture.c.

Referenced by START_TEST(), and test_D3DXCheckTextureRequirements().

◆ has_2d_dxt3

int has_2d_dxt3
static

◆ has_2d_dxt5

int has_2d_dxt5
static

◆ has_3d_dxt3

◆ has_cube_dxt5

int has_cube_dxt5
static

Definition at line 30 of file texture.c.

Referenced by START_TEST(), and test_D3DXCreateTextureFromFileInMemory().