ReactOS 0.4.16-dev-329-g9223134
shader.c File Reference
#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  d3dx9_fragment_linker
 
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)
 
static struct d3dx9_fragment_linkerimpl_from_ID3DXFragmentLinker (ID3DXFragmentLinker *iface)
 
static HRESULT WINAPI d3dx9_fragment_linker_QueryInterface (ID3DXFragmentLinker *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3dx9_fragment_linker_AddRef (ID3DXFragmentLinker *iface)
 
static ULONG WINAPI d3dx9_fragment_linker_Release (ID3DXFragmentLinker *iface)
 
static HRESULT WINAPI d3dx9_fragment_linker_GetDevice (ID3DXFragmentLinker *iface, struct IDirect3DDevice9 **device)
 
static UINT WINAPI d3dx9_fragment_linker_GetNumberOfFragments (ID3DXFragmentLinker *iface)
 
static D3DXHANDLE WINAPI d3dx9_fragment_linker_GetFragmentHandleByIndex (ID3DXFragmentLinker *iface, UINT index)
 
static D3DXHANDLE WINAPI d3dx9_fragment_linker_GetFragmentHandleByName (ID3DXFragmentLinker *iface, const char *name)
 
static HRESULT WINAPI d3dx9_fragment_linker_GetFragmentDesc (ID3DXFragmentLinker *iface, D3DXHANDLE name, D3DXFRAGMENT_DESC *desc)
 
static HRESULT WINAPI d3dx9_fragment_linker_AddFragments (ID3DXFragmentLinker *iface, const DWORD *fragments)
 
static HRESULT WINAPI d3dx9_fragment_linker_GetAllFragments (ID3DXFragmentLinker *iface, ID3DXBuffer **buffer)
 
static HRESULT WINAPI d3dx9_fragment_linker_GetFragment (ID3DXFragmentLinker *iface, D3DXHANDLE name, ID3DXBuffer **buffer)
 
static HRESULT WINAPI d3dx9_fragment_linker_LinkShader (ID3DXFragmentLinker *iface, const char *profile, DWORD flags, const D3DXHANDLE *handles, UINT fragment_count, ID3DXBuffer **buffer, ID3DXBuffer **errors)
 
static HRESULT WINAPI d3dx9_fragment_linker_LinkVertexShader (ID3DXFragmentLinker *iface, const char *profile, DWORD flags, const D3DXHANDLE *handles, UINT fragment_count, IDirect3DVertexShader9 **shader, ID3DXBuffer **errors)
 
static HRESULT WINAPI d3dx9_fragment_linker_LinkPixelShader (ID3DXFragmentLinker *iface, const char *profile, DWORD flags, const D3DXHANDLE *handles, UINT fragment_count, IDirect3DPixelShader9 **shader, ID3DXBuffer **errors)
 
static HRESULT WINAPI d3dx9_fragment_linker_ClearCache (ID3DXFragmentLinker *iface)
 
HRESULT WINAPI D3DXCreateFragmentLinkerEx (IDirect3DDevice9 *device, UINT size, DWORD flags, ID3DXFragmentLinker **linker)
 
HRESULT WINAPI D3DXCreateFragmentLinker (IDirect3DDevice9 *device, UINT size, 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 struct ID3DXFragmentLinkerVtbl d3dx9_fragment_linker_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 2386 of file shader.c.

2387{
2388 char *buf = buffer;
2389 DWORD dst_mod = param & D3DSP_DSTMOD_MASK;
2390
2391 if (dst_mod & D3DSPDM_SATURATE)
2392 buf += sprintf(buf, "_sat");
2393 if (dst_mod & D3DSPDM_PARTIALPRECISION)
2394 buf += sprintf(buf, "_pp");
2395 if (dst_mod & D3DSPDM_MSAMPCENTROID)
2396 buf += sprintf(buf, "_centroid");
2397
2398 return buf - buffer;
2399}
@ D3DSPDM_SATURATE
Definition: d3d8types.h:385
#define D3DSP_DSTMOD_MASK
Definition: d3d8types.h:381
@ D3DSPDM_PARTIALPRECISION
Definition: d3d9types.h:494
@ D3DSPDM_MSAMPCENTROID
Definition: d3d9types.h:495
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat param
Definition: glext.h:5796
#define sprintf(buf, format,...)
Definition: sprintf.c:55

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 2401 of file shader.c.

2402{
2403 char *buf = buffer;
2406 DWORD reg_num = param & D3DSP_REGNUM_MASK;
2407
2408 if (reg_type == D3DSPR_INPUT)
2409 buf += sprintf(buf, "v%d", reg_num);
2410 else if (reg_type == D3DSPR_CONST)
2411 buf += sprintf(buf, "c%d", reg_num);
2412 else if (reg_type == D3DSPR_TEMP)
2413 buf += sprintf(buf, "r%d", reg_num);
2414 else if (reg_type == D3DSPR_ADDR)
2415 buf += sprintf(buf, "%s%d", ps ? "t" : "a", reg_num);
2416 else if (reg_type == D3DSPR_SAMPLER)
2417 buf += sprintf(buf, "s%d", reg_num);
2418 else if (reg_type == D3DSPR_RASTOUT)
2419 buf += sprintf(buf, "oPos");
2420 else if (reg_type == D3DSPR_COLOROUT)
2421 buf += sprintf(buf, "oC%d", reg_num);
2422 else if (reg_type == D3DSPR_TEXCRDOUT)
2423 buf += sprintf(buf, "oT%d", reg_num);
2424 else if (reg_type == D3DSPR_ATTROUT)
2425 buf += sprintf(buf, "oD%d", reg_num);
2426 else
2427 buf += sprintf(buf, "? (%d)", reg_type);
2428
2429 if (dst)
2430 {
2432 {
2433 buf += sprintf(buf, ".%s%s%s%s", param & D3DSP_WRITEMASK_0 ? "x" : "",
2434 param & D3DSP_WRITEMASK_1 ? "y" : "",
2435 param & D3DSP_WRITEMASK_2 ? "z" : "",
2436 param & D3DSP_WRITEMASK_3 ? "w" : "");
2437 }
2438 }
2439 else
2440 {
2442 {
2447 buf += sprintf(buf, ".%c", 'w' + (((param >> D3DVS_SWIZZLE_SHIFT) + 1) & 0x3));
2448 else
2449 buf += sprintf(buf, ".%c%c%c%c", 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+0)) + 1) & 0x3),
2450 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+2)) + 1) & 0x3),
2451 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+4)) + 1) & 0x3),
2452 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+6)) + 1) & 0x3));
2453 }
2454 }
2455
2456 return buf - buffer;
2457}
#define D3DVS_W_Z
Definition: d3d8types.h:448
#define D3DSP_WRITEMASK_ALL
Definition: d3d8types.h:378
#define D3DSP_WRITEMASK_2
Definition: d3d8types.h:376
#define D3DVS_X_Z
Definition: d3d8types.h:433
#define D3DVS_Z_Z
Definition: d3d8types.h:443
#define D3DVS_W_W
Definition: d3d8types.h:449
#define D3DVS_SWIZZLE_MASK
Definition: d3d8types.h:426
#define D3DSP_WRITEMASK_3
Definition: d3d8types.h:377
#define D3DVS_Y_Y
Definition: d3d8types.h:437
#define D3DVS_W_X
Definition: d3d8types.h:446
#define D3DSP_SWIZZLE_MASK
Definition: d3d8types.h:429
#define D3DSP_WRITEMASK_0
Definition: d3d8types.h:374
#define D3DVS_Z_X
Definition: d3d8types.h:441
#define D3DVS_Y_X
Definition: d3d8types.h:436
#define D3DVS_NOSWIZZLE
Definition: d3d8types.h:451
#define D3DSP_WRITEMASK_1
Definition: d3d8types.h:375
#define D3DVS_SWIZZLE_SHIFT
Definition: d3d8types.h:425
#define D3DSP_REGTYPE_MASK
Definition: d3d8types.h:395
#define D3DVS_X_X
Definition: d3d8types.h:431
#define D3DVS_Y_W
Definition: d3d8types.h:439
#define D3DVS_W_Y
Definition: d3d8types.h:447
#define D3DVS_Z_W
Definition: d3d8types.h:444
#define D3DVS_Y_Z
Definition: d3d8types.h:438
#define D3DVS_X_Y
Definition: d3d8types.h:432
#define D3DSP_REGTYPE_SHIFT
Definition: d3d8types.h:394
#define D3DVS_X_W
Definition: d3d8types.h:434
@ D3DSPR_RASTOUT
Definition: d3d8types.h:403
@ D3DSPR_ADDR
Definition: d3d8types.h:401
@ D3DSPR_TEMP
Definition: d3d8types.h:398
@ D3DSPR_INPUT
Definition: d3d8types.h:399
@ D3DSPR_ATTROUT
Definition: d3d8types.h:404
@ D3DSPR_CONST
Definition: d3d8types.h:400
@ D3DSPR_TEXCRDOUT
Definition: d3d8types.h:405
#define D3DVS_Z_Y
Definition: d3d8types.h:442
#define D3DSP_REGTYPE_MASK2
Definition: d3d9types.h:508
#define D3DSP_REGTYPE_SHIFT2
Definition: d3d9types.h:506
#define D3DSP_REGNUM_MASK
Definition: d3d9types.h:479
@ D3DSPR_SAMPLER
Definition: d3d9types.h:523
@ D3DSPR_COLOROUT
Definition: d3d9types.h:521
GLenum GLenum dst
Definition: glext.h:6340
type_t * reg_type(type_t *type, const char *name, struct namespace *namespace, int t)

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}
#define FIXME(fmt,...)
Definition: precomp.h:53
static CRITICAL_SECTION wpp_mutex
Definition: compiler.c:75
static char * wpp_output
Definition: compiler.c:57
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 HRESULT assemble_shader(const char *preproc_shader, ID3DBlob **shader_blob, ID3DBlob **error_messages)
Definition: compiler.c:553
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:31
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:32
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:31
static SIZE_T datasize
Definition: asm.c:30
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint shader
Definition: glext.h:6030
GLbitfield flags
Definition: glext.h:7161
#define SUCCEEDED(hr)
Definition: intsafe.h:50
const char * filename
Definition: ioapi.h:137
#define debugstr_a
Definition: kernel32.h:31
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by D3DXAssembleShader().

◆ d3dx9_fragment_linker_AddFragments()

static HRESULT WINAPI d3dx9_fragment_linker_AddFragments ( ID3DXFragmentLinker *  iface,
const DWORD fragments 
)
static

Definition at line 2224 of file shader.c.

2225{
2226 FIXME("iface %p, fragments %p: stub.\n", iface, fragments);
2227
2228 return E_NOTIMPL;
2229}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ d3dx9_fragment_linker_AddRef()

static ULONG WINAPI d3dx9_fragment_linker_AddRef ( ID3DXFragmentLinker *  iface)
static

Definition at line 2149 of file shader.c.

2150{
2152 ULONG refcount = InterlockedIncrement(&linker->ref);
2153
2154 TRACE("%p increasing refcount to %u.\n", linker, refcount);
2155
2156 return refcount;
2157}
#define InterlockedIncrement
Definition: armddk.h:53
static struct d3dx9_fragment_linker * impl_from_ID3DXFragmentLinker(ID3DXFragmentLinker *iface)
Definition: shader.c:2127
uint32_t ULONG
Definition: typedefs.h:59

◆ d3dx9_fragment_linker_ClearCache()

