ReactOS 0.4.17-dev-966-gf06eace
texture.c File Reference
#include <assert.h>
#include "d3dx9_private.h"
Include dependency graph for texture.c:

Go to the source code of this file.

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

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static BOOL is_pow2 (UINT num)
 
static HRESULT get_surface (D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, int face, UINT level, struct IDirect3DSurface9 **surf)
 
HRESULT WINAPI D3DXFilterTexture (IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
 
static D3DFORMAT get_replacement_format (D3DFORMAT format)
 
static HRESULT check_texture_requirements (struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool, D3DRESOURCETYPE resource_type)
 
HRESULT WINAPI D3DXCheckTextureRequirements (struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCheckCubeTextureRequirements (struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCheckVolumeTextureRequirements (struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCreateTexture (struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
 
static D3DFORMAT get_alpha_replacement_format (D3DFORMAT format)
 
static uint32_t d3dx9_get_mip_filter_value (uint32_t mip_filter, uint32_t *skip_levels)
 
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)
 
HRESULT WINAPI D3DXCreateTextureFromFileInMemory (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileExW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, 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)
 
HRESULT WINAPI D3DXCreateTextureFromFileExA (struct IDirect3DDevice9 *device, const char *srcfile, 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)
 
HRESULT WINAPI D3DXCreateTextureFromFileA (struct IDirect3DDevice9 *device, const char *srcfile, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromResourceA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromResourceW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, struct IDirect3DTexture9 **texture)
 
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)
 
HRESULT WINAPI D3DXCreateTextureFromResourceExW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *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)
 
HRESULT WINAPI D3DXCreateCubeTexture (struct IDirect3DDevice9 *device, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DCubeTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory (struct IDirect3DDevice9 *device, const void *data, UINT datasize, struct IDirect3DCubeTexture9 **texture)
 
HRESULT WINAPI D3DXCreateVolumeTexture (struct IDirect3DDevice9 *device, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DVolumeTexture9 **texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileA (IDirect3DDevice9 *device, const char *filename, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileW (IDirect3DDevice9 *device, const WCHAR *filename, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileExA (IDirect3DDevice9 *device, const char *filename, 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 *src_info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileExW (IDirect3DDevice9 *device, const WCHAR *filename, 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 *src_info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory (IDirect3DDevice9 *device, const void *data, UINT data_size, IDirect3DVolumeTexture9 **volume_texture)
 
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)
 
HRESULT WINAPI D3DXFillTexture (struct IDirect3DTexture9 *texture, LPD3DXFILL2D function, void *funcdata)
 
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)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileA (IDirect3DDevice9 *device, const char *src_filename, IDirect3DCubeTexture9 **cube_texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileW (IDirect3DDevice9 *device, const WCHAR *src_filename, IDirect3DCubeTexture9 **cube_texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileExA (IDirect3DDevice9 *device, const char *src_filename, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *image_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileExW (IDirect3DDevice9 *device, const WCHAR *src_filename, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *image_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
 
static float get_cube_coord (enum cube_coord coord, unsigned int x, unsigned int y, unsigned int size)
 
HRESULT WINAPI D3DXFillCubeTexture (struct IDirect3DCubeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
 
HRESULT WINAPI D3DXFillVolumeTexture (struct IDirect3DVolumeTexture9 *texture, LPD3DXFILL3D function, void *funcdata)
 
HRESULT WINAPI D3DXFillVolumeTextureTX (struct IDirect3DVolumeTexture9 *texture, ID3DXTextureShader *texture_shader)
 
HRESULT WINAPI D3DXSaveTextureToFileA (const char *dst_filename, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
 
HRESULT WINAPI D3DXSaveTextureToFileW (const WCHAR *dst_filename, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
 
HRESULT WINAPI D3DXSaveTextureToFileInMemory (ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
 
HRESULT WINAPI D3DXComputeNormalMap (IDirect3DTexture9 *texture, IDirect3DTexture9 *src_texture, const PALETTEENTRY *src_palette, DWORD flags, DWORD channel, float amplitude)
 

Enumeration Type Documentation

◆ cube_coord

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

Definition at line 1625 of file texture.c.

1626{
1627 XCOORD = 0,
1628 XCOORDINV = 1,
1629 YCOORD = 2,
1630 YCOORDINV = 3,
1631 ZERO = 4,
1632 ONE = 5
1633};
@ 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_texture_requirements()

static HRESULT check_texture_requirements ( struct IDirect3DDevice9 *  device,
UINT *  width,
UINT *  height,
UINT *  miplevels,
DWORD  usage,
D3DFORMAT *  format,
D3DPOOL  pool,
D3DRESOURCETYPE  resource_type 
)
static

Definition at line 198 of file texture.c.

200{
201 UINT w = (width && *width) ? *width : 1;
202 UINT h = (height && *height) ? *height : 1;
203 D3DCAPS9 caps;
205 IDirect3D9 *d3d = NULL;
207 HRESULT hr;
208 D3DFORMAT usedformat = D3DFMT_UNKNOWN;
209 const struct pixel_format_desc *fmt;
210
211 if (!device)
212 return D3DERR_INVALIDCALL;
213
214 /* usage */
215 if (usage == D3DX_DEFAULT)
216 usage = 0;
218 return D3DERR_INVALIDCALL;
219
220 /* pool */
222 return D3DERR_INVALIDCALL;
223
224 /* format */
225 if (format)
226 {
227 TRACE("Requested format %x\n", *format);
228 usedformat = *format;
229 }
230
232
233 if (FAILED(hr))
234 goto cleanup;
235
237
238 if (FAILED(hr))
239 goto cleanup;
240
242
243 if (FAILED(hr))
244 goto cleanup;
245
246 if ((usedformat == D3DFMT_UNKNOWN) || (usedformat == D3DX_DEFAULT))
247 usedformat = D3DFMT_A8R8G8B8;
248
249 fmt = get_format_info(usedformat);
250
251 hr = IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType, mode.Format,
252 usage, resource_type, usedformat);
253 if (FAILED(hr))
254 {
255 BOOL allow_24bits;
256 int bestscore = INT_MIN, i = 0, j;
257 unsigned int channels;
258 const struct pixel_format_desc *curfmt, *bestfmt = NULL;
259
260 TRACE("Requested format is not supported, looking for a fallback.\n");
261
262 if (!fmt)
263 {
264 FIXME("Pixel format %x not handled\n", usedformat);
265 goto cleanup;
266 }
268
269 allow_24bits = fmt->bytes_per_pixel == 3;
270 channels = !!fmt->bits[0] + !!fmt->bits[1] + !!fmt->bits[2] + !!fmt->bits[3];
271 usedformat = D3DFMT_UNKNOWN;
272
273 while ((curfmt = get_format_info_idx(i)))
274 {
275 unsigned int curchannels = !!curfmt->bits[0] + !!curfmt->bits[1]
276 + !!curfmt->bits[2] + !!curfmt->bits[3];
277 D3DFORMAT cur_d3dfmt;
278 int score;
279
280 i++;
281
282 if ((cur_d3dfmt = d3dformat_from_d3dx_pixel_format_id(curfmt->format)) == D3DFMT_UNKNOWN)
283 continue;
284 if (curchannels < channels)
285 continue;
286 if (curfmt->bytes_per_pixel == 3 && !allow_24bits)
287 continue;
288
289 hr = IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType,
290 mode.Format, usage, resource_type, cur_d3dfmt);
291 if (FAILED(hr))
292 continue;
293
294 /* This format can be used, let's evaluate it.
295 Weights chosen quite arbitrarily... */
296 score = 512 * (format_types_match(curfmt, fmt));
297 score -= 32 * (curchannels - channels);
298
299 for (j = 0; j < 4; j++)
300 {
301 int diff = curfmt->bits[j] - fmt->bits[j];
302 score -= (diff < 0 ? -diff * 8 : diff) * (j == 0 ? 1 : 2);
303 }
304
305 if (score > bestscore)
306 {
307 bestscore = score;
308 usedformat = cur_d3dfmt;
309 bestfmt = curfmt;
310 }
311 }
312 if (!bestfmt)
313 {
315 goto cleanup;
316 }
317 fmt = bestfmt;
318 hr = D3D_OK;
319 }
320
322 return D3DERR_INVALIDCALL;
323
324 if ((w == D3DX_DEFAULT) && (h == D3DX_DEFAULT))
325 w = h = 256;
326 else if (w == D3DX_DEFAULT)
327 w = (height ? h : 256);
328 else if (h == D3DX_DEFAULT)
329 h = (width ? w : 256);
330
331 assert(!(fmt->block_width & (fmt->block_width - 1)));
332 assert(!(fmt->block_height & (fmt->block_height - 1)));
333 if (w & (fmt->block_width - 1))
334 w = (w + fmt->block_width) & ~(fmt->block_width - 1);
335 if (h & (fmt->block_height - 1))
336 h = (h + fmt->block_height) & ~(fmt->block_height - 1);
337
338 if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))
339 w = make_pow2(w);
340
341 if (w > caps.MaxTextureWidth)
342 w = caps.MaxTextureWidth;
343
344 if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(h)))
345 h = make_pow2(h);
346
347 if (h > caps.MaxTextureHeight)
348 h = caps.MaxTextureHeight;
349
351 {
352 if (w > h)
353 h = w;
354 else
355 w = h;
356 }
357
358 if (width)
359 *width = w;
360
361 if (height)
362 *height = h;
363
364 if (miplevels && (usage & D3DUSAGE_AUTOGENMIPMAP))
365 {
366 if (*miplevels > 1)
367 *miplevels = 0;
368 }
369 else if (miplevels)
370 {
371 UINT max_mipmaps = 1;
372
373 if (!width && !height)
374 max_mipmaps = 9; /* number of mipmaps in a 256x256 texture */
375 else
376 {
377 UINT max_dimen = max(w, h);
378
379 while (max_dimen > 1)
380 {
381 max_dimen >>= 1;
382 max_mipmaps++;
383 }
384 }
385
386 if (*miplevels == 0 || *miplevels > max_mipmaps)
387 *miplevels = max_mipmaps;
388 }
389
390cleanup:
391
392 if (d3d)
394
395 if (FAILED(hr))
396 return hr;
397
398 if (usedformat == D3DFMT_UNKNOWN)
399 {
400 WARN("Couldn't find a suitable pixel format\n");
401 return D3DERR_NOTAVAILABLE;
402 }
403
404 TRACE("Format chosen: %x\n", usedformat);
405 if (format)
406 *format = usedformat;
407
408 return D3D_OK;
409}
unsigned int channels
Definition: audiorecord.c:89
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#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_A8R8G8B8
Definition: d3d8types.h:604
@ D3DFMT_UNKNOWN
Definition: d3d8types.h:601
#define D3DUSAGE_WRITEONLY
Definition: d3d8types.h:93
@ D3DPOOL_SCRATCH
Definition: d3d8types.h:712
@ D3DPOOL_DEFAULT
Definition: d3d8types.h:709
@ D3DPOOL_SYSTEMMEM
Definition: d3d8types.h:711
@ D3DPOOL_MANAGED
Definition: d3d8types.h:710
enum _D3DFORMAT D3DFORMAT
#define D3DUSAGE_RTPATCHES
Definition: d3d8types.h:97
#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 D3D_OK
Definition: d3d.h:106
const struct pixel_format_desc * get_format_info(D3DFORMAT format)
Definition: util.c:312
static BOOL format_types_match(const struct pixel_format_desc *src, const struct pixel_format_desc *dst)
const struct pixel_format_desc * get_format_info_idx(int idx)
Definition: util.c:321
static uint32_t make_pow2(uint32_t num)
D3DFORMAT d3dformat_from_d3dx_pixel_format_id(enum d3dx_pixel_format_id format)
Definition: util.c:83
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
static D3DFORMAT get_replacement_format(D3DFORMAT format)
Definition: texture.c:171
static BOOL is_pow2(UINT num)
Definition: texture.c:28
static void cleanup(void)
Definition: main.c:1335
#define assert(_expr)
Definition: assert.h:32
#define INT_MIN
Definition: limits.h:25
#define D3DPTEXTURECAPS_SQUAREONLY
Definition: d3d8caps.h:116
#define D3DPTEXTURECAPS_POW2
Definition: d3d8caps.h:114
#define D3DX_DEFAULT
Definition: d3dx9.h:24
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum mode
Definition: glext.h:6217
GLenum const GLfloat * params
Definition: glext.h:5645
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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
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 GLint GLint j
Definition: glfuncs.h:250
unsigned int UINT
Definition: sysinfo.c:13
#define FAILED(hr)
Definition: intsafe.h:51
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:80
#define TRACE(s)
Definition: solgame.cpp:4
DWORD MaxTextureWidth
Definition: d3d9caps.h:286
DWORD MaxTextureHeight
Definition: d3d9caps.h:287
DWORD TextureCaps
Definition: d3d9caps.h:279
Definition: devices.h:37
Definition: dsound.c:943
int bits
Definition: dsound.c:944
enum d3dx_pixel_format_id format
#define max(a, b)
Definition: svc.c:63

Referenced by D3DXCheckCubeTextureRequirements(), D3DXCheckTextureRequirements(), and D3DXCheckVolumeTextureRequirements().

◆ d3dx9_get_mip_filter_value()

static uint32_t d3dx9_get_mip_filter_value ( uint32_t  mip_filter,
uint32_t *  skip_levels 
)
static

Definition at line 568 of file texture.c.

569{
570 uint32_t filter = (mip_filter == D3DX_DEFAULT) ? D3DX_FILTER_BOX : mip_filter & ~D3DX9_FILTER_INVALID_BITS;
571
572 *skip_levels = mip_filter != D3DX_DEFAULT ? mip_filter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0;
573 *skip_levels &= D3DX_SKIP_DDS_MIP_LEVELS_MASK;
574 if (!(filter & 0x7) || (filter & 0x7) > D3DX_FILTER_BOX)
575 filter = (filter & 0x007f0000) | D3DX_FILTER_BOX;
576 return filter;
577}
#define D3DX9_FILTER_INVALID_BITS
Definition: d3dx9_private.h:36
UINT32 uint32_t
Definition: types.h:75
#define D3DX_FILTER_BOX
Definition: d3dx9tex.h:31
#define D3DX_SKIP_DDS_MIP_LEVELS_MASK
Definition: d3dx9tex.h:42
#define D3DX_SKIP_DDS_MIP_LEVELS_SHIFT
Definition: d3dx9tex.h:43
Definition: filter.c:165

Referenced by D3DXCreateCubeTextureFromFileInMemoryEx(), D3DXCreateTextureFromFileInMemoryEx(), and D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ D3DXCheckCubeTextureRequirements()

HRESULT WINAPI D3DXCheckCubeTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT *  size,
UINT *  miplevels,
DWORD  usage,
D3DFORMAT *  format,
D3DPOOL  pool 
)

Definition at line 420 of file texture.c.

422{
423 D3DCAPS9 caps;
424 UINT s = (size && *size) ? *size : 256;
425 HRESULT hr;
426
427 TRACE("device %p, size %p, miplevels %p, usage %#lx, format %p, pool %#x.\n",
428 device, size, miplevels, usage, format, pool);
429
430 if (s == D3DX_DEFAULT)
431 s = 256;
432
434 return D3DERR_INVALIDCALL;
435
437 return D3DERR_NOTAVAILABLE;
438
440 s = make_pow2(s);
441
443
445 {
446 if(miplevels)
447 *miplevels = 1;
448 }
449
450 if (size)
451 *size = s;
452
453 return hr;
454}
@ D3DRTYPE_CUBETEXTURE
Definition: d3d8types.h:814
static HRESULT check_texture_requirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool, D3DRESOURCETYPE resource_type)
Definition: texture.c:198
#define D3DPTEXTURECAPS_CUBEMAP_POW2
Definition: d3d8caps.h:126
#define D3DPTEXTURECAPS_CUBEMAP
Definition: d3d8caps.h:121
#define D3DPTEXTURECAPS_MIPCUBEMAP
Definition: d3d8caps.h:125
GLdouble s
Definition: gl.h:2039
GLsizeiptr size
Definition: glext.h:5919

Referenced by D3DXCreateCubeTexture(), D3DXCreateCubeTextureFromFileInMemoryEx(), and test_D3DXCheckCubeTextureRequirements().

◆ D3DXCheckTextureRequirements()

HRESULT WINAPI D3DXCheckTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT *  width,
UINT *  height,
UINT *  miplevels,
DWORD  usage,
D3DFORMAT *  format,
D3DPOOL  pool 
)

Definition at line 411 of file texture.c.

413{
414 TRACE("device %p, width %p, height %p, miplevels %p, usage %#lx, format %p, pool %#x.\n",
415 device, width, height, miplevels, usage, format, pool);
416
418}
@ D3DRTYPE_TEXTURE
Definition: d3d8types.h:812

Referenced by D3DXCreateRenderToEnvMap(), D3DXCreateTexture(), D3DXCreateTextureFromFileInMemoryEx(), and test_D3DXCheckTextureRequirements().

◆ D3DXCheckVolumeTextureRequirements()

HRESULT WINAPI D3DXCheckVolumeTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT *  width,
UINT *  height,
UINT *  depth,
UINT *  miplevels,
DWORD  usage,
D3DFORMAT *  format,
D3DPOOL  pool 
)

Definition at line 456 of file texture.c.

458{
459 D3DCAPS9 caps;
462 UINT d = (depth && *depth) ? *depth : 1;
463 HRESULT hr;
464
465 TRACE("device %p, width %p, height %p, depth %p, miplevels %p, usage %#lx, format %p, pool %#x.\n",
466 device, width, height, depth, miplevels, usage, format, pool);
467
469 return D3DERR_INVALIDCALL;
470
472 return D3DERR_NOTAVAILABLE;
473
475 if (d == D3DX_DEFAULT)
476 d = 1;
477
479 (!is_pow2(w) || !is_pow2(h) || !is_pow2(d)))
480 {
481 w = make_pow2(w);
482 h = make_pow2(h);
483 d = make_pow2(d);
484 }
485
486 if (w > caps.MaxVolumeExtent)
487 w = caps.MaxVolumeExtent;
488 if (h > caps.MaxVolumeExtent)
489 h = caps.MaxVolumeExtent;
490 if (d > caps.MaxVolumeExtent)
491 d = caps.MaxVolumeExtent;
492
493 if (miplevels)
494 {
496 *miplevels = 1;
497 else if ((usage & D3DUSAGE_AUTOGENMIPMAP))
498 {
499 if (*miplevels > 1)
500 *miplevels = 0;
501 }
502 else
503 {
504 UINT max_mipmaps = 1;
505 UINT max_dimen = max(max(w, h), d);
506
507 while (max_dimen > 1)
508 {
509 max_dimen >>= 1;
510 max_mipmaps++;
511 }
512
513 if (*miplevels == 0 || *miplevels > max_mipmaps)
514 *miplevels = max_mipmaps;
515 }
516 }
517
518 if (width)
519 *width = w;
520 if (height)
521 *height = h;
522 if (depth)
523 *depth = d;
524
525 return hr;
526}
@ D3DRTYPE_VOLUMETEXTURE
Definition: d3d8types.h:813
#define D3DPTEXTURECAPS_VOLUMEMAP
Definition: d3d8caps.h:122
#define D3DPTEXTURECAPS_VOLUMEMAP_POW2
Definition: d3d8caps.h:127
#define D3DPTEXTURECAPS_MIPVOLUMEMAP
Definition: d3d8caps.h:124
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define d
Definition: ke_i.h:81
DWORD MaxVolumeExtent
Definition: d3d9caps.h:288

Referenced by D3DXCreateVolumeTexture(), D3DXCreateVolumeTextureFromFileInMemoryEx(), and test_D3DXCheckVolumeTextureRequirements().

◆ D3DXComputeNormalMap()

HRESULT WINAPI D3DXComputeNormalMap ( IDirect3DTexture9 *  texture,
IDirect3DTexture9 *  src_texture,
const PALETTEENTRY *  src_palette,
DWORD  flags,
DWORD  channel,
float  amplitude 
)

Definition at line 1897 of file texture.c.

1899{
1900 FIXME("texture %p, src_texture %p, src_palette %p, flags %#lx, channel %lu, amplitude %.8e stub.\n",
1901 texture, src_texture, src_palette, flags, channel, amplitude);
1902
1903 return D3D_OK;
1904}
GLenum GLuint texture
Definition: glext.h:6295
GLbitfield flags
Definition: glext.h:7161

◆ D3DXCreateCubeTexture()

HRESULT WINAPI D3DXCreateCubeTexture ( struct IDirect3DDevice9 *  device,
UINT  size,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DCubeTexture9 **  texture 
)

Definition at line 905 of file texture.c.

907{
908 HRESULT hr;
909
910 TRACE("device %p, size %u, miplevels %u, usage %#lx, format %#x, pool %#x, texture %p.\n",
911 device, size, miplevels, usage, format, pool, texture);
912
913 if (!device || !texture)
914 return D3DERR_INVALIDCALL;
915
917
918 if (FAILED(hr))
919 {
920 TRACE("D3DXCheckCubeTextureRequirements failed\n");
921 return hr;
922 }
923
925}
#define IDirect3DDevice9_CreateCubeTexture(p, a, b, c, d, e, f, g)
Definition: d3d9.h:1360
HRESULT WINAPI D3DXCheckCubeTextureRequirements(struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:420

Referenced by D3DXCreateCubeTextureFromFileInMemoryEx().

◆ D3DXCreateCubeTextureFromFileA()

HRESULT WINAPI D3DXCreateCubeTextureFromFileA ( IDirect3DDevice9 *  device,
const char *  src_filename,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1509 of file texture.c.

1512{
1513 int len;
1514 HRESULT hr;
1515 WCHAR *filename;
1516 void *data;
1517 DWORD data_size;
1518
1519 TRACE("device %p, src_filename %s, cube_texture %p.\n", device, wine_dbgstr_a(src_filename), cube_texture);
1520
1521 if (!src_filename) return D3DERR_INVALIDCALL;
1522
1523 len = MultiByteToWideChar(CP_ACP, 0, src_filename, -1, NULL, 0);
1524 filename = malloc(len * sizeof(WCHAR));
1525 if (!filename) return E_OUTOFMEMORY;
1526 MultiByteToWideChar(CP_ACP, 0, src_filename, -1, filename, len);
1527
1528 hr = map_view_of_file(filename, &data, &data_size);
1529 if (FAILED(hr))
1530 {
1531 free(filename);
1532 return D3DXERR_INVALIDDATA;
1533 }
1534
1537
1539 free(filename);
1540 return hr;
1541}
#define D3DXERR_INVALIDDATA
Definition: compiler.c:53
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length)
Definition: util.c:211
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
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
#define UnmapViewOfFile
Definition: compat.h:746
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
const char * filename
Definition: ioapi.h:137
short WCHAR
Definition: pedump.c:58
int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:160

◆ D3DXCreateCubeTextureFromFileExA()

HRESULT WINAPI D3DXCreateCubeTextureFromFileExA ( IDirect3DDevice9 *  device,
const char *  src_filename,
UINT  size,
UINT  mip_levels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mip_filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO *  image_info,
PALETTEENTRY *  palette,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1563 of file texture.c.

1567{
1568 int len;
1569 HRESULT hr;
1570 WCHAR *filename;
1571 void *data;
1572 DWORD data_size;
1573
1574 TRACE("device %p, src_filename %s, size %u, mip_levels %u, usage %#lx, format %#x, pool %#x, "
1575 "filter %#lx, mip_filter %#lx, color_key 0x%08lx, image_info %p, palette %p, cube_texture %p.\n",
1576 device, wine_dbgstr_a(src_filename), size, mip_levels, usage, format, pool,
1577 filter, mip_filter, color_key, image_info, palette, cube_texture);
1578
1579 if (!src_filename) return D3DERR_INVALIDCALL;
1580
1581 len = MultiByteToWideChar(CP_ACP, 0, src_filename, -1, NULL, 0);
1582 filename = malloc(len * sizeof(WCHAR));
1583 if (!filename) return E_OUTOFMEMORY;
1584 MultiByteToWideChar(CP_ACP, 0, src_filename, -1, filename, len);
1585
1586 hr = map_view_of_file(filename, &data, &data_size);
1587 if (FAILED(hr))
1588 {
1589 free(filename);
1590 return D3DXERR_INVALIDDATA;
1591 }
1592
1593 hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, data, data_size, size, mip_levels,
1594 usage, format, pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1595
1597 free(filename);
1598 return hr;
1599}
static HPALETTE palette
Definition: clipboard.c:1457

◆ D3DXCreateCubeTextureFromFileExW()

HRESULT WINAPI D3DXCreateCubeTextureFromFileExW ( IDirect3DDevice9 *  device,
const WCHAR *  src_filename,
UINT  size,
UINT  mip_levels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mip_filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO *  image_info,
PALETTEENTRY *  palette,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1601 of file texture.c.

1605{
1606 HRESULT hr;
1607 void *data;
1608 DWORD data_size;
1609
1610 TRACE("device %p, src_filename %s, size %u, mip_levels %u, usage %#lx, format %#x, pool %#x, "
1611 "filter %#lx, mip_filter %#lx, color_key 0x%08lx, image_info %p, palette %p, cube_texture %p.\n",
1612 device, wine_dbgstr_w(src_filename), size, mip_levels, usage, format,
1613 pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1614
1615 hr = map_view_of_file(src_filename, &data, &data_size);
1616 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1617
1618 hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, data, data_size, size, mip_levels,
1619 usage, format, pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1620
1622 return hr;
1623}
#define wine_dbgstr_w
Definition: kernel32.h:34

◆ D3DXCreateCubeTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory ( struct IDirect3DDevice9 *  device,
const void *  data,
UINT  datasize,
struct IDirect3DCubeTexture9 **  texture 
)

Definition at line 927 of file texture.c.

929{
930 TRACE("device %p, data %p, datasize %u, texture %p.\n", device, data, datasize, texture);
931
934}
static SIZE_T datasize
Definition: asm.c:30

Referenced by test_D3DXCreateCubeTextureFromFileInMemory().

◆ D3DXCreateCubeTextureFromFileInMemoryEx()

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 at line 1342 of file texture.c.

1346{
1347 const struct pixel_format_desc *src_fmt_desc, *dst_fmt_desc;
1348 BOOL dynamic_texture, format_specified = FALSE;
1349 uint32_t loaded_miplevels, skip_levels, i;
1350 IDirect3DCubeTexture9 *tex, *staging_tex;
1351 struct d3dx_image image;
1352 D3DXIMAGE_INFO img_info;
1353 D3DCAPS9 caps;
1354 HRESULT hr;
1355
1356 TRACE("device %p, src_data %p, src_data_size %u, size %u, mip_levels %u, usage %#lx, "
1357 "format %#x, pool %#x, filter %#lx, mip_filter %#lx, color_key 0x%08lx, src_info %p, "
1358 "palette %p, cube_texture %p.\n",
1359 device, src_data, src_data_size, size, mip_levels, usage, format, pool, filter,
1360 mip_filter, color_key, src_info, palette, cube_texture);
1361
1362 if (!device || !cube_texture || !src_data || !src_data_size)
1363 return D3DERR_INVALIDCALL;
1364
1366 return hr;
1367
1368 staging_tex = tex = *cube_texture = NULL;
1369 mip_filter = d3dx9_get_mip_filter_value(mip_filter, &skip_levels);
1370 hr = d3dx_image_init(src_data, src_data_size, &image, skip_levels, 0);
1371 if (FAILED(hr))
1372 {
1373 FIXME("Unrecognized file format, returning failure.\n");
1374 return hr;
1375 }
1376
1378 if (img_info.ResourceType != D3DRTYPE_CUBETEXTURE)
1379 {
1380 hr = E_FAIL;
1381 goto err;
1382 }
1383
1384 /* Handle default values. */
1386 size = max(img_info.Width, img_info.Height);
1387 else if (size == D3DX_DEFAULT)
1388 size = make_pow2(max(img_info.Width, img_info.Height));
1389
1390 format_specified = (format != D3DFMT_UNKNOWN && format != D3DX_DEFAULT);
1392 format = img_info.Format;
1393 mip_levels = (mip_levels == D3DX_FROM_FILE) ? img_info.MipLevels : mip_levels;
1394
1396 if (FAILED(hr))
1397 {
1398 FIXME("Couldn't find suitable texture parameters.\n");
1399 goto err;
1400 }
1401
1402 if (color_key && !format_specified)
1404
1406 if (FAILED(hr))
1407 {
1409 goto err;
1410 }
1411
1412 dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
1413 if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
1414 {
1415 TRACE("Creating staging texture.\n");
1417 tex = staging_tex;
1418 }
1419 else
1420 {
1422 }
1423
1424 if (FAILED(hr))
1425 {
1426 FIXME("Texture creation failed.\n");
1427 goto err;
1428 }
1429
1430 TRACE("Texture created correctly. Now loading the texture data into it.\n");
1431 dst_fmt_desc = get_format_info(format);
1432 src_fmt_desc = get_d3dx_pixel_format_info(image.format);
1433 loaded_miplevels = min(img_info.MipLevels, IDirect3DCubeTexture9_GetLevelCount(tex));
1434 for (i = 0; i < loaded_miplevels; ++i)
1435 {
1436 struct d3dx_pixels src_pixels, dst_pixels;
1437 D3DSURFACE_DESC dst_surface_desc;
1438 D3DLOCKED_RECT dst_locked_rect;
1439 RECT dst_rect;
1440 uint32_t face;
1441
1442 IDirect3DCubeTexture9_GetLevelDesc(tex, i, &dst_surface_desc);
1443 SetRect(&dst_rect, 0, 0, dst_surface_desc.Width, dst_surface_desc.Height);
1445 {
1446 hr = d3dx_image_get_pixels(&image, face, i, &src_pixels);
1447 if (FAILED(hr))
1448 break;
1449
1450 hr = IDirect3DCubeTexture9_LockRect(tex, face, i, &dst_locked_rect, NULL, 0);
1451 if (FAILED(hr))
1452 break;
1453
1454 set_d3dx_pixels(&dst_pixels, dst_locked_rect.pBits, dst_locked_rect.Pitch, 0, palette,
1455 dst_surface_desc.Width, dst_surface_desc.Height, 1, &dst_rect);
1456
1457 hr = d3dx_load_pixels_from_pixels(&dst_pixels, dst_fmt_desc, &src_pixels, src_fmt_desc, filter, color_key);
1459 if (FAILED(hr))
1460 break;
1461 }
1462
1463 if (FAILED(hr))
1464 break;
1465 }
1466
1467 if (FAILED(hr))
1468 {
1469 FIXME("Texture loading failed.\n");
1470 goto err;
1471 }
1472
1473 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, palette, loaded_miplevels - 1, mip_filter);
1474 if (FAILED(hr))
1475 {
1476 FIXME("Texture filtering failed.\n");
1477 goto err;
1478 }
1479
1480 if (staging_tex)
1481 {
1482 hr = D3DXCreateCubeTexture(device, size, mip_levels, usage, format, pool, cube_texture);
1483 if (FAILED(hr))
1484 goto err;
1485
1486 IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)staging_tex, (IDirect3DBaseTexture9 *)(*cube_texture));
1487 IDirect3DCubeTexture9_Release(staging_tex);
1488 }
1489 else
1490 {
1491 *cube_texture = tex;
1492 }
1493
1495 if (src_info)
1496 *src_info = img_info;
1497
1498 return hr;
1499
1500err:
1502 if (tex)
1504
1505 return hr;
1506}
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
@ D3DCUBEMAP_FACE_POSITIVE_X
Definition: d3d8types.h:550
@ D3DCUBEMAP_FACE_NEGATIVE_Z
Definition: d3d8types.h:555
#define IDirect3DCubeTexture9_UnlockRect(p, a, b)
Definition: d3d9.h:768
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:747
#define IDirect3DCubeTexture9_LockRect(p, a, b, c, d, e)
Definition: d3d9.h:767
#define IDirect3DCubeTexture9_GetLevelCount(p)
Definition: d3d9.h:760
#define IDirect3DCubeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:765
#define IDirect3DDevice9_UpdateTexture(p, a, b)
Definition: d3d9.h:1366
HRESULT d3dx_load_pixels_from_pixels(struct d3dx_pixels *dst_pixels, const struct pixel_format_desc *dst_desc, struct d3dx_pixels *src_pixels, const struct pixel_format_desc *src_desc, uint32_t filter_flags, uint32_t color_key)
Definition: surface.c:2498
void d3dx_image_cleanup(struct d3dx_image *image)
Definition: surface.c:1392
const struct pixel_format_desc * get_d3dx_pixel_format_info(enum d3dx_pixel_format_id format)
Definition: util.c:297
static HRESULT d3dx9_handle_load_filter(DWORD *filter)
Definition: d3dx9_private.h:45
static void set_d3dx_pixels(struct d3dx_pixels *pixels, const void *data, uint32_t row_pitch, uint32_t slice_pitch, const PALETTEENTRY *palette, uint32_t width, uint32_t height, uint32_t depth, const RECT *unaligned_rect)
HRESULT d3dx_image_init(const void *src_data, uint32_t src_data_size, struct d3dx_image *image, uint32_t starting_mip_level, uint32_t flags)
Definition: surface.c:1332
HRESULT d3dx_image_get_pixels(struct d3dx_image *image, uint32_t layer, uint32_t mip_level, struct d3dx_pixels *pixels)
Definition: surface.c:1398
void d3dximage_info_from_d3dx_image(D3DXIMAGE_INFO *info, struct d3dx_image *image)
Definition: surface.c:1441
#define E_FAIL
Definition: ddrawi.h:102
#define FALSE
Definition: types.h:117
WORD face[3]
Definition: mesh.c:4854
HRESULT WINAPI D3DXCreateCubeTexture(struct IDirect3DDevice9 *device, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DCubeTexture9 **texture)
Definition: texture.c:905
static uint32_t d3dx9_get_mip_filter_value(uint32_t mip_filter, uint32_t *skip_levels)
Definition: texture.c:568
static D3DFORMAT get_alpha_replacement_format(D3DFORMAT format)
Definition: texture.c:545
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
Definition: texture.c:48
#define D3DCAPS2_DYNAMICTEXTURES
Definition: d3d8caps.h:25
#define D3DX_DEFAULT_NONPOW2
Definition: d3dx9.h:25
#define D3DX_FROM_FILE
Definition: d3dx9.h:27
#define D3DFMT_FROM_FILE
Definition: d3dx9.h:28
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define min(a, b)
Definition: monoChain.cc:55
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define err(...)
Definition: dcommon.idl:28
DWORD Caps2
Definition: d3d9caps.h:267
uint32_t mip_levels
Definition: image.c:84

Referenced by D3DXCreateCubeTextureFromFileA(), D3DXCreateCubeTextureFromFileExA(), D3DXCreateCubeTextureFromFileExW(), D3DXCreateCubeTextureFromFileInMemory(), D3DXCreateCubeTextureFromFileW(), and test_D3DXCreateCubeTextureFromFileInMemoryEx().

◆ D3DXCreateCubeTextureFromFileW()

HRESULT WINAPI D3DXCreateCubeTextureFromFileW ( IDirect3DDevice9 *  device,
const WCHAR *  src_filename,
IDirect3DCubeTexture9 **  cube_texture 
)

Definition at line 1543 of file texture.c.

1546{
1547 HRESULT hr;
1548 void *data;
1549 DWORD data_size;
1550
1551 TRACE("device %p, src_filename %s, cube_texture %p.\n", device, wine_dbgstr_w(src_filename), cube_texture);
1552
1553 hr = map_view_of_file(src_filename, &data, &data_size);
1554 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1555
1558
1560 return hr;
1561}

◆ D3DXCreateTexture()

HRESULT WINAPI D3DXCreateTexture ( struct IDirect3DDevice9 *  device,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DTexture9 **  texture 
)

Definition at line 528 of file texture.c.

530{
531 HRESULT hr;
532
533 TRACE("device %p, width %u, height %u, miplevels %u, usage %#lx, format %#x, pool %#x, texture %p.\n",
534 device, width, height, miplevels, usage, format, pool, texture);
535
536 if (!device || !texture)
537 return D3DERR_INVALIDCALL;
538
540 return hr;
541
543}
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1358
HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:411

Referenced by D3DXCreateTextureFromFileInMemoryEx(), test_D3DXCreateTexture(), test_effect_parameter_block(), and test_effect_setvalue_object().

◆ D3DXCreateTextureFromFileA()

HRESULT WINAPI D3DXCreateTextureFromFileA ( struct IDirect3DDevice9 *  device,
const char *  srcfile,
struct IDirect3DTexture9 **  texture 
)

Definition at line 806 of file texture.c.

808{
809 TRACE("device %p, srcfile %s, texture %p.\n", device, debugstr_a(srcfile), texture);
810
813}
HRESULT WINAPI D3DXCreateTextureFromFileExA(struct IDirect3DDevice9 *device, const char *srcfile, 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:777
#define debugstr_a
Definition: kernel32.h:31

◆ D3DXCreateTextureFromFileExA()

HRESULT WINAPI D3DXCreateTextureFromFileExA ( struct IDirect3DDevice9 *  device,
const char *  srcfile,
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 at line 777 of file texture.c.

781{
782 WCHAR *widename;
783 HRESULT hr;
784 DWORD len;
785
786 TRACE("device %p, srcfile %s, width %u, height %u, miplevels %u, usage %#lx, format %#x, "
787 "pool %#x, filter %#lx, mipfilter %#lx, colorkey 0x%08lx, srcinfo %p, palette %p, texture %p.\n",
788 device, debugstr_a(srcfile), width, height, miplevels, usage, format,
789 pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
790
791 if (!device || !srcfile || !texture)
792 return D3DERR_INVALIDCALL;
793
794 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
795 widename = malloc(len * sizeof(*widename));
796 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, widename, len);
797
798 hr = D3DXCreateTextureFromFileExW(device, widename, width, height, miplevels,
799 usage, format, pool, filter, mipfilter,
800 colorkey, srcinfo, palette, texture);
801
802 free(widename);
803 return hr;
804}
HRESULT WINAPI D3DXCreateTextureFromFileExW(struct IDirect3DDevice9 *device, const WCHAR *srcfile, 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:745

Referenced by D3DXCreateTextureFromFileA().

◆ D3DXCreateTextureFromFileExW()

HRESULT WINAPI D3DXCreateTextureFromFileExW ( struct IDirect3DDevice9 *  device,
const WCHAR *  srcfile,
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 at line 745 of file texture.c.

749{
750 void *buffer;
751 HRESULT hr;
752 DWORD size;
753
754 TRACE("device %p, srcfile %s, width %u, height %u, miplevels %u, usage %#lx, format %#x, "
755 "pool %#x, filter %#lx, mipfilter %#lx, colorkey 0x%08lx, srcinfo %p, palette %p, texture %p.\n",
756 device, debugstr_w(srcfile), width, height, miplevels, usage, format,
757 pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
758
759 if (!srcfile)
760 return D3DERR_INVALIDCALL;
761
762 hr = map_view_of_file(srcfile, &buffer, &size);
763 if (FAILED(hr))
764 {
765 WARN("Failed to open file.\n");
766 return D3DXERR_INVALIDDATA;
767 }
768
770 filter, mipfilter, colorkey, srcinfo, palette, texture);
771
773
774 return hr;
775}
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
GLuint buffer
Definition: glext.h:5915
#define debugstr_w
Definition: kernel32.h:32

Referenced by D3DXCreateTextureFromFileExA(), and D3DXCreateTextureFromFileW().

◆ D3DXCreateTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateTextureFromFileInMemory ( struct IDirect3DDevice9 *  device,
const void *  srcdata,
UINT  srcdatasize,
struct IDirect3DTexture9 **  texture 
)

Definition at line 736 of file texture.c.

738{
739 TRACE("device %p, srcdata %p, srcdatasize %u, texture %p.\n", device, srcdata, srcdatasize, texture);
740
743}

Referenced by test_D3DXCreateTextureFromFileInMemory().

◆ D3DXCreateTextureFromFileInMemoryEx()

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 at line 579 of file texture.c.

583{
584 const struct pixel_format_desc *src_fmt_desc, *dst_fmt_desc;
585 BOOL dynamic_texture, format_specified = FALSE;
586 uint32_t loaded_miplevels, skip_levels, i;
587 IDirect3DTexture9 *staging_tex, *tex;
588 struct d3dx_image image;
589 D3DXIMAGE_INFO imginfo;
590 D3DCAPS9 caps;
591 HRESULT hr;
592
593 TRACE("device %p, srcdata %p, srcdatasize %u, width %u, height %u, miplevels %u, "
594 "usage %#lx, format %#x, pool %#x, filter %#lx, mipfilter %#lx, colorkey %#lx, "
595 "srcinfo %p, palette %p, texture %p.\n",
596 device, srcdata, srcdatasize, width, height, miplevels, usage, format, pool,
597 filter, mipfilter, colorkey, srcinfo, palette, texture);
598
599 /* check for invalid parameters */
600 if (!device || !texture || !srcdata || !srcdatasize)
601 return D3DERR_INVALIDCALL;
602
604 return hr;
605
606 staging_tex = tex = *texture = NULL;
607 mipfilter = d3dx9_get_mip_filter_value(mipfilter, &skip_levels);
608 hr = d3dx_image_init(srcdata, srcdatasize, &image, skip_levels, 0);
609 if (FAILED(hr))
610 {
611 FIXME("Unrecognized file format, returning failure.\n");
612 return hr;
613 }
614
616
617 /* handle default values */
619 width = (width == D3DX_DEFAULT) ? make_pow2(imginfo.Width) : imginfo.Width;
621 height = (height == D3DX_DEFAULT) ? make_pow2(imginfo.Height) : imginfo.Height;
622
623 format_specified = (format != D3DFMT_UNKNOWN && format != D3DX_DEFAULT);
625 format = imginfo.Format;
626 miplevels = (miplevels == D3DX_FROM_FILE) ? imginfo.MipLevels : miplevels;
627
628 /* Fix up texture creation parameters. */
630 if (FAILED(hr))
631 {
632 FIXME("Couldn't find suitable texture parameters.\n");
633 goto err;
634 }
635
636 if (colorkey && !format_specified)
638
640 {
642 goto err;
643 }
644
645 /* Create the to-be-filled texture */
646 dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
647 if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
648 {
649 TRACE("Creating staging texture.\n");
650 hr = D3DXCreateTexture(device, width, height, miplevels, 0, format, D3DPOOL_SYSTEMMEM, &staging_tex);
651 tex = staging_tex;
652 }
653 else
654 {
655 hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, pool, &tex);
656 }
657
658 if (FAILED(hr))
659 {
660 FIXME("Texture creation failed.\n");
661 goto err;
662 }
663
664 TRACE("Texture created correctly. Now loading the texture data into it.\n");
665 dst_fmt_desc = get_format_info(format);
666 src_fmt_desc = get_d3dx_pixel_format_info(image.format);
667 loaded_miplevels = min(imginfo.MipLevels, IDirect3DTexture9_GetLevelCount(tex));
668 for (i = 0; i < loaded_miplevels; i++)
669 {
670 struct d3dx_pixels src_pixels, dst_pixels;
671 D3DSURFACE_DESC dst_surface_desc;
672 D3DLOCKED_RECT dst_locked_rect;
673 RECT dst_rect;
674
675 hr = d3dx_image_get_pixels(&image, 0, i, &src_pixels);
676 if (FAILED(hr))
677 break;
678
679 hr = IDirect3DTexture9_LockRect(tex, i, &dst_locked_rect, NULL, 0);
680 if (FAILED(hr))
681 break;
682
683 IDirect3DTexture9_GetLevelDesc(tex, i, &dst_surface_desc);
684 SetRect(&dst_rect, 0, 0, dst_surface_desc.Width, dst_surface_desc.Height);
685 set_d3dx_pixels(&dst_pixels, dst_locked_rect.pBits, dst_locked_rect.Pitch, 0, palette,
686 dst_surface_desc.Width, dst_surface_desc.Height, 1, &dst_rect);
687
688 hr = d3dx_load_pixels_from_pixels(&dst_pixels, dst_fmt_desc, &src_pixels, src_fmt_desc, filter, colorkey);
690 if (FAILED(hr))
691 break;
692 }
693
694 if (FAILED(hr))
695 {
696 FIXME("Texture loading failed.\n");
697 goto err;
698 }
699
700 hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)tex, palette, loaded_miplevels - 1, mipfilter);
701 if (FAILED(hr))
702 {
703 FIXME("Texture filtering failed.\n");
704 goto err;
705 }
706
707 /* Move the data to the actual texture if necessary */
708 if (staging_tex)
709 {
711 if (FAILED(hr))
712 goto err;
713
714 IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)staging_tex, (IDirect3DBaseTexture9 *)(*texture));
715 IDirect3DTexture9_Release(staging_tex);
716 }
717 else
718 {
719 *texture = tex;
720 }
721
723 if (srcinfo)
724 *srcinfo = imginfo;
725
726 return hr;
727
728err:
730 if (tex)
732
733 return hr;
734}
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:860
#define IDirect3DTexture9_UnlockRect(p, a)
Definition: d3d9.h:863
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:855
#define IDirect3DTexture9_LockRect(p, a, b, c, d)
Definition: d3d9.h:862
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:842
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

Referenced by D3DXCreateTextureFromFileExW(), D3DXCreateTextureFromFileInMemory(), D3DXCreateTextureFromResourceExA(), D3DXCreateTextureFromResourceExW(), and test_D3DXCreateTextureFromFileInMemoryEx().

◆ D3DXCreateTextureFromFileW()

HRESULT WINAPI D3DXCreateTextureFromFileW ( struct IDirect3DDevice9 *  device,
const WCHAR *  srcfile,
struct IDirect3DTexture9 **  texture 
)

Definition at line 815 of file texture.c.

817{
818 TRACE("device %p, srcfile %s, texture %p.\n", device, debugstr_w(srcfile), texture);
819
822}

◆ D3DXCreateTextureFromResourceA()

HRESULT WINAPI D3DXCreateTextureFromResourceA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char *  resource,
struct IDirect3DTexture9 **  texture 
)

Definition at line 825 of file texture.c.

827{
828 TRACE("device %p, srcmodule %p, resource %s, texture %p.\n",
829 device, srcmodule, debugstr_a(resource), texture);
830
833 NULL, texture);
834}
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

Referenced by test_D3DXCreateTexture().

◆ D3DXCreateTextureFromResourceExA()

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 at line 847 of file texture.c.

851{
852 HRSRC resinfo;
853 void *buffer;
854 DWORD size;
855
856 TRACE("device %p, srcmodule %p, resource %s, width %u, height %u, miplevels %u, usage %#lx, format %#x, "
857 "pool %#x, filter %#lx, mipfilter %#lx, colorkey 0x%08lx, srcinfo %p, palette %p, texture %p.\n",
858 device, srcmodule, debugstr_a(resource), width, height, miplevels, usage, format,
859 pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
860
861 if (!device || !texture)
862 return D3DERR_INVALIDCALL;
863
864 if (!(resinfo = FindResourceA(srcmodule, resource, (const char *)RT_RCDATA))
865 /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
866 && !(resinfo = FindResourceA(srcmodule, resource, (const char *)RT_BITMAP)))
867 return D3DXERR_INVALIDDATA;
868
869 if (FAILED(load_resource_into_memory(srcmodule, resinfo, &buffer, &size)))
870 return D3DXERR_INVALIDDATA;
871
873 usage, format, pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
874}
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length)
Definition: util.c:261
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
#define RT_BITMAP
Definition: pedump.c:364
#define RT_RCDATA
Definition: pedump.c:372

Referenced by D3DXCreateTextureFromResourceA(), and test_D3DXCreateTexture().

◆ D3DXCreateTextureFromResourceExW()

HRESULT WINAPI D3DXCreateTextureFromResourceExW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR *  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 at line 876 of file texture.c.

880{
881 HRSRC resinfo;
882 void *buffer;
883 DWORD size;
884
885 TRACE("device %p, srcmodule %p, resource %s, width %u, height %u, miplevels %u, usage %#lx, format %#x, "
886 "pool %#x, filter %#lx, mipfilter %#lx, colorkey 0x%08lx, srcinfo %p, palette %p, texture %p.\n",
887 device, srcmodule, debugstr_w(resource), width, height, miplevels, usage, format,
888 pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
889
890 if (!device || !texture)
891 return D3DERR_INVALIDCALL;
892
893 if (!(resinfo = FindResourceW(srcmodule, resource, (const WCHAR *)RT_RCDATA))
894 /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
895 && !(resinfo = FindResourceW(srcmodule, resource, (const WCHAR *)RT_BITMAP)))
896 return D3DXERR_INVALIDDATA;
897
898 if (FAILED(load_resource_into_memory(srcmodule, resinfo, &buffer, &size)))
899 return D3DXERR_INVALIDDATA;
900
902 usage, format, pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
903}
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176

Referenced by D3DXCreateTextureFromResourceW().

◆ D3DXCreateTextureFromResourceW()

HRESULT WINAPI D3DXCreateTextureFromResourceW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR *  resource,
struct IDirect3DTexture9 **  texture 
)

Definition at line 836 of file texture.c.

838{
839 TRACE("device %p, srcmodule %p, resource %s, texture %p.\n",
840 device, srcmodule, debugstr_w(resource), texture);
841
844 NULL, texture);
845}
HRESULT WINAPI D3DXCreateTextureFromResourceExW(struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *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:876

◆ D3DXCreateVolumeTexture()

HRESULT WINAPI D3DXCreateVolumeTexture ( struct IDirect3DDevice9 *  device,
UINT  width,
UINT  height,
UINT  depth,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DVolumeTexture9 **  texture 
)

Definition at line 936 of file texture.c.

938{
939 HRESULT hr;
940
941 TRACE("device %p, width %u, height %u, depth %u, miplevels %u, usage %#lx, format %#x, pool %#x, texture %p.\n",
942 device, width, height, depth, miplevels, usage, format, pool, texture);
943
944 if (!device || !texture)
945 return D3DERR_INVALIDCALL;
946
948 &miplevels, usage, &format, pool);
949
950 if (FAILED(hr))
951 {
952 TRACE("D3DXCheckVolumeTextureRequirements failed\n");
953 return hr;
954 }
955
958}
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1359
HRESULT WINAPI D3DXCheckVolumeTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:456

