ReactOS  0.4.15-dev-2091-gc14c9ca
d3dx9_private.h File Reference
#include <stdint.h>
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/rbtree.h"
#include "d3dx9.h"
Include dependency graph for d3dx9_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  vec4
 
struct  volume
 
struct  pixel_format_desc
 
struct  d3dx_include_from_file
 
struct  d3dx_const_param_eval_output
 
struct  d3dx_const_tab
 
struct  d3dx_regstore
 
struct  d3dx_preshader
 
struct  d3dx_param_eval
 
struct  param_rb_entry
 
struct  d3dx_parameter
 
struct  d3dx_top_level_parameter
 
struct  d3dx_shared_data
 
struct  ctab_constant
 

Macros

#define NONAMELESSUNION
 
#define COBJMACROS
 
#define ULONG64_MAX   (~(ULONG64)0)
 
#define SET_D3D_STATE_(manager, device, method, args...)
 
#define SET_D3D_STATE(base_effect, args...)   SET_D3D_STATE_(base_effect->manager, base_effect->device, args)
 

Enumerations

enum  format_type {
  FORMAT_ARGB, FORMAT_ARGBF16, FORMAT_ARGBF, FORMAT_DXT,
  FORMAT_INDEX, FORMAT_UNKNOWN
}
 
enum  pres_reg_tables {
  PRES_REGTAB_IMMED, PRES_REGTAB_CONST, PRES_REGTAB_OCONST, PRES_REGTAB_OBCONST,
  PRES_REGTAB_OICONST, PRES_REGTAB_TEMP, PRES_REGTAB_COUNT, PRES_REGTAB_FIRST_SHADER = PRES_REGTAB_CONST
}
 

Functions

static BOOL is_conversion_from_supported (const struct pixel_format_desc *format)
 
static BOOL is_conversion_to_supported (const struct pixel_format_desc *format)
 