static HRESULT WINAPI d3dx9_fragment_linker_ClearCache ( ID3DXFragmentLinker *  iface)
static

Definition at line 2276 of file shader.c.

2277{
2278 FIXME("iface %p: stub.\n", iface);
2279
2280 return E_NOTIMPL;
2281}

◆ d3dx9_fragment_linker_GetAllFragments()

static HRESULT WINAPI d3dx9_fragment_linker_GetAllFragments ( ID3DXFragmentLinker *  iface,
ID3DXBuffer **  buffer 
)
static

Definition at line 2231 of file shader.c.

2232{
2233 FIXME("iface %p, buffer %p: stub.\n", iface, buffer);
2234
2235 return E_NOTIMPL;
2236}

◆ d3dx9_fragment_linker_GetDevice()

static HRESULT WINAPI d3dx9_fragment_linker_GetDevice ( ID3DXFragmentLinker *  iface,
struct IDirect3DDevice9 **  device 
)
static

Definition at line 2175 of file shader.c.

2176{
2178
2179 TRACE("iface %p, device %p.\n", linker, device);
2180
2181 if (!device)
2182 {
2183 WARN("Invalid argument supplied.\n");
2184 return D3DERR_INVALIDCALL;
2185 }
2186
2188 *device = linker->device;
2189 TRACE("Returning device %p.\n", *device);
2190
2191 return S_OK;
2192}
#define WARN(fmt,...)
Definition: precomp.h:61
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
#define D3DERR_INVALIDCALL
#define S_OK
Definition: intsafe.h:52
struct IDirect3DDevice9 * device
Definition: shader.c:2123
Definition: devices.h:37

◆ d3dx9_fragment_linker_GetFragment()

static HRESULT WINAPI d3dx9_fragment_linker_GetFragment ( ID3DXFragmentLinker *  iface,
D3DXHANDLE  name,
ID3DXBuffer **  buffer 
)
static

Definition at line 2238 of file shader.c.

2240{
2241 FIXME("iface %p, name %p, buffer %p: stub.\n", iface, name, buffer);
2242
2243 return E_NOTIMPL;
2244}
Definition: name.c:39

◆ d3dx9_fragment_linker_GetFragmentDesc()

static HRESULT WINAPI d3dx9_fragment_linker_GetFragmentDesc ( ID3DXFragmentLinker *  iface,
D3DXHANDLE  name,
D3DXFRAGMENT_DESC desc 
)
static

Definition at line 2216 of file shader.c.

2218{
2219 FIXME("iface %p, name %p, desc %p: stub.\n", iface, name, desc);
2220
2221 return E_NOTIMPL;
2222}
static const WCHAR desc[]
Definition: protectdata.c:36

◆ d3dx9_fragment_linker_GetFragmentHandleByIndex()

static D3DXHANDLE WINAPI d3dx9_fragment_linker_GetFragmentHandleByIndex ( ID3DXFragmentLinker *  iface,
UINT  index 
)
static

Definition at line 2201 of file shader.c.

2202{
2203 FIXME("iface %p, index %u: stub.\n", iface, index);
2204
2205 return NULL;
2206}
GLuint index
Definition: glext.h:6031

◆ d3dx9_fragment_linker_GetFragmentHandleByName()

static D3DXHANDLE WINAPI d3dx9_fragment_linker_GetFragmentHandleByName ( ID3DXFragmentLinker *  iface,
const char name 
)
static

Definition at line 2208 of file shader.c.

2210{
2211 FIXME("iface %p, name %s: stub.\n", iface, debugstr_a(name));
2212
2213 return NULL;
2214}

◆ d3dx9_fragment_linker_GetNumberOfFragments()

static UINT WINAPI d3dx9_fragment_linker_GetNumberOfFragments ( ID3DXFragmentLinker *  iface)
static

Definition at line 2194 of file shader.c.

2195{
2196 FIXME("iface %p: stub.\n", iface);
2197
2198 return E_NOTIMPL;
2199}

◆ d3dx9_fragment_linker_LinkPixelShader()

static HRESULT WINAPI d3dx9_fragment_linker_LinkPixelShader ( ID3DXFragmentLinker *  iface,
const char profile,
DWORD  flags,
const D3DXHANDLE handles,
UINT  fragment_count,
IDirect3DPixelShader9 **  shader,
ID3DXBuffer **  errors 
)
static

Definition at line 2266 of file shader.c.

2269{
2270 FIXME("iface %p, profile %s, flags %#x, handles %p, fragment_count %u, shader %p, errors %p: stub.\n",
2271 iface, debugstr_a(profile), flags, handles, fragment_count, shader, errors);
2272
2273 return E_NOTIMPL;
2274}
#define profile
Definition: kernel32.h:12
static EFI_HANDLE * handles
Definition: uefidisk.c:62

◆ d3dx9_fragment_linker_LinkShader()

static HRESULT WINAPI d3dx9_fragment_linker_LinkShader ( ID3DXFragmentLinker *  iface,
const char profile,
DWORD  flags,
const D3DXHANDLE handles,
UINT  fragment_count,
ID3DXBuffer **  buffer,
ID3DXBuffer **  errors 
)
static

Definition at line 2246 of file shader.c.

2249{
2250 FIXME("iface %p, profile %s, flags %#x, handles %p, fragment_count %u, buffer %p, errors %p: stub.\n",
2251 iface, debugstr_a(profile), flags, handles, fragment_count, buffer, errors);
2252
2253 return E_NOTIMPL;
2254}

◆ d3dx9_fragment_linker_LinkVertexShader()

static HRESULT WINAPI d3dx9_fragment_linker_LinkVertexShader ( ID3DXFragmentLinker *  iface,
const char profile,
DWORD  flags,
const D3DXHANDLE handles,
UINT  fragment_count,
IDirect3DVertexShader9 **  shader,
ID3DXBuffer **  errors 
)
static

Definition at line 2256 of file shader.c.

2259{
2260 FIXME("iface %p, profile %s, flags %#x, handles %p, fragment_count %u, shader %p, errors %p: stub.\n",
2261 iface, debugstr_a(profile), flags, handles, fragment_count, shader, errors);
2262
2263 return E_NOTIMPL;
2264}

◆ d3dx9_fragment_linker_QueryInterface()

static HRESULT WINAPI d3dx9_fragment_linker_QueryInterface ( ID3DXFragmentLinker *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 2132 of file shader.c.

2133{
2134 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2135
2137 || IsEqualGUID(riid, &IID_ID3DXFragmentLinker))
2138 {
2139 iface->lpVtbl->AddRef(iface);
2140 *out = iface;
2141 return D3D_OK;
2142 }
2143
2144 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
2145 *out = NULL;
2146 return E_NOINTERFACE;
2147}
const GUID IID_IUnknown
#define D3D_OK
Definition: d3d.h:106
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static FILE * out
Definition: regtests2xml.c:44
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ d3dx9_fragment_linker_Release()

static ULONG WINAPI d3dx9_fragment_linker_Release ( ID3DXFragmentLinker *  iface)
static

Definition at line 2159 of file shader.c.

2160{
2162 ULONG refcount = InterlockedDecrement(&linker->ref);
2163
2164 TRACE("%p decreasing refcount to %u.\n", linker, refcount);
2165
2166 if (!refcount)
2167 {
2169 heap_free(linker);
2170 }
2171
2172 return refcount;
2173}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508

◆ d3dx9_texture_shader_AddRef()

static ULONG WINAPI d3dx9_texture_shader_AddRef ( ID3DXTextureShader *  iface)
static

Definition at line 2738 of file shader.c.

2739{
2740 struct d3dx9_texture_shader *texture_shader = impl_from_ID3DXTextureShader(iface);
2741 ULONG refcount = InterlockedIncrement(&texture_shader->ref);
2742
2743 TRACE("%p increasing refcount to %u.\n", texture_shader, refcount);
2744
2745 return refcount;
2746}
static struct d3dx9_texture_shader * impl_from_ID3DXTextureShader(ID3DXTextureShader *iface)
Definition: shader.c:2716

◆ d3dx9_texture_shader_GetConstant()

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

Definition at line 2791 of file shader.c.

2792{
2793 FIXME("iface %p, constant %p, index %u stub.\n", iface, constant, index);
2794
2795 return NULL;
2796}

◆ d3dx9_texture_shader_GetConstantBuffer()

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

Definition at line 2770 of file shader.c.

2771{
2772 FIXME("iface %p, constant_buffer %p stub.\n", iface, constant_buffer);
2773
2774 return E_NOTIMPL;
2775}

◆ d3dx9_texture_shader_GetConstantByName()

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

Definition at line 2798 of file shader.c.

2799{
2800 FIXME("iface %p, constant %p, name %s stub.\n", iface, constant, debugstr_a(name));
2801
2802 return NULL;
2803}

◆ 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 2784 of file shader.c.

2785{
2786 FIXME("iface %p, constant %p, constant_desc %p, count %p stub.\n", iface, constant, constant_desc, count);
2787
2788 return E_NOTIMPL;
2789}
GLuint GLuint GLsizei count
Definition: gl.h:1545

◆ d3dx9_texture_shader_GetConstantElement()

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

Definition at line 2805 of file shader.c.

2806{
2807 FIXME("iface %p, constant %p, index %u stub.\n", iface, constant, index);
2808
2809 return NULL;
2810}

◆ d3dx9_texture_shader_GetDesc()

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

Definition at line 2777 of file shader.c.

2778{
2779 FIXME("iface %p, desc %p stub.\n", iface, desc);
2780
2781 return E_NOTIMPL;
2782}

◆ d3dx9_texture_shader_GetFunction()

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

Definition at line 2763 of file shader.c.

2764{
2765 FIXME("iface %p, function %p stub.\n", iface, function);
2766
2767 return E_NOTIMPL;
2768}

◆ d3dx9_texture_shader_QueryInterface()

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

Definition at line 2721 of file shader.c.

2722{
2723 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2724
2725 if (IsEqualGUID(riid, &IID_IUnknown) ||
2726 IsEqualGUID(riid, &IID_ID3DXTextureShader))
2727 {
2728 iface->lpVtbl->AddRef(iface);
2729 *out = iface;
2730 return D3D_OK;
2731 }
2732
2733 WARN("Interface %s not found.\n", debugstr_guid(riid));
2734 *out = NULL;
2735 return E_NOINTERFACE;
2736}

◆ d3dx9_texture_shader_Release()

static ULONG WINAPI d3dx9_texture_shader_Release ( ID3DXTextureShader *  iface)
static

Definition at line 2748 of file shader.c.

2749{
2750 struct d3dx9_texture_shader *texture_shader = impl_from_ID3DXTextureShader(iface);
2751 ULONG refcount = InterlockedDecrement(&texture_shader->ref);
2752
2753 TRACE("%p decreasing refcount to %u.\n", texture_shader, refcount);
2754
2755 if (!refcount)
2756 {
2757 HeapFree(GetProcessHeap(), 0, texture_shader);
2758 }
2759
2760 return refcount;
2761}

◆ d3dx9_texture_shader_SetBool()

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

Definition at line 2826 of file shader.c.

2827{
2828 FIXME("iface %p, constant %p, b %u stub.\n", iface, constant, b);
2829
2830 return E_NOTIMPL;
2831}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ d3dx9_texture_shader_SetBoolArray()

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

Definition at line 2833 of file shader.c.

2834{
2835 FIXME("iface %p, constant %p, b %p, count %u stub.\n", iface, constant, b, count);
2836
2837 return E_NOTIMPL;
2838}

◆ d3dx9_texture_shader_SetDefaults()