Referenced by D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ D3DXCreateVolumeTextureFromFileA()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileA ( IDirect3DDevice9 *  device,
const char *  filename,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 960 of file texture.c.

963{
964 int len;
965 HRESULT hr;
966 void *data;
967 DWORD data_size;
969
970 TRACE("device %p, filename %s, volume_texture %p.\n", device, debugstr_a(filename), volume_texture);
971
972 if (!filename) return D3DERR_INVALIDCALL;
973
975 filenameW = malloc(len * sizeof(WCHAR));
976 if (!filenameW) return E_OUTOFMEMORY;
978
979 hr = map_view_of_file(filenameW, &data, &data_size);
981 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
982
985
987 return hr;
988}
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
static const WCHAR filenameW[]
Definition: resource.c:27

◆ D3DXCreateVolumeTextureFromFileExA()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileExA ( IDirect3DDevice9 *  device,
const char *  filename,
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 *  src_info,
PALETTEENTRY *  palette,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 1012 of file texture.c.

1027{
1028 int len;
1029 HRESULT hr;
1031 void *data;
1032 DWORD data_size;
1033
1034 TRACE("device %p, filename %s, width %u, height %u, depth %u, mip_levels %u, usage %#lx, "
1035 "format %#x, pool %#x, filter %#lx, mip_filter %#lx, color_key 0x%08lx, src_info %p, "
1036 "palette %p, volume_texture %p.\n",
1037 device, debugstr_a(filename), width, height, depth, mip_levels, usage,
1038 format, pool, filter, mip_filter, color_key, src_info, palette, volume_texture);
1039
1040 if (!filename) return D3DERR_INVALIDCALL;
1041
1043 filenameW = malloc(len * sizeof(WCHAR));
1044 if (!filenameW) return E_OUTOFMEMORY;
1046
1047 hr = map_view_of_file(filenameW, &data, &data_size);
1048 free(filenameW);
1049 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1050
1052 mip_levels, usage, format, pool, filter, mip_filter, color_key, src_info, palette,
1053 volume_texture);
1054
1056 return hr;
1057}

◆ D3DXCreateVolumeTextureFromFileExW()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileExW ( IDirect3DDevice9 *  device,
const WCHAR *  filename,
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 *  src_info,
PALETTEENTRY *  palette,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 1059 of file texture.c.

1074{
1075 HRESULT hr;
1076 void *data;
1077 DWORD data_size;
1078
1079 TRACE("device %p, filename %s, width %u, height %u, depth %u, mip_levels %u, usage %#lx, "
1080 "format %#x, pool %#x, filter %#lx, mip_filter %#lx, color_key 0x%08lx, src_info %p, "
1081 "palette %p, volume_texture %p.\n",
1082 device, debugstr_w(filename), width, height, depth, mip_levels, usage,
1083 format, pool, filter, mip_filter, color_key, src_info, palette, volume_texture);
1084
1085 if (!filename) return D3DERR_INVALIDCALL;
1086
1087 hr = map_view_of_file(filename, &data, &data_size);
1088 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1089
1091 mip_levels, usage, format, pool, filter, mip_filter, color_key, src_info, palette,
1092 volume_texture);
1093
1095 return hr;
1096}

◆ D3DXCreateVolumeTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory ( IDirect3DDevice9 *  device,
const void *  data,
UINT  data_size,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 1098 of file texture.c.

1102{
1103 TRACE("device %p, data %p, data_size %u, volume_texture %p.\n", device, data, data_size, volume_texture);
1104
1107 0, NULL, NULL, volume_texture);
1108}

Referenced by test_D3DXCreateVolumeTextureFromFileInMemory().

◆ D3DXCreateVolumeTextureFromFileInMemoryEx()

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 at line 1110 of file texture.c.

1114{
1115 HRESULT hr;
1116 D3DCAPS9 caps;
1117 struct d3dx_image image;
1118 D3DXIMAGE_INFO image_info;
1119 uint32_t loaded_miplevels, skip_levels, i;
1120 IDirect3DVolumeTexture9 *tex, *staging_tex;
1121 BOOL dynamic_texture, format_specified = FALSE;
1122 const struct pixel_format_desc *src_fmt_desc, *dst_fmt_desc;
1123
1124 TRACE("device %p, data %p, data_size %u, width %u, height %u, depth %u, mip_levels %u, "
1125 "usage %#lx, format %#x, pool %#x, filter %#lx, mip_filter %#lx, color_key 0x%08lx, "
1126 "info %p, palette %p, volume_texture %p.\n",
1127 device, data, data_size, width, height, depth, mip_levels, usage, format, pool,
1128 filter, mip_filter, color_key, info, palette, volume_texture);
1129
1130 if (!device || !data || !data_size || !volume_texture)
1131 return D3DERR_INVALIDCALL;
1132
1134 return hr;
1135
1136 staging_tex = tex = *volume_texture = NULL;
1137 mip_filter = d3dx9_get_mip_filter_value(mip_filter, &skip_levels);
1138 hr = d3dx_image_init(data, data_size, &image, skip_levels, 0);
1139 if (FAILED(hr))
1140 {
1141 FIXME("Unrecognized file format, returning failure.\n");
1142 return hr;
1143 }
1144
1146
1147 /* Handle default values. */
1149 width = (width == D3DX_DEFAULT) ? make_pow2(image_info.Width) : image_info.Width;
1151 height = (height == D3DX_DEFAULT) ? make_pow2(image_info.Height) : image_info.Height;
1153 depth = (depth == D3DX_DEFAULT) ? make_pow2(image_info.Depth) : image_info.Depth;
1154
1155 format_specified = (format != D3DFMT_UNKNOWN && format != D3DX_DEFAULT);
1157 format = image_info.Format;
1158 mip_levels = (mip_levels == D3DX_FROM_FILE) ? image_info.MipLevels : mip_levels;
1159
1161 if (FAILED(hr))
1162 {
1163 FIXME("Couldn't find suitable texture parameters.\n");
1164 goto err;
1165 }
1166
1167 if (color_key && !format_specified)
1169
1171 if (FAILED(hr))
1172 {
1174 goto err;
1175 }
1176
1177 dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
1178 if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
1179 {
1180 TRACE("Creating staging texture.\n");
1181 hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, 0, format, D3DPOOL_SYSTEMMEM, &staging_tex);
1182 tex = staging_tex;
1183 }
1184 else
1185 {
1186 hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, &tex);
1187 }
1188
1189 if (FAILED(hr))
1190 {
1191 FIXME("Texture creation failed.\n");
1192 goto err;
1193 }
1194
1195 TRACE("Texture created correctly. Now loading the texture data into it.\n");
1196 dst_fmt_desc = get_format_info(format);
1197 src_fmt_desc = get_d3dx_pixel_format_info(image.format);
1198 loaded_miplevels = min(image_info.MipLevels, IDirect3DVolumeTexture9_GetLevelCount(tex));
1199 for (i = 0; i < loaded_miplevels; i++)
1200 {
1201 struct d3dx_pixels src_pixels, dst_pixels;
1202 D3DVOLUME_DESC dst_volume_desc;
1203 D3DLOCKED_BOX dst_locked_box;
1204 RECT dst_rect;
1205
1206 hr = d3dx_image_get_pixels(&image, 0, i, &src_pixels);
1207 if (FAILED(hr))
1208 break;
1209
1210 hr = IDirect3DVolumeTexture9_LockBox(tex, i, &dst_locked_box, NULL, 0);
1211 if (FAILED(hr))
1212 break;
1213
1214 IDirect3DVolumeTexture9_GetLevelDesc(tex, i, &dst_volume_desc);
1215 SetRect(&dst_rect, 0, 0, dst_volume_desc.Width, dst_volume_desc.Height);
1216 set_d3dx_pixels(&dst_pixels, dst_locked_box.pBits, dst_locked_box.RowPitch, dst_locked_box.SlicePitch, palette,
1217 dst_volume_desc.Width, dst_volume_desc.Height, dst_volume_desc.Depth, &dst_rect);
1218
1219 hr = d3dx_load_pixels_from_pixels(&dst_pixels, dst_fmt_desc, &src_pixels, src_fmt_desc, filter, color_key);
1221 if (FAILED(hr))
1222 break;
1223 }
1224
1225 if (FAILED(hr))
1226 {
1227 FIXME("Texture loading failed.\n");
1228 goto err;
1229 }
1230
1231 hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)tex, palette, loaded_miplevels - 1, mip_filter);
1232 if (FAILED(hr))
1233 {
1234 FIXME("Texture filtering failed.\n");
1235 goto err;
1236 }
1237
1238 /* Move the data to the actual texture if necessary. */
1239 if (staging_tex)
1240 {
1241 hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, volume_texture);
1242 if (FAILED(hr))
1243 goto err;
1244
1245 IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)staging_tex, (IDirect3DBaseTexture9 *)(*volume_texture));
1247 }
1248 else
1249 {
1250 *volume_texture = tex;
1251 }
1252
1254 if (info)
1255 *info = image_info;
1256
1257 return hr;
1258
1259err:
1261 if (tex)
1263
1264 return hr;
1265}
#define IDirect3DVolumeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:955
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:937
#define IDirect3DVolumeTexture9_GetLevelCount(p)
Definition: d3d9.h:950
#define IDirect3DVolumeTexture9_LockBox(p, a, b, c, d)
Definition: d3d9.h:957
#define IDirect3DVolumeTexture9_UnlockBox(p, a)
Definition: d3d9.h:958
HRESULT WINAPI D3DXCreateVolumeTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DVolumeTexture9 **texture)
Definition: texture.c:936

