ReactOS 0.4.15-dev-8332-ga943bb4
util.c File Reference
#include "d3dx9_private.h"
Include dependency graph for util.c:

Go to the source code of this file.

Macros

#define WINE_D3DX_TO_STR(x)   case x: return #x
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static void la_from_rgba (const struct vec4 *rgba, struct vec4 *la)
 
static void la_to_rgba (const struct vec4 *la, struct vec4 *rgba, const PALETTEENTRY *palette)
 
static void index_to_rgba (const struct vec4 *index, struct vec4 *rgba, const PALETTEENTRY *palette)
 
HRESULT map_view_of_file (const WCHAR *filename, void **buffer, DWORD *length)
 
HRESULT load_resource_into_memory (HMODULE module, HRSRC resinfo, void **buffer, DWORD *length)
 
HRESULT write_buffer_to_file (const WCHAR *dst_filename, ID3DXBuffer *buffer)
 
const struct pixel_format_descget_format_info (D3DFORMAT format)
 
const struct pixel_format_descget_format_info_idx (int idx)
 
const chardebug_d3dxparameter_class (D3DXPARAMETER_CLASS c)
 
const chardebug_d3dxparameter_type (D3DXPARAMETER_TYPE t)
 
const chardebug_d3dxparameter_registerset (D3DXREGISTER_SET r)
 
BOOL WINAPI D3DXDebugMute (BOOL mute)
 
UINT WINAPI D3DXGetDriverLevel (struct IDirect3DDevice9 *device)
 

Variables

static const struct pixel_format_desc formats []
 

Macro Definition Documentation

◆ WINE_D3DX_TO_STR

#define WINE_D3DX_TO_STR (   x)    case x: return #x

Definition at line 235 of file util.c.

Function Documentation

◆ D3DXDebugMute()

BOOL WINAPI D3DXDebugMute ( BOOL  mute)

Definition at line 303 of file util.c.

304{
305 return FALSE;
306}
#define FALSE
Definition: types.h:117

◆ D3DXGetDriverLevel()

UINT WINAPI D3DXGetDriverLevel ( struct IDirect3DDevice9 *  device)

Definition at line 312 of file util.c.

313{
314 return 900;
315}

◆ 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: precomp.h:53
@ D3DXPC_SCALAR
Definition: d3dx9shader.h:62
@ D3DXPC_MATRIX_COLUMNS
Definition: d3dx9shader.h:65
@ D3DXPC_STRUCT
Definition: d3dx9shader.h:67
@ D3DXPC_MATRIX_ROWS
Definition: d3dx9shader.h:64
@ D3DXPC_VECTOR
Definition: d3dx9shader.h:63
@ D3DXPC_OBJECT
Definition: d3dx9shader.h:66
#define WINE_D3DX_TO_STR(x)
Definition: util.c:235
const GLubyte * c
Definition: glext.h:8905

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}
@ D3DXRS_FLOAT4
Definition: d3dx9shader.h:55
@ D3DXRS_BOOL
Definition: d3dx9shader.h:53
@ D3DXRS_INT4
Definition: d3dx9shader.h:54
@ D3DXRS_SAMPLER
Definition: d3dx9shader.h:56
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

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}
@ D3DXPT_STRING
Definition: d3dx9shader.h:77
@ D3DXPT_TEXTURE
Definition: d3dx9shader.h:78
@ D3DXPT_SAMPLER3D
Definition: d3dx9shader.h:86
@ D3DXPT_UNSUPPORTED
Definition: d3dx9shader.h:92
@ D3DXPT_VERTEXSHADER
Definition: d3dx9shader.h:89
@ D3DXPT_VERTEXFRAGMENT
Definition: d3dx9shader.h:91
@ D3DXPT_TEXTURE1D
Definition: d3dx9shader.h:79
@ D3DXPT_SAMPLERCUBE
Definition: d3dx9shader.h:87
@ D3DXPT_FLOAT
Definition: d3dx9shader.h:76
@ D3DXPT_TEXTURECUBE
Definition: d3dx9shader.h:82
@ D3DXPT_PIXELSHADER
Definition: d3dx9shader.h:88
@ D3DXPT_PIXELFRAGMENT
Definition: d3dx9shader.h:90
@ D3DXPT_BOOL
Definition: d3dx9shader.h:74
@ D3DXPT_INT
Definition: d3dx9shader.h:75
@ D3DXPT_VOID
Definition: d3dx9shader.h:73
@ D3DXPT_SAMPLER
Definition: d3dx9shader.h:83
@ D3DXPT_SAMPLER1D
Definition: d3dx9shader.h:84
@ D3DXPT_SAMPLER2D
Definition: d3dx9shader.h:85
@ D3DXPT_TEXTURE3D
Definition: d3dx9shader.h:81
@ D3DXPT_TEXTURE2D
Definition: d3dx9shader.h:80
GLdouble GLdouble t
Definition: gl.h:2047

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().

