ReactOS  0.4.13-dev-73-gcfe54aa
utils.c File Reference
#include "config.h"
#include "wine/port.h"
#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, 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_exprhlsl_mul (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_div (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_mod (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_add (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_sub (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_lt (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_gt (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_le (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_ge (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_eq (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc)
 
struct hlsl_ir_exprhlsl_ne (struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, 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 33 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 764 of file utils.c.

765 {
766  struct hlsl_ir_var *var;
767 
768  LIST_FOR_EACH_ENTRY(var, &scope->vars, struct hlsl_ir_var, scope_entry)
769  {
770  if (!strcmp(decl->name, var->name))
771  return FALSE;
772  }
773  if (local_var && scope->upper->upper == hlsl_ctx.globals)
774  {
775  /* Check whether the variable redefines a function parameter. */
776  LIST_FOR_EACH_ENTRY(var, &scope->upper->vars, struct hlsl_ir_var, scope_entry)
777  {
778  if (!strcmp(decl->name, var->name))
779  return FALSE;
780  }
781  }
782 
783  list_add_tail(&scope->vars, &decl->scope_entry);
784  return TRUE;
785 }
#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:87
struct list scope_entry
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 2456 of file utils.c.

2457 {
2458  struct hlsl_ir_function *func;
2459  struct wine_rb_entry *func_entry, *old_entry;
2460 
2461  func_entry = wine_rb_get(funcs, name);
2462  if (func_entry)
2463  {
2464  func = WINE_RB_ENTRY_VALUE(func_entry, struct hlsl_ir_function, entry);
2465  if (intrinsic != func->intrinsic)
2466  {
2467  if (intrinsic)
2468  {
2469  ERR("Redeclaring a user defined function as an intrinsic.\n");
2470  return;
2471  }
2472  TRACE("Function %s redeclared as a user defined function.\n", debugstr_a(name));
2473  func->intrinsic = intrinsic;
2476  }
2477  decl->func = func;
2478  if ((old_entry = wine_rb_get(&func->overloads, decl->parameters)))
2479  {
2480  struct hlsl_ir_function_decl *old_decl =
2481  WINE_RB_ENTRY_VALUE(old_entry, struct hlsl_ir_function_decl, entry);
2482 
2483  if (!decl->body)
2484  {
2485  free_function_decl(decl);
2487  return;
2488  }
2489  wine_rb_remove(&func->overloads, old_entry);
2490  free_function_decl(old_decl);
2491  }
2492  wine_rb_put(&func->overloads, decl->parameters, &decl->entry);
2494  return;
2495  }
2496  func = d3dcompiler_alloc(sizeof(*func));
2497  func->name = name;
2499  decl->func = func;
2500  wine_rb_put(&func->overloads, decl->parameters, &decl->entry);
2501  func->intrinsic = intrinsic;
2502  wine_rb_put(funcs, func->name, &func->entry);
2503 }
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:1798
uint8_t entry
Definition: isohybrid.c:63
static BOOL d3dcompiler_free(void *ptr)
static void free_function_decl(struct hlsl_ir_function_decl *decl)
Definition: utils.c:2431
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
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:36
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:2439
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 932 of file utils.c.

933 {
934  struct hlsl_type *type;
935  struct hlsl_struct_field *old_field, *field;
936 
937  type = d3dcompiler_alloc(sizeof(*type));
938  if (!type)
939  {
940  ERR("Out of memory\n");
941  return NULL;
942  }
943  if (old->name)
944  {
945  type->name = d3dcompiler_strdup(old->name);
946  if (!type->name)
947  {
949  return NULL;
950  }
951  }
952  type->type = old->type;
953  type->base_type = old->base_type;
954  type->dimx = old->dimx;
955  type->dimy = old->dimy;
956  type->modifiers = old->modifiers;
957  type->sampler_dim = old->sampler_dim;
958  switch (old->type)
959  {
960  case HLSL_CLASS_ARRAY:
961  type->e.array.type = old->e.array.type;
962  type->e.array.elements_count = old->e.array.elements_count;
963  break;
964  case HLSL_CLASS_STRUCT:
965  type->e.elements = d3dcompiler_alloc(sizeof(*type->e.elements));
966  if (!type->e.elements)
967  {
968  d3dcompiler_free((void *)type->name);
970  return NULL;
971  }
972  list_init(type->e.elements);
973  LIST_FOR_EACH_ENTRY(old_field, old->e.elements, struct hlsl_struct_field, entry)
974  {
975  field = d3dcompiler_alloc(sizeof(*field));
976  if (!field)
977  {
978  LIST_FOR_EACH_ENTRY_SAFE(field, old_field, type->e.elements, struct hlsl_struct_field, entry)
979  {
980  d3dcompiler_free((void *)field->semantic);
981  d3dcompiler_free((void *)field->name);
983  }
984  d3dcompiler_free(type->e.elements);
985  d3dcompiler_free((void *)type->name);
987  return NULL;
988  }
989  field->type = clone_hlsl_type(old_field->type);
990  field->name = d3dcompiler_strdup(old_field->name);
991  if (old_field->semantic)
992  field->semantic = d3dcompiler_strdup(old_field->semantic);
993  field->modifiers = old_field->modifiers;
994  list_add_tail(type->e.elements, &field->entry);
995  }
996  break;
997  default:
998  break;
999  }
1000 
1001  list_add_tail(&hlsl_ctx.types, &type->entry);
1002  return type;
1003 }
unsigned int dimx
enum hlsl_type_class type
enum hlsl_sampler_dim sampler_dim
uint8_t entry
Definition: isohybrid.c:63
static BOOL d3dcompiler_free(void *ptr)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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
union hlsl_type::@231 e
#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:87
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::@231::@232 array
struct hlsl_type * clone_hlsl_type(struct hlsl_type *old)
Definition: utils.c:932
__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 1798 of file utils.c.

1799 {
1800  const struct list *params = key;
1801  const struct hlsl_ir_function_decl *decl = WINE_RB_ENTRY_VALUE(entry, const struct hlsl_ir_function_decl, entry);
1802  int params_count = params ? list_count(params) : 0;
1803  int decl_params_count = decl->parameters ? list_count(decl->parameters) : 0;
1804  int r;
1805  struct list *p1cur, *p2cur;
1806 
1807  if (params_count != decl_params_count)
1808  return params_count - decl_params_count;
1809 
1810  p1cur = params ? list_head(params) : NULL;
1811  p2cur = decl->parameters ? list_head(decl->parameters) : NULL;
1812  while (p1cur && p2cur)
1813  {
1814  struct hlsl_ir_var *p1, *p2;
1815  p1 = LIST_ENTRY(p1cur, struct hlsl_ir_var, node.entry);
1816  p2 = LIST_ENTRY(p2cur, struct hlsl_ir_var, node.entry);
1817  if ((r = compare_param_hlsl_types(p1->node.data_type, p2->node.data_type)))
1818  return r;
1819  p1cur = list_next(params, p1cur);
1820  p2cur = list_next(decl->parameters, p2cur);
1821  }
1822  return 0;
1823 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
struct hlsl_ir_node node
uint8_t entry
Definition: isohybrid.c:63
__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
HKEY key
Definition: reg.c:42
Definition: _list.h:228
static int compare_param_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:1749
__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
Definition: dlist.c:348

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 1825 of file utils.c.

1826 {
1827  const char *name = key;
1828  const struct hlsl_ir_function *func = WINE_RB_ENTRY_VALUE(entry, const struct hlsl_ir_function,entry);
1829 
1830  return strcmp(name, func->name);
1831 }
GLenum func
Definition: glext.h:6028
uint8_t entry
Definition: isohybrid.c:63
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
HKEY key
Definition: reg.c:42
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
WCHAR * name
Definition: name.c:40

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 886 of file utils.c.

887 {
888  if (t1 == t2)
889  return TRUE;
890 
891  if (t1->type != t2->type)
892  return FALSE;
893  if (t1->base_type != t2->base_type)
894  return FALSE;
895  if (t1->base_type == HLSL_TYPE_SAMPLER && t1->sampler_dim != t2->sampler_dim)
896  return FALSE;
899  return FALSE;
900  if (t1->dimx != t2->dimx)
901  return FALSE;
902  if (t1->dimy != t2->dimy)
903  return FALSE;
904  if (t1->type == HLSL_CLASS_STRUCT)
905  {
906  struct list *t1cur, *t2cur;
907  struct hlsl_struct_field *t1field, *t2field;
908 
909  t1cur = list_head(t1->e.elements);
910  t2cur = list_head(t2->e.elements);
911  while (t1cur && t2cur)
912  {
913  t1field = LIST_ENTRY(t1cur, struct hlsl_struct_field, entry);
914  t2field = LIST_ENTRY(t2cur, struct hlsl_struct_field, entry);
915  if (!compare_hlsl_types(t1field->type, t2field->type))
916  return FALSE;
917  if (strcmp(t1field->name, t2field->name))
918  return FALSE;
919  t1cur = list_next(t1->e.elements, t1cur);
920  t2cur = list_next(t2->e.elements, t2cur);
921  }
922  if (t1cur != t2cur)
923  return FALSE;
924  }
925  if (t1->type == HLSL_CLASS_ARRAY)
926  return t1->e.array.elements_count == t2->e.array.elements_count
927  && compare_hlsl_types(t1->e.array.type, t2->e.array.type);
928 
929  return TRUE;
930 }
unsigned int dimx
#define TRUE
Definition: types.h:120
enum hlsl_type_class type
enum hlsl_sampler_dim sampler_dim
uint8_t entry
Definition: isohybrid.c:63
#define HLSL_MODIFIERS_COMPARISON_MASK
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
union hlsl_type::@231 e
struct hlsl_type * type
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:886
enum hlsl_base_type base_type
struct list * elements
Definition: _list.h:228
unsigned int modifiers
struct hlsl_type::@231::@232 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 1688 of file utils.c.

1689 {
1690  const char *name = key;
1691  const struct hlsl_type *type = WINE_RB_ENTRY_VALUE(entry, const struct hlsl_type, scope_entry);
1692 
1693  if (name == type->name)
1694  return 0;
1695 
1696  if (!name || !type->name)
1697  {
1698  ERR("hlsl_type without a name in a scope?\n");
1699  return -1;
1700  }
1701  return strcmp(name, type->name);
1702 }
uint8_t entry
Definition: isohybrid.c:63
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
#define ERR(fmt,...)
Definition: debug.h:109
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
WCHAR * name
Definition: name.c:40

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 1749 of file utils.c.

1750 {
1751  if (t1->type != t2->type)
1752  {
1753  if (!((t1->type == HLSL_CLASS_SCALAR && t2->type == HLSL_CLASS_VECTOR)
1754  || (t1->type == HLSL_CLASS_VECTOR && t2->type == HLSL_CLASS_SCALAR)))
1755  return t1->type - t2->type;
1756  }
1757  if (t1->base_type != t2->base_type)
1758  return t1->base_type - t2->base_type;
1759  if (t1->base_type == HLSL_TYPE_SAMPLER && t1->sampler_dim != t2->sampler_dim)
1760  return t1->sampler_dim - t2->sampler_dim;
1761  if (t1->dimx != t2->dimx)
1762  return t1->dimx - t2->dimx;
1763  if (t1->dimy != t2->dimy)
1764  return t1->dimx - t2->dimx;
1765  if (t1->type == HLSL_CLASS_STRUCT)
1766  {
1767  struct list *t1cur, *t2cur;
1768  struct hlsl_struct_field *t1field, *t2field;
1769  int r;
1770 
1771  t1cur = list_head(t1->e.elements);
1772  t2cur = list_head(t2->e.elements);
1773  while (t1cur && t2cur)
1774  {
1775  t1field = LIST_ENTRY(t1cur, struct hlsl_struct_field, entry);
1776  t2field = LIST_ENTRY(t2cur, struct hlsl_struct_field, entry);
1777  if ((r = compare_param_hlsl_types(t1field->type, t2field->type)))
1778  return r;
1779  if ((r = strcmp(t1field->name, t2field->name)))
1780  return r;
1781  t1cur = list_next(t1->e.elements, t1cur);
1782  t2cur = list_next(t2->e.elements, t2cur);
1783  }
1784  if (t1cur != t2cur)
1785  return t1cur ? 1 : -1;
1786  return 0;
1787  }
1788  if (t1->type == HLSL_CLASS_ARRAY)
1789  {
1790  if (t1->e.array.elements_count != t2->e.array.elements_count)
1791  return t1->e.array.elements_count - t2->e.array.elements_count;
1792  return compare_param_hlsl_types(t1->e.array.type, t2->e.array.type);
1793  }
1794 
1795  return 0;
1796 }
unsigned int dimx
enum hlsl_type_class type
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
enum hlsl_sampler_dim sampler_dim
uint8_t entry
Definition: isohybrid.c:63
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
union hlsl_type::@231 e
struct hlsl_type * type
enum hlsl_base_type base_type
struct list * elements
Definition: _list.h:228
static int compare_param_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:1749
struct hlsl_type::@231::@232 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 1010 of file utils.c.

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

Referenced by yyparse().

◆ compilation_message()

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

Definition at line 722 of file utils.c.

723 {
724  char* buffer;
725  int rc, size;
726 
727  if (msg->capacity == 0)
728  {
730  if (msg->string == NULL)
731  {
732  ERR("Error allocating memory for parser messages\n");
733  return;
734  }
735  msg->capacity = MESSAGEBUFFER_INITIAL_SIZE;
736  }
737 
738  while (1)
739  {
740  rc = vsnprintf(msg->string + msg->size,
741  msg->capacity - msg->size, fmt, args);
742 
743  if (rc < 0 || rc >= msg->capacity - msg->size)
744  {
745  size = msg->capacity * 2;
746  buffer = d3dcompiler_realloc(msg->string, size);
747  if (buffer == NULL)
748  {
749  ERR("Error reallocating memory for parser messages\n");
750  return;
751  }
752  msg->string = buffer;
753  msg->capacity = size;
754  }
755  else
756  {
757  TRACE("%s", msg->string + msg->size);
758  msg->size += rc;
759  return;
760  }
761  }
762 }
#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 860 of file utils.c.

861 {
862  unsigned int count = 0;
863  struct hlsl_struct_field *field;
864 
865  if (type->type <= HLSL_CLASS_LAST_NUMERIC)
866  {
867  return type->dimx * type->dimy;
868  }
869  if (type->type == HLSL_CLASS_ARRAY)
870  {
871  return components_count_type(type->e.array.type) * type->e.array.elements_count;
872  }
873  if (type->type != HLSL_CLASS_STRUCT)
874  {
875  ERR("Unexpected data type %s.\n", debug_hlsl_type(type));
876  return 0;
877  }
878 
879  LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
880  {
882  }
883  return count;
884 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
uint8_t entry
Definition: isohybrid.c:63
const char * debug_hlsl_type(const struct hlsl_type *type)
Definition: utils.c:1866
unsigned int components_count_type(struct hlsl_type *type)
Definition: utils.c:860
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
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by compatible_data_types(), components_count_expr_list(), 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 1005 of file utils.c.

1006 {
1007  return type->type != HLSL_CLASS_OBJECT;
1008 }
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 1838 of file utils.c.

1839 {
1840  const char *name = "(unknown)";
1841 
1842  switch (type->base_type)
1843  {
1844  case HLSL_TYPE_FLOAT: name = "float"; break;
1845  case HLSL_TYPE_HALF: name = "half"; break;
1846  case HLSL_TYPE_DOUBLE: name = "double"; break;
1847  case HLSL_TYPE_INT: name = "int"; break;
1848  case HLSL_TYPE_UINT: name = "uint"; break;
1849  case HLSL_TYPE_BOOL: name = "bool"; break;
1850  case HLSL_TYPE_SAMPLER:
1851  switch (type->sampler_dim)
1852  {
1853  case HLSL_SAMPLER_DIM_GENERIC: name = "sampler"; break;
1854  case HLSL_SAMPLER_DIM_1D: name = "sampler1D"; break;
1855  case HLSL_SAMPLER_DIM_2D: name = "sampler2D"; break;
1856  case HLSL_SAMPLER_DIM_3D: name = "sampler3D"; break;
1857  case HLSL_SAMPLER_DIM_CUBE: name = "samplerCUBE"; break;
1858  }
1859  break;
1860  default:
1861  FIXME("Unhandled case %u\n", type->base_type);
1862  }
1863  return name;
1864 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: name.c:36
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 109 of file utils.c.

110 {
111  switch(part)
112  {
125  default:
126  FIXME("Unrecognized D3D_BLOB_PART %#x\n", part);
127  return "unrecognized";
128  }
129 }
#define WINE_D3DCOMPILER_TO_STR(x)
Definition: utils.c:33
#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 35 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 53 of file utils.c.

54 {
55  switch (t)
56  {
103  default:
104  FIXME("Unrecognized D3D_SHADER_VARIABLE_TYPE %#x.\n", t);
105  return "unrecognized";
106  }
107 }
GLdouble GLdouble t
Definition: gl.h:2047
#define WINE_D3DCOMPILER_TO_STR(x)
Definition: utils.c:33
#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 2226 of file utils.c.

2227 {
2228  switch (instr->type)
2229  {
2230  case HLSL_IR_EXPR:
2232  break;
2233  case HLSL_IR_DEREF:
2235  break;
2236  case HLSL_IR_CONSTANT:
2238  break;
2239  case HLSL_IR_ASSIGNMENT:
2241  break;
2242  case HLSL_IR_SWIZZLE:
2244  break;
2245  case HLSL_IR_CONSTRUCTOR:
2247  break;
2248  case HLSL_IR_JUMP:
2250  break;
2251  case HLSL_IR_IF:
2253  break;
2254  default:
2255  TRACE("<No dump function for %s>", debug_node_type(instr->type));
2256  }
2257 }
static void debug_dump_ir_swizzle(const struct hlsl_ir_swizzle *swizzle)
Definition: utils.c:2169
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:2158
static const char * debug_node_type(enum hlsl_ir_node_type type)
Definition: utils.c:1930
#define TRACE(s)
Definition: solgame.cpp:4
static void debug_dump_ir_deref(const struct hlsl_ir_deref *deref)
Definition: utils.c:1973
static void debug_dump_ir_jump(const struct hlsl_ir_jump *jump)
Definition: utils.c:2189
static void debug_dump_ir_constructor(const struct hlsl_ir_constructor *constructor)
Definition: utils.c:2126
static void debug_dump_ir_constant(const struct hlsl_ir_constant *constant)
Definition: utils.c:1995
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:2211
static void debug_dump_ir_expr(const struct hlsl_ir_expr *expr)
Definition: utils.c:2113

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 1953 of file utils.c.

1954 {
1955  struct hlsl_ir_node *instr;
1956 
1958  {
1960  TRACE("\n");
1961  }
1962 }
struct x86_inst instr
uint8_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
Definition: _list.h:228
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2226

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 2158 of file utils.c.

2159 {
2160  TRACE("= (");
2161  debug_dump_instr(assign->lhs);
2162  if (assign->writemask != BWRITERSP_WRITEMASK_ALL)
2163  TRACE("%s", debug_writemask(assign->writemask));
2164  TRACE(" ");
2165  debug_dump_instr(assign->rhs);
2166  TRACE(")");
2167 }
#define BWRITERSP_WRITEMASK_ALL
static const char * debug_writemask(DWORD writemask)
Definition: utils.c:2139
#define TRACE(s)
Definition: solgame.cpp:4
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2226
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 1995 of file utils.c.

1996 {
1997  struct hlsl_type *type = constant->node.data_type;
1998  unsigned int x, y;
1999 
2000  if (type->dimy != 1)
2001  TRACE("{");
2002  for (y = 0; y < type->dimy; ++y)
2003  {
2004  if (type->dimx != 1)
2005  TRACE("{");
2006  for (x = 0; x < type->dimx; ++x)
2007  {
2008  switch (type->base_type)
2009  {
2010  case HLSL_TYPE_FLOAT:
2011  TRACE("%g ", (double)constant->v.value.f[y * type->dimx + x]);
2012  break;
2013  case HLSL_TYPE_DOUBLE:
2014  TRACE("%g ", constant->v.value.d[y * type->dimx + x]);
2015  break;
2016  case HLSL_TYPE_INT:
2017  TRACE("%d ", constant->v.value.i[y * type->dimx + x]);
2018  break;
2019  case HLSL_TYPE_UINT:
2020  TRACE("%u ", constant->v.value.u[y * type->dimx + x]);
2021  break;
2022  case HLSL_TYPE_BOOL:
2023  TRACE("%s ", constant->v.value.b[y * type->dimx + x] == FALSE ? "false" : "true");
2024  break;
2025  default:
2026  TRACE("Constants of type %s not supported\n", debug_base_type(type));
2027  }
2028  }
2029  if (type->dimx != 1)
2030  TRACE("}");
2031  }
2032  if (type->dimy != 1)
2033  TRACE("}");
2034 }
union constant::@229 value[4]
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:1838
#define TRACE(s)
Definition: solgame.cpp: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 2126 of file utils.c.

2127 {
2128  struct hlsl_ir_node *arg;
2129 
2130  TRACE("%s (", debug_hlsl_type(constructor->node.data_type));
2131  LIST_FOR_EACH_ENTRY(arg, constructor->arguments, struct hlsl_ir_node, entry)
2132  {
2134  TRACE(" ");
2135  }
2136  TRACE(")");
2137 }
uint8_t entry
Definition: isohybrid.c:63
const char * debug_hlsl_type(const struct hlsl_type *type)
Definition: utils.c:1866
void * arg
Definition: msvc.h:12
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
static void debug_dump_instr(const struct hlsl_ir_node *instr)
Definition: utils.c:2226
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 1973 of file utils.c.

1974 {
1975  switch (deref->type)
1976  {
1977  case HLSL_IR_DEREF_VAR:
1978  TRACE("deref(");
1979  debug_dump_ir_var(deref->v.var);
1980  TRACE(")");
1981  break;
1982  case HLSL_IR_DEREF_ARRAY:
1983  debug_dump_instr(deref->v.array.array);
1984  TRACE("[");
1985  debug_dump_instr(deref->v.array.index);
1986  TRACE("]");
1987  break;
1988  case HLSL_IR_DEREF_RECORD:
1989  debug_dump_instr(deref->v.record.record);
1990  TRACE(".%s", debugstr_a(deref->v.record.field->name));
1991  break;
1992  }
1993 }
union hlsl_ir_deref::@233 v
static void debug_dump_ir_var(const struct hlsl_ir_var *var)
Definition: utils.c:1964
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
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:2226
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 2113 of file utils.c.

2114 {
2115  unsigned int i;
2116 
2117  TRACE("%s (", debug_expr_op(expr));
2118  for (i = 0; i < 3 && expr->operands[i]; ++i)
2119  {
2120  debug_dump_instr(expr->operands[i]);
2121  TRACE(" ");
2122  }
2123  TRACE(")");
2124 }
static const char * debug_expr_op(const struct hlsl_ir_expr *expr)
Definition: utils.c:2036
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:2226

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 2259 of file utils.c.

2260 {
2261  struct hlsl_ir_var *param;
2262 
2263  TRACE("Dumping function %s.\n", debugstr_a(func->func->name));
2264  TRACE("Function parameters:\n");
2265  LIST_FOR_EACH_ENTRY(param, func->parameters, struct hlsl_ir_var, node.entry)
2266  {
2268  TRACE("\n");
2269  }
2270  if (func->semantic)
2271  TRACE("Function semantic: %s\n", debugstr_a(func->semantic));
2272  if (func->body)
2273  {
2274  debug_dump_instr_list(func->body);
2275  }
2276 }
GLenum func
Definition: glext.h:6028
#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:1953
static void debug_dump_ir_var(const struct hlsl_ir_var *var)
Definition: utils.c:1964
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
GLfloat param
Definition: glext.h:5796
Definition: dlist.c:348

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 2211 of file utils.c.

2212 {
2213  TRACE("if (");
2214  debug_dump_instr(if_node->condition);
2215  TRACE(")\n{\n");
2217  TRACE("}\n");
2218  if (if_node->else_instrs)
2219  {
2220  TRACE("else\n{\n");
2222  TRACE("}\n");
2223  }
2224 }
struct hlsl_ir_node * condition
static void debug_dump_instr_list(const struct list *list)
Definition: utils.c:1953
#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:2226

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 2189 of file utils.c.

2190 {
2191  switch (jump->type)
2192  {
2193  case HLSL_IR_JUMP_BREAK:
2194  TRACE("break");
2195  break;
2196  case HLSL_IR_JUMP_CONTINUE:
2197  TRACE("continue");
2198  break;
2199  case HLSL_IR_JUMP_DISCARD:
2200  TRACE("discard");
2201  break;
2202  case HLSL_IR_JUMP_RETURN:
2203  TRACE("return ");
2204  if (jump->return_value)
2206  TRACE(";");
2207  break;
2208  }
2209 }
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:2226

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 2169 of file utils.c.

2170 {
2171  unsigned int i;
2172 
2173  debug_dump_instr(swizzle->val);
2174  TRACE(".");
2175  if (swizzle->val->data_type->dimy > 1)
2176  {
2177  for (i = 0; i < swizzle->node.data_type->dimx; ++i)
2178  TRACE("_m%u%u", (swizzle->swizzle >> i * 8) & 0xf, (swizzle->swizzle >> (i * 8 + 4)) & 0xf);
2179  }
2180  else
2181  {
2182  static const char c[] = {'x', 'y', 'z', 'w'};
2183 
2184  for (i = 0; i < swizzle->node.data_type->dimx; ++i)
2185  TRACE("%c", c[(swizzle->swizzle >> i * 2) & 0x3]);
2186  }
2187 }
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:2226
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 1964 of file utils.c.

1965 {
1966  if (var->modifiers)
1967  TRACE("%s ", debug_modifiers(var->modifiers));
1968  TRACE("%s %s", debug_hlsl_type(var->node.data_type), var->name);
1969  if (var->semantic)
1970  TRACE(" : %s", debugstr_a(var->semantic));
1971 }
const char * semantic
struct hlsl_ir_node node
const char * debug_hlsl_type(const struct hlsl_type *type)
Definition: utils.c:1866
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned int modifiers
const char * debug_modifiers(DWORD modifiers)
Definition: utils.c:1893
const char * name

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 2036 of file utils.c.

2037 {
2038  static const char * const op_names[] =
2039  {
2040  "~",
2041  "!",
2042  "-",
2043  "abs",
2044  "sign",
2045  "rcp",
2046  "rsq",
2047  "sqrt",
2048  "nrm",
2049  "exp2",
2050  "log2",
2051 
2052  "cast",
2053 
2054  "fract",
2055 
2056  "sin",
2057  "cos",
2058  "sin_reduced",
2059  "cos_reduced",
2060 
2061  "dsx",
2062  "dsy",
2063 
2064  "sat",
2065 
2066  "pre++",
2067  "pre--",
2068  "post++",
2069  "post--",
2070 
2071  "+",
2072  "-",
2073  "*",
2074  "/",
2075 
2076  "%",
2077 
2078  "<",
2079  ">",
2080  "<=",
2081  ">=",
2082  "==",
2083  "!=",
2084 
2085  "&&",
2086  "||",
2087 
2088  "<<",
2089  ">>",
2090  "&",
2091  "|",
2092  "^",
2093 
2094  "dot",
2095  "crs",
2096  "min",
2097  "max",
2098 
2099  "pow",
2100 
2101  "lerp",
2102 
2103  ",",
2104  };
2105 
2106  if (expr->op == HLSL_IR_UNOP_CAST)
2107  return debug_hlsl_type(expr->node.data_type);
2108 
2109  return op_names[expr->op];
2110 }
const char * debug_hlsl_type(const struct hlsl_type *type)
Definition: utils.c:1866
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 1866 of file utils.c.

1867 {
1868  const char *name;
1869 
1870  if (type->name)
1871  return debugstr_a(type->name);
1872 
1873  if (type->type == HLSL_CLASS_STRUCT)
1874  return "<anonymous struct>";
1875 
1876  if (type->type == HLSL_CLASS_ARRAY)
1877  {
1878  name = debug_base_type(type->e.array.type);
1879  return wine_dbg_sprintf("%s[%u]", name, type->e.array.elements_count);
1880  }
1881 
1883 
1884  if (type->type == HLSL_CLASS_SCALAR)
1885  return wine_dbg_sprintf("%s", name);
1886  if (type->type == HLSL_CLASS_VECTOR)
1887  return wine_dbg_sprintf("%s%u", name, type->dimx);
1888  if (type->type == HLSL_CLASS_MATRIX)
1889  return wine_dbg_sprintf("%s%ux%u", name, type->dimx, type->dimy);
1890  return "unexpected_type";
1891 }
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:1838
#define debugstr_a
Definition: kernel32.h:31
Definition: name.c:36
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 1893 of file utils.c.

1894 {
1895  char string[110];
1896 
1897  string[0] = 0;
1899  strcat(string, " extern"); /* 7 */
1901  strcat(string, " nointerpolation"); /* 16 */
1903  strcat(string, " precise"); /* 8 */
1905  strcat(string, " shared"); /* 7 */
1907  strcat(string, " groupshared"); /* 12 */
1909  strcat(string, " static"); /* 7 */
1911  strcat(string, " uniform"); /* 8 */
1913  strcat(string, " volatile"); /* 9 */
1915  strcat(string, " const"); /* 6 */
1917  strcat(string, " row_major"); /* 10 */
1919  strcat(string, " column_major"); /* 13 */
1921  strcat(string, " inout"); /* 6 */
1922  else if (modifiers & HLSL_MODIFIER_IN)
1923  strcat(string, " in"); /* 3 */
1924  else if (modifiers & HLSL_MODIFIER_OUT)
1925  strcat(string, " out"); /* 4 */
1926 
1927  return wine_dbg_sprintf("%s", string[0] ? string + 1 : "");
1928 }
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 1930 of file utils.c.

1931 {
1932  static const char * const names[] =
1933  {
1934  "HLSL_IR_VAR",
1935  "HLSL_IR_ASSIGNMENT",
1936  "HLSL_IR_CONSTANT",
1937  "HLSL_IR_CONSTRUCTOR",
1938  "HLSL_IR_DEREF",
1939  "HLSL_IR_EXPR",
1940  "HLSL_IR_FUNCTION_DECL",
1941  "HLSL_IR_IF",
1942  "HLSL_IR_JUMP",
1943  "HLSL_IR_SWIZZLE",
1944  };
1945 
1946  if (type >= ARRAY_SIZE(names))
1947  return "Unexpected node type";
1948  return names[type];
1949 }
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 404 of file utils.c.

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

Referenced by asmparser_instr().

◆ debug_print_dstmod()

const char* debug_print_dstmod ( DWORD  mod)

Definition at line 156 of file utils.c.

157 {
158  switch (mod)
159  {
160  case 0:
161  return "";
163  return "_sat";
165  return "_pp";
167  return "_centroid";
169  return "_sat_pp";
171  return "_sat_centroid";
173  return "_pp_centroid";
175  return "_sat_pp_centroid";
176  default:
177  return "Unexpected modifier\n";
178  }
179 }
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 333 of file utils.c.

334 {
335  return wine_dbg_sprintf("%s%s%s", get_regname(reg),
337  debug_print_writemask(reg->u.writemask));
338 }
static const char * debug_print_relarg(const struct shader_reg *reg)
Definition: utils.c:318
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static const char * debug_print_writemask(DWORD mask)
Definition: utils.c:261
static const char * get_regname(const struct shader_reg *reg)
Definition: utils.c:205
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 419 of file utils.c.

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

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 318 of file utils.c.

319 {
320  const char *short_swizzle;
321  if (!reg->rel_reg) return "";
322 
323  short_swizzle = debug_print_swizzle(reg->rel_reg->u.swizzle);
324 
325  if (reg->rel_reg->type == BWRITERSPR_ADDR)
326  return wine_dbg_sprintf("[a%u%s]", reg->rel_reg->regnum, short_swizzle);
327  else if(reg->rel_reg->type == BWRITERSPR_LOOP && reg->rel_reg->regnum == 0)
328  return wine_dbg_sprintf("[aL%s]", short_swizzle);
329  else
330  return "Unexpected relative addressing argument";
331 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static const char * debug_print_swizzle(DWORD arg)
Definition: utils.c:277
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 181 of file utils.c.

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

Referenced by asmparser_instr().

◆ debug_print_srcmod()

const char* debug_print_srcmod ( DWORD  mod)

Definition at line 131 of file utils.c.

132 {
133  switch (mod)
134  {
148  default:
149  FIXME("Unrecognized source modifier %#x.\n", mod);
150  return "unrecognized_src_mod";
151  }
152 }
#define WINE_D3DCOMPILER_TO_STR(x)
Definition: utils.c:33
#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 340 of file utils.c.

341 {
342  switch (reg->srcmod)
343  {
344  case BWRITERSPSM_NONE:
345  return wine_dbg_sprintf("%s%s%s", get_regname(reg),
347  debug_print_swizzle(reg->u.swizzle));
348  case BWRITERSPSM_NEG:
349  return wine_dbg_sprintf("-%s%s%s", get_regname(reg),
351  debug_print_swizzle(reg->u.swizzle));
352  case BWRITERSPSM_BIAS:
353  return wine_dbg_sprintf("%s%s_bias%s", get_regname(reg),
355  debug_print_swizzle(reg->u.swizzle));
356  case BWRITERSPSM_BIASNEG:
357  return wine_dbg_sprintf("-%s%s_bias%s", get_regname(reg),
359  debug_print_swizzle(reg->u.swizzle));
360  case BWRITERSPSM_SIGN:
361  return wine_dbg_sprintf("%s%s_bx2%s", get_regname(reg),
363  debug_print_swizzle(reg->u.swizzle));
364  case BWRITERSPSM_SIGNNEG:
365  return wine_dbg_sprintf("-%s%s_bx2%s", get_regname(reg),
367  debug_print_swizzle(reg->u.swizzle));
368  case BWRITERSPSM_COMP:
369  return wine_dbg_sprintf("1 - %s%s%s", get_regname(reg),
371  debug_print_swizzle(reg->u.swizzle));
372  case BWRITERSPSM_X2:
373  return wine_dbg_sprintf("%s%s_x2%s", get_regname(reg),
375  debug_print_swizzle(reg->u.swizzle));
376  case BWRITERSPSM_X2NEG:
377  return wine_dbg_sprintf("-%s%s_x2%s", get_regname(reg),
379  debug_print_swizzle(reg->u.swizzle));
380  case BWRITERSPSM_DZ:
381  return wine_dbg_sprintf("%s%s_dz%s", get_regname(reg),
383  debug_print_swizzle(reg->u.swizzle));
384  case BWRITERSPSM_DW:
385  return wine_dbg_sprintf("%s%s_dw%s", get_regname(reg),
387  debug_print_swizzle(reg->u.swizzle));
388  case BWRITERSPSM_ABS:
389  return wine_dbg_sprintf("%s%s_abs%s", get_regname(reg),
391  debug_print_swizzle(reg->u.swizzle));
392  case BWRITERSPSM_ABSNEG:
393  return wine_dbg_sprintf("-%s%s_abs%s", get_regname(reg),
395  debug_print_swizzle(reg->u.swizzle));
396  case BWRITERSPSM_NOT:
397  return wine_dbg_sprintf("!%s%s%s", get_regname(reg),
399  debug_print_swizzle(reg->u.swizzle));
400  }
401  return "Unknown modifier";
402 }
static const char * debug_print_relarg(const struct shader_reg *reg)
Definition: utils.c:318
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static const char * debug_print_swizzle(DWORD arg)
Definition: utils.c:277
static const char * get_regname(const struct shader_reg *reg)
Definition: utils.c:205
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 277 of file utils.c.

278 {
279  char ret[6];
280  unsigned int i;
281  DWORD swizzle[4];
282 
283  switch (arg)
284  {
285  case BWRITERVS_NOSWIZZLE:
286  return "";
287  case BWRITERVS_SWIZZLE_X:
288  return ".x";
289  case BWRITERVS_SWIZZLE_Y:
290  return ".y";
291  case BWRITERVS_SWIZZLE_Z:
292  return ".z";
293  case BWRITERVS_SWIZZLE_W:
294  return ".w";
295  }
296 
297  swizzle[0] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 0)) & 0x03;
298  swizzle[1] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 2)) & 0x03;
299  swizzle[2] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 4)) & 0x03;
300  swizzle[3] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 6)) & 0x03;
301 
302  ret[0] = '.';
303  for (i = 0; i < 4; ++i)
304  {
305  switch (swizzle[i])
306  {
307  case 0: ret[1 + i] = 'x'; break;
308  case 1: ret[1 + i] = 'y'; break;
309  case 2: ret[1 + i] = 'z'; break;
310  case 3: ret[1 + i] = 'w'; break;
311  }
312  }
313  ret[5] = '\0';
314 
315  return wine_dbg_sprintf("%s", ret);
316 }
#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 261 of file utils.c.