Referenced by D3DXCreateVolumeTextureFromFileA(), D3DXCreateVolumeTextureFromFileExA(), D3DXCreateVolumeTextureFromFileExW(), D3DXCreateVolumeTextureFromFileInMemory(), D3DXCreateVolumeTextureFromFileW(), and test_D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ D3DXCreateVolumeTextureFromFileW()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileW ( IDirect3DDevice9 *  device,
const WCHAR *  filename,
IDirect3DVolumeTexture9 **  volume_texture 
)

Definition at line 990 of file texture.c.

993{
994 HRESULT hr;
995 void *data;
996 DWORD data_size;
997
998 TRACE("device %p, filename %s, volume_texture %p.\n", device, debugstr_w(filename), volume_texture);
999
1000 if (!filename) return D3DERR_INVALIDCALL;
1001
1002 hr = map_view_of_file(filename, &data, &data_size);
1003 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1004
1007
1009 return hr;
1010}

◆ D3DXFillCubeTexture()

HRESULT WINAPI D3DXFillCubeTexture ( struct IDirect3DCubeTexture9 *  texture,
LPD3DXFILL3D  function,
void *  funcdata 
)

Definition at line 1657 of file texture.c.

1658{
1659 DWORD miplevels;
1660 DWORD m, x, y, f;
1662 D3DLOCKED_RECT lock_rect;
1665 const struct pixel_format_desc *format;
1666 BYTE *data;
1667 static const enum cube_coord coordmap[6][3] =
1668 {
1670 {ZERO, YCOORDINV, XCOORD},
1671 {XCOORD, ONE, YCOORD},
1672 {XCOORD, ZERO, YCOORDINV},
1673 {XCOORD, YCOORDINV, ONE},
1675 };
1676
1677 TRACE("texture %p, function %p, funcdata %p.\n", texture, function, funcdata);
1678
1679 if (texture == NULL || function == NULL)
1680 return D3DERR_INVALIDCALL;
1681
1683
1684 for (m = 0; m < miplevels; m++)
1685 {
1687 return D3DERR_INVALIDCALL;
1688
1689 format = get_format_info(desc.Format);
1691 {
1692 FIXME("Unsupported texture format %#x\n", desc.Format);
1693 return D3DERR_INVALIDCALL;
1694 }
1695
1696 for (f = 0; f < 6; f++)
1697 {
1699 return D3DERR_INVALIDCALL;
1700
1701 size.x = (f == 0) || (f == 1) ? 0.0f : 2.0f / desc.Width;
1702 size.y = (f == 2) || (f == 3) ? 0.0f : 2.0f / desc.Width;
1703 size.z = (f == 4) || (f == 5) ? 0.0f : 2.0f / desc.Width;
1704
1705 data = lock_rect.pBits;
1706
1707 for (y = 0; y < desc.Height; y++)
1708 {
1709 for (x = 0; x < desc.Width; x++)
1710 {
1711 BYTE *dst = data + y * lock_rect.Pitch + x * format->bytes_per_pixel;
1712 struct d3dx_color color;
1713
1714 coord.x = get_cube_coord(coordmap[f][0], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1715 coord.y = get_cube_coord(coordmap[f][1], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1716 coord.z = get_cube_coord(coordmap[f][2], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1717
1718 function(&value, &coord, &size, funcdata);
1719
1720 set_d3dx_color(&color, (const struct vec4 *)&value, RANGE_FULL, RANGE_FULL);
1722 }
1723 }
1725 }
1726 }
1727
1728 return D3D_OK;
1729}
#define D3DLOCK_DISCARD
Definition: d3d8types.h:72
void format_from_d3dx_color(const struct pixel_format_desc *format, const struct d3dx_color *src, BYTE *dst)
Definition: surface.c:2051
static BOOL is_index_format(const struct pixel_format_desc *format)
static BOOL is_unknown_format(const struct pixel_format_desc *format)
@ RANGE_FULL
Definition: d3dx9_private.h:59
static void set_d3dx_color(struct d3dx_color *color, const struct vec4 *value, enum range rgb_range, enum range a_range)
Definition: d3dx9_private.h:71
static BOOL is_compressed_format(const struct pixel_format_desc *format)
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
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
GLuint coord
Definition: glext.h:9511
GLfloat f
Definition: glext.h:7540
GLenum GLenum dst
Definition: glext.h:6340
const GLfloat * m
Definition: glext.h:10848
#define f
Definition: ke_i.h:83
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
Definition: pdh_main.c:64
unsigned char BYTE
Definition: xxhash.c:193

Referenced by D3DXFillCubeTextureTX(), test_D3DXFillCubeTexture(), and test_D3DXSaveTextureToFileInMemory().

◆ D3DXFillTexture()

HRESULT WINAPI D3DXFillTexture ( struct IDirect3DTexture9 *  texture,
LPD3DXFILL2D  function,
void *  funcdata 
)

Definition at line 1267 of file texture.c.

1268{
1269 IDirect3DSurface9 *surface, *temp_surface;
1270 DWORD miplevels;
1271 DWORD m, x, y;
1273 D3DLOCKED_RECT lock_rect;
1276 const struct pixel_format_desc *format;
1277 BYTE *data;
1278 HRESULT hr;
1279
1280 TRACE("texture %p, function %p, funcdata %p.\n", texture, function, funcdata);
1281
1282 if (!texture || !function)
1283 return D3DERR_INVALIDCALL;
1284
1286
1287 for (m = 0; m < miplevels; m++)
1288 {
1290 return hr;
1291
1292 format = get_format_info(desc.Format);
1294 {
1295 FIXME("Unsupported texture format %#x.\n", desc.Format);
1296 return D3DERR_INVALIDCALL;
1297 }
1298
1300 return hr;
1301 if (FAILED(hr = lock_surface(surface, NULL, &lock_rect, &temp_surface, TRUE)))
1302 {
1304 return hr;
1305 }
1306
1307 size.x = 1.0f / desc.Width;
1308 size.y = 1.0f / desc.Height;
1309
1310 data = lock_rect.pBits;
1311
1312 for (y = 0; y < desc.Height; y++)
1313 {
1314 /* The callback function expects the coordinates of the center
1315 of the texel */
1316 coord.y = (y + 0.5f) / desc.Height;
1317
1318 for (x = 0; x < desc.Width; x++)
1319 {
1320 BYTE *dst = data + y * lock_rect.Pitch + x * format->bytes_per_pixel;
1321 struct d3dx_color color;
1322
1323 coord.x = (x + 0.5f) / desc.Width;
1324
1325 function(&value, &coord, &size, funcdata);
1326
1327 set_d3dx_color(&color, (const struct vec4 *)&value, RANGE_FULL, RANGE_FULL);
1329 }
1330 }
1331 if (FAILED(hr = unlock_surface(surface, NULL, temp_surface, TRUE)))
1332 {
1334 return hr;
1335 }
1337 }
1338
1339 return D3D_OK;
1340}
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:861
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:450
HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, IDirect3DSurface9 *temp_surface, BOOL update)
Definition: surface.c:214
HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, IDirect3DSurface9 **temp_surface, BOOL write)
Definition: surface.c:156
#define TRUE
Definition: types.h:120
DWORD IDirect3DSurface9
Definition: dxva2api.idl:23
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)