HRESULT map_view_of_file (const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
 
HRESULT load_resource_into_memory (HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
 
HRESULT write_buffer_to_file (const WCHAR *filename, ID3DXBuffer *buffer) DECLSPEC_HIDDEN
 
const struct pixel_format_descget_format_info (D3DFORMAT format) DECLSPEC_HIDDEN
 
const struct pixel_format_descget_format_info_idx (int idx) DECLSPEC_HIDDEN
 
void copy_pixels (const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size, const struct pixel_format_desc *format) DECLSPEC_HIDDEN
 
void convert_argb_pixels (const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN
 
void point_filter_argb_pixels (const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN
 
HRESULT load_texture_from_dds (IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info, unsigned int skip_levels, unsigned int *loaded_miplevels) DECLSPEC_HIDDEN
 
HRESULT load_cube_texture_from_dds (IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
 
HRESULT load_volume_from_dds (IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
 
HRESULT load_volume_texture_from_dds (IDirect3DVolumeTexture9 *volume_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
 
HRESULT lock_surface (IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, IDirect3DSurface9 **temp_surface, BOOL write) DECLSPEC_HIDDEN
 
HRESULT unlock_surface (IDirect3DSurface9 *surface, const RECT *surface_rect, IDirect3DSurface9 *temp_surface, BOOL update) DECLSPEC_HIDDEN
 
HRESULT save_dds_texture_to_memory (ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN
 
unsigned short float_32_to_16 (const float in) DECLSPEC_HIDDEN
 
float float_16_to_32 (const unsigned short in) DECLSPEC_HIDDEN
 
const chardebug_d3dxparameter_class (D3DXPARAMETER_CLASS c) DECLSPEC_HIDDEN
 
const chardebug_d3dxparameter_type (D3DXPARAMETER_TYPE t) DECLSPEC_HIDDEN
 
const chardebug_d3dxparameter_registerset (D3DXREGISTER_SET r) DECLSPEC_HIDDEN
 
static BOOL get_bool (D3DXPARAMETER_TYPE type, const void *data)
 
static int get_int (D3DXPARAMETER_TYPE type, const void *data)
 
static float get_float (D3DXPARAMETER_TYPE type, const void *data)
 
static void set_number (void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
 
static BOOL is_param_type_sampler (D3DXPARAMETER_TYPE type)
 
static uint32_t make_pow2 (uint32_t num)
 
static BOOL is_top_level_parameter (struct d3dx_parameter *param)
 
static struct d3dx_top_level_parametertop_level_parameter_from_parameter (struct d3dx_parameter *param)
 
static ULONG64 next_update_version (ULONG64 *version_counter)
 
static BOOL is_top_level_param_dirty (struct d3dx_top_level_parameter *param, ULONG64 update_version)
 
static BOOL is_param_dirty (struct d3dx_parameter *param, ULONG64 update_version)
 
struct d3dx_parameterget_parameter_by_name (struct d3dx_effect *effect, struct d3dx_parameter *parameter, const char *name) DECLSPEC_HIDDEN
 
HRESULT d3dx_create_param_eval (struct d3dx_effect *effect, void *byte_code, unsigned int byte_code_size, D3DXPARAMETER_TYPE type, struct d3dx_param_eval **peval, ULONG64 *version_counter, const char **skip_constants, unsigned int skip_constants_count) DECLSPEC_HIDDEN
 
void d3dx_free_param_eval (struct d3dx_param_eval *peval) DECLSPEC_HIDDEN
 
HRESULT d3dx_evaluate_parameter (struct d3dx_param_eval *peval, const struct d3dx_parameter *param, void *param_value) DECLSPEC_HIDDEN
 
HRESULT d3dx_param_eval_set_shader_constants (ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, struct d3dx_param_eval *peval, BOOL update_all) DECLSPEC_HIDDEN
 
BOOL is_param_eval_input_dirty (struct d3dx_param_eval *peval, ULONG64 update_version) DECLSPEC_HIDDEN
 
const struct ctab_constantd3dx_shader_get_ctab_constant (ID3DXConstantTable *iface, D3DXHANDLE constant) DECLSPEC_HIDDEN
 

Variables

CRITICAL_SECTION from_file_mutex DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 31 of file d3dx9_private.h.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 26 of file d3dx9_private.h.

◆ SET_D3D_STATE

#define SET_D3D_STATE (   base_effect,
  args... 
)    SET_D3D_STATE_(base_effect->manager, base_effect->device, args)

Definition at line 402 of file d3dx9_private.h.

◆ SET_D3D_STATE_

#define SET_D3D_STATE_ (   manager,
  device,
  method,
  args... 
)
Value:
(manager ? manager->lpVtbl->method(manager, args) \
: device->lpVtbl->method(device, args))
Definition: match.c:390
Definition: devices.h:37

Definition at line 400 of file d3dx9_private.h.

◆ ULONG64_MAX

#define ULONG64_MAX   (~(ULONG64)0)

Definition at line 34 of file d3dx9_private.h.

Enumeration Type Documentation

◆ format_type

Enumerator
FORMAT_ARGB 
FORMAT_ARGBF16 
FORMAT_ARGBF 
FORMAT_DXT 
FORMAT_INDEX 
FORMAT_UNKNOWN 

Definition at line 49 of file d3dx9_private.h.

49  {
50  FORMAT_ARGB, /* unsigned */
51  FORMAT_ARGBF16,/* float 16 */
52  FORMAT_ARGBF, /* float */
53  FORMAT_DXT,
56 };

◆ pres_reg_tables

Enumerator
PRES_REGTAB_IMMED 
PRES_REGTAB_CONST 
PRES_REGTAB_OCONST 
PRES_REGTAB_OBCONST 
PRES_REGTAB_OICONST 
PRES_REGTAB_TEMP 
PRES_REGTAB_COUNT 
PRES_REGTAB_FIRST_SHADER 

Definition at line 244 of file d3dx9_private.h.

Function Documentation

◆ convert_argb_pixels()

void convert_argb_pixels ( const BYTE src,
UINT  src_row_pitch,
UINT  src_slice_pitch,
const struct volume src_size,
const struct pixel_format_desc src_format,
BYTE dst,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
const struct volume dst_size,
const struct pixel_format_desc dst_format,
D3DCOLOR  color_key,
const PALETTEENTRY palette 
)

Definition at line 1731 of file surface.c.

1735 {
1736  struct argb_conversion_info conv_info, ck_conv_info;
1737  const struct pixel_format_desc *ck_format = NULL;
1738  DWORD channels[4];
1739  UINT min_width, min_height, min_depth;
1740  UINT x, y, z;
1741 
1742  TRACE("src %p, src_row_pitch %u, src_slice_pitch %u, src_size %p, src_format %p, dst %p, "
1743  "dst_row_pitch %u, dst_slice_pitch %u, dst_size %p, dst_format %p, color_key 0x%08x, palette %p.\n",
1744  src, src_row_pitch, src_slice_pitch, src_size, src_format, dst, dst_row_pitch, dst_slice_pitch, dst_size,
1746 
1747  ZeroMemory(channels, sizeof(channels));
1748  init_argb_conversion_info(src_format, dst_format, &conv_info);
1749 
1750  min_width = min(src_size->width, dst_size->width);
1751  min_height = min(src_size->height, dst_size->height);
1752  min_depth = min(src_size->depth, dst_size->depth);
1753 
1754  if (color_key)
1755  {
1756  /* Color keys are always represented in D3DFMT_A8R8G8B8 format. */
1757  ck_format = get_format_info(D3DFMT_A8R8G8B8);
1758  init_argb_conversion_info(src_format, ck_format, &ck_conv_info);
1759  }
1760 
1761  for (z = 0; z < min_depth; z++) {
1762  const BYTE *src_slice_ptr = src + z * src_slice_pitch;
1763  BYTE *dst_slice_ptr = dst + z * dst_slice_pitch;
1764 
1765  for (y = 0; y < min_height; y++) {
1766  const BYTE *src_ptr = src_slice_ptr + y * src_row_pitch;
1767  BYTE *dst_ptr = dst_slice_ptr + y * dst_row_pitch;
1768 
1769  for (x = 0; x < min_width; x++) {
1770  if (!src_format->to_rgba && !dst_format->from_rgba
1771  && src_format->type == dst_format->type
1772  && src_format->bytes_per_pixel <= 4 && dst_format->bytes_per_pixel <= 4)
1773  {
1774  DWORD val;
1775 
1776  get_relevant_argb_components(&conv_info, src_ptr, channels);
1777  val = make_argb_color(&conv_info, channels);
1778 
1779  if (color_key)
1780  {
1781  DWORD ck_pixel;
1782 
1783  get_relevant_argb_components(&ck_conv_info, src_ptr, channels);
1784  ck_pixel = make_argb_color(&ck_conv_info, channels);
1785  if (ck_pixel == color_key)
1786  val &= ~conv_info.destmask[0];
1787  }
1788  memcpy(dst_ptr, &val, dst_format->bytes_per_pixel);
1789  }
1790  else
1791  {
1792  struct vec4 color, tmp;
1793 
1794  format_to_vec4(src_format, src_ptr, &color);
1795  if (src_format->to_rgba)
1796  src_format->to_rgba(&color, &tmp, palette);
1797  else
1798  tmp = color;
1799 
1800  if (ck_format)
1801  {
1802  DWORD ck_pixel;
1803 
1804  format_from_vec4(ck_format, &tmp, (BYTE *)&ck_pixel);
1805  if (ck_pixel == color_key)
1806  tmp.w = 0.0f;
1807  }
1808 
1809  if (dst_format->from_rgba)
1810  dst_format->from_rgba(&tmp, &color);
1811  else
1812  color = tmp;
1813 
1814  format_from_vec4(dst_format, &color, dst_ptr);
1815  }
1816 
1817  src_ptr += src_format->bytes_per_pixel;
1818  dst_ptr += dst_format->bytes_per_pixel;
1819  }
1820 
1821  if (src_size->width < dst_size->width) /* black out remaining pixels */
1822  memset(dst_ptr, 0, dst_format->bytes_per_pixel * (dst_size->width - src_size->width));
1823  }
1824 
1825  if (src_size->height < dst_size->height) /* black out remaining pixels */
1826  memset(dst + src_size->height * dst_row_pitch, 0, dst_row_pitch * (dst_size->height - src_size->height));
1827  }
1828  if (src_size->depth < dst_size->depth) /* black out remaining pixels */
1829  memset(dst + src_size->depth * dst_slice_pitch, 0, dst_slice_pitch * (dst_size->depth - src_size->depth));
1830 }
UINT width
Definition: d3dx9_private.h:43
static const char * dst_format
Definition: dib.c:1133
#define ZeroMemory
Definition: winbase.h:1664
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int This channels
Definition: rdpsnd_libao.c:37
void(* to_rgba)(const struct vec4 *src, struct vec4 *dst, const PALETTEENTRY *palette)
Definition: d3dx9_private.h:68
GLuint color
Definition: glext.h:6243
GLdouble GLdouble z
Definition: glext.h:5874
UINT height
Definition: d3dx9_private.h:44
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
UINT depth
Definition: d3dx9_private.h:45
enum format_type type
Definition: d3dx9_private.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
unsigned char BYTE
Definition: xxhash.c:193
static HPALETTE palette
Definition: clipboard.c:1345
static void format_from_vec4(const struct pixel_format_desc *format, const struct vec4 *src, BYTE *dst)
Definition: surface.c:1650
static void init_argb_conversion_info(const struct pixel_format_desc *srcformat, const struct pixel_format_desc *destformat, struct argb_conversion_info *info)
Definition: surface.c:1539
GLenum GLenum dst
Definition: glext.h:6340
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static void get_relevant_argb_components(const struct argb_conversion_info *info, const BYTE *col, DWORD *out)
Definition: surface.c:1572
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
static void format_to_vec4(const struct pixel_format_desc *format, const BYTE *src, struct vec4 *dst)
Definition: surface.c:1620
#define memset(x, y, z)
Definition: compat.h:39
static DWORD make_argb_color(const struct argb_conversion_info *info, const DWORD *in)
Definition: surface.c:1602

Referenced by D3DXLoadSurfaceFromMemory(), D3DXLoadVolumeFromMemory(), and D3DXSaveSurfaceToFileInMemory().

◆ copy_pixels()

void copy_pixels ( const BYTE src,
UINT  src_row_pitch,
UINT  src_slice_pitch,
BYTE dst,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
const struct volume size,
const struct pixel_format_desc format 
)

Definition at line 1700 of file surface.c.

1703 {
1704  UINT row, slice;
1705  BYTE *dst_addr;
1706  const BYTE *src_addr;
1707  UINT row_block_count = (size->width + format->block_width - 1) / format->block_width;
1708  UINT row_count = (size->height + format->block_height - 1) / format->block_height;
1709 
1710  for (slice = 0; slice < size->depth; slice++)
1711  {
1712  src_addr = src + slice * src_slice_pitch;
1713  dst_addr = dst + slice * dst_slice_pitch;
1714 
1715  for (row = 0; row < row_count; row++)
1716  {
1717  memcpy(dst_addr, src_addr, row_block_count * format->block_byte_count);
1718  src_addr += src_row_pitch;
1719  dst_addr += dst_row_pitch;
1720  }
1721  }
1722 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
unsigned char BYTE
Definition: xxhash.c:193
GLenum GLenum dst
Definition: glext.h:6340
unsigned int UINT
Definition: ndis.h:50
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by BitmapImpl_CopyPixels(), BmpFrameDecode_CopyPixels(), D3DXLoadSurfaceFromMemory(), D3DXLoadVolumeFromMemory(), GifFrameDecode_CopyPixels(), IcoFrameDecode_CopyPixels(), save_dds_surface_to_memory(), and TgaDecoder_Frame_CopyPixels().

◆ d3dx_create_param_eval()

HRESULT d3dx_create_param_eval ( struct d3dx_effect effect,
void byte_code,
unsigned int  byte_code_size,
D3DXPARAMETER_TYPE  type,
struct d3dx_param_eval **  peval,
ULONG64 version_counter,
const char **  skip_constants,
unsigned int  skip_constants_count 
)

Definition at line 1233 of file preshader.c.

1236 {
1237  struct d3dx_param_eval *peval;
1238  unsigned int *ptr, *shader_ptr = NULL;
1239  unsigned int i;
1240  BOOL shader;
1241  unsigned int count, pres_size;
1242  HRESULT ret;
1243 
1244  TRACE("effect %p, byte_code %p, byte_code_size %u, type %u, peval_out %p.\n",
1245  effect, byte_code, byte_code_size, type, peval_out);
1246 
1247  count = byte_code_size / sizeof(unsigned int);
1248  if (!byte_code || !count)
1249  {
1250  *peval_out = NULL;
1251  return D3D_OK;
1252  }
1253 
1254  peval = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*peval));
1255  if (!peval)
1256  {
1257  ret = E_OUTOFMEMORY;
1258  goto err_out;
1259  }
1261 
1262  peval->param_type = type;
1263  switch (type)
1264  {
1265  case D3DXPT_VERTEXSHADER:
1266  case D3DXPT_PIXELSHADER:
1267  shader = TRUE;
1268  break;
1269  default:
1270  shader = FALSE;
1271  break;
1272  }
1273  peval->shader_inputs.regset2table = shad_regset2table;
1274 
1275  ptr = (unsigned int *)byte_code;
1276  if (shader)
1277  {
1278  if ((*ptr & 0xfffe0000) != 0xfffe0000)
1279  {
1280  FIXME("Invalid shader signature %#x.\n", *ptr);
1282  goto err_out;
1283  }
1284  TRACE("Shader version %#x.\n", *ptr & 0xffff);
1285  shader_ptr = ptr;
1286  ptr = find_bytecode_comment(ptr + 1, count - 1, FOURCC_PRES, &pres_size);
1287  if (!ptr)
1288  TRACE("No preshader found.\n");
1289  }
1290  else
1291  {
1292  pres_size = count;
1293  }
1294 
1295  if (ptr && FAILED(ret = parse_preshader(&peval->pres, ptr, pres_size, effect)))
1296  {
1297  FIXME("Failed parsing preshader, byte code for analysis follows.\n");
1298  dump_bytecode(byte_code, byte_code_size);
1299  goto err_out;
1300  }
1301 
1302  if (shader)
1303  {
1304  if (FAILED(ret = get_constants_desc(shader_ptr, &peval->shader_inputs, effect,
1305  skip_constants, skip_constants_count, &peval->pres)))
1306  {
1307  TRACE("Could not get shader constant table, hr %#x.\n", ret);
1308  goto err_out;
1309  }
1310  update_table_sizes_consts(peval->pres.regs.table_sizes, &peval->shader_inputs);
1311  }
1312 
1314  {
1315  if (FAILED(ret = regstore_alloc_table(&peval->pres.regs, i)))
1316  goto err_out;
1317  }
1318 
1319  if (TRACE_ON(d3dx))
1320  {
1321  dump_bytecode(byte_code, byte_code_size);
1322  dump_preshader(&peval->pres);
1323  if (shader)
1324  {
1325  TRACE("// Shader registers:\n");
1326  dump_registers(&peval->shader_inputs);
1327  }
1328  }
1329  *peval_out = peval;
1330  TRACE("Created parameter evaluator %p.\n", *peval_out);
1331  return D3D_OK;
1332 
1333 err_out:
1334  WARN("Error creating parameter evaluator.\n");
1335  if (TRACE_ON(d3dx))
1336  dump_bytecode(byte_code, byte_code_size);
1337 
1338  d3dx_free_param_eval(peval);
1339  *peval_out = NULL;
1340  return ret;
1341 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:112
enum pres_value_type type
Definition: preshader.c:209
static void dump_preshader(struct d3dx_preshader *pres)
Definition: preshader.c:1089
void d3dx_free_param_eval(struct d3dx_param_eval *peval)
Definition: preshader.c:1358
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
static PVOID ptr
Definition: dispmode.c:27
static HRESULT parse_preshader(struct d3dx_preshader *pres, unsigned int *ptr, unsigned int count, struct d3dx_effect *effect)
Definition: preshader.c:1113
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
static enum pres_reg_tables shad_regset2table[]
Definition: preshader.c:235
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
static void dump_registers(struct d3dx_const_tab *ctab)
Definition: preshader.c:1063
static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab *out, struct d3dx_effect *effect, const char **skip_constants, unsigned int skip_constants_count, struct d3dx_preshader *pres)
Definition: preshader.c:862
int ret
struct d3dx_const_tab shader_inputs
#define FOURCC_PRES
Definition: preshader.c:153
#define D3D_OK
Definition: d3d.h:106
struct d3dx_preshader pres
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static HRESULT regstore_alloc_table(struct d3dx_regstore *rs, unsigned int table)
Definition: preshader.c:313
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static void update_table_sizes_consts(unsigned int *table_sizes, struct d3dx_const_tab *ctab)
Definition: preshader.c:1015
ULONG64 * version_counter
D3DXPARAMETER_TYPE param_type
static void dump_bytecode(void *data, unsigned int size)
Definition: preshader.c:384
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define TRACE_ON(x)
Definition: compat.h:75
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static unsigned int * find_bytecode_comment(unsigned int *ptr, unsigned int count, unsigned int fourcc, unsigned int *size)
Definition: preshader.c:401

Referenced by d3dx_parse_array_selector(), and d3dx_parse_resource().

◆ d3dx_evaluate_parameter()

HRESULT d3dx_evaluate_parameter ( struct d3dx_param_eval peval,
const struct d3dx_parameter param,
void param_value 
)

Definition at line 1723 of file preshader.c.

1725 {
1726  HRESULT hr;
1727  unsigned int i;
1728  unsigned int elements, elements_param, elements_table;
1729  float *oc;
1730 
1731  TRACE("peval %p, param %p, param_value %p.\n", peval, param, param_value);
1732 
1733  if (is_const_tab_input_dirty(&peval->pres.inputs, ULONG64_MAX))
1734  {
1735  set_constants(&peval->pres.regs, &peval->pres.inputs,
1737  NULL, NULL, peval->param_type, FALSE, FALSE);
1738 
1739  if (FAILED(hr = execute_preshader(&peval->pres)))
1740  return hr;
1741  }
1742 
1743  elements_table = get_offset_reg(PRES_REGTAB_OCONST, peval->pres.regs.table_sizes[PRES_REGTAB_OCONST]);
1744  elements_param = param->bytes / sizeof(unsigned int);
1745  elements = min(elements_table, elements_param);
1746  oc = (float *)peval->pres.regs.tables[PRES_REGTAB_OCONST];
1747  for (i = 0; i < elements; ++i)
1748  set_number((unsigned int *)param_value + i, param->type, oc + i, D3DXPT_FLOAT);
1749  return D3D_OK;
1750 }
static HRESULT set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const_tab, ULONG64 new_update_version, ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, D3DXPARAMETER_TYPE type, BOOL device_update_all, BOOL pres_dirty)
Definition: preshader.c:1483
HRESULT hr
Definition: shlfolder.c:183
static void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
static BOOL is_const_tab_input_dirty(struct d3dx_const_tab *ctab, ULONG64 update_version)
Definition: preshader.c:1702
#define FALSE
Definition: types.h:117
static HRESULT execute_preshader(struct d3dx_preshader *pres)
Definition: preshader.c:1659
#define TRACE(s)
Definition: solgame.cpp:4
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:301
static ULONG64 next_update_version(ULONG64 *version_counter)
LONG HRESULT
Definition: typedefs.h:79
GLfloat param
Definition: glext.h:5796
#define for
Definition: utility.h:88
#define ULONG64_MAX
Definition: d3dx9_private.h:34
#define D3D_OK
Definition: d3d.h:106
struct d3dx_preshader pres
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
ULONG64 * version_counter
D3DXPARAMETER_TYPE param_type
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by d3dx9_get_param_value_ptr().

◆ d3dx_free_param_eval()

void d3dx_free_param_eval ( struct d3dx_param_eval peval)

Definition at line 1358 of file preshader.c.

1359 {
1360  TRACE("peval %p.\n", peval);
1361 
1362  if (!peval)
1363  return;
1364 
1365  d3dx_free_preshader(&peval->pres);
1367  HeapFree(GetProcessHeap(), 0, peval);
1368 }
static void d3dx_free_preshader(struct d3dx_preshader *pres)
Definition: preshader.c:1350
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
struct d3dx_const_tab shader_inputs
struct d3dx_preshader pres
static void d3dx_free_const_tab(struct d3dx_const_tab *ctab)
Definition: preshader.c:1343
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by d3dx_create_param_eval(), and free_parameter().

◆ d3dx_param_eval_set_shader_constants()

HRESULT d3dx_param_eval_set_shader_constants ( ID3DXEffectStateManager *  manager,
struct IDirect3DDevice9 *  device,
struct d3dx_param_eval peval,
BOOL  update_all 
)

Definition at line 1752 of file preshader.c.

1754 {
1755  HRESULT hr;
1756  struct d3dx_preshader *pres = &peval->pres;
1757  struct d3dx_regstore *rs = &pres->regs;
1758  ULONG64 new_update_version = next_update_version(peval->version_counter);
1759  BOOL pres_dirty = FALSE;
1760 
1761  TRACE("device %p, peval %p, param_type %u.\n", device, peval, peval->param_type);
1762 
1764  {
1765  set_constants(rs, &pres->inputs, new_update_version,
1766  NULL, NULL, peval->param_type, FALSE, FALSE);
1767  if (FAILED(hr = execute_preshader(pres)))
1768  return hr;
1769  pres_dirty = TRUE;
1770  }
1771 
1772  return set_constants(rs, &peval->shader_inputs, new_update_version,
1773  manager, device, peval->param_type, update_all, pres_dirty);
1774 }
static HRESULT set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const_tab, ULONG64 new_update_version, ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, D3DXPARAMETER_TYPE type, BOOL device_update_all, BOOL pres_dirty)
Definition: preshader.c:1483
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
static BOOL is_const_tab_input_dirty(struct d3dx_const_tab *ctab, ULONG64 update_version)
Definition: preshader.c:1702
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
static HRESULT execute_preshader(struct d3dx_preshader *pres)
Definition: preshader.c:1659
#define TRACE(s)
Definition: solgame.cpp:4
static ULONG64 next_update_version(ULONG64 *version_counter)
LONG HRESULT
Definition: typedefs.h:79
#define ULONG64_MAX
Definition: d3dx9_private.h:34
unsigned __int64 ULONG64
Definition: imports.h:198
struct d3dx_const_tab shader_inputs
struct d3dx_preshader pres
#define NULL
Definition: types.h:112
ULONG64 * version_counter
D3DXPARAMETER_TYPE param_type
struct d3dx_regstore regs
struct d3dx_const_tab inputs

Referenced by d3dx_set_shader_constants().

◆ d3dx_shader_get_ctab_constant()

const struct ctab_constant* d3dx_shader_get_ctab_constant ( ID3DXConstantTable *  iface,
D3DXHANDLE  constant 
)

Definition at line 984 of file shader.c.

985 {
987 
989 }
static struct ID3DXConstantTableImpl * impl_from_ID3DXConstantTable(ID3DXConstantTable *iface)
Definition: shader.c:762
static struct ctab_constant * get_valid_constant(struct ID3DXConstantTableImpl *table, D3DXHANDLE handle)
Definition: shader.c:887

Referenced by get_ctab_constant_desc().

◆ debug_d3dxparameter_class()

const char* debug_d3dxparameter_class ( D3DXPARAMETER_CLASS  c)

Definition at line 237 of file util.c.

238 {
239  switch (c)
240  {
247  default:
248  FIXME("Unrecognized D3DXPARAMETER_CLASS %#x.\n", c);
249  return "unrecognized";
250  }
251 }
#define FIXME(fmt,...)
Definition: debug.h:111
const GLubyte * c
Definition: glext.h:8905
#define WINE_D3DX_TO_STR(x)
Definition: util.c:235

Referenced by d3dx_effect_GetMatrix(), d3dx_effect_GetMatrixArray(), d3dx_effect_GetMatrixPointerArray(), d3dx_effect_GetMatrixTranspose(), d3dx_effect_GetMatrixTransposeArray(), d3dx_effect_GetMatrixTransposePointerArray(), d3dx_effect_GetVector(), d3dx_effect_GetVectorArray(), d3dx_effect_SetBoolArray(), d3dx_effect_SetFloatArray(), d3dx_effect_SetIntArray(), d3dx_effect_SetMatrix(), d3dx_effect_SetMatrixArray(), d3dx_effect_SetMatrixPointerArray(), d3dx_effect_SetMatrixTranspose(), d3dx_effect_SetMatrixTransposeArray(), d3dx_effect_SetMatrixTransposePointerArray(), d3dx_effect_SetVector(), d3dx_effect_SetVectorArray(), d3dx_parse_effect_typedef(), d3dx_parse_init_value(), d3dx_parse_resource(), d3dx_parse_value(), ID3DXConstantTableImpl_SetValue(), parse_ctab_constant_type(), set(), set_matrix_array(), set_matrix_pointer_array(), set_scalar(), set_scalar_array(), set_vector(), and set_vector_array().

◆ debug_d3dxparameter_registerset()

const char* debug_d3dxparameter_registerset ( D3DXREGISTER_SET  r)

Definition at line 283 of file util.c.

284 {
285  switch (r)
286  {
291  default:
292  FIXME("Unrecognized D3DXREGISTER_SET %#x.\n", r);
293  return "unrecognized";
294  }
295 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define FIXME(fmt,...)
Definition: debug.h:111
#define WINE_D3DX_TO_STR(x)
Definition: util.c:235

Referenced by ID3DXConstantTableImpl_SetDefaults(), parse_ctab_constant_type(), and set().

◆ debug_d3dxparameter_type()

const char* debug_d3dxparameter_type ( D3DXPARAMETER_TYPE  t)

Definition at line 253 of file util.c.

254 {
255  switch (t)
256  {
277  default:
278  FIXME("Unrecognized D3DXPARAMETER_TYP %#x.\n", t);
279  return "unrecognized";
280  }
281 }
GLdouble GLdouble t
Definition: gl.h:2047
#define FIXME(fmt,...)
Definition: debug.h:111
#define WINE_D3DX_TO_STR(x)
Definition: util.c:235

Referenced by d3dx_effect_GetValue(), d3dx_parse_effect_typedef(), d3dx_parse_resource(), d3dx_parse_value(), free_parameter(), free_parameter_object_data(), parse_ctab_constant_type(), and set_value().

◆ float_16_to_32()

float float_16_to_32 ( const unsigned short  in)

Definition at line 2203 of file math.c.

2204 {
2205  const unsigned short s = (in & 0x8000);
2206  const unsigned short e = (in & 0x7C00) >> 10;
2207  const unsigned short m = in & 0x3FF;
2208  const float sgn = (s ? -1.0f : 1.0f);
2209 
2210  if (e == 0)
2211  {
2212  if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
2213  else return sgn * powf(2, -14.0f) * (m / 1024.0f);
2214  }
2215  else
2216  {
2217  return sgn * powf(2, e - 15.0f) * (1.0f + (m / 1024.0f));
2218  }
2219 }
long sgn(REAL x)
Definition: varray.cc:48
const GLfloat * m
Definition: glext.h:10848
#define e
Definition: ke_i.h:82
_Check_return_ __CRT_INLINE float powf(_In_ float x, _In_ float y)
Definition: math.h:216
GLfloat f
Definition: glext.h:7540
GLdouble s
Definition: gl.h:2039
GLuint in
Definition: glext.h:9616

Referenced by D3DXFloat16To32Array(), format_to_vec4(), generic_float16_2(), generic_float16_4(), and load_numbered_arrays().

◆ float_32_to_16()

unsigned short float_32_to_16 ( const float  in)

Definition at line 2102 of file math.c.

2103 {
2104  int exp = 0, origexp;
2105  float tmp = fabsf(in);
2106  int sign = (copysignf(1, in) < 0);
2107  unsigned int mantissa;
2108  unsigned short ret;
2109 
2110  /* Deal with special numbers */
2111  if (isinf(in)) return (sign ? 0xffff : 0x7fff);
2112  if (isnan(in)) return (sign ? 0xffff : 0x7fff);
2113  if (in == 0.0f) return (sign ? 0x8000 : 0x0000);
2114 
2115  if (tmp < (float)(1u << 10))
2116  {
2117  do
2118  {
2119  tmp *= 2.0f;
2120  exp--;
2121  } while (tmp < (float)(1u << 10));
2122  }
2123  else if (tmp >= (float)(1u << 11))
2124  {
2125  do
2126  {
2127  tmp /= 2.0f;
2128  exp++;
2129  } while (tmp >= (float)(1u << 11));
2130  }
2131 
2132  exp += 10; /* Normalize the mantissa */
2133  exp += 15; /* Exponent is encoded with excess 15 */
2134 
2135  origexp = exp;
2136 
2137  mantissa = (unsigned int) tmp;
2138  if ((tmp - mantissa == 0.5f && mantissa % 2 == 1) || /* round half to even */
2139  (tmp - mantissa > 0.5f))
2140  {
2141  mantissa++; /* round to nearest, away from zero */
2142  }
2143  if (mantissa == 2048)
2144  {
2145  mantissa = 1024;
2146  exp++;
2147  }
2148 
2149  if (exp > 31)
2150  {
2151  /* too big */
2152  ret = 0x7fff; /* INF */
2153  }
2154  else if (exp <= 0)
2155  {
2156  unsigned int rounding = 0;
2157 
2158  /* Denormalized half float */
2159 
2160  /* return 0x0000 (=0.0) for numbers too small to represent in half floats */
2161  if (exp < -11)
2162  return (sign ? 0x8000 : 0x0000);
2163 
2164  exp = origexp;
2165 
2166  /* the 13 extra bits from single precision are used for rounding */
2167  mantissa = (unsigned int)(tmp * (1u << 13));
2168  mantissa >>= 1 - exp; /* denormalize */
2169 
2170  mantissa -= ~(mantissa >> 13) & 1; /* round half to even */
2171  /* remove 13 least significant bits to get half float precision */
2172  mantissa >>= 12;
2173  rounding = mantissa & 1;
2174  mantissa >>= 1;
2175 
2176  ret = mantissa + rounding;
2177  }
2178  else
2179  {
2180  ret = (exp << 10) | (mantissa & 0x3ff);
2181  }
2182 
2183  ret |= ((sign ? 1 : 0) << 15); /* Add the sign */
2184  return ret;
2185 }
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 * u
Definition: glfuncs.h:240
static size_t double int int int * sign
Definition: printf.c:69
float __cdecl copysignf(float, float)
GLfloat f
Definition: glext.h:7540
int isinf(double x)
int ret
int isnan(double x)
GLuint in
Definition: glext.h:9616
DWORD exp
Definition: msg.c:16033
_Check_return_ __CRT_INLINE float __CRTDECL fabsf(_In_ float x)
Definition: math.h:164
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by D3DXFloat32To16Array(), and fill_texture().

◆ get_bool()

static BOOL get_bool ( D3DXPARAMETER_TYPE  type,
const void data 
)
inlinestatic

Definition at line 141 of file d3dx9_private.h.

142 {
143  switch (type)
144  {
145  case D3DXPT_FLOAT:
146  case D3DXPT_INT:
147  case D3DXPT_BOOL:
148  return !!*(DWORD *)data;
149 
150  case D3DXPT_VOID:
151  return *(BOOL *)data;
152 
153  default:
154  return FALSE;
155  }
156 }
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by debugstr_jsval(), equal_values(), get_float(), get_int(), interp_end_finally(), jsval_strict_equal(), jsval_to_variant(), set_number(), stringify(), to_boolean(), to_number(), to_object(), and to_string().

◆ get_float()

static float get_float ( D3DXPARAMETER_TYPE  type,
const void data 
)
inlinestatic

Definition at line 177 of file d3dx9_private.h.

178 {
179  switch (type)
180  {
181  case D3DXPT_FLOAT:
182  case D3DXPT_VOID:
183  return *(float *)data;
184 
185  case D3DXPT_INT:
186  return (float)(*(int *)data);
187 
188  case D3DXPT_BOOL:
189  return (float)get_bool(type, data);
190 
191  default:
192  return 0.0f;
193  }
194 }
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by set_number().

◆ get_format_info()

const struct pixel_format_desc* get_format_info ( D3DFORMAT  format)

Definition at line 217 of file util.c.

218 {
219  unsigned int i = 0;
220  while(formats[i].format != format && formats[i].format != D3DFMT_UNKNOWN) i++;
221  if (formats[i].format == D3DFMT_UNKNOWN)
222  FIXME("Unknown format %#x (as FOURCC %s).\n", format, debugstr_an((const char *)&format, 4));
223  return &formats[i];
224 }
static const struct pixel_format_desc formats[]
Definition: util.c:59
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FIXME(fmt,...)
Definition: debug.h:111
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
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

Referenced by calculate_dds_surface_size(), check_texture_requirements(), convert_argb_pixels(), D3DXFillCubeTexture(), D3DXFillTexture(), D3DXFillVolumeTexture(), D3DXLoadSurfaceFromFileInMemory(), D3DXLoadSurfaceFromMemory(), D3DXLoadSurfaceFromSurface(), D3DXLoadVolumeFromMemory(), D3DXSaveSurfaceToFileInMemory(), point_filter_argb_pixels(), and save_dds_surface_to_memory().

◆ get_format_info_idx()

const struct pixel_format_desc* get_format_info_idx ( int  idx)

Definition at line 226 of file util.c.

227 {
228  if(idx >= ARRAY_SIZE(formats))
229  return NULL;
231  return NULL;
232  return &formats[idx];
233 }
static const struct pixel_format_desc formats[]
Definition: util.c:59
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
unsigned int idx
Definition: utils.c:41
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112

Referenced by check_texture_requirements().

◆ get_int()

static int get_int ( D3DXPARAMETER_TYPE  type,
const void data 
)
inlinestatic

Definition at line 158 of file d3dx9_private.h.

159 {
160  switch (type)
161  {
162  case D3DXPT_FLOAT:
163  return (int)(*(float *)data);
164 
165  case D3DXPT_INT:
166  case D3DXPT_VOID:
167  return *(int *)data;
168 
169  case D3DXPT_BOOL:
170  return get_bool(type, data);
171 
172  default:
173  return 0;
174  }
175 }
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by set_number().

◆ get_parameter_by_name()

struct d3dx_parameter* get_parameter_by_name ( struct d3dx_effect effect,
struct d3dx_parameter parameter,
const char name 
)

Definition at line 1026 of file effect.c.

1028 {
1029  struct d3dx_parameter *temp_parameter;
1030  unsigned int name_len, param_name_len;
1031  unsigned int i, count, length;
1032  struct wine_rb_entry *entry;
1033  unsigned int full_name_size;
1034  const char *part;
1035  char *full_name;
1036 
1037  TRACE("effect %p, parameter %p, name %s.\n", effect, parameter, debugstr_a(name));
1038 
1039  if (!name || !*name) return NULL;
1040 
1041  if (!parameter)
1042  {
1043  if ((entry = wine_rb_get(&effect->param_tree, name)))
1045  return NULL;
1046  }
1047 
1048  if (parameter->full_name)
1049  {
1050  name_len = strlen(name);
1051  param_name_len = strlen(parameter->full_name);
1052  full_name_size = name_len + param_name_len + 2;
1053  if (effect->full_name_tmp_size < full_name_size)
1054  {
1055  if (!(full_name = heap_realloc(effect->full_name_tmp, full_name_size)))
1056  {
1057  ERR("Out of memory.\n");
1058  return NULL;
1059  }
1060  effect->full_name_tmp = full_name;
1061  effect->full_name_tmp_size = full_name_size;
1062  }
1063  else
1064  {
1065  full_name = effect->full_name_tmp;
1066  }
1067  memcpy(full_name, parameter->full_name, param_name_len);
1068  full_name[param_name_len] = '.';
1069  memcpy(full_name + param_name_len + 1, name, name_len);
1070  full_name[param_name_len + 1 + name_len] = 0;
1071 
1072  if ((entry = wine_rb_get(&effect->param_tree, full_name)))
1074  return NULL;
1075  }
1076 
1077  /* Pass / technique annotations are not stored in the parameters tree,
1078  * do a linear search. */
1079  count = parameter->member_count;
1080 
1081  length = strcspn( name, "[." );
1082  part = name + length;
1083 
1084  for (i = 0; i < count; i++)
1085  {
1086  temp_parameter = &parameter->members[i];
1087 
1088  if (!strcmp(temp_parameter->name, name))
1089  {
1090  TRACE("Returning parameter %p\n", temp_parameter);
1091  return temp_parameter;
1092  }
1093  else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
1094  {
1095  switch (*part++)
1096  {
1097  case '.':
1098  return get_parameter_by_name(effect, temp_parameter, part);
1099 
1100  case '[':
1101  return get_parameter_element_by_name(effect, temp_parameter, part);
1102 
1103  default:
1104  FIXME("Unhandled case \"%c\"\n", *--part);
1105  break;
1106  }
1107  }
1108  }
1109 
1110  TRACE("Parameter not found\n");
1111  return NULL;
1112 }
static struct d3dx_parameter * get_parameter_element_by_name(struct d3dx_effect *effect, struct d3dx_parameter *parameter, const char *name)
Definition: effect.c:944
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
GLuint GLuint GLsizei count
Definition: gl.h:1545
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
unsigned int full_name_tmp_size
Definition: effect.c:188
#define FIXME(fmt,...)
Definition: debug.h:111
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
struct d3dx_parameter * members
struct wine_rb_tree param_tree
Definition: effect.c:186
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
struct d3dx_parameter * get_parameter_by_name(struct d3dx_effect *effect, struct d3dx_parameter *parameter, const char *name)
Definition: effect.c:1026
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: rbtree.h:35
#define NULL
Definition: types.h:112
#define rb_entry(ptr, type, member)
Definition: rbtree.h:130
Definition: name.c:38
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * full_name_tmp
Definition: effect.c:187

Referenced by d3dx9_effect_init(), d3dx_effect_GetParameterByName(), d3dx_parse_array_selector(), d3dx_parse_resource(), get_annotation_by_name(), get_constants_desc(), get_parameter_element_by_name(), and get_valid_parameter().

◆ is_conversion_from_supported()

static BOOL is_conversion_from_supported ( const struct pixel_format_desc format)
inlinestatic

Definition at line 79 of file d3dx9_private.h.

80 {
81  if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
82  || format->type == FORMAT_ARGBF || format->type == FORMAT_DXT)
83  return TRUE;
84  return !!format->to_rgba;
85 }
#define TRUE
Definition: types.h:120
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546

Referenced by D3DXLoadSurfaceFromMemory(), D3DXLoadVolumeFromMemory(), and D3DXSaveSurfaceToFileInMemory().

◆ is_conversion_to_supported()

static BOOL is_conversion_to_supported ( const struct pixel_format_desc format)
inlinestatic

Definition at line 87 of file d3dx9_private.h.

88 {
89  if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
90  || format->type == FORMAT_ARGBF || format->type == FORMAT_DXT)
91  return TRUE;
92  return !!format->from_rgba;
93 }
#define TRUE
Definition: types.h:120
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546

Referenced by D3DXLoadSurfaceFromMemory(), D3DXLoadVolumeFromMemory(), and D3DXSaveSurfaceToFileInMemory().

◆ is_param_dirty()

static BOOL is_param_dirty ( struct d3dx_parameter param,
ULONG64  update_version 
)
inlinestatic

Definition at line 387 of file d3dx9_private.h.

388 {
389  return is_top_level_param_dirty(param->top_level_param, update_version);
390 }
static BOOL is_top_level_param_dirty(struct d3dx_top_level_parameter *param, ULONG64 update_version)
GLfloat param
Definition: glext.h:5796

Referenced by d3dx9_get_param_value_ptr(), and set_constants().

◆ is_param_eval_input_dirty()

BOOL is_param_eval_input_dirty ( struct d3dx_param_eval peval,
ULONG64  update_version 
)

Definition at line 1717 of file preshader.c.

1718 {
1719  return is_const_tab_input_dirty(&peval->pres.inputs, update_version)
1720  || is_const_tab_input_dirty(&peval->shader_inputs, update_version);
1721 }
static BOOL is_const_tab_input_dirty(struct d3dx_const_tab *ctab, ULONG64 update_version)
Definition: preshader.c:1702
struct d3dx_const_tab shader_inputs
struct d3dx_preshader pres

Referenced by d3dx9_get_param_value_ptr().

◆ is_param_type_sampler()

◆ is_top_level_param_dirty()

static BOOL is_top_level_param_dirty ( struct d3dx_top_level_parameter param,
ULONG64  update_version 
)
inlinestatic

Definition at line 377 of file d3dx9_private.h.

378 {
379  struct d3dx_shared_data *shared_data;
380 
381  if ((shared_data = param->shared_data))
382  return update_version < shared_data->update_version;
383  else
384  return update_version < param->update_version;
385 }
ULONG64 update_version
GLfloat param
Definition: glext.h:5796

Referenced by is_const_tab_input_dirty(), and is_param_dirty().

◆ is_top_level_parameter()

static BOOL is_top_level_parameter ( struct d3dx_parameter param)
inlinestatic

Definition at line 361 of file d3dx9_private.h.

362 {
363  return &param->top_level_param->param == param;
364 }
GLfloat param
Definition: glext.h:5796

Referenced by add_param_to_tree(), d3dx_effect_GetParameterDesc(), get_annotation_from_object(), and get_constants_desc().

◆ load_cube_texture_from_dds()

HRESULT load_cube_texture_from_dds ( IDirect3DCubeTexture9 *  cube_texture,
const void src_data,
const PALETTEENTRY palette,
DWORD  filter,
D3DCOLOR  color_key,
const D3DXIMAGE_INFO src_info 
)

◆ load_resource_into_memory()

HRESULT load_resource_into_memory ( HMODULE  module,
HRSRC  resinfo,
void **  buffer,
DWORD length 
)

Definition at line 170 of file util.c.

171 {
173 
174  *length = SizeofResource(module, resinfo);
175  if(*length == 0) return HRESULT_FROM_WIN32(GetLastError());
176 
177  resource = LoadResource(module, resinfo);
178  if( !resource ) return HRESULT_FROM_WIN32(GetLastError());
179 
181  if(*buffer == NULL) return HRESULT_FROM_WIN32(GetLastError());
182 
183  return S_OK;
184 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
GLuint buffer
Definition: glext.h:5915
int resource
Definition: rdpsnd_sgi.c:44
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568

Referenced by D3DXAssembleShaderFromResourceA(), D3DXAssembleShaderFromResourceW(), D3DXCompileShaderFromResourceA(), D3DXCompileShaderFromResourceW(), D3DXCreateEffectCompilerFromResourceA(), D3DXCreateEffectCompilerFromResourceW(), D3DXCreateEffectFromResourceExA(), D3DXCreateEffectFromResourceExW(), D3DXCreateTextureFromResourceExA(), D3DXCreateTextureFromResourceExW(), D3DXGetImageInfoFromResourceA(), D3DXGetImageInfoFromResourceW(), D3DXLoadMeshFromXResource(), D3DXLoadSurfaceFromResourceA(), D3DXLoadSurfaceFromResourceW(), D3DXPreprocessShaderFromResourceA(), and D3DXPreprocessShaderFromResourceW().

◆ load_texture_from_dds()

HRESULT load_texture_from_dds ( IDirect3DTexture9 *  texture,
const void src_data,
const PALETTEENTRY palette,
DWORD  filter,
D3DCOLOR  color_key,
const D3DXIMAGE_INFO src_info,
unsigned int  skip_levels,
unsigned int loaded_miplevels 
)

Definition at line 737 of file surface.c.

740 {
741  HRESULT hr;
742  RECT src_rect;
743  UINT src_pitch;
744  UINT mip_level;
745  UINT mip_levels;
746  UINT mip_level_size;
747  UINT width, height;
748  IDirect3DSurface9 *surface;
749  const struct dds_header *header = src_data;
750  const BYTE *pixels = (BYTE *)(header + 1);
751 
752  /* Loading a cube texture as a simple texture is also supported
753  * (only first face texture is taken). Same with volume textures. */
754  if ((src_info->ResourceType != D3DRTYPE_TEXTURE)
755  && (src_info->ResourceType != D3DRTYPE_CUBETEXTURE)
756  && (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE))
757  {
758  WARN("Trying to load a %u resource as a 2D texture, returning failure.\n", src_info->ResourceType);
759  return D3DXERR_INVALIDDATA;
760  }
761 
762  width = src_info->Width;
763  height = src_info->Height;
764  mip_levels = min(src_info->MipLevels, IDirect3DTexture9_GetLevelCount(texture));
765  if (src_info->ResourceType == D3DRTYPE_VOLUMETEXTURE)
766  mip_levels = 1;
767  for (mip_level = 0; mip_level < mip_levels + skip_levels; ++mip_level)
768  {
769  hr = calculate_dds_surface_size(src_info->Format, width, height, &src_pitch, &mip_level_size);
770  if (FAILED(hr)) return hr;
771 
772  if (mip_level >= skip_levels)
773  {
774  SetRect(&src_rect, 0, 0, width, height);
775 
776  IDirect3DTexture9_GetSurfaceLevel(texture, mip_level - skip_levels, &surface);
777  hr = D3DXLoadSurfaceFromMemory(surface, palette, NULL, pixels, src_info->Format, src_pitch,
778  NULL, &src_rect, filter, color_key);
779  IDirect3DSurface9_Release(surface);
780  if (FAILED(hr))
781  return hr;
782  }
783 
784  pixels += mip_level_size;
785  width = max(1, width / 2);
786  height = max(1, height / 2);
787  }
788 
789  *loaded_miplevels = mip_levels - skip_levels;
790 
791  return D3D_OK;
792 }
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
GLint GLint GLsizei width
Definition: gl.h:1546
#define max(a, b)
Definition: svc.c:63
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:1033
#define WARN(fmt,...)
Definition: debug.h:112
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:1027
D3DRESOURCETYPE ResourceType
Definition: d3dx9tex.h:83
UINT MipLevels
Definition: d3dx9tex.h:81
D3DFORMAT Format
Definition: d3dx9tex.h:82
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
static HRESULT calculate_dds_surface_size(D3DFORMAT format, UINT width, UINT height, UINT *pitch, UINT *size)
Definition: surface.c:452
unsigned char BYTE
Definition: xxhash.c:193
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define D3D_OK
Definition: d3d.h:106
HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, const void *src_memory, D3DFORMAT src_format, UINT src_pitch, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key)
Definition: surface.c:1963
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by D3DXCreateTextureFromFileInMemoryEx().

◆ load_volume_from_dds()

HRESULT load_volume_from_dds ( IDirect3DVolume9 *  dst_volume,
const PALETTEENTRY dst_palette,
const D3DBOX dst_box,
const void src_data,
const D3DBOX src_box,
DWORD  filter,
D3DCOLOR  color_key,
const D3DXIMAGE_INFO src_info 
)

Definition at line 719 of file surface.c.

722 {
723  UINT row_pitch, slice_pitch;
724  const struct dds_header *header = src_data;
725  const BYTE *pixels = (BYTE *)(header + 1);
726 
727  if (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE)
728  return D3DXERR_INVALIDDATA;
729 
730  if (FAILED(calculate_dds_surface_size(src_info->Format, src_info->Width, src_info->Height, &row_pitch, &slice_pitch)))
731  return E_NOTIMPL;
732 
733  return D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box, pixels, src_info->Format,
734  row_pitch, slice_pitch, NULL, src_box, filter, color_key);
735 }
D3DRESOURCETYPE ResourceType
Definition: d3dx9tex.h:83
D3DFORMAT Format
Definition: d3dx9tex.h:82
static HRESULT calculate_dds_surface_size(D3DFORMAT format, UINT width, UINT height, UINT *pitch, UINT *size)
Definition: surface.c:452
unsigned char BYTE
Definition: xxhash.c:193
HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_memory, D3DFORMAT src_format, UINT src_row_pitch, UINT src_slice_pitch, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
Definition: volume.c:87
#define E_NOTIMPL
Definition: ddrawi.h:99
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by D3DXLoadVolumeFromFileInMemory().

◆ load_volume_texture_from_dds()

HRESULT load_volume_texture_from_dds ( IDirect3DVolumeTexture9 *  volume_texture,
const void src_data,
const PALETTEENTRY palette,
DWORD  filter,
DWORD  color_key,
const D3DXIMAGE_INFO src_info 
)

Definition at line 847 of file surface.c.

849 {
850  HRESULT hr;
851  UINT mip_level;
852  UINT mip_levels;
853  UINT src_slice_pitch;
854  UINT src_row_pitch;
855  D3DBOX src_box;
857  IDirect3DVolume9 *volume;
858  const struct dds_header *header = src_data;
859  const BYTE *pixels = (BYTE *)(header + 1);
860 
861  if (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE)
862  return D3DXERR_INVALIDDATA;
863 
864  width = src_info->Width;
865  height = src_info->Height;
866  depth = src_info->Depth;
867  mip_levels = min(src_info->MipLevels, IDirect3DVolumeTexture9_GetLevelCount(volume_texture));
868 
869  for (mip_level = 0; mip_level < mip_levels; mip_level++)
870  {
871  hr = calculate_dds_surface_size(src_info->Format, width, height, &src_row_pitch, &src_slice_pitch);
872  if (FAILED(hr)) return hr;
873 
874  hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, mip_level, &volume);
875  if (FAILED(hr)) return hr;
876 
877  src_box.Left = 0;
878  src_box.Top = 0;
879  src_box.Right = width;
880  src_box.Bottom = height;
881  src_box.Front = 0;
882  src_box.Back = depth;
883 
885  src_row_pitch, src_slice_pitch, NULL, &src_box, filter, color_key);
886 
888  if (FAILED(hr)) return hr;
889 
890  pixels += depth * src_slice_pitch;
891  width = max(1, width / 2);
892  height = max(1, height / 2);
893  depth = max(1, depth / 2);
894  }
895 
896  return D3D_OK;
897 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define max(a, b)
Definition: svc.c:63
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DVolumeTexture9_GetLevelCount(p)
Definition: d3d9.h:1122
D3DRESOURCETYPE ResourceType
Definition: d3dx9tex.h:83
UINT MipLevels
Definition: d3dx9tex.h:81
UINT Back
Definition: d3d8types.h:1016
UINT Bottom
Definition: d3d8types.h:1014
D3DFORMAT Format
Definition: d3dx9tex.h:82
UINT Top
Definition: d3d8types.h:1012
LONG HRESULT
Definition: typedefs.h:79
UINT Left
Definition: d3d8types.h:1011
static HRESULT calculate_dds_surface_size(D3DFORMAT format, UINT width, UINT height, UINT *pitch, UINT *size)
Definition: surface.c:452
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define IDirect3DVolume9_Release(p)
Definition: d3d9.h:383
unsigned char BYTE
Definition: xxhash.c:193
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define D3D_OK
Definition: d3d.h:106
HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_memory, D3DFORMAT src_format, UINT src_row_pitch, UINT src_slice_pitch, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
Definition: volume.c:87
UINT Front
Definition: d3d8types.h:1015
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define IDirect3DVolumeTexture9_GetVolumeLevel(p, a, b)
Definition: d3d9.h:1128
UINT Right
Definition: d3d8types.h:1013
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ lock_surface()

HRESULT lock_surface ( IDirect3DSurface9 *  surface,
const RECT surface_rect,
D3DLOCKED_RECT lock,
IDirect3DSurface9 **  temp_surface,
BOOL  write 
)

Definition at line 209 of file surface.c.

211 {
212  unsigned int width, height;
213  IDirect3DDevice9 *device;
215  DWORD lock_flag;
216  HRESULT hr;
217 
218  lock_flag = write ? 0 : D3DLOCK_READONLY;
219  *temp_surface = NULL;
220  if (FAILED(hr = IDirect3DSurface9_LockRect(surface, lock, surface_rect, lock_flag)))
221  {
223  IDirect3DSurface9_GetDesc(surface, &desc);
224 
225  if (surface_rect)
226  {
227  width = surface_rect->right - surface_rect->left;
228  height = surface_rect->bottom - surface_rect->top;
229  }
230  else
231  {
232  width = desc.Width;
233  height = desc.Height;
234  }
235 
237  desc.Format, D3DPOOL_SYSTEMMEM, temp_surface, NULL)
239  desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, temp_surface, NULL);
240  if (FAILED(hr))
241  {
242  WARN("Failed to create temporary surface, surface %p, format %#x,"
243  " usage %#x, pool %#x, write %#x, width %u, height %u.\n",
244  surface, desc.Format, desc.Usage, desc.Pool, write, width, height);
246  return hr;
247  }
248 
249  if (write || SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, surface, surface_rect,
250  *temp_surface, NULL, D3DTEXF_NONE)))
251  hr = IDirect3DSurface9_LockRect(*temp_surface, lock, NULL, lock_flag);
252 
254  if (FAILED(hr))
255  {
256  WARN("Failed to lock surface %p, write %#x, usage %#x, pool %#x.\n",
257  surface, write, desc.Usage, desc.Pool);
258  IDirect3DSurface9_Release(*temp_surface);
259  *temp_surface = NULL;
260  return hr;
261  }
262  TRACE("Created temporary surface %p.\n", surface);
263  }
264  return hr;
265 }
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
GLint GLint GLsizei width
Definition: gl.h:1546
rwlock_t lock
Definition: tcpcore.h:1163
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
LONG top
Definition: windef.h:307
#define IDirect3DSurface9_GetDevice(p, a)
Definition: d3d9.h:624
#define IDirect3DDevice9_CreateRenderTarget(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1535
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
FxDevice * device
#define IDirect3DDevice9_CreateOffscreenPlainSurface(p, a, b, c, d, e, f)
Definition: d3d9.h:1543
#define write
Definition: acwin.h:97
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
if SUCCEEDED(hr)
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDirect3DSurface9_GetDesc(p, a)
Definition: d3d9.h:634
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define NULL
Definition: types.h:112
LONG bottom
Definition: windef.h:309
#define IDirect3DSurface9_LockRect(p, a, b, c)
Definition: d3d9.h:635
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define IDirect3DDevice9_StretchRect(p, a, b, c, d, e)
Definition: d3d9.h:1541