262 {
263  char ret[6];
264  unsigned char pos = 1;
265 
266  if(mask == BWRITERSP_WRITEMASK_ALL) return "";
267  ret[0] = '.';
268  if(mask & BWRITERSP_WRITEMASK_0) ret[pos++] = 'x';
269  if(mask & BWRITERSP_WRITEMASK_1) ret[pos++] = 'y';
270  if(mask & BWRITERSP_WRITEMASK_2) ret[pos++] = 'z';
271  if(mask & BWRITERSP_WRITEMASK_3) ret[pos++] = 'w';
272  ret[pos] = 0;
273 
274  return wine_dbg_sprintf("%s", ret);
275 }
#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 2139 of file utils.c.

2140 {
2141  static const char components[] = {'x', 'y', 'z', 'w'};
2142  char string[5];
2143  unsigned int i = 0, pos = 0;
2144 
2145  assert(!(writemask & ~BWRITERSP_WRITEMASK_ALL));
2146 
2147  while (writemask)
2148  {
2149  if (writemask & 1)
2150  string[pos++] = components[i];
2151  writemask >>= 1;
2152  i++;
2153  }
2154  string[pos] = '\0';
2155  return wine_dbg_sprintf(".%s", string);
2156 }
#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 532 of file utils.c.

533 {
534  TRACE("dxbc %p, tag %s, size %#x.\n", dxbc, debugstr_an((const char *)&tag, 4), data_size);
535 
536  if (dxbc->count >= dxbc->size)
537  {
538  struct dxbc_section *new_sections;
539  DWORD new_size = dxbc->size << 1;
540 
541  new_sections = HeapReAlloc(GetProcessHeap(), 0, dxbc->sections, new_size * sizeof(*dxbc->sections));
542  if (!new_sections)
543  {
544  ERR("Failed to allocate dxbc section memory\n");
545  return E_OUTOFMEMORY;
546  }
547 
548  dxbc->sections = new_sections;
549  dxbc->size = new_size;
550  }
551 
552  dxbc->sections[dxbc->count].tag = tag;
553  dxbc->sections[dxbc->count].data_size = data_size;
554  dxbc->sections[dxbc->count].data = data;
555  ++dxbc->count;
556 
557  return S_OK;
558 }
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:395
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:393
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 651 of file utils.c.