Referenced by D3DXFillTextureTX(), and test_D3DXFillTexture().

◆ D3DXFillVolumeTexture()

HRESULT WINAPI D3DXFillVolumeTexture ( struct IDirect3DVolumeTexture9 *  texture,
LPD3DXFILL3D  function,
void *  funcdata 
)

Definition at line 1731 of file texture.c.

1732{
1733 DWORD miplevels;
1734 DWORD m, x, y, z;
1736 D3DLOCKED_BOX lock_box;
1739 const struct pixel_format_desc *format;
1740 BYTE *data;
1741
1742 TRACE("texture %p, function %p, funcdata %p.\n", texture, function, funcdata);
1743
1744 if (texture == NULL || function == NULL)
1745 return D3DERR_INVALIDCALL;
1746
1748
1749 for (m = 0; m < miplevels; m++)
1750 {
1752 return D3DERR_INVALIDCALL;
1753
1754 format = get_format_info(desc.Format);
1756 {
1757 FIXME("Unsupported texture format %#x\n", desc.Format);
1758 return D3DERR_INVALIDCALL;
1759 }
1760
1762 return D3DERR_INVALIDCALL;
1763
1764 size.x = 1.0f / desc.Width;
1765 size.y = 1.0f / desc.Height;
1766 size.z = 1.0f / desc.Depth;
1767
1768 data = lock_box.pBits;
1769
1770 for (z = 0; z < desc.Depth; z++)
1771 {
1772 /* The callback function expects the coordinates of the center
1773 of the texel */
1774 coord.z = (z + 0.5f) / desc.Depth;
1775
1776 for (y = 0; y < desc.Height; y++)
1777 {
1778 coord.y = (y + 0.5f) / desc.Height;
1779
1780 for (x = 0; x < desc.Width; x++)
1781 {
1782 BYTE *dst = data + z * lock_box.SlicePitch + y * lock_box.RowPitch + x * format->bytes_per_pixel;
1783 struct d3dx_color color;
1784
1785 coord.x = (x + 0.5f) / desc.Width;
1786
1787 function(&value, &coord, &size, funcdata);
1788
1789 set_d3dx_color(&color, (const struct vec4 *)&value, RANGE_FULL, RANGE_FULL);
1791 }
1792 }
1793 }
1795 }
1796
1797 return D3D_OK;
1798}
GLdouble GLdouble z
Definition: glext.h:5874

