ReactOS  0.4.14-dev-1279-gc1464a4
utils.c File Reference
#include <stdio.h>
#include "d3dcompiler_private.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Macros

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

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dcompiler)
 
const chardebug_d3dcompiler_shader_variable_class (D3D_SHADER_VARIABLE_CLASS c)
 
const chardebug_d3dcompiler_shader_variable_type (D3D_SHADER_VARIABLE_TYPE t)
 
const chardebug_d3dcompiler_d3d_blob_part (D3D_BLOB_PART part)
 
const chardebug_print_srcmod (DWORD mod)
 
const chardebug_print_dstmod (DWORD mod)
 
const chardebug_print_shift (DWORD shift)
 
static const charget_regname (const struct shader_reg *reg)
 
static const chardebug_print_writemask (DWORD mask)
 
static const chardebug_print_swizzle (DWORD arg)
 
static const chardebug_print_relarg (const struct shader_reg *reg)
 
const chardebug_print_dstreg (const struct shader_reg *reg)
 
const chardebug_print_srcreg (const struct shader_reg *reg)
 
const chardebug_print_comp (DWORD comp)
 
const chardebug_print_opcode (DWORD opcode)
 
void skip_dword_unknown (const char **ptr, unsigned int count)
 
static void write_dword_unknown (char **ptr, DWORD d)
 
HRESULT dxbc_add_section (struct dxbc *dxbc, DWORD tag, const char *data, DWORD data_size)
 
HRESULT dxbc_init (struct dxbc *dxbc, unsigned int size)
 
HRESULT dxbc_parse (const char *data, SIZE_T data_size, struct dxbc *dxbc)
 
void dxbc_destroy (struct dxbc *dxbc)
 
HRESULT dxbc_write_blob (struct dxbc *dxbc, ID3DBlob **blob)
 
void compilation_message (struct compilation_messages *msg, const char *fmt, __ms_va_list args)
 
BOOL add_declaration (struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var)
 
struct hlsl_ir_varget_variable (struct hlsl_scope *scope, const char *name)
 
void free_declaration (struct hlsl_ir_var *decl)
 
struct hlsl_typenew_hlsl_type (const char *name, enum hlsl_type_class type_class, enum hlsl_base_type base_type, unsigned dimx, unsigned dimy)
 
struct hlsl_typenew_array_type (struct hlsl_type *basic_type, unsigned int array_size)
 
struct hlsl_typeget_type (struct hlsl_scope *scope, const char *name, BOOL recursive)
 
BOOL find_function (const char *name)
 
unsigned int components_count_type (struct hlsl_type *type)
 
BOOL compare_hlsl_types (const struct hlsl_type *t1, const struct hlsl_type *t2)
 
struct hlsl_typeclone_hlsl_type (struct hlsl_type *old)
 
static BOOL convertible_data_type (struct hlsl_type *type)
 
BOOL compatible_data_types (struct hlsl_type *t1, struct hlsl_type *t2)
 
static BOOL implicit_compatible_data_types (struct hlsl_type *t1, struct hlsl_type *t2)
 
static BOOL expr_compatible_data_types (struct hlsl_type *t1, struct hlsl_type *t2)
 
static enum hlsl_base_type expr_common_base_type (enum hlsl_base_type t1, enum hlsl_base_type t2)
 
static struct hlsl_typeexpr_common_type (struct hlsl_type *t1, struct hlsl_type *t2, struct source_location *loc)
 
static struct hlsl_ir_nodeimplicit_conversion (struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc)
 
struct hlsl_ir_exprnew_expr (enum hlsl_ir_expr_op op, struct hlsl_ir_node **operands, struct source_location *loc)
 
struct hlsl_ir_exprnew_cast (struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc)
 
struct hlsl_ir_derefnew_var_deref (struct hlsl_ir_var *var)
 
struct hlsl_ir_derefnew_record_deref (struct hlsl_ir_node *record, struct hlsl_struct_field *field)
 
static enum hlsl_ir_expr_op op_from_assignment (enum parse_assign_op op)
 
struct hlsl_ir_nodemake_assignment (struct hlsl_ir_node *left, enum parse_assign_op assign_op, DWORD writemask, struct hlsl_ir_node *right)
 
static int compare_hlsl_types_rb (const void *key, const struct wine_rb_entry *entry)
 
void push_scope (struct hlsl_parse_ctx *ctx)
 
BOOL pop_scope (struct hlsl_parse_ctx *ctx)
 
struct hlsl_ir_function_declnew_func_decl (struct hlsl_type *return_type, struct list *parameters)
 
static int compare_param_hlsl_types (const struct hlsl_type *t1, const struct hlsl_type *t2)
 
static int compare_function_decl_rb (const void *key, const struct wine_rb_entry *entry)
 
static int compare_function_rb (const void *key, const struct wine_rb_entry *entry)
 
void init_functions_tree (struct wine_rb_tree *funcs)
 
static const chardebug_base_type (const struct hlsl_type *type)
 
const chardebug_hlsl_type (const struct hlsl_type *type)
 
const chardebug_modifiers (DWORD modifiers)
 
static const chardebug_node_type (enum hlsl_ir_node_type type)
 
static void debug_dump_instr (const struct hlsl_ir_node *instr)
 
static void debug_dump_instr_list (const struct list *list)
 
static void debug_dump_ir_var (const struct hlsl_ir_var *var)
 
static void debug_dump_ir_deref (const struct hlsl_ir_deref *deref)
 
static void debug_dump_ir_constant (const struct hlsl_ir_constant *constant)
 
static const chardebug_expr_op (const struct hlsl_ir_expr *expr)
 
static void debug_dump_ir_expr (const struct hlsl_ir_expr *expr)
 
static void debug_dump_ir_constructor (const struct hlsl_ir_constructor *constructor)
 
static const chardebug_writemask (DWORD writemask)
 
static void debug_dump_ir_assignment (const struct hlsl_ir_assignment *assign)
 
static void debug_dump_ir_swizzle (const struct hlsl_ir_swizzle *swizzle)
 
static void debug_dump_ir_jump (const struct hlsl_ir_jump *jump)
 
static void debug_dump_ir_if (const struct hlsl_ir_if *if_node)
 
void debug_dump_ir_function_decl (const struct hlsl_ir_function_decl *func)
 
void free_hlsl_type (struct hlsl_type *type)
 
void free_instr_list (struct list *list)
 
static void free_ir_constant (struct hlsl_ir_constant *constant)
 
static void free_ir_deref (struct hlsl_ir_deref *deref)
 
static void free_ir_swizzle (struct hlsl_ir_swizzle *swizzle)
 
static void free_ir_constructor (struct hlsl_ir_constructor *constructor)
 
static void free_ir_expr (struct hlsl_ir_expr *expr)
 
static void free_ir_assignment (struct hlsl_ir_assignment *assignment)
 
static void free_ir_if (struct hlsl_ir_if *if_node)
 
static void free_ir_jump (struct hlsl_ir_jump *jump)
 
void free_instr (struct hlsl_ir_node *node)
 
static void free_function_decl (struct hlsl_ir_function_decl *decl)
 
static void free_function_decl_rb (struct wine_rb_entry *entry, void *context)
 
static void free_function (struct hlsl_ir_function *func)
 
void free_function_rb (struct wine_rb_entry *entry, void *context)
 
void add_function_decl (struct wine_rb_tree *funcs, char *name, struct hlsl_ir_function_decl *decl, BOOL intrinsic)
 

Macro Definition Documentation

◆ WINE_D3DCOMPILER_TO_STR

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

Definition at line 30 of file utils.c.

Function Documentation

◆ add_declaration()

BOOL add_declaration ( struct hlsl_scope scope,
struct hlsl_ir_var decl,
BOOL  local_var 
)

Definition at line 761 of file utils.c.

762 {
763  struct hlsl_ir_var *var;
764 
765  LIST_FOR_EACH_ENTRY(var, &scope->vars, struct hlsl_ir_var, scope_entry)
766  {
767  if (!strcmp(decl->name, var->name))
768  return FALSE;
769  }
770  if (local_var && scope->upper->upper == hlsl_ctx.globals)
771  {
772  /* Check whether the variable redefines a function parameter. */
773  LIST_FOR_EACH_ENTRY(var, &scope->upper->vars, struct hlsl_ir_var, scope_entry)
774  {
775  if (!strcmp(decl->name, var->name))
776  return FALSE;
777  }
778  }
779 
780  list_add_tail(&scope->vars, &decl->scope_entry);
781  return TRUE;
782 }
const char * var
Definition: shader.c:5666
#define TRUE
Definition: types.h:120
struct list vars
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
struct hlsl_scope * upper
struct hlsl_parse_ctx hlsl_ctx
Definition: hlsl.tab.c:90
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
const char * name

Referenced by add_func_parameter(), and declare_variable().

◆ add_function_decl()

void add_function_decl ( struct wine_rb_tree funcs,
char name,
struct hlsl_ir_function_decl decl,
BOOL  intrinsic 
)

Definition at line 2282 of file utils.c.

2283 {
2284  struct hlsl_ir_function *func;
2285  struct wine_rb_entry *func_entry, *old_entry;
2286 
2287  func_entry = wine_rb_get(funcs, name);
2288  if (func_entry)
2289  {
2290  func = WINE_RB_ENTRY_VALUE(func_entry, struct hlsl_ir_function, entry);
2291  if (intrinsic != func->intrinsic)
2292  {
2293  if (intrinsic)
2294  {
2295  ERR("Redeclaring a user defined function as an intrinsic.\n");
2296  return;
2297  }
2298  TRACE("Function %s redeclared as a user defined function.\n", debugstr_a(name));
2299  func->intrinsic = intrinsic;
2302  }
2303  decl->func = func;
2304  if ((old_entry = wine_rb_get(&func->overloads, decl->parameters)))
2305  {
2306  struct hlsl_ir_function_decl *old_decl =
2307  WINE_RB_ENTRY_VALUE(old_entry, struct hlsl_ir_function_decl, entry);
2308 
2309  if (!decl->body)
2310  {
2311  free_function_decl(decl);
2313  return;
2314  }
2315  wine_rb_remove(&func->overloads, old_entry);
2316  free_function_decl(old_decl);
2317  }
2318  wine_rb_put(&func->overloads, decl->parameters, &decl->entry);
2320  return;
2321  }
2322  func = d3dcompiler_alloc(sizeof(*func));
2323  func->name = name;
2325  decl->func = func;
2326  wine_rb_put(&func->overloads, decl->parameters, &decl->entry);
2327  func->intrinsic = intrinsic;
2328  wine_rb_put(funcs, func->name, &func->entry);
2329 }
struct wine_rb_entry entry
GLenum func
Definition: glext.h:6028
static int compare_function_decl_rb(const void *key, const struct wine_rb_entry *entry)
Definition: utils.c:1627
static BOOL d3dcompiler_free(void *ptr)
static void free_function_decl(struct hlsl_ir_function_decl *decl)
Definition: utils.c:2257
static void * d3dcompiler_alloc(SIZE_T size)
smooth NULL
Definition: ftsmooth.c:416
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
Definition: rbtree.h:179
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
static struct __wine_debug_functions funcs
Definition: debug.c:59
static void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:198
uint32_t entry
Definition: isohybrid.c:63
static void wine_rb_remove(struct wine_rb_tree *tree, struct wine_rb_entry *entry)
Definition: rbtree.h:283
#define ERR(fmt,...)
Definition: debug.h:109
Definition: rbtree.h:35
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
Definition: rbtree.h:215
Definition: name.c:38
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203
struct hlsl_ir_function * func
static void free_function_decl_rb(struct wine_rb_entry *entry, void *context)
Definition: utils.c:2265
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by yyparse().

◆ clone_hlsl_type()

struct hlsl_type* clone_hlsl_type ( struct hlsl_type old)

Definition at line 929 of file utils.c.