652 {
653  TRACE("dxbc %p.\n", dxbc);
654 
656 }
struct dxbc_section * sections
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394

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 560 of file utils.c.

561 {
562  TRACE("dxbc %p, size %u.\n", dxbc, size);
563 
564  /* use a good starting value for the size if none specified */
565  if (!size) size = 2;
566 
567  dxbc->sections = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*dxbc->sections));
568  if (!dxbc->sections)
569  {
570  ERR("Failed to allocate dxbc section memory\n");
571  return E_OUTOFMEMORY;
572  }
573 
574  dxbc->size = size;
575  dxbc->count = 0;
576 
577  return S_OK;
578 }
#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:395
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 580 of file utils.c.

581 {
582  const char *ptr = data;
583  HRESULT hr;
584  unsigned int i;
585  DWORD tag, total_size, chunk_count;
586 
587  if (!data)
588  {
589  WARN("No data supplied.\n");
590  return E_FAIL;
591  }
592 
593  read_dword(&ptr, &tag);
594  TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
595 
596  if (tag != TAG_DXBC)
597  {
598  WARN("Wrong tag.\n");
599  return E_FAIL;
600  }
601 
602  /* checksum? */
603  skip_dword_unknown(&ptr, 4);
604 
605  skip_dword_unknown(&ptr, 1);
606 
607  read_dword(&ptr, &total_size);
608  TRACE("total size: %#x\n", total_size);
609 
610  if (data_size != total_size)
611  {
612  WARN("Wrong size supplied.\n");
613  return D3DERR_INVALIDCALL;
614  }
615 
616  read_dword(&ptr, &chunk_count);
617  TRACE("chunk count: %#x\n", chunk_count);
618 
619  hr = dxbc_init(dxbc, chunk_count);
620  if (FAILED(hr))
621  {
622  WARN("Failed to init dxbc\n");
623  return hr;
624  }
625 
626  for (i = 0; i < chunk_count; ++i)
627  {
628  DWORD chunk_tag, chunk_size;
629  const char *chunk_ptr;
630  DWORD chunk_offset;
631 
632  read_dword(&ptr, &chunk_offset);
633  TRACE("chunk %u at offset %#x\n", i, chunk_offset);
634 
635  chunk_ptr = data + chunk_offset;
636 
637  read_dword(&chunk_ptr, &chunk_tag);
638  read_dword(&chunk_ptr, &chunk_size);
639 
640  hr = dxbc_add_section(dxbc, chunk_tag, chunk_ptr, chunk_size);
641  if (FAILED(hr))
642  {
643  WARN("Failed to add section to dxbc\n");
644  return hr;
645  }
646  }
647 
648  return hr;
649 }
void skip_dword_unknown(const char **ptr, unsigned int count)
Definition: utils.c:513
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:560
#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:77
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:532
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 658 of file utils.c.