Referenced by test_D3DXFillVolumeTexture().

◆ D3DXFillVolumeTextureTX()

HRESULT WINAPI D3DXFillVolumeTextureTX ( struct IDirect3DVolumeTexture9 *  texture,
ID3DXTextureShader *  texture_shader 
)

Definition at line 1800 of file texture.c.

1801{
1802 FIXME("texture %p, texture_shader %p stub.\n", texture, texture_shader);
1803 return E_NOTIMPL;
1804}
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by test_texture_shader().

◆ D3DXFilterTexture()

HRESULT WINAPI D3DXFilterTexture ( IDirect3DBaseTexture9 *  texture,
const PALETTEENTRY *  palette,
UINT  srclevel,
DWORD  filter 
)

Definition at line 48 of file texture.c.

52{
53 UINT level;
54 HRESULT hr;
56
57 TRACE("texture %p, palette %p, srclevel %u, filter %#lx.\n", texture, palette, srclevel, filter);
58
59 if (!texture)
60 return D3DERR_INVALIDCALL;
61
63 return hr;
64
65 if (srclevel == D3DX_DEFAULT)
66 srclevel = 0;
67 else if (srclevel >= IDirect3DBaseTexture9_GetLevelCount(texture))
68 return D3DERR_INVALIDCALL;
69
71 {
74 {
75 IDirect3DSurface9 *topsurf, *mipsurf;
77 int i, numfaces;
78
80 {
81 numfaces = 1;
82 IDirect3DTexture9_GetLevelDesc((IDirect3DTexture9*) texture, srclevel, &desc);
83 }
84 else
85 {
86 numfaces = 6;
87 IDirect3DCubeTexture9_GetLevelDesc((IDirect3DCubeTexture9 *)texture, srclevel, &desc);
88 }
89
90 if (filter == D3DX_DEFAULT)
91 {
92 if (is_pow2(desc.Width) && is_pow2(desc.Height))
94 else
96 }
97
98 for (i = 0; i < numfaces; i++)
99 {
100 level = srclevel + 1;
101 hr = get_surface(type, texture, i, srclevel, &topsurf);
102
103 if (FAILED(hr))
104 return D3DERR_INVALIDCALL;
105
106 while (get_surface(type, texture, i, level, &mipsurf) == D3D_OK)
107 {
108 hr = D3DXLoadSurfaceFromSurface(mipsurf, palette, NULL, topsurf, palette, NULL, filter, 0);
110 topsurf = mipsurf;
111
112 if (FAILED(hr))
113 break;
114
115 level++;
116 }
117
119 if (FAILED(hr))
120 return hr;
121 }
122
123 return D3D_OK;
124 }
125
127 {
129 int level, level_count;
130 IDirect3DVolume9 *top_volume, *mip_volume;
131 IDirect3DVolumeTexture9 *volume_texture = (IDirect3DVolumeTexture9*) texture;
132
133 IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, srclevel, &desc);
134
135 if (filter == D3DX_DEFAULT)
136 {
137 if (is_pow2(desc.Width) && is_pow2(desc.Height) && is_pow2(desc.Depth))
139 else
141 }
142
143 hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, srclevel, &top_volume);
144 if (FAILED(hr))
145 return hr;
146
147 level_count = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
148 for (level = srclevel + 1; level < level_count; level++)
149 {
150 IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, level, &mip_volume);
151 hr = D3DXLoadVolumeFromVolume(mip_volume, palette, NULL, top_volume, palette, NULL, filter, 0);
152 IDirect3DVolume9_Release(top_volume);
153 top_volume = mip_volume;
154
155 if (FAILED(hr))
156 break;
157 }
158
159 IDirect3DVolume9_Release(top_volume);
160 if (FAILED(hr))
161 return hr;
162
163 return D3D_OK;
164 }
165
166 default:
167 return D3DERR_INVALIDCALL;
168 }
169}
enum _D3DRESOURCETYPE D3DRESOURCETYPE
#define IDirect3DVolume9_Release(p)
Definition: d3d9.h:277
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:676
#define IDirect3DVolumeTexture9_GetVolumeLevel(p, a, b)
Definition: d3d9.h:956
#define IDirect3DBaseTexture9_GetType(p)
Definition: d3d9.h:672
static HRESULT d3dx9_validate_filter(uint32_t filter)
Definition: d3dx9_private.h:37
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
static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, int face, UINT level, struct IDirect3DSurface9 **surf)
Definition: texture.c:33
HRESULT WINAPI D3DXLoadVolumeFromVolume(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, IDirect3DVolume9 *src_volume, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
Definition: volume.c:242
#define D3DX_FILTER_DITHER
Definition: d3dx9tex.h:36
GLint level
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by D3DXCreateCubeTextureFromFileInMemoryEx(), D3DXCreateTextureFromFileInMemoryEx(), D3DXCreateVolumeTextureFromFileInMemoryEx(), D3DXRenderToEnvMap_End(), and test_D3DXFilterTexture().

◆ D3DXSaveTextureToFileA()

HRESULT WINAPI D3DXSaveTextureToFileA ( const char *  dst_filename,
D3DXIMAGE_FILEFORMAT  file_format,
IDirect3DBaseTexture9 *  src_texture,
const PALETTEENTRY *  src_palette 
)

Definition at line 1806 of file texture.c.

1808{
1809 int len;
1810 WCHAR *filename;
1811 HRESULT hr;
1813
1814 TRACE("dst_filename %s, file_format %u, src_texture %p, src_palette %p.\n",
1815 wine_dbgstr_a(dst_filename), file_format, src_texture, src_palette);
1816
1817 if (!dst_filename) return D3DERR_INVALIDCALL;
1818
1819 len = MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, NULL, 0);
1820 filename = malloc(len * sizeof(WCHAR));
1821 if (!filename) return E_OUTOFMEMORY;
1822 MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, filename, len);
1823
1824 hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, src_texture, src_palette);
1825 if (SUCCEEDED(hr))
1826 {
1829 }
1830
1831 free(filename);
1832 return hr;
1833}
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
HRESULT write_buffer_to_file(const WCHAR *filename, ID3DXBuffer *buffer)
Definition: util.c:277
HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
Definition: texture.c:1856
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
#define SUCCEEDED(hr)
Definition: intsafe.h:50