930 {
931  struct hlsl_type *type;
932  struct hlsl_struct_field *old_field, *field;
933 
934  type = d3dcompiler_alloc(sizeof(*type));
935  if (!type)
936  {
937  ERR("Out of memory\n");
938  return NULL;
939  }
940  if (old->name)
941  {
942  type->name = d3dcompiler_strdup(old->name);
943  if (!type->name)
944  {
946  return NULL;
947  }
948  }
949  type->type = old->type;
950  type->base_type = old->base_type;
951  type->dimx = old->dimx;
952  type->dimy = old->dimy;
953  type->modifiers = old->modifiers;
954  type->sampler_dim = old->sampler_dim;
955  switch (old->type)
956  {
957  case HLSL_CLASS_ARRAY:
958  type->e.array.type = old->e.array.type;
959  type->e.array.elements_count = old->e.array.elements_count;
960  break;
961  case HLSL_CLASS_STRUCT:
962  type->e.elements = d3dcompiler_alloc(sizeof(*type->e.elements));
963  if (!type->e.elements)
964  {
965  d3dcompiler_free((void *)type->name);
967  return NULL;
968  }
969  list_init(type->e.elements);
970  LIST_FOR_EACH_ENTRY(old_field, old->e.elements, struct hlsl_struct_field, entry)
971  {
972  field = d3dcompiler_alloc(sizeof(*field));
973  if (!field)
974  {
975  LIST_FOR_EACH_ENTRY_SAFE(field, old_field, type->e.elements, struct hlsl_struct_field, entry)
976  {
977  d3dcompiler_free((void *)field->semantic);
978  d3dcompiler_free((void *)field->name);
980  }
981  d3dcompiler_free(type->e.elements);
982  d3dcompiler_free((void *)type->name);
984  return NULL;
985  }
986  field->type = clone_hlsl_type(old_field->type);
987  field->name = d3dcompiler_strdup(old_field->name);
988  if (old_field->semantic)
989  field->semantic = d3dcompiler_strdup(old_field->semantic);
990  field->modifiers = old_field->modifiers;
991  list_add_tail(type->e.elements, &field->entry);
992  }
993  break;
994  default:
995  break;
996  }
997 
998  list_add_tail(&hlsl_ctx.types, &type->entry);
999  return type;
1000 }
unsigned int dimx
enum hlsl_type_class type
enum hlsl_sampler_dim sampler_dim
static BOOL d3dcompiler_free(void *ptr)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
union hlsl_type::@233 e
static void * d3dcompiler_alloc(SIZE_T size)
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
smooth NULL
Definition: ftsmooth.c:416
static char * d3dcompiler_strdup(const char *string)
Definition: parser.c:43
struct hlsl_type * type
enum hlsl_base_type base_type
const char * name
struct list * elements
struct hlsl_parse_ctx hlsl_ctx
Definition: hlsl.tab.c:90
uint32_t entry
Definition: isohybrid.c:63
unsigned int modifiers
#define ERR(fmt,...)
Definition: debug.h:109
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
struct hlsl_type::@233::@234 array
struct hlsl_type * clone_hlsl_type(struct hlsl_type *old)
Definition: utils.c:929
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
unsigned int dimy

Referenced by add_typedef(), and yyparse().

◆ compare_function_decl_rb()

static int compare_function_decl_rb ( const void key,
const struct wine_rb_entry entry 
)
static

Definition at line 1627 of file utils.c.