659 {
660  DWORD size = 32, offset = size + 4 * dxbc->count;
661  ID3DBlob *object;
662  HRESULT hr;
663  char *ptr;
664  unsigned int i;
665 
666  TRACE("dxbc %p, blob %p.\n", dxbc, blob);
667 
668  for (i = 0; i < dxbc->count; ++i)
669  {
670  size += 12 + dxbc->sections[i].data_size;
671  }
672 
673  hr = D3DCreateBlob(size, &object);
674  if (FAILED(hr))
675  {
676  WARN("Failed to create blob\n");
677  return hr;
678  }
679 
680  ptr = ID3D10Blob_GetBufferPointer(object);
681 
683 
684  /* signature(?) */
689 
690  /* seems to be always 1 */
692 
693  /* DXBC size */
694  write_dword(&ptr, size);
695 
696  /* chunk count */
698 
699  /* write the chunk offsets */
700  for (i = 0; i < dxbc->count; ++i)
701  {
703  offset += 8 + dxbc->sections[i].data_size;
704  }
705 
706  /* write the chunks */
707  for (i = 0; i < dxbc->count; ++i)
708  {
709  write_dword(&ptr, dxbc->sections[i].tag);
710  write_dword(&ptr, dxbc->sections[i].data_size);
711  memcpy(ptr, dxbc->sections[i].data, dxbc->sections[i].data_size);
712  ptr += dxbc->sections[i].data_size;
713  }
714 
715  TRACE("Created ID3DBlob %p\n", object);
716 
717  *blob = object;
718 
719  return S_OK;
720 }
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:77
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
Definition: blob.c:136
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
static void write_dword_unknown(char **ptr, DWORD d)
Definition: utils.c:526
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 1155 of file utils.c.