◆ D3DXSaveTextureToFileInMemory()

HRESULT WINAPI D3DXSaveTextureToFileInMemory ( ID3DXBuffer **  dst_buffer,
D3DXIMAGE_FILEFORMAT  file_format,
IDirect3DBaseTexture9 *  src_texture,
const PALETTEENTRY *  src_palette 
)

Definition at line 1856 of file texture.c.

1858{
1859 HRESULT hr;
1861 IDirect3DSurface9 *surface;
1862
1863 TRACE("dst_buffer %p, file_format %u, src_texture %p, src_palette %p.\n",
1864 dst_buffer, file_format, src_texture, src_palette);
1865
1866 if (!dst_buffer || !src_texture) return D3DERR_INVALIDCALL;
1867
1868 if (file_format == D3DXIFF_DDS)
1869 {
1870 FIXME("DDS file format isn't supported yet\n");
1871 return E_NOTIMPL;
1872 }
1873
1874 type = IDirect3DBaseTexture9_GetType(src_texture);
1875 switch (type)
1876 {
1877 case D3DRTYPE_TEXTURE:
1879 hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
1880 break;
1882 FIXME("Volume textures aren't supported yet\n");
1883 return E_NOTIMPL;
1884 default:
1885 return D3DERR_INVALIDCALL;
1886 }
1887
1888 if (SUCCEEDED(hr))
1889 {
1890 hr = D3DXSaveSurfaceToFileInMemory(dst_buffer, file_format, surface, src_palette, NULL);
1892 }
1893
1894 return hr;
1895}
HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DSurface9 *src_surface, const PALETTEENTRY *src_palette, const RECT *src_rect)
Definition: surface.c:2949
@ D3DXIFF_DDS
Definition: dx8vb.idl:66