Referenced by D3DXFillTexture(), D3DXLoadSurfaceFromMemory(), D3DXLoadSurfaceFromSurface(), D3DXSaveSurfaceToFileInMemory(), and save_dds_surface_to_memory().

◆ make_pow2()

static uint32_t make_pow2 ( uint32_t  num)
inlinestatic

Definition at line 232 of file d3dx9_private.h.

233 {
234 #ifndef __REACTOS__
235  uint32_t index;
236 #else
237  unsigned long index;
238 #endif
239  return BitScanReverse(&index, num - 1) ? 1u << (index + 1) : 1;
240 }
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 * u
Definition: glfuncs.h:240
GLuint index
Definition: glext.h:6031
GLuint GLuint num
Definition: glext.h:9618
#define index(s, c)
Definition: various.h:29
#define BitScanReverse
Definition: interlocked.h:6
UINT32 uint32_t
Definition: types.h:75

Referenced by check_texture_requirements(), D3DXCheckCubeTextureRequirements(), D3DXCheckVolumeTextureRequirements(), D3DXCreateCubeTextureFromFileInMemoryEx(), D3DXCreateFontIndirectW(), D3DXCreateTextureFromFileInMemoryEx(), and D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ map_view_of_file()

HRESULT map_view_of_file ( const WCHAR filename,
void **  buffer,
DWORD length 
)