1628 {
1629  const struct list *params = key;
1630  const struct hlsl_ir_function_decl *decl = WINE_RB_ENTRY_VALUE(entry, const struct hlsl_ir_function_decl, entry);
1631  int params_count = params ? list_count(params) : 0;
1632  int decl_params_count = decl->parameters ? list_count(decl->parameters) : 0;
1633  int r;
1634  struct list *p1cur, *p2cur;
1635 
1636  if (params_count != decl_params_count)
1637  return params_count - decl_params_count;
1638 
1639  p1cur = params ? list_head(params) : NULL;
1640  p2cur = decl->parameters ? list_head(decl->parameters) : NULL;
1641  while (p1cur && p2cur)
1642  {
1643  struct hlsl_ir_var *p1, *p2;
1644  p1 = LIST_ENTRY(p1cur, struct hlsl_ir_var, param_entry);
1645  p2 = LIST_ENTRY(p2cur, struct hlsl_ir_var, param_entry);
1646  if ((r = compare_param_hlsl_types(p1->data_type, p2->data_type)))
1647  return r;
1648  p1cur = list_next(params, p1cur);
1649  p2cur = list_next(decl->parameters, p2cur);
1650  }
1651  return 0;
1652 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
struct list scope_entry param_entry
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
GLenum const GLfloat * params
Definition: glext.h:5645
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
smooth NULL
Definition: ftsmooth.c:416
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
struct hlsl_type * data_type
HKEY key
Definition: reg.c:42
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static int compare_param_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:1578
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by add_function_decl().

◆ compare_function_rb()

static int compare_function_rb ( const void key,
const struct wine_rb_entry entry 
)
static

Definition at line 1654 of file utils.c.

1655 {
1656  const char *name = key;
1657  const struct hlsl_ir_function *func = WINE_RB_ENTRY_VALUE(entry, const struct hlsl_ir_function,entry);
1658 
1659  return strcmp(name, func->name);
1660 }
GLenum func
Definition: glext.h:6028
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
HKEY key
Definition: reg.c:42
uint32_t entry
Definition: isohybrid.c:63
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
WCHAR * name
Definition: name.c:42

Referenced by init_functions_tree().

◆ compare_hlsl_types()

BOOL compare_hlsl_types ( const struct hlsl_type t1,
const struct hlsl_type t2 
)

Definition at line 883 of file utils.c.

884 {
885  if (t1 == t2)
886  return TRUE;
887 
888  if (t1->type != t2->type)
889  return FALSE;
890  if (t1->base_type != t2->base_type)
891  return FALSE;
892  if (t1->base_type == HLSL_TYPE_SAMPLER && t1->sampler_dim != t2->sampler_dim)
893  return FALSE;
896  return FALSE;
897  if (t1->dimx != t2->dimx)
898  return FALSE;
899  if (t1->dimy != t2->dimy)
900  return FALSE;
901  if (t1->type == HLSL_CLASS_STRUCT)
902  {
903  struct list *t1cur, *t2cur;
904  struct hlsl_struct_field *t1field, *t2field;
905 
906  t1cur = list_head(t1->e.elements);
907  t2cur = list_head(t2->e.elements);
908  while (t1cur && t2cur)
909  {
910  t1field = LIST_ENTRY(t1cur, struct hlsl_struct_field, entry);
911  t2field = LIST_ENTRY(t2cur, struct hlsl_struct_field, entry);
912  if (!compare_hlsl_types(t1field->type, t2field->type))
913  return FALSE;
914  if (strcmp(t1field->name, t2field->name))
915  return FALSE;
916  t1cur = list_next(t1->e.elements, t1cur);
917  t2cur = list_next(t2->e.elements, t2cur);
918  }
919  if (t1cur != t2cur)
920  return FALSE;
921  }
922  if (t1->type == HLSL_CLASS_ARRAY)
923  return t1->e.array.elements_count == t2->e.array.elements_count
924  && compare_hlsl_types(t1->e.array.type, t2->e.array.type);
925 
926  return TRUE;
927 }
unsigned int dimx
#define TRUE
Definition: types.h:120
enum hlsl_type_class type
enum hlsl_sampler_dim sampler_dim
#define HLSL_MODIFIERS_COMPARISON_MASK
union hlsl_type::@233 e
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
struct hlsl_type * type
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:883
enum hlsl_base_type base_type
struct list * elements
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
unsigned int modifiers
struct hlsl_type::@233::@234 array
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define LIST_ENTRY(type)
Definition: queue.h:175
unsigned int dimy

Referenced by compatible_data_types(), expr_common_type(), implicit_compatible_data_types(), implicit_conversion(), make_assignment(), new_expr(), and yyparse().

◆ compare_hlsl_types_rb()

static int compare_hlsl_types_rb ( const void key,
const struct wine_rb_entry entry 
)
static

Definition at line 1518 of file utils.c.

1519 {
1520  const char *name = key;
1521  const struct hlsl_type *type = WINE_RB_ENTRY_VALUE(entry, const struct hlsl_type, scope_entry);
1522 
1523  if (name == type->name)
1524  return 0;
1525 
1526  if (!name || !type->name)
1527  {
1528  ERR("hlsl_type without a name in a scope?\n");
1529  return -1;
1530  }
1531  return strcmp(name, type->name);
1532 }
struct wine_rb_entry scope_entry
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
HKEY key
Definition: reg.c:42
uint32_t entry
Definition: isohybrid.c:63
#define ERR(fmt,...)
Definition: debug.h:109
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
WCHAR * name
Definition: name.c:42

Referenced by push_scope().

◆ compare_param_hlsl_types()

static int compare_param_hlsl_types ( const struct hlsl_type t1,
const struct hlsl_type t2 
)
static

Definition at line 1578 of file utils.c.

1579 {
1580  if (t1->type != t2->type)
1581  {
1582  if (!((t1->type == HLSL_CLASS_SCALAR && t2->type == HLSL_CLASS_VECTOR)
1583  || (t1->type == HLSL_CLASS_VECTOR && t2->type == HLSL_CLASS_SCALAR)))
1584  return t1->type - t2->type;
1585  }
1586  if (t1->base_type != t2->base_type)
1587  return t1->base_type - t2->base_type;
1588  if (t1->base_type == HLSL_TYPE_SAMPLER && t1->sampler_dim != t2->sampler_dim)
1589  return t1->sampler_dim - t2->sampler_dim;
1590  if (t1->dimx != t2->dimx)
1591  return t1->dimx - t2->dimx;
1592  if (t1->dimy != t2->dimy)
1593  return t1->dimx - t2->dimx;
1594  if (t1->type == HLSL_CLASS_STRUCT)
1595  {
1596  struct list *t1cur, *t2cur;
1597  struct hlsl_struct_field *t1field, *t2field;
1598  int r;
1599 
1600  t1cur = list_head(t1->e.elements);
1601  t2cur = list_head(t2->e.elements);
1602  while (t1cur && t2cur)
1603  {
1604  t1field = LIST_ENTRY(t1cur, struct hlsl_struct_field, entry);
1605  t2field = LIST_ENTRY(t2cur, struct hlsl_struct_field, entry);
1606  if ((r = compare_param_hlsl_types(t1field->type, t2field->type)))
1607  return r;
1608  if ((r = strcmp(t1field->name, t2field->name)))
1609  return r;
1610  t1cur = list_next(t1->e.elements, t1cur);
1611  t2cur = list_next(t2->e.elements, t2cur);
1612  }
1613  if (t1cur != t2cur)
1614  return t1cur ? 1 : -1;
1615  return 0;
1616  }
1617  if (t1->type == HLSL_CLASS_ARRAY)
1618  {
1619  if (t1->e.array.elements_count != t2->e.array.elements_count)
1620  return t1->e.array.elements_count - t2->e.array.elements_count;
1621  return compare_param_hlsl_types(t1->e.array.type, t2->e.array.type);
1622  }
1623 
1624  return 0;
1625 }
unsigned int dimx
enum hlsl_type_class type
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
enum hlsl_sampler_dim sampler_dim
union hlsl_type::@233 e
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
struct hlsl_type * type
enum hlsl_base_type base_type
struct list * elements
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static int compare_param_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:1578
struct hlsl_type::@233::@234 array
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define LIST_ENTRY(type)
Definition: queue.h:175
unsigned int dimy

Referenced by compare_function_decl_rb().

◆ compatible_data_types()

BOOL compatible_data_types ( struct hlsl_type t1,
struct hlsl_type t2 
)

Definition at line 1007 of file utils.c.

1008 {
1010  return FALSE;
1011 
1012  if (t1->type <= HLSL_CLASS_LAST_NUMERIC)
1013  {
1014  /* Scalar vars can be cast to pretty much everything */
1015  if (t1->dimx == 1 && t1->dimy == 1)
1016  return TRUE;
1017 
1018  if (t1->type == HLSL_CLASS_VECTOR && t2->type == HLSL_CLASS_VECTOR)
1019  return t1->dimx >= t2->dimx;
1020  }
1021 
1022  /* The other way around is true too i.e. whatever to scalar */
1023  if (t2->type <= HLSL_CLASS_LAST_NUMERIC && t2->dimx == 1 && t2->dimy == 1)
1024  return TRUE;
1025 
1026  if (t1->type == HLSL_CLASS_ARRAY)
1027  {
1028  if (compare_hlsl_types(t1->e.array.type, t2))
1029  /* e.g. float4[3] to float4 is allowed */
1030  return TRUE;
1031 
1032  if (t2->type == HLSL_CLASS_ARRAY || t2->type == HLSL_CLASS_STRUCT)
1033  return components_count_type(t1) >= components_count_type(t2);
1034  else
1035  return components_count_type(t1) == components_count_type(t2);
1036  }
1037 
1038  if (t1->type == HLSL_CLASS_STRUCT)
1039  return components_count_type(t1) >= components_count_type(t2);
1040 
1041  if (t2->type == HLSL_CLASS_ARRAY || t2->type == HLSL_CLASS_STRUCT)
1042  return components_count_type(t1) == components_count_type(t2);
1043 
1044  if (t1->type == HLSL_CLASS_MATRIX || t2->type == HLSL_CLASS_MATRIX)
1045  {
1046  if (t1->type == HLSL_CLASS_MATRIX && t2->type == HLSL_CLASS_MATRIX && t1->dimx >= t2->dimx && t1->dimy >= t2->dimy)
1047  return TRUE;
1048 
1049  /* Matrix-vector conversion is apparently allowed if they have the same components count */
1050  if ((t1->type == HLSL_CLASS_VECTOR || t2->type == HLSL_CLASS_VECTOR)
1052  return TRUE;
1053  return FALSE;
1054  }
1055 
1057  return TRUE;
1058  return FALSE;
1059 }
unsigned int dimx
#define TRUE
Definition: types.h:120
enum hlsl_type_class type
unsigned int components_count_type(struct hlsl_type *type)
Definition: utils.c:857
union hlsl_type::@233 e
static BOOL convertible_data_type(struct hlsl_type *type)
Definition: utils.c:1002
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:883
struct hlsl_type::@233::@234 array
unsigned int dimy

Referenced by yyparse().

◆ compilation_message()

void compilation_message ( struct compilation_messages msg,
const char fmt,
__ms_va_list  args 
)

Definition at line 719 of file utils.c.

720 {
721  char* buffer;
722  int rc, size;
723 
724  if (msg->capacity == 0)
725  {
727  if (msg->string == NULL)
728  {
729  ERR("Error allocating memory for parser messages\n");
730  return;
731  }
732  msg->capacity = MESSAGEBUFFER_INITIAL_SIZE;
733  }
734 
735  while (1)
736  {
737  rc = vsnprintf(msg->string + msg->size,
738  msg->capacity - msg->size, fmt, args);
739 
740  if (rc < 0 || rc >= msg->capacity - msg->size)
741  {
742  size = msg->capacity * 2;
743  buffer = d3dcompiler_realloc(msg->string, size);
744  if (buffer == NULL)
745  {
746  ERR("Error reallocating memory for parser messages\n");
747  return;
748  }
749  msg->string = buffer;
750  msg->capacity = size;
751  }
752  else
753  {
754  TRACE("%s", msg->string + msg->size);
755  msg->size += rc;
756  return;
757  }
758  }
759 }
#define vsnprintf
Definition: tif_win32.c:406
static void * d3dcompiler_realloc(void *ptr, SIZE_T size)
GLuint buffer
Definition: glext.h:5915
Definition: match.c:390
static void * d3dcompiler_alloc(SIZE_T size)
#define MESSAGEBUFFER_INITIAL_SIZE
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define ERR(fmt,...)
Definition: debug.h:109
#define msg(x)
Definition: auth_time.c:54
Definition: dsound.c:943

Referenced by asmparser_message(), and hlsl_message().

◆ components_count_type()

unsigned int components_count_type ( struct hlsl_type type)

Definition at line 857 of file utils.c.

858 {
859  unsigned int count = 0;
860  struct hlsl_struct_field *field;
861 
862  if (type->type <= HLSL_CLASS_LAST_NUMERIC)
863  {
864  return type->dimx * type->dimy;
865  }
866  if (type->type == HLSL_CLASS_ARRAY)
867  {
868  return components_count_type(type->e.array.type) * type->e.array.elements_count;
869  }
870  if (type->type != HLSL_CLASS_STRUCT)
871  {
872  ERR("Unexpected data type %s.\n", debug_hlsl_type(type));
873  return 0;
874  }
875 
876  LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
877  {
879  }
880  return count;
881 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
const char * debug_hlsl_type(const struct hlsl_type *type)
Definition: utils.c:1695
unsigned int components_count_type(struct hlsl_type *type)
Definition: utils.c:857
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
Definition: parser.c:43
uint32_t entry
Definition: isohybrid.c:63
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by compatible_data_types(), declare_vars(), expr_compatible_data_types(), implicit_compatible_data_types(), initializer_size(), and struct_var_initializer().

◆ convertible_data_type()

static BOOL convertible_data_type ( struct hlsl_type type)
static

Definition at line 1002 of file utils.c.

1003 {
1004  return type->type != HLSL_CLASS_OBJECT;
1005 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by compatible_data_types(), and implicit_compatible_data_types().

◆ debug_base_type()

static const char* debug_base_type ( const struct hlsl_type type)
static

Definition at line 1667 of file utils.c.

1668 {
1669  const char *name = "(unknown)";
1670 
1671  switch (type->base_type)
1672  {
1673  case HLSL_TYPE_FLOAT: name = "float"; break;
1674  case HLSL_TYPE_HALF: name = "half"; break;
1675  case HLSL_TYPE_DOUBLE: name = "double"; break;
1676  case HLSL_TYPE_INT: name = "int"; break;
1677  case HLSL_TYPE_UINT: name = "uint"; break;
1678  case HLSL_TYPE_BOOL: name = "bool"; break;
1679  case HLSL_TYPE_SAMPLER:
1680  switch (type->sampler_dim)
1681  {
1682  case HLSL_SAMPLER_DIM_GENERIC: name = "sampler"; break;
1683  case HLSL_SAMPLER_DIM_1D: name = "sampler1D"; break;
1684  case HLSL_SAMPLER_DIM_2D: name = "sampler2D"; break;
1685  case HLSL_SAMPLER_DIM_3D: name = "sampler3D"; break;
1686  case HLSL_SAMPLER_DIM_CUBE: name = "samplerCUBE"; break;
1687  }
1688  break;
1689  default:
1690  FIXME("Unhandled case %u\n", type->base_type);
1691  }
1692  return name;
1693 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: name.c:38
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by debug_dump_ir_constant(), and debug_hlsl_type().

◆ debug_d3dcompiler_d3d_blob_part()

const char* debug_d3dcompiler_d3d_blob_part ( D3D_BLOB_PART  part)

Definition at line 106 of file utils.c.

107 {
108  switch(part)
109  {
122  default:
123  FIXME("Unrecognized D3D_BLOB_PART %#x\n", part);
124  return "unrecognized";
125  }
126 }
#define WINE_D3DCOMPILER_TO_STR(x)
Definition: utils.c:30
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by check_blob_part(), d3dcompiler_get_blob_part(), and D3DGetBlobPart().

◆ debug_d3dcompiler_shader_variable_class()

const char* debug_d3dcompiler_shader_variable_class ( D3D_SHADER_VARIABLE_CLASS  c)

Definition at line 32 of file utils.c.

Referenced by d3dcompiler_parse_type().

◆ debug_d3dcompiler_shader_variable_type()

const char* debug_d3dcompiler_shader_variable_type ( D3D_SHADER_VARIABLE_TYPE  t)

Definition at line 50 of file utils.c.

51 {
52  switch (t)
53  {
100  default:
101  FIXME("Unrecognized D3D_SHADER_VARIABLE_TYPE %#x.\n", t);
102  return "unrecognized";
103  }
104 }
GLdouble GLdouble t
Definition: gl.h:2047
#define WINE_D3DCOMPILER_TO_STR(x)
Definition: utils.c:30
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by d3dcompiler_parse_type().

◆ debug_dump_instr()

static void debug_dump_instr ( const struct hlsl_ir_node instr)
static

Definition at line 2053 of file utils.c.

2054 {
2055  switch (instr->type)
2056  {
2057  case HLSL_IR_EXPR:
2059  break;
2060  case HLSL_IR_DEREF:
2062  break;
2063  case HLSL_IR_CONSTANT:
2065  break;
2066  case HLSL_IR_ASSIGNMENT:
2068  break;
2069  case HLSL_IR_SWIZZLE:
2071  break;
2072  case HLSL_IR_CONSTRUCTOR:
2074  break;
2075  case HLSL_IR_JUMP:
2077  break;
2078  case HLSL_IR_IF:
2080  break;
2081  default:
2082  TRACE("<No dump function for %s>", debug_node_type(instr->type));
2083  }
2084 }
static void debug_dump_ir_swizzle(const struct hlsl_ir_swizzle *swizzle)
Definition: utils.c:1996
static struct hlsl_ir_deref * deref_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_if * if_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_constructor * constructor_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_constant * constant_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_assignment * assignment_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_expr * expr_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_swizzle * swizzle_from_node(const struct hlsl_ir_node *node)
static void debug_dump_ir_assignment(const struct hlsl_ir_assignment *assign)
Definition: utils.c:1985
static const char * debug_node_type(enum hlsl_ir_node_type type)
Definition: utils.c:1759
#define TRACE(s)
Definition: solgame.cpp:4
static void debug_dump_ir_deref(const struct hlsl_ir_deref *deref)
Definition: utils.c:1800
static void debug_dump_ir_jump(const struct hlsl_ir_jump *jump)
Definition: utils.c:2016
static void debug_dump_ir_constructor(const struct hlsl_ir_constructor *constructor)
Definition: utils.c:1953
static void debug_dump_ir_constant(const struct hlsl_ir_constant *constant)
Definition: utils.c:1822
static struct hlsl_ir_jump * jump_from_node(const struct hlsl_ir_node *node)
static void debug_dump_ir_if(const struct hlsl_ir_if *if_node)
Definition: utils.c:2038
static void debug_dump_ir_expr(const struct hlsl_ir_expr *expr)
Definition: utils.c:1940

Referenced by debug_dump_instr_list(), debug_dump_ir_assignment(), debug_dump_ir_constructor(), debug_dump_ir_deref(), debug_dump_ir_expr(), debug_dump_ir_if(), debug_dump_ir_jump(), and debug_dump_ir_swizzle().

◆ debug_dump_instr_list()

static void debug_dump_instr_list ( const struct list list)
static

Definition at line 1780 of file utils.c.

1781 {
1782  struct hlsl_ir_node *instr;
1783 
1785  {
1787  TRACE("\n");
1788  }
1789 }
struct x86_inst instr
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2053

Referenced by debug_dump_ir_function_decl(), and debug_dump_ir_if().

◆ debug_dump_ir_assignment()

static void debug_dump_ir_assignment ( const struct hlsl_ir_assignment assign)
static

Definition at line 1985 of file utils.c.

1986 {
1987  TRACE("= (");
1988  debug_dump_instr(assign->lhs);
1989  if (assign->writemask != BWRITERSP_WRITEMASK_ALL)
1990  TRACE("%s", debug_writemask(assign->writemask));
1991  TRACE(" ");
1992  debug_dump_instr(assign->rhs);
1993  TRACE(")");
1994 }
#define BWRITERSP_WRITEMASK_ALL
static const char * debug_writemask(DWORD writemask)
Definition: utils.c:1966
#define TRACE(s)
Definition: solgame.cpp:4
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2053
struct hlsl_ir_node * rhs
struct hlsl_ir_node * lhs

Referenced by debug_dump_instr().

◆ debug_dump_ir_constant()

static void debug_dump_ir_constant ( const struct hlsl_ir_constant constant)
static

Definition at line 1822 of file utils.c.

1823 {
1824  struct hlsl_type *type = constant->node.data_type;
1825  unsigned int x, y;
1826 
1827  if (type->dimy != 1)
1828  TRACE("{");
1829  for (y = 0; y < type->dimy; ++y)
1830  {
1831  if (type->dimx != 1)
1832  TRACE("{");
1833  for (x = 0; x < type->dimx; ++x)
1834  {
1835  switch (type->base_type)
1836  {
1837  case HLSL_TYPE_FLOAT:
1838  TRACE("%g ", (double)constant->v.value.f[y * type->dimx + x]);
1839  break;
1840  case HLSL_TYPE_DOUBLE:
1841  TRACE("%g ", constant->v.value.d[y * type->dimx + x]);
1842  break;
1843  case HLSL_TYPE_INT:
1844  TRACE("%d ", constant->v.value.i[y * type->dimx + x]);
1845  break;
1846  case HLSL_TYPE_UINT:
1847  TRACE("%u ", constant->v.value.u[y * type->dimx + x]);
1848  break;
1849  case HLSL_TYPE_BOOL:
1850  TRACE("%s ", constant->v.value.b[y * type->dimx + x] == FALSE ? "false" : "true");
1851  break;
1852  default:
1853  TRACE("Constants of type %s not supported\n", debug_base_type(type));
1854  }
1855  }
1856  if (type->dimx != 1)
1857  TRACE("}");
1858  }
1859  if (type->dimy != 1)
1860  TRACE("}");
1861 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static const char * debug_base_type(const struct hlsl_type *type)
Definition: utils.c:1667
#define TRACE(s)
Definition: solgame.cpp:4
union constant::@231 value[4]
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by debug_dump_instr().

◆ debug_dump_ir_constructor()

static void debug_dump_ir_constructor ( const struct hlsl_ir_constructor constructor)
static

Definition at line 1953 of file utils.c.

1954 {
1955  unsigned int i;
1956 
1957  TRACE("%s (", debug_hlsl_type(constructor->node.data_type));
1958  for (i = 0; i < constructor->args_count; ++i)
1959  {
1960  debug_dump_instr(constructor->args[i]);
1961  TRACE(" ");
1962  }
1963  TRACE(")");
1964 }
const char * debug_hlsl_type(const struct hlsl_type *type)
Definition: utils.c:1695
struct hlsl_ir_node * args[16]
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 debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2053
struct hlsl_ir_node node

Referenced by debug_dump_instr().

◆ debug_dump_ir_deref()

static void debug_dump_ir_deref ( const struct hlsl_ir_deref deref)
static

Definition at line 1800 of file utils.c.

1801 {
1802  switch (deref->type)
1803  {
1804  case HLSL_IR_DEREF_VAR:
1805  TRACE("deref(");
1806  debug_dump_ir_var(deref->v.var);
1807  TRACE(")");
1808  break;
1809  case HLSL_IR_DEREF_ARRAY:
1810  debug_dump_instr(deref->v.array.array);
1811  TRACE("[");
1812  debug_dump_instr(deref->v.array.index);
1813  TRACE("]");
1814  break;
1815  case HLSL_IR_DEREF_RECORD:
1816  debug_dump_instr(deref->v.record.record);
1817  TRACE(".%s", debugstr_a(deref->v.record.field->name));
1818  break;
1819  }
1820 }
static void debug_dump_ir_var(const struct hlsl_ir_var *var)
Definition: utils.c:1791
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
union hlsl_ir_deref::@235 v
enum hlsl_ir_deref_type type
struct hlsl_ir_var * var
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2053
struct hlsl_ir_node * array
struct hlsl_ir_node * record

Referenced by debug_dump_instr().

◆ debug_dump_ir_expr()

static void debug_dump_ir_expr ( const struct hlsl_ir_expr expr)
static

Definition at line 1940 of file utils.c.

1941 {
1942  unsigned int i;
1943 
1944  TRACE("%s (", debug_expr_op(expr));
1945  for (i = 0; i < 3 && expr->operands[i]; ++i)
1946  {
1947  debug_dump_instr(expr->operands[i]);
1948  TRACE(" ");
1949  }
1950  TRACE(")");
1951 }
static const char * debug_expr_op(const struct hlsl_ir_expr *expr)
Definition: utils.c:1863
Definition: query.h:86
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 debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2053

Referenced by debug_dump_instr().

◆ debug_dump_ir_function_decl()

void debug_dump_ir_function_decl ( const struct hlsl_ir_function_decl func)

Definition at line 2086 of file utils.c.

2087 {
2088  struct hlsl_ir_var *param;
2089 
2090  TRACE("Dumping function %s.\n", debugstr_a(func->func->name));
2091  TRACE("Function parameters:\n");
2092  LIST_FOR_EACH_ENTRY(param, func->parameters, struct hlsl_ir_var, param_entry)
2093  {
2095  TRACE("\n");
2096  }
2097  if (func->semantic)
2098  TRACE("Function semantic: %s\n", debugstr_a(func->semantic));
2099  if (func->body)
2100  {
2101  debug_dump_instr_list(func->body);
2102  }
2103 }
GLenum func
Definition: glext.h:6028
struct list scope_entry param_entry
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static void debug_dump_instr_list(const struct list *list)
Definition: utils.c:1780
static void debug_dump_ir_var(const struct hlsl_ir_var *var)
Definition: utils.c:1791
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
GLfloat param
Definition: glext.h:5796

Referenced by dump_function_decl().

◆ debug_dump_ir_if()

static void debug_dump_ir_if ( const struct hlsl_ir_if if_node)
static

Definition at line 2038 of file utils.c.

2039 {
2040  TRACE("if (");
2041  debug_dump_instr(if_node->condition);
2042  TRACE(")\n{\n");
2044  TRACE("}\n");
2045  if (if_node->else_instrs)
2046  {
2047  TRACE("else\n{\n");
2049  TRACE("}\n");
2050  }
2051 }
struct hlsl_ir_node * condition
static void debug_dump_instr_list(const struct list *list)
Definition: utils.c:1780
#define TRACE(s)
Definition: solgame.cpp:4
struct list * else_instrs
struct list * then_instrs
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2053

Referenced by debug_dump_instr().

◆ debug_dump_ir_jump()

static void debug_dump_ir_jump ( const struct hlsl_ir_jump jump)
static

Definition at line 2016 of file utils.c.

2017 {
2018  switch (jump->type)
2019  {
2020  case HLSL_IR_JUMP_BREAK:
2021  TRACE("break");
2022  break;
2023  case HLSL_IR_JUMP_CONTINUE:
2024  TRACE("continue");
2025  break;
2026  case HLSL_IR_JUMP_DISCARD:
2027  TRACE("discard");
2028  break;
2029  case HLSL_IR_JUMP_RETURN:
2030  TRACE("return ");
2031  if (jump->return_value)
2033  TRACE(";");
2034  break;
2035  }
2036 }
struct hlsl_ir_node * return_value
enum hlsl_ir_jump_type type
#define TRACE(s)
Definition: solgame.cpp:4
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2053

Referenced by debug_dump_instr().

◆ debug_dump_ir_swizzle()

static void debug_dump_ir_swizzle ( const struct hlsl_ir_swizzle swizzle)
static

Definition at line 1996 of file utils.c.

1997 {
1998  unsigned int i;
1999 
2000  debug_dump_instr(swizzle->val);
2001  TRACE(".");
2002  if (swizzle->val->data_type->dimy > 1)
2003  {
2004  for (i = 0; i < swizzle->node.data_type->dimx; ++i)
2005  TRACE("_m%u%u", (swizzle->swizzle >> i * 8) & 0xf, (swizzle->swizzle >> (i * 8 + 4)) & 0xf);
2006  }
2007  else
2008  {
2009  static const char c[] = {'x', 'y', 'z', 'w'};
2010 
2011  for (i = 0; i < swizzle->node.data_type->dimx; ++i)
2012  TRACE("%c", c[(swizzle->swizzle >> i * 2) & 0x3]);
2013  }
2014 }
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
const GLubyte * c
Definition: glext.h:8905
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2053
GLuint GLenum swizzle
Definition: glext.h:9511

Referenced by debug_dump_instr().

◆ debug_dump_ir_var()

static void debug_dump_ir_var ( const struct hlsl_ir_var var)
static

Definition at line 1791 of file utils.c.

1792 {
1793  if (var->modifiers)
1794  TRACE("%s ", debug_modifiers(var->modifiers));
1795  TRACE("%s %s", debug_hlsl_type(var->data_type), var->name);
1796  if (var->semantic)
1797  TRACE(" : %s", debugstr_a(var->semantic));
1798 }
const char * var
Definition: shader.c:5666
const char * debug_hlsl_type(const struct hlsl_type *type)
Definition: utils.c:1695
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
const char * debug_modifiers(DWORD modifiers)
Definition: utils.c:1722

Referenced by debug_dump_ir_deref(), and debug_dump_ir_function_decl().

◆ debug_expr_op()

static const char* debug_expr_op ( const struct hlsl_ir_expr expr)
static

Definition at line 1863 of file utils.c.

1864 {
1865  static const char * const op_names[] =
1866  {
1867  "~",
1868  "!",
1869  "-",
1870  "abs",
1871  "sign",
1872  "rcp",
1873  "rsq",
1874  "sqrt",
1875  "nrm",
1876  "exp2",
1877  "log2",
1878 
1879  "cast",
1880 
1881  "fract",
1882 
1883  "sin",
1884  "cos",
1885  "sin_reduced",
1886  "cos_reduced",
1887 
1888  "dsx",
1889  "dsy",
1890 
1891  "sat",
1892 
1893  "pre++",
1894  "pre--",
1895  "post++",
1896  "post--",
1897 
1898  "+",
1899  "-",
1900  "*",
1901  "/",
1902 
1903  "%",
1904 
1905  "<",
1906  ">",
1907  "<=",
1908  ">=",
1909  "==",
1910  "!=",
1911 
1912  "&&",
1913  "||",
1914 
1915  "<<",
1916  ">>",
1917  "&",
1918  "|",
1919  "^",
1920 
1921  "dot",
1922  "crs",
1923  "min",
1924  "max",
1925 
1926  "pow",
1927 
1928  "lerp",
1929 
1930  ",",
1931  };
1932 
1933  if (expr->op == HLSL_IR_UNOP_CAST)
1934  return debug_hlsl_type(expr->node.data_type);
1935 
1936  return op_names[expr->op];
1937 }
const char * debug_hlsl_type(const struct hlsl_type *type)
Definition: utils.c:1695
Definition: query.h:86

Referenced by debug_dump_ir_expr().

◆ debug_hlsl_type()

const char* debug_hlsl_type ( const struct hlsl_type type)

Definition at line 1695 of file utils.c.

1696 {
1697  const char *name;
1698 
1699  if (type->name)
1700  return debugstr_a(type->name);
1701 
1702  if (type->type == HLSL_CLASS_STRUCT)
1703  return "<anonymous struct>";
1704 
1705  if (type->type == HLSL_CLASS_ARRAY)
1706  {
1707  name = debug_base_type(type->e.array.type);
1708  return wine_dbg_sprintf("%s[%u]", name, type->e.array.elements_count);
1709  }
1710 
1712 
1713  if (type->type == HLSL_CLASS_SCALAR)
1714  return wine_dbg_sprintf("%s", name);
1715  if (type->type == HLSL_CLASS_VECTOR)
1716  return wine_dbg_sprintf("%s%u", name, type->dimx);
1717  if (type->type == HLSL_CLASS_MATRIX)
1718  return wine_dbg_sprintf("%s%ux%u", name, type->dimx, type->dimy);
1719  return "unexpected_type";
1720 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static const char * debug_base_type(const struct hlsl_type *type)
Definition: utils.c:1667
#define debugstr_a
Definition: kernel32.h:31
Definition: name.c:38
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by components_count_type(), debug_dump_decl(), debug_dump_ir_constructor(), debug_dump_ir_var(), debug_expr_op(), implicit_conversion(), make_assignment(), new_expr(), and yyparse().

◆ debug_modifiers()

const char* debug_modifiers ( DWORD  modifiers)

Definition at line 1722 of file utils.c.

1723 {
1724  char string[110];
1725 
1726  string[0] = 0;
1728  strcat(string, " extern"); /* 7 */
1730  strcat(string, " nointerpolation"); /* 16 */
1732  strcat(string, " precise"); /* 8 */
1734  strcat(string, " shared"); /* 7 */
1736  strcat(string, " groupshared"); /* 12 */
1738  strcat(string, " static"); /* 7 */
1740  strcat(string, " uniform"); /* 8 */
1742  strcat(string, " volatile"); /* 9 */
1744  strcat(string, " const"); /* 6 */
1746  strcat(string, " row_major"); /* 10 */
1748  strcat(string, " column_major"); /* 13 */
1750  strcat(string, " inout"); /* 6 */
1751  else if (modifiers & HLSL_MODIFIER_IN)
1752  strcat(string, " in"); /* 3 */
1753  else if (modifiers & HLSL_MODIFIER_OUT)
1754  strcat(string, " out"); /* 4 */
1755 
1756  return wine_dbg_sprintf("%s", string[0] ? string + 1 : "");
1757 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define HLSL_MODIFIER_CONST
#define HLSL_MODIFIER_PRECISE
#define HLSL_MODIFIER_OUT
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
#define HLSL_STORAGE_STATIC
#define HLSL_STORAGE_GROUPSHARED
#define HLSL_MODIFIER_ROW_MAJOR
#define HLSL_STORAGE_SHARED
#define HLSL_STORAGE_EXTERN
#define HLSL_MODIFIER_IN
#define HLSL_STORAGE_UNIFORM
#define HLSL_STORAGE_NOINTERPOLATION
#define HLSL_STORAGE_VOLATILE
unsigned int modifiers
#define HLSL_MODIFIER_COLUMN_MAJOR

Referenced by add_modifier(), debug_dump_decl(), debug_dump_ir_var(), and declare_variable().

◆ debug_node_type()

static const char* debug_node_type ( enum hlsl_ir_node_type  type)
static

Definition at line 1759 of file utils.c.

1760 {
1761  static const char * const names[] =
1762  {
1763  "HLSL_IR_ASSIGNMENT",
1764  "HLSL_IR_CONSTANT",
1765  "HLSL_IR_CONSTRUCTOR",
1766  "HLSL_IR_DEREF",
1767  "HLSL_IR_EXPR",
1768  "HLSL_IR_IF",
1769  "HLSL_IR_JUMP",
1770  "HLSL_IR_SWIZZLE",
1771  };
1772 
1773  if (type >= ARRAY_SIZE(names))
1774  return "Unexpected node type";
1775  return names[type];
1776 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint * names
Definition: glext.h:11545
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by debug_dump_instr(), and free_instr().

◆ debug_print_comp()

const char* debug_print_comp ( DWORD  comp)

Definition at line 401 of file utils.c.

402 {
403  switch (comp)
404  {
405  case BWRITER_COMPARISON_NONE: return "";
406  case BWRITER_COMPARISON_GT: return "_gt";
407  case BWRITER_COMPARISON_EQ: return "_eq";
408  case BWRITER_COMPARISON_GE: return "_ge";
409  case BWRITER_COMPARISON_LT: return "_lt";
410  case BWRITER_COMPARISON_NE: return "_ne";
411  case BWRITER_COMPARISON_LE: return "_le";
412  default: return "_unknown";
413  }
414 }

Referenced by asmparser_instr().

◆ debug_print_dstmod()

const char* debug_print_dstmod ( DWORD  mod)

Definition at line 153 of file utils.c.

154 {
155  switch (mod)
156  {
157  case 0:
158  return "";
160  return "_sat";
162  return "_pp";
164  return "_centroid";
166  return "_sat_pp";
168  return "_sat_centroid";
170  return "_pp_centroid";
172  return "_sat_pp_centroid";
173  default:
174  return "Unexpected modifier\n";
175  }
176 }
static int mod
Definition: i386-dis.c:1273

Referenced by asmparser_instr(), and check_ps_dstmod().

◆ debug_print_dstreg()

const char* debug_print_dstreg ( const struct shader_reg reg)

Definition at line 330 of file utils.c.

331 {
332  return wine_dbg_sprintf("%s%s%s", get_regname(reg),
334  debug_print_writemask(reg->u.writemask));
335 }
static const char * debug_print_relarg(const struct shader_reg *reg)
Definition: utils.c:315
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static const char * debug_print_writemask(DWORD mask)
Definition: utils.c:258
static const char * get_regname(const struct shader_reg *reg)
Definition: utils.c:202
static int reg
Definition: i386-dis.c:1275

Referenced by asmparser_dstreg_ps_1_0123(), asmparser_dstreg_ps_1_4(), asmparser_dstreg_ps_2(), asmparser_dstreg_ps_2_x(), asmparser_dstreg_ps_3(), asmparser_dstreg_vs_1(), asmparser_dstreg_vs_2(), asmparser_dstreg_vs_3(), and asmparser_instr().

◆ debug_print_opcode()

const char* debug_print_opcode ( DWORD  opcode)

Definition at line 416 of file utils.c.

417 {
418  switch (opcode)
419  {
420  case BWRITERSIO_NOP: return "nop";
421  case BWRITERSIO_MOV: return "mov";
422  case BWRITERSIO_ADD: return "add";
423  case BWRITERSIO_SUB: return "sub";
424  case BWRITERSIO_MAD: return "mad";
425  case BWRITERSIO_MUL: return "mul";
426  case BWRITERSIO_RCP: return "rcp";
427  case BWRITERSIO_RSQ: return "rsq";
428  case BWRITERSIO_DP3: return "dp3";
429  case BWRITERSIO_DP4: return "dp4";
430  case BWRITERSIO_MIN: return "min";
431  case BWRITERSIO_MAX: return "max";
432  case BWRITERSIO_SLT: return "slt";
433  case BWRITERSIO_SGE: return "sge";
434  case BWRITERSIO_EXP: return "exp";
435  case BWRITERSIO_LOG: return "log";
436  case BWRITERSIO_LIT: return "lit";
437  case BWRITERSIO_DST: return "dst";
438  case BWRITERSIO_LRP: return "lrp";
439  case BWRITERSIO_FRC: return "frc";
440  case BWRITERSIO_M4x4: return "m4x4";
441  case BWRITERSIO_M4x3: return "m4x3";
442  case BWRITERSIO_M3x4: return "m3x4";
443  case BWRITERSIO_M3x3: return "m3x3";
444  case BWRITERSIO_M3x2: return "m3x2";
445  case BWRITERSIO_CALL: return "call";
446  case BWRITERSIO_CALLNZ: return "callnz";
447  case BWRITERSIO_LOOP: return "loop";
448  case BWRITERSIO_RET: return "ret";
449  case BWRITERSIO_ENDLOOP: return "endloop";
450  case BWRITERSIO_LABEL: return "label";
451  case BWRITERSIO_DCL: return "dcl";
452  case BWRITERSIO_POW: return "pow";
453  case BWRITERSIO_CRS: return "crs";
454  case BWRITERSIO_SGN: return "sgn";
455  case BWRITERSIO_ABS: return "abs";
456  case BWRITERSIO_NRM: return "nrm";
457  case BWRITERSIO_SINCOS: return "sincos";
458  case BWRITERSIO_REP: return "rep";
459  case BWRITERSIO_ENDREP: return "endrep";
460  case BWRITERSIO_IF: return "if";
461  case BWRITERSIO_IFC: return "ifc";
462  case BWRITERSIO_ELSE: return "else";
463  case BWRITERSIO_ENDIF: return "endif";
464  case BWRITERSIO_BREAK: return "break";
465  case BWRITERSIO_BREAKC: return "breakc";
466  case BWRITERSIO_MOVA: return "mova";
467  case BWRITERSIO_DEFB: return "defb";
468  case BWRITERSIO_DEFI: return "defi";
469  case BWRITERSIO_TEXCOORD: return "texcoord";
470  case BWRITERSIO_TEXKILL: return "texkill";
471  case BWRITERSIO_TEX: return "tex";
472  case BWRITERSIO_TEXBEM: return "texbem";
473  case BWRITERSIO_TEXBEML: return "texbeml";
474  case BWRITERSIO_TEXREG2AR: return "texreg2ar";
475  case BWRITERSIO_TEXREG2GB: return "texreg2gb";
476  case BWRITERSIO_TEXM3x2PAD: return "texm3x2pad";
477  case BWRITERSIO_TEXM3x2TEX: return "texm3x2tex";
478  case BWRITERSIO_TEXM3x3PAD: return "texm3x3pad";
479  case BWRITERSIO_TEXM3x3TEX: return "texm3x3tex";
480  case BWRITERSIO_TEXM3x3SPEC: return "texm3x3vspec";
481  case BWRITERSIO_TEXM3x3VSPEC: return "texm3x3vspec";
482  case BWRITERSIO_EXPP: return "expp";
483  case BWRITERSIO_LOGP: return "logp";
484  case BWRITERSIO_CND: return "cnd";
485  case BWRITERSIO_DEF: return "def";
486  case BWRITERSIO_TEXREG2RGB: return "texreg2rgb";
487  case BWRITERSIO_TEXDP3TEX: return "texdp3tex";
488  case BWRITERSIO_TEXM3x2DEPTH: return "texm3x2depth";
489  case BWRITERSIO_TEXDP3: return "texdp3";
490  case BWRITERSIO_TEXM3x3: return "texm3x3";
491  case BWRITERSIO_TEXDEPTH: return "texdepth";
492  case BWRITERSIO_CMP: return "cmp";
493  case BWRITERSIO_BEM: return "bem";
494  case BWRITERSIO_DP2ADD: return "dp2add";
495  case BWRITERSIO_DSX: return "dsx";
496  case BWRITERSIO_DSY: return "dsy";
497  case BWRITERSIO_TEXLDD: return "texldd";
498  case BWRITERSIO_SETP: return "setp";
499  case BWRITERSIO_TEXLDL: return "texldl";
500  case BWRITERSIO_BREAKP: return "breakp";
501  case BWRITERSIO_PHASE: return "phase";
502 
503  case BWRITERSIO_TEXLDP: return "texldp";
504  case BWRITERSIO_TEXLDB: return "texldb";
505 
506  default: return "unknown";
507  }
508 }

Referenced by asmparser_instr(), and call_instr_handler().

◆ debug_print_relarg()

static const char* debug_print_relarg ( const struct shader_reg reg)
static

Definition at line 315 of file utils.c.

316 {
317  const char *short_swizzle;
318  if (!reg->rel_reg) return "";
319 
320  short_swizzle = debug_print_swizzle(reg->rel_reg->u.swizzle);
321 
322  if (reg->rel_reg->type == BWRITERSPR_ADDR)
323  return wine_dbg_sprintf("[a%u%s]", reg->rel_reg->regnum, short_swizzle);
324  else if(reg->rel_reg->type == BWRITERSPR_LOOP && reg->rel_reg->regnum == 0)
325  return wine_dbg_sprintf("[aL%s]", short_swizzle);
326  else
327  return "Unexpected relative addressing argument";
328 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static const char * debug_print_swizzle(DWORD arg)
Definition: utils.c:274
static int reg
Definition: i386-dis.c:1275

Referenced by debug_print_dstreg(), and debug_print_srcreg().

◆ debug_print_shift()

const char* debug_print_shift ( DWORD  shift)

Definition at line 178 of file utils.c.

179 {
180  static const char * const shiftstrings[] =
181  {
182  "",
183  "_x2",
184  "_x4",
185  "_x8",
186  "_x16",
187  "_x32",
188  "",
189  "",
190  "",
191  "",
192  "",
193  "",
194  "_d16",
195  "_d8",
196  "_d4",
197  "_d2",
198  };
199  return shiftstrings[shift];
200 }
#define shift
Definition: input.c:1756

Referenced by asmparser_instr().

◆ debug_print_srcmod()

const char* debug_print_srcmod ( DWORD  mod)

Definition at line 128 of file utils.c.

129 {
130  switch (mod)
131  {
145  default:
146  FIXME("Unrecognized source modifier %#x.\n", mod);
147  return "unrecognized_src_mod";
148  }
149 }
#define WINE_D3DCOMPILER_TO_STR(x)
Definition: utils.c:30
#define FIXME(fmt,...)
Definition: debug.h:110
static int mod
Definition: i386-dis.c:1273

Referenced by check_abs_srcmod(), check_legacy_srcmod(), and yyparse().

◆ debug_print_srcreg()

const char* debug_print_srcreg ( const struct shader_reg reg)

Definition at line 337 of file utils.c.

338 {
339  switch (reg->srcmod)
340  {
341  case BWRITERSPSM_NONE:
342  return wine_dbg_sprintf("%s%s%s", get_regname(reg),
344  debug_print_swizzle(reg->u.swizzle));
345  case BWRITERSPSM_NEG:
346  return wine_dbg_sprintf("-%s%s%s", get_regname(reg),
348  debug_print_swizzle(reg->u.swizzle));
349  case BWRITERSPSM_BIAS:
350  return wine_dbg_sprintf("%s%s_bias%s", get_regname(reg),
352  debug_print_swizzle(reg->u.swizzle));
353  case BWRITERSPSM_BIASNEG:
354  return wine_dbg_sprintf("-%s%s_bias%s", get_regname(reg),
356  debug_print_swizzle(reg->u.swizzle));
357  case BWRITERSPSM_SIGN:
358  return wine_dbg_sprintf("%s%s_bx2%s", get_regname(reg),
360  debug_print_swizzle(reg->u.swizzle));
361  case BWRITERSPSM_SIGNNEG:
362  return wine_dbg_sprintf("-%s%s_bx2%s", get_regname(reg),
364  debug_print_swizzle(reg->u.swizzle));
365  case BWRITERSPSM_COMP:
366  return wine_dbg_sprintf("1 - %s%s%s", get_regname(reg),
368  debug_print_swizzle(reg->u.swizzle));
369  case BWRITERSPSM_X2:
370  return wine_dbg_sprintf("%s%s_x2%s", get_regname(reg),
372  debug_print_swizzle(reg->u.swizzle));
373  case BWRITERSPSM_X2NEG:
374  return wine_dbg_sprintf("-%s%s_x2%s", get_regname(reg),
376  debug_print_swizzle(reg->u.swizzle));
377  case BWRITERSPSM_DZ:
378  return wine_dbg_sprintf("%s%s_dz%s", get_regname(reg),
380  debug_print_swizzle(reg->u.swizzle));
381  case BWRITERSPSM_DW:
382  return wine_dbg_sprintf("%s%s_dw%s", get_regname(reg),
384  debug_print_swizzle(reg->u.swizzle));
385  case BWRITERSPSM_ABS:
386  return wine_dbg_sprintf("%s%s_abs%s", get_regname(reg),
388  debug_print_swizzle(reg->u.swizzle));
389  case BWRITERSPSM_ABSNEG:
390  return wine_dbg_sprintf("-%s%s_abs%s", get_regname(reg),
392  debug_print_swizzle(reg->u.swizzle));
393  case BWRITERSPSM_NOT:
394  return wine_dbg_sprintf("!%s%s%s", get_regname(reg),
396  debug_print_swizzle(reg->u.swizzle));
397  }
398  return "Unknown modifier";
399 }
static const char * debug_print_relarg(const struct shader_reg *reg)
Definition: utils.c:315
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static const char * debug_print_swizzle(DWORD arg)
Definition: utils.c:274
static const char * get_regname(const struct shader_reg *reg)
Definition: utils.c:202
static int reg
Definition: i386-dis.c:1275

Referenced by asmparser_instr(), asmparser_srcreg_ps_1_0123(), asmparser_srcreg_ps_1_4(), asmparser_srcreg_ps_2(), asmparser_srcreg_ps_2_x(), asmparser_srcreg_ps_3(), asmparser_srcreg_vs_1(), asmparser_srcreg_vs_2(), and asmparser_srcreg_vs_3().

◆ debug_print_swizzle()

static const char* debug_print_swizzle ( DWORD  arg)
static

Definition at line 274 of file utils.c.

275 {
276  char ret[6];
277  unsigned int i;
278  DWORD swizzle[4];
279 
280  switch (arg)
281  {
282  case BWRITERVS_NOSWIZZLE:
283  return "";
284  case BWRITERVS_SWIZZLE_X:
285  return ".x";
286  case BWRITERVS_SWIZZLE_Y:
287  return ".y";
288  case BWRITERVS_SWIZZLE_Z:
289  return ".z";
290  case BWRITERVS_SWIZZLE_W:
291  return ".w";
292  }
293 
294  swizzle[0] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 0)) & 0x03;
295  swizzle[1] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 2)) & 0x03;
296  swizzle[2] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 4)) & 0x03;
297  swizzle[3] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 6)) & 0x03;
298 
299  ret[0] = '.';
300  for (i = 0; i < 4; ++i)
301  {
302  switch (swizzle[i])
303  {
304  case 0: ret[1 + i] = 'x'; break;
305  case 1: ret[1 + i] = 'y'; break;
306  case 2: ret[1 + i] = 'z'; break;
307  case 3: ret[1 + i] = 'w'; break;
308  }
309  }
310  ret[5] = '\0';
311 
312  return wine_dbg_sprintf("%s", ret);
313 }
#define BWRITERVS_SWIZZLE_SHIFT
#define BWRITERVS_SWIZZLE_Z
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
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 long DWORD
Definition: ntddk_ex.h:95
int ret
#define BWRITERVS_SWIZZLE_X
#define BWRITERVS_NOSWIZZLE
GLuint GLenum swizzle
Definition: glext.h:9511
#define BWRITERVS_SWIZZLE_Y
#define BWRITERVS_SWIZZLE_W

Referenced by debug_print_relarg(), and debug_print_srcreg().

◆ debug_print_writemask()

static const char* debug_print_writemask ( DWORD  mask)
static

Definition at line 258 of file utils.c.

259 {
260  char ret[6];
261  unsigned char pos = 1;
262 
263  if(mask == BWRITERSP_WRITEMASK_ALL) return "";
264  ret[0] = '.';
265  if(mask & BWRITERSP_WRITEMASK_0) ret[pos++] = 'x';
266  if(mask & BWRITERSP_WRITEMASK_1) ret[pos++] = 'y';
267  if(mask & BWRITERSP_WRITEMASK_2) ret[pos++] = 'z';
268  if(mask & BWRITERSP_WRITEMASK_3) ret[pos++] = 'w';
269  ret[pos] = 0;
270 
271  return wine_dbg_sprintf("%s", ret);
272 }
#define BWRITERSP_WRITEMASK_1
#define BWRITERSP_WRITEMASK_ALL
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
GLenum GLint GLuint mask
Definition: glext.h:6028
int ret
#define BWRITERSP_WRITEMASK_3
#define BWRITERSP_WRITEMASK_2
#define BWRITERSP_WRITEMASK_0

Referenced by debug_print_dstreg().

◆ debug_writemask()

static const char* debug_writemask ( DWORD  writemask)
static

Definition at line 1966 of file utils.c.

1967 {
1968  static const char components[] = {'x', 'y', 'z', 'w'};
1969  char string[5];
1970  unsigned int i = 0, pos = 0;
1971 
1972  assert(!(writemask & ~BWRITERSP_WRITEMASK_ALL));
1973 
1974  while (writemask)
1975  {
1976  if (writemask & 1)
1977  string[pos++] = components[i];
1978  writemask >>= 1;
1979  i++;
1980  }
1981  string[pos] = '\0';
1982  return wine_dbg_sprintf(".%s", string);
1983 }
#define BWRITERSP_WRITEMASK_ALL
#define assert(x)
Definition: debug.h:53
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
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
GLenum GLenum GLuint components
Definition: glext.h:9620

Referenced by debug_dump_ir_assignment().

◆ dxbc_add_section()

HRESULT dxbc_add_section ( struct dxbc dxbc,
DWORD  tag,
const char data,
DWORD  data_size 
)

Definition at line 529 of file utils.c.

530 {
531  TRACE("dxbc %p, tag %s, size %#x.\n", dxbc, debugstr_an((const char *)&tag, 4), data_size);
532 
533  if (dxbc->count >= dxbc->size)
534  {
535  struct dxbc_section *new_sections;
536  DWORD new_size = dxbc->size << 1;
537 
538  new_sections = HeapReAlloc(GetProcessHeap(), 0, dxbc->sections, new_size * sizeof(*dxbc->sections));
539  if (!new_sections)
540  {
541  ERR("Failed to allocate dxbc section memory\n");
542  return E_OUTOFMEMORY;
543  }
544 
545  dxbc->sections = new_sections;
546  dxbc->size = new_size;
547  }
548 
549  dxbc->sections[dxbc->count].tag = tag;
550  dxbc->sections[dxbc->count].data_size = data_size;
551  dxbc->sections[dxbc->count].data = data;
552  ++dxbc->count;
553 
554  return S_OK;
555 }
Definition: ecma_167.h:138
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
struct dxbc_section * sections
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:47
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
#define HeapReAlloc
Definition: compat.h:401
char * tag
Definition: main.c:59

Referenced by d3dcompiler_get_blob_part(), d3dcompiler_strip_shader(), and dxbc_parse().

◆ dxbc_destroy()

void dxbc_destroy ( struct dxbc dxbc)

Definition at line 648 of file utils.c.

649 {
650  TRACE("dxbc %p.\n", dxbc);
651 
653 }
struct dxbc_section * sections
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by d3dcompiler_get_blob_part(), d3dcompiler_shader_reflection_init(), and d3dcompiler_strip_shader().

◆ dxbc_init()

HRESULT dxbc_init ( struct dxbc dxbc,
unsigned int  size 
)

Definition at line 557 of file utils.c.

558 {
559  TRACE("dxbc %p, size %u.\n", dxbc, size);
560 
561  /* use a good starting value for the size if none specified */
562  if (!size) size = 2;
563 
564  dxbc->sections = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*dxbc->sections));
565  if (!dxbc->sections)
566  {
567  ERR("Failed to allocate dxbc section memory\n");
568  return E_OUTOFMEMORY;
569  }
570 
571  dxbc->size = size;
572  dxbc->count = 0;
573 
574  return S_OK;
575 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
struct dxbc_section * sections
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59

Referenced by d3dcompiler_get_blob_part(), d3dcompiler_strip_shader(), and dxbc_parse().

◆ dxbc_parse()

HRESULT dxbc_parse ( const char data,
SIZE_T  data_size,
struct dxbc dxbc 
)

Definition at line 577 of file utils.c.

578 {
579  const char *ptr = data;
580  HRESULT hr;
581  unsigned int i;
582  DWORD tag, total_size, chunk_count;
583 
584  if (!data)
585  {
586  WARN("No data supplied.\n");
587  return E_FAIL;
588  }
589 
590  read_dword(&ptr, &tag);
591  TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
592 
593  if (tag != TAG_DXBC)
594  {
595  WARN("Wrong tag.\n");
596  return E_FAIL;
597  }
598 
599  /* checksum? */
600  skip_dword_unknown(&ptr, 4);
601 
602  skip_dword_unknown(&ptr, 1);
603 
604  read_dword(&ptr, &total_size);
605  TRACE("total size: %#x\n", total_size);
606 
607  if (data_size != total_size)
608  {
609  WARN("Wrong size supplied.\n");
610  return D3DERR_INVALIDCALL;
611  }
612 
613  read_dword(&ptr, &chunk_count);
614  TRACE("chunk count: %#x\n", chunk_count);
615 
616  hr = dxbc_init(dxbc, chunk_count);
617  if (FAILED(hr))
618  {
619  WARN("Failed to init dxbc\n");
620  return hr;
621  }
622 
623  for (i = 0; i < chunk_count; ++i)
624  {
625  DWORD chunk_tag, chunk_size;
626  const char *chunk_ptr;
627  DWORD chunk_offset;
628 
629  read_dword(&ptr, &chunk_offset);
630  TRACE("chunk %u at offset %#x\n", i, chunk_offset);
631 
632  chunk_ptr = data + chunk_offset;
633 
634  read_dword(&chunk_ptr, &chunk_tag);
635  read_dword(&chunk_ptr, &chunk_size);
636 
637  hr = dxbc_add_section(dxbc, chunk_tag, chunk_ptr, chunk_size);
638  if (FAILED(hr))
639  {
640  WARN("Failed to add section to dxbc\n");
641  return hr;
642  }
643  }
644 
645  return hr;
646 }
void skip_dword_unknown(const char **ptr, unsigned int count)
Definition: utils.c:510
HRESULT hr
Definition: shlfolder.c:183
static void read_dword(const char **ptr, DWORD *d)
#define WARN(fmt,...)
Definition: debug.h:111
HRESULT dxbc_init(struct dxbc *dxbc, unsigned int size)
Definition: utils.c:557
#define D3DERR_INVALIDCALL
Definition: ecma_167.h:138
#define E_FAIL
Definition: ddrawi.h:102
#define TAG_DXBC
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 PVOID ptr
Definition: dispmode.c:27
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:47
HRESULT dxbc_add_section(struct dxbc *dxbc, DWORD tag, const char *data, DWORD data_size)
Definition: utils.c:529
char * tag
Definition: main.c:59

Referenced by d3dcompiler_get_blob_part(), d3dcompiler_shader_reflection_init(), and d3dcompiler_strip_shader().

◆ dxbc_write_blob()

HRESULT dxbc_write_blob ( struct dxbc dxbc,
ID3DBlob **  blob 
)

Definition at line 655 of file utils.c.

656 {
657  DWORD size = 32, offset = size + 4 * dxbc->count;
658  ID3DBlob *object;
659  HRESULT hr;
660  char *ptr;
661  unsigned int i;
662 
663  TRACE("dxbc %p, blob %p.\n", dxbc, blob);
664 
665  for (i = 0; i < dxbc->count; ++i)
666  {
667  size += 12 + dxbc->sections[i].data_size;
668  }
669 
670  hr = D3DCreateBlob(size, &object);
671  if (FAILED(hr))
672  {
673  WARN("Failed to create blob\n");
674  return hr;
675  }
676 
677  ptr = ID3D10Blob_GetBufferPointer(object);
678 
680 
681  /* signature(?) */
686 
687  /* seems to be always 1 */
689 
690  /* DXBC size */
691  write_dword(&ptr, size);
692 
693  /* chunk count */
695 
696  /* write the chunk offsets */
697  for (i = 0; i < dxbc->count; ++i)
698  {
700  offset += 8 + dxbc->sections[i].data_size;
701  }
702 
703  /* write the chunks */
704  for (i = 0; i < dxbc->count; ++i)
705  {
706  write_dword(&ptr, dxbc->sections[i].tag);
707  write_dword(&ptr, dxbc->sections[i].data_size);
708  memcpy(ptr, dxbc->sections[i].data, dxbc->sections[i].data_size);
709  ptr += dxbc->sections[i].data_size;
710  }
711 
712  TRACE("Created ID3DBlob %p\n", object);
713 
714  *blob = object;
715 
716  return S_OK;
717 }
HRESULT hr
Definition: shlfolder.c:183
Definition: image.c:133
#define WARN(fmt,...)
Definition: debug.h:111
static void write_dword(char **ptr, DWORD d)
GLintptr offset
Definition: glext.h:5920
#define TAG_DXBC
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 PVOID ptr
Definition: dispmode.c:27
struct dxbc_section * sections
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:78
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
Definition: blob.c:133
static void write_dword_unknown(char **ptr, DWORD d)
Definition: utils.c:523
void * object
Definition: jmemsys.h:48

Referenced by d3dcompiler_get_blob_part(), and d3dcompiler_strip_shader().

◆ expr_common_base_type()

static enum hlsl_base_type expr_common_base_type ( enum hlsl_base_type  t1,
enum hlsl_base_type  t2 
)
static

Definition at line 1152 of file utils.c.

1153 {
1154  static const enum hlsl_base_type types[] =
1155  {
1157  HLSL_TYPE_INT,
1162  };
1163  int t1_idx = -1, t2_idx = -1, i;
1164 
1165  for (i = 0; i < ARRAY_SIZE(types); ++i)
1166  {
1167  /* Always convert away from HLSL_TYPE_HALF */
1168  if (t1 == types[i])
1169  t1_idx = t1 == HLSL_TYPE_HALF ? i + 1 : i;
1170  if (t2 == types[i])
1171  t2_idx = t2 == HLSL_TYPE_HALF ? i + 1 : i;
1172 
1173  if (t1_idx != -1 && t2_idx != -1)
1174  break;
1175  }
1176  if (t1_idx == -1 || t2_idx == -1)
1177  {
1178  FIXME("Unexpected base type.\n");
1179  return HLSL_TYPE_FLOAT;
1180  }
1181  return t1_idx >= t2_idx ? t1 : t2;
1182 }
hlsl_base_type
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 FIXME(fmt,...)
Definition: debug.h:110
Definition: cmds.c:130
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by expr_common_type().

◆ expr_common_type()

static struct hlsl_type* expr_common_type ( struct hlsl_type t1,
struct hlsl_type t2,
struct source_location loc 
)
static

Definition at line 1184 of file utils.c.

1186 {
1187  enum hlsl_type_class type;
1188  enum hlsl_base_type base;
1189  unsigned int dimx, dimy;
1190 
1192  {
1193  hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR,
1194  "non scalar/vector/matrix data type in expression");
1195  return NULL;
1196  }
1197 
1198  if (compare_hlsl_types(t1, t2))
1199  return t1;
1200 
1201  if (!expr_compatible_data_types(t1, t2))
1202  {
1203  hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR,
1204  "expression data types are incompatible");
1205  return NULL;
1206  }
1207 
1208  if (t1->base_type == t2->base_type)
1209  base = t1->base_type;
1210  else
1212 
1213  if (t1->dimx == 1 && t1->dimy == 1)
1214  {
1215  type = t2->type;
1216  dimx = t2->dimx;
1217  dimy = t2->dimy;
1218  }
1219  else if (t2->dimx == 1 && t2->dimy == 1)
1220  {
1221  type = t1->type;
1222  dimx = t1->dimx;
1223  dimy = t1->dimy;
1224  }
1225  else if (t1->type == HLSL_CLASS_MATRIX && t2->type == HLSL_CLASS_MATRIX)
1226  {
1228  dimx = min(t1->dimx, t2->dimx);
1229  dimy = min(t1->dimy, t2->dimy);
1230  }
1231  else
1232  {
1233  /* Two vectors or a vector and a matrix (matrix must be 1xn or nx1) */
1234  unsigned int max_dim_1, max_dim_2;
1235 
1236  max_dim_1 = max(t1->dimx, t1->dimy);
1237  max_dim_2 = max(t2->dimx, t2->dimy);
1238  if (t1->dimx * t1->dimy == t2->dimx * t2->dimy)
1239  {
1241  dimx = max(t1->dimx, t2->dimx);
1242  dimy = 1;
1243  }
1244  else if (max_dim_1 <= max_dim_2)
1245  {
1246  type = t1->type;
1247  if (type == HLSL_CLASS_VECTOR)
1248  {
1249  dimx = max_dim_1;
1250  dimy = 1;
1251  }
1252  else
1253  {
1254  dimx = t1->dimx;
1255  dimy = t1->dimy;
1256  }
1257  }
1258  else
1259  {
1260  type = t2->type;
1261  if (type == HLSL_CLASS_VECTOR)
1262  {
1263  dimx = max_dim_2;
1264  dimy = 1;
1265  }
1266  else
1267  {
1268  dimx = t2->dimx;
1269  dimy = t2->dimy;
1270  }
1271  }
1272  }
1273 
1274  return new_hlsl_type(NULL, type, base, dimx, dimy);
1275 }
unsigned int dimx
#define max(a, b)
Definition: svc.c:63
static BOOL expr_compatible_data_types(struct hlsl_type *t1, struct hlsl_type *t2)
Definition: utils.c:1118
hlsl_base_type
enum hlsl_type_class type
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void WINAPIV hlsl_report_message(const char *filename, DWORD line, DWORD column, enum hlsl_error_level level, const char *fmt,...) PRINTF_ATTR(5
GLuint base
Definition: 3dtext.c:35
smooth NULL
Definition: ftsmooth.c:416
static enum hlsl_base_type expr_common_base_type(enum hlsl_base_type t1, enum hlsl_base_type t2)
Definition: utils.c:1152
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:883
enum hlsl_base_type base_type
hlsl_type_class
#define min(a, b)
Definition: monoChain.cc:55
struct hlsl_type * new_hlsl_type(const char *name, enum hlsl_type_class type_class, enum hlsl_base_type base_type, unsigned dimx, unsigned dimy)
Definition: utils.c:806
unsigned int dimy

Referenced by new_expr().

◆ expr_compatible_data_types()

static BOOL expr_compatible_data_types ( struct hlsl_type t1,
struct hlsl_type t2 
)
static

Definition at line 1118 of file utils.c.

1119 {
1121  return FALSE;
1122 
1123  /* Scalar vars can be converted to pretty much everything */
1124  if ((t1->dimx == 1 && t1->dimy == 1) || (t2->dimx == 1 && t2->dimy == 1))
1125  return TRUE;
1126 
1127  if (t1->type == HLSL_CLASS_VECTOR && t2->type == HLSL_CLASS_VECTOR)
1128  return TRUE;
1129 
1130  if (t1->type == HLSL_CLASS_MATRIX || t2->type == HLSL_CLASS_MATRIX)
1131  {
1132  /* Matrix-vector conversion is apparently allowed if either they have the same components
1133  count or the matrix is nx1 or 1xn */
1134  if (t1->type == HLSL_CLASS_VECTOR || t2->type == HLSL_CLASS_VECTOR)
1135  {
1137  return TRUE;
1138 
1139  return (t1->type == HLSL_CLASS_MATRIX && (t1->dimx == 1 || t1->dimy == 1))
1140  || (t2->type == HLSL_CLASS_MATRIX && (t2->dimx == 1 || t2->dimy == 1));
1141  }
1142 
1143  /* Both matrices */
1144  if ((t1->dimx >= t2->dimx && t1->dimy >= t2->dimy)
1145  || (t1->dimx <= t2->dimx && t1->dimy <= t2->dimy))
1146  return TRUE;
1147  }
1148 
1149  return FALSE;
1150 }
unsigned int dimx
#define TRUE
Definition: types.h:120
enum hlsl_type_class type
unsigned int components_count_type(struct hlsl_type *type)
Definition: utils.c:857
enum hlsl_base_type base_type
unsigned int dimy

Referenced by expr_common_type().

◆ find_function()

BOOL find_function ( const char name)

Definition at line 852 of file utils.c.

853 {
854  return wine_rb_get(&hlsl_ctx.functions, name) != NULL;
855 }
smooth NULL
Definition: ftsmooth.c:416
struct hlsl_parse_ctx hlsl_ctx
Definition: hlsl.tab.c:90
Definition: name.c:38
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203

Referenced by declare_variable().

◆ free_declaration()

void free_declaration ( struct hlsl_ir_var decl)

Definition at line 798 of file utils.c.

799 {
800  d3dcompiler_free((void *)decl->name);
801  d3dcompiler_free((void *)decl->semantic);
802  d3dcompiler_free((void *)decl->reg_reservation);
803  d3dcompiler_free(decl);
804 }
const char * semantic
const struct reg_reservation * reg_reservation
static BOOL d3dcompiler_free(void *ptr)
const char * name

Referenced by add_func_parameter(), declare_vars(), and parse_hlsl().

◆ free_function()

static void free_function ( struct hlsl_ir_function func)
static

Definition at line 2270 of file utils.c.

2271 {
2273  d3dcompiler_free((void *)func->name);
2275 }
GLenum func
Definition: glext.h:6028
static BOOL d3dcompiler_free(void *ptr)
smooth NULL
Definition: ftsmooth.c:416
static void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:198
static void free_function_decl_rb(struct wine_rb_entry *entry, void *context)
Definition: utils.c:2265

Referenced by free_function_rb().

◆ free_function_decl()

static void free_function_decl ( struct hlsl_ir_function_decl decl)
static

Definition at line 2257 of file utils.c.

2258 {
2259  d3dcompiler_free((void *)decl->semantic);
2261  free_instr_list(decl->body);
2262  d3dcompiler_free(decl);
2263 }
void free_instr_list(struct list *list)
Definition: utils.c:2122
static BOOL d3dcompiler_free(void *ptr)

Referenced by add_function_decl(), and free_function_decl_rb().

◆ free_function_decl_rb()

static void free_function_decl_rb ( struct wine_rb_entry entry,
void context 
)
static

Definition at line 2265 of file utils.c.

2266 {
2268 }
static void free_function_decl(struct hlsl_ir_function_decl *decl)
Definition: utils.c:2257
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63

Referenced by add_function_decl(), and free_function().

◆ free_function_rb()

void free_function_rb ( struct wine_rb_entry entry,
void context 
)

Definition at line 2277 of file utils.c.

2278 {
2280 }
static void free_function(struct hlsl_ir_function *func)
Definition: utils.c:2270
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63

Referenced by parse_hlsl().

◆ free_hlsl_type()

void free_hlsl_type ( struct hlsl_type type)

Definition at line 2105 of file utils.c.

2106 {
2107  struct hlsl_struct_field *field, *next_field;
2108 
2109  d3dcompiler_free((void *)type->name);
2110  if (type->type == HLSL_CLASS_STRUCT)
2111  {
2112  LIST_FOR_EACH_ENTRY_SAFE(field, next_field, type->e.elements, struct hlsl_struct_field, entry)
2113  {
2114  d3dcompiler_free((void *)field->name);
2115  d3dcompiler_free((void *)field->semantic);
2117  }
2118  }
2120 }
static BOOL d3dcompiler_free(void *ptr)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: parser.c:43
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204

Referenced by parse_hlsl().

◆ free_instr()

void free_instr ( struct hlsl_ir_node node)

Definition at line 2224 of file utils.c.

2225 {
2226  switch (node->type)
2227  {
2228  case HLSL_IR_CONSTANT:
2230  break;
2231  case HLSL_IR_DEREF:
2233  break;
2234  case HLSL_IR_SWIZZLE:
2236  break;
2237  case HLSL_IR_CONSTRUCTOR:
2239  break;
2240  case HLSL_IR_EXPR:
2242  break;
2243  case HLSL_IR_ASSIGNMENT:
2245  break;
2246  case HLSL_IR_IF:
2248  break;
2249  case HLSL_IR_JUMP:
2251  break;
2252  default:
2253  FIXME("Unsupported node type %s\n", debug_node_type(node->type));
2254  }
2255 }
static void free_ir_expr(struct hlsl_ir_expr *expr)
Definition: utils.c:2188
static struct hlsl_ir_deref * deref_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_if * if_from_node(const struct hlsl_ir_node *node)
static void free_ir_jump(struct hlsl_ir_jump *jump)
Definition: utils.c:2217
static struct hlsl_ir_constructor * constructor_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_constant * constant_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_assignment * assignment_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_expr * expr_from_node(const struct hlsl_ir_node *node)
static struct hlsl_ir_swizzle * swizzle_from_node(const struct hlsl_ir_node *node)
static void free_ir_deref(struct hlsl_ir_deref *deref)
Definition: utils.c:2156
#define FIXME(fmt,...)
Definition: debug.h:110
static void free_ir_assignment(struct hlsl_ir_assignment *assignment)
Definition: utils.c:2202
static void free_ir_constant(struct hlsl_ir_constant *constant)
Definition: utils.c:2133
static const char * debug_node_type(enum hlsl_ir_node_type type)
Definition: utils.c:1759
static void free_ir_if(struct hlsl_ir_if *if_node)
Definition: utils.c:2209
static struct hlsl_ir_jump * jump_from_node(const struct hlsl_ir_node *node)
static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
Definition: utils.c:2174
static void free_ir_constructor(struct hlsl_ir_constructor *constructor)
Definition: utils.c:2180
Definition: dlist.c:348

Referenced by create_loop(), free_instr_list(), free_ir_assignment(), free_ir_constructor(), free_ir_deref(), free_ir_expr(), free_ir_if(), free_ir_jump(), free_ir_swizzle(), free_parse_initializer(), make_assignment(), struct_var_initializer(), and yyparse().

◆ free_instr_list()

void free_instr_list ( struct list list)

Definition at line 2122 of file utils.c.

2123 {
2124  struct hlsl_ir_node *node, *next_node;
2125 
2126  if (!list)
2127  return;
2129  free_instr(node);
2131 }
static BOOL d3dcompiler_free(void *ptr)
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
struct node node
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2224
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
Definition: dlist.c:348

Referenced by create_loop(), free_function_decl(), free_ir_expr(), and free_ir_if().

◆ free_ir_assignment()

static void free_ir_assignment ( struct hlsl_ir_assignment assignment)
static

Definition at line 2202 of file utils.c.

2203 {
2204  free_instr(assignment->lhs);
2205  free_instr(assignment->rhs);
2206  d3dcompiler_free(assignment);
2207 }
static BOOL d3dcompiler_free(void *ptr)
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2224
struct hlsl_ir_node * rhs
struct hlsl_ir_node * lhs

Referenced by free_instr().

◆ free_ir_constant()

static void free_ir_constant ( struct hlsl_ir_constant constant)
static

Definition at line 2133 of file utils.c.

2134 {
2135  struct hlsl_type *type = constant->node.data_type;
2136  unsigned int i;
2137  struct hlsl_ir_constant *field, *next_field;
2138 
2139  switch (type->type)
2140  {
2141  case HLSL_CLASS_ARRAY:
2142  for (i = 0; i < type->e.array.elements_count; ++i)
2143  free_ir_constant(&constant->v.array_elements[i]);
2144  d3dcompiler_free(constant->v.array_elements);
2145  break;
2146  case HLSL_CLASS_STRUCT:
2147  LIST_FOR_EACH_ENTRY_SAFE(field, next_field, constant->v.struct_elements, struct hlsl_ir_constant, node.entry)
2149  break;
2150  default:
2151  break;
2152  }
2154 }
static BOOL d3dcompiler_free(void *ptr)
GLuint GLuint GLsizei GLenum type
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 void free_ir_constant(struct hlsl_ir_constant *constant)
Definition: utils.c:2133
Definition: parser.c:43
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
Definition: dlist.c:348

Referenced by free_instr().

◆ free_ir_constructor()

static void free_ir_constructor ( struct hlsl_ir_constructor constructor)
static

Definition at line 2180 of file utils.c.

2181 {
2182  unsigned int i;
2183  for (i = 0; i < constructor->args_count; ++i)
2184  free_instr(constructor->args[i]);
2185  d3dcompiler_free(constructor);
2186 }
static BOOL d3dcompiler_free(void *ptr)
struct hlsl_ir_node * args[16]
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 free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2224

Referenced by free_instr().

◆ free_ir_deref()

static void free_ir_deref ( struct hlsl_ir_deref deref)
static

Definition at line 2156 of file utils.c.

2157 {
2158  switch (deref->type)
2159  {
2160  case HLSL_IR_DEREF_VAR:
2161  /* Variables are shared among nodes in the tree. */
2162  break;
2163  case HLSL_IR_DEREF_ARRAY:
2164  free_instr(deref->v.array.array);
2165  free_instr(deref->v.array.index);
2166  break;
2167  case HLSL_IR_DEREF_RECORD:
2168  free_instr(deref->v.record.record);
2169  break;
2170  }
2171  d3dcompiler_free(deref);
2172 }
static BOOL d3dcompiler_free(void *ptr)
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2224
union hlsl_ir_deref::@235 v
enum hlsl_ir_deref_type type
struct hlsl_ir_node * array
struct hlsl_ir_node * record

Referenced by free_instr().

◆ free_ir_expr()

static void free_ir_expr ( struct hlsl_ir_expr expr)
static

Definition at line 2188 of file utils.c.

2189 {
2190  unsigned int i;
2191 
2192  for (i = 0; i < 3; ++i)
2193  {
2194  if (!expr->operands[i])
2195  break;
2196  free_instr(expr->operands[i]);
2197  }
2198  free_instr_list(expr->subexpressions);
2200 }
void free_instr_list(struct list *list)
Definition: utils.c:2122
static BOOL d3dcompiler_free(void *ptr)
Definition: query.h:86
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 free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2224

Referenced by free_instr().

◆ free_ir_if()

static void free_ir_if ( struct hlsl_ir_if if_node)
static

Definition at line 2209 of file utils.c.

2210 {
2211  free_instr(if_node->condition);
2212  free_instr_list(if_node->then_instrs);
2213  free_instr_list(if_node->else_instrs);
2214  d3dcompiler_free(if_node);
2215 }
void free_instr_list(struct list *list)
Definition: utils.c:2122
static BOOL d3dcompiler_free(void *ptr)
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2224
struct hlsl_ir_node * condition
struct list * else_instrs
struct list * then_instrs

Referenced by free_instr().

◆ free_ir_jump()

static void free_ir_jump ( struct hlsl_ir_jump jump)
static

Definition at line 2217 of file utils.c.

2218 {
2219  if (jump->type == HLSL_IR_JUMP_RETURN)
2220  free_instr(jump->return_value);
2221  d3dcompiler_free(jump);
2222 }
static BOOL d3dcompiler_free(void *ptr)
struct hlsl_ir_node * return_value
enum hlsl_ir_jump_type type
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2224

Referenced by free_instr().

◆ free_ir_swizzle()

static void free_ir_swizzle ( struct hlsl_ir_swizzle swizzle)
static

Definition at line 2174 of file utils.c.

2175 {
2176  free_instr(swizzle->val);
2178 }
static BOOL d3dcompiler_free(void *ptr)
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2224
GLuint GLenum swizzle
Definition: glext.h:9511

Referenced by free_instr().

◆ get_regname()

static const char* get_regname ( const struct shader_reg reg)
static

Definition at line 202 of file utils.c.

203 {
204  switch (reg->type)
205  {
206  case BWRITERSPR_TEMP:
207  return wine_dbg_sprintf("r%u", reg->regnum);
208  case BWRITERSPR_INPUT:
209  return wine_dbg_sprintf("v%u", reg->regnum);
210  case BWRITERSPR_CONST:
211  return wine_dbg_sprintf("c%u", reg->regnum);
212  case BWRITERSPR_ADDR:
213  return wine_dbg_sprintf("a%u", reg->regnum);
214  case BWRITERSPR_TEXTURE:
215  return wine_dbg_sprintf("t%u", reg->regnum);
216  case BWRITERSPR_RASTOUT:
217  switch (reg->regnum)
218  {
219  case BWRITERSRO_POSITION: return "oPos";
220  case BWRITERSRO_FOG: return "oFog";
221  case BWRITERSRO_POINT_SIZE: return "oPts";
222  default: return "Unexpected RASTOUT";
223  }
224  case BWRITERSPR_ATTROUT:
225  return wine_dbg_sprintf("oD%u", reg->regnum);
227  return wine_dbg_sprintf("oT%u", reg->regnum);
228  case BWRITERSPR_OUTPUT:
229  return wine_dbg_sprintf("o%u", reg->regnum);
230  case BWRITERSPR_CONSTINT:
231  return wine_dbg_sprintf("i%u", reg->regnum);
232  case BWRITERSPR_COLOROUT:
233  return wine_dbg_sprintf("oC%u", reg->regnum);
234  case BWRITERSPR_DEPTHOUT:
235  return "oDepth";
236  case BWRITERSPR_SAMPLER:
237  return wine_dbg_sprintf("s%u", reg->regnum);
239  return wine_dbg_sprintf("b%u", reg->regnum);
240  case BWRITERSPR_LOOP:
241  return "aL";
242  case BWRITERSPR_MISCTYPE:
243  switch (reg->regnum)
244  {
245  case 0: return "vPos";
246  case 1: return "vFace";
247  default: return "unexpected misctype";
248  }
249  case BWRITERSPR_LABEL:
250  return wine_dbg_sprintf("l%u", reg->regnum);
252  return wine_dbg_sprintf("p%u", reg->regnum);
253  default:
254  return wine_dbg_sprintf("unknown regname %#x", reg->type);
255  }
256 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static int reg
Definition: i386-dis.c:1275

Referenced by debug_print_dstreg(), and debug_print_srcreg().

◆ get_type()

struct hlsl_type* get_type ( struct hlsl_scope scope,
const char name,
BOOL  recursive 
)

Definition at line 841 of file utils.c.

842 {
843  struct wine_rb_entry *entry = wine_rb_get(&scope->types, name);
844  if (entry)
845  return WINE_RB_ENTRY_VALUE(entry, struct hlsl_type, scope_entry);
846 
847  if (recursive && scope->upper)
848  return get_type(scope->upper, name, recursive);
849  return NULL;
850 }
struct hlsl_type * get_type(struct hlsl_scope *scope, const char *name, BOOL recursive)
Definition: utils.c:841
smooth NULL
Definition: ftsmooth.c:416
struct hlsl_scope * upper
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63
Definition: rbtree.h:35
Definition: name.c:38
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203
struct wine_rb_tree types

Referenced by add_type_to_scope(), type_new_coclass(), type_new_encapsulated_union(), type_new_module(), and yyparse().

◆ get_variable()

struct hlsl_ir_var* get_variable ( struct hlsl_scope scope,
const char name 
)

Definition at line 784 of file utils.c.

785 {
786  struct hlsl_ir_var *var;
787 
788  LIST_FOR_EACH_ENTRY(var, &scope->vars, struct hlsl_ir_var, scope_entry)
789  {
790  if (!strcmp(name,