static HRESULT WINAPI d3dx9_texture_shader_SetDefaults ( ID3DXTextureShader *  iface)
static

Definition at line 2812 of file shader.c.

2813{
2814 FIXME("iface %p stub.\n", iface);
2815
2816 return E_NOTIMPL;
2817}

◆ d3dx9_texture_shader_SetFloat()

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

Definition at line 2854 of file shader.c.

2855{
2856 FIXME("iface %p, constant %p, f %f stub.\n", iface, constant, f);
2857
2858 return E_NOTIMPL;
2859}
GLfloat f
Definition: glext.h:7540

◆ d3dx9_texture_shader_SetFloatArray()

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

Definition at line 2861 of file shader.c.

2862{
2863 FIXME("iface %p, constant %p, f %p, count %u stub.\n", iface, constant, f, count);
2864
2865 return E_NOTIMPL;
2866}

◆ d3dx9_texture_shader_SetInt()

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

Definition at line 2840 of file shader.c.

2841{
2842 FIXME("iface %p, constant %p, n %d stub.\n", iface, constant, n);
2843
2844 return E_NOTIMPL;
2845}
GLdouble n
Definition: glext.h:7729

◆ d3dx9_texture_shader_SetIntArray()

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

Definition at line 2847 of file shader.c.

2848{
2849 FIXME("iface %p, constant %p, n %p, count %u stub.\n", iface, constant, n, count);
2850
2851 return E_NOTIMPL;
2852}

◆ d3dx9_texture_shader_SetMatrix()

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

Definition at line 2882 of file shader.c.

2883{
2884 FIXME("iface %p, constant %p, matrix %p stub.\n", iface, constant, matrix);
2885
2886 return E_NOTIMPL;
2887}
GLuint GLenum matrix
Definition: glext.h:9407

◆ d3dx9_texture_shader_SetMatrixArray()

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

Definition at line 2889 of file shader.c.

2890{
2891 FIXME("iface %p, constant %p, matrix %p, count %u stub.\n", iface, constant, matrix, count);
2892
2893 return E_NOTIMPL;
2894}

◆ d3dx9_texture_shader_SetMatrixPointerArray()

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

Definition at line 2896 of file shader.c.

2897{
2898 FIXME("iface %p, constant %p, matrix %p, count %u stub.\n", iface, constant, matrix, count);
2899
2900 return E_NOTIMPL;
2901}

◆ d3dx9_texture_shader_SetMatrixTranspose()

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

Definition at line 2903 of file shader.c.

2904{
2905 FIXME("iface %p, constant %p, matrix %p stub.\n", iface, constant, matrix);
2906
2907 return E_NOTIMPL;
2908}

◆ d3dx9_texture_shader_SetMatrixTransposeArray()

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

Definition at line 2910 of file shader.c.

2911{
2912 FIXME("iface %p, constant %p, matrix %p, count %u stub.\n", iface, constant, matrix, count);
2913
2914 return E_NOTIMPL;
2915}

◆ d3dx9_texture_shader_SetMatrixTransposePointerArray()

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

Definition at line 2917 of file shader.c.

2918{
2919 FIXME("iface %p, constant %p, matrix %p, count %u stub.\n", iface, constant, matrix, count);
2920
2921 return E_NOTIMPL;
2922}

◆ d3dx9_texture_shader_SetValue()

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

Definition at line 2819 of file shader.c.

2820{
2821 FIXME("iface %p, constant %p, data %p, bytes %u stub.\n", iface, constant, data, bytes);
2822
2823 return E_NOTIMPL;
2824}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74

◆ d3dx9_texture_shader_SetVector()

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

Definition at line 2868 of file shader.c.

2869{
2870 FIXME("iface %p, constant %p, vector %p stub.\n", iface, constant, vector);
2871
2872 return E_NOTIMPL;
2873}

◆ d3dx9_texture_shader_SetVectorArray()

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

Definition at line 2875 of file shader.c.

2876{
2877 FIXME("iface %p, constant %p, vector %p, count %u stub.\n", iface, constant, vector, count);
2878
2879 return E_NOTIMPL;
2880}

◆ d3dx_include_from_file_close()

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

Definition at line 306 of file shader.c.

307{
308 HeapFree(GetProcessHeap(), 0, *((char **)data - 1));
309 HeapFree(GetProcessHeap(), 0, (char **)data - 1);
310 if (main_file_data == data)
312 return S_OK;
313}
static const void * main_file_data
Definition: shader.c:218

◆ 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 236 of file shader.c.

238{
239 const char *p, *parent_name = "";
240 char *pathname = NULL, *ptr;
241 char **buffer = NULL;
242 HANDLE file;
243 UINT size;
244
245 if (parent_data)
246 {
247 parent_name = *((const char **)parent_data - 1);
248 }
249 else
250 {
251 if (main_file_data)
252 parent_name = *((const char **)main_file_data - 1);
253 }
254
255 TRACE("Looking up include file %s, parent %s.\n", debugstr_a(filename), debugstr_a(parent_name));
256
257 if ((p = strrchr(parent_name, '\\')))
258 ++p;
259 else
260 p = parent_name;
261 pathname = HeapAlloc(GetProcessHeap(), 0, (p - parent_name) + strlen(filename) + 1);
262 if(!pathname)
264
265 memcpy(pathname, parent_name, p - parent_name);
266 strcpy(pathname + (p - parent_name), filename);
267 ptr = pathname + (p - parent_name);
268 while (*ptr)
269 {
270 if (*ptr == '/')
271 *ptr = '\\';
272 ++ptr;
273 }
274
277 goto error;
278
279 TRACE("Include file found at pathname = %s\n", debugstr_a(pathname));
280
283 goto error;
284
285 buffer = HeapAlloc(GetProcessHeap(), 0, size + sizeof(char *));
286 if(!buffer)
287 goto error;
288 *buffer = pathname;
289 if(!ReadFile(file, buffer + 1, size, bytes, NULL))
290 goto error;
291
292 *data = buffer + 1;
293 if (!main_file_data)
295
297 return S_OK;
298
299error:
304}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
GLsizeiptr size
Definition: glext.h:5919
GLfloat GLfloat p
Definition: glext.h:8902
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char pathname[512]
Definition: util.h:13
static PVOID ptr
Definition: dispmode.c:27
unsigned int UINT
Definition: ndis.h:50
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
Definition: fci.c:127
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define INVALID_FILE_SIZE
Definition: winbase.h:574
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

◆ d3dx_shader_get_ctab_constant()

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

Definition at line 984 of file shader.c.

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

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 200 of file shader.c.