Definition at line 120 of file util.c.

121 {
122  HANDLE hfile, hmapping = NULL;
123 
125  if(hfile == INVALID_HANDLE_VALUE) goto error;
126 
127  *length = GetFileSize(hfile, NULL);
128  if(*length == INVALID_FILE_SIZE) goto error;
129 
130  hmapping = CreateFileMappingW(hfile, NULL, PAGE_READONLY, 0, 0, NULL);
131  if(!hmapping) goto error;
132 
133  *buffer = MapViewOfFile(hmapping, FILE_MAP_READ, 0, 0, 0);
134  if(*buffer == NULL) goto error;
135 
136  CloseHandle(hmapping);
137  CloseHandle(hfile);
138 
139  return S_OK;
140 
141 error:
142  if (hmapping)
143  CloseHandle(hmapping);
144  if (hfile != INVALID_HANDLE_VALUE)
145  CloseHandle(hfile);
147 }
#define CloseHandle
Definition: compat.h:598
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define MapViewOfFile
Definition: compat.h:604
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
#define INVALID_FILE_SIZE
Definition: winbase.h:545
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define FILE_MAP_READ
Definition: compat.h:635
#define OPEN_EXISTING
Definition: compat.h:634
void error(char *format,...)
Definition: util.c:72
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:603
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define GENERIC_READ
Definition: compat.h:135
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
#define PAGE_READONLY
Definition: compat.h:138
#define CreateFileW
Definition: compat.h:600

Referenced by D3DXCreateCubeTextureFromFileA(), D3DXCreateCubeTextureFromFileExA(), D3DXCreateCubeTextureFromFileExW(), D3DXCreateCubeTextureFromFileW(), D3DXCreateEffectCompilerFromFileW(), D3DXCreateTextureFromFileExW(), D3DXCreateVolumeTextureFromFileA(), D3DXCreateVolumeTextureFromFileExA(), D3DXCreateVolumeTextureFromFileExW(), D3DXCreateVolumeTextureFromFileW(), D3DXGetImageInfoFromFileW(), D3DXLoadMeshFromXW(), D3DXLoadMeshHierarchyFromXW(), D3DXLoadSurfaceFromFileW(), and D3DXLoadVolumeFromFileW().

◆ next_update_version()

static ULONG64 next_update_version ( ULONG64 version_counter)
inlinestatic

Definition at line 372 of file d3dx9_private.h.

373 {
374  return ++*version_counter;
375 }

Referenced by d3dx_evaluate_parameter(), d3dx_param_eval_set_shader_constants(), next_effect_update_version(), and set_dirty().

◆ point_filter_argb_pixels()

void point_filter_argb_pixels ( const BYTE src,
UINT  src_row_pitch,
UINT  src_slice_pitch,
const struct volume src_size,
const struct pixel_format_desc src_format,
BYTE dst,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
const struct volume dst_size,
const struct pixel_format_desc dst_format,
D3DCOLOR  color_key,
const PALETTEENTRY palette 
)

Definition at line 1839 of file surface.c.

1843 {
1844  struct argb_conversion_info conv_info, ck_conv_info;
1845  const struct pixel_format_desc *ck_format = NULL;
1846  DWORD channels[4];
1847  UINT x, y, z;
1848 
1849  TRACE("src %p, src_row_pitch %u, src_slice_pitch %u, src_size %p, src_format %p, dst %p, "
1850  "dst_row_pitch %u, dst_slice_pitch %u, dst_size %p, dst_format %p, color_key 0x%08x, palette %p.\n",
1851  src, src_row_pitch, src_slice_pitch, src_size, src_format, dst, dst_row_pitch, dst_slice_pitch, dst_size,
1853 
1854  ZeroMemory(channels, sizeof(channels));
1855  init_argb_conversion_info(src_format, dst_format, &conv_info);
1856 
1857  if (color_key)
1858  {
1859  /* Color keys are always represented in D3DFMT_A8R8G8B8 format. */
1860  ck_format = get_format_info(D3DFMT_A8R8G8B8);
1861  init_argb_conversion_info(src_format, ck_format, &ck_conv_info);
1862  }
1863 
1864  for (z = 0; z < dst_size->depth; z++)
1865  {
1866  BYTE *dst_slice_ptr = dst + z * dst_slice_pitch;
1867  const BYTE *src_slice_ptr = src + src_slice_pitch * (z * src_size->depth / dst_size->depth);
1868 
1869  for (y = 0; y < dst_size->height; y++)
1870  {
1871  BYTE *dst_ptr = dst_slice_ptr + y * dst_row_pitch;
1872  const BYTE *src_row_ptr = src_slice_ptr + src_row_pitch * (y * src_size->height / dst_size->height);
1873 
1874  for (x = 0; x < dst_size->width; x++)
1875  {
1876  const BYTE *src_ptr = src_row_ptr + (x * src_size->width / dst_size->width) * src_format->bytes_per_pixel;
1877 
1878  if (!src_format->to_rgba && !dst_format->from_rgba
1879  && src_format->type == dst_format->type
1880  && src_format->bytes_per_pixel <= 4 && dst_format->bytes_per_pixel <= 4)
1881  {
1882  DWORD val;
1883 
1884  get_relevant_argb_components(&conv_info, src_ptr, channels);
1885  val = make_argb_color(&conv_info, channels);
1886 
1887  if (color_key)
1888  {
1889  DWORD ck_pixel;
1890 
1891  get_relevant_argb_components(&ck_conv_info, src_ptr, channels);
1892  ck_pixel = make_argb_color(&ck_conv_info, channels);
1893  if (ck_pixel == color_key)
1894  val &= ~conv_info.destmask[0];
1895  }
1896  memcpy(dst_ptr, &val, dst_format->bytes_per_pixel);
1897  }
1898  else
1899  {
1900  struct vec4 color, tmp;
1901 
1902  format_to_vec4(src_format, src_ptr, &color);
1903  if (src_format->to_rgba)
1904  src_format->to_rgba(&color, &tmp, palette);
1905  else
1906  tmp = color;
1907 
1908  if (ck_format)
1909  {
1910  DWORD ck_pixel;
1911 
1912  format_from_vec4(ck_format, &tmp, (BYTE *)&ck_pixel);
1913  if (ck_pixel == color_key)
1914  tmp.w = 0.0f;
1915  }
1916 
1917  if (dst_format->from_rgba)
1918  dst_format->from_rgba(&tmp, &color);
1919  else
1920  color = tmp;
1921 
1922  format_from_vec4(dst_format, &color, dst_ptr);
1923  }
1924 
1925  dst_ptr += dst_format->bytes_per_pixel;
1926  }
1927  }
1928  }
1929 }
UINT width
Definition: d3dx9_private.h:43
static const char * dst_format
Definition: dib.c:1133
#define ZeroMemory
Definition: winbase.h:1664
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int This channels
Definition: rdpsnd_libao.c:37
void(* to_rgba)(const struct vec4 *src, struct vec4 *dst, const PALETTEENTRY *palette)
Definition: d3dx9_private.h:68
GLuint color
Definition: glext.h:6243
GLdouble GLdouble z
Definition: glext.h:5874
UINT height
Definition: d3dx9_private.h:44
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
UINT depth
Definition: d3dx9_private.h:45
if(!(yy_init))
Definition: macro.lex.yy.c:714
enum format_type type
Definition: d3dx9_private.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
unsigned char BYTE
Definition: xxhash.c:193
static HPALETTE palette
Definition: clipboard.c:1345
static void format_from_vec4(const struct pixel_format_desc *format, const struct vec4 *src, BYTE *dst)
Definition: surface.c:1650
static void init_argb_conversion_info(const struct pixel_format_desc *srcformat, const struct pixel_format_desc *destformat, struct argb_conversion_info *info)
Definition: surface.c:1539
GLenum GLenum dst
Definition: glext.h:6340
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static void get_relevant_argb_components(const struct argb_conversion_info *info, const BYTE *col, DWORD *out)
Definition: surface.c:1572
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
static void format_to_vec4(const struct pixel_format_desc *format, const BYTE *src, struct vec4 *dst)
Definition: surface.c:1620
static DWORD make_argb_color(const struct argb_conversion_info *info, const DWORD *in)
Definition: surface.c:1602

Referenced by D3DXLoadSurfaceFromMemory(), and D3DXLoadVolumeFromMemory().

◆ save_dds_texture_to_memory()

HRESULT save_dds_texture_to_memory ( ID3DXBuffer **  dst_buffer,
IDirect3DBaseTexture9 *  src_texture,
const PALETTEENTRY src_palette 
)

Definition at line 672 of file surface.c.

673 {
674  HRESULT hr;
676  UINT mip_levels;
677  IDirect3DSurface9 *surface;
678 
679  type = IDirect3DBaseTexture9_GetType(src_texture);
680 
682  return D3DERR_INVALIDCALL;
683 
684  if (type == D3DRTYPE_CUBETEXTURE)
685  {
686  FIXME("Cube texture not supported yet\n");
687  return E_NOTIMPL;
688  }
689  else if (type == D3DRTYPE_VOLUMETEXTURE)
690  {
691  FIXME("Volume texture not supported yet\n");
692  return E_NOTIMPL;
693  }
694 
695  mip_levels = IDirect3DTexture9_GetLevelCount(src_texture);
696 
697  if (mip_levels > 1)
698  {
699  FIXME("Mipmap not supported yet\n");
700  return E_NOTIMPL;
701  }
702 
703  if (src_palette)
704  {
705  FIXME("Saving surfaces with palettized pixel formats not implemented yet\n");
706  return E_NOTIMPL;
707  }
708 
709  hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
710 
711  if (SUCCEEDED(hr))
712  {
713  hr = save_dds_surface_to_memory(dst_buffer, surface, NULL);
714  IDirect3DSurface9_Release(surface);
715  }
716 
717  return hr;
718 }
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:1027
static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, int face, UINT level, struct IDirect3DSurface9 **surf)
Definition: surface.c:657
if SUCCEEDED(hr)
#define FIXME(fmt,...)
Definition: debug.h:111
#define IDirect3DBaseTexture9_GetType(p)
Definition: d3d9.h:844
LONG HRESULT
Definition: typedefs.h:79
#define E_NOTIMPL
Definition: ddrawi.h:99
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSurface9 *src_surface, const RECT *src_rect)
Definition: surface.c:587
enum _D3DRESOURCETYPE D3DRESOURCETYPE

Referenced by D3DXSaveTextureToFileInMemory().

◆ set_number()

static void set_number ( void outdata,
D3DXPARAMETER_TYPE  outtype,
const void indata,
D3DXPARAMETER_TYPE  intype 
)
inlinestatic

Definition at line 196 of file d3dx9_private.h.

197 {
198  if (outtype == intype)
199  {
200  *(DWORD *)outdata = *(DWORD *)indata;
201  return;
202  }
203 
204  switch (outtype)
205  {
206  case D3DXPT_FLOAT:
207  *(float *)outdata = get_float(intype, indata);
208  break;
209 
210  case D3DXPT_BOOL:
211  *(BOOL *)outdata = get_bool(intype, indata);
212  break;
213 
214  case D3DXPT_INT:
215  *(int *)outdata = get_int(intype, indata);
216  break;
217 
218  default:
219  *(DWORD *)outdata = 0;
220  break;
221  }
222 }
static int get_int(D3DXPARAMETER_TYPE type, const void *data)
static float get_float(D3DXPARAMETER_TYPE type, const void *data)
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by d3dx_evaluate_parameter(), and set().

◆ top_level_parameter_from_parameter()

static struct d3dx_top_level_parameter* top_level_parameter_from_parameter ( struct d3dx_parameter param)
inlinestatic

Definition at line 367 of file d3dx9_private.h.

368 {
370 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
GLfloat param
Definition: glext.h:5796

Referenced by d3dx_effect_GetParameterDesc(), get_annotation_from_object(), and is_const_tab_input_dirty().

◆ unlock_surface()

HRESULT unlock_surface ( IDirect3DSurface9 *  surface,
const RECT surface_rect,
IDirect3DSurface9 *  temp_surface,
BOOL  update 
)

Definition at line 267 of file surface.c.

269 {
270  IDirect3DDevice9 *device;
271  POINT surface_point;
272  HRESULT hr;
273 
274  if (!temp_surface)
275  {
276  hr = IDirect3DSurface9_UnlockRect(surface);
277  return hr;
278  }
279 
280  hr = IDirect3DSurface9_UnlockRect(temp_surface);
281  if (update)
282  {
283  if (surface_rect)
284  {
285  surface_point.x = surface_rect->left;
286  surface_point.y = surface_rect->top;
287  }
288  else
289  {
290  surface_point.x = 0;
291  surface_point.y = 0;
292  }
294  if (FAILED(hr = IDirect3DDevice9_UpdateSurface(device, temp_surface, NULL, surface, &surface_point)))
295  WARN("Updating surface failed, hr %#x, surface %p, temp_surface %p.\n",
296  hr, surface, temp_surface);
298  }
299  IDirect3DSurface9_Release(temp_surface);
300  return hr;
301 }
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
long y
Definition: polytest.cpp:48
HRESULT hr
Definition: shlfolder.c:183
long x
Definition: polytest.cpp:48
#define WARN(fmt,...)
Definition: debug.h:112
LONG top
Definition: windef.h:307
#define IDirect3DSurface9_GetDevice(p, a)
Definition: d3d9.h:624
LONG left
Definition: windef.h:306
FxDevice * device
Definition: devices.h:37
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
LONG HRESULT
Definition: typedefs.h:79
#define IDirect3DDevice9_UpdateSurface(p, a, b, c, d)
Definition: d3d9.h:1537
#define NULL
Definition: types.h:112
#define IDirect3DSurface9_UnlockRect(p)
Definition: d3d9.h:636

Referenced by D3DXFillTexture(), D3DXLoadSurfaceFromMemory(), D3DXLoadSurfaceFromSurface(), D3DXSaveSurfaceToFileInMemory(), and save_dds_surface_to_memory().

◆ write_buffer_to_file()

HRESULT write_buffer_to_file ( const WCHAR filename,
ID3DXBuffer buffer 
)

Definition at line 186 of file util.c.

187 {
188  HRESULT hr = S_OK;
189  void *buffer_pointer;
191  DWORD bytes_written;
193  if (file == INVALID_HANDLE_VALUE)
195 
196  buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
198 
199  if (!WriteFile(file, buffer_pointer, buffer_size, &bytes_written, NULL))
201 
202  CloseHandle(file);
203  return hr;
204 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:598
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
#define GENERIC_WRITE
Definition: nt_native.h:90
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define S_OK
Definition: intsafe.h:51
#define CREATE_ALWAYS
Definition: disk.h:72
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
Definition: fci.c:126

Referenced by D3DXSaveSurfaceToFileA(), D3DXSaveSurfaceToFileW(), D3DXSaveTextureToFileA(), and D3DXSaveTextureToFileW().

Variable Documentation

◆ DECLSPEC_HIDDEN

const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl DECLSPEC_HIDDEN

Definition at line 77 of file d3dx9_private.h.