1156 {
1157  static const enum hlsl_base_type types[] =
1158  {
1160  HLSL_TYPE_INT,
1165  };
1166  int t1_idx = -1, t2_idx = -1, i;
1167 
1168  for (i = 0; i < ARRAY_SIZE(types); ++i)
1169  {
1170  /* Always convert away from HLSL_TYPE_HALF */
1171  if (t1 == types[i])
1172  t1_idx = t1 == HLSL_TYPE_HALF ? i + 1 : i;
1173  if (t2 == types[i])
1174  t2_idx = t2 == HLSL_TYPE_HALF ? i + 1 : i;
1175 
1176  if (t1_idx != -1 && t2_idx != -1)
1177  break;
1178  }
1179  if (t1_idx == -1 || t2_idx == -1)
1180  {
1181  FIXME("Unexpected base type.\n");
1182  return HLSL_TYPE_FLOAT;
1183  }
1184  return t1_idx >= t2_idx ? t1 : t2;
1185 }
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 1187 of file utils.c.

1189 {
1190  enum hlsl_type_class type;
1191  enum hlsl_base_type base;
1192  unsigned int dimx, dimy;
1193 
1195  {
1196  hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR,
1197  "non scalar/vector/matrix data type in expression");
1198  return NULL;
1199  }
1200 
1201  if (compare_hlsl_types(t1, t2))
1202  return t1;
1203 
1204  if (!expr_compatible_data_types(t1, t2))
1205  {
1206  hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR,
1207  "expression data types are incompatible");
1208  return NULL;
1209  }
1210 
1211  if (t1->base_type == t2->base_type)
1212  base = t1->base_type;
1213  else
1215 
1216  if (t1->dimx == 1 && t1->dimy == 1)
1217  {
1218  type = t2->type;
1219  dimx = t2->dimx;
1220  dimy = t2->dimy;
1221  }
1222  else if (t2->dimx == 1 && t2->dimy == 1)
1223  {
1224  type = t1->type;
1225  dimx = t1->dimx;
1226  dimy = t1->dimy;
1227  }
1228  else if (t1->type == HLSL_CLASS_MATRIX && t2->type == HLSL_CLASS_MATRIX)
1229  {
1231  dimx = min(t1->dimx, t2->dimx);
1232  dimy = min(t1->dimy, t2->dimy);
1233  }
1234  else
1235  {
1236  /* Two vectors or a vector and a matrix (matrix must be 1xn or nx1) */
1237  unsigned int max_dim_1, max_dim_2;
1238 
1239  max_dim_1 = max(t1->dimx, t1->dimy);
1240  max_dim_2 = max(t2->dimx, t2->dimy);
1241  if (t1->dimx * t1->dimy == t2->dimx * t2->dimy)
1242  {
1244  dimx = max(t1->dimx, t2->dimx);
1245  dimy = 1;
1246  }
1247  else if (max_dim_1 <= max_dim_2)
1248  {
1249  type = t1->type;
1250  if (type == HLSL_CLASS_VECTOR)
1251  {
1252  dimx = max_dim_1;
1253  dimy = 1;
1254  }
1255  else
1256  {
1257  dimx = t1->dimx;
1258  dimy = t1->dimy;
1259  }
1260  }
1261  else
1262  {
1263  type = t2->type;
1264  if (type == HLSL_CLASS_VECTOR)
1265  {
1266  dimx = max_dim_2;
1267  dimy = 1;
1268  }
1269  else
1270  {
1271  dimx = t2->dimx;
1272  dimy = t2->dimy;
1273  }
1274  }
1275  }
1276 
1277  return new_hlsl_type(NULL, type, base, dimx, dimy);
1278 }
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:1121
hlsl_base_type
enum hlsl_type_class type
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void 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:1155
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: utils.c:886
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:809
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 1121 of file utils.c.

