30 #define WINE_D3DCOMPILER_TO_STR(x) case x: return #x 45 FIXME(
"Unrecognized D3D_SHADER_VARIABLE_CLASS %#x.\n",
c);
46 return "unrecognized";
101 FIXME(
"Unrecognized D3D_SHADER_VARIABLE_TYPE %#x.\n",
t);
102 return "unrecognized";
123 FIXME(
"Unrecognized D3D_BLOB_PART %#x\n", part);
124 return "unrecognized";
146 FIXME(
"Unrecognized source modifier %#x.\n",
mod);
147 return "unrecognized_src_mod";
151 #undef WINE_D3DCOMPILER_TO_STR 168 return "_sat_centroid";
170 return "_pp_centroid";
172 return "_sat_pp_centroid";
174 return "Unexpected modifier\n";
180 static const char *
const shiftstrings[] =
199 return shiftstrings[
shift];
222 default:
return "Unexpected RASTOUT";
245 case 0:
return "vPos";
246 case 1:
return "vFace";
247 default:
return "unexpected misctype";
261 unsigned char pos = 1;
300 for (
i = 0;
i < 4; ++
i)
304 case 0:
ret[1 +
i] =
'x';
break;
305 case 1:
ret[1 +
i] =
'y';
break;
306 case 2:
ret[1 +
i] =
'z';
break;
307 case 3:
ret[1 +
i] =
'w';
break;
317 const char *short_swizzle;
318 if (!
reg->rel_reg)
return "";
327 return "Unexpected relative addressing argument";
398 return "Unknown modifier";
412 default:
return "_unknown";
506 default:
return "unknown";
515 FIXME(
"Skipping %u unknown DWORDs:\n",
count);
525 FIXME(
"Writing unknown DWORD 0x%08x\n",
d);
541 ERR(
"Failed to allocate dxbc section memory\n");
567 ERR(
"Failed to allocate dxbc section memory\n");
586 WARN(
"No data supplied.\n");
595 WARN(
"Wrong tag.\n");
605 TRACE(
"total size: %#x\n", total_size);
609 WARN(
"Wrong size supplied.\n");
614 TRACE(
"chunk count: %#x\n", chunk_count);
619 WARN(
"Failed to init dxbc\n");
623 for (
i = 0;
i < chunk_count; ++
i)
625 DWORD chunk_tag, chunk_size;
626 const char *chunk_ptr;
630 TRACE(
"chunk %u at offset %#x\n",
i, chunk_offset);
632 chunk_ptr =
data + chunk_offset;
640 WARN(
"Failed to add section to dxbc\n");
673 WARN(
"Failed to create blob\n");
677 ptr = ID3D10Blob_GetBufferPointer(
object);
712 TRACE(
"Created ID3DBlob %p\n",
object);
724 if (
msg->capacity == 0)
729 ERR(
"Error allocating memory for parser messages\n");
740 if (rc < 0 || rc >=
msg->capacity -
msg->size)
746 ERR(
"Error reallocating memory for parser messages\n");
770 if (local_var && scope->
upper->upper == hlsl_ctx.globals)
814 ERR(
"Out of memory\n");
818 type->type = type_class;
837 type->e.array.type = basic_type;
847 if (recursive && scope->
upper)
859 unsigned int count = 0;
903 struct list *t1cur, *t2cur;
908 while (t1cur && t2cur)
923 return t1->
e.
array.elements_count == t2->
e.
array.elements_count
937 ERR(
"Out of memory\n");
959 type->e.array.elements_count = old->
e.
array.elements_count;
963 if (!
type->e.elements)
1015 if (t1->
dimx == 1 && t1->
dimy == 1)
1163 int t1_idx = -1, t2_idx = -1,
i;
1173 if (t1_idx != -1 && t2_idx != -1)
1176 if (t1_idx == -1 || t2_idx == -1)
1178 FIXME(
"Unexpected base type.\n");
1181 return t1_idx >= t2_idx ? t1 : t2;
1194 "non scalar/vector/matrix data type in expression");
1204 "expression data types are incompatible");
1213 if (t1->
dimx == 1 && t1->
dimy == 1)
1219 else if (t2->
dimx == 1 && t2->
dimy == 1)
1234 unsigned int max_dim_1, max_dim_2;
1244 else if (max_dim_1 <= max_dim_2)
1295 ERR(
"Out of memory\n");
1299 expr->node.loc = *loc;
1301 for (
i = 1;
i <= 2; ++
i)
1312 for (
i = 0;
i <= 2; ++
i)
1319 if (operands[
i]->data_type->dimx * operands[
i]->
data_type->dimy != 1
1324 "implicit truncation of vector/matrix type");
1336 expr->operands[0] = operands[0];
1337 expr->operands[1] = operands[1];
1338 expr->operands[2] = operands[2];
1360 ERR(
"Out of memory.\n");
1364 deref->
node.data_type =
var->data_type;
1376 ERR(
"Out of memory.\n");
1416 ERR(
"Out of memory\n");
1420 TRACE(
"Creating proper assignment expression.\n");
1426 unsigned int dimx = 0;
1433 "writemask on a non scalar/vector/matrix type");
1437 bitmask = writemask & ((1 <<
left->data_type->dimx) - 1);
1445 FIXME(
"Assignments with writemasks and matrices on lhs are not supported yet.\n");
1449 type_class =
left->data_type->type;
1456 FIXME(
"Check for casts in the lhs.\n");
1468 "can't implicitly convert %s to %s",
1477 "implicit truncation of vector type");
1488 rhs = converted_rhs;
1499 FIXME(
"LHS expression not supported in compound assignments yet.\n");
1506 TRACE(
"Adding an expression for the compound assignment.\n");
1515 return &assign->
node;
1528 ERR(
"hlsl_type without a name in a scope?\n");
1540 ERR(
"Out of memory!\n");
1543 TRACE(
"Pushing a new scope\n");
1547 ctx->cur_scope = new_scope;
1557 TRACE(
"Popping current scope\n");
1558 ctx->cur_scope = prev_scope;
1569 ERR(
"Out of memory.\n");
1596 struct list *t1cur, *t2cur;
1602 while (t1cur && t2cur)
1614 return t1cur ? 1 : -1;
1619 if (t1->
e.
array.elements_count != t2->
e.
array.elements_count)
1620 return t1->
e.
array.elements_count - t2->
e.
array.elements_count;
1634 struct list *p1cur, *p2cur;
1636 if (params_count != decl_params_count)
1637 return params_count - decl_params_count;
1641 while (p1cur && p2cur)
1669 const char *
name =
"(unknown)";
1671 switch (
type->base_type)
1680 switch (
type->sampler_dim)
1690 FIXME(
"Unhandled case %u\n",
type->base_type);
1703 return "<anonymous struct>";
1719 return "unexpected_type";
1728 strcat(
string,
" extern");
1730 strcat(
string,
" nointerpolation");
1732 strcat(
string,
" precise");
1734 strcat(
string,
" shared");
1736 strcat(
string,
" groupshared");
1738 strcat(
string,
" static");
1740 strcat(
string,
" uniform");
1742 strcat(
string,
" volatile");
1744 strcat(
string,
" const");
1746 strcat(
string,
" row_major");
1748 strcat(
string,
" column_major");
1750 strcat(
string,
" inout");
1761 static const char *
const names[] =
1763 "HLSL_IR_ASSIGNMENT",
1765 "HLSL_IR_CONSTRUCTOR",
1774 return "Unexpected node type";
1802 switch (deref->
type)
1827 if (
type->dimy != 1)
1829 for (
y = 0;
y <
type->dimy; ++
y)
1831 if (
type->dimx != 1)
1833 for (
x = 0;
x <
type->dimx; ++
x)
1835 switch (
type->base_type)
1856 if (
type->dimx != 1)
1859 if (
type->dimy != 1)
1865 static const char *
const op_names[] =
1936 return op_names[
expr->op];
1945 for (
i = 0;
i < 3 &&
expr->operands[
i]; ++
i)
1968 static const char components[] = {
'x',
'y',
'z',
'w'};
1970 unsigned int i = 0,
pos = 0;
2002 if (
swizzle->val->data_type->dimy > 1)
2004 for (
i = 0;
i <
swizzle->node.data_type->dimx; ++
i)
2009 static const char c[] = {
'x',
'y',
'z',
'w'};
2011 for (
i = 0;
i <
swizzle->node.data_type->dimx; ++
i)
2055 switch (
instr->type)
2091 TRACE(
"Function parameters:\n");
2142 for (
i = 0;
i <
type->e.array.elements_count; ++
i)
2158 switch (deref->
type)
2192 for (
i = 0;
i < 3; ++
i)
2194 if (!
expr->operands[
i])
2291 if (intrinsic !=
func->intrinsic)
2295 ERR(
"Redeclaring a user defined function as an intrinsic.\n");
2299 func->intrinsic = intrinsic;
2327 func->intrinsic = intrinsic;
#define BWRITERSP_WRITEMASK_1
struct wine_rb_entry entry
union hlsl_ir_deref::@224 v
static int compare_function_decl_rb(const void *key, const struct wine_rb_entry *entry)
#define BWRITERVS_SWIZZLE_SHIFT
void free_instr_list(struct list *list)
static void free_ir_expr(struct hlsl_ir_expr *expr)
static void debug_dump_ir_swizzle(const struct hlsl_ir_swizzle *swizzle)
static void * d3dcompiler_realloc(void *ptr, SIZE_T size)
static BOOL expr_compatible_data_types(struct hlsl_type *t1, struct hlsl_type *t2)
static void free_function(struct hlsl_ir_function *func)
BOOL compatible_data_types(struct hlsl_type *t1, struct hlsl_type *t2)
static struct hlsl_ir_deref * deref_from_node(const struct hlsl_ir_node *node)
void skip_dword_unknown(const char **ptr, unsigned int count)
const struct reg_reservation * reg_reservation
enum hlsl_type_class type
static static const char __ms_va_list
#define BWRITERSP_WRITEMASK_ALL
coclass MSXML2::XSLTemplate40 object
const char * debug_print_shift(DWORD shift)
char * strcat(char *DstString, const char *SrcString)
static const char * debug_expr_op(const struct hlsl_ir_expr *expr)
static void read_dword(const char **ptr, DWORD *d)
#define HLSL_MODIFIER_CONST
static const char * debug_print_relarg(const struct shader_reg *reg)
GLdouble GLdouble GLdouble r
static struct hlsl_ir_if * if_from_node(const struct hlsl_ir_node *node)
enum hlsl_sampler_dim sampler_dim
GLuint GLuint GLsizei count
enum hlsl_ir_node_type type
static void free_ir_jump(struct hlsl_ir_jump *jump)
static struct hlsl_ir_constructor * constructor_from_node(const struct hlsl_ir_node *node)
struct wine_rb_entry scope_entry
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)
const char * debug_hlsl_type(const struct hlsl_type *type)
static BOOL d3dcompiler_free(void *ptr)
static void write_dword(char **ptr, DWORD d)
struct hlsl_ir_node * return_value
D3D_FL9_3_MAX_TEXTURE_REPEAT enum _D3D_SHADER_VARIABLE_CLASS D3D_SHADER_VARIABLE_CLASS
#define HLSL_MODIFIERS_COMPARISON_MASK
HRESULT dxbc_init(struct dxbc *dxbc, unsigned int size)
enum _D3D_SHADER_VARIABLE_TYPE D3D_SHADER_VARIABLE_TYPE
struct hlsl_ir_node * args[16]
static struct hlsl_ir_expr * expr_from_node(const struct hlsl_ir_node *node)
BOOL find_function(const char *name)
#define D3DERR_INVALIDCALL
unsigned int components_count_type(struct hlsl_type *type)
static void free_function_decl(struct hlsl_ir_function_decl *decl)
GLint GLint GLint GLint GLint x
void add_function_decl(struct wine_rb_tree *funcs, char *name, struct hlsl_ir_function_decl *decl, BOOL intrinsic)
static struct hlsl_type * expr_common_type(struct hlsl_type *t1, struct hlsl_type *t2, struct source_location *loc)
#define HLSL_MODIFIER_PRECISE
const char * debug_d3dcompiler_shader_variable_class(D3D_SHADER_VARIABLE_CLASS c)
const char * debug_print_dstmod(DWORD mod)
#define BWRITERVS_SWIZZLE_Z
struct list scope_entry param_entry
HRESULT dxbc_write_blob(struct dxbc *dxbc, ID3DBlob **blob)
BOOL next_node(stream_t *stream, strbuf_t *buf)
void WINAPIV hlsl_report_message(const char *filename, DWORD line, DWORD column, enum hlsl_error_level level, const char *fmt,...) PRINTF_ATTR(5
#define HLSL_MODIFIER_OUT
static const char * debug_writemask(DWORD writemask)
enum hlsl_ir_jump_type type
static struct hlsl_ir_swizzle * swizzle_from_node(const struct hlsl_ir_node *node)
static void * d3dcompiler_alloc(SIZE_T size)
const char * debug_print_srcreg(const struct shader_reg *reg)
BOOL pop_scope(struct hlsl_parse_ctx *ctx)
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
struct source_location loc
const char * wine_dbg_sprintf(const char *format,...)
struct hlsl_ir_deref * new_var_deref(struct hlsl_ir_var *var)
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
void free_hlsl_type(struct hlsl_type *type)
const char * debug_print_srcmod(DWORD mod)
static struct hlsl_ir_node * new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *op1, struct source_location loc)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
void free_declaration(struct hlsl_ir_var *decl)
HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc)
void free_instr(struct hlsl_ir_node *node)
void init_functions_tree(struct wine_rb_tree *funcs)
GLenum const GLfloat * params
#define HLSL_STORAGE_STATIC
static void free_ir_deref(struct hlsl_ir_deref *deref)
struct hlsl_type * get_type(struct hlsl_scope *scope, const char *name, BOOL recursive)
#define MESSAGEBUFFER_INITIAL_SIZE
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
static BOOL convertible_data_type(struct hlsl_type *type)
#define WINE_D3DCOMPILER_TO_STR(x)
#define HLSL_STORAGE_GROUPSHARED
static void debug_dump_ir_assignment(const struct hlsl_ir_assignment *assign)
#define HLSL_MODIFIER_ROW_MAJOR
struct hlsl_ir_var * get_variable(struct hlsl_scope *scope, const char *name)
static int compare_function_rb(const void *key, const struct wine_rb_entry *entry)
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var)
struct hlsl_type * new_array_type(struct hlsl_type *basic_type, unsigned int array_size)
static void free_ir_assignment(struct hlsl_ir_assignment *assignment)
static int compare_hlsl_types_rb(const void *key, const struct wine_rb_entry *entry)
struct hlsl_ir_node * condition
#define HLSL_STORAGE_SHARED
static const char * debug_base_type(const struct hlsl_type *type)
void free_function_rb(struct wine_rb_entry *entry, void *context)
#define HLSL_STORAGE_EXTERN
struct hlsl_struct_field * field
union constant::@220 value[4]
static void debug_dump_instr_list(const struct list *list)
struct hlsl_scope * upper
static enum hlsl_base_type expr_common_base_type(enum hlsl_base_type t1, enum hlsl_base_type t2)
static void debug_dump_ir_var(const struct hlsl_ir_var *var)
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
struct hlsl_ir_node * operands[3]
static void free_ir_constant(struct hlsl_ir_constant *constant)
struct dxbc_section * sections
static const char * debug_print_writemask(DWORD mask)
static const char * debug_node_type(enum hlsl_ir_node_type type)
struct hlsl_type * return_type
static char * d3dcompiler_strdup(const char *string)
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct hlsl_ir_expr * new_cast(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc)
const char * debug_d3dcompiler_d3d_blob_part(D3D_BLOB_PART part)
void debug_dump_ir_function_decl(const struct hlsl_ir_function_decl *func)
struct hlsl_ir_function_decl * new_func_decl(struct hlsl_type *return_type, struct list *parameters)
#define WINE_RB_ENTRY_VALUE(element, type, field)
struct hlsl_type * data_type
static struct __wine_debug_functions funcs
struct hlsl_type * data_type
static BOOL implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_type *t2)
WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler)
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
enum hlsl_base_type base_type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
static void debug_dump_ir_deref(const struct hlsl_ir_deref *deref)
#define HLSL_STORAGE_UNIFORM
static void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context)
GLenum GLenum GLuint components
#define BWRITERSP_WRITEMASK_3
static __inline const char * debugstr_an(const char *s, int n)
static void debug_dump_ir_jump(const struct hlsl_ir_jump *jump)
static const char * debug_print_swizzle(DWORD arg)
#define BWRITERSP_WRITEMASK_2
struct list * else_instrs
const char * debug_print_dstreg(const struct shader_reg *reg)
#define memcpy(s1, s2, n)
static void debug_dump_ir_constructor(const struct hlsl_ir_constructor *constructor)
#define BWRITERVS_SWIZZLE_X
HRESULT dxbc_add_section(struct dxbc *dxbc, DWORD tag, const char *data, DWORD data_size)
static void debug_dump_ir_constant(const struct hlsl_ir_constant *constant)
static void wine_rb_remove(struct wine_rb_tree *tree, struct wine_rb_entry *entry)
const char * debug_print_opcode(DWORD opcode)
static const char * get_regname(const struct shader_reg *reg)
const char * debug_d3dcompiler_shader_variable_type(D3D_SHADER_VARIABLE_TYPE t)
static int compare_param_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2)
static void free_ir_if(struct hlsl_ir_if *if_node)
#define BWRITERVS_NOSWIZZLE
static struct hlsl_ir_jump * jump_from_node(const struct hlsl_ir_node *node)
enum hlsl_ir_deref_type type
static struct hlsl_ir_node * new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location loc)
void compilation_message(struct compilation_messages *msg, const char *fmt, __ms_va_list args)
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
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
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
#define HLSL_STORAGE_NOINTERPOLATION
static void debug_dump_ir_if(const struct hlsl_ir_if *if_node)
#define HLSL_STORAGE_VOLATILE
struct list * then_instrs
GLint GLint GLint GLint GLint GLint y
static struct hlsl_ir_node * implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc)
static void debug_dump_instr(const struct hlsl_ir_node *instr)
struct hlsl_ir_deref * new_record_deref(struct hlsl_ir_node *record, struct hlsl_struct_field *field)
struct hlsl_type * clone_hlsl_type(struct hlsl_type *old)
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
#define BWRITERSP_WRITEMASK_0
struct hlsl_ir_node * rhs
struct hlsl_ir_expr * new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **operands, struct source_location *loc)
void dxbc_destroy(struct dxbc *dxbc)
struct hlsl_ir_node * lhs
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
int strcmp(const char *String1, const char *String2)
const char * debug_modifiers(DWORD modifiers)
HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
const char * debug_print_comp(DWORD comp)
static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
struct hlsl_ir_node * array
GLuint GLuint GLsizei GLenum type
static void write_dword_unknown(char **ptr, DWORD d)
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)
static void debug_dump_ir_expr(const struct hlsl_ir_expr *expr)
#define BWRITERVS_SWIZZLE_Y
static enum hlsl_ir_expr_op op_from_assignment(enum parse_assign_op op)
struct hlsl_ir_function * func
struct hlsl_ir_node * record
struct hlsl_ir_node * make_assignment(struct hlsl_ir_node *left, enum parse_assign_op assign_op, DWORD writemask, struct hlsl_ir_node *right)
#define HeapFree(x, y, z)
struct wine_rb_tree types
#define BWRITERVS_SWIZZLE_W
struct hlsl_type::@222::@223 array
static void free_ir_constructor(struct hlsl_ir_constructor *constructor)
static void free_function_decl_rb(struct wine_rb_entry *entry, void *context)
#define HLSL_MODIFIER_COLUMN_MAJOR
void push_scope(struct hlsl_parse_ctx *ctx)
GLuint const GLchar * name