ReactOS  0.4.14-dev-323-g6fe6a88
preshader.c File Reference
#include "config.h"
#include "wine/port.h"
#include "d3dx9_private.h"
#include <float.h>
#include <assert.h>
Include dependency graph for preshader.c:

Go to the source code of this file.

Classes

struct  op_info
 
struct  d3dx_pres_reg
 
struct  d3dx_pres_operand
 
struct  d3dx_pres_ins
 
struct  const_upload_info
 

Macros

#define fmin   min
 
#define fmax   max
 
#define PRES_OPCODE_MASK   0x7ff00000
 
#define PRES_OPCODE_SHIFT   20
 
#define PRES_SCALAR_FLAG   0x80000000
 
#define PRES_NCOMP_MASK   0x0000ffff
 
#define FOURCC_PRES   0x53455250
 
#define FOURCC_CLIT   0x54494c43
 
#define FOURCC_FXLC   0x434c5846
 
#define FOURCC_PRSI   0x49535250
 
#define PRES_SIGN   0x46580000
 
#define MAX_INPUTS_COUNT   8
 
#define PRES_BITMASK_BLOCK_SIZE   (sizeof(unsigned int) * 8)
 
#define INITIAL_CONST_SET_SIZE   16
 
#define ARGS_ARRAY_SIZE   8
 

Typedefs

typedef double(* pres_op_func) (double *args, int n)
 

Enumerations

enum  pres_ops {
  PRESHADER_OP_NOP, PRESHADER_OP_MOV, PRESHADER_OP_NEG, PRESHADER_OP_RCP,
  PRESHADER_OP_FRC, PRESHADER_OP_EXP, PRESHADER_OP_LOG, PRESHADER_OP_RSQ,
  PRESHADER_OP_SIN, PRESHADER_OP_COS, PRESHADER_OP_ASIN, PRESHADER_OP_ACOS,
  PRESHADER_OP_ATAN, PRESHADER_OP_MIN, PRESHADER_OP_MAX, PRESHADER_OP_LT,
  PRESHADER_OP_GE, PRESHADER_OP_ADD, PRESHADER_OP_MUL, PRESHADER_OP_ATAN2,
  PRESHADER_OP_DIV, PRESHADER_OP_CMP, PRESHADER_OP_DOT, PRESHADER_OP_DOTSWIZ6,
  PRESHADER_OP_DOTSWIZ8
}
 
enum  pres_value_type {
  PRES_VT_FLOAT, PRES_VT_DOUBLE, PRES_VT_INT, PRES_VT_BOOL,
  PRES_VT_COUNT
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static double to_signed_nan (double v)
 
static double pres_mov (double *args, int n)
 
static double pres_add (double *args, int n)
 
static double pres_mul (double *args, int n)
 
static double pres_dot (double *args, int n)
 
static double pres_dotswiz6 (double *args, int n)
 
static double pres_dotswiz8 (double *args, int n)
 
static double pres_neg (double *args, int n)
 
static double pres_rcp (double *args, int n)
 
static double pres_lt (double *args, int n)
 
static double pres_ge (double *args, int n)
 
static double pres_frc (double *args, int n)
 
static double pres_min (double *args, int n)
 
static double pres_max (double *args, int n)
 
static double pres_cmp (double *args, int n)
 
static double pres_sin (double *args, int n)
 
static double pres_cos (double *args, int n)
 
static double pres_rsq (double *args, int n)
 
static double pres_exp (double *args, int n)
 
static double pres_log (double *args, int n)
 
static double pres_asin (double *args, int n)
 
static double pres_acos (double *args, int n)
 
static double pres_atan (double *args, int n)
 
static double pres_atan2 (double *args, int n)
 
static double pres_div (double *args, int n)
 
static enum pres_value_type table_type_from_param_type (D3DXPARAMETER_TYPE type)
 
static unsigned int get_reg_offset (unsigned int table, unsigned int offset)
 
static unsigned int get_offset_reg (unsigned int table, unsigned int reg_idx)
 
static unsigned int get_reg_components (unsigned int table)
 
static HRESULT regstore_alloc_table (struct d3dx_regstore *rs, unsigned int table)
 
static void regstore_free_tables (struct d3dx_regstore *rs)
 
static void regstore_set_values (struct d3dx_regstore *rs, unsigned int table, const void *data, unsigned int start_offset, unsigned int count)
 
static double regstore_get_double (struct d3dx_regstore *rs, unsigned int table, unsigned int offset)
 
static void regstore_set_double (struct d3dx_regstore *rs, unsigned int table, unsigned int offset, double v)
 
static void dump_bytecode (void *data, unsigned int size)
 
static unsigned intfind_bytecode_comment (unsigned int *ptr, unsigned int count, unsigned int fourcc, unsigned int *size)
 
static unsigned intparse_pres_reg (unsigned int *ptr, struct d3dx_pres_reg *reg)
 
static unsigned intparse_pres_arg (unsigned int *ptr, unsigned int count, struct d3dx_pres_operand *opr)
 
static unsigned intparse_pres_ins (unsigned int *ptr, unsigned int count, struct d3dx_pres_ins *ins)
 
static HRESULT get_ctab_constant_desc (ID3DXConstantTable *ctab, D3DXHANDLE hc, D3DXCONSTANT_DESC *desc, WORD *constantinfo_reserved)
 
static void get_const_upload_info (struct d3dx_const_param_eval_output *const_set, struct const_upload_info *info)
 
static HRESULT append_const_set (struct d3dx_const_tab *const_tab, struct d3dx_const_param_eval_output *set)
 
static void append_pres_const_sets_for_shader_input (struct d3dx_const_tab *const_tab, struct d3dx_preshader *pres)
 
static int compare_const_set (const void *a, const void *b)
 
static HRESULT merge_const_set_entries (struct d3dx_const_tab *const_tab, struct d3dx_parameter *param, unsigned int index)
 
static HRESULT init_set_constants_param (struct d3dx_const_tab *const_tab, ID3DXConstantTable *ctab, D3DXHANDLE hc, struct d3dx_parameter *param)
 
static HRESULT get_constants_desc (unsigned int *byte_code, struct d3dx_const_tab *out, struct d3dx9_base_effect *base, const char **skip_constants, unsigned int skip_constants_count, struct d3dx_preshader *pres)
 
static void update_table_size (unsigned int *table_sizes, unsigned int table, unsigned int max_register)
 
static void update_table_sizes_consts (unsigned int *table_sizes, struct d3dx_const_tab *ctab)
 
static void dump_arg (struct d3dx_regstore *rs, const struct d3dx_pres_operand *arg, int component_count)
 
static void dump_registers (struct d3dx_const_tab *ctab)
 
static void dump_ins (struct d3dx_regstore *rs, const struct d3dx_pres_ins *ins)
 
static void dump_preshader (struct d3dx_preshader *pres)
 
static HRESULT parse_preshader (struct d3dx_preshader *pres, unsigned int *ptr, unsigned int count, struct d3dx9_base_effect *base)
 
HRESULT d3dx_create_param_eval (struct d3dx9_base_effect *base_effect, void *byte_code, unsigned int byte_code_size, D3DXPARAMETER_TYPE type, struct d3dx_param_eval **peval_out, ULONG64 *version_counter, const char **skip_constants, unsigned int skip_constants_count)
 
static void d3dx_free_const_tab (struct d3dx_const_tab *ctab)
 
static void d3dx_free_preshader (struct d3dx_preshader *pres)
 
void d3dx_free_param_eval (struct d3dx_param_eval *peval)
 
static void pres_int_from_float (void *out, const void *in, unsigned int count)
 
static void pres_bool_from_value (void *out, const void *in, unsigned int count)
 
static void pres_float_from_int (void *out, const void *in, unsigned int count)
 
static void pres_float_from_bool (void *out, const void *in, unsigned int count)
 
static void pres_int_from_bool (void *out, const void *in, unsigned int count)
 
static void regstore_set_data (struct d3dx_regstore *rs, unsigned int table, unsigned int offset, const unsigned int *in, unsigned int count, enum pres_value_type param_type)
 
static HRESULT set_constants_device (ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, D3DXPARAMETER_TYPE type, enum pres_reg_tables table, void *ptr, unsigned int start, unsigned int count)
 
static HRESULT set_constants (struct d3dx_regstore *rs, struct d3dx_const_tab *const_tab, ULONG64 new_update_version, ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, D3DXPARAMETER_TYPE type, BOOL device_update_all, BOOL pres_dirty)
 
static double exec_get_reg_value (struct d3dx_regstore *rs, enum pres_reg_tables table, unsigned int offset)
 
static double exec_get_arg (struct d3dx_regstore *rs, const struct d3dx_pres_operand *opr, unsigned int comp)
 
static void exec_set_arg (struct d3dx_regstore *rs, const struct d3dx_pres_reg *reg, unsigned int comp, double res)
 
static HRESULT execute_preshader (struct d3dx_preshader *pres)
 
static BOOL is_const_tab_input_dirty (struct d3dx_const_tab *ctab, ULONG64 update_version)
 
BOOL is_param_eval_input_dirty (struct d3dx_param_eval *peval, ULONG64 update_version)
 
HRESULT d3dx_evaluate_parameter (struct d3dx_param_eval *peval, const struct d3dx_parameter *param, void *param_value)
 
HRESULT d3dx_param_eval_set_shader_constants (ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, struct d3dx_param_eval *peval, BOOL update_all)
 

Variables

static const struct op_info pres_op_info []
 
struct {
   unsigned int   component_size
 
