ReactOS  0.4.14-dev-593-g1793dcc
shader.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include "d3dx9_private.h"
#include "d3dcommon.h"
#include "d3dcompiler.h"
Include dependency graph for shader.c:

Go to the source code of this file.

Classes

struct  ID3DXConstantTableImpl
 
struct  instr_info
 
struct  d3dx9_texture_shader
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
HRESULT WINAPI D3DAssemble (const void *data, SIZE_T datasize, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, UINT flags, ID3DBlob **shader, ID3DBlob **error_messages)
 
static BOOL is_valid_bytecode (DWORD token)
 
const char *WINAPI D3DXGetPixelShaderProfile (struct IDirect3DDevice9 *device)
 
UINT WINAPI D3DXGetShaderSize (const DWORD *byte_code)
 
DWORD WINAPI D3DXGetShaderVersion (const DWORD *byte_code)
 
const char *WINAPI D3DXGetVertexShaderProfile (struct IDirect3DDevice9 *device)
 
HRESULT WINAPI D3DXFindShaderComment (const DWORD *byte_code, DWORD fourcc, const void **data, UINT *size)
 
HRESULT WINAPI D3DXAssembleShader (const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
static HRESULT WINAPI d3dx_include_from_file_open (ID3DXInclude *iface, D3DXINCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes)
 
static HRESULT WINAPI d3dx_include_from_file_close (ID3DXInclude *iface, const void *data)
 
HRESULT WINAPI D3DXAssembleShaderFromFileA (const char *filename, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
HRESULT WINAPI D3DXAssembleShaderFromFileW (const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
HRESULT WINAPI D3DXAssembleShaderFromResourceA (HMODULE module, const char *resource, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
HRESULT WINAPI D3DXAssembleShaderFromResourceW (HMODULE module, const WCHAR *resource, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
HRESULT WINAPI D3DXCompileShader (const char *data, UINT length, const D3DXMACRO *defines, ID3DXInclude *include, const char *function, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_msgs, ID3DXConstantTable **constant_table)
 
HRESULT WINAPI D3DXCompileShaderFromFileA (const char *filename, const D3DXMACRO *defines, ID3DXInclude *include, const char *entrypoint, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages, ID3DXConstantTable **constant_table)
 
HRESULT WINAPI D3DXCompileShaderFromFileW (const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, const char *entrypoint, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages, ID3DXConstantTable **constant_table)
 
HRESULT WINAPI D3DXCompileShaderFromResourceA (HMODULE module, const char *resource, const D3DXMACRO *defines, ID3DXInclude *include, const char *entrypoint, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages, ID3DXConstantTable **constant_table)
 
HRESULT WINAPI D3DXCompileShaderFromResourceW (HMODULE module, const WCHAR *resource, const D3DXMACRO *defines, ID3DXInclude *include, const char *entrypoint, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages, ID3DXConstantTable **constant_table)
 
HRESULT WINAPI D3DXPreprocessShader (const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
HRESULT WINAPI D3DXPreprocessShaderFromFileA (const char *filename, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
HRESULT WINAPI D3DXPreprocessShaderFromFileW (const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
HRESULT WINAPI D3DXPreprocessShaderFromResourceA (HMODULE module, const char *resource, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
HRESULT WINAPI D3DXPreprocessShaderFromResourceW (HMODULE module, const WCHAR *resource, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
 
static void free_constant (struct ctab_constant *constant)
 
static void free_constant_table (struct ID3DXConstantTableImpl *table)
 
static struct ID3DXConstantTableImplimpl_from_ID3DXConstantTable (ID3DXConstantTable *iface)
 
static BOOL is_vertex_shader (DWORD version)
 
static D3DXHANDLE handle_from_constant (struct ctab_constant *constant)
 
static struct ctab_constantget_constant_by_name (struct ID3DXConstantTableImpl *table, struct ctab_constant *constant, const char *name)
 
static struct ctab_constantget_constant_element_by_name (struct ctab_constant *constant, const char *name)
 
static struct ctab_constantis_valid_sub_constant (struct ctab_constant *parent, D3DXHANDLE handle)
 
static struct ctab_constantget_valid_constant (struct ID3DXConstantTableImpl *table, D3DXHANDLE handle)
 
static HRESULT WINAPI ID3DXConstantTableImpl_QueryInterface (ID3DXConstantTable *iface, REFIID riid, void **out)
 
static ULONG WINAPI ID3DXConstantTableImpl_AddRef (ID3DXConstantTable *iface)
 
static ULONG WINAPI ID3DXConstantTableImpl_Release (ID3DXConstantTable *iface)
 
static void *WINAPI ID3DXConstantTableImpl_GetBufferPointer (ID3DXConstantTable *iface)
 
static DWORD WINAPI ID3DXConstantTableImpl_GetBufferSize (ID3DXConstantTable *iface)
 
static HRESULT WINAPI ID3DXConstantTableImpl_GetDesc (ID3DXConstantTable *iface, D3DXCONSTANTTABLE_DESC *desc)
 
const struct ctab_constantd3dx_shader_get_ctab_constant (ID3DXConstantTable *iface, D3DXHANDLE constant)
 
static HRESULT WINAPI ID3DXConstantTableImpl_GetConstantDesc (ID3DXConstantTable *iface, D3DXHANDLE constant, D3DXCONSTANT_DESC *desc, UINT *count)
 
static UINT WINAPI ID3DXConstantTableImpl_GetSamplerIndex (ID3DXConstantTable *iface, D3DXHANDLE constant)
 
static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstant (ID3DXConstantTable *iface, D3DXHANDLE constant, UINT index)
 
static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantByName (ID3DXConstantTable *iface, D3DXHANDLE constant, const char *name)
 
static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantElement (ID3DXConstantTable *iface, D3DXHANDLE constant, UINT index)
 
static DWORD get_index (const void **indata, UINT index, BOOL is_pointer)
 
static UINT set (struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, struct ctab_constant *constant, const void **indata, D3DXPARAMETER_TYPE intype, UINT *size, UINT incol, D3DXPARAMETER_CLASS inclass, UINT index, BOOL is_pointer)
 
static HRESULT set_scalar (struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, D3DXPARAMETER_TYPE intype)
 
static HRESULT set_scalar_array (struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, UINT count, D3DXPARAMETER_TYPE intype)
 
static HRESULT set_vector (struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, D3DXPARAMETER_TYPE intype)
 
static HRESULT set_vector_array (struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, UINT count, D3DXPARAMETER_TYPE intype)
 
static HRESULT set_matrix_array (struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, UINT count, BOOL transpose)
 
static HRESULT set_matrix_pointer_array (struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void **indata, UINT count, BOOL transpose)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetDefaults (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetValue (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const void *data, unsigned int bytes)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetBool (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, BOOL b)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetBoolArray (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const BOOL *b, UINT count)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetInt (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, INT n)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetIntArray (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const INT *n, UINT count)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetFloat (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, float f)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetFloatArray (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const float *f, UINT count)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetVector (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const D3DXVECTOR4 *vector)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetVectorArray (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const D3DXVECTOR4 *vector, UINT count)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrix (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const D3DXMATRIX *matrix)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixArray (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const D3DXMATRIX *matrix, UINT count)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixPointerArray (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const D3DXMATRIX **matrix, UINT count)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTranspose (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const D3DXMATRIX *matrix)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTransposeArray (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const D3DXMATRIX *matrix, UINT count)
 
static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTransposePointerArray (struct ID3DXConstantTable *iface, struct IDirect3DDevice9 *device, D3DXHANDLE constant, const D3DXMATRIX **matrix, UINT count)
 
static HRESULT parse_ctab_constant_type (const char *ctab, DWORD typeoffset, struct ctab_constant *constant, BOOL is_element, WORD index, WORD max_index, DWORD *offset, DWORD nameoffset, UINT regset)
 
HRESULT WINAPI D3DXGetShaderConstantTableEx (const DWORD *byte_code, DWORD flags, ID3DXConstantTable **constant_table)
 
HRESULT WINAPI D3DXGetShaderConstantTable (const DWORD *byte_code, ID3DXConstantTable **constant_table)
 
HRESULT WINAPI D3DXCreateFragmentLinker (IDirect3DDevice9 *device, UINT size, ID3DXFragmentLinker **linker)
 
HRESULT WINAPI D3DXCreateFragmentLinkerEx (IDirect3DDevice9 *device, UINT size, DWORD flags, ID3DXFragmentLinker **linker)
 
HRESULT WINAPI D3DXGetShaderSamplers (const DWORD *byte_code, const char **samplers, UINT *count)
 
static int add_modifier (char *buffer, DWORD param)
 
static int add_register (char *buffer, DWORD param, BOOL dst, BOOL ps)
 
static int instr_comment (const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps)
 
static int instr_def (const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps)
 
static int instr_dcl (const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps)
 
static int instr_generic (const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps)
 
HRESULT WINAPI D3DXDisassembleShader (const DWORD *shader, BOOL colorcode, const char *comments, ID3DXBuffer **disassembly)
 
static struct d3dx9_texture_shaderimpl_from_ID3DXTextureShader (ID3DXTextureShader *iface)
 
static HRESULT WINAPI d3dx9_texture_shader_QueryInterface (ID3DXTextureShader *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3dx9_texture_shader_AddRef (ID3DXTextureShader *iface)
 
static ULONG WINAPI d3dx9_texture_shader_Release (ID3DXTextureShader *iface)
 
static HRESULT WINAPI d3dx9_texture_shader_GetFunction (ID3DXTextureShader *iface, struct ID3DXBuffer **function)
 
static HRESULT WINAPI d3dx9_texture_shader_GetConstantBuffer (ID3DXTextureShader *iface, struct ID3DXBuffer **constant_buffer)
 
static HRESULT WINAPI d3dx9_texture_shader_GetDesc (ID3DXTextureShader *iface, D3DXCONSTANTTABLE_DESC *desc)
 
static HRESULT WINAPI d3dx9_texture_shader_GetConstantDesc (ID3DXTextureShader *iface, D3DXHANDLE constant, D3DXCONSTANT_DESC *constant_desc, UINT *count)
 
static D3DXHANDLE WINAPI d3dx9_texture_shader_GetConstant (ID3DXTextureShader *iface, D3DXHANDLE constant, UINT index)
 
static D3DXHANDLE WINAPI d3dx9_texture_shader_GetConstantByName (ID3DXTextureShader *iface, D3DXHANDLE constant, const char *name)
 
static D3DXHANDLE WINAPI d3dx9_texture_shader_GetConstantElement (ID3DXTextureShader *iface, D3DXHANDLE constant, UINT index)
 
static HRESULT WINAPI d3dx9_texture_shader_SetDefaults (ID3DXTextureShader *iface)
 
static HRESULT WINAPI d3dx9_texture_shader_SetValue (ID3DXTextureShader *iface, D3DXHANDLE constant, const void *data, UINT bytes)
 
static HRESULT WINAPI d3dx9_texture_shader_SetBool (ID3DXTextureShader *iface, D3DXHANDLE constant, BOOL b)
 
static HRESULT WINAPI d3dx9_texture_shader_SetBoolArray (ID3DXTextureShader *iface, D3DXHANDLE constant, const BOOL *b, UINT count)
 
static HRESULT WINAPI d3dx9_texture_shader_SetInt (ID3DXTextureShader *iface, D3DXHANDLE constant, INT n)
 
static HRESULT WINAPI d3dx9_texture_shader_SetIntArray (ID3DXTextureShader *iface, D3DXHANDLE constant, const INT *n, UINT count)
 
static HRESULT WINAPI d3dx9_texture_shader_SetFloat (ID3DXTextureShader *iface, D3DXHANDLE constant, FLOAT f)
 
static HRESULT WINAPI d3dx9_texture_shader_SetFloatArray (ID3DXTextureShader *iface, D3DXHANDLE constant, const FLOAT *f, UINT count)
 
static HRESULT WINAPI d3dx9_texture_shader_SetVector (ID3DXTextureShader *iface, D3DXHANDLE constant, const D3DXVECTOR4 *vector)
 
static HRESULT WINAPI d3dx9_texture_shader_SetVectorArray (ID3DXTextureShader *iface, D3DXHANDLE constant, const D3DXVECTOR4 *vector, UINT count)
 
static HRESULT WINAPI d3dx9_texture_shader_SetMatrix (ID3DXTextureShader *iface, D3DXHANDLE constant, const D3DXMATRIX *matrix)
 
static HRESULT WINAPI d3dx9_texture_shader_SetMatrixArray (ID3DXTextureShader *iface, D3DXHANDLE constant, const D3DXMATRIX *matrix, UINT count)
 
static HRESULT WINAPI d3dx9_texture_shader_SetMatrixPointerArray (ID3DXTextureShader *iface, D3DXHANDLE constant, const D3DXMATRIX **matrix, UINT count)
 
static HRESULT WINAPI d3dx9_texture_shader_SetMatrixTranspose (ID3DXTextureShader *iface, D3DXHANDLE constant, const D3DXMATRIX *matrix)
 
static HRESULT WINAPI d3dx9_texture_shader_SetMatrixTransposeArray (ID3DXTextureShader *iface, D3DXHANDLE constant, const D3DXMATRIX *matrix, UINT count)
 
static HRESULT WINAPI d3dx9_texture_shader_SetMatrixTransposePointerArray (ID3DXTextureShader *iface, D3DXHANDLE constant, const D3DXMATRIX **matrix, UINT count)
 
HRESULT WINAPI D3DXCreateTextureShader (const DWORD *function, ID3DXTextureShader **texture_shader)
 
static unsigned int get_instr_length (const DWORD *byte_code, unsigned int major, unsigned int minor)
 
static HRESULT get_shader_semantics (const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count, BOOL output)
 
HRESULT WINAPI D3DXGetShaderInputSemantics (const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count)
 
HRESULT WINAPI D3DXGetShaderOutputSemantics (const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count)
 

Variables

static const voidmain_file_data
 
static CRITICAL_SECTION_DEBUG from_file_mutex_debug
 
CRITICAL_SECTION from_file_mutex = {&from_file_mutex_debug, -1, 0, 0, 0, 0}
 
const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl
 
static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl
 
static const chardecl_usage []
 
static const chartex_type [] = { "", "1d", "2d", "cube", "volume" }
 
const struct instr_info instructions []
 
static const struct ID3DXTextureShaderVtbl d3dx9_texture_shader_vtbl
 

Function Documentation

◆ add_modifier()

static int add_modifier ( char buffer,
DWORD  param 
)
static

Definition at line 2186 of file shader.c.

2187 {
2188  char *buf = buffer;
2189  DWORD dst_mod = param & D3DSP_DSTMOD_MASK;
2190 
2191  if (dst_mod & D3DSPDM_SATURATE)
2192  buf += sprintf(buf, "_sat");
2193  if (dst_mod & D3DSPDM_PARTIALPRECISION)
2194  buf += sprintf(buf, "_pp");
2195  if (dst_mod & D3DSPDM_MSAMPCENTROID)
2196  buf += sprintf(buf, "_centroid");
2197 
2198  return buf - buffer;
2199 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint buffer
Definition: glext.h:5915
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define D3DSP_DSTMOD_MASK
Definition: d3d8types.h:381
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by instr_dcl(), and instr_generic().

◆ add_register()

static int add_register ( char buffer,
DWORD  param,
BOOL  dst,
BOOL  ps 
)
static

Definition at line 2201 of file shader.c.

2202 {
2203  char *buf = buffer;
2206  DWORD reg_num = param & D3DSP_REGNUM_MASK;
2207 
2208  if (reg_type == D3DSPR_INPUT)
2209  buf += sprintf(buf, "v%d", reg_num);
2210  else if (reg_type == D3DSPR_CONST)
2211  buf += sprintf(buf, "c%d", reg_num);
2212  else if (reg_type == D3DSPR_TEMP)
2213  buf += sprintf(buf, "r%d", reg_num);
2214  else if (reg_type == D3DSPR_ADDR)
2215  buf += sprintf(buf, "%s%d", ps ? "t" : "a", reg_num);
2216  else if (reg_type == D3DSPR_SAMPLER)
2217  buf += sprintf(buf, "s%d", reg_num);
2218  else if (reg_type == D3DSPR_RASTOUT)
2219  buf += sprintf(buf, "oPos");
2220  else if (reg_type == D3DSPR_COLOROUT)
2221  buf += sprintf(buf, "oC%d", reg_num);
2222  else if (reg_type == D3DSPR_TEXCRDOUT)
2223  buf += sprintf(buf, "oT%d", reg_num);
2224  else if (reg_type == D3DSPR_ATTROUT)
2225  buf += sprintf(buf, "oD%d", reg_num);
2226  else
2227  buf += sprintf(buf, "? (%d)", reg_type);
2228 
2229  if (dst)
2230  {
2232  {
2233  buf += sprintf(buf, ".%s%s%s%s", param & D3DSP_WRITEMASK_0 ? "x" : "",
2234  param & D3DSP_WRITEMASK_1 ? "y" : "",
2235  param & D3DSP_WRITEMASK_2 ? "z" : "",
2236  param & D3DSP_WRITEMASK_3 ? "w" : "");
2237  }
2238  }
2239  else
2240  {
2242  {
2247  buf += sprintf(buf, ".%c", 'w' + (((param >> D3DVS_SWIZZLE_SHIFT) + 1) & 0x3));
2248  else
2249  buf += sprintf(buf, ".%c%c%c%c", 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+0)) + 1) & 0x3),
2250  'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+2)) + 1) & 0x3),
2251  'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+4)) + 1) & 0x3),
2252  'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+6)) + 1) & 0x3));
2253  }
2254  }
2255 
2256  return buf - buffer;
2257 }
#define D3DSP_REGTYPE_MASK2
Definition: d3d9types.h:508
#define D3DVS_Z_Y
Definition: d3d8types.h:442
#define D3DVS_NOSWIZZLE
Definition: d3d8types.h:451
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define D3DVS_X_Y
Definition: d3d8types.h:432
#define D3DVS_Y_Z
Definition: d3d8types.h:438
GLuint buffer
Definition: glext.h:5915
#define D3DVS_Y_X
Definition: d3d8types.h:436
#define D3DSP_WRITEMASK_ALL
Definition: d3d8types.h:378
#define D3DVS_Z_W
Definition: d3d8types.h:444
#define D3DSP_REGTYPE_SHIFT
Definition: d3d8types.h:394
#define D3DVS_W_Z
Definition: d3d8types.h:448
#define D3DSP_WRITEMASK_2
Definition: d3d8types.h:376
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define D3DVS_Y_W
Definition: d3d8types.h:439
#define D3DVS_SWIZZLE_MASK
Definition: d3d8types.h:426
#define D3DVS_W_W
Definition: d3d8types.h:449
#define D3DVS_X_Z
Definition: d3d8types.h:433
#define D3DVS_W_Y
Definition: d3d8types.h:447
#define D3DVS_Z_Z
Definition: d3d8types.h:443
#define D3DSP_WRITEMASK_0
Definition: d3d8types.h:374
#define D3DVS_Y_Y
Definition: d3d8types.h:437
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3DVS_Z_X
Definition: d3d8types.h:441
#define D3DSP_WRITEMASK_3
Definition: d3d8types.h:377
#define D3DSP_SWIZZLE_MASK
Definition: d3d8types.h:429
#define D3DSP_REGNUM_MASK
Definition: d3d9types.h:479
#define D3DVS_W_X
Definition: d3d8types.h:446
GLenum GLenum dst
Definition: glext.h:6340
#define D3DVS_X_X
Definition: d3d8types.h:431
#define D3DVS_SWIZZLE_SHIFT
Definition: d3d8types.h:425
#define D3DSP_WRITEMASK_1
Definition: d3d8types.h:375
#define D3DSP_REGTYPE_SHIFT2
Definition: d3d9types.h:506
#define D3DVS_X_W
Definition: d3d8types.h:434
type_t * reg_type(type_t *type, const char *name, struct namespace *namespace, int t)
Definition: parser.tab.c:5992
#define D3DSP_REGTYPE_MASK
Definition: d3d8types.h:395

Referenced by instr_dcl(), and instr_generic().

◆ D3DAssemble()

HRESULT WINAPI D3DAssemble ( const void data,
SIZE_T  datasize,
const char filename,
const D3D_SHADER_MACRO defines,
ID3DInclude include,
UINT  flags,
ID3DBlob **  shader,
ID3DBlob **  error_messages 
)

Definition at line 630 of file compiler.c.

633 {
634  HRESULT hr;
635 
636  TRACE("data %p, datasize %lu, filename %s, defines %p, include %p, sflags %#x, "
637  "shader %p, error_messages %p.\n",
639 
641 
642  /* TODO: flags */
643  if (flags) FIXME("flags %x\n", flags);
644 
645  if (shader) *shader = NULL;
647 
649  if (SUCCEEDED(hr))
651 
654  return hr;
655 }
static char * wpp_output
Definition: compiler.c:57
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
static SIZE_T datasize
Definition: asm.c:30
HRESULT hr
Definition: shlfolder.c:183
static CRITICAL_SECTION wpp_mutex
Definition: compiler.c:75
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
const char * filename
Definition: ioapi.h:135
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
static HRESULT assemble_shader(const char *preproc_shader, ID3DBlob **shader_blob, ID3DBlob **error_messages)
Definition: compiler.c:553
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **error_messages)
Definition: compiler.c:484
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:402
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by D3DXAssembleShader().

◆ d3dx9_texture_shader_AddRef()

static ULONG WINAPI d3dx9_texture_shader_AddRef ( ID3DXTextureShader *  iface)
static

Definition at line 2538 of file shader.c.

2539 {
2540  struct d3dx9_texture_shader *texture_shader = impl_from_ID3DXTextureShader(iface);
2541  ULONG refcount = InterlockedIncrement(&texture_shader->ref);
2542 
2543  TRACE("%p increasing refcount to %u.\n", texture_shader, refcount);
2544 
2545  return refcount;
2546 }
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
static struct d3dx9_texture_shader * impl_from_ID3DXTextureShader(ID3DXTextureShader *iface)
Definition: shader.c:2516
unsigned int ULONG
Definition: retypes.h:1

◆ d3dx9_texture_shader_GetConstant()

static D3DXHANDLE WINAPI d3dx9_texture_shader_GetConstant ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
UINT  index 
)
static

Definition at line 2591 of file shader.c.

2592 {
2593  FIXME("iface %p, constant %p, index %u stub.\n", iface, constant, index);
2594 
2595  return NULL;
2596 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031

◆ d3dx9_texture_shader_GetConstantBuffer()

static HRESULT WINAPI d3dx9_texture_shader_GetConstantBuffer ( ID3DXTextureShader *  iface,
struct ID3DXBuffer **  constant_buffer 
)
static

Definition at line 2570 of file shader.c.

2571 {
2572  FIXME("iface %p, constant_buffer %p stub.\n", iface, constant_buffer);
2573 
2574  return E_NOTIMPL;
2575 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_GetConstantByName()

static D3DXHANDLE WINAPI d3dx9_texture_shader_GetConstantByName ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const char name 
)
static

Definition at line 2598 of file shader.c.

2599 {
2600  FIXME("iface %p, constant %p, name %s stub.\n", iface, constant, debugstr_a(name));
2601 
2602  return NULL;
2603 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_a
Definition: kernel32.h:31
Definition: name.c:38

◆ d3dx9_texture_shader_GetConstantDesc()

static HRESULT WINAPI d3dx9_texture_shader_GetConstantDesc ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
D3DXCONSTANT_DESC constant_desc,
UINT count 
)
static

Definition at line 2584 of file shader.c.

2585 {
2586  FIXME("iface %p, constant %p, constant_desc %p, count %p stub.\n", iface, constant, constant_desc, count);
2587 
2588  return E_NOTIMPL;
2589 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_GetConstantElement()

static D3DXHANDLE WINAPI d3dx9_texture_shader_GetConstantElement ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
UINT  index 
)
static

Definition at line 2605 of file shader.c.

2606 {
2607  FIXME("iface %p, constant %p, index %u stub.\n", iface, constant, index);
2608 
2609  return NULL;
2610 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031

◆ d3dx9_texture_shader_GetDesc()

static HRESULT WINAPI d3dx9_texture_shader_GetDesc ( ID3DXTextureShader *  iface,
D3DXCONSTANTTABLE_DESC desc 
)
static

Definition at line 2577 of file shader.c.

2578 {
2579  FIXME("iface %p, desc %p stub.\n", iface, desc);
2580 
2581  return E_NOTIMPL;
2582 }
static const WCHAR desc[]
Definition: protectdata.c:36
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_GetFunction()

static HRESULT WINAPI d3dx9_texture_shader_GetFunction ( ID3DXTextureShader *  iface,
struct ID3DXBuffer **  function 
)
static

Definition at line 2563 of file shader.c.

2564 {
2565  FIXME("iface %p, function %p stub.\n", iface, function);
2566 
2567  return E_NOTIMPL;
2568 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_QueryInterface()

static HRESULT WINAPI d3dx9_texture_shader_QueryInterface ( ID3DXTextureShader *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 2521 of file shader.c.

2522 {
2523  TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2524 
2525  if (IsEqualGUID(riid, &IID_IUnknown) ||
2526  IsEqualGUID(riid, &IID_ID3DXTextureShader))
2527  {
2528  iface->lpVtbl->AddRef(iface);
2529  *out = iface;
2530  return D3D_OK;
2531  }
2532 
2533  WARN("Interface %s not found.\n", debugstr_guid(riid));
2534  *out = NULL;
2535  return E_NOINTERFACE;
2536 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
static FILE * out
Definition: regtests2xml.c:44
#define D3D_OK
Definition: d3d.h:106
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ d3dx9_texture_shader_Release()

static ULONG WINAPI d3dx9_texture_shader_Release ( ID3DXTextureShader *  iface)
static

Definition at line 2548 of file shader.c.

2549 {
2550  struct d3dx9_texture_shader *texture_shader = impl_from_ID3DXTextureShader(iface);
2551  ULONG refcount = InterlockedDecrement(&texture_shader->ref);
2552 
2553  TRACE("%p decreasing refcount to %u.\n", texture_shader, refcount);
2554 
2555  if (!refcount)
2556  {
2557  HeapFree(GetProcessHeap(), 0, texture_shader);
2558  }
2559 
2560  return refcount;
2561 }
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define InterlockedDecrement
Definition: armddk.h:52
static struct d3dx9_texture_shader * impl_from_ID3DXTextureShader(ID3DXTextureShader *iface)
Definition: shader.c:2516
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ d3dx9_texture_shader_SetBool()

static HRESULT WINAPI d3dx9_texture_shader_SetBool ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
BOOL  b 
)
static

Definition at line 2626 of file shader.c.

2627 {
2628  FIXME("iface %p, constant %p, b %u stub.\n", iface, constant, b);
2629 
2630  return E_NOTIMPL;
2631 }
#define FIXME(fmt,...)
Definition: debug.h:110
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetBoolArray()

static HRESULT WINAPI d3dx9_texture_shader_SetBoolArray ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const BOOL b,
UINT  count 
)
static

Definition at line 2633 of file shader.c.

2634 {
2635  FIXME("iface %p, constant %p, b %p, count %u stub.\n", iface, constant, b, count);
2636 
2637  return E_NOTIMPL;
2638 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetDefaults()

static HRESULT WINAPI d3dx9_texture_shader_SetDefaults ( ID3DXTextureShader *  iface)
static

Definition at line 2612 of file shader.c.

2613 {
2614  FIXME("iface %p stub.\n", iface);
2615 
2616  return E_NOTIMPL;
2617 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetFloat()

static HRESULT WINAPI d3dx9_texture_shader_SetFloat ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
FLOAT  f 
)
static

Definition at line 2654 of file shader.c.

2655 {
2656  FIXME("iface %p, constant %p, f %f stub.\n", iface, constant, f);
2657 
2658  return E_NOTIMPL;
2659 }
#define FIXME(fmt,...)
Definition: debug.h:110
GLfloat f
Definition: glext.h:7540
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetFloatArray()

static HRESULT WINAPI d3dx9_texture_shader_SetFloatArray ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const FLOAT f,
UINT  count 
)
static

Definition at line 2661 of file shader.c.

2662 {
2663  FIXME("iface %p, constant %p, f %p, count %u stub.\n", iface, constant, f, count);
2664 
2665  return E_NOTIMPL;
2666 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
GLfloat f
Definition: glext.h:7540
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetInt()

static HRESULT WINAPI d3dx9_texture_shader_SetInt ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
INT  n 
)
static

Definition at line 2640 of file shader.c.

2641 {
2642  FIXME("iface %p, constant %p, n %d stub.\n", iface, constant, n);
2643 
2644  return E_NOTIMPL;
2645 }
GLdouble n
Definition: glext.h:7729
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetIntArray()

static HRESULT WINAPI d3dx9_texture_shader_SetIntArray ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const INT n,
UINT  count 
)
static

Definition at line 2647 of file shader.c.

2648 {
2649  FIXME("iface %p, constant %p, n %p, count %u stub.\n", iface, constant, n, count);
2650 
2651  return E_NOTIMPL;
2652 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetMatrix()

static HRESULT WINAPI d3dx9_texture_shader_SetMatrix ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const D3DXMATRIX matrix 
)
static

Definition at line 2682 of file shader.c.

2683 {
2684  FIXME("iface %p, constant %p, matrix %p stub.\n", iface, constant, matrix);
2685 
2686  return E_NOTIMPL;
2687 }
GLuint GLenum matrix
Definition: glext.h:9407
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetMatrixArray()

static HRESULT WINAPI d3dx9_texture_shader_SetMatrixArray ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const D3DXMATRIX matrix,
UINT  count 
)
static

Definition at line 2689 of file shader.c.

2690 {
2691  FIXME("iface %p, constant %p, matrix %p, count %u stub.\n", iface, constant, matrix, count);
2692 
2693  return E_NOTIMPL;
2694 }
GLuint GLenum matrix
Definition: glext.h:9407
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetMatrixPointerArray()

static HRESULT WINAPI d3dx9_texture_shader_SetMatrixPointerArray ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const D3DXMATRIX **  matrix,
UINT  count 
)
static

Definition at line 2696 of file shader.c.

2697 {
2698  FIXME("iface %p, constant %p, matrix %p, count %u stub.\n", iface, constant, matrix, count);
2699 
2700  return E_NOTIMPL;
2701 }
GLuint GLenum matrix
Definition: glext.h:9407
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetMatrixTranspose()

static HRESULT WINAPI d3dx9_texture_shader_SetMatrixTranspose ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const D3DXMATRIX matrix 
)
static

Definition at line 2703 of file shader.c.

2704 {
2705  FIXME("iface %p, constant %p, matrix %p stub.\n", iface, constant, matrix);
2706 
2707  return E_NOTIMPL;
2708 }
GLuint GLenum matrix
Definition: glext.h:9407
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetMatrixTransposeArray()

static HRESULT WINAPI d3dx9_texture_shader_SetMatrixTransposeArray ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const D3DXMATRIX matrix,
UINT  count 
)
static

Definition at line 2710 of file shader.c.

2711 {
2712  FIXME("iface %p, constant %p, matrix %p, count %u stub.\n", iface, constant, matrix, count);
2713 
2714  return E_NOTIMPL;
2715 }
GLuint GLenum matrix
Definition: glext.h:9407
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetMatrixTransposePointerArray()

static HRESULT WINAPI d3dx9_texture_shader_SetMatrixTransposePointerArray ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const D3DXMATRIX **  matrix,
UINT  count 
)
static

Definition at line 2717 of file shader.c.

2718 {
2719  FIXME("iface %p, constant %p, matrix %p, count %u stub.\n", iface, constant, matrix, count);
2720 
2721  return E_NOTIMPL;
2722 }
GLuint GLenum matrix
Definition: glext.h:9407
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetValue()

static HRESULT WINAPI d3dx9_texture_shader_SetValue ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const void data,
UINT  bytes 
)
static

Definition at line 2619 of file shader.c.

2620 {
2621  FIXME("iface %p, constant %p, data %p, bytes %u stub.\n", iface, constant, data, bytes);
2622 
2623  return E_NOTIMPL;
2624 }
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define FIXME(fmt,...)
Definition: debug.h:110
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetVector()

static HRESULT WINAPI d3dx9_texture_shader_SetVector ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const D3DXVECTOR4 vector 
)
static

Definition at line 2668 of file shader.c.

2669 {
2670  FIXME("iface %p, constant %p, vector %p stub.\n", iface, constant, vector);
2671 
2672  return E_NOTIMPL;
2673 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_texture_shader_SetVectorArray()

static HRESULT WINAPI d3dx9_texture_shader_SetVectorArray ( ID3DXTextureShader *  iface,
D3DXHANDLE  constant,
const D3DXVECTOR4 vector,
UINT  count 
)
static

Definition at line 2675 of file shader.c.

2676 {
2677  FIXME("iface %p, constant %p, vector %p, count %u stub.\n", iface, constant, vector, count);
2678 
2679  return E_NOTIMPL;
2680 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx_include_from_file_close()

static HRESULT WINAPI d3dx_include_from_file_close ( ID3DXInclude *  iface,
const void data 
)
static

Definition at line 305 of file shader.c.

306 {
307  HeapFree(GetProcessHeap(), 0, *((char **)data - 1));
308  HeapFree(GetProcessHeap(), 0, (char **)data - 1);
309  if (main_file_data == data)
311  return S_OK;
312 }
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
static const void * main_file_data
Definition: shader.c:217
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ d3dx_include_from_file_open()

static HRESULT WINAPI d3dx_include_from_file_open ( ID3DXInclude *  iface,
D3DXINCLUDE_TYPE  include_type,
const char filename,
const void parent_data,
const void **  data,
UINT bytes 
)
static

Definition at line 235 of file shader.c.

237 {
238  const char *p, *parent_name = "";
239  char *pathname = NULL, *ptr;
240  char **buffer = NULL;
241  HANDLE file;
242  UINT size;
243 
244  if (parent_data)
245  {
246  parent_name = *((const char **)parent_data - 1);
247  }
248  else
249  {
250  if (main_file_data)
251  parent_name = *((const char **)main_file_data - 1);
252  }
253 
254  TRACE("Looking up include file %s, parent %s.\n", debugstr_a(filename), debugstr_a(parent_name));
255 
256  if ((p = strrchr(parent_name, '\\')))
257  ++p;
258  else
259  p = parent_name;
260  pathname = HeapAlloc(GetProcessHeap(), 0, (p - parent_name) + strlen(filename) + 1);
261  if(!pathname)
263 
264  memcpy(pathname, parent_name, p - parent_name);
265  strcpy(pathname + (p - parent_name), filename);
266  ptr = pathname + (p - parent_name);
267  while (*ptr)
268  {
269  if (*ptr == '/')
270  *ptr = '\\';
271  ++ptr;
272  }
273 
276  goto error;
277 
278  TRACE("Include file found at pathname = %s\n", debugstr_a(pathname));
279 
281  if(size == INVALID_FILE_SIZE)
282  goto error;
283 
284  buffer = HeapAlloc(GetProcessHeap(), 0, size + sizeof(char *));
285  if(!buffer)
286  goto error;
287  *buffer = pathname;
288  if(!ReadFile(file, buffer + 1, size, bytes, NULL))
289  goto error;
290 
291  *data = buffer + 1;
292  if (!main_file_data)
293  main_file_data = *data;
294 
295  CloseHandle(file);
296  return S_OK;
297 
298 error:
299  CloseHandle(file);
303 }
#define CloseHandle
Definition: compat.h:406
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define error(str)
Definition: mkdosfs.c:1605
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char pathname[512]
Definition: util.h:13
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define INVALID_FILE_SIZE
Definition: winbase.h:529
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:125
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define debugstr_a
Definition: kernel32.h:31
const char file[]
Definition: icontest.c:11
static const void * main_file_data
Definition: shader.c:217
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GENERIC_READ
Definition: compat.h:124
#define S_OK
Definition: intsafe.h:59
unsigned int UINT
Definition: ndis.h:50
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
GLfloat GLfloat p
Definition: glext.h:8902
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:402
Definition: fci.c:126

◆ d3dx_shader_get_ctab_constant()

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

Definition at line 977 of file shader.c.

978 {
980 
982 }
static struct ctab_constant * get_valid_constant(struct ID3DXConstantTableImpl *table, D3DXHANDLE handle)
Definition: shader.c:880
static struct ID3DXConstantTableImpl * impl_from_ID3DXConstantTable(ID3DXConstantTable *iface)
Definition: shader.c:755

Referenced by get_ctab_constant_desc().

◆ D3DXAssembleShader()

HRESULT WINAPI D3DXAssembleShader ( const char data,
UINT  data_len,
const D3DXMACRO defines,
ID3DXInclude *  include,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 199 of file shader.c.

201 {
202  HRESULT hr;
203 
204  TRACE("data %p, data_len %u, defines %p, include %p, flags %#x, shader %p, error_messages %p\n",
205  data, data_len, defines, include, flags, shader, error_messages);
206 
207  /* Forward to d3dcompiler: the parameter types aren't really different,
208  the actual data types are equivalent */
209  hr = D3DAssemble(data, data_len, NULL, (D3D_SHADER_MACRO *)defines,
212 
213  if(hr == E_FAIL) hr = D3DXERR_INVALIDDATA;
214  return hr;
215 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
HRESULT hr
Definition: shlfolder.c:183
#define E_FAIL
Definition: ddrawi.h:102
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, UINT flags, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:630
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30

Referenced by D3DXAssembleShaderFromFileW(), D3DXAssembleShaderFromResourceA(), and D3DXAssembleShaderFromResourceW().

◆ D3DXAssembleShaderFromFileA()

HRESULT WINAPI D3DXAssembleShaderFromFileA ( const char filename,
const D3DXMACRO defines,
ID3DXInclude *  include,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 320 of file shader.c.

322 {
323  WCHAR *filename_w;
324  DWORD len;
325  HRESULT ret;
326 
327  TRACE("filename %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
329 
330  if (!filename) return D3DXERR_INVALIDDATA;
331 
332  len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
333  filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
334  if (!filename_w) return E_OUTOFMEMORY;
335  MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
336 
338 
339  HeapFree(GetProcessHeap(), 0, filename_w);
340  return ret;
341 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
#define CP_ACP
Definition: compat.h:99
const char * filename
Definition: ioapi.h:135
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
HRESULT WINAPI D3DXAssembleShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:343
#define MultiByteToWideChar
Definition: compat.h:100
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ D3DXAssembleShaderFromFileW()

HRESULT WINAPI D3DXAssembleShaderFromFileW ( const WCHAR filename,
const D3DXMACRO defines,
ID3DXInclude *  include,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 343 of file shader.c.

345 {
346  const void *buffer;
347  DWORD len;
348  HRESULT hr;
349  struct d3dx_include_from_file include_from_file;
350  char *filename_a;
351 
352  TRACE("filename %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
354 
355  if(!include)
356  {
357  include_from_file.ID3DXInclude_iface.lpVtbl = &d3dx_include_from_file_vtbl;
358  include = &include_from_file.ID3DXInclude_iface;
359  }
360 
362  filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
363  if (!filename_a)
364  return E_OUTOFMEMORY;
365  WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
366 
368  hr = ID3DXInclude_Open(include, D3DXINC_LOCAL, filename_a, NULL, &buffer, &len);
369  if (FAILED(hr))
370  {
372  HeapFree(GetProcessHeap(), 0, filename_a);
373  return D3DXERR_INVALIDDATA;
374  }
375 
377 
380  HeapFree(GetProcessHeap(), 0, filename_a);
381  return hr;
382 }
#define ID3DXInclude_Open(p, a, b, c, d, e)
Definition: d3dx9shader.h:303
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl
Definition: shader.c:314
GLuint buffer
Definition: glext.h:5915
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
const char * filename
Definition: ioapi.h:135
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define ID3DXInclude_Close(p, a)
Definition: d3dx9shader.h:304
HRESULT WINAPI D3DXAssembleShader(const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:199
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
CRITICAL_SECTION from_file_mutex
Definition: shader.c:228
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by D3DXAssembleShaderFromFileA().

◆ D3DXAssembleShaderFromResourceA()

HRESULT WINAPI D3DXAssembleShaderFromResourceA ( HMODULE  module,
const char resource,
const D3DXMACRO defines,
ID3DXInclude *  include,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 384 of file shader.c.

386 {
387  void *buffer;
388  HRSRC res;
389  DWORD len;
390 
391  TRACE("module %p, resource %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
393 
394  if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
395  return D3DXERR_INVALIDDATA;
397  return D3DXERR_INVALIDDATA;
400 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
GLuint buffer
Definition: glext.h:5915
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:166
HRESULT WINAPI D3DXAssembleShader(const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:199
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define RT_RCDATA
Definition: pedump.c:372
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
GLuint res
Definition: glext.h:9613

◆ D3DXAssembleShaderFromResourceW()

HRESULT WINAPI D3DXAssembleShaderFromResourceW ( HMODULE  module,
const WCHAR resource,
const D3DXMACRO defines,
ID3DXInclude *  include,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 402 of file shader.c.

404 {
405  void *buffer;
406  HRSRC res;
407  DWORD len;
408 
409  TRACE("module %p, resource %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
411 
412  if (!(res = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
413  return D3DXERR_INVALIDDATA;
415  return D3DXERR_INVALIDDATA;
418 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
GLuint buffer
Definition: glext.h:5915
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define debugstr_w
Definition: kernel32.h:32
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:166
HRESULT WINAPI D3DXAssembleShader(const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:199
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define RT_RCDATA
Definition: pedump.c:372
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
GLuint res
Definition: glext.h:9613

◆ D3DXCompileShader()

HRESULT WINAPI D3DXCompileShader ( const char data,
UINT  length,
const D3DXMACRO defines,
ID3DXInclude *  include,
const char function,
const char profile,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_msgs,
ID3DXConstantTable **  constant_table 
)

Definition at line 420 of file shader.c.

423 {
424  HRESULT hr;
425 
426  TRACE("data %s, length %u, defines %p, include %p, function %s, profile %s, "
427  "flags %#x, shader %p, error_msgs %p, constant_table %p.\n",
429  flags, shader, error_msgs, constant_table);
430 
432  function, profile, flags, 0, (ID3DBlob **)shader, (ID3DBlob **)error_msgs);
433 
434  if (SUCCEEDED(hr) && constant_table)
435  {
437  if (FAILED(hr))
438  {
440  *shader = NULL;
441  }
442  }
443 
444  /* Filter out D3DCompile warning messages that are not present with D3DCompileShader */
445  if (SUCCEEDED(hr) && error_msgs && *error_msgs)
446  {
447  char *messages = ID3DXBuffer_GetBufferPointer(*error_msgs);
448  DWORD size = ID3DXBuffer_GetBufferSize(*error_msgs);
449 
450  /* Ensure messages are null terminated for safe processing */
451  if (size) messages[size - 1] = 0;
452 
453  while (size > 1)
454  {
455  char *prev, *next;
456 
457  /* Warning has the form "warning X3206: ... implicit truncation of vector type"
458  but we only search for "X3206:" in case d3dcompiler_43 has localization */
459  prev = next = strstr(messages, "X3206:");
460  if (!prev) break;
461 
462  /* get pointer to beginning and end of current line */
463  while (prev > messages && *(prev - 1) != '\n') prev--;
464  while (next < messages + size - 1 && *next != '\n') next++;
465  if (next < messages + size - 1 && *next == '\n') next++;
466 
467  memmove(prev, next, messages + size - next);
468  size -= (next - prev);
469  }
470 
471  /* Only return a buffer if the resulting string is not empty as some apps depend on that */
472  if (size <= 1)
473  {
474  ID3DXBuffer_Release(*error_msgs);
475  *error_msgs = NULL;
476  }
477  }
478 
479  return hr;
480 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
HRESULT hr
Definition: shlfolder.c:183
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:889
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT WINAPI D3DXGetShaderConstantTable(const DWORD *byte_code, ID3DXConstantTable **constant_table)
Definition: shader.c:2104
GLbitfield flags
Definition: glext.h:7161
static unsigned __int64 next
Definition: rand_nt.c:6
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
#define profile
Definition: kernel32.h:12
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by D3DXCompileShaderFromResourceA(), and D3DXCompileShaderFromResourceW().

◆ D3DXCompileShaderFromFileA()

HRESULT WINAPI D3DXCompileShaderFromFileA ( const char filename,
const D3DXMACRO defines,
ID3DXInclude *  include,
const char entrypoint,
const char profile,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages,
ID3DXConstantTable **  constant_table 
)

Definition at line 482 of file shader.c.

485 {
486  WCHAR *filename_w;
487  DWORD len;
488  HRESULT ret;
489 
490  TRACE("filename %s, defines %p, include %p, entrypoint %s, profile %s, "
491  "flags %#x, shader %p, error_messages %p, constant_table %p.\n",
492  debugstr_a(filename), defines, include, debugstr_a(entrypoint),
493  debugstr_a(profile), flags, shader, error_messages, constant_table);
494 
495  if (!filename) return D3DXERR_INVALIDDATA;
496 
497  len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
498  filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
499  if (!filename_w) return E_OUTOFMEMORY;
500  MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
501 
503  entrypoint, profile, flags,
504  shader, error_messages, constant_table);
505 
506  HeapFree(GetProcessHeap(), 0, filename_w);
507  return ret;
508 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
#define CP_ACP
Definition: compat.h:99
const char * filename
Definition: ioapi.h:135
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, const char *entrypoint, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages, ID3DXConstantTable **constant_table)
Definition: shader.c:510
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
#define MultiByteToWideChar
Definition: compat.h:100
#define profile
Definition: kernel32.h:12
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ D3DXCompileShaderFromFileW()

HRESULT WINAPI D3DXCompileShaderFromFileW ( const WCHAR filename,
const D3DXMACRO defines,
ID3DXInclude *  include,
const char entrypoint,
const char profile,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages,
ID3DXConstantTable **  constant_table 
)

Definition at line 510 of file shader.c.

513 {
514  const void *buffer;
515  DWORD len, filename_len;
516  HRESULT hr;
517  struct d3dx_include_from_file include_from_file;
518  char *filename_a;
519 
520  TRACE("filename %s, defines %p, include %p, entrypoint %s, profile %s, "
521  "flags %#x, shader %p, error_messages %p, constant_table %p.\n",
523  flags, shader, error_messages, constant_table);
524 
525  if (!include)
526  {
527  include_from_file.ID3DXInclude_iface.lpVtbl = &d3dx_include_from_file_vtbl;
528  include = &include_from_file.ID3DXInclude_iface;
529  }
530 
531  filename_len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
532  filename_a = HeapAlloc(GetProcessHeap(), 0, filename_len * sizeof(char));
533  if (!filename_a)
534  return E_OUTOFMEMORY;
535  WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, filename_len, NULL, NULL);
536 
538  hr = ID3DXInclude_Open(include, D3DXINC_LOCAL, filename_a, NULL, &buffer, &len);
539  if (FAILED(hr))
540  {
542  HeapFree(GetProcessHeap(), 0, filename_a);
543  return D3DXERR_INVALIDDATA;
544  }
545 
546  hr = D3DCompile(buffer, len, filename_a, (const D3D_SHADER_MACRO *)defines,
547  (ID3DInclude *)include, entrypoint, profile, flags, 0,
549 
550  if (SUCCEEDED(hr) && constant_table)
552  constant_table);
553 
556  HeapFree(GetProcessHeap(), 0, filename_a);
557  return hr;
558 }
#define ID3DXInclude_Open(p, a, b, c, d, e)
Definition: d3dx9shader.h:303
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl
Definition: shader.c:314
GLuint buffer
Definition: glext.h:5915
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
const char * filename
Definition: ioapi.h:135
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define ID3DXInclude_Close(p, a)
Definition: d3dx9shader.h:304
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:889
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI D3DXGetShaderConstantTable(const DWORD *byte_code, ID3DXConstantTable **constant_table)
Definition: shader.c:2104
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
CRITICAL_SECTION from_file_mutex
Definition: shader.c:228
#define profile
Definition: kernel32.h:12
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:402
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by D3DXCompileShaderFromFileA().

◆ D3DXCompileShaderFromResourceA()

HRESULT WINAPI D3DXCompileShaderFromResourceA ( HMODULE  module,
const char resource,
const D3DXMACRO defines,
ID3DXInclude *  include,
const char entrypoint,
const char profile,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages,
ID3DXConstantTable **  constant_table 
)

Definition at line 560 of file shader.c.

563 {
564  void *buffer;
565  HRSRC res;
566  DWORD len;
567 
568  TRACE("module %p, resource %s, defines %p, include %p, entrypoint %s, profile %s, "
569  "flags %#x, shader %p, error_messages %p, constant_table %p.\n",
571  flags, shader, error_messages, constant_table);
572 
573  if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
574  return D3DXERR_INVALIDDATA;
576  return D3DXERR_INVALIDDATA;
577  return D3DXCompileShader(buffer, len, defines, include, entrypoint, profile,
578  flags, shader, error_messages, constant_table);
579 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
GLuint buffer
Definition: glext.h:5915
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:166
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO *defines, ID3DXInclude *include, const char *function, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_msgs, ID3DXConstantTable **constant_table)
Definition: shader.c:420
GLbitfield flags
Definition: glext.h:7161
#define RT_RCDATA
Definition: pedump.c:372
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
GLuint res
Definition: glext.h:9613
#define profile
Definition: kernel32.h:12

◆ D3DXCompileShaderFromResourceW()

HRESULT WINAPI D3DXCompileShaderFromResourceW ( HMODULE  module,
const WCHAR resource,
const D3DXMACRO defines,
ID3DXInclude *  include,
const char entrypoint,
const char profile,
DWORD  flags,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages,
ID3DXConstantTable **  constant_table 
)

Definition at line 581 of file shader.c.

584 {
585  void *buffer;
586  HRSRC res;
587  DWORD len;
588 
589  TRACE("module %p, resource %s, defines %p, include %p, entrypoint %s, profile %s, "
590  "flags %#x, shader %p, error_messages %p, constant_table %p.\n",
592  flags, shader, error_messages, constant_table);
593 
594  if (!(res = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
595  return D3DXERR_INVALIDDATA;
597  return D3DXERR_INVALIDDATA;
598  return D3DXCompileShader(buffer, len, defines, include, entrypoint, profile,
599  flags, shader, error_messages, constant_table);
600 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
GLuint buffer
Definition: glext.h:5915
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define debugstr_w
Definition: kernel32.h:32
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:166
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO *defines, ID3DXInclude *include, const char *function, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_msgs, ID3DXConstantTable **constant_table)
Definition: shader.c:420
GLbitfield flags
Definition: glext.h:7161
#define RT_RCDATA
Definition: pedump.c:372
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
GLuint res
Definition: glext.h:9613
#define profile
Definition: kernel32.h:12

◆ D3DXCreateFragmentLinker()

HRESULT WINAPI D3DXCreateFragmentLinker ( IDirect3DDevice9 *  device,
UINT  size,
ID3DXFragmentLinker **  linker 
)

Definition at line 2111 of file shader.c.

2112 {
2113  FIXME("device %p, size %u, linker %p: stub.\n", device, size, linker);
2114 
2115  if (linker)
2116  *linker = NULL;
2117 
2118 
2119  return E_NOTIMPL;
2120 }
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ D3DXCreateFragmentLinkerEx()

HRESULT WINAPI D3DXCreateFragmentLinkerEx ( IDirect3DDevice9 *  device,
UINT  size,
DWORD  flags,
ID3DXFragmentLinker **  linker 
)

Definition at line 2122 of file shader.c.

2123 {
2124  FIXME("device %p, size %u, flags %#x, linker %p: stub.\n", device, size, flags, linker);
2125 
2126  if (linker)
2127  *linker = NULL;
2128 
2129  return E_NOTIMPL;
2130 }
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ D3DXCreateTextureShader()

HRESULT WINAPI D3DXCreateTextureShader ( const DWORD function,
ID3DXTextureShader **  texture_shader 
)

Definition at line 2756 of file shader.c.

2757 {
2758  struct d3dx9_texture_shader *object;
2759 
2760  TRACE("function %p, texture_shader %p.\n", function, texture_shader);
2761 
2762  if (!function || !texture_shader)
2763  return D3DERR_INVALIDCALL;
2764 
2765  object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
2766  if (!object)
2767  return E_OUTOFMEMORY;
2768 
2769  object->ID3DXTextureShader_iface.lpVtbl = &d3dx9_texture_shader_vtbl;
2770  object->ref = 1;
2771 
2772  *texture_shader = &object->ID3DXTextureShader_iface;
2773 
2774  return D3D_OK;
2775 }
#define D3DERR_INVALIDCALL
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define D3D_OK
Definition: d3d.h:106
static const struct ID3DXTextureShaderVtbl d3dx9_texture_shader_vtbl
Definition: shader.c:2724
void * object
Definition: jmemsys.h:48

◆ D3DXDisassembleShader()

HRESULT WINAPI D3DXDisassembleShader ( const DWORD shader,
BOOL  colorcode,
const char comments,
ID3DXBuffer **  disassembly 
)

Definition at line 2445 of file shader.c.

2446 {
2447  DWORD *ptr = (DWORD *)shader;
2448  char *buffer, *buf;
2449  UINT capacity = 4096;
2450  BOOL ps;
2451  WORD version;
2452  HRESULT hr;
2453 
2454  TRACE("%p %d %s %p\n", shader, colorcode, debugstr_a(comments), disassembly);
2455 
2456  if (!shader || !disassembly)
2457  return D3DERR_INVALIDCALL;
2458 
2459  buf = buffer = HeapAlloc(GetProcessHeap(), 0, capacity);
2460  if (!buffer)
2461  return E_OUTOFMEMORY;
2462 
2463  ps = (*ptr >> 16) & 1;
2464  version = *ptr & 0xFFFF;
2465  buf += sprintf(buf, " %s_%d_%d\n", ps ? "ps" : "vs", D3DSHADER_VERSION_MAJOR(*ptr), D3DSHADER_VERSION_MINOR(*ptr));
2466  ptr++;
2467 
2468  while (*ptr != D3DSIO_END)
2469  {
2470  DWORD index;
2471 
2472  if ((buf - buffer + 128) > capacity)
2473  {
2474  UINT count = buf - buffer;
2475  char *new_buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, capacity * 2);
2476  if (!new_buffer)
2477  {
2479  return E_OUTOFMEMORY;
2480  }
2481  capacity *= 2;
2482  buffer = new_buffer;
2483  buf = buffer + count;
2484  }
2485 
2486  for (index = 0; index < sizeof(instructions)/sizeof(instructions[0]); index++)
2487  if (((*ptr & D3DSI_OPCODE_MASK) == instructions[index].opcode) &&
2488  (version >= instructions[index].min_version) && (version <= instructions[index].max_version))
2489  break;
2490 
2491  if (index != sizeof(instructions)/sizeof(instructions[0]))
2492  {
2493  buf += instructions[index].function(&(instructions[index]), &ptr, buf, ps);
2494  }
2495  else
2496  {
2497  buf += sprintf(buf, " ??? (Unknown opcode %x)\n", *ptr);
2498  while (*++ptr & (1u << 31));
2499  }
2500  }
2501 
2502  hr = D3DXCreateBuffer(buf - buffer + 1 , disassembly);
2503  if (SUCCEEDED(hr))
2504  strcpy(ID3DXBuffer_GetBufferPointer(*disassembly), buffer);
2506 
2507  return hr;
2508 }
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
#define D3DSHADER_VERSION_MAJOR(version)
Definition: d3d8types.h:476
HRESULT hr
Definition: shlfolder.c:183
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define D3DERR_INVALIDCALL
GLuint buffer
Definition: glext.h:5915
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR version[]
Definition: asmname.c:66
GLuint index
Definition: glext.h:6031
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define index(s, c)
Definition: various.h:29
char comments[4096]
#define HeapReAlloc
Definition: compat.h:401
const struct instr_info instructions[]
Definition: shader.c:2353
#define D3DSHADER_VERSION_MINOR(version)
Definition: d3d8types.h:477
unsigned int UINT
Definition: ndis.h:50
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define D3DSI_OPCODE_MASK
Definition: d3d8types.h:306
#define HeapFree(x, y, z)
Definition: compat.h:402
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:129
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ D3DXFindShaderComment()

HRESULT WINAPI D3DXFindShaderComment ( const DWORD byte_code,
DWORD  fourcc,
const void **  data,
UINT size 
)

Definition at line 149 of file shader.c.

150 {
151  const DWORD *ptr = byte_code;
152  DWORD version;
153 
154  TRACE("byte_code %p, fourcc %x, data %p, size %p\n", byte_code, fourcc, data, size);
155 
156  if (data) *data = NULL;
157  if (size) *size = 0;
158 
159  if (!byte_code) return D3DERR_INVALIDCALL;
160 
161  version = *ptr >> 16;
162  if (version != 0x4658 /* FX */
163  && version != 0x5458 /* TX */
164  && version != 0x7ffe
165  && version != 0x7fff
166  && version != 0xfffe /* VS */
167  && version != 0xffff) /* PS */
168  {
169  WARN("Invalid data supplied\n");
170  return D3DXERR_INVALIDDATA;
171  }
172 
173  while (*++ptr != D3DSIO_END)
174  {
175  /* Check if it is a comment */
177  {
179 
180  /* Check if this is the comment we are looking for */
181  if (*(ptr + 1) == fourcc)
182  {
183  UINT ctab_size = (comment_size - 1) * sizeof(DWORD);
184  const void *ctab_data = ptr + 2;
185  if (size)
186  *size = ctab_size;
187  if (data)
188  *data = ctab_data;
189  TRACE("Returning comment data at %p with size %d\n", ctab_data, ctab_size);
190  return D3D_OK;
191  }
192  ptr += comment_size;
193  }
194  }
195 
196  return S_FALSE;
197 }
#define WARN(fmt,...)
Definition: debug.h:111
#define D3DERR_INVALIDCALL
static PVOID ptr
Definition: dispmode.c:27
#define D3DSI_COMMENTSIZE_SHIFT
Definition: d3d8types.h:479
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:66
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define D3DSI_COMMENTSIZE_MASK
Definition: d3d8types.h:480
#define D3D_OK
Definition: d3d.h:106
unsigned int UINT
Definition: ndis.h:50
#define D3DSI_OPCODE_MASK
Definition: d3d8types.h:306

Referenced by D3DXGetShaderConstantTableEx(), and D3DXGetShaderSamplers().

◆ D3DXGetPixelShaderProfile()

const char* WINAPI D3DXGetPixelShaderProfile ( struct IDirect3DDevice9 *  device)

Definition at line 42 of file shader.c.

43 {
44  D3DCAPS9 caps;
45 
46  TRACE("device %p\n", device);
47 
48  if (!device) return NULL;
49 
51 
52  switch (caps.PixelShaderVersion)
53  {
54  case D3DPS_VERSION(1, 1):
55  return "ps_1_1";
56 
57  case D3DPS_VERSION(1, 2):
58  return "ps_1_2";
59 
60  case D3DPS_VERSION(1, 3):
61  return "ps_1_3";
62 
63  case D3DPS_VERSION(1, 4):
64  return "ps_1_4";
65 
66  case D3DPS_VERSION(2, 0):
67  if ((caps.PS20Caps.NumTemps>=22) &&
68  (caps.PS20Caps.Caps&D3DPS20CAPS_ARBITRARYSWIZZLE) &&
69  (caps.PS20Caps.Caps&D3DPS20CAPS_GRADIENTINSTRUCTIONS) &&
70  (caps.PS20Caps.Caps&D3DPS20CAPS_PREDICATION) &&
71  (caps.PS20Caps.Caps&D3DPS20CAPS_NODEPENDENTREADLIMIT) &&
72  (caps.PS20Caps.Caps&D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT))
73  {
74  return "ps_2_a";
75  }
76  if ((caps.PS20Caps.NumTemps>=32) &&
78  {
79  return "ps_2_b";
80  }
81  return "ps_2_0";
82 
83  case D3DPS_VERSION(3, 0):
84  return "ps_3_0";
85  }
86 
87  return NULL;
88 }
D3DPSHADERCAPS2_0 PS20Caps
Definition: d3d9caps.h:327
#define D3DPS20CAPS_GRADIENTINSTRUCTIONS
Definition: d3d9caps.h:226
return
Definition: dirsup.c:529
#define D3DPS20CAPS_PREDICATION
Definition: d3d9caps.h:227
#define D3DPS_VERSION(major, minor)
Definition: d3d8types.h:474
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define D3DPS20CAPS_NODEPENDENTREADLIMIT
Definition: d3d9caps.h:228
#define D3DPS20CAPS_ARBITRARYSWIZZLE
Definition: d3d9caps.h:225
DWORD PixelShaderVersion
Definition: d3d9caps.h:315
#define D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
Definition: d3d9caps.h:229
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514

◆ D3DXGetShaderConstantTable()

HRESULT WINAPI D3DXGetShaderConstantTable ( const DWORD byte_code,
ID3DXConstantTable **  constant_table 
)

Definition at line 2104 of file shader.c.

2105 {
2106  TRACE("(%p, %p): Forwarded to D3DXGetShaderConstantTableEx\n", byte_code, constant_table);
2107 
2108  return D3DXGetShaderConstantTableEx(byte_code, 0, constant_table);
2109 }
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags, ID3DXConstantTable **constant_table)
Definition: shader.c:1986

Referenced by compile_pixel_shader9(), D3DXCompileShader(), D3DXCompileShaderFromFileW(), and get_constants_desc().

◆ D3DXGetShaderConstantTableEx()

HRESULT WINAPI D3DXGetShaderConstantTableEx ( const DWORD byte_code,
DWORD  flags,
ID3DXConstantTable **  constant_table 
)

Definition at line 1986 of file shader.c.

1987 {
1988  struct ID3DXConstantTableImpl *object = NULL;
1989  const void *data;
1990  HRESULT hr;
1991  UINT size;
1992  const D3DXSHADER_CONSTANTTABLE *ctab_header;
1993  const D3DXSHADER_CONSTANTINFO *constant_info;
1994  DWORD i;
1995 
1996  TRACE("byte_code %p, flags %x, constant_table %p\n", byte_code, flags, constant_table);
1997 
1998  if (constant_table) *constant_table = NULL;
1999 
2000  if (!byte_code || !constant_table)
2001  {
2002  WARN("Invalid argument specified.\n");
2003  return D3DERR_INVALIDCALL;
2004  }
2005 
2006  if (!is_valid_bytecode(*byte_code))
2007  {
2008  WARN("Invalid byte_code specified.\n");
2009  return D3D_OK;
2010  }
2011 
2012  if (flags) FIXME("Flags (%#x) are not handled, yet!\n", flags);
2013 
2014  hr = D3DXFindShaderComment(byte_code, MAKEFOURCC('C','T','A','B'), &data, &size);
2015  if (hr != D3D_OK)
2016  {
2017  WARN("CTAB not found.\n");
2018  return D3DXERR_INVALIDDATA;
2019  }
2020 
2021  if (size < sizeof(*ctab_header))
2022  {
2023  WARN("Invalid CTAB size.\n");
2024  return D3DXERR_INVALIDDATA;
2025  }
2026 
2027  ctab_header = (const D3DXSHADER_CONSTANTTABLE *)data;
2028  if (ctab_header->Size != sizeof(*ctab_header))
2029  {
2030  WARN("Invalid D3DXSHADER_CONSTANTTABLE size.\n");
2031  return D3DXERR_INVALIDDATA;
2032  }
2033 
2034  object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
2035  if (!object)
2036  return E_OUTOFMEMORY;
2037 
2038  object->ID3DXConstantTable_iface.lpVtbl = &ID3DXConstantTable_Vtbl;
2039  object->ref = 1;
2040 
2041  object->ctab = HeapAlloc(GetProcessHeap(), 0, size);
2042  if (!object->ctab)
2043  {
2044  ERR("Out of memory\n");
2045  HeapFree(GetProcessHeap(), 0, object);
2046  return E_OUTOFMEMORY;
2047  }
2048  object->size = size;
2049  memcpy(object->ctab, data, object->size);
2050 
2051  object->desc.Creator = ctab_header->Creator ? object->ctab + ctab_header->Creator : NULL;
2052  object->desc.Version = ctab_header->Version;
2053  object->desc.Constants = ctab_header->Constants;
2054  TRACE("Creator %s, Version %x, Constants %u, Target %s\n",
2055  debugstr_a(object->desc.Creator), object->desc.Version, object->desc.Constants,
2056  debugstr_a(ctab_header->Target ? object->ctab + ctab_header->Target : NULL));
2057 
2058  object->constants = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
2059  sizeof(*object->constants) * object->desc.Constants);
2060  if (!object->constants)
2061  {
2062  ERR("Out of memory\n");
2063  hr = E_OUTOFMEMORY;
2064  goto error;
2065  }
2066 
2067  constant_info = (const D3DXSHADER_CONSTANTINFO *)(object->ctab + ctab_header->ConstantInfo);
2068  for (i = 0; i < ctab_header->Constants; i++)
2069  {
2070  DWORD offset = constant_info[i].DefaultValue;
2071 
2072  hr = parse_ctab_constant_type(object->ctab, constant_info[i].TypeInfo,
2073  &object->constants[i], FALSE, constant_info[i].RegisterIndex,
2074  constant_info[i].RegisterIndex + constant_info[i].RegisterCount,
2075  offset ? &offset : NULL, constant_info[i].Name, constant_info[i].RegisterSet);
2076  if (hr != D3D_OK)
2077  goto error;
2078 
2079  /*
2080  * Set the register count, it may differ for D3DXRS_INT4, because somehow
2081  * it makes the assumption that the register size is 1 instead of 4, so the
2082  * count is 4 times bigger. This holds true only for toplevel shader
2083  * constants. The count of elements and members is always based on a
2084  * register size of 4.
2085  */
2086  if (object->constants[i].desc.RegisterSet == D3DXRS_INT4)
2087  {
2088  object->constants[i].desc.RegisterCount = constant_info[i].RegisterCount;
2089  }
2090  object->constants[i].constantinfo_reserved = constant_info[i].Reserved;
2091  }
2092 
2093  *constant_table = &object->ID3DXConstantTable_iface;
2094 
2095  return D3D_OK;
2096 
2097 error:
2098  free_constant_table(object);
2099  HeapFree(GetProcessHeap(), 0, object);
2100 
2101  return hr;
2102 }
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
#define WARN(fmt,...)
Definition: debug.h:111
GLintptr offset
Definition: glext.h:5920
#define D3DERR_INVALIDCALL
HRESULT WINAPI D3DXFindShaderComment(const DWORD *byte_code, DWORD fourcc, const void **data, UINT *size)
Definition: shader.c:149
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 E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl
Definition: shader.c:1814
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:109
#define D3D_OK
Definition: d3d.h:106
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static BOOL is_valid_bytecode(DWORD token)
Definition: shader.c:37
#define MAKEFOURCC(ch0, ch1, ch2, ch3)
Definition: dmdls.h:24
static HRESULT parse_ctab_constant_type(const char *ctab, DWORD typeoffset, struct ctab_constant *constant, BOOL is_element, WORD index, WORD max_index, DWORD *offset, DWORD nameoffset, UINT regset)
Definition: shader.c:1848
#define HeapFree(x, y, z)
Definition: compat.h:402
static void free_constant_table(struct ID3DXConstantTableImpl *table)
Definition: shader.c:740

Referenced by D3DXGetShaderConstantTable().

◆ D3DXGetShaderInputSemantics()

HRESULT WINAPI D3DXGetShaderInputSemantics ( const DWORD byte_code,
D3DXSEMANTIC semantics,
UINT count 
)

Definition at line 3011 of file shader.c.

3012 {
3013  TRACE("byte_code %p, semantics %p, count %p.\n", byte_code, semantics, count);
3014 
3015  return get_shader_semantics(byte_code, semantics, count, FALSE);
3016 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT get_shader_semantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count, BOOL output)
Definition: shader.c:2810

◆ D3DXGetShaderOutputSemantics()

HRESULT WINAPI D3DXGetShaderOutputSemantics ( const DWORD byte_code,
D3DXSEMANTIC semantics,
UINT count 
)

Definition at line 3018 of file shader.c.

3019 {
3020  TRACE("byte_code %p, semantics %p, count %p.\n", byte_code, semantics, count);
3021 
3022  return get_shader_semantics(byte_code, semantics, count, TRUE);
3023 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT get_shader_semantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count, BOOL output)
Definition: shader.c:2810

◆ D3DXGetShaderSamplers()

HRESULT WINAPI D3DXGetShaderSamplers ( const DWORD byte_code,
const char **  samplers,
UINT count 
)

Definition at line 2132 of file shader.c.

2133 {
2134  UINT i, sampler_count = 0;
2135  UINT size;
2136  const char *data;
2137  const D3DXSHADER_CONSTANTTABLE *ctab_header;
2138  const D3DXSHADER_CONSTANTINFO *constant_info;
2139 
2140  TRACE("byte_code %p, samplers %p, count %p\n", byte_code, samplers, count);
2141 
2142  if (count) *count = 0;
2143 
2144  if (D3DXFindShaderComment(byte_code, MAKEFOURCC('C','T','A','B'), (const void **)&data, &size) != D3D_OK)
2145  return D3D_OK;
2146 
2147  if (size < sizeof(*ctab_header)) return D3D_OK;
2148 
2149  ctab_header = (const D3DXSHADER_CONSTANTTABLE *)data;
2150  if (ctab_header->Size != sizeof(*ctab_header)) return D3D_OK;
2151 
2152  constant_info = (const D3DXSHADER_CONSTANTINFO *)(data + ctab_header->ConstantInfo);
2153  for (i = 0; i < ctab_header->Constants; i++)
2154  {
2155  const D3DXSHADER_TYPEINFO *type;
2156 
2157  TRACE("name = %s\n", data + constant_info[i].Name);
2158 
2159  type = (const D3DXSHADER_TYPEINFO *)(data + constant_info[i].TypeInfo);
2160 
2161  if (type->Type == D3DXPT_SAMPLER
2162  || type->Type == D3DXPT_SAMPLER1D
2163  || type->Type == D3DXPT_SAMPLER2D
2164  || type->Type == D3DXPT_SAMPLER3D
2165  || type->Type == D3DXPT_SAMPLERCUBE)
2166  {
2167  if (samplers) samplers[sampler_count] = data + constant_info[i].Name;
2168 
2169  ++sampler_count;
2170  }
2171  }
2172 
2173  TRACE("Found %u samplers\n", sampler_count);
2174 
2175  if (count) *count = sampler_count;
2176 
2177  return D3D_OK;
2178 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
HRESULT WINAPI D3DXFindShaderComment(const DWORD *byte_code, DWORD fourcc, const void **data, UINT *size)
Definition: shader.c:149
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 TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define D3D_OK
Definition: d3d.h:106
unsigned int UINT
Definition: ndis.h:50
GLuint * samplers
Definition: glext.h:7280
#define MAKEFOURCC(ch0, ch1, ch2, ch3)
Definition: dmdls.h:24

◆ D3DXGetShaderSize()

UINT WINAPI D3DXGetShaderSize ( const DWORD byte_code)

Definition at line 90 of file shader.c.

91 {
92  const DWORD *ptr = byte_code;
93 
94  TRACE("byte_code %p\n", byte_code);
95 
96  if (!ptr) return 0;
97 
98  /* Look for the END token, skipping the VERSION token */
99  while (*++ptr != D3DSIO_END)
100  {
101  /* Skip comments */
103  {
105  }
106  }
107  ++ptr;
108 
109  /* Return the shader size in bytes */
110  return (ptr - byte_code) * sizeof(*ptr);
111 }
static PVOID ptr
Definition: dispmode.c:27
#define D3DSI_COMMENTSIZE_SHIFT
Definition: d3d8types.h:479
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3DSI_COMMENTSIZE_MASK
Definition: d3d8types.h:480
#define D3DSI_OPCODE_MASK
Definition: d3d8types.h:306

◆ D3DXGetShaderVersion()

DWORD WINAPI D3DXGetShaderVersion ( const DWORD byte_code)

Definition at line 113 of file shader.c.

114 {
115  TRACE("byte_code %p\n", byte_code);
116 
117  return byte_code ? *byte_code : 0;
118 }
#define TRACE(s)
Definition: solgame.cpp:4

◆ D3DXGetVertexShaderProfile()

const char* WINAPI D3DXGetVertexShaderProfile ( struct IDirect3DDevice9 *  device)

Definition at line 120 of file shader.c.

121 {
122  D3DCAPS9 caps;
123 
124  TRACE("device %p\n", device);
125 
126  if (!device) return NULL;
127 
129 
130  switch (caps.VertexShaderVersion)
131  {
132  case D3DVS_VERSION(1, 1):
133  return "vs_1_1";
134  case D3DVS_VERSION(2, 0):
135  if ((caps.VS20Caps.NumTemps>=13) &&
136  (caps.VS20Caps.DynamicFlowControlDepth==24) &&
137  (caps.VS20Caps.Caps&D3DPS20CAPS_PREDICATION))
138  {
139  return "vs_2_a";
140  }
141  return "vs_2_0";
142  case D3DVS_VERSION(3, 0):
143  return "vs_3_0";
144  }
145 
146  return NULL;
147 }
return
Definition: dirsup.c:529
#define D3DPS20CAPS_PREDICATION
Definition: d3d9caps.h:227
DWORD VertexShaderVersion
Definition: d3d9caps.h:313
#define D3DVS_VERSION(major, minor)
Definition: d3d8types.h:475
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514

◆ D3DXPreprocessShader()

HRESULT WINAPI D3DXPreprocessShader ( const char data,
UINT  data_len,
const D3DXMACRO defines,
ID3DXInclude *  include,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 602 of file shader.c.

604 {
605  TRACE("data %s, data_len %u, defines %p, include %p, shader %p, error_messages %p.\n",
607 
608  return D3DPreprocess(data, data_len, NULL,
611 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:902
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30

Referenced by D3DXPreprocessShaderFromResourceA(), and D3DXPreprocessShaderFromResourceW().

◆ D3DXPreprocessShaderFromFileA()

HRESULT WINAPI D3DXPreprocessShaderFromFileA ( const char filename,
const D3DXMACRO defines,
ID3DXInclude *  include,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 613 of file shader.c.

615 {
616  WCHAR *filename_w = NULL;
617  DWORD len;
618  HRESULT ret;
619 
620  TRACE("filename %s, defines %p, include %p, shader %p, error_messages %p.\n",
622 
623  if (!filename) return D3DXERR_INVALIDDATA;
624 
625  len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
626  filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
627  if (!filename_w) return E_OUTOFMEMORY;
628  MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
629 
631 
632  HeapFree(GetProcessHeap(), 0, filename_w);
633  return ret;
634 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
HRESULT WINAPI D3DXPreprocessShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:636
#define CP_ACP
Definition: compat.h:99
const char * filename
Definition: ioapi.h:135
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
#define MultiByteToWideChar
Definition: compat.h:100
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ D3DXPreprocessShaderFromFileW()

HRESULT WINAPI D3DXPreprocessShaderFromFileW ( const WCHAR filename,
const D3DXMACRO defines,
ID3DXInclude *  include,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 636 of file shader.c.

638 {
639  const void *buffer;
640  DWORD len;
641  HRESULT hr;
642  struct d3dx_include_from_file include_from_file;
643  char *filename_a;
644 
645  TRACE("filename %s, defines %p, include %p, shader %p, error_messages %p.\n",
647 
648  if (!include)
649  {
650  include_from_file.ID3DXInclude_iface.lpVtbl = &d3dx_include_from_file_vtbl;
651  include = &include_from_file.ID3DXInclude_iface;
652  }
653 
655  filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
656  if (!filename_a)
657  return E_OUTOFMEMORY;
658  WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
659 
661  hr = ID3DXInclude_Open(include, D3DXINC_LOCAL, filename_a, NULL, &buffer, &len);
662  if (FAILED(hr))
663  {
665  HeapFree(GetProcessHeap(), 0, filename_a);
666  return D3DXERR_INVALIDDATA;
667  }
668 
670  (const D3D_SHADER_MACRO *)defines,
671  (ID3DInclude *) include,
673 
676  HeapFree(GetProcessHeap(), 0, filename_a);
677  return hr;
678 }
#define ID3DXInclude_Open(p, a, b, c, d, e)
Definition: d3dx9shader.h:303
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl
Definition: shader.c:314
GLuint buffer
Definition: glext.h:5915
HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:902
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
const char * filename
Definition: ioapi.h:135
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define ID3DXInclude_Close(p, a)
Definition: d3dx9shader.h:304
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
CRITICAL_SECTION from_file_mutex
Definition: shader.c:228
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by D3DXPreprocessShaderFromFileA().

◆ D3DXPreprocessShaderFromResourceA()

HRESULT WINAPI D3DXPreprocessShaderFromResourceA ( HMODULE  module,
const char resource,
const D3DXMACRO defines,
ID3DXInclude *  include,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 680 of file shader.c.

682 {
683  void *buffer;
684  HRSRC res;
685  DWORD len;
686 
687  TRACE("module %p, resource %s, defines %p, include %p, shader %p, error_messages %p.\n",
689 
690  if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
691  return D3DXERR_INVALIDDATA;
693  return D3DXERR_INVALIDDATA;
696 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
HRESULT WINAPI D3DXPreprocessShader(const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:602
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
GLuint buffer
Definition: glext.h:5915
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:166
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RT_RCDATA
Definition: pedump.c:372
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
GLuint res
Definition: glext.h:9613

◆ D3DXPreprocessShaderFromResourceW()

HRESULT WINAPI D3DXPreprocessShaderFromResourceW ( HMODULE  module,
const WCHAR resource,
const D3DXMACRO defines,
ID3DXInclude *  include,
ID3DXBuffer **  shader,
ID3DXBuffer **  error_messages 
)

Definition at line 698 of file shader.c.

700 {
701  void *buffer;
702  HRSRC res;
703  DWORD len;
704 
705  TRACE("module %p, resource %s, defines %p, include %p, shader %p, error_messages %p.\n",
707 
708  if (!(res = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
709  return D3DXERR_INVALIDDATA;
711  return D3DXERR_INVALIDDATA;
714 
715 }
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:30
HRESULT WINAPI D3DXPreprocessShader(const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:602
GLuint buffer
Definition: glext.h:5915
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define debugstr_w
Definition: kernel32.h:32
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:166
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RT_RCDATA
Definition: pedump.c:372
GLenum GLsizei len
Definition: glext.h:6722
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:30
GLuint res
Definition: glext.h:9613

◆ free_constant()

static void free_constant ( struct ctab_constant constant)
static

Definition at line 726 of file shader.c.

727 {
728  if (constant->constants)
729  {
730  UINT i, count = constant->desc.Elements > 1 ? constant->desc.Elements : constant->desc.StructMembers;
731 
732  for (i = 0; i < count; ++i)
733  {
734  free_constant(&constant->constants[i]);
735  }
736  HeapFree(GetProcessHeap(), 0, constant->constants);
737  }
738 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
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 GetProcessHeap()
Definition: compat.h:403
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:402
static void free_constant(struct ctab_constant *constant)
Definition: shader.c:726

Referenced by free_constant_table(), and parse_ctab_constant_type().

◆ free_constant_table()

static void free_constant_table ( struct ID3DXConstantTableImpl table)
static

Definition at line 740 of file shader.c.

741 {
742  if (table->constants)
743  {
744  UINT i;
745 
746  for (i = 0; i < table->desc.Constants; ++i)
747  {
748  free_constant(&table->constants[i]);
749  }
750  HeapFree(GetProcessHeap(), 0, table->constants);
751  }
752  HeapFree(GetProcessHeap(), 0, table->ctab);
753 }
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 GetProcessHeap()
Definition: compat.h:403
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:402
static void free_constant(struct ctab_constant *constant)
Definition: shader.c:726

Referenced by D3DXGetShaderConstantTableEx(), and ID3DXConstantTableImpl_Release().

◆ get_constant_by_name()

static struct ctab_constant * get_constant_by_name ( struct ID3DXConstantTableImpl table,
struct ctab_constant constant,
const char name 
)
static

Definition at line 811 of file shader.c.

813 {
814  UINT i, count, length;
815  struct ctab_constant *handles;
816  const char *part;
817 
818  TRACE("table %p, constant %p, name %s\n", table, constant, debugstr_a(name));
819 
820  if (!name || !*name) return NULL;
821 
822  if (!constant)
823  {
824  count = table->desc.Constants;
825  handles = table->constants;
826  }
827  else
828  {
829  count = constant->desc.StructMembers;
830  handles = constant->constants;
831  }
832 
833  length = strcspn(name, "[.");
834  part = name + length;
835 
836  for (i = 0; i < count; i++)
837  {
838  if (strlen(handles[i].desc.Name) == length && !strncmp(handles[i].desc.Name, name, length))
839  {
840  switch (*part++)
841  {
842  case '.':
843  return get_constant_by_name(NULL, &handles[i], part);
844 
845  case '[':
846  return get_constant_element_by_name(&handles[i], part);
847 
848  default:
849  TRACE("Returning parameter %p\n", &handles[i]);
850  return &handles[i];
851  }
852  }
853  }
854 
855  TRACE("Constant not found\n");
856  return NULL;
857 }
static struct object_header ** handles
Definition: handle.c:45
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
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 const WCHAR desc[]
Definition: protectdata.c:36
smooth NULL
Definition: ftsmooth.c:416
static struct ctab_constant * get_constant_element_by_name(struct ctab_constant *constant, const char *name)
Definition: shader.c:773
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static struct ctab_constant * get_constant_by_name(struct ID3DXConstantTableImpl *table, struct ctab_constant *constant, const char *name)
Definition: shader.c:811
unsigned int UINT
Definition: ndis.h:50
Definition: name.c:38

Referenced by get_constant_element_by_name(), get_valid_constant(), and ID3DXConstantTableImpl_GetConstantByName().

◆ get_constant_element_by_name()

static struct ctab_constant* get_constant_element_by_name ( struct ctab_constant constant,
const char name 
)
static

Definition at line 773 of file shader.c.

774 {
775  const char *part;
776  UINT element;
777 
778  TRACE("constant %p, name %s\n", constant, debugstr_a(name));
779 
780  if (!name || !*name) return NULL;
781 
782  element = atoi(name);
783  part = strchr(name, ']') + 1;
784 
785  if (constant->desc.Elements > element)
786  {
787  struct ctab_constant *c = constant->constants ? &constant->constants[element] : constant;
788 
789  switch (*part++)
790  {
791  case '.':
792  return get_constant_by_name(NULL, c, part);
793 
794  case '[':
795  return get_constant_element_by_name(c, part);
796 
797  case '\0':
798  TRACE("Returning parameter %p\n", c);
799  return c;
800 
801  default:
802  FIXME("Unhandled case \"%c\"\n", *--part);
803  break;
804  }
805  }
806 
807  TRACE("Constant not found\n");
808  return NULL;
809 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static struct ctab_constant * get_constant_element_by_name(struct ctab_constant *constant, const char *name)
Definition: shader.c:773
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
const GLubyte * c
Definition: glext.h:8905
static struct ctab_constant * get_constant_by_name(struct ID3DXConstantTableImpl *table, struct ctab_constant *constant, const char *name)
Definition: shader.c:811
unsigned int UINT
Definition: ndis.h:50
char * strchr(const char *String, int ch)
Definition: utclib.c:501
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
Definition: name.c:38
#define c
Definition: ke_i.h:80

Referenced by get_constant_by_name().

◆ get_index()

static DWORD get_index ( const void **  indata,
UINT  index,
BOOL  is_pointer 
)
inlinestatic

Definition at line 1084 of file shader.c.

1085 {
1086  if (!indata)
1087  return 0;
1088 
1089  if (is_pointer)
1090  return ((DWORD **)indata)[index / 16][index % 16];
1091 
1092  return (*((DWORD **)indata))[index];
1093 }
GLuint index
Definition: glext.h:6031
unsigned long DWORD
Definition: ntddk_ex.h:95
#define index(s, c)
Definition: various.h:29

Referenced by set().

◆ get_instr_length()

static unsigned int get_instr_length ( const DWORD byte_code,
unsigned int  major,
unsigned int  minor 
)
static

Definition at line 2777 of file shader.c.

2778 {
2779  DWORD opcode = *byte_code & 0xffff;
2780  unsigned int len = 0;
2781 
2782  if (opcode == D3DSIO_COMMENT)
2783  return (*byte_code & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT;
2784 
2785  if (major > 1)
2786  return (*byte_code & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT;
2787 
2788  switch (opcode)
2789  {
2790  case D3DSIO_END:
2791  ERR("Unexpected END token.\n");
2792  return 0;
2793  case D3DSIO_DEF:
2794  case D3DSIO_DEFI:
2795  return 5;
2796  case D3DSIO_DEFB:
2797  return 2;
2798  default:
2799  ++byte_code;
2800  while (*byte_code & 0x80000000)
2801  {
2802  ++byte_code;
2803  ++len;
2804  }
2805  }
2806 
2807  return len;
2808 }
#define D3DSI_INSTLENGTH_MASK
Definition: d3d9types.h:353
#define D3DSI_COMMENTSIZE_SHIFT
Definition: d3d8types.h:479
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3DSI_COMMENTSIZE_MASK
Definition: d3d8types.h:480
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:109
#define major(rdev)
Definition: propsheet.cpp:916
#define D3DSI_INSTLENGTH_SHIFT
Definition: d3d9types.h:354

Referenced by get_shader_semantics().

◆ get_shader_semantics()

static HRESULT get_shader_semantics ( const DWORD byte_code,
D3DXSEMANTIC semantics,
UINT count,
BOOL  output 
)
static

Definition at line 2810 of file shader.c.

2811 {
2812  static const D3DDECLUSAGE regtype_usage[] =
2813  {
2816  0,
2818  0,
2821  0,
2822  0,
2824  };
2825  static const D3DDECLUSAGE rast_usage[] =
2826  {
2830  };
2831  DWORD reg_type, usage, index, version_token = *byte_code;
2832  BOOL is_ps = version_token >> 16 == 0xffff;
2833  unsigned int major, minor, i = 0, j;
2834  BYTE colors = 0, rastout = 0;
2835  BOOL has_dcl, depth = 0;
2836  WORD texcoords = 0;
2837 
2838  if ((version_token & 0xffff0000) != 0xfffe0000 && (version_token & 0xffff0000) != 0xffff0000)
2839  return D3DXERR_INVALIDDATA;
2840 
2841  major = version_token >> 8 & 0xff;
2842  minor = version_token & 0xff;
2843 
2844  TRACE("%s shader, version %u.%u.\n", is_ps ? "Pixel" : "Vertex", major, minor);
2845  ++byte_code;
2846 
2847  has_dcl = (!is_ps && (!output || major == 3)) || (is_ps && !output && major >= 2);
2848 
2849  while (*byte_code != D3DSIO_END)
2850  {
2851  if (has_dcl && (*byte_code & 0xffff) == D3DSIO_DCL)
2852  {
2853  DWORD usage_token = byte_code[1];
2854  DWORD reg = byte_code[2];
2855 
2858 
2859  if (is_ps && !output && major == 2)
2860  {
2861  /* dcl with no explicit usage, look at the register. */
2865  if (reg_type >= ARRAY_SIZE(regtype_usage))
2866  {
2867  WARN("Invalid register type %u.\n", reg_type);
2868  reg_type = 0;
2869  }
2870  usage = regtype_usage[reg_type];
2871  if (semantics)
2872  {
2873  semantics[i].Usage = usage;
2874  semantics[i].UsageIndex = index;
2875  }
2876  ++i;
2877  }
2878  else if ((!output && reg_type == D3DSPR_INPUT) || (output && reg_type == D3DSPR_OUTPUT))
2879  {
2880  if (semantics)
2881  {
2882  semantics[i].Usage =
2883  (usage_token & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT;
2884  semantics[i].UsageIndex =
2886  }
2887  ++i;
2888  }
2889  byte_code += 3;
2890  }
2891  else if (!has_dcl)
2892  {
2893  unsigned int len = get_instr_length(byte_code, major, minor) + 1;
2894 
2895  switch (*byte_code & 0xffff)
2896  {
2897  case D3DSIO_COMMENT:
2898  case D3DSIO_DEF:
2899  case D3DSIO_DEFB:
2900  case D3DSIO_DEFI:
2901  byte_code += len;
2902  break;
2903  default:
2904  ++byte_code;
2905  while (*byte_code & 0x80000000)
2906  {
2907  reg_type = ((*byte_code & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT)
2908  | ((*byte_code & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2);
2909  index = *byte_code & D3DSP_REGNUM_MASK;
2910 
2911  if ((reg_type == D3DSPR_TEMP && is_ps && major == 1)
2912  || (reg_type == D3DSPR_INPUT && is_ps)
2913  || (reg_type == D3DSPR_TEXTURE && is_ps && !output)
2914  || reg_type == D3DSPR_RASTOUT
2915  || reg_type == D3DSPR_ATTROUT
2916  || reg_type == D3DSPR_OUTPUT
2917  || reg_type == D3DSPR_DEPTHOUT)
2918  {
2919  if (reg_type == D3DSPR_RASTOUT)
2920  rastout |= 1u << index;
2921  else if (reg_type == D3DSPR_DEPTHOUT)
2922  depth = TRUE;
2923  else if (reg_type == D3DSPR_TEXTURE || reg_type == D3DSPR_OUTPUT)
2924  texcoords |= 1u << index;
2925  else
2926  colors |= 1u << index;
2927  }
2928  ++byte_code;
2929  }
2930  }
2931  }
2932  else
2933  {
2934  byte_code += get_instr_length(byte_code, major, minor) + 1;
2935  }
2936  }
2937 
2938  if (!has_dcl)
2939  {
2940  i = j = 0;
2941  while (texcoords)
2942  {
2943  if (texcoords & 1)
2944  {
2945  if (semantics)
2946  {
2947  semantics[i].Usage = D3DDECLUSAGE_TEXCOORD;
2948  semantics[i].UsageIndex = j;
2949  }
2950  ++i;
2951  }
2952  texcoords >>= 1;
2953  ++j;
2954  }
2955  j = 0;
2956  while (colors)
2957  {
2958  if (colors & 1)
2959  {
2960  if (semantics)
2961  {
2962  semantics[i].Usage = D3DDECLUSAGE_COLOR;
2963  semantics[i].UsageIndex = j;
2964  }
2965  ++i;
2966  }
2967  colors >>= 1;
2968  ++j;
2969  }
2970  j = 0;
2971  while (rastout)
2972  {
2973  if (rastout & 1)
2974  {
2975  if (j >= ARRAY_SIZE(rast_usage))
2976  {
2977  WARN("Invalid RASTOUT register index.\n");
2978  usage = 0;
2979  }
2980  else
2981  {
2982  usage = rast_usage[j];
2983  }
2984  if (semantics)
2985  {
2986  semantics[i].Usage = usage;
2987  semantics[i].UsageIndex = 0;
2988  }
2989  ++i;
2990  }
2991  rastout >>= 1;
2992  ++j;
2993  }
2994  if (depth)
2995  {
2996  if (semantics)
2997  {
2998  semantics[i].Usage = D3DDECLUSAGE_DEPTH;
2999  semantics[i].UsageIndex = 0;
3000  }
3001  ++i;
3002  }
3003  }
3004 
3005  if (count)
3006  *count = i;
3007 
3008  return D3D_OK;
3009 }
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
#define D3DSP_REGTYPE_MASK2
Definition: d3d9types.h:508
#define TRUE
Definition: types.h:120
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:111
#define D3DSP_DCL_USAGEINDEX_SHIFT
Definition: d3d9types.h:463
#define D3DSP_REGTYPE_SHIFT
Definition: d3d8types.h:394
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
unsigned int BOOL
Definition: ntddk_ex.h:94
enum _D3DDECLUSAGE D3DDECLUSAGE
static unsigned int get_instr_length(const DWORD *byte_code, unsigned int major, unsigned int minor)
Definition: shader.c:2777
GLuint index
Definition: glext.h:6031
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
#define D3DSP_DCL_USAGE_SHIFT
Definition: d3d9types.h:460
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3DSP_DCL_USAGE_MASK
Definition: d3d9types.h:461
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define index(s, c)
Definition: various.h:29
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define D3D_OK
Definition: d3d.h:106
#define ARRAY_SIZE(a)
Definition: main.h:24
#define major(rdev)
Definition: propsheet.cpp:916
#define D3DSP_REGNUM_MASK
Definition: d3d9types.h:479
static int reg
Definition: i386-dis.c:1275
#define minor(rdev)
Definition: propsheet.cpp:917
#define D3DSP_REGTYPE_SHIFT2
Definition: d3d9types.h:506
#define D3DSP_DCL_USAGEINDEX_MASK
Definition: d3d9types.h:464
type_t * reg_type(type_t *type, const char *name, struct namespace *namespace, int t)
Definition: parser.tab.c:5992
#define D3DSP_REGTYPE_MASK
Definition: d3d8types.h:395

Referenced by D3DXGetShaderInputSemantics(), and D3DXGetShaderOutputSemantics().

◆ get_valid_constant()

static struct ctab_constant* get_valid_constant ( struct ID3DXConstantTableImpl table,
D3DXHANDLE  handle 
)
inlinestatic

Definition at line 880 of file shader.c.

881 {
882  struct ctab_constant *c;
883  UINT i;
884 
885  if (!handle) return NULL;
886 
887  for (i = 0; i < table->desc.Constants; ++i)
888  {
889  if (handle_from_constant(&table->constants[i]) == handle)
890  return &table->constants[i];
891 
892  c = is_valid_sub_constant(&table->constants[i], handle);
893  if (c) return c;
894  }
895 
897 }
static struct ctab_constant * is_valid_sub_constant(struct ctab_constant *parent, D3DXHANDLE handle)
Definition: shader.c:859
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 D3DXHANDLE handle_from_constant(struct ctab_constant *constant)
Definition: shader.c:765
smooth NULL
Definition: ftsmooth.c:416
const GLubyte * c
Definition: glext.h:8905
static struct ctab_constant * get_constant_by_name(struct ID3DXConstantTableImpl *table, struct ctab_constant *constant, const char *name)
Definition: shader.c:811
unsigned int UINT
Definition: ndis.h:50
#define c
Definition: ke_i.h:80

Referenced by d3dx_shader_get_ctab_constant(), ID3DXConstantTableImpl_GetConstant(), ID3DXConstantTableImpl_GetConstantByName(), ID3DXConstantTableImpl_GetConstantDesc(), ID3DXConstantTableImpl_GetConstantElement(), ID3DXConstantTableImpl_GetSamplerIndex(), ID3DXConstantTableImpl_SetValue(), set_matrix_array(), set_matrix_pointer_array(), set_scalar(), set_scalar_array(), set_vector(), and set_vector_array().

◆ handle_from_constant()

static D3DXHANDLE handle_from_constant ( struct ctab_constant constant)
inlinestatic

◆ ID3DXConstantTableImpl_AddRef()

static ULONG WINAPI ID3DXConstantTableImpl_AddRef ( ID3DXConstantTable *  iface)
static

Definition at line 918 of file shader.c.

919 {
921 
922  TRACE("(%p)->(): AddRef from %d\n", This, This->ref);
923 
924  return InterlockedIncrement(&This->ref);
925 }
#define TRACE(s)
Definition: solgame.cpp:4
static struct ID3DXConstantTableImpl * impl_from_ID3DXConstantTable(ID3DXConstantTable *iface)
Definition: shader.c:755
#define InterlockedIncrement
Definition: armddk.h:53

◆ ID3DXConstantTableImpl_GetBufferPointer()

static void* WINAPI ID3DXConstantTableImpl_GetBufferPointer ( ID3DXConstantTable *  iface)
static

Definition at line 944 of file shader.c.

945 {
947 
948  TRACE("iface %p.\n", iface);
949 
950  return table->ctab;