◆ 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++;
222 FIXME("Unknown format %#x (as FOURCC %s).\n", format, debugstr_an((const char *)&format, 4));
223 return &formats[i];
224}
@ D3DFMT_UNKNOWN
Definition: d3d8types.h:601
static const struct pixel_format_desc formats[]
Definition: util.c:59
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
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}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41

Referenced by check_texture_requirements().

◆ index_to_rgba()

static void index_to_rgba ( const struct vec4 index,
struct vec4 rgba,
const PALETTEENTRY palette 
)
static

Definition at line 43 of file util.c.

44{
45 ULONG idx = (ULONG)(index->x * 255.0f + 0.5f);
46
47 rgba->x = palette[idx].peRed / 255.0f;
48 rgba->y = palette[idx].peGreen / 255.0f;
49 rgba->z = palette[idx].peBlue / 255.0f;
50 rgba->w = palette[idx].peFlags / 255.0f; /* peFlags is the alpha component in DX8 and higher */
51}
GLuint index
Definition: glext.h:6031
static HPALETTE palette
Definition: clipboard.c:1345
float w
Definition: d3dx9_private.h:38
float z
Definition: d3dx9_private.h:38
float x
Definition: d3dx9_private.h:38
float y
Definition: d3dx9_private.h:38
uint32_t ULONG
Definition: typedefs.h:59

◆ la_from_rgba()

static void la_from_rgba ( const struct vec4 rgba,
struct vec4 la 
)
static

Definition at line 29 of file util.c.

30{
31 la->x = rgba->x * 0.2125f + rgba->y * 0.7154f + rgba->z * 0.0721f;
32 la->w = rgba->w;
33}

◆ la_to_rgba()

static void la_to_rgba ( const struct vec4 la,
struct vec4 rgba,
const PALETTEENTRY palette 
)
static

Definition at line 35 of file util.c.

36{
37 rgba->x = la->x;
38 rgba->y = la->x;
39 rgba->z = la->x;
40 rgba->w = la->w;
41}

◆ 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);
179
181 if(*buffer == NULL) return HRESULT_FROM_WIN32(GetLastError());
182
183 return S_OK;
184}
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define S_OK
Definition: intsafe.h:52
#define resource
Definition: kernel32.h:9
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

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

◆ 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
141error:
142 if (hmapping)
143 CloseHandle(hmapping);
144 if (hfile != INVALID_HANDLE_VALUE)
145 CloseHandle(hfile);
147}
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
const char * filename
Definition: ioapi.h:137
#define error(str)
Definition: mkdosfs.c:1605
#define INVALID_FILE_SIZE
Definition: winbase.h:548

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

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )

◆ write_buffer_to_file()

HRESULT write_buffer_to_file ( const WCHAR dst_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;
195
196 buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
198
199 if (!WriteFile(file, buffer_pointer, buffer_size, &bytes_written, NULL))
201
203 return hr;
204}
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90
HRESULT hr
Definition: shlfolder.c:183
Definition: fci.c:127
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888

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

Variable Documentation

◆ formats