Referenced by D3DXSaveTextureToFileA(), D3DXSaveTextureToFileW(), and test_D3DXSaveTextureToFileInMemory().

◆ D3DXSaveTextureToFileW()

HRESULT WINAPI D3DXSaveTextureToFileW ( const WCHAR *  dst_filename,
D3DXIMAGE_FILEFORMAT  file_format,
IDirect3DBaseTexture9 *  src_texture,
const PALETTEENTRY *  src_palette 
)

Definition at line 1835 of file texture.c.

1837{
1838 HRESULT hr;
1840
1841 TRACE("dst_filename %s, file_format %u, src_texture %p, src_palette %p.\n",
1842 wine_dbgstr_w(dst_filename), file_format, src_texture, src_palette);
1843
1844 if (!dst_filename) return D3DERR_INVALIDCALL;
1845
1846 hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, src_texture, src_palette);
1847 if (SUCCEEDED(hr))
1848 {
1849 hr = write_buffer_to_file(dst_filename, buffer);
1851 }
1852
1853 return hr;
1854}

◆ get_alpha_replacement_format()

static D3DFORMAT get_alpha_replacement_format ( D3DFORMAT  format)
static

Definition at line 545 of file texture.c.

546{
547 static const struct
548 {
549 D3DFORMAT orig_format;
550 D3DFORMAT replacement_format;
551 }
552 replacement_formats[] =
553 {
559 };
560 unsigned int i;
561
562 for (i = 0; i < ARRAY_SIZE(replacement_formats); ++i)
563 if (replacement_formats[i].orig_format == format)
564 return replacement_formats[i].replacement_format;
565 return format;
566}
#define ARRAY_SIZE(A)
Definition: main.h:20
@ D3DFMT_A1R5G5B5
Definition: d3d8types.h:608
@ D3DFMT_X1R5G5B5
Definition: d3d8types.h:607
@ D3DFMT_A8L8
Definition: d3d8types.h:621
@ D3DFMT_X4R4G4B4
Definition: d3d8types.h:613
@ D3DFMT_A4R4G4B4
Definition: d3d8types.h:609
@ D3DFMT_X8R8G8B8
Definition: d3d8types.h:605
@ D3DFMT_L8
Definition: d3d8types.h:620
@ D3DFMT_X8B8G8R8
Definition: d3d9types.h:803
@ D3DFMT_A8B8G8R8
Definition: d3d9types.h:802