   enum pres_value_type   type
 
table_info []
 
static const chartable_symbol []
 
static enum pres_reg_tables pres_regset2table []
 
static enum pres_reg_tables shad_regset2table []
 

Macro Definition Documentation

◆ ARGS_ARRAY_SIZE

#define ARGS_ARRAY_SIZE   8

Definition at line 1657 of file preshader.c.

◆ fmax

#define fmax   max

Definition at line 31 of file preshader.c.

◆ fmin

#define fmin   min

Definition at line 30 of file preshader.c.

◆ FOURCC_CLIT

#define FOURCC_CLIT   0x54494c43

Definition at line 153 of file preshader.c.

◆ FOURCC_FXLC

#define FOURCC_FXLC   0x434c5846

Definition at line 154 of file preshader.c.

◆ FOURCC_PRES

#define FOURCC_PRES   0x53455250

Definition at line 152 of file preshader.c.

◆ FOURCC_PRSI

#define FOURCC_PRSI   0x49535250

Definition at line 155 of file preshader.c.

◆ INITIAL_CONST_SET_SIZE

#define INITIAL_CONST_SET_SIZE   16

Definition at line 592 of file preshader.c.

◆ MAX_INPUTS_COUNT

#define MAX_INPUTS_COUNT   8

Definition at line 256 of file preshader.c.

◆ PRES_BITMASK_BLOCK_SIZE

#define PRES_BITMASK_BLOCK_SIZE   (sizeof(unsigned int) * 8)

Definition at line 310 of file preshader.c.

◆ PRES_NCOMP_MASK

#define PRES_NCOMP_MASK   0x0000ffff

Definition at line 150 of file preshader.c.

◆ PRES_OPCODE_MASK

#define PRES_OPCODE_MASK   0x7ff00000

Definition at line 147 of file preshader.c.

◆ PRES_OPCODE_SHIFT

#define PRES_OPCODE_SHIFT   20

Definition at line 148 of file preshader.c.

◆ PRES_SCALAR_FLAG

#define PRES_SCALAR_FLAG   0x80000000

Definition at line 149 of file preshader.c.

◆ PRES_SIGN

#define PRES_SIGN   0x46580000

Definition at line 156 of file preshader.c.

Typedef Documentation

◆ pres_op_func

typedef double(* pres_op_func) (double *args, int n)

Definition at line 62 of file preshader.c.

Enumeration Type Documentation

◆ pres_ops

Enumerator
PRESHADER_OP_NOP 
PRESHADER_OP_MOV 
PRESHADER_OP_NEG 
PRESHADER_OP_RCP 
PRESHADER_OP_FRC 
PRESHADER_OP_EXP 
PRESHADER_OP_LOG 
PRESHADER_OP_RSQ 
PRESHADER_OP_SIN 
PRESHADER_OP_COS 
PRESHADER_OP_ASIN 
PRESHADER_OP_ACOS 
PRESHADER_OP_ATAN 
PRESHADER_OP_MIN 
PRESHADER_OP_MAX 
PRESHADER_OP_LT 
PRESHADER_OP_GE 
PRESHADER_OP_ADD 
PRESHADER_OP_MUL 
PRESHADER_OP_ATAN2 
PRESHADER_OP_DIV 
PRESHADER_OP_CMP 
PRESHADER_OP_DOT 
PRESHADER_OP_DOTSWIZ6 
PRESHADER_OP_DOTSWIZ8 

Definition at line 33 of file preshader.c.

34 {
60 };

◆ pres_value_type

Enumerator
PRES_VT_FLOAT 
PRES_VT_DOUBLE 
PRES_VT_INT 
PRES_VT_BOOL 
PRES_VT_COUNT 

Definition at line 196 of file preshader.c.

Function Documentation

◆ append_const_set()

static HRESULT append_const_set ( struct d3dx_const_tab const_tab,
struct d3dx_const_param_eval_output set 
)
static

Definition at line 594 of file preshader.c.

595 {
596  if (const_tab->const_set_count >= const_tab->const_set_size)
597  {
598  unsigned int new_size;
599  struct d3dx_const_param_eval_output *new_alloc;
600 
601  if (!const_tab->const_set_size)
602  {
603  new_size = INITIAL_CONST_SET_SIZE;
604  new_alloc = HeapAlloc(GetProcessHeap(), 0, sizeof(*const_tab->const_set) * new_size);
605  if (!new_alloc)
606  {
607  ERR("Out of memory.\n");
608  return E_OUTOFMEMORY;
609  }
610  }
611  else
612  {
613  new_size = const_tab->const_set_size * 2;
614  new_alloc = HeapReAlloc(GetProcessHeap(), 0, const_tab->const_set,
615  sizeof(*const_tab->const_set) * new_size);
616  if (!new_alloc)
617  {
618  ERR("Out of memory.\n");
619  return E_OUTOFMEMORY;
620  }
621  }
622  const_tab->const_set = new_alloc;
623  const_tab->const_set_size = new_size;
624  }
625  const_tab->const_set[const_tab->const_set_count++] = *set;
626  return D3D_OK;
627 }
struct d3dx_const_param_eval_output * const_set
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define INITIAL_CONST_SET_SIZE
Definition: preshader.c:592
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
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)
Definition: shader.c:1095
#define ERR(fmt,...)
Definition: debug.h:109
#define D3D_OK
Definition: d3d.h:106
unsigned int const_set_size
#define HeapReAlloc
Definition: compat.h:393
unsigned int const_set_count

Referenced by append_pres_const_sets_for_shader_input(), and init_set_constants_param().

◆ append_pres_const_sets_for_shader_input()

static void append_pres_const_sets_for_shader_input ( struct d3dx_const_tab const_tab,
struct d3dx_preshader pres 
)
static

Definition at line 629 of file preshader.c.

631 {
632  unsigned int i;
633  struct d3dx_const_param_eval_output const_set = {NULL};
634 
635  for (i = 0; i < pres->ins_count; ++i)
636  {
637  const struct d3dx_pres_ins *ins = &pres->ins[i];
638  const struct d3dx_pres_reg *reg = &ins->output.reg;
639 
640  if (reg->table == PRES_REGTAB_TEMP)
641  continue;
642 
643  const_set.register_index = get_reg_offset(reg->table, reg->offset);
644  const_set.register_count = 1;
645  const_set.table = reg->table;
647  const_set.element_count = 1;
648  append_const_set(const_tab, &const_set);
649  }
650 }
enum pres_reg_tables table
static unsigned int get_reg_offset(unsigned int table, unsigned int offset)
Definition: preshader.c:295
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
smooth NULL
Definition: ftsmooth.c:416
struct d3dx_pres_operand output
Definition: preshader.c:266
unsigned int ins_count
enum D3DXPARAMETER_CLASS constant_class
static int reg
Definition: i386-dis.c:1275
struct d3dx_pres_ins * ins
static HRESULT append_const_set(struct d3dx_const_tab *const_tab, struct d3dx_const_param_eval_output *set)
Definition: preshader.c:594

Referenced by get_constants_desc().

◆ compare_const_set()

static int compare_const_set ( const void a,
const void b 
)
static

Definition at line 652 of file preshader.c.

653 {
654  const struct d3dx_const_param_eval_output *r1 = a;
655  const struct d3dx_const_param_eval_output *r2 = b;
656 
657  if (r1->table != r2->table)
658  return r1->table - r2->table;
659  return r1->register_index - r2->register_index;
660 }
static DNS_RECORDW r1
Definition: record.c:37
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
static DNS_RECORDW r2
Definition: record.c:38

Referenced by get_constants_desc().

◆ d3dx_create_param_eval()

HRESULT d3dx_create_param_eval ( struct d3dx9_base_effect base_effect,
void byte_code,
unsigned int  byte_code_size,
D3DXPARAMETER_TYPE  type,
struct d3dx_param_eval **  peval_out,
ULONG64 version_counter,
const char **  skip_constants,
unsigned int  skip_constants_count 
)

Definition at line 1232 of file preshader.c.

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

Referenced by d3dx9_parse_array_selector(), and d3dx9_parse_resource().

◆ d3dx_evaluate_parameter()

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

Definition at line 1722 of file preshader.c.

1724 {
1725  HRESULT hr;
1726  unsigned int i;
1727  unsigned int elements, elements_param, elements_table;
1728  float *oc;
1729 
1730  TRACE("peval %p, param %p, param_value %p.\n", peval, param, param_value);
1731 
1732  if (is_const_tab_input_dirty(&peval->pres.inputs, ULONG64_MAX))
1733  {
1734  set_constants(&peval->pres.regs, &peval->pres.inputs,
1736  NULL, NULL, peval->param_type, FALSE, FALSE);
1737 
1738  if (FAILED(hr = execute_preshader(&peval->pres)))
1739  return hr;
1740  }
1741 
1742  elements_table = get_offset_reg(PRES_REGTAB_OCONST, peval->pres.regs.table_sizes[PRES_REGTAB_OCONST]);
1743  elements_param = param->bytes / sizeof(unsigned int);
1744  elements = min(elements_table, elements_param);
1745  oc = (float *)peval->pres.regs.tables[PRES_REGTAB_OCONST];
1746  for (i = 0; i < elements; ++i)
1747  set_number((unsigned int *)param_value + i, param->type, oc + i, D3DXPT_FLOAT);
1748  return D3D_OK;
1749 }
static HRESULT set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const_tab, ULONG64 new_update_version, ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, D3DXPARAMETER_TYPE type, BOOL device_update_all, BOOL pres_dirty)
Definition: preshader.c:1482
HRESULT hr
Definition: shlfolder.c:183
static void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
static BOOL is_const_tab_input_dirty(struct d3dx_const_tab *ctab, ULONG64 update_version)
Definition: preshader.c:1701
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
smooth NULL
Definition: ftsmooth.c:416
static HRESULT execute_preshader(struct d3dx_preshader *pres)
Definition: preshader.c:1658
#define TRACE(s)
Definition: solgame.cpp:4
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300
static ULONG64 next_update_version(ULONG64 *version_counter)
LONG HRESULT
Definition: typedefs.h:77
GLfloat param
Definition: glext.h:5796
#define for
Definition: utility.h:88
#define ULONG64_MAX
Definition: d3dx9_private.h:33
#define D3D_OK
Definition: d3d.h:106
struct d3dx_preshader pres
#define min(a, b)
Definition: monoChain.cc:55
ULONG64 * version_counter
D3DXPARAMETER_TYPE param_type
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by d3dx9_get_param_value_ptr().

◆ d3dx_free_const_tab()

static void d3dx_free_const_tab ( struct d3dx_const_tab ctab)
static

Definition at line 1342 of file preshader.c.

1343 {
1344  HeapFree(GetProcessHeap(), 0, ctab->inputs);
1345  HeapFree(GetProcessHeap(), 0, ctab->inputs_param);
1346  HeapFree(GetProcessHeap(), 0, ctab->const_set);
1347 }
D3DXCONSTANT_DESC * inputs
struct d3dx_const_param_eval_output * const_set
struct d3dx_parameter ** inputs_param
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by d3dx_free_param_eval(), and d3dx_free_preshader().

◆ d3dx_free_param_eval()

void d3dx_free_param_eval ( struct d3dx_param_eval peval)

Definition at line 1357 of file preshader.c.

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

Referenced by d3dx_create_param_eval(), and free_parameter().

◆ d3dx_free_preshader()

static void d3dx_free_preshader ( struct d3dx_preshader pres)
static

Definition at line 1349 of file preshader.c.

1350 {
1351  HeapFree(GetProcessHeap(), 0, pres->ins);
1352 
1353  regstore_free_tables(&pres->regs);
1354  d3dx_free_const_tab(&pres->inputs);
1355 }
#define GetProcessHeap()
Definition: compat.h:395
struct d3dx_preshader pres
static void regstore_free_tables(struct d3dx_regstore *rs)
Definition: preshader.c:326
static void d3dx_free_const_tab(struct d3dx_const_tab *ctab)
Definition: preshader.c:1342
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by d3dx_free_param_eval().

◆ d3dx_param_eval_set_shader_constants()

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

Definition at line 1751 of file preshader.c.

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

Referenced by d3dx_set_shader_constants().

◆ dump_arg()

static void dump_arg ( struct d3dx_regstore rs,
const struct d3dx_pres_operand arg,
int  component_count 
)
static

Definition at line 1028 of file preshader.c.

1029 {
1030  static const char *xyzw_str = "xyzw";
1031  unsigned int i, table;
1032 
1033  table = arg->reg.table;
1034  if (table == PRES_REGTAB_IMMED && arg->index_reg.table == PRES_REGTAB_COUNT)
1035  {
1036  TRACE("(");
1037  for (i = 0; i < component_count; ++i)
1038  TRACE(i < component_count - 1 ? "%.16e, " : "%.16e",
1039  ((double *)rs->tables[PRES_REGTAB_IMMED])[arg->reg.offset + i]);
1040  TRACE(")");
1041  }
1042  else
1043  {
1044  if (arg->index_reg.table == PRES_REGTAB_COUNT)
1045  {
1046  TRACE("%s%u.", table_symbol[table], get_reg_offset(table, arg->reg.offset));
1047  }
1048  else
1049  {
1050  unsigned int index_reg;
1051 
1052  index_reg = get_reg_offset(arg->index_reg.table, arg->index_reg.offset);
1053  TRACE("%s[%u + %s%u.%c].", table_symbol[table], get_reg_offset(table, arg->reg.offset),
1054  table_symbol[arg->index_reg.table], index_reg,
1055  xyzw_str[arg->index_reg.offset - get_offset_reg(arg->index_reg.table, index_reg)]);
1056  }
1057  for (i = 0; i < component_count; ++i)
1058  TRACE("%c", xyzw_str[(arg->reg.offset + i) % 4]);
1059  }
1060 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static unsigned int get_reg_offset(unsigned int table, unsigned int offset)
Definition: preshader.c:295
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int component_count
#define TRACE(s)
Definition: solgame.cpp:4
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300
static const char * table_symbol[]
Definition: preshader.c:221
void * tables[PRES_REGTAB_COUNT]

Referenced by dump_ins().

◆ dump_bytecode()

static void dump_bytecode ( void data,
unsigned int  size 
)
static

Definition at line 383 of file preshader.c.

384 {
385  unsigned int *bytecode = (unsigned int *)data;
386  unsigned int i, j, n;
387 
388  size /= sizeof(*bytecode);
389  i = 0;
390  while (i < size)
391  {
392  n = min(size - i, 8);
393  for (j = 0; j < n; ++j)
394  TRACE("0x%08x,", bytecode[i + j]);
395  i += n;
396  TRACE("\n");
397  }
398 }
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define min(a, b)
Definition: monoChain.cc:55

Referenced by d3dx_create_param_eval().

◆ dump_ins()

static void dump_ins ( struct d3dx_regstore rs,
const struct d3dx_pres_ins ins 
)
static

Definition at line 1074 of file preshader.c.

1075 {
1076  unsigned int i;
1077 
1078  TRACE("%s ", pres_op_info[ins->op].mnem);
1079  dump_arg(rs, &ins->output, pres_op_info[ins->op].func_all_comps ? 1 : ins->component_count);
1080  for (i = 0; i < pres_op_info[ins->op].input_count; ++i)
1081  {
1082  TRACE(", ");
1083  dump_arg(rs, &ins->inputs[i], ins->scalar_op && !i ? 1 : ins->component_count);
1084  }
1085  TRACE("\n");
1086 }
BOOL scalar_op
Definition: preshader.c:263
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
enum pres_ops op
Definition: preshader.c:260
static const struct op_info pres_op_info[]
Definition: preshader.c:167
unsigned int component_count
Definition: preshader.c:264
struct d3dx_pres_operand output
Definition: preshader.c:266
#define TRACE(s)
Definition: solgame.cpp:4
static void dump_arg(struct d3dx_regstore *rs, const struct d3dx_pres_operand *arg, int component_count)
Definition: preshader.c:1028
struct d3dx_pres_operand inputs[MAX_INPUTS_COUNT]
Definition: preshader.c:265

Referenced by dump_preshader().

◆ dump_preshader()

static void dump_preshader ( struct d3dx_preshader pres)
static

Definition at line 1088 of file preshader.c.

1089 {
1090  unsigned int i, immediate_count = pres->regs.table_sizes[PRES_REGTAB_IMMED] * 4;
1091  const double *immediates = pres->regs.tables[PRES_REGTAB_IMMED];
1092 
1093  if (immediate_count)
1094  TRACE("// Immediates:\n");
1095  for (i = 0; i < immediate_count; ++i)
1096  {
1097  if (!(i % 4))
1098  TRACE("// ");
1099  TRACE("%.8e", immediates[i]);
1100  if (i % 4 == 3)
1101  TRACE("\n");
1102  else
1103  TRACE(", ");
1104  }
1105  TRACE("// Preshader registers:\n");
1106  dump_registers(&pres->inputs);
1107  TRACE("preshader\n");
1108  for (i = 0; i < pres->ins_count; ++i)
1109  dump_ins(&pres->regs, &pres->ins[i]);
1110 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TRACE(s)
Definition: solgame.cpp:4
static void dump_registers(struct d3dx_const_tab *ctab)
Definition: preshader.c:1062
unsigned int ins_count
struct d3dx_pres_ins * ins
struct d3dx_regstore regs
struct d3dx_const_tab inputs
static void dump_ins(struct d3dx_regstore *rs, const struct d3dx_pres_ins *ins)
Definition: preshader.c:1074

Referenced by d3dx_create_param_eval().

◆ dump_registers()

static void dump_registers ( struct d3dx_const_tab ctab)
static

Definition at line 1062 of file preshader.c.

1063 {
1064  unsigned int table, i;
1065 
1066  for (i = 0; i < ctab->input_count; ++i)
1067  {
1068  table = ctab->regset2table[ctab->inputs[i].RegisterSet];
1069  TRACE("// %-12s %s%-4u %u\n", ctab->inputs_param[i] ? ctab->inputs_param[i]->name : "(nil)",
1071  }
1072 }
D3DXCONSTANT_DESC * inputs
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
struct d3dx_parameter ** inputs_param
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
D3DXREGISTER_SET RegisterSet
Definition: d3dx9shader.h:106
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int input_count
static const char * table_symbol[]
Definition: preshader.c:221
enum pres_reg_tables * regset2table

Referenced by d3dx_create_param_eval(), and dump_preshader().

◆ exec_get_arg()

static double exec_get_arg ( struct d3dx_regstore rs,
const struct d3dx_pres_operand opr,
unsigned int  comp 
)
static

Definition at line 1609 of file preshader.c.

1610 {
1611  unsigned int offset, base_index, reg_index, table;
1612 
1613  table = opr->reg.table;
1614 
1615  if (opr->index_reg.table == PRES_REGTAB_COUNT)
1616  base_index = 0;
1617  else
1618  base_index = lrint(exec_get_reg_value(rs, opr->index_reg.table, opr->index_reg.offset));
1619 
1620  offset = get_offset_reg(table, base_index) + opr->reg.offset + comp;
1621  reg_index = get_reg_offset(table, offset);
1622 
1623  if (reg_index >= rs->table_sizes[table])
1624  {
1625  unsigned int wrap_size;
1626 
1627  if (table == PRES_REGTAB_CONST)
1628  {
1629  /* As it can be guessed from tests, offset into floating constant table is wrapped
1630  * to the nearest power of 2 and not to the actual table size. */
1631  for (wrap_size = 1; wrap_size < rs->table_sizes[table]; wrap_size <<= 1)
1632  ;
1633  }
1634  else
1635  {
1636  wrap_size = rs->table_sizes[table];
1637  }
1638  WARN("Wrapping register index %u, table %u, wrap_size %u, table size %u.\n",
1639  reg_index, table, wrap_size, rs->table_sizes[table]);
1640  reg_index %= wrap_size;
1641 
1642  if (reg_index >= rs->table_sizes[table])
1643  return 0.0;
1644 
1646  }
1647 
1648  return exec_get_reg_value(rs, table, offset);
1649 }
static double exec_get_reg_value(struct d3dx_regstore *rs, enum pres_reg_tables table, unsigned int offset)
Definition: preshader.c:1604
#define WARN(fmt,...)
Definition: debug.h:111
GLintptr offset
Definition: glext.h:5920
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
_Check_return_ __CRT_INLINE long lrint(_In_ double x)
Definition: math.h:267
static unsigned int get_reg_offset(unsigned int table, unsigned int offset)
Definition: preshader.c:295
unsigned int table_sizes[PRES_REGTAB_COUNT]
static unsigned int get_reg_components(unsigned int table)
Definition: preshader.c:305
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300
struct d3dx_pres_reg reg
Definition: preshader.c:252
struct d3dx_pres_reg index_reg
Definition: preshader.c:253

Referenced by execute_preshader().

◆ exec_get_reg_value()

static double exec_get_reg_value ( struct d3dx_regstore rs,
enum pres_reg_tables  table,
unsigned int  offset 
)
static

Definition at line 1604 of file preshader.c.

1605 {
1606  return regstore_get_double(rs, table, offset);
1607 }
GLintptr offset
Definition: glext.h:5920
static double regstore_get_double(struct d3dx_regstore *rs, unsigned int table, unsigned int offset)
Definition: preshader.c:349

Referenced by exec_get_arg().

◆ exec_set_arg()

static void exec_set_arg ( struct d3dx_regstore rs,
const struct d3dx_pres_reg reg,
unsigned int  comp,
double  res 
)
static

Definition at line 1651 of file preshader.c.

1653 {
1654  regstore_set_double(rs, reg->table, reg->offset + comp, res);
1655 }
static int reg
Definition: i386-dis.c:1275
GLuint res
Definition: glext.h:9613
static void regstore_set_double(struct d3dx_regstore *rs, unsigned int table, unsigned int offset, double v)
Definition: preshader.c:366

Referenced by execute_preshader().

◆ execute_preshader()

static HRESULT execute_preshader ( struct d3dx_preshader pres)
static

Definition at line 1658 of file preshader.c.

1659 {
1660  unsigned int i, j, k;
1661  double args[ARGS_ARRAY_SIZE];
1662  double res;
1663 
1664  for (i = 0; i < pres->ins_count; ++i)
1665  {
1666  const struct d3dx_pres_ins *ins;
1667  const struct op_info *oi;
1668 
1669  ins = &pres->ins[i];
1670  oi = &pres_op_info[ins->op];
1671  if (oi->func_all_comps)
1672  {
1673  if (oi->input_count * ins->component_count > ARGS_ARRAY_SIZE)
1674  {
1675  FIXME("Too many arguments (%u) for one instruction.\n", oi->input_count * ins->component_count);
1676  return E_FAIL;
1677  }
1678  for (k = 0; k < oi->input_count; ++k)
1679  for (j = 0; j < ins->component_count; ++j)
1680  args[k * ins->component_count + j] = exec_get_arg(&pres->regs, &ins->inputs[k],
1681  ins->scalar_op && !k ? 0 : j);
1682  res = oi->func(args, ins->component_count);
1683 
1684  /* only 'dot' instruction currently falls here */
1685  exec_set_arg(&pres->regs, &ins->output.reg, 0, res);
1686  }
1687  else
1688  {
1689  for (j = 0; j < ins->component_count; ++j)
1690  {
1691  for (k = 0; k < oi->input_count; ++k)
1692  args[k] = exec_get_arg(&pres->regs, &ins->inputs[k], ins->scalar_op && !k ? 0 : j);
1693  res = oi->func(args, ins->component_count);
1694  exec_set_arg(&pres->regs, &ins->output.reg, j, res);
1695  }
1696  }
1697  }
1698  return D3D_OK;
1699 }
static double exec_get_arg(struct d3dx_regstore *rs, const struct d3dx_pres_operand *opr, unsigned int comp)
Definition: preshader.c:1609
#define E_FAIL
Definition: ddrawi.h:102
Definition: match.c:390
BOOL scalar_op
Definition: preshader.c:263
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
enum pres_ops op
Definition: preshader.c:260
#define FIXME(fmt,...)
Definition: debug.h:110
static const struct op_info pres_op_info[]
Definition: preshader.c:167
unsigned int component_count
Definition: preshader.c:264
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
struct d3dx_pres_operand output
Definition: preshader.c:266
unsigned int ins_count
#define D3D_OK
Definition: d3d.h:106
pres_op_func func
Definition: preshader.c:164
struct d3dx_pres_ins * ins
GLuint res
Definition: glext.h:9613
struct d3dx_regstore regs
BOOL func_all_comps
Definition: preshader.c:163
static void exec_set_arg(struct d3dx_regstore *rs, const struct d3dx_pres_reg *reg, unsigned int comp, double res)
Definition: preshader.c:1651
int k
Definition: mpi.c:3369
#define ARGS_ARRAY_SIZE
Definition: preshader.c:1657
struct d3dx_pres_operand inputs[MAX_INPUTS_COUNT]
Definition: preshader.c:265
unsigned int input_count
Definition: preshader.c:162

Referenced by d3dx_evaluate_parameter(), and d3dx_param_eval_set_shader_constants().

◆ find_bytecode_comment()

static unsigned int* find_bytecode_comment ( unsigned int ptr,
unsigned int  count,
unsigned int  fourcc,
unsigned int size 
)
static

Definition at line 400 of file preshader.c.

402 {
403  /* Provide at least one value in comment section on non-NULL return. */
404  while (count > 2 && (*ptr & 0xffff) == 0xfffe)
405  {
406  unsigned int section_size;
407 
408  section_size = (*ptr >> 16);
409  if (!section_size || section_size + 1 > count)
410  break;
411  if (*(ptr + 1) == fourcc)
412  {
413  *size = section_size;
414  return ptr + 2;
415  }
416  count -= section_size + 1;
417  ptr += section_size + 1;
418  }
419  return NULL;
420 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919

Referenced by d3dx_create_param_eval(), and parse_preshader().

◆ get_const_upload_info()

static void get_const_upload_info ( struct d3dx_const_param_eval_output const_set,
struct const_upload_info info 
)
static

Definition at line 556 of file preshader.c.

558 {
559  struct d3dx_parameter *param = const_set->param;
560  unsigned int table = const_set->table;
561 
562  info->transpose = (const_set->constant_class == D3DXPC_MATRIX_COLUMNS && param->class == D3DXPC_MATRIX_ROWS)
563  || (param->class == D3DXPC_MATRIX_COLUMNS && const_set->constant_class == D3DXPC_MATRIX_ROWS);
564  if (const_set->constant_class == D3DXPC_MATRIX_COLUMNS)
565  {
566  info->major = param->columns;
567  info->minor = param->rows;
568  }
569  else
570  {
571  info->major = param->rows;
572  info->minor = param->columns;
573  }
574 
575  if (get_reg_components(table) == 1)
576  {
577  unsigned int const_length = get_offset_reg(table, const_set->register_count);
578 
579  info->major_stride = info->minor;
580  info->major_count = const_length / info->major_stride;
581  info->minor_remainder = const_length % info->major_stride;
582  }
583  else
584  {
585  info->major_stride = get_reg_components(table);
586  info->major_count = const_set->register_count;
587  info->minor_remainder = 0;
588  }
589  info->count = info->major_count * info->minor + info->minor_remainder;
590 }
enum pres_reg_tables table
unsigned int count
Definition: notification.c:64
static unsigned int get_reg_components(unsigned int table)
Definition: preshader.c:305
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300
GLfloat param
Definition: glext.h:5796
enum D3DXPARAMETER_CLASS constant_class
struct d3dx_parameter * param

Referenced by init_set_constants_param(), and set_constants().

◆ get_constants_desc()

static HRESULT get_constants_desc ( unsigned int byte_code,
struct d3dx_const_tab out,
struct d3dx9_base_effect base,
const char **  skip_constants,
unsigned int  skip_constants_count,
struct d3dx_preshader pres 
)
static

Definition at line 861 of file preshader.c.

864 {
865  ID3DXConstantTable *ctab;
866  D3DXCONSTANT_DESC *cdesc;
867  struct d3dx_parameter **inputs_param;
869  HRESULT hr;
870  D3DXHANDLE hc;
871  unsigned int i, j;
872 
873  hr = D3DXGetShaderConstantTable(byte_code, &ctab);
874  if (FAILED(hr) || !ctab)
875  {
876  TRACE("Could not get CTAB data, hr %#x.\n", hr);
877  /* returning OK, shaders and preshaders without CTAB are valid */
878  return D3D_OK;
879  }
880  if (FAILED(hr = ID3DXConstantTable_GetDesc(ctab, &desc)))
881  {
882  FIXME("Could not get CTAB desc, hr %#x.\n", hr);
883  goto cleanup;
884  }
885 
886  out->inputs = cdesc = HeapAlloc(GetProcessHeap(), 0, sizeof(*cdesc) * desc.Constants);
887  out->inputs_param = inputs_param = HeapAlloc(GetProcessHeap(), 0, sizeof(*inputs_param) * desc.Constants);
888  if (!cdesc || !inputs_param)
889  {
890  hr = E_OUTOFMEMORY;
891  goto cleanup;
892  }
893 
894  for (i = 0; i < desc.Constants; ++i)
895  {
896  unsigned int index = out->input_count;
897  WORD constantinfo_reserved;
898 
900  if (!hc)
901  {
902  FIXME("Null constant handle.\n");
903  goto cleanup;
904  }
905  if (FAILED(hr = get_ctab_constant_desc(ctab, hc, &cdesc[index], &constantinfo_reserved)))
906  goto cleanup;
907  inputs_param[index] = get_parameter_by_name(base, NULL, cdesc[index].Name);
908  if (!inputs_param[index])
909  {
910  WARN("Could not find parameter %s in effect.\n", cdesc[index].Name);
911  continue;
912  }
913  if (cdesc[index].Class == D3DXPC_OBJECT)
914  {
915  TRACE("Object %s, parameter %p.\n", cdesc[index].Name, inputs_param[index]);
916  if (cdesc[index].RegisterSet != D3DXRS_SAMPLER || inputs_param[index]->class != D3DXPC_OBJECT
917  || !is_param_type_sampler(inputs_param[index]->type))
918  {
919  WARN("Unexpected object type, constant %s.\n", debugstr_a(cdesc[index].Name));
921  goto cleanup;
922  }
923  if (max(inputs_param[index]->element_count, 1) < cdesc[index].RegisterCount)
924  {
925  WARN("Register count exceeds parameter size, constant %s.\n", debugstr_a(cdesc[index].Name));
927  goto cleanup;
928  }
929  }
930  if (!is_top_level_parameter(inputs_param[index]))
931  {
932  WARN("Expected top level parameter '%s'.\n", debugstr_a(cdesc[index].Name));
933  hr = E_FAIL;
934  goto cleanup;
935  }
936 
937  for (j = 0; j < skip_constants_count; ++j)
938  {
939  if (!strcmp(cdesc[index].Name, skip_constants[j]))
940  {
941  if (!constantinfo_reserved)
942  {
943  WARN("skip_constants parameter %s is not register bound.\n",
944  cdesc[index].Name);
946  goto cleanup;
947  }
948  TRACE("Skipping constant %s.\n", cdesc[index].Name);
949  break;
950  }
951  }
952  if (j < skip_constants_count)
953  continue;
954  ++out->input_count;
955  if (inputs_param[index]->class == D3DXPC_OBJECT)
956  continue;
957  if (FAILED(hr = init_set_constants_param(out, ctab, hc, inputs_param[index])))
958  goto cleanup;
959  }
960  if (pres)
962  if (out->const_set_count)
963  {
964  struct d3dx_const_param_eval_output *new_alloc;
965 
966  qsort(out->const_set, out->const_set_count, sizeof(*out->const_set), compare_const_set);
967 
968  i = 0;
969  while (i < out->const_set_count - 1)
970  {
971  if (out->const_set[i].constant_class == D3DXPC_FORCE_DWORD
972  && out->const_set[i + 1].constant_class == D3DXPC_FORCE_DWORD
973  && out->const_set[i].table == out->const_set[i + 1].table
974  && out->const_set[i].register_index + out->const_set[i].register_count
975  >= out->const_set[i + 1].register_index)
976  {
977  assert(out->const_set[i].register_index + out->const_set[i].register_count
978  <= out->const_set[i + 1].register_index + 1);
979  out->const_set[i].register_count = out->const_set[i + 1].register_index + 1
980  - out->const_set[i].register_index;
981  memmove(&out->const_set[i + 1], &out->const_set[i + 2], sizeof(out->const_set[i])
982  * (out->const_set_count - i - 2));
983  --out->const_set_count;
984  }
985  else
986  {
987  ++i;
988  }
989  }
990 
991  new_alloc = HeapReAlloc(GetProcessHeap(), 0, out->const_set,
992  sizeof(*out->const_set) * out->const_set_count);
993  if (new_alloc)
994  {
995  out->const_set = new_alloc;
996  out->const_set_size = out->const_set_count;
997  }
998  else
999  {
1000  WARN("Out of memory.\n");
1001  }
1002  }
1003 cleanup:
1005  return hr;
1006 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define max(a, b)
Definition: svc.c:63
static int compare_const_set(const void *a, const void *b)
Definition: preshader.c:652
static BOOL is_param_type_sampler(D3DXPARAMETER_TYPE type)
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT init_set_constants_param(struct d3dx_const_tab *const_tab, ID3DXConstantTable *ctab, D3DXHANDLE hc, struct d3dx_parameter *param)
Definition: preshader.c:739
#define D3DERR_INVALIDCALL
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
#define ID3DXConstantTable_GetConstant(p, a, b)
Definition: d3dx9shader.h:185
#define ID3DXConstantTable_Release(p)
Definition: d3dx9shader.h:177
#define E_FAIL
Definition: ddrawi.h:102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const WCHAR desc[]
Definition: protectdata.c:36
static void append_pres_const_sets_for_shader_input(struct d3dx_const_tab *const_tab, struct d3dx_preshader *pres)
Definition: preshader.c:629
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
struct d3dx_parameter * get_parameter_by_name(struct d3dx9_base_effect *base, struct d3dx_parameter *parameter, const char *name) DECLSPEC_HIDDEN
Definition: effect.c:898
static BOOL is_top_level_parameter(struct d3dx_parameter *param)
GLuint index
Definition: glext.h:6031
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
unsigned short WORD
Definition: ntddk_ex.h:93
static FILE * out
Definition: regtests2xml.c:44
HRESULT WINAPI D3DXGetShaderConstantTable(const DWORD *byte_code, ID3DXConstantTable **constant_table)
Definition: shader.c:2104
#define index(s, c)
Definition: various.h:29
#define ID3DXConstantTable_GetDesc(p, a)
Definition: d3dx9shader.h:182
#define D3D_OK
Definition: d3d.h:106
#define HeapReAlloc
Definition: compat.h:393
static HRESULT get_ctab_constant_desc(ID3DXConstantTable *ctab, D3DXHANDLE hc, D3DXCONSTANT_DESC *desc, WORD *constantinfo_reserved)
Definition: preshader.c:538
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * cleanup(char *str)
Definition: wpickclick.c:99

Referenced by d3dx_create_param_eval(), and parse_preshader().

◆ get_ctab_constant_desc()

static HRESULT get_ctab_constant_desc ( ID3DXConstantTable *  ctab,
D3DXHANDLE  hc,
D3DXCONSTANT_DESC desc,
WORD constantinfo_reserved 
)
static

Definition at line 538 of file preshader.c.

540 {
541  const struct ctab_constant *constant = d3dx_shader_get_ctab_constant(ctab, hc);
542 
543  if (!constant)
544  {
545  FIXME("Could not get constant desc.\n");
548  return D3DERR_INVALIDCALL;
549  }
550  *desc = constant->desc;
552  *constantinfo_reserved = constant->constantinfo_reserved;
553  return D3D_OK;
554 }
#define D3DERR_INVALIDCALL
WORD constantinfo_reserved
static const WCHAR desc[]
Definition: protectdata.c:36
#define FIXME(fmt,...)
Definition: debug.h:110
const struct ctab_constant * d3dx_shader_get_ctab_constant(ID3DXConstantTable *iface, D3DXHANDLE constant) DECLSPEC_HIDDEN
Definition: shader.c:977
#define D3D_OK
Definition: d3d.h:106

Referenced by get_constants_desc(), and init_set_constants_param().

◆ get_offset_reg()

static unsigned int get_offset_reg ( unsigned int  table,
unsigned int  reg_idx 
)
static

◆ get_reg_components()

static unsigned int get_reg_components ( unsigned int  table)
static

Definition at line 305 of file preshader.c.

306 {
307  return get_offset_reg(table, 1);
308 }
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300

Referenced by exec_get_arg(), get_const_upload_info(), parse_preshader(), and set_constants().

◆ get_reg_offset()

static unsigned int get_reg_offset ( unsigned int  table,
unsigned int  offset 
)
static

◆ init_set_constants_param()

static HRESULT init_set_constants_param ( struct d3dx_const_tab const_tab,
ID3DXConstantTable *  ctab,
D3DXHANDLE  hc,
struct d3dx_parameter param 
)
static

Definition at line 739 of file preshader.c.

741 {
743  unsigned int const_count, param_count, i;
744  BOOL get_element;
745  struct d3dx_const_param_eval_output const_set;
746  struct const_upload_info info;
747  enum pres_value_type table_type;
748  HRESULT hr;
749 
750  if (FAILED(get_ctab_constant_desc(ctab, hc, &desc, NULL)))
751  return D3DERR_INVALIDCALL;
752 
753  if (param->element_count)
754  {
755  param_count = param->element_count;
756  const_count = desc.Elements;
757  get_element = TRUE;
758  }
759  else
760  {
761  if (desc.Elements > 1)
762  {
763  FIXME("Unexpected number of constant elements %u.\n", desc.Elements);
764  return D3DERR_INVALIDCALL;
765  }
766  param_count = param->member_count;
767  const_count = desc.StructMembers;
768  get_element = FALSE;
769  }
770  if (const_count != param_count)
771  {
772  FIXME("Number of elements or struct members differs between parameter (%u) and constant (%u).\n",
773  param_count, const_count);
774  return D3DERR_INVALIDCALL;
775  }
776  if (const_count)
777  {
778  HRESULT ret = D3D_OK;
779  D3DXHANDLE hc_element;
780  unsigned int index = const_tab->const_set_count;
781 
782  for (i = 0; i < const_count; ++i)
783  {
784  if (get_element)
785  hc_element = ID3DXConstantTable_GetConstantElement(ctab, hc, i);
786  else
787  hc_element = ID3DXConstantTable_GetConstant(ctab, hc, i);
788  if (!hc_element)
789  {
790  FIXME("Could not get constant.\n");
792  }
793  else
794  {
795  hr = init_set_constants_param(const_tab, ctab, hc_element, &param->members[i]);
796  }
797  if (FAILED(hr))
798  ret = hr;
799  }
800  if (FAILED(ret))
801  return ret;
802  return merge_const_set_entries(const_tab, param, index);
803  }
804 
805  TRACE("Constant %s, rows %u, columns %u, class %u, bytes %u.\n",
806  debugstr_a(desc.Name), desc.Rows, desc.Columns, desc.Class, desc.Bytes);
807  TRACE("Parameter %s, rows %u, columns %u, class %u, flags %#x, bytes %u.\n",
808  debugstr_a(param->name), param->rows, param->columns, param->class,
809  param->flags, param->bytes);
810 
811  const_set.element_count = 1;
812  const_set.param = param;
813  const_set.constant_class = desc.Class;
814  if (desc.RegisterSet >= ARRAY_SIZE(shad_regset2table))
815  {
816  FIXME("Unknown register set %u.\n", desc.RegisterSet);
817  return D3DERR_INVALIDCALL;
818  }
819  const_set.register_index = desc.RegisterIndex;
820  const_set.table = const_tab->regset2table[desc.RegisterSet];
821  if (const_set.table >= PRES_REGTAB_COUNT)
822  {
823  ERR("Unexpected register set %u.\n", desc.RegisterSet);
824  return D3DERR_INVALIDCALL;
825  }
826  assert(table_info[const_set.table].component_size == sizeof(unsigned int));
827  assert(param->bytes / (param->rows * param->columns) == sizeof(unsigned int));
828  const_set.register_count = desc.RegisterCount;
829  table_type = table_info[const_set.table].type;
830  get_const_upload_info(&const_set, &info);
831  if (!info.count)
832  {
833  TRACE("%s has zero count, skipping.\n", debugstr_a(param->name));
834  return D3D_OK;
835  }
836 
838  return D3DERR_INVALIDCALL;
839 
840  const_set.direct_copy = table_type_from_param_type(param->type) == table_type
841  && !info.transpose && info.minor == info.major_stride
842  && info.count == get_offset_reg(const_set.table, const_set.register_count)
843  && info.count * sizeof(unsigned int) <= param->bytes;
844  if (info.minor_remainder && !const_set.direct_copy && !info.transpose)
845  FIXME("Incomplete last row for not transposed matrix which cannot be directly copied, parameter %s.\n",
846  debugstr_a(param->name));
847 
848  if (info.major_count > info.major
849  || (info.major_count == info.major && info.minor_remainder))
850  {
851  WARN("Constant dimensions exceed parameter size.\n");
852  return D3DERR_INVALIDCALL;
853  }
854 
855  if (FAILED(hr = append_const_set(const_tab, &const_set)))
856  return hr;
857 
858  return D3D_OK;
859 }
#define ID3DXConstantTable_GetConstantElement(p, a, b)
Definition: d3dx9shader.h:187
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT init_set_constants_param(struct d3dx_const_tab *const_tab, ID3DXConstantTable *ctab, D3DXHANDLE hc, struct d3dx_parameter *param)
Definition: preshader.c:739
#define D3DERR_INVALIDCALL
#define assert(x)
Definition: debug.h:53
#define ID3DXConstantTable_GetConstant(p, a, b)
Definition: d3dx9shader.h:185
static const struct @243 table_info[]
static enum pres_value_type table_type_from_param_type(D3DXPARAMETER_TYPE type)
Definition: preshader.c:279
unsigned int count
Definition: notification.c:64
pres_value_type
Definition: preshader.c:196
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR desc[]
Definition: protectdata.c:36
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static void get_const_upload_info(struct d3dx_const_param_eval_output *const_set, struct const_upload_info *info)
Definition: preshader.c:556
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300
static enum pres_reg_tables shad_regset2table[]
Definition: preshader.c:234
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
GLfloat param
Definition: glext.h:5796
int ret
#define ERR(fmt,...)
Definition: debug.h:109
#define D3D_OK
Definition: d3d.h:106
#define ARRAY_SIZE(a)
Definition: main.h:24
static HRESULT merge_const_set_entries(struct d3dx_const_tab *const_tab, struct d3dx_parameter *param, unsigned int index)
Definition: preshader.c:662
static HRESULT get_ctab_constant_desc(ID3DXConstantTable *ctab, D3DXHANDLE hc, D3DXCONSTANT_DESC *desc, WORD *constantinfo_reserved)
Definition: preshader.c:538
unsigned int const_set_count
enum pres_reg_tables * regset2table
static HRESULT append_const_set(struct d3dx_const_tab *const_tab, struct d3dx_const_param_eval_output *set)
Definition: preshader.c:594
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by get_constants_desc().

◆ is_const_tab_input_dirty()

static BOOL is_const_tab_input_dirty ( struct d3dx_const_tab ctab,
ULONG64  update_version 
)
static

Definition at line 1701 of file preshader.c.

1702 {
1703  unsigned int i;
1704 
1705  if (update_version == ULONG64_MAX)
1706  update_version = ctab->update_version;
1707  for (i = 0; i < ctab->input_count; ++i)
1708  {
1710  update_version))
1711  return TRUE;
1712  }
1713  return FALSE;
1714 }
#define TRUE
Definition: types.h:120
struct d3dx_parameter ** inputs_param
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static BOOL is_top_level_param_dirty(struct d3dx_top_level_parameter *param, ULONG64 update_version)
unsigned int input_count
#define ULONG64_MAX
Definition: d3dx9_private.h:33
static struct d3dx_top_level_parameter * top_level_parameter_from_parameter(struct d3dx_parameter *param)
ULONG64 update_version

Referenced by d3dx_evaluate_parameter(), d3dx_param_eval_set_shader_constants(), and is_param_eval_input_dirty().

◆ is_param_eval_input_dirty()

BOOL is_param_eval_input_dirty ( struct d3dx_param_eval peval,
ULONG64  update_version 
)

Definition at line 1716 of file preshader.c.

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

Referenced by d3dx9_get_param_value_ptr().

◆ merge_const_set_entries()

static HRESULT merge_const_set_entries ( struct d3dx_const_tab const_tab,
struct d3dx_parameter param,
unsigned int  index 
)
static

Definition at line 662 of file preshader.c.

664 {
665  unsigned int i, start_index = index;
666  DWORD *current_data;
667  enum pres_reg_tables current_table;
668  unsigned int current_start_offset, element_count;
669  struct d3dx_const_param_eval_output *first_const;
670 
671  if (!const_tab->const_set_count)
672  return D3D_OK;
673 
674  while (index < const_tab->const_set_count - 1)
675  {
676  first_const = &const_tab->const_set[index];
677  current_data = first_const->param->data;
678  current_table = first_const->table;
679  current_start_offset = get_offset_reg(current_table, first_const->register_index);
680  element_count = 0;
681  for (i = index; i < const_tab->const_set_count; ++i)
682  {
683  struct d3dx_const_param_eval_output *const_set = &const_tab->const_set[i];
684  unsigned int count = get_offset_reg(const_set->table,
685  const_set->register_count * const_set->element_count);
686  unsigned int start_offset = get_offset_reg(const_set->table, const_set->register_index);
687 
688  if (!(const_set->table == current_table && current_start_offset == start_offset
689  && const_set->direct_copy == first_const->direct_copy
690  && current_data == const_set->param->data
691  && (const_set->direct_copy || (first_const->param->type == const_set->param->type
692  && first_const->param->class == const_set->param->class
693  && first_const->param->columns == const_set->param->columns
694  && first_const->param->rows == const_set->param->rows
695  && first_const->register_count == const_set->register_count
696  && (i == const_tab->const_set_count - 1
697  || first_const->param->element_count == const_set->param->element_count)))))
698  break;
699 
700  current_start_offset += count;
701  current_data += const_set->direct_copy ? count : const_set->param->rows
702  * const_set->param->columns * const_set->element_count;
703  element_count += const_set->element_count;
704  }
705 
706  if (i > index + 1)
707  {
708  TRACE("Merging %u child parameters for %s, not merging %u, direct_copy %#x.\n", i - index,
709  debugstr_a(param->name), const_tab->const_set_count - i, first_const->direct_copy);
710 
711  first_const->element_count = element_count;
712  if (first_const->direct_copy)
713  {
714  first_const->element_count = 1;
715  if (index == start_index
716  && !(param->type == D3DXPT_VOID && param->class == D3DXPC_STRUCT))
717  {
719  return D3DERR_INVALIDCALL;
720  first_const->param = param;
721  }
722  first_const->register_count = get_reg_offset(current_table, current_start_offset)
723  - first_const->register_index;
724  }
725  memmove(&const_tab->const_set[index + 1], &const_tab->const_set[i],
726  sizeof(*const_tab->const_set) * (const_tab->const_set_count - i));
727  const_tab->const_set_count -= i - index - 1;
728  }
729  else
730  {
731  TRACE("Not merging %u child parameters for %s, direct_copy %#x.\n",
732  const_tab->const_set_count - i, debugstr_a(param->name), first_const->direct_copy);
733  }
734  index = i;
735  }
736  return D3D_OK;
737 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
GLuint GLuint GLsizei count
Definition: gl.h:1545
enum pres_reg_tables table
#define D3DERR_INVALIDCALL
static enum pres_value_type table_type_from_param_type(D3DXPARAMETER_TYPE type)
Definition: preshader.c:279
struct d3dx_const_param_eval_output * const_set
static unsigned int get_reg_offset(unsigned int table, unsigned int offset)
Definition: preshader.c:295
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
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300
#define debugstr_a
Definition: kernel32.h:31
pres_reg_tables
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
#define index(s, c)
Definition: various.h:29
#define D3D_OK
Definition: d3d.h:106
unsigned int const_set_count
struct d3dx_parameter * param

Referenced by init_set_constants_param().

◆ parse_pres_arg()

static unsigned int* parse_pres_arg ( unsigned int ptr,
unsigned int  count,
struct d3dx_pres_operand opr 
)
static

Definition at line 441 of file preshader.c.

442 {
443  if (count < 3 || (*ptr && count < 5))
444  {
445  WARN("Byte code buffer ends unexpectedly, count %u.\n", count);
446  return NULL;
447  }
448 
449  if (*ptr)
450  {
451  if (*ptr != 1)
452  {
453  FIXME("Unknown relative addressing flag, word %#x.\n", *ptr);
454  return NULL;
455  }
456  ptr = parse_pres_reg(ptr + 1, &opr->index_reg);
457  if (!ptr)
458  return NULL;
459  }
460  else
461  {
462  opr->index_reg.table = PRES_REGTAB_COUNT;
463  ++ptr;
464  }
465 
466  ptr = parse_pres_reg(ptr, &opr->reg);
467 
468  if (opr->reg.table == PRES_REGTAB_OBCONST)
469  opr->reg.offset /= 4;
470  return ptr;
471 }
static unsigned int * parse_pres_reg(unsigned int *ptr, struct d3dx_pres_reg *reg)
Definition: preshader.c:422
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:111
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
struct d3dx_pres_reg reg
Definition: preshader.c:252
struct d3dx_pres_reg index_reg
Definition: preshader.c:253

Referenced by parse_pres_ins().

◆ parse_pres_ins()

static unsigned int* parse_pres_ins ( unsigned int ptr,
unsigned int  count,
struct d3dx_pres_ins ins 
)
static

Definition at line 473 of file preshader.c.

474 {
475  unsigned int ins_code, ins_raw;
476  unsigned int input_count;
477  unsigned int i;
478 
479  if (count < 2)
480  {
481  WARN("Byte code buffer ends unexpectedly.\n");
482  return NULL;
483  }
484 
485  ins_raw = *ptr++;
486  ins_code = (ins_raw & PRES_OPCODE_MASK) >> PRES_OPCODE_SHIFT;
487  ins->component_count = ins_raw & PRES_NCOMP_MASK;
488  ins->scalar_op = !!(ins_raw & PRES_SCALAR_FLAG);
489 
490  if (ins->component_count < 1 || ins->component_count > 4)
491  {
492  FIXME("Unsupported number of components %u.\n", ins->component_count);
493  return NULL;
494  }
495  input_count = *ptr++;
496  count -= 2;
497  for (i = 0; i < ARRAY_SIZE(pres_op_info); ++i)
498  if (ins_code == pres_op_info[i].opcode && input_count == pres_op_info[i].input_count)
499  break;
500  if (i == ARRAY_SIZE(pres_op_info))
501  {
502  FIXME("Unknown opcode %#x, input_count %u, raw %#x.\n", ins_code, input_count, ins_raw);
503  return NULL;
504  }
505  ins->op = i;
506  if (input_count > ARRAY_SIZE(ins->inputs))
507  {
508  FIXME("Actual input args count %u exceeds inputs array size, instruction %s.\n", input_count,
509  pres_op_info[i].mnem);
510  return NULL;
511  }
512  for (i = 0; i < input_count; ++i)
513  {
514  unsigned int *p;
515 
516  p = parse_pres_arg(ptr, count, &ins->inputs[i]);
517  if (!p)
518  return NULL;
519  count -= p - ptr;
520  ptr = p;
521  }
522  ptr = parse_pres_arg(ptr, count, &ins->output);
523  if (ins->output.index_reg.table != PRES_REGTAB_COUNT)
524  {
525  FIXME("Relative addressing in output register not supported.\n");
526  return NULL;
527  }
528  if (get_reg_offset(ins->output.reg.table, ins->output.reg.offset
529  + (pres_op_info[ins->op].func_all_comps ? 0 : ins->component_count - 1))
530  != get_reg_offset(ins->output.reg.table, ins->output.reg.offset))
531  {
532  FIXME("Instructions outputting multiple registers are not supported.\n");
533  return NULL;
534  }
535  return ptr;
536 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:111
#define PRES_NCOMP_MASK
Definition: preshader.c:150
static unsigned int * parse_pres_arg(unsigned int *ptr, unsigned int count, struct d3dx_pres_operand *opr)
Definition: preshader.c:441
BOOL scalar_op
Definition: preshader.c:263
static unsigned int get_reg_offset(unsigned int table, unsigned int offset)
Definition: preshader.c:295
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
enum pres_ops op
Definition: preshader.c:260
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
static const struct op_info pres_op_info[]
Definition: preshader.c:167
smooth NULL
Definition: ftsmooth.c:416
unsigned int component_count
Definition: preshader.c:264
#define PRES_SCALAR_FLAG
Definition: preshader.c:149
struct d3dx_pres_operand output
Definition: preshader.c:266
#define PRES_OPCODE_SHIFT
Definition: preshader.c:148
#define PRES_OPCODE_MASK
Definition: preshader.c:147
#define ARRAY_SIZE(a)
Definition: main.h:24
GLfloat GLfloat p
Definition: glext.h:8902
struct d3dx_pres_operand inputs[MAX_INPUTS_COUNT]
Definition: preshader.c:265

Referenced by parse_preshader().

◆ parse_pres_reg()

static unsigned int* parse_pres_reg ( unsigned int ptr,
struct d3dx_pres_reg reg 
)
static

Definition at line 422 of file preshader.c.

423 {
424  static const enum pres_reg_tables reg_table[8] =
425  {
428  };
429 
430  if (*ptr >= ARRAY_SIZE(reg_table) || reg_table[*ptr] == PRES_REGTAB_COUNT)
431  {
432  FIXME("Unsupported register table %#x.\n", *ptr);
433  return NULL;
434  }
435 
436  reg->table = reg_table[*ptr++];
437  reg->offset = *ptr++;
438  return ptr;
439 }
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
pres_reg_tables
#define ARRAY_SIZE(a)
Definition: main.h:24
static int reg
Definition: i386-dis.c:1275

Referenced by parse_pres_arg().

◆ parse_preshader()

static HRESULT parse_preshader ( struct d3dx_preshader pres,
unsigned int ptr,
unsigned int  count,
struct d3dx9_base_effect base 
)
static

Definition at line 1112 of file preshader.c.

1113 {
1114  unsigned int *p;
1115  unsigned int i, j, const_count;
1116  double *dconst;
1117  HRESULT hr;
1118  unsigned int saved_word;
1119  unsigned int section_size;
1120 
1121  TRACE("Preshader version %#x.\n", *ptr & 0xffff);
1122 
1123  if (!count)
1124  {
1125  WARN("Unexpected end of byte code buffer.\n");
1126  return D3DXERR_INVALIDDATA;
1127  }
1128 
1129  p = find_bytecode_comment(ptr + 1, count - 1, FOURCC_CLIT, &section_size);
1130  if (p)
1131  {
1132  const_count = *p++;
1133  if (const_count > (section_size - 1) / (sizeof(double) / sizeof(unsigned int)))
1134  {
1135  WARN("Byte code buffer ends unexpectedly.\n");
1136  return D3DXERR_INVALIDDATA;
1137  }
1138  dconst = (double *)p;
1139  }
1140  else
1141  {
1142  const_count = 0;
1143  dconst = NULL;
1144  }
1145  TRACE("%u double constants.\n", const_count);
1146 
1147  p = find_bytecode_comment(ptr + 1, count - 1, FOURCC_FXLC, &section_size);
1148  if (!p)
1149  {
1150  WARN("Could not find preshader code.\n");
1151  return D3D_OK;
1152  }
1153  pres->ins_count = *p++;
1154  --section_size;
1155  if (pres->ins_count > UINT_MAX / sizeof(*pres->ins))
1156  {
1157  WARN("Invalid instruction count %u.\n", pres->ins_count);
1158  return D3DXERR_INVALIDDATA;
1159  }
1160  TRACE("%u instructions.\n", pres->ins_count);
1161  pres->ins = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pres->ins) * pres->ins_count);
1162  if (!pres->ins)
1163  return E_OUTOFMEMORY;
1164  for (i = 0; i < pres->ins_count; ++i)
1165  {
1166  unsigned int *ptr_next;
1167 
1168  ptr_next = parse_pres_ins(p, section_size, &pres->ins[i]);
1169  if (!ptr_next)
1170  return D3DXERR_INVALIDDATA;
1171  section_size -= ptr_next - p;
1172  p = ptr_next;
1173  }
1174 
1175  pres->inputs.regset2table = pres_regset2table;
1176 
1177  saved_word = *ptr;
1178  *ptr = 0xfffe0000;
1179  hr = get_constants_desc(ptr, &pres->inputs, base, NULL, 0, NULL);
1180  *ptr = saved_word;
1181  if (FAILED(hr))
1182  return hr;
1183 
1184  if (const_count % get_reg_components(PRES_REGTAB_IMMED))
1185  {
1186  FIXME("const_count %u is not a multiple of %u.\n", const_count,
1188  return D3DXERR_INVALIDDATA;
1189  }
1190  pres->regs.table_sizes[PRES_REGTAB_IMMED] = get_reg_offset(PRES_REGTAB_IMMED, const_count);
1191 
1192  update_table_sizes_consts(pres->regs.table_sizes, &pres->inputs);
1193  for (i = 0; i < pres->ins_count; ++i)
1194  {
1195  for (j = 0; j < pres_op_info[pres->ins[i].op].input_count; ++j)
1196  {
1197  enum pres_reg_tables table;
1198  unsigned int reg_idx;
1199 
1200  if (pres->ins[i].inputs[j].index_reg.table == PRES_REGTAB_COUNT)
1201  {
1202  unsigned int last_component_index = pres->ins[i].scalar_op && !j ? 0
1203  : pres->ins[i].component_count - 1;
1204 
1205  table = pres->ins[i].inputs[j].reg.table;
1206  reg_idx = get_reg_offset(table, pres->ins[i].inputs[j].reg.offset
1207  + last_component_index);
1208  }
1209  else
1210  {
1211  table = pres->ins[i].inputs[j].index_reg.table;
1212  reg_idx = get_reg_offset(table, pres->ins[i].inputs[j].index_reg.offset);
1213  }
1214  if (reg_idx >= pres->regs.table_sizes[table])
1215  {
1216  /* Native accepts these broken preshaders. */
1217  FIXME("Out of bounds register index, i %u, j %u, table %u, reg_idx %u, preshader parsing failed.\n",
1218  i, j, table, reg_idx);
1219  return D3DXERR_INVALIDDATA;
1220  }
1221  }
1222  update_table_size(pres->regs.table_sizes, pres->ins[i].output.reg.table,
1223  get_reg_offset(pres->ins[i].output.reg.table, pres->ins[i].output.reg.offset));
1224  }
1226  return E_OUTOFMEMORY;
1227  regstore_set_values(&pres->regs, PRES_REGTAB_IMMED, dconst, 0, const_count);
1228 
1229  return D3D_OK;
1230 }
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:111
static enum pres_reg_tables pres_regset2table[]
Definition: preshader.c:226
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static unsigned int get_reg_offset(unsigned int table, unsigned int offset)
Definition: preshader.c:295
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static void regstore_set_values(struct d3dx_regstore *rs, unsigned int table, const void *data, unsigned int start_offset, unsigned int count)
Definition: preshader.c:336
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
static unsigned int get_reg_components(unsigned int table)
Definition: preshader.c:305
static void update_table_size(unsigned int *table_sizes, unsigned int table, unsigned int max_register)
Definition: preshader.c:1008
static const struct op_info pres_op_info[]
Definition: preshader.c:167
smooth NULL
Definition: ftsmooth.c:416
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define FOURCC_FXLC
Definition: preshader.c:154
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
pres_reg_tables
#define FOURCC_CLIT
Definition: preshader.c:153
unsigned int ins_count
#define UINT_MAX
Definition: limits.h:41
#define D3D_OK
Definition: d3d.h:106
static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab *out, struct d3dx9_base_effect *base, const char **skip_constants, unsigned int skip_constants_count, struct d3dx_preshader *pres)
Definition: preshader.c:861
static HRESULT regstore_alloc_table(struct d3dx_regstore *rs, unsigned int table)
Definition: preshader.c:312
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
struct d3dx_pres_ins * ins
static void update_table_sizes_consts(unsigned int *table_sizes, struct d3dx_const_tab *ctab)
Definition: preshader.c:1014
struct d3dx_regstore regs
struct d3dx_const_tab inputs
GLfloat GLfloat p
Definition: glext.h:8902
static unsigned int * parse_pres_ins(unsigned int *ptr, unsigned int count, struct d3dx_pres_ins *ins)
Definition: preshader.c:473
static unsigned int * find_bytecode_comment(unsigned int *ptr, unsigned int count, unsigned int fourcc, unsigned int *size)
Definition: preshader.c:400

Referenced by d3dx_create_param_eval().

◆ pres_acos()

static double pres_acos ( double args,
int  n 
)
static

Definition at line 139 of file preshader.c.

139 {return to_signed_nan(acos(args[0]));}
static double to_signed_nan(double v)
Definition: preshader.c:64
Definition: match.c:390
valarray< _Tp > acos(const valarray< _Tp > &__x)
Definition: _valarray.h:901

◆ pres_add()

static double pres_add ( double args,
int  n 
)
static

Definition at line 80 of file preshader.c.

80 {return args[0] + args[1];}
Definition: match.c:390

◆ pres_asin()

static double pres_asin ( double args,
int  n 
)
static

Definition at line 138 of file preshader.c.

138 {return to_signed_nan(asin(args[0]));}
static double to_signed_nan(double v)
Definition: preshader.c:64
Definition: match.c:390
valarray< _Tp > asin(const valarray< _Tp > &__x)
Definition: _valarray.h:910

◆ pres_atan()

static double pres_atan ( double args,
int  n 
)
static

Definition at line 140 of file preshader.c.

140 {return atan(args[0]);}
Definition: match.c:390
valarray< _Tp > atan(const valarray< _Tp > &__x)
Definition: _valarray.h:919

◆ pres_atan2()

static double pres_atan2 ( double args,
int  n 
)
static

Definition at line 141 of file preshader.c.

141 {return atan2(args[0], args[1]);}
valarray< _Tp > atan2(const valarray< _Tp > &__x, const valarray< _Tp > &__y)
Definition: _valarray.h:928
Definition: match.c:390

◆ pres_bool_from_value()

static void pres_bool_from_value ( void out,
const void in,
unsigned int  count 
)
static

Definition at line 1379 of file preshader.c.

1380 {
1381  unsigned int i;
1382  const DWORD *in_dword = in;
1383  BOOL *out_bool = out;
1384 
1385  for (i = 0; i < count; ++i)
1386  out_bool[i] = !!in_dword[i];
1387 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint in
Definition: glext.h:9616

Referenced by regstore_set_data().

◆ pres_cmp()

static double pres_cmp ( double args,
int  n 
)
static

Definition at line 110 of file preshader.c.

110 {return args[0] >= 0.0 ? args[1] : args[2];}
Definition: match.c:390

◆ pres_cos()

static double pres_cos ( double args,
int  n 
)
static

Definition at line 112 of file preshader.c.

112 {return cos(args[0]);}
Definition: match.c:390
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)

◆ pres_div()

static double pres_div ( double args,
int  n 
)
static

Definition at line 145 of file preshader.c.

145 {return 0.0;}

◆ pres_dot()

static double pres_dot ( double args,
int  n 
)
static

Definition at line 82 of file preshader.c.

83 {
84  int i;
85  double sum;
86 
87  sum = 0.0;
88  for (i = 0; i < n; ++i)
89  sum += args[i] * args[i + n];
90  return sum;
91 }
GLdouble n
Definition: glext.h:7729
Definition: match.c:390
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35

Referenced by pres_dotswiz6(), and pres_dotswiz8().

◆ pres_dotswiz6()

static double pres_dotswiz6 ( double args,
int  n 
)
static

Definition at line 93 of file preshader.c.

94 {
95  return pres_dot(args, 3);
96 }
Definition: match.c:390
static double pres_dot(double *args, int n)
Definition: preshader.c:82

◆ pres_dotswiz8()

static double pres_dotswiz8 ( double args,
int  n 
)
static

Definition at line 98 of file preshader.c.

99 {
100  return pres_dot(args, 4);
101 }
Definition: match.c:390
static double pres_dot(double *args, int n)
Definition: preshader.c:82

◆ pres_exp()

static double pres_exp ( double args,
int  n 
)
static

Definition at line 123 of file preshader.c.

123 {return pow(2.0, args[0]);}
Definition: match.c:390
float pow(float __x, int __y)
Definition: _cmath.h:458

◆ pres_float_from_bool()

static void pres_float_from_bool ( void out,
const void in,
unsigned int  count 
)
static

Definition at line 1399 of file preshader.c.

1400 {
1401  unsigned int i;
1402  const BOOL *in_bool = in;
1403  float *out_float = out;
1404 
1405  for (i = 0; i < count; ++i)
1406  out_float[i] = !!in_bool[i];
1407 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616

Referenced by regstore_set_data().

◆ pres_float_from_int()

static void pres_float_from_int ( void out,
const void in,
unsigned int  count 
)
static

Definition at line 1389 of file preshader.c.

1390 {
1391  unsigned int i;
1392  const int *in_int = in;
1393  float *out_float = out;
1394 
1395  for (i = 0; i < count; ++i)
1396  out_float[i] = in_int[i];
1397 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616

Referenced by regstore_set_data().

◆ pres_frc()

static double pres_frc ( double args,
int  n 
)
static

Definition at line 107 of file preshader.c.

107 {return args[0] - floor(args[0]);}
Definition: match.c:390
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)

◆ pres_ge()

static double pres_ge ( double args,
int  n 
)
static

Definition at line 106 of file preshader.c.

106 {return args[0] >= args[1] ? 1.0 : 0.0;}
Definition: match.c:390

◆ pres_int_from_bool()

static void pres_int_from_bool ( void out,
const void in,
unsigned int  count 
)
static

Definition at line 1409 of file preshader.c.

1410 {
1411  unsigned int i;
1412  const float *in_bool = in;
1413  int *out_int = out;
1414 
1415  for (i = 0; i < count; ++i)
1416  out_int[i] = !!in_bool[i];
1417 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616

Referenced by regstore_set_data().

◆ pres_int_from_float()

static void pres_int_from_float ( void out,
const void in,
unsigned int  count 
)
static

Definition at line 1369 of file preshader.c.

1370 {
1371  unsigned int i;
1372  const float *in_float = in;
1373  int *out_int = out;
1374 
1375  for (i = 0; i < count; ++i)
1376  out_int[i] = in_float[i];
1377 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616

Referenced by regstore_set_data().

◆ pres_log()

static double pres_log ( double args,
int  n 
)
static

Definition at line 124 of file preshader.c.

125 {
126  double v;
127 
128  v = fabs(args[0]);
129  if (v == 0.0)
130  return 0.0;
131  else
132 #ifdef HAVE_LOG2
133  return log2(v);
134 #else
135  return log(v) / log(2);
136 #endif
137 }
Definition: match.c:390
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
const GLdouble * v
Definition: gl.h:2040
double __cdecl log2(double)
#define log(outFile, fmt,...)
Definition: util.h:15

◆ pres_lt()

static double pres_lt ( double args,
int  n 
)
static

Definition at line 105 of file preshader.c.

105 {return args[0] < args[1] ? 1.0 : 0.0;}
Definition: match.c:390

◆ pres_max()

static double pres_max ( double args,
int  n 
)
static

Definition at line 109 of file preshader.c.

109 {return fmax(args[0], args[1]);}
Definition: match.c:390
#define fmax
Definition: preshader.c:31

◆ pres_min()

static double pres_min ( double args,
int  n 
)
static

Definition at line 108 of file preshader.c.

108 {return fmin(args[0], args[1]);}
#define fmin
Definition: preshader.c:30
Definition: match.c:390

◆ pres_mov()

static double pres_mov ( double args,
int  n 
)
static

Definition at line 79 of file preshader.c.

79 {return args[0];}
Definition: match.c:390

◆ pres_mul()

static double pres_mul ( double args,
int  n 
)
static

Definition at line 81 of file preshader.c.

81 {return args[0] * args[1];}
Definition: match.c:390

◆ pres_neg()

static double pres_neg ( double args,
int  n 
)
static

Definition at line 103 of file preshader.c.

103 {return -args[0];}
Definition: match.c:390

◆ pres_rcp()

static double pres_rcp ( double args,
int  n 
)
static

Definition at line 104 of file preshader.c.

104 {return 1.0 / args[0];}
Definition: match.c:390

◆ pres_rsq()

static double pres_rsq ( double args,
int  n 
)
static

Definition at line 113 of file preshader.c.

114 {
115  double v;
116 
117  v = fabs(args[0]);
118  if (v == 0.0)
119  return INFINITY;
120  else
121  return 1.0 / sqrt(v);
122 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
Definition: match.c:390
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
const GLdouble * v
Definition: gl.h:2040
#define INFINITY
Definition: misc.c:36

◆ pres_sin()

static double pres_sin ( double args,
int  n 
)
static

Definition at line 111 of file preshader.c.

111 {return sin(args[0]);}
Definition: match.c:390
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)

◆ regstore_alloc_table()

static HRESULT regstore_alloc_table ( struct d3dx_regstore rs,
unsigned int  table 
)
static

Definition at line 312 of file preshader.c.

313 {
314  unsigned int size;
315 
316  size = get_offset_reg(table, rs->table_sizes[table]) * table_info[table].component_size;
317  if (size)
318  {
320  if (!rs->tables[table])
321  return E_OUTOFMEMORY;
322  }
323  return D3D_OK;
324 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static const struct @243 table_info[]
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int table_sizes[PRES_REGTAB_COUNT]
static unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void * tables[PRES_REGTAB_COUNT]
#define D3D_OK
Definition: d3d.h:106
#define HEAP_ZERO_MEMORY
Definition: compat.h:123

Referenced by d3dx_create_param_eval(), and parse_preshader().

◆ regstore_free_tables()

static void regstore_free_tables ( struct d3dx_regstore rs)
static

Definition at line 326 of file preshader.c.

327 {
328  unsigned int i;
329 
330  for (i = 0; i < PRES_REGTAB_COUNT; ++i)
331  {
332  HeapFree(GetProcessHeap(), 0, rs->tables[i]);
333  }
334 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GetProcessHeap()
Definition: compat.h:395
void * tables[PRES_REGTAB_COUNT]
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by d3dx_free_preshader().

◆ regstore_get_double()

static double regstore_get_double ( struct d3dx_regstore rs,
unsigned int  table,
unsigned int  offset 
)
static

Definition at line 349 of file preshader.c.

350 {
351  BYTE *p;
352 
353  p = (BYTE *)rs->tables[table] + table_info[table].component_size * offset;
355  {
356  case PRES_VT_FLOAT:
357  return *(float *)p;
358  case PRES_VT_DOUBLE:
359  return *(double *)p;
360  default:
361  FIXME("Unexpected preshader input from table %u.\n", table);
362  return NAN;
363  }
364 }
GLintptr offset
Definition: glext.h:5920
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static const struct @243 table_info[]
#define FIXME(fmt,...)
Definition: debug.h:110
switch(r->id)
Definition: btrfs.c:2904
#define NAN
Definition: misc.c:46
void * tables[PRES_REGTAB_COUNT]
unsigned char BYTE
Definition: mem.h:68
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by exec_get_reg_value().

◆ regstore_set_data()

static void regstore_set_data ( struct d3dx_regstore rs,
unsigned int  table,
unsigned int  offset,
const unsigned int in,
unsigned int  count,
enum pres_value_type  param_type 
)
static

Definition at line 1419 of file preshader.c.

1421 {
1422  typedef void (*conv_func)(void *out, const void *in, unsigned int count);
1423  static const conv_func set_const_funcs[PRES_VT_COUNT][PRES_VT_COUNT] =
1424  {
1426  {NULL, NULL, NULL, NULL},
1429  };
1430  enum pres_value_type table_type = table_info[table].type;
1431 
1432  if (param_type == table_type)
1433  {
1435  return;
1436  }
1437 
1438  set_const_funcs[param_type][table_type]((unsigned int *)rs->tables[table] + offset, in, count);
1439 }
static void pres_int_from_float(void *out, const void *in, unsigned int count)
Definition: preshader.c:1369
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLintptr offset
Definition: glext.h:5920
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static void pres_int_from_bool(void *out, const void *in, unsigned int count)
Definition: preshader.c:1409
static const struct @243 table_info[]
static void pres_bool_from_value(void *out, const void *in, unsigned int count)
Definition: preshader.c:1379
pres_value_type
Definition: preshader.c:196
static void regstore_set_values(struct d3dx_regstore *rs, unsigned int table, const void *data, unsigned int start_offset, unsigned int count)
Definition: preshader.c:336
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
void * tables[PRES_REGTAB_COUNT]
GLuint in
Definition: glext.h:9616
static void pres_float_from_bool(void *out, const void *in, unsigned int count)
Definition: preshader.c:1399
static void pres_float_from_int(void *out, const void *in, unsigned int count)
Definition: preshader.c:1389

Referenced by set_constants().

◆ regstore_set_double()

static void regstore_set_double ( struct d3dx_regstore rs,
unsigned int  table,
unsigned int  offset,
double  v 
)
static

Definition at line 366 of file preshader.c.

367 {
368  BYTE *p;
369 
370  p = (BYTE *)rs->tables[table] + table_info[table].component_size * offset;
372  {
373  case PRES_VT_FLOAT : *(float *)p = v; break;
374  case PRES_VT_DOUBLE: *(double *)p = v; break;
375  case PRES_VT_INT : *(int *)p = lrint(v); break;
376  case PRES_VT_BOOL : *(BOOL *)p = !!v; break;
377  default:
378  FIXME("Bad type %u.\n", table_info[table].type);
379  break;
380  }
381 }
GLintptr offset
Definition: glext.h:5920
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static const struct @243 table_info[]
_Check_return_ __CRT_INLINE long lrint(_In_ double x)
Definition: math.h:267
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
switch(r->id)
Definition: btrfs.c:2904
void * tables[PRES_REGTAB_COUNT]
unsigned char BYTE
Definition: mem.h:68
const GLdouble * v
Definition: gl.h:2040
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by exec_set_arg().

◆ regstore_set_values()

static void regstore_set_values ( struct d3dx_regstore rs,
unsigned int  table,
const void data,
unsigned int  start_offset,
unsigned int  count 
)
static

Definition at line 336 of file preshader.c.

338 {
339  BYTE *dst = rs->tables[table];
340  const BYTE *src = data;
341  unsigned int size;
342 
343  dst += start_offset * table_info[table].component_size;
344  size = count * table_info[table].component_size;
345  assert((src < dst && size <= dst - src) || (src > dst && size <= src - dst));
346  memcpy(dst, src, size);
347 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static const struct @243 table_info[]
GLsizeiptr size
Definition: glext.h:5919
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
void * tables[PRES_REGTAB_COUNT]
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by parse_preshader(), regstore_set_data(), and set_constants().

◆ set_constants()

static HRESULT set_constants ( struct d3dx_regstore rs,
struct d3dx_const_tab const_tab,
ULONG64  new_update_version,
ID3DXEffectStateManager *  manager,
struct IDirect3DDevice9 *  device,
D3DXPARAMETER_TYPE  type,
BOOL  device_update_all,
BOOL  pres_dirty 
)
static

Definition at line 1482 of file preshader.c.

1485 {
1486  unsigned int const_idx;
1487  unsigned int current_start = 0, current_count = 0;
1488  enum pres_reg_tables current_table = PRES_REGTAB_COUNT;
1489  BOOL update_device = manager || device;
1490  HRESULT hr, result = D3D_OK;
1491  ULONG64 update_version = const_tab->update_version;
1492 
1493  for (const_idx = 0; const_idx < const_tab->const_set_count; ++const_idx)
1494  {
1495  struct d3dx_const_param_eval_output *const_set = &const_tab->const_set[const_idx];
1496  enum pres_reg_tables table = const_set->table;
1497  struct d3dx_parameter *param = const_set->param;
1498  unsigned int element, i, j, start_offset;
1499  struct const_upload_info info;
1500  unsigned int *data;
1501  enum pres_value_type param_type;
1502 
1503  if (!(param && is_param_dirty(param, update_version)))
1504  continue;
1505 
1506  data = param->data;
1507  start_offset = get_offset_reg(table, const_set->register_index);
1508  if (const_set->direct_copy)
1509  {
1510  regstore_set_values(rs, table, data, start_offset,
1511  get_offset_reg(table, const_set->register_count));
1512  continue;
1513  }
1514  param_type = table_type_from_param_type(param->type);
1515  if (const_set->constant_class == D3DXPC_SCALAR || const_set->constant_class == D3DXPC_VECTOR)
1516  {
1517  unsigned int count = max(param->rows, param->columns);
1518 
1519  if (count >= get_reg_components(table))
1520  {
1521  regstore_set_data(rs, table, start_offset, data,
1522  count * const_set->element_count, param_type);
1523  }
1524  else
1525  {
1526  for (element = 0; element < const_set->element_count; ++element)
1527  regstore_set_data(rs, table, start_offset + get_offset_reg(table, element),
1528  &data[element * count], count, param_type);
1529  }
1530  continue;
1531  }
1532  get_const_upload_info(const_set, &info);
1533  for (element = 0; element < const_set->element_count; ++element)
1534  {
1535  unsigned int *out = (unsigned int *)rs->tables[table] + start_offset;
1536 
1537  /* Store reshaped but (possibly) not converted yet data temporarily in the same constants buffer.
1538  * All the supported types of parameters and table values have the same size. */
1539  if (info.transpose)
1540  {
1541  for (i = 0; i < info.major_count; ++i)
1542  for (j = 0; j < info.minor; ++j)
1543  out[i * info.major_stride + j] = data[i + j * info.major];
1544 
1545  for (j = 0; j < info.minor_remainder; ++j)
1546  out[i * info.major_stride + j] = data[i + j * info.major];
1547  }
1548  else
1549  {
1550  for (i = 0; i < info.major_count; ++i)
1551  for (j = 0; j < info.minor; ++j)
1552  out[i * info.major_stride + j] = data[i * info.minor + j];
1553  }
1554  start_offset += get_offset_reg(table, const_set->register_count);
1555  data += param->rows * param->columns;
1556  }
1557  start_offset = get_offset_reg(table, const_set->register_index);
1558  if (table_info[table].type != param_type)
1559  regstore_set_data(rs, table, start_offset, (unsigned int *)rs->tables[table] + start_offset,
1560  get_offset_reg(table, const_set->register_count) * const_set->element_count, param_type);
1561  }
1562  const_tab->update_version = new_update_version;
1563  if (!update_device)
1564  return D3D_OK;
1565 
1566  for (const_idx = 0; const_idx < const_tab->const_set_count; ++const_idx)
1567  {
1568  struct d3dx_const_param_eval_output *const_set = &const_tab->const_set[const_idx];
1569 
1570  if (device_update_all || (const_set->param
1571  ? is_param_dirty(const_set->param, update_version) : pres_dirty))
1572  {
1573  enum pres_reg_tables table = const_set->table;
1574 
1575  if (table == current_table && current_start + current_count == const_set->register_index)
1576  {
1577  current_count += const_set->register_count * const_set->element_count;
1578  }
1579  else
1580  {
1581  if (current_count)
1582  {
1583  if (FAILED(hr = set_constants_device(manager, device, type, current_table,
1584  (DWORD *)rs->tables[current_table]
1585  + get_offset_reg(current_table, current_start), current_start, current_count)))
1586  result = hr;
1587  }
1588  current_table = table;
1589  current_start = const_set->register_index;
1590  current_count = const_set->register_count * const_set->element_count;
1591  }
1592  }
1593  }
1594  if (current_count)
1595  {
1596  if (FAILED(hr = set_constants_device(manager, device, type, current_table,
1597  (DWORD *)rs->tables[current_table]
1598  + get_offset_reg(current_table, current_start), current_start, current_count)))
1599  result = hr;
1600  }
1601  return result;
1602 }
#define max(a, b)
Definition: svc.c:63
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
enum pres_reg_tables table
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static HRESULT set_constants_device(ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, D3DXPARAMETER_TYPE type, enum pres_reg_tables table, void *ptr, unsigned int start, unsigned int count)
Definition: preshader.c:1441
static const struct @243 table_info[]
static enum pres_value_type table_type_from_param_type(D3DXPARAMETER_TYPE type)
Definition: preshader.c:279
struct d3dx_const_param_eval_output * const_set
pres_value_type
Definition: preshader.c:196
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
static void regstore_set_values(struct d3dx_regstore *rs, unsigned int table, const void *data, unsigned int start_offset, unsigned int count)
Definition: preshader.c:336
static unsigned int get_reg_components(unsigned int table)
Definition: preshader.c:305
static void get_const_upload_info(struct d3dx_const_param_eval_output *const_set, struct const_upload_info *info)
Definition: preshader.c:556
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 unsigned int get_offset_reg(unsigned int table, unsigned int reg_idx)
Definition: preshader.c:300
if(!(yy_init))
Definition: macro.lex.yy.c:714
LONG HRESULT
Definition: typedefs.h:77
pres_reg_tables
GLfloat param
Definition: glext.h:5796
static void regstore_set_data(struct d3dx_regstore *rs, unsigned int table, unsigned int offset, const unsigned int *in, unsigned int count, enum pres_value_type param_type)
Definition: preshader.c:1419
static FILE * out
Definition: regtests2xml.c:44
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static BOOL is_param_dirty(struct d3dx_parameter *param, ULONG64 update_version)
unsigned __int64 ULONG64
Definition: imports.h:198
void * tables[PRES_REGTAB_COUNT]
enum D3DXPARAMETER_CLASS constant_class
#define D3D_OK
Definition: d3d.h:106
ULONG64 update_version
unsigned int const_set_count
GLuint64EXT * result
Definition: glext.h:11304
struct d3dx_parameter * param

Referenced by d3dx_evaluate_parameter(), and d3dx_param_eval_set_shader_constants().

◆ set_constants_device()

static HRESULT set_constants_device ( ID3DXEffectStateManager *  manager,
struct IDirect3DDevice9 *  device,
D3DXPARAMETER_TYPE  type,
enum pres_reg_tables  table,
void ptr,
unsigned int  start,
unsigned int  count 
)
static

Definition at line 1441 of file preshader.c.

1444 {
1445  if (type == D3DXPT_VERTEXSHADER)
1446  {
1447  switch(table)
1448  {
1449  case PRES_REGTAB_OCONST:
1450  return SET_D3D_STATE_(manager, device, SetVertexShaderConstantF, start, ptr, count);
1451  case PRES_REGTAB_OICONST:
1452  return SET_D3D_STATE_(manager, device, SetVertexShaderConstantI, start, ptr, count);
1453  case PRES_REGTAB_OBCONST:
1454  return SET_D3D_STATE_(manager, device, SetVertexShaderConstantB, start, ptr, count);
1455  default:
1456  FIXME("Unexpected register table %u.\n", table);
1457  return D3DERR_INVALIDCALL;
1458  }
1459  }
1460  else if (type == D3DXPT_PIXELSHADER)
1461  {
1462  switch(table)
1463  {
1464  case PRES_REGTAB_OCONST:
1465  return SET_D3D_STATE_(manager, device, SetPixelShaderConstantF, start, ptr, count);
1466  case PRES_REGTAB_OICONST:
1467  return SET_D3D_STATE_(manager, device, SetPixelShaderConstantI, start, ptr, count);
1468  case PRES_REGTAB_OBCONST:
1469  return SET_D3D_STATE_(manager, device, SetPixelShaderConstantB, start, ptr, count);
1470  default:
1471  FIXME("Unexpected register table %u.\n", table);
1472  return D3DERR_INVALIDCALL;
1473  }
1474  }
1475  else
1476  {
1477  FIXME("Unexpected parameter type %u.\n", type);
1478  return D3DERR_INVALIDCALL;
1479  }
1480 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define D3DERR_INVALIDCALL
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
GLuint start
Definition: gl.h:1545
#define SET_D3D_STATE_(manager, device, method, args...)

Referenced by set_constants().

◆ table_type_from_param_type()

static enum pres_value_type table_type_from_param_type ( D3DXPARAMETER_TYPE  type)
static

Definition at line 279 of file preshader.c.

280 {
281  switch (type)
282  {
283  case D3DXPT_FLOAT:
284  return PRES_VT_FLOAT;
285  case D3DXPT_INT:
286  return PRES_VT_INT;
287  case D3DXPT_BOOL:
288  return PRES_VT_BOOL;
289  default:
290  FIXME("Unsupported type %u.\n", type);
291  return PRES_VT_COUNT;
292  }
293 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by init_set_constants_param(), merge_const_set_entries(), and set_constants().

◆ to_signed_nan()

static double to_signed_nan ( double  v)
static

Definition at line 64 of file preshader.c.

65 {
66  static const union
67  {
68  ULONG64 ulong64_value;
69  double double_value;
70  }
71  signed_nan =
72  {
73  0xfff8000000000000
74  };
75 
76  return isnan(v) ? signed_nan.double_value : v;
77 }
unsigned __int64 ULONG64
Definition: imports.h:198
int isnan(double x)
const GLdouble * v
Definition: gl.h:2040

Referenced by pres_acos(), and pres_asin().

◆ update_table_size()

static void update_table_size ( unsigned int table_sizes,
unsigned int  table,
unsigned int  max_register 
)
static

Definition at line 1008 of file preshader.c.

1009 {
1010  if (table < PRES_REGTAB_COUNT)
1011  table_sizes[table] = max(table_sizes[table], max_register + 1);
1012 }
#define max(a, b)
Definition: svc.c:63
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644

Referenced by parse_preshader(), and update_table_sizes_consts().

◆ update_table_sizes_consts()

static void update_table_sizes_consts ( unsigned int table_sizes,
struct d3dx_const_tab ctab 
)
static

Definition at line 1014 of file preshader.c.

1015 {
1016  unsigned int i, table, max_register;
1017 
1018  for (i = 0; i < ctab->input_count; ++i)
1019  {
1020  if (!ctab->inputs[i].RegisterCount)
1021  continue;
1022  max_register = ctab->inputs[i].RegisterIndex + ctab->inputs[i].RegisterCount - 1;
1023  table = ctab->regset2table[ctab->inputs[i].RegisterSet];
1024  update_table_size(table_sizes, table, max_register);
1025  }
1026 }
D3DXCONSTANT_DESC * inputs
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void update_table_size(unsigned int *table_sizes, unsigned int table, unsigned int max_register)
Definition: preshader.c:1008
D3DXREGISTER_SET RegisterSet
Definition: d3dx9shader.h:106
unsigned int input_count
enum pres_reg_tables * regset2table

Referenced by d3dx_create_param_eval(), and parse_preshader().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )

Variable Documentation

◆ component_size

unsigned int component_size

Definition at line 207 of file preshader.c.

◆ pres_op_info

const struct op_info pres_op_info[]
static
Initial value:
=
{
{0x000, "nop", 0, 0, NULL },
{0x100, "mov", 1, 0, pres_mov},
{0x101, "neg", 1, 0, pres_neg},
{0x103, "rcp", 1, 0, pres_rcp},
{0x104, "frc", 1, 0, pres_frc},
{0x105, "exp", 1, 0, pres_exp},
{0x106, "log", 1, 0, pres_log},
{0x107, "rsq", 1, 0, pres_rsq},
{0x108, "sin", 1, 0, pres_sin},
{0x109, "cos", 1, 0, pres_cos},
{0x10a, "asin", 1, 0, pres_asin},
{0x10b, "acos", 1, 0, pres_acos},
{0x10c, "atan", 1, 0, pres_atan},
{0x200, "min", 2, 0, pres_min},
{0x201, "max", 2, 0, pres_max},
{0x202, "lt", 2, 0, pres_lt },
{0x203, "ge", 2, 0, pres_ge },
{0x204, "add", 2, 0, pres_add},
{0x205, "mul", 2, 0, pres_mul},
{0x206, "atan2", 2, 0, pres_atan2},
{0x208, "div", 2, 0, pres_div},
{0x300, "cmp", 3, 0, pres_cmp},
{0x500, "dot", 2, 1, pres_dot},
{0x70e, "d3ds_dotswiz", 6, 0, pres_dotswiz6},
{0x70e, "d3ds_dotswiz", 8, 0, pres_dotswiz8},
}
static double pres_log(double *args, int n)
Definition: preshader.c:124
static double pres_asin(double *args, int n)
Definition: preshader.c:138
static double pres_dotswiz6(double *args, int n)
Definition: preshader.c:93
static double pres_ge(double *args, int n)
Definition: preshader.c:106
static double pres_add(double *args, int n)
Definition: preshader.c:80
static double pres_exp(double *args, int n)
Definition: preshader.c:123
static double pres_min(double *args, int n)
Definition: preshader.c:108
static double pres_rcp(double *args, int n)
Definition: preshader.c:104
static double pres_acos(double *args, int n)
Definition: preshader.c:139
static double pres_frc(double *args, int n)
Definition: preshader.c:107
smooth NULL
Definition: ftsmooth.c:416
static double pres_lt(double *args, int n)
Definition: preshader.c:105
static double pres_neg(double *args, int n)
Definition: preshader.c:103
static double pres_mul(double *args, int n)
Definition: preshader.c:81
static double pres_max(double *args, int n)
Definition: preshader.c:109
static double pres_atan(double *args, int n)
Definition: preshader.c:140
static double pres_atan2(double *args, int n)
Definition: preshader.c:141
static double pres_cmp(double *args, int n)
Definition: preshader.c:110
static double pres_dotswiz8(double *args, int n)
Definition: preshader.c:98
static double pres_rsq(double *args, int n)
Definition: preshader.c:113
static double pres_cos(double *args, int n)
Definition: preshader.c:112
static double pres_mov(double *args, int n)
Definition: preshader.c:79
static double pres_sin(double *args, int n)
Definition: preshader.c:111
static double pres_dot(double *args, int n)
Definition: preshader.c:82
static double pres_div(double *args, int n)
Definition: preshader.c:145

Definition at line 167 of file preshader.c.

Referenced by dump_ins(), execute_preshader(), parse_pres_ins(), and parse_preshader().

◆ pres_regset2table

◆ shad_regset2table

◆ table_info

const { ... } table_info[]
Initial value:
=
{
{sizeof(double), PRES_VT_DOUBLE},
{sizeof(float), PRES_VT_FLOAT },
{sizeof(float), PRES_VT_FLOAT },
{sizeof(BOOL), PRES_VT_BOOL },
{sizeof(int), PRES_VT_INT, },
{sizeof(float), PRES_VT_FLOAT }
}
#define BOOL
Definition: nt_native.h:43
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by FT_DEFINE_SERVICE(), init_set_constants_param(), regstore_alloc_table(), regstore_get_double(), regstore_set_data(), regstore_set_double(), regstore_set_values(), and set_constants().

◆ table_symbol

const char* table_symbol[]
static
Initial value:
=
{
"imm", "c", "oc", "ob", "oi", "r", "(null)",
}

Definition at line 221 of file preshader.c.

Referenced by dump_arg(), and dump_registers().

◆ type

Definition at line 208 of file preshader.c.

Referenced by d3dx_create_param_eval().