202{
203 HRESULT hr;
204
205 TRACE("data %p, data_len %u, defines %p, include %p, flags %#x, shader %p, error_messages %p\n",
207
208 /* Forward to d3dcompiler: the parameter types aren't really different,
209 the actual data types are equivalent */
213
215 return hr;
216}
#define D3DXERR_INVALIDDATA
Definition: compiler.c:30
#define E_FAIL
Definition: ddrawi.h:102
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

Referenced by assembleshader_test(), 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 321 of file shader.c.

323{
324 WCHAR *filename_w;
325 DWORD len;
326 HRESULT ret;
327
328 TRACE("filename %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
330
331 if (!filename) return D3DXERR_INVALIDDATA;
332
334 filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
335 if (!filename_w) return E_OUTOFMEMORY;
336 MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
337
339
340 HeapFree(GetProcessHeap(), 0, filename_w);
341 return ret;
342}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI D3DXAssembleShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:344
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by assembleshader_test().

◆ D3DXAssembleShaderFromFileW()

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

Definition at line 344 of file shader.c.

346{
347 const void *buffer;
348 DWORD len;
349 HRESULT hr;
350 struct d3dx_include_from_file include_from_file;
351 char *filename_a;
352
353 TRACE("filename %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
355
356 if(!include)
357 {
358 include_from_file.ID3DXInclude_iface.lpVtbl = &d3dx_include_from_file_vtbl;
359 include = &include_from_file.ID3DXInclude_iface;
360 }
361
363 filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
364 if (!filename_a)
365 return E_OUTOFMEMORY;
366 WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
367
370 if (FAILED(hr))
371 {
373 HeapFree(GetProcessHeap(), 0, filename_a);
374 return D3DXERR_INVALIDDATA;
375 }
376
378
381 HeapFree(GetProcessHeap(), 0, filename_a);
382 return hr;
383}
@ D3DXINC_LOCAL
Definition: d3dx9shader.h:288
#define ID3DXInclude_Close(p, a)
Definition: d3dx9shader.h:304
#define ID3DXInclude_Open(p, a, b, c, d, e)
Definition: d3dx9shader.h:303
CRITICAL_SECTION from_file_mutex
Definition: shader.c:229
HRESULT WINAPI D3DXAssembleShader(const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:200
const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl
Definition: shader.c:315
#define WideCharToMultiByte
Definition: compat.h:111
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32

Referenced by assembleshader_test(), and 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 385 of file shader.c.

387{
388 void *buffer;
389 HRSRC res;
390 DWORD len;
391
392 TRACE("module %p, resource %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
394
395 if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
396 return D3DXERR_INVALIDDATA;
398 return D3DXERR_INVALIDDATA;
401}
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:170
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
GLuint res
Definition: glext.h:9613
#define RT_RCDATA
Definition: pedump.c:372

Referenced by assembleshader_test().

◆ D3DXAssembleShaderFromResourceW()

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

Definition at line 403 of file shader.c.

405{
406 void *buffer;
407 HRSRC res;
408 DWORD len;
409
410 TRACE("module %p, resource %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
412
413 if (!(res = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
414 return D3DXERR_INVALIDDATA;
416 return D3DXERR_INVALIDDATA;
419}
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176

◆ 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 421 of file shader.c.

424{
425 HRESULT hr;
426
427 TRACE("data %s, length %u, defines %p, include %p, function %s, profile %s, "
428 "flags %#x, shader %p, error_msgs %p, constant_table %p.\n",
430 flags, shader, error_msgs, constant_table);
431
432 if (D3DX_SDK_VERSION <= 36)
434
436 function, profile, flags, 0, (ID3DBlob **)shader, (ID3DBlob **)error_msgs);
437
438 if (SUCCEEDED(hr) && constant_table)
439 {
441 if (FAILED(hr))
442 {
444 *shader = NULL;
445 }
446 }
447
448 /* Filter out D3DCompile warning messages that are not present with D3DCompileShader */
449 if (SUCCEEDED(hr) && error_msgs && *error_msgs)
450 {
451 char *messages = ID3DXBuffer_GetBufferPointer(*error_msgs);
452 DWORD size = ID3DXBuffer_GetBufferSize(*error_msgs);
453
454 /* Ensure messages are null terminated for safe processing */
455 if (size) messages[size - 1] = 0;
456
457 while (size > 1)
458 {
459 char *prev, *next;
460
461 /* Warning has the form "warning X3206: ... implicit truncation of vector type"
462 but we only search for "X3206:" in case d3dcompiler_43 has localization */
463 prev = next = strstr(messages, "X3206:");
464 if (!prev) break;
465
466 /* get pointer to beginning and end of current line */
467 while (prev > messages && *(prev - 1) != '\n') prev--;
468 while (next < messages + size - 1 && *next != '\n') next++;
469 if (next < messages + size - 1 && *next == '\n') next++;
470
471 memmove(prev, next, messages + size - next);
472 size -= (next - prev);
473 }
474
475 /* Only return a buffer if the resulting string is not empty as some apps depend on that */
476 if (size <= 1)
477 {
478 ID3DXBuffer_Release(*error_msgs);
479 *error_msgs = NULL;
480 }
481 }
482
483 return hr;
484}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
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
#define D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY
Definition: d3dcompiler.h:51
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
#define D3DX_SDK_VERSION
Definition: d3dx9core.h:31
HRESULT WINAPI D3DXGetShaderConstantTable(const DWORD *byte_code, ID3DXConstantTable **constant_table)
Definition: shader.c:2111
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static unsigned __int64 next
Definition: rand_nt.c:6

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 486 of file shader.c.

489{
490 WCHAR *filename_w;
491 DWORD len;
492 HRESULT ret;
493
494 TRACE("filename %s, defines %p, include %p, entrypoint %s, profile %s, "
495 "flags %#x, shader %p, error_messages %p, constant_table %p.\n",
497 debugstr_a(profile), flags, shader, error_messages, constant_table);
498
499 if (!filename) return D3DXERR_INVALIDDATA;
500
502 filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
503 if (!filename_w) return E_OUTOFMEMORY;
504 MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
505
507 entrypoint, profile, flags,
508 shader, error_messages, constant_table);
509
510 HeapFree(GetProcessHeap(), 0, filename_w);
511 return ret;
512}
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:514

◆ 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 514 of file shader.c.

517{
518 const void *buffer;
519 DWORD len, filename_len;
520 HRESULT hr;
521 struct d3dx_include_from_file include_from_file;
522 char *filename_a;
523
524 TRACE("filename %s, defines %p, include %p, entrypoint %s, profile %s, "
525 "flags %#x, shader %p, error_messages %p, constant_table %p.\n",
527 flags, shader, error_messages, constant_table);
528
529 if (!include)
530 {
531 include_from_file.ID3DXInclude_iface.lpVtbl = &d3dx_include_from_file_vtbl;
532 include = &include_from_file.ID3DXInclude_iface;
533 }
534
535 filename_len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
536 filename_a = HeapAlloc(GetProcessHeap(), 0, filename_len * sizeof(char));
537 if (!filename_a)
538 return E_OUTOFMEMORY;
539 WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, filename_len, NULL, NULL);
540
543 if (FAILED(hr))
544 {
546 HeapFree(GetProcessHeap(), 0, filename_a);
547 return D3DXERR_INVALIDDATA;
548 }
549
550 if (D3DX_SDK_VERSION <= 36)
552
553 hr = D3DCompile(buffer, len, filename_a, (const D3D_SHADER_MACRO *)defines,
554 (ID3DInclude *)include, entrypoint, profile, flags, 0,
556
557 if (SUCCEEDED(hr) && constant_table)
559 constant_table);
560
563 HeapFree(GetProcessHeap(), 0, filename_a);
564 return hr;
565}

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 567 of file shader.c.

570{
571 void *buffer;
572 HRSRC res;
573 DWORD len;
574
575 TRACE("module %p, resource %s, defines %p, include %p, entrypoint %s, profile %s, "
576 "flags %#x, shader %p, error_messages %p, constant_table %p.\n",
578 flags, shader, error_messages, constant_table);
579
580 if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
581 return D3DXERR_INVALIDDATA;
583 return D3DXERR_INVALIDDATA;
584 return D3DXCompileShader(buffer, len, defines, include, entrypoint, profile,
585 flags, shader, error_messages, constant_table);
586}
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:421

◆ 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 588 of file shader.c.

591{
592 void *buffer;
593 HRSRC res;
594 DWORD len;
595
596 TRACE("module %p, resource %s, defines %p, include %p, entrypoint %s, profile %s, "
597 "flags %#x, shader %p, error_messages %p, constant_table %p.\n",
599 flags, shader, error_messages, constant_table);
600
601 if (!(res = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
602 return D3DXERR_INVALIDDATA;
604 return D3DXERR_INVALIDDATA;
605 return D3DXCompileShader(buffer, len, defines, include, entrypoint, profile,
606 flags, shader, error_messages, constant_table);
607}

◆ D3DXCreateFragmentLinker()

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

Definition at line 2325 of file shader.c.

2326{
2327 TRACE("device %p, size %u, linker %p.\n", device, size, linker);
2328
2329 return D3DXCreateFragmentLinkerEx(device, size, 0, linker);
2330}
HRESULT WINAPI D3DXCreateFragmentLinkerEx(IDirect3DDevice9 *device, UINT size, DWORD flags, ID3DXFragmentLinker **linker)
Definition: shader.c:2302

Referenced by test_fragment_linker().

◆ D3DXCreateFragmentLinkerEx()

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

Definition at line 2302 of file shader.c.

2304{
2306
2307 TRACE("device %p, size %u, flags %#x, linker %p.\n", device, size, flags, linker);
2308
2309 object = heap_alloc(sizeof(*object));
2310 if (!object)
2311 return E_OUTOFMEMORY;
2312
2313 object->ID3DXFragmentLinker_iface.lpVtbl = &d3dx9_fragment_linker_vtbl;
2314 object->ref = 1;
2315
2317 object->device = device;
2318 object->flags = flags;
2319
2320 *linker = &object->ID3DXFragmentLinker_iface;
2321
2322 return S_OK;
2323}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static const struct ID3DXFragmentLinkerVtbl d3dx9_fragment_linker_vtbl
Definition: shader.c:2283

Referenced by D3DXCreateFragmentLinker(), and test_fragment_linker().

◆ D3DXCreateTextureShader()

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

Definition at line 2956 of file shader.c.

2957{
2959
2960 TRACE("function %p, texture_shader %p.\n", function, texture_shader);
2961
2962 if (!function || !texture_shader)
2963 return D3DERR_INVALIDCALL;
2964
2965 object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
2966 if (!object)
2967 return E_OUTOFMEMORY;
2968
2969 object->ID3DXTextureShader_iface.lpVtbl = &d3dx9_texture_shader_vtbl;
2970 object->ref = 1;
2971
2972 *texture_shader = &object->ID3DXTextureShader_iface;
2973
2974 return D3D_OK;
2975}
static const struct ID3DXTextureShaderVtbl d3dx9_texture_shader_vtbl
Definition: shader.c:2924

Referenced by test_texture_shader().

◆ D3DXDisassembleShader()

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

Definition at line 2645 of file shader.c.

2646{
2647 DWORD *ptr = (DWORD *)shader;
2648 char *buffer, *buf;
2649 UINT capacity = 4096;
2650 BOOL ps;
2651 WORD version;
2652 HRESULT hr;
2653
2654 TRACE("%p %d %s %p\n", shader, colorcode, debugstr_a(comments), disassembly);
2655
2656 if (!shader || !disassembly)
2657 return D3DERR_INVALIDCALL;
2658
2659 buf = buffer = HeapAlloc(GetProcessHeap(), 0, capacity);
2660 if (!buffer)
2661 return E_OUTOFMEMORY;
2662
2663 ps = (*ptr >> 16) & 1;
2664 version = *ptr & 0xFFFF;
2665 buf += sprintf(buf, " %s_%d_%d\n", ps ? "ps" : "vs", D3DSHADER_VERSION_MAJOR(*ptr), D3DSHADER_VERSION_MINOR(*ptr));
2666 ptr++;
2667
2668 while (*ptr != D3DSIO_END)
2669 {
2670 DWORD index;
2671
2672 if ((buf - buffer + 128) > capacity)
2673 {
2674 UINT count = buf - buffer;
2675 char *new_buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, capacity * 2);
2676 if (!new_buffer)
2677 {
2679 return E_OUTOFMEMORY;
2680 }
2681 capacity *= 2;
2682 buffer = new_buffer;
2683 buf = buffer + count;
2684 }
2685
2686 for (index = 0; index < sizeof(instructions)/sizeof(instructions[0]); index++)
2687 if (((*ptr & D3DSI_OPCODE_MASK) == instructions[index].opcode) &&
2688 (version >= instructions[index].min_version) && (version <= instructions[index].max_version))
2689 break;
2690
2691 if (index != sizeof(instructions)/sizeof(instructions[0]))
2692 {
2693 buf += instructions[index].function(&(instructions[index]), &ptr, buf, ps);
2694 }
2695 else
2696 {
2697 buf += sprintf(buf, " ??? (Unknown opcode %x)\n", *ptr);
2698 while (*++ptr & (1u << 31));
2699 }
2700 }
2701
2702 hr = D3DXCreateBuffer(buf - buffer + 1 , disassembly);
2703 if (SUCCEEDED(hr))
2706
2707 return hr;
2708}
#define index(s, c)
Definition: various.h:29
#define D3DSI_OPCODE_MASK
Definition: d3d8types.h:306
#define D3DSHADER_VERSION_MAJOR(version)
Definition: d3d8types.h:476
#define D3DSHADER_VERSION_MINOR(version)
Definition: d3d8types.h:477
@ D3DSIO_END
Definition: d3d8types.h:365
char comments[4096]
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:131
const struct instr_info instructions[]
Definition: shader.c:2553
#define HeapReAlloc
Definition: compat.h:734
static const WCHAR version[]
Definition: asmname.c:66
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93

Referenced by test_disassemble_shader().

◆ D3DXFindShaderComment()

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

Definition at line 150 of file shader.c.

151{
152 const DWORD *ptr = byte_code;
154
155 TRACE("byte_code %p, fourcc %x, data %p, size %p\n", byte_code, fourcc, data, size);
156
157 if (data) *data = NULL;
158 if (size) *size = 0;
159
160 if (!byte_code) return D3DERR_INVALIDCALL;
161
162 version = *ptr >> 16;
163 if (version != 0x4658 /* FX */
164 && version != 0x5458 /* TX */
165 && version != 0x7ffe
166 && version != 0x7fff
167 && version != 0xfffe /* VS */
168 && version != 0xffff) /* PS */
169 {
170 WARN("Invalid data supplied\n");
171 return D3DXERR_INVALIDDATA;
172 }
173
174 while (*++ptr != D3DSIO_END)
175 {
176 /* Check if it is a comment */
178 {
180
181 /* Check if this is the comment we are looking for */
182 if (*(ptr + 1) == fourcc)
183 {
184 UINT ctab_size = (comment_size - 1) * sizeof(DWORD);
185 const void *ctab_data = ptr + 2;
186 if (size)
187 *size = ctab_size;
188 if (data)
189 *data = ctab_data;
190 TRACE("Returning comment data at %p with size %d\n", ctab_data, ctab_size);
191 return D3D_OK;
192 }
193 ptr += comment_size;
194 }
195 }
196
197 return S_FALSE;
198}
#define D3DSI_COMMENTSIZE_SHIFT
Definition: d3d8types.h:479
#define D3DSI_COMMENTSIZE_MASK
Definition: d3d8types.h:480
@ D3DSIO_COMMENT
Definition: d3d8types.h:364
#define S_FALSE
Definition: winerror.h:2357

Referenced by D3DXGetShaderConstantTableEx(), D3DXGetShaderSamplers(), and test_find_shader_comment().

◆ D3DXGetPixelShaderProfile()

const char *WINAPI D3DXGetPixelShaderProfile ( struct IDirect3DDevice9 *  device)

Definition at line 43 of file shader.c.

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

◆ D3DXGetShaderConstantTable()

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

Definition at line 2111 of file shader.c.

2112{
2113 TRACE("(%p, %p): Forwarded to D3DXGetShaderConstantTableEx\n", byte_code, constant_table);
2114
2115 return D3DXGetShaderConstantTableEx(byte_code, 0, constant_table);
2116}
HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags, ID3DXConstantTable **constant_table)
Definition: shader.c:1993

Referenced by compile_pixel_shader9(), D3DXCompileShader(), D3DXCompileShaderFromFileW(), get_constants_desc(), test_constant_table(), test_get_sampler_index(), test_get_shader_constant_variables(), test_registerset(), test_registerset_defaults(), test_SetDefaults(), test_setting_arrays_table(), test_setting_basic_table(), test_setting_matrices_table(), and test_SetValue().

◆ D3DXGetShaderConstantTableEx()

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

Definition at line 1993 of file shader.c.

1994{
1995 struct ID3DXConstantTableImpl *object = NULL;
1996 const void *data;
1997 HRESULT hr;
1998 UINT size;
1999 const D3DXSHADER_CONSTANTTABLE *ctab_header;
2000 const D3DXSHADER_CONSTANTINFO *constant_info;
2001 DWORD i;
2002
2003 TRACE("byte_code %p, flags %x, constant_table %p\n", byte_code, flags, constant_table);
2004
2005 if (constant_table) *constant_table = NULL;
2006
2007 if (!byte_code || !constant_table)
2008 {
2009 WARN("Invalid argument specified.\n");
2010 return D3DERR_INVALIDCALL;
2011 }
2012
2013 if (!is_valid_bytecode(*byte_code))
2014 {
2015 WARN("Invalid byte_code specified.\n");
2016 return D3D_OK;
2017 }
2018
2019 if (flags) FIXME("Flags (%#x) are not handled, yet!\n", flags);
2020
2021 hr = D3DXFindShaderComment(byte_code, MAKEFOURCC('C','T','A','B'), &data, &size);
2022 if (hr != D3D_OK)
2023 {
2024 WARN("CTAB not found.\n");
2025 return D3DXERR_INVALIDDATA;
2026 }
2027
2028 if (size < sizeof(*ctab_header))
2029 {
2030 WARN("Invalid CTAB size.\n");
2031 return D3DXERR_INVALIDDATA;
2032 }
2033
2034 ctab_header = (const D3DXSHADER_CONSTANTTABLE *)data;
2035 if (ctab_header->Size != sizeof(*ctab_header))
2036 {
2037 WARN("Invalid D3DXSHADER_CONSTANTTABLE size.\n");
2038 return D3DXERR_INVALIDDATA;
2039 }
2040
2041 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
2042 if (!object)
2043 return E_OUTOFMEMORY;
2044
2045 object->ID3DXConstantTable_iface.lpVtbl = &ID3DXConstantTable_Vtbl;
2046 object->ref = 1;
2047
2048 object->ctab = HeapAlloc(GetProcessHeap(), 0, size);
2049 if (!object->ctab)
2050 {
2051 ERR("Out of memory\n");
2052 HeapFree(GetProcessHeap(), 0, object);
2053 return E_OUTOFMEMORY;
2054 }
2055 object->size = size;
2056 memcpy(object->ctab, data, object->size);
2057
2058 object->desc.Creator = ctab_header->Creator ? object->ctab + ctab_header->Creator : NULL;
2059 object->desc.Version = ctab_header->Version;
2060 object->desc.Constants = ctab_header->Constants;
2061 TRACE("Creator %s, Version %x, Constants %u, Target %s\n",
2062 debugstr_a(object->desc.Creator), object->desc.Version, object->desc.Constants,
2063 debugstr_a(ctab_header->Target ? object->ctab + ctab_header->Target : NULL));
2064
2065 object->constants = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
2066 sizeof(*object->constants) * object->desc.Constants);
2067 if (!object->constants)
2068 {
2069 ERR("Out of memory\n");
2070 hr = E_OUTOFMEMORY;
2071 goto error;
2072 }
2073
2074 constant_info = (const D3DXSHADER_CONSTANTINFO *)(object->ctab + ctab_header->ConstantInfo);
2075 for (i = 0; i < ctab_header->Constants; i++)
2076 {
2077 DWORD offset = constant_info[i].DefaultValue;
2078
2079 hr = parse_ctab_constant_type(object->ctab, constant_info[i].TypeInfo,
2080 &object->constants[i], FALSE, constant_info[i].RegisterIndex,
2081 constant_info[i].RegisterIndex + constant_info[i].RegisterCount,
2082 offset ? &offset : NULL, constant_info[i].Name, constant_info[i].RegisterSet);
2083 if (hr != D3D_OK)
2084 goto error;
2085
2086 /*
2087 * Set the register count, it may differ for D3DXRS_INT4, because somehow
2088 * it makes the assumption that the register size is 1 instead of 4, so the
2089 * count is 4 times bigger. This holds true only for toplevel shader
2090 * constants. The count of elements and members is always based on a
2091 * register size of 4.
2092 */
2093 if (object->constants[i].desc.RegisterSet == D3DXRS_INT4)
2094 {
2095 object->constants[i].desc.RegisterCount = constant_info[i].RegisterCount;
2096 }
2097 object->constants[i].constantinfo_reserved = constant_info[i].Reserved;
2098 }
2099
2100 *constant_table = &object->ID3DXConstantTable_iface;
2101
2102 return D3D_OK;
2103
2104error:
2105 free_constant_table(object);
2106 HeapFree(GetProcessHeap(), 0, object);
2107
2108 return hr;
2109}
#define ERR(fmt,...)
Definition: precomp.h:57
@ D3DXRS_INT4
Definition: d3dx9shader.h:54
#define FALSE
Definition: types.h:117
static void free_constant_table(struct ID3DXConstantTableImpl *table)
Definition: shader.c:747
HRESULT WINAPI D3DXFindShaderComment(const DWORD *byte_code, DWORD fourcc, const void **data, UINT *size)
Definition: shader.c:150
static BOOL is_valid_bytecode(DWORD token)
Definition: shader.c:38
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:1855
static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl
Definition: shader.c:1821
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define MAKEFOURCC(ch0, ch1, ch2, ch3)
Definition: dmdls.h:24
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by D3DXGetShaderConstantTable(), and test_get_shader_constant_table_ex().

◆ D3DXGetShaderInputSemantics()

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

Definition at line 3211 of file shader.c.

3212{
3213 TRACE("byte_code %p, semantics %p, count %p.\n", byte_code, semantics, count);
3214
3215 return get_shader_semantics(byte_code, semantics, count, FALSE);
3216}
static HRESULT get_shader_semantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count, BOOL output)
Definition: shader.c:3010

Referenced by test_shader_semantics().

◆ D3DXGetShaderOutputSemantics()

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

Definition at line 3218 of file shader.c.

3219{
3220 TRACE("byte_code %p, semantics %p, count %p.\n", byte_code, semantics, count);
3221
3222 return get_shader_semantics(byte_code, semantics, count, TRUE);
3223}
#define TRUE
Definition: types.h:120

Referenced by test_shader_semantics().

◆ D3DXGetShaderSamplers()

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

Definition at line 2332 of file shader.c.

2333{
2334 UINT i, sampler_count = 0;
2335 UINT size;
2336 const char *data;
2337 const D3DXSHADER_CONSTANTTABLE *ctab_header;
2338 const D3DXSHADER_CONSTANTINFO *constant_info;
2339
2340 TRACE("byte_code %p, samplers %p, count %p\n", byte_code, samplers, count);
2341
2342 if (count) *count = 0;
2343
2344 if (D3DXFindShaderComment(byte_code, MAKEFOURCC('C','T','A','B'), (const void **)&data, &size) != D3D_OK)
2345 return D3D_OK;
2346
2347 if (size < sizeof(*ctab_header)) return D3D_OK;
2348
2349 ctab_header = (const D3DXSHADER_CONSTANTTABLE *)data;
2350 if (ctab_header->Size != sizeof(*ctab_header)) return D3D_OK;
2351
2352 constant_info = (const D3DXSHADER_CONSTANTINFO *)(data + ctab_header->ConstantInfo);
2353 for (i = 0; i < ctab_header->Constants; i++)
2354 {
2356
2357 TRACE("name = %s\n", data + constant_info[i].Name);
2358
2359 type = (const D3DXSHADER_TYPEINFO *)(data + constant_info[i].TypeInfo);
2360
2361 if (type->Type == D3DXPT_SAMPLER
2362 || type->Type == D3DXPT_SAMPLER1D
2363 || type->Type == D3DXPT_SAMPLER2D
2364 || type->Type == D3DXPT_SAMPLER3D
2365 || type->Type == D3DXPT_SAMPLERCUBE)
2366 {
2367 if (samplers) samplers[sampler_count] = data + constant_info[i].Name;
2368
2369 ++sampler_count;
2370 }
2371 }
2372
2373 TRACE("Found %u samplers\n", sampler_count);
2374
2375 if (count) *count = sampler_count;
2376
2377 return D3D_OK;
2378}
@ D3DXPT_SAMPLER3D
Definition: d3dx9shader.h:86
@ D3DXPT_SAMPLERCUBE
Definition: d3dx9shader.h:87
@ D3DXPT_SAMPLER
Definition: d3dx9shader.h:83
@ D3DXPT_SAMPLER1D
Definition: d3dx9shader.h:84
@ D3DXPT_SAMPLER2D
Definition: d3dx9shader.h:85
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint * samplers
Definition: glext.h:7280
__in WDFOBJECT __in PCWDF_OBJECT_CONTEXT_TYPE_INFO TypeInfo
Definition: handleapi.cpp:601

Referenced by test_get_shader_samplers().

◆ D3DXGetShaderSize()

UINT WINAPI D3DXGetShaderSize ( const DWORD byte_code)

Definition at line 91 of file shader.c.

92{
93 const DWORD *ptr = byte_code;
94
95 TRACE("byte_code %p\n", byte_code);
96
97 if (!ptr) return 0;
98
99 /* Look for the END token, skipping the VERSION token */
100 while (*++ptr != D3DSIO_END)
101 {
102 /* Skip comments */
104 {
106 }
107 }
108 ++ptr;
109
110 /* Return the shader size in bytes */
111 return (ptr - byte_code) * sizeof(*ptr);
112}

Referenced by test_get_shader_size().

◆ D3DXGetShaderVersion()

DWORD WINAPI D3DXGetShaderVersion ( const DWORD byte_code)

Definition at line 114 of file shader.c.

115{
116 TRACE("byte_code %p\n", byte_code);
117
118 return byte_code ? *byte_code : 0;
119}

Referenced by test_get_shader_version().

◆ D3DXGetVertexShaderProfile()

const char *WINAPI D3DXGetVertexShaderProfile ( struct IDirect3DDevice9 *  device)

Definition at line 121 of file shader.c.

122{
123 D3DCAPS9 caps;
124
125 TRACE("device %p\n", device);
126
127 if (!device) return NULL;
128
130
131 switch (caps.VertexShaderVersion)
132 {
133 case D3DVS_VERSION(1, 1):
134 return "vs_1_1";
135 case D3DVS_VERSION(2, 0):
136 if ((caps.VS20Caps.NumTemps>=13) &&
137 (caps.VS20Caps.DynamicFlowControlDepth==24) &&
138 (caps.VS20Caps.Caps&D3DPS20CAPS_PREDICATION))
139 {
140 return "vs_2_a";
141 }
142 return "vs_2_0";
143 case D3DVS_VERSION(3, 0):
144 return "vs_3_0";
145 }
146
147 return NULL;
148}
#define D3DVS_VERSION(major, minor)
Definition: d3d8types.h:475
DWORD VertexShaderVersion
Definition: d3d9caps.h:313

◆ D3DXPreprocessShader()

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

Definition at line 609 of file shader.c.

611{
612 TRACE("data %s, data_len %u, defines %p, include %p, shader %p, error_messages %p.\n",
614
615 return D3DPreprocess(data, data_len, NULL,
618}
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

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 620 of file shader.c.

622{
623 WCHAR *filename_w = NULL;
624 DWORD len;
625 HRESULT ret;
626
627 TRACE("filename %s, defines %p, include %p, shader %p, error_messages %p.\n",
629
630 if (!filename) return D3DXERR_INVALIDDATA;
631
633 filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
634 if (!filename_w) return E_OUTOFMEMORY;
635 MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
636
638
639 HeapFree(GetProcessHeap(), 0, filename_w);
640 return ret;
641}
HRESULT WINAPI D3DXPreprocessShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:643

Referenced by d3dxpreprocess_test().

◆ D3DXPreprocessShaderFromFileW()

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

Definition at line 643 of file shader.c.

645{
646 const void *buffer;
647 DWORD len;
648 HRESULT hr;
649 struct d3dx_include_from_file include_from_file;
650 char *filename_a;
651
652 TRACE("filename %s, defines %p, include %p, shader %p, error_messages %p.\n",
654
655 if (!include)
656 {
657 include_from_file.ID3DXInclude_iface.lpVtbl = &d3dx_include_from_file_vtbl;
658 include = &include_from_file.ID3DXInclude_iface;
659 }
660
662 filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
663 if (!filename_a)
664 return E_OUTOFMEMORY;
665 WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
666
669 if (FAILED(hr))
670 {
672 HeapFree(GetProcessHeap(), 0, filename_a);
673 return D3DXERR_INVALIDDATA;
674 }
675
677 (const D3D_SHADER_MACRO *)defines,
680
683 HeapFree(GetProcessHeap(), 0, filename_a);
684 return hr;
685}

Referenced by d3dxpreprocess_test(), and D3DXPreprocessShaderFromFileA().

◆ D3DXPreprocessShaderFromResourceA()

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

Definition at line 687 of file shader.c.

689{
690 void *buffer;
691 HRSRC res;
692 DWORD len;
693
694 TRACE("module %p, resource %s, defines %p, include %p, shader %p, error_messages %p.\n",
696
697 if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
698 return D3DXERR_INVALIDDATA;
700 return D3DXERR_INVALIDDATA;
703}
HRESULT WINAPI D3DXPreprocessShader(const char *data, UINT data_len, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
Definition: shader.c:609

Referenced by d3dxpreprocess_test().

◆ D3DXPreprocessShaderFromResourceW()

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

Definition at line 705 of file shader.c.

707{
708 void *buffer;
709 HRSRC res;
710 DWORD len;
711
712 TRACE("module %p, resource %s, defines %p, include %p, shader %p, error_messages %p.\n",
714
715 if (!(res = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
716 return D3DXERR_INVALIDDATA;
718 return D3DXERR_INVALIDDATA;
721
722}

◆ free_constant()

static void free_constant ( struct ctab_constant constant)
static

Definition at line 733 of file shader.c.

734{
735 if (constant->constants)
736 {
737 UINT i, count = constant->desc.Elements > 1 ? constant->desc.Elements : constant->desc.StructMembers;
738
739 for (i = 0; i < count; ++i)
740 {
741 free_constant(&constant->constants[i]);
742 }
743 HeapFree(GetProcessHeap(), 0, constant->constants);
744 }
745}
static void free_constant(struct ctab_constant *constant)
Definition: shader.c:733

Referenced by free_constant(), free_constant_table(), and parse_ctab_constant_type().

◆ free_constant_table()

static void free_constant_table ( struct ID3DXConstantTableImpl table)
static

Definition at line 747 of file shader.c.

748{
749 if (table->constants)
750 {
751 UINT i;
752
753 for (i = 0; i < table->desc.Constants; ++i)
754 {
755 free_constant(&table->constants[i]);
756 }
757 HeapFree(GetProcessHeap(), 0, table->constants);
758 }
759 HeapFree(GetProcessHeap(), 0, table->ctab);
760}

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 818 of file shader.c.

820{
821 UINT i, count, length;
822 struct ctab_constant *handles;
823 const char *part;
824
825 TRACE("table %p, constant %p, name %s\n", table, constant, debugstr_a(name));
826
827 if (!name || !*name) return NULL;
828
829 if (!constant)
830 {
831 count = table->desc.Constants;
832 handles = table->constants;
833 }
834 else
835 {
836 count = constant->desc.StructMembers;
837 handles = constant->constants;
838 }
839
840 length = strcspn(name, "[.");
841 part = name + length;
842
843 for (i = 0; i < count; i++)
844 {
845 if (strlen(handles[i].desc.Name) == length && !strncmp(handles[i].desc.Name, name, length))
846 {
847 switch (*part++)
848 {
849 case '.':
850 return get_constant_by_name(NULL, &handles[i], part);
851
852 case '[':
853 return get_constant_element_by_name(&handles[i], part);
854
855 default:
856 TRACE("Returning parameter %p\n", &handles[i]);
857 return &handles[i];
858 }
859 }
860 }
861
862 TRACE("Constant not found\n");
863 return NULL;
864}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static struct ctab_constant * get_constant_element_by_name(struct ctab_constant *constant, const char *name)
Definition: shader.c:780
static struct ctab_constant * get_constant_by_name(struct ID3DXConstantTableImpl *table, struct ctab_constant *constant, const char *name)
Definition: shader.c:818
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)

Referenced by get_constant_by_name(), 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 780 of file shader.c.

781{
782 const char *part;
784
785 TRACE("constant %p, name %s\n", constant, debugstr_a(name));
786
787 if (!name || !*name) return NULL;
788
789 element = atoi(name);
790 part = strchr(name, ']') + 1;
791
792 if (constant->desc.Elements > element)
793 {
794 struct ctab_constant *c = constant->constants ? &constant->constants[element] : constant;
795
796 switch (*part++)
797 {
798 case '.':
799 return get_constant_by_name(NULL, c, part);
800
801 case '[':
802 return get_constant_element_by_name(c, part);
803
804 case '\0':
805 TRACE("Returning parameter %p\n", c);
806 return c;
807
808 default:
809 FIXME("Unhandled case \"%c\"\n", *--part);
810 break;
811 }
812 }
813
814 TRACE("Constant not found\n");
815 return NULL;
816}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
const GLubyte * c
Definition: glext.h:8905
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define c
Definition: ke_i.h:80

Referenced by get_constant_by_name(), and get_constant_element_by_name().

◆ get_index()

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

Definition at line 1091 of file shader.c.

1092{
1093 if (!indata)
1094 return 0;
1095
1096 if (is_pointer)
1097 return ((DWORD **)indata)[index / 16][index % 16];
1098
1099 return (*((DWORD **)indata))[index];
1100}

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 2977 of file shader.c.

2978{
2979 DWORD opcode = *byte_code & 0xffff;
2980 unsigned int len = 0;
2981
2982 if (opcode == D3DSIO_COMMENT)
2983 return (*byte_code & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT;
2984
2985 if (major > 1)
2986 return (*byte_code & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT;
2987
2988 switch (opcode)
2989 {
2990 case D3DSIO_END:
2991 ERR("Unexpected END token.\n");
2992 return 0;
2993 case D3DSIO_DEF:
2994 case D3DSIO_DEFI:
2995 return 5;
2996 case D3DSIO_DEFB:
2997 return 2;
2998 default:
2999 ++byte_code;
3000 while (*byte_code & 0x80000000)
3001 {
3002 ++byte_code;
3003 ++len;
3004 }
3005 }
3006
3007 return len;
3008}
@ D3DSIO_DEF
Definition: d3d8types.h:353
#define D3DSI_INSTLENGTH_SHIFT
Definition: d3d9types.h:354
@ D3DSIO_DEFB
Definition: d3d9types.h:405
@ D3DSIO_DEFI
Definition: d3d9types.h:406
#define D3DSI_INSTLENGTH_MASK
Definition: d3d9types.h:353
#define major(rdev)
Definition: propsheet.cpp:928

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 3010 of file shader.c.

3011{
3012 static const D3DDECLUSAGE regtype_usage[] =
3013 {
3016 0,
3018 0,
3021 0,
3022 0,
3024 };
3025 static const D3DDECLUSAGE rast_usage[] =
3026 {
3030 };
3031 DWORD reg_type, usage, index, version_token = *byte_code;
3032 BOOL is_ps = version_token >> 16 == 0xffff;
3033 unsigned int major, minor, i = 0, j;
3034 BYTE colors = 0, rastout = 0;
3035 BOOL has_dcl, depth = 0;
3036 WORD texcoords = 0;
3037
3038 if ((version_token & 0xffff0000) != 0xfffe0000 && (version_token & 0xffff0000) != 0xffff0000)
3039 return D3DXERR_INVALIDDATA;
3040
3041 major = version_token >> 8 & 0xff;
3042 minor = version_token & 0xff;
3043
3044 TRACE("%s shader, version %u.%u.\n", is_ps ? "Pixel" : "Vertex", major, minor);
3045 ++byte_code;
3046
3047 has_dcl = (!is_ps && (!output || major == 3)) || (is_ps && !output && major >= 2);
3048
3049 while (*byte_code != D3DSIO_END)
3050 {
3051 if (has_dcl && (*byte_code & 0xffff) == D3DSIO_DCL)
3052 {
3053 DWORD usage_token = byte_code[1];
3054 DWORD reg = byte_code[2];
3055
3058
3059 if (is_ps && !output && major == 2)
3060 {
3061 /* dcl with no explicit usage, look at the register. */
3065 if (reg_type >= ARRAY_SIZE(regtype_usage))
3066 {
3067 WARN("Invalid register type %u.\n", reg_type);
3068 reg_type = 0;
3069 }
3070 usage = regtype_usage[reg_type];
3071 if (semantics)
3072 {
3073 semantics[i].Usage = usage;
3074 semantics[i].UsageIndex = index;
3075 }
3076 ++i;
3077 }
3078 else if ((!output && reg_type == D3DSPR_INPUT) || (output && reg_type == D3DSPR_OUTPUT))
3079 {
3080 if (semantics)
3081 {
3082 semantics[i].Usage =
3084 semantics[i].UsageIndex =
3086 }
3087 ++i;
3088 }
3089 byte_code += 3;
3090 }
3091 else if (!has_dcl)
3092 {
3093 unsigned int len = get_instr_length(byte_code, major, minor) + 1;
3094
3095 switch (*byte_code & 0xffff)
3096 {
3097 case D3DSIO_COMMENT:
3098 case D3DSIO_DEF:
3099 case D3DSIO_DEFB:
3100 case D3DSIO_DEFI:
3101 byte_code += len;
3102 break;
3103 default:
3104 ++byte_code;
3105 while (*byte_code & 0x80000000)
3106 {
3107 reg_type = ((*byte_code & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT)
3108 | ((*byte_code & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2);
3109 index = *byte_code & D3DSP_REGNUM_MASK;
3110
3111 if ((reg_type == D3DSPR_TEMP && is_ps && major == 1)
3112 || (reg_type == D3DSPR_INPUT && is_ps)
3113 || (reg_type == D3DSPR_TEXTURE && is_ps && !output)
3118 {
3119 if (reg_type == D3DSPR_RASTOUT)
3120 rastout |= 1u << index;
3121 else if (reg_type == D3DSPR_DEPTHOUT)
3122 depth = TRUE;
3124 texcoords |= 1u << index;
3125 else
3126 colors |= 1u << index;
3127 }
3128 ++byte_code;
3129 }
3130 }
3131 }
3132 else
3133 {
3134 byte_code += get_instr_length(byte_code, major, minor) + 1;
3135 }
3136 }
3137
3138 if (!has_dcl)
3139 {
3140 i = j = 0;
3141 while (texcoords)
3142 {
3143 if (texcoords & 1)
3144 {
3145 if (semantics)
3146 {
3147 semantics[i].Usage = D3DDECLUSAGE_TEXCOORD;
3148 semantics[i].UsageIndex = j;
3149 }
3150 ++i;
3151 }
3152 texcoords >>= 1;
3153 ++j;
3154 }
3155 j = 0;
3156 while (colors)
3157 {
3158 if (colors & 1)
3159 {
3160 if (semantics)
3161 {
3162 semantics[i].Usage = D3DDECLUSAGE_COLOR;
3163 semantics[i].UsageIndex = j;
3164 }
3165 ++i;
3166 }
3167 colors >>= 1;
3168 ++j;
3169 }
3170 j = 0;
3171 while (rastout)
3172 {
3173 if (rastout & 1)
3174 {
3175 if (j >= ARRAY_SIZE(rast_usage))
3176 {
3177 WARN("Invalid RASTOUT register index.\n");
3178 usage = 0;
3179 }
3180 else
3181 {
3182 usage = rast_usage[j];
3183 }
3184 if (semantics)
3185 {
3186 semantics[i].Usage = usage;
3187 semantics[i].UsageIndex = 0;
3188 }
3189 ++i;
3190 }
3191 rastout >>= 1;
3192 ++j;
3193 }
3194 if (depth)
3195 {
3196 if (semantics)
3197 {
3198 semantics[i].Usage = D3DDECLUSAGE_DEPTH;
3199 semantics[i].UsageIndex = 0;
3200 }
3201 ++i;
3202 }
3203 }
3204
3205 if (count)
3206 *count = i;
3207
3208 return D3D_OK;
3209}
#define ARRAY_SIZE(A)
Definition: main.h:20
@ D3DSPR_TEXTURE
Definition: d3d8types.h:402
@ D3DDECLUSAGE_FOG
Definition: d3d9types.h:231
@ D3DDECLUSAGE_TEXCOORD
Definition: d3d9types.h:225
@ D3DDECLUSAGE_DEPTH
Definition: d3d9types.h:232
@ D3DDECLUSAGE_POSITION
Definition: d3d9types.h:220
@ D3DDECLUSAGE_PSIZE
Definition: d3d9types.h:224
@ D3DDECLUSAGE_COLOR
Definition: d3d9types.h:230
#define D3DSP_DCL_USAGE_MASK
Definition: d3d9types.h:461
enum _D3DDECLUSAGE D3DDECLUSAGE
#define D3DSP_DCL_USAGE_SHIFT
Definition: d3d9types.h:460
@ D3DSIO_DCL
Definition: d3d9types.h:389
#define D3DSP_DCL_USAGEINDEX_MASK
Definition: d3d9types.h:464
#define D3DSP_DCL_USAGEINDEX_SHIFT
Definition: d3d9types.h:463
@ D3DSPR_DEPTHOUT
Definition: d3d9types.h:522
@ D3DSPR_OUTPUT
Definition: d3d9types.h:519
static unsigned int get_instr_length(const DWORD *byte_code, unsigned int major, unsigned int minor)
Definition: shader.c:2977
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
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
static int reg
Definition: i386-dis.c:1290
#define minor(rdev)
Definition: propsheet.cpp:929
unsigned char BYTE
Definition: xxhash.c:193

Referenced by D3DXGetShaderInputSemantics(), and D3DXGetShaderOutputSemantics().

◆ get_valid_constant()

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

Definition at line 887 of file shader.c.

888{
889 struct ctab_constant *c;
890 UINT i;
891
892 if (!handle) return NULL;
893
894 for (i = 0; i < table->desc.Constants; ++i)
895 {
896 if (handle_from_constant(&table->constants[i]) == handle)
897 return &table->constants[i];
898
899 c = is_valid_sub_constant(&table->constants[i], handle);
900 if (c) return c;
901 }
902
904}
static D3DXHANDLE handle_from_constant(struct ctab_constant *constant)
Definition: shader.c:772
static struct ctab_constant * is_valid_sub_constant(struct ctab_constant *parent, D3DXHANDLE handle)
Definition: shader.c:866

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 925 of file shader.c.

926{
928
929 TRACE("(%p)->(): AddRef from %d\n", This, This->ref);
930
931 return InterlockedIncrement(&This->ref);
932}

◆ ID3DXConstantTableImpl_GetBufferPointer()

static void *WINAPI ID3DXConstantTableImpl_GetBufferPointer ( ID3DXConstantTable *  iface)
static

Definition at line 951 of file shader.c.

952{
954
955 TRACE("iface %p.\n", iface);
956
957 return table->ctab;
958}

◆ ID3DXConstantTableImpl_GetBufferSize()

static DWORD WINAPI ID3DXConstantTableImpl_GetBufferSize ( ID3DXConstantTable *  iface)
static

Definition at line 960 of file shader.c.

961{
963
964 TRACE("(%p)->()\n", This);
965
966 return This->size;
967}

◆ ID3DXConstantTableImpl_GetConstant()

static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstant ( ID3DXConstantTable *  iface,
D3DXHANDLE  constant,
UINT  index 
)
static

Definition at line 1028 of file shader.c.

1029{
1031 struct ctab_constant *c;
1032
1033 TRACE("(%p)->(%p, %d)\n", This, constant, index);
1034
1035 if (constant)
1036 {
1038 if (c && index < c->desc.StructMembers)
1039 {
1040 c = &c->constants[index];
1041 TRACE("Returning constant %p\n", c);
1042 return handle_from_constant(c);
1043 }
1044 }
1045 else
1046 {
1047 if (index < This->desc.Constants)
1048 {
1049 c = &This->constants[index];
1050 TRACE("Returning constant %p\n", c);
1051 return handle_from_constant(c);
1052 }
1053 }
1054
1055 WARN("Index out of range\n");
1056 return NULL;
1057}

◆ ID3DXConstantTableImpl_GetConstantByName()

static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantByName ( ID3DXConstantTable *  iface,
D3DXHANDLE  constant,
const char name 
)
static

Definition at line 1059 of file shader.c.

1061{
1064
1065 TRACE("iface %p, constant %p, name %s.\n", iface, constant, debugstr_a(name));
1066
1068 TRACE("Returning constant %p\n", c);
1069
1070 return handle_from_constant(c);
1071}

◆ ID3DXConstantTableImpl_GetConstantDesc()

static HRESULT WINAPI ID3DXConstantTableImpl_GetConstantDesc ( ID3DXConstantTable *  iface,
D3DXHANDLE  constant,
D3DXCONSTANT_DESC desc,
UINT count 
)
static

Definition at line 991 of file shader.c.

993{
996
997 TRACE("(%p)->(%p, %p, %p)\n", ctab, constant, desc, count);
998
999 if (!c)
1000 {
1001 WARN("Invalid argument specified\n");
1002 return D3DERR_INVALIDCALL;
1003 }
1004
1005 if (desc) *desc = c->desc;
1006 if (count) *count = 1;
1007
1008 return D3D_OK;
1009}

◆ ID3DXConstantTableImpl_GetConstantElement()

static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantElement ( ID3DXConstantTable *  iface,
D3DXHANDLE  constant,
UINT  index 
)
static

Definition at line 1073 of file shader.c.

1074{
1077
1078 TRACE("(%p)->(%p, %d)\n", This, constant, index);
1079
1080 if (c && index < c->desc.Elements)
1081 {
1082 if (c->desc.Elements > 1) c = &c->constants[index];
1083 TRACE("Returning constant %p\n", c);
1084 return handle_from_constant(c);
1085 }
1086
1087 WARN("Invalid argument specified\n");
1088 return NULL;
1089}

◆ ID3DXConstantTableImpl_GetDesc()

static HRESULT WINAPI ID3DXConstantTableImpl_GetDesc ( ID3DXConstantTable *  iface,
D3DXCONSTANTTABLE_DESC desc 
)
static

Definition at line 970 of file shader.c.

971{
973
974 TRACE("(%p)->(%p)\n", This, desc);
975
976 if (!desc)
977 return D3DERR_INVALIDCALL;
978
979 *desc = This->desc;
980
981 return D3D_OK;
982}

◆ ID3DXConstantTableImpl_GetSamplerIndex()

static UINT WINAPI ID3DXConstantTableImpl_GetSamplerIndex ( ID3DXConstantTable *  iface,
D3DXHANDLE  constant 
)
static

Definition at line 1011 of file shader.c.

1012{
1015
1016 TRACE("(%p)->(%p)\n", This, constant);
1017
1018 if (!c || c->desc.RegisterSet != D3DXRS_SAMPLER)
1019 {
1020 WARN("Invalid argument specified\n");
1021 return (UINT)-1;
1022 }
1023
1024 TRACE("Returning RegisterIndex %u\n", c->desc.RegisterIndex);
1025 return c->desc.RegisterIndex;
1026}
@ D3DXRS_SAMPLER
Definition: d3dx9shader.h:56

◆ ID3DXConstantTableImpl_QueryInterface()

static HRESULT WINAPI ID3DXConstantTableImpl_QueryInterface ( ID3DXConstantTable *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 907 of file shader.c.

908{
909 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
910
912 IsEqualGUID(riid, &IID_ID3DXBuffer) ||
913 IsEqualGUID(riid, &IID_ID3DXConstantTable))
914 {
916 *out = iface;
917 return S_OK;
918 }
919
920 WARN("Interface %s not found.\n", debugstr_guid(riid));
921
922 return E_NOINTERFACE;
923}
#define ID3DXConstantTable_AddRef(p)
Definition: d3dx9shader.h:176

◆ ID3DXConstantTableImpl_Release()

static ULONG WINAPI ID3DXConstantTableImpl_Release ( ID3DXConstantTable *  iface)
static

Definition at line 934 of file shader.c.

935{
938
939 TRACE("(%p)->(): Release from %d\n", This, ref + 1);
940
941 if (!ref)
942 {
945 }
946
947 return ref;
948}
Definition: send.c:48

◆ ID3DXConstantTableImpl_SetBool()

static HRESULT WINAPI ID3DXConstantTableImpl_SetBool ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
BOOL  b 
)
static

Definition at line 1681 of file shader.c.

1683{
1685
1686 TRACE("iface %p, device %p, constant %p, b %d\n", iface, device, constant, b);
1687
1689}
@ D3DXPT_BOOL
Definition: d3dx9shader.h:74
static HRESULT set_scalar(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, D3DXPARAMETER_TYPE intype)
Definition: shader.c:1410

◆ ID3DXConstantTableImpl_SetBoolArray()

static HRESULT WINAPI ID3DXConstantTableImpl_SetBoolArray ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const BOOL b,
UINT  count 
)
static

Definition at line 1691 of file shader.c.

1693{
1695
1696 TRACE("iface %p, device %p, constant %p, b %p, count %d\n", iface, device, constant, b, count);
1697
1699}
static HRESULT set_scalar_array(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, UINT count, D3DXPARAMETER_TYPE intype)
Definition: shader.c:1440

◆ ID3DXConstantTableImpl_SetDefaults()

static HRESULT WINAPI ID3DXConstantTableImpl_SetDefaults ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device 
)
static

Definition at line 1583 of file shader.c.

1585{
1587 UINT i;
1588
1589 TRACE("iface %p, device %p\n", iface, device);
1590
1591 if (!device)
1592 {
1593 WARN("Invalid argument specified\n");
1594 return D3DERR_INVALIDCALL;
1595 }
1596
1597 for (i = 0; i < This->desc.Constants; i++)
1598 {
1599 D3DXCONSTANT_DESC *desc = &This->constants[i].desc;
1600 HRESULT hr;
1601
1602 if (!desc->DefaultValue)
1603 continue;
1604
1605 switch (desc->RegisterSet)
1606 {
1607 case D3DXRS_BOOL:
1608 if (is_vertex_shader(This->desc.Version))
1609 hr = IDirect3DDevice9_SetVertexShaderConstantB(device, desc->RegisterIndex, desc->DefaultValue,
1610 desc->RegisterCount);
1611 else
1612 hr = IDirect3DDevice9_SetPixelShaderConstantB(device, desc->RegisterIndex, desc->DefaultValue,
1613 desc->RegisterCount);
1614 break;
1615
1616 case D3DXRS_INT4:
1617 if (is_vertex_shader(This->desc.Version))
1618 hr = IDirect3DDevice9_SetVertexShaderConstantI(device, desc->RegisterIndex, desc->DefaultValue,
1619 desc->RegisterCount);
1620 else
1621 hr = IDirect3DDevice9_SetPixelShaderConstantI(device, desc->RegisterIndex, desc->DefaultValue,
1622 desc->RegisterCount);
1623 break;
1624
1625 case D3DXRS_FLOAT4:
1626 if (is_vertex_shader(This->desc.Version))
1627 hr = IDirect3DDevice9_SetVertexShaderConstantF(device, desc->RegisterIndex, desc->DefaultValue,
1628 desc->RegisterCount);
1629 else
1630 hr = IDirect3DDevice9_SetPixelShaderConstantF(device, desc->RegisterIndex, desc->DefaultValue,
1631 desc->RegisterCount);
1632 break;
1633
1634 default:
1635 FIXME("Unhandled register set %s\n", debug_d3dxparameter_registerset(desc->RegisterSet));
1636 hr = E_NOTIMPL;
1637 break;
1638 }
1639
1640 if (hr != D3D_OK)
1641 return hr;
1642 }
1643
1644 return D3D_OK;
1645}
#define IDirect3DDevice9_SetPixelShaderConstantI(p, a, b, c)
Definition: d3d9.h:1618
#define IDirect3DDevice9_SetVertexShaderConstantF(p, a, b, c)
Definition: d3d9.h:1601
#define IDirect3DDevice9_SetPixelShaderConstantF(p, a, b, c)
Definition: d3d9.h:1616
#define IDirect3DDevice9_SetVertexShaderConstantI(p, a, b, c)
Definition: d3d9.h:1603
#define IDirect3DDevice9_SetPixelShaderConstantB(p, a, b, c)
Definition: d3d9.h:1620
#define IDirect3DDevice9_SetVertexShaderConstantB(p, a, b, c)
Definition: d3d9.h:1605
const char * debug_d3dxparameter_registerset(D3DXREGISTER_SET r) DECLSPEC_HIDDEN
Definition: util.c:283
@ D3DXRS_FLOAT4
Definition: d3dx9shader.h:55
@ D3DXRS_BOOL
Definition: d3dx9shader.h:53
static BOOL is_vertex_shader(DWORD version)
Definition: shader.c:767

◆ ID3DXConstantTableImpl_SetFloat()

static HRESULT WINAPI ID3DXConstantTableImpl_SetFloat ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
float  f 
)
static

Definition at line 1721 of file shader.c.

1723{
1725
1726 TRACE("iface %p, device %p, constant %p, f %f\n", iface, device, constant, f);
1727
1729}
@ D3DXPT_FLOAT
Definition: d3dx9shader.h:76

◆ ID3DXConstantTableImpl_SetFloatArray()

static HRESULT WINAPI ID3DXConstantTableImpl_SetFloatArray ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const float f,
UINT  count 
)
static

Definition at line 1731 of file shader.c.

1733{
1735
1736 TRACE("iface %p, device %p, constant %p, f %p, count %d\n", iface, device, constant, f, count);
1737
1739}

◆ ID3DXConstantTableImpl_SetInt()

static HRESULT WINAPI ID3DXConstantTableImpl_SetInt ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
INT  n 
)
static

Definition at line 1701 of file shader.c.

1703{
1705
1706 TRACE("iface %p, device %p, constant %p, n %d\n", iface, device, constant, n);
1707
1709}
@ D3DXPT_INT
Definition: d3dx9shader.h:75

◆ ID3DXConstantTableImpl_SetIntArray()

static HRESULT WINAPI ID3DXConstantTableImpl_SetIntArray ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const INT n,
UINT  count 
)
static

Definition at line 1711 of file shader.c.

1713{
1715
1716 TRACE("iface %p, device %p, constant %p, n %p, count %d\n", iface, device, constant, n, count);
1717
1719}

◆ ID3DXConstantTableImpl_SetMatrix()

static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrix ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const D3DXMATRIX matrix 
)
static

Definition at line 1761 of file shader.c.

1763{
1765
1766 TRACE("iface %p, device %p, constant %p, matrix %p\n", iface, device, constant, matrix);
1767
1769}
static HRESULT set_matrix_array(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, UINT count, BOOL transpose)
Definition: shader.c:1525

◆ ID3DXConstantTableImpl_SetMatrixArray()

static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixArray ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const D3DXMATRIX matrix,
UINT  count 
)
static

Definition at line 1771 of file shader.c.

1773{
1775
1776 TRACE("iface %p, device %p, constant %p, matrix %p, count %u\n", iface, device, constant, matrix, count);
1777
1779}

◆ ID3DXConstantTableImpl_SetMatrixPointerArray()

static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixPointerArray ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const D3DXMATRIX **  matrix,
UINT  count 
)
static

Definition at line 1781 of file shader.c.

1783{
1785
1786 TRACE("iface %p, device %p, constant %p, matrix %p, count %u)\n", iface, device, constant, matrix, count);
1787
1788 return set_matrix_pointer_array(This, device, constant, (const void **)matrix, count, FALSE);
1789}
static HRESULT set_matrix_pointer_array(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void **indata, UINT count, BOOL transpose)
Definition: shader.c:1554

◆ ID3DXConstantTableImpl_SetMatrixTranspose()

static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTranspose ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const D3DXMATRIX matrix 
)
static

Definition at line 1791 of file shader.c.

1793{
1795
1796 TRACE("iface %p, device %p, constant %p, matrix %p\n", iface, device, constant, matrix);
1797
1799}

◆ ID3DXConstantTableImpl_SetMatrixTransposeArray()

static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTransposeArray ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const D3DXMATRIX matrix,
UINT  count 
)
static

Definition at line 1801 of file shader.c.

1803{
1805
1806 TRACE("iface %p, device %p, constant %p, matrix %p, count %u\n", iface, device, constant, matrix, count);
1807
1809}

◆ ID3DXConstantTableImpl_SetMatrixTransposePointerArray()

static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTransposePointerArray ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const D3DXMATRIX **  matrix,
UINT  count 
)
static

Definition at line 1811 of file shader.c.

1813{
1815
1816 TRACE("iface %p, device %p, constant %p, matrix %p, count %u)\n", iface, device, constant, matrix, count);
1817
1818 return set_matrix_pointer_array(This, device, constant, (const void **)matrix, count, TRUE);
1819}

◆ ID3DXConstantTableImpl_SetValue()

static HRESULT WINAPI ID3DXConstantTableImpl_SetValue ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const void data,
unsigned int  bytes 
)
static

Definition at line 1647 of file shader.c.

1649{
1653
1654 TRACE("iface %p, device %p, constant %p, data %p, bytes %u\n", iface, device, constant, data, bytes);
1655
1656 if (!device || !c || !data)
1657 {
1658 WARN("Invalid argument specified\n");
1659 return D3DERR_INVALIDCALL;
1660 }
1661
1662 desc = &c->desc;
1663
1664 switch (desc->Class)
1665 {
1666 case D3DXPC_SCALAR:
1667 case D3DXPC_VECTOR:
1668 case D3DXPC_MATRIX_ROWS:
1670 case D3DXPC_STRUCT:
1671 bytes /= 4;
1672 set(table, device, c, &data, desc->Type, &bytes, desc->Columns, D3DXPC_SCALAR, 0, FALSE);
1673 return D3D_OK;
1674
1675 default:
1676 FIXME("Unhandled parameter class %s\n", debug_d3dxparameter_class(desc->Class));
1677 return D3DERR_INVALIDCALL;
1678 }
1679}
Definition: _set.h:50
const char * debug_d3dxparameter_class(D3DXPARAMETER_CLASS c) DECLSPEC_HIDDEN
Definition: util.c:237
@ D3DXPC_SCALAR
Definition: d3dx9shader.h:62
@ D3DXPC_MATRIX_COLUMNS
Definition: d3dx9shader.h:65
@ D3DXPC_STRUCT
Definition: d3dx9shader.h:67
@ D3DXPC_MATRIX_ROWS
Definition: d3dx9shader.h:64
@ D3DXPC_VECTOR
Definition: d3dx9shader.h:63

◆ ID3DXConstantTableImpl_SetVector()

static HRESULT WINAPI ID3DXConstantTableImpl_SetVector ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const D3DXVECTOR4 vector 
)
static

Definition at line 1741 of file shader.c.

1743{
1745
1746 TRACE("iface %p, device %p, constant %p, vector %p\n", iface, device, constant, vector);
1747
1749}
static HRESULT set_vector(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, D3DXPARAMETER_TYPE intype)
Definition: shader.c:1467

◆ ID3DXConstantTableImpl_SetVectorArray()

static HRESULT WINAPI ID3DXConstantTableImpl_SetVectorArray ( struct ID3DXConstantTable *  iface,
struct IDirect3DDevice9 *  device,
D3DXHANDLE  constant,
const D3DXVECTOR4 vector,
UINT  count 
)
static

Definition at line 1751 of file shader.c.

1753{
1755
1756 TRACE("iface %p, device %p, constant %p, vector %p, count %u\n", iface, device, constant, vector, count);
1757
1759}
static HRESULT set_vector_array(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, D3DXHANDLE constant, const void *indata, UINT count, D3DXPARAMETER_TYPE intype)
Definition: shader.c:1497

◆ impl_from_ID3DXConstantTable()

◆ impl_from_ID3DXFragmentLinker()

static struct d3dx9_fragment_linker * impl_from_ID3DXFragmentLinker ( ID3DXFragmentLinker *  iface)
inlinestatic

Definition at line 2127 of file shader.c.

2128{
2129 return CONTAINING_RECORD(iface, struct d3dx9_fragment_linker, ID3DXFragmentLinker_iface);
2130}

Referenced by d3dx9_fragment_linker_AddRef(), d3dx9_fragment_linker_GetDevice(), and d3dx9_fragment_linker_Release().

◆ impl_from_ID3DXTextureShader()

static struct d3dx9_texture_shader * impl_from_ID3DXTextureShader ( ID3DXTextureShader *  iface)
inlinestatic

Definition at line 2716 of file shader.c.

2717{
2718 return CONTAINING_RECORD(iface, struct d3dx9_texture_shader, ID3DXTextureShader_iface);
2719}

Referenced by d3dx9_texture_shader_AddRef(), and d3dx9_texture_shader_Release().

◆ instr_comment()

static int instr_comment ( const struct instr_info info,