1122 {
1124  return FALSE;
1125 
1126  /* Scalar vars can be converted to pretty much everything */
1127  if ((t1->dimx == 1 && t1->dimy == 1) || (t2->dimx == 1 && t2->dimy == 1))
1128  return TRUE;
1129 
1130  if (t1->type == HLSL_CLASS_VECTOR && t2->type == HLSL_CLASS_VECTOR)
1131  return TRUE;
1132 
1133  if (t1->type == HLSL_CLASS_MATRIX || t2->type == HLSL_CLASS_MATRIX)
1134  {
1135  /* Matrix-vector conversion is apparently allowed if either they have the same components
1136  count or the matrix is nx1 or 1xn */
1137  if (t1->type == HLSL_CLASS_VECTOR || t2->type == HLSL_CLASS_VECTOR)
1138  {
1140  return TRUE;
1141 
1142  return (t1->type == HLSL_CLASS_MATRIX && (t1->dimx == 1 || t1->dimy == 1))
1143  || (t2->type == HLSL_CLASS_MATRIX && (t2->dimx == 1 || t2->dimy == 1));
1144  }
1145 
1146  /* Both matrices */
1147  if ((t1->dimx >= t2->dimx && t1->dimy >= t2->dimy)
1148  || (t1->dimx <= t2->dimx && t1->dimy <= t2->dimy))
1149  return TRUE;
1150  }
1151 
1152  return FALSE;
1153 }
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:860
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 855 of file utils.c.

856 {
857  return wine_rb_get(&hlsl_ctx.functions, name) != NULL;
858 }
smooth NULL
Definition: ftsmooth.c:416
struct hlsl_parse_ctx hlsl_ctx
Definition: hlsl.tab.c:87
Definition: name.c:36
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(), and while().

◆ free_declaration()

void free_declaration ( struct hlsl_ir_var decl)

Definition at line 801 of file utils.c.

802 {
803  d3dcompiler_free((void *)decl->name);
804  d3dcompiler_free((void *)decl->semantic);
805  d3dcompiler_free((void *)decl->reg_reservation);
806  d3dcompiler_free(decl);
807 }
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 2444 of file utils.c.

2445 {
2447  d3dcompiler_free((void *)func->name);
2449 }
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:2439

Referenced by free_function_rb().

◆ free_function_decl()

static void free_function_decl ( struct hlsl_ir_function_decl decl)
static

Definition at line 2431 of file utils.c.

2432 {
2433  d3dcompiler_free((void *)decl->semantic);
2435  free_instr_list(decl->body);
2436  d3dcompiler_free(decl);
2437 }
void free_instr_list(struct list *list)
Definition: utils.c:2295
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 2439 of file utils.c.

2440 {
2442 }
uint8_t entry
Definition: isohybrid.c:63
static void free_function_decl(struct hlsl_ir_function_decl *decl)
Definition: utils.c:2431
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31

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 2451 of file utils.c.

2452 {
2454 }
static void free_function(struct hlsl_ir_function *func)
Definition: utils.c:2444
uint8_t entry
Definition: isohybrid.c:63
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31

Referenced by parse_hlsl().

◆ free_hlsl_type()

void free_hlsl_type ( struct hlsl_type type)

Definition at line 2278 of file utils.c.

2279 {
2280  struct hlsl_struct_field *field, *next_field;
2281 
2282  d3dcompiler_free((void *)type->name);
2283  if (type->type == HLSL_CLASS_STRUCT)
2284  {
2285  LIST_FOR_EACH_ENTRY_SAFE(field, next_field, type->e.elements, struct hlsl_struct_field, entry)
2286  {
2287  d3dcompiler_free((void *)field->name);
2288  d3dcompiler_free((void *)field->semantic);
2290  }
2291  }
2293 }
uint8_t entry
Definition: isohybrid.c:63
static BOOL d3dcompiler_free(void *ptr)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: parser.c:43
#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 2395 of file utils.c.

2396 {
2397  switch (node->type)
2398  {
2399  case HLSL_IR_VAR:
2400  /* These are freed later on from the scopes. */
2401  break;
2402  case HLSL_IR_CONSTANT:
2404  break;
2405  case HLSL_IR_DEREF:
2407  break;
2408  case HLSL_IR_SWIZZLE:
2410  break;
2411  case HLSL_IR_CONSTRUCTOR:
2413  break;
2414  case HLSL_IR_EXPR:
2416  break;
2417  case HLSL_IR_ASSIGNMENT:
2419  break;
2420  case HLSL_IR_IF:
2422  break;
2423  case HLSL_IR_JUMP:
2425  break;
2426  default:
2427  FIXME("Unsupported node type %s\n", debug_node_type(node->type));
2428  }
2429 }
static void free_ir_expr(struct hlsl_ir_expr *expr)
Definition: utils.c:2359
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:2388
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:2329
#define FIXME(fmt,...)
Definition: debug.h:110
static void free_ir_assignment(struct hlsl_ir_assignment *assignment)
Definition: utils.c:2373
static void free_ir_constant(struct hlsl_ir_constant *constant)
Definition: utils.c:2306
static const char * debug_node_type(enum hlsl_ir_node_type type)
Definition: utils.c:1930
static void free_ir_if(struct hlsl_ir_if *if_node)
Definition: utils.c:2380
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:2347
static void free_ir_constructor(struct hlsl_ir_constructor *constructor)
Definition: utils.c:2353
Definition: dlist.c:348

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

◆ free_instr_list()

void free_instr_list ( struct list list)

Definition at line 2295 of file utils.c.

2296 {
2297  struct hlsl_ir_node *node, *next_node;
2298 
2299  if (!list)
2300  return;
2302  free_instr(node);
2304 }
uint8_t entry
Definition: isohybrid.c:63
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:2395
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(), declare_vars(), free_function_decl(), free_ir_constructor(), free_ir_expr(), free_ir_if(), gen_struct_fields(), and struct_var_initializer().

◆ free_ir_assignment()

static void free_ir_assignment ( struct hlsl_ir_assignment assignment)
static

Definition at line 2373 of file utils.c.

2374 {
2375  free_instr(assignment->lhs);
2376  free_instr(assignment->rhs);
2377  d3dcompiler_free(assignment);
2378 }
static BOOL d3dcompiler_free(void *ptr)
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2395
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 2306 of file utils.c.

2307 {
2308  struct hlsl_type *type = constant->node.data_type;
2309  unsigned int i;
2310  struct hlsl_ir_constant *field, *next_field;
2311 
2312  switch (type->type)
2313  {
2314  case HLSL_CLASS_ARRAY:
2315  for (i = 0; i < type->e.array.elements_count; ++i)
2316  free_ir_constant(&constant->v.array_elements[i]);
2317  d3dcompiler_free(constant->v.array_elements);
2318  break;
2319  case HLSL_CLASS_STRUCT:
2320  LIST_FOR_EACH_ENTRY_SAFE(field, next_field, constant->v.struct_elements, struct hlsl_ir_constant, node.entry)
2322  break;
2323  default:
2324  break;
2325  }
2327 }
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:2306
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 2353 of file utils.c.

2354 {
2355  free_instr_list(constructor->arguments);
2356  d3dcompiler_free(constructor);
2357 }
void free_instr_list(struct list *list)
Definition: utils.c:2295
static BOOL d3dcompiler_free(void *ptr)

Referenced by free_instr().

◆ free_ir_deref()

static void free_ir_deref ( struct hlsl_ir_deref deref)
static

Definition at line 2329 of file utils.c.

2330 {
2331  switch (deref->type)
2332  {
2333  case HLSL_IR_DEREF_VAR:
2334  /* Variables are shared among nodes in the tree. */
2335  break;
2336  case HLSL_IR_DEREF_ARRAY:
2337  free_instr(deref->v.array.array);
2338  free_instr(deref->v.array.index);
2339  break;
2340  case HLSL_IR_DEREF_RECORD:
2341  free_instr(deref->v.record.record);
2342  break;
2343  }
2344  d3dcompiler_free(deref);
2345 }
static BOOL d3dcompiler_free(void *ptr)
union hlsl_ir_deref::@233 v
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2395
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 2359 of file utils.c.

2360 {
2361  unsigned int i;
2362 
2363  for (i = 0; i < 3; ++i)
2364  {
2365  if (!expr->operands[i])
2366  break;
2367  free_instr(expr->operands[i]);
2368  }
2369  free_instr_list(expr->subexpressions);
2371 }
void free_instr_list(struct list *list)
Definition: utils.c:2295
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:2395

Referenced by free_instr().

◆ free_ir_if()

static void free_ir_if ( struct hlsl_ir_if if_node)
static

Definition at line 2380 of file utils.c.

2381 {
2382  free_instr(if_node->condition);
2383  free_instr_list(if_node->then_instrs);
2384  free_instr_list(if_node->else_instrs);
2385  d3dcompiler_free(if_node);
2386 }
void free_instr_list(struct list *list)
Definition: utils.c:2295
static BOOL d3dcompiler_free(void *ptr)
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2395
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 2388 of file utils.c.

2389 {
2390  if (jump->type == HLSL_IR_JUMP_RETURN)
2391  free_instr(jump->return_value);
2392  d3dcompiler_free(jump);
2393 }
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:2395

Referenced by free_instr().

◆ free_ir_swizzle()

static void free_ir_swizzle ( struct hlsl_ir_swizzle swizzle)
static

Definition at line 2347 of file utils.c.

2348 {
2349  free_instr(swizzle->val);
2351 }
static BOOL d3dcompiler_free(void *ptr)
void free_instr(struct hlsl_ir_node *node)
Definition: utils.c:2395
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 205 of file utils.c.

206 {
207  switch (reg->type)
208  {
209  case BWRITERSPR_TEMP:
210  return wine_dbg_sprintf("r%u", reg->regnum);
211  case BWRITERSPR_INPUT:
212  return wine_dbg_sprintf("v%u", reg->regnum);
213  case BWRITERSPR_CONST:
214  return wine_dbg_sprintf("c%u", reg->regnum);
215  case BWRITERSPR_ADDR:
216  return wine_dbg_sprintf("a%u", reg->regnum);
217  case BWRITERSPR_TEXTURE:
218  return wine_dbg_sprintf("t%u", reg->regnum);
219  case BWRITERSPR_RASTOUT:
220  switch (reg->regnum)
221  {
222  case BWRITERSRO_POSITION: return "oPos";
223  case BWRITERSRO_FOG: return "oFog";
224  case BWRITERSRO_POINT_SIZE: return "oPts";
225  default: return "Unexpected RASTOUT";
226  }
227  case BWRITERSPR_ATTROUT:
228  return wine_dbg_sprintf("oD%u", reg->regnum);
230  return wine_dbg_sprintf("oT%u", reg->regnum);
231  case BWRITERSPR_OUTPUT:
232  return wine_dbg_sprintf("o%u", reg->regnum);
233  case BWRITERSPR_CONSTINT:
234  return wine_dbg_sprintf("i%u", reg->regnum);
235  case BWRITERSPR_COLOROUT:
236  return wine_dbg_sprintf("oC%u", reg->regnum);
237  case BWRITERSPR_DEPTHOUT:
238  return "oDepth";
239  case BWRITERSPR_SAMPLER:
240  return wine_dbg_sprintf("s%u", reg->regnum);
242  return wine_dbg_sprintf("b%u", reg->regnum);
243  case BWRITERSPR_LOOP:
244  return "aL";
245  case BWRITERSPR_MISCTYPE:
246  switch (reg->regnum)
247  {
248  case 0: return "vPos";
249  case 1: return "vFace";
250  default: return "unexpected misctype";
251  }
252  case BWRITERSPR_LABEL:
253  return wine_dbg_sprintf("l%u", reg->regnum);
255  return wine_dbg_sprintf("p%u", reg->regnum);
256  default:
257  return wine_dbg_sprintf("unknown regname %#x", reg->type);
258  }
259 }
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 844 of file utils.c.

845 {
846  struct wine_rb_entry *entry = wine_rb_get(&scope->types, name);
847  if (entry)
848  return WINE_RB_ENTRY_VALUE(entry, struct hlsl_type, scope_entry);
849 
850  if (recursive && scope->upper)
851  return get_type(scope->upper, name, recursive);
852  return NULL;
853 }
uint8_t entry
Definition: isohybrid.c:63
struct hlsl_type * get_type(struct hlsl_scope *scope, const char *name, BOOL recursive)
Definition: utils.c:844
smooth NULL
Definition: ftsmooth.c:416
struct hlsl_scope * upper
Definition: d3dcom