Referenced by D3DXCreateCubeTextureFromFileInMemoryEx(), D3DXCreateTextureFromFileInMemoryEx(), and D3DXCreateVolumeTextureFromFileInMemoryEx().

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

1636{
1637 switch (coord)
1638 {
1639 case XCOORD:
1640 return x + 0.5f;
1641 case XCOORDINV:
1642 return size - x - 0.5f;
1643 case YCOORD:
1644 return y + 0.5f;
1645 case YCOORDINV:
1646 return size - y - 0.5f;
1647 case ZERO:
1648 return 0.0f;
1649 case ONE:
1650 return size;
1651 default:
1652 ERR("Unexpected coordinate value\n");
1653 return 0.0f;
1654 }
1655}
#define ERR(fmt,...)
Definition: precomp.h:57

Referenced by compare_cube_texture_(), and D3DXFillCubeTexture().

◆ get_replacement_format()

static D3DFORMAT get_replacement_format ( D3DFORMAT  format)
static

Definition at line 171 of file texture.c.

172{
173 static const struct
174 {
176 D3DFORMAT replacement_format;
177 }
178 replacements[] =
179 {
189 };
190 unsigned int i;
191
192 for (i = 0; i < ARRAY_SIZE(replacements); ++i)
193 if (format == replacements[i].format)
194 return replacements[i].replacement_format;
195 return format;
196}
@ D3DFMT_DXT5
Definition: d3d8types.h:638
@ D3DFMT_DXT2
Definition: d3d8types.h:635
@ D3DFMT_DXT1
Definition: d3d8types.h:634
@ D3DFMT_DXT4
Definition: d3d8types.h:637
@ D3DFMT_DXT3
Definition: d3d8types.h:636
@ D3DFMT_A4L4
Definition: d3d8types.h:622
@ D3DFMT_A16B16G16R16
Definition: d3d9types.h:806
@ D3DFMT_L16
Definition: d3d9types.h:841

Referenced by check_texture_requirements().

◆ get_surface()

static HRESULT get_surface ( D3DRESOURCETYPE  type,
struct IDirect3DBaseTexture9 *  tex,
int  face,
UINT  level,
struct IDirect3DSurface9 **  surf 
)
static

Definition at line 33 of file texture.c.

35{
36 switch (type)
37 {
39 return IDirect3DTexture9_GetSurfaceLevel((IDirect3DTexture9*) tex, level, surf);
41 return IDirect3DCubeTexture9_GetCubeMapSurface((IDirect3DCubeTexture9*) tex, face, level, surf);
42 default:
43 ERR("Unexpected texture type\n");
44 return E_NOTIMPL;
45 }
46}
#define IDirect3DCubeTexture9_GetCubeMapSurface(p, a, b, c)
Definition: d3d9.h:766

Referenced by D3DXFilterTexture(), and D3DXSaveTextureToFileInMemory().

◆ is_pow2()

static BOOL is_pow2 ( UINT  num)
static

Definition at line 28 of file texture.c.

29{
30 return !(num & (num - 1));
31}
GLuint GLuint num
Definition: glext.h:9618

Referenced by check_texture_requirements(), D3DXCheckCubeTextureRequirements(), D3DXCheckVolumeTextureRequirements(), and D3DXFilterTexture().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )