vkd3d-shader: Add a hlsl_ namespace prefix to common functions.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura
2021-02-02 16:11:14 -06:00
committed by Alexandre Julliard
parent 0da1401d3d
commit 7c5bd7c776
4 changed files with 308 additions and 299 deletions

File diff suppressed because it is too large Load Diff

View File

@ -206,7 +206,7 @@ struct hlsl_src
#define HLSL_MODIFIERS_MAJORITY_MASK (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR) #define HLSL_MODIFIERS_MAJORITY_MASK (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)
struct reg_reservation struct hlsl_reg_reservation
{ {
enum vkd3d_shader_register_type type; enum vkd3d_shader_register_type type;
DWORD regnum; DWORD regnum;
@ -219,7 +219,7 @@ struct hlsl_ir_var
const char *name; const char *name;
const char *semantic; const char *semantic;
unsigned int modifiers; unsigned int modifiers;
const struct reg_reservation *reg_reservation; const struct hlsl_reg_reservation *reg_reservation;
struct list scope_entry, param_entry; struct list scope_entry, param_entry;
unsigned int first_write, last_read; unsigned int first_write, last_read;
@ -404,14 +404,14 @@ struct parse_parameter
struct hlsl_type *type; struct hlsl_type *type;
const char *name; const char *name;
const char *semantic; const char *semantic;
const struct reg_reservation *reg_reservation; const struct hlsl_reg_reservation *reg_reservation;
unsigned int modifiers; unsigned int modifiers;
}; };
struct parse_colon_attribute struct parse_colon_attribute
{ {
const char *semantic; const char *semantic;
struct reg_reservation *reg_reservation; struct hlsl_reg_reservation *reg_reservation;
}; };
struct parse_initializer struct parse_initializer
@ -429,7 +429,7 @@ struct parse_variable_def
char *name; char *name;
unsigned int array_size; unsigned int array_size;
const char *semantic; const char *semantic;
struct reg_reservation *reg_reservation; struct hlsl_reg_reservation *reg_reservation;
struct parse_initializer initializer; struct parse_initializer initializer;
}; };
@ -508,53 +508,49 @@ enum hlsl_error_level
HLSL_LEVEL_NOTE, HLSL_LEVEL_NOTE,
}; };
void hlsl_message(const char *fmt, ...) VKD3D_PRINTF_FUNC(1,2) DECLSPEC_HIDDEN; static inline struct hlsl_ir_assignment *hlsl_ir_assignment(const struct hlsl_ir_node *node)
void hlsl_report_message(const struct source_location loc,
enum hlsl_error_level level, const char *fmt, ...) VKD3D_PRINTF_FUNC(3,4) DECLSPEC_HIDDEN;
static inline struct hlsl_ir_assignment *assignment_from_node(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_ASSIGNMENT); assert(node->type == HLSL_IR_ASSIGNMENT);
return CONTAINING_RECORD(node, struct hlsl_ir_assignment, node); return CONTAINING_RECORD(node, struct hlsl_ir_assignment, node);
} }
static inline struct hlsl_ir_constant *constant_from_node(const struct hlsl_ir_node *node) static inline struct hlsl_ir_constant *hlsl_ir_constant(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_CONSTANT); assert(node->type == HLSL_IR_CONSTANT);
return CONTAINING_RECORD(node, struct hlsl_ir_constant, node); return CONTAINING_RECORD(node, struct hlsl_ir_constant, node);
} }
static inline struct hlsl_ir_expr *expr_from_node(const struct hlsl_ir_node *node) static inline struct hlsl_ir_expr *hlsl_ir_expr(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_EXPR); assert(node->type == HLSL_IR_EXPR);
return CONTAINING_RECORD(node, struct hlsl_ir_expr, node); return CONTAINING_RECORD(node, struct hlsl_ir_expr, node);
} }
static inline struct hlsl_ir_if *if_from_node(const struct hlsl_ir_node *node) static inline struct hlsl_ir_if *hlsl_ir_if(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_IF); assert(node->type == HLSL_IR_IF);
return CONTAINING_RECORD(node, struct hlsl_ir_if, node); return CONTAINING_RECORD(node, struct hlsl_ir_if, node);
} }
static inline struct hlsl_ir_jump *jump_from_node(const struct hlsl_ir_node *node) static inline struct hlsl_ir_jump *hlsl_ir_jump(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_JUMP); assert(node->type == HLSL_IR_JUMP);
return CONTAINING_RECORD(node, struct hlsl_ir_jump, node); return CONTAINING_RECORD(node, struct hlsl_ir_jump, node);
} }
static inline struct hlsl_ir_load *load_from_node(const struct hlsl_ir_node *node) static inline struct hlsl_ir_load *hlsl_ir_load(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_LOAD); assert(node->type == HLSL_IR_LOAD);
return CONTAINING_RECORD(node, struct hlsl_ir_load, node); return CONTAINING_RECORD(node, struct hlsl_ir_load, node);
} }
static inline struct hlsl_ir_loop *loop_from_node(const struct hlsl_ir_node *node) static inline struct hlsl_ir_loop *hlsl_ir_loop(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_LOOP); assert(node->type == HLSL_IR_LOOP);
return CONTAINING_RECORD(node, struct hlsl_ir_loop, node); return CONTAINING_RECORD(node, struct hlsl_ir_loop, node);
} }
static inline struct hlsl_ir_swizzle *swizzle_from_node(const struct hlsl_ir_node *node) static inline struct hlsl_ir_swizzle *hlsl_ir_swizzle(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_SWIZZLE); assert(node->type == HLSL_IR_SWIZZLE);
return CONTAINING_RECORD(node, struct hlsl_ir_swizzle, node); return CONTAINING_RECORD(node, struct hlsl_ir_swizzle, node);
@ -592,61 +588,75 @@ static inline void set_parse_status(enum parse_status *current, enum parse_statu
*current = PARSE_WARN; *current = PARSE_WARN;
} }
struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int array_size) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *new_assignment(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_ir_node *rhs, unsigned int writemask, struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_node *new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN;
struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
struct source_location *loc) DECLSPEC_HIDDEN;
struct hlsl_ir_function_decl *new_func_decl(struct hlsl_type *return_type,
struct list *parameters, const char *semantic, struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_if *new_if(struct hlsl_ir_node *condition, struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *new_simple_assignment(struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;
struct hlsl_type *new_struct_type(const char *name, struct list *fields) DECLSPEC_HIDDEN;
struct hlsl_ir_swizzle *new_swizzle(DWORD s, unsigned int components,
struct hlsl_ir_node *val, struct source_location *loc) DECLSPEC_HIDDEN;
struct hlsl_ir_var *new_synthetic_var(const char *name, struct hlsl_type *type,
const struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_constant *new_uint_constant(unsigned int n, const struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_node *new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_var *new_var(const char *name, struct hlsl_type *type, const struct source_location loc,
const char *semantic, unsigned int modifiers, const struct reg_reservation *reg_reservation) DECLSPEC_HIDDEN;
struct hlsl_ir_load *new_var_load(struct hlsl_ir_var *var, const struct source_location loc) DECLSPEC_HIDDEN;
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
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) DECLSPEC_HIDDEN;
struct hlsl_type *clone_hlsl_type(struct hlsl_type *old, unsigned int default_majority) DECLSPEC_HIDDEN;
struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
BOOL is_row_major(const struct hlsl_type *type) DECLSPEC_HIDDEN;
BOOL find_function(const char *name) DECLSPEC_HIDDEN;
unsigned int components_count_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
void init_functions_tree(struct rb_tree *funcs) DECLSPEC_HIDDEN; void init_functions_tree(struct rb_tree *funcs) DECLSPEC_HIDDEN;
void add_function_decl(struct rb_tree *funcs, char *name, struct hlsl_ir_function_decl *decl,
const char *hlsl_base_type_to_string(const struct hlsl_type *type) DECLSPEC_HIDDEN;
const char *debug_hlsl_type(const struct hlsl_type *type) DECLSPEC_HIDDEN;
const char *hlsl_debug_modifiers(DWORD modifiers) DECLSPEC_HIDDEN;
const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type) DECLSPEC_HIDDEN;
void hlsl_add_function(struct rb_tree *funcs, char *name, struct hlsl_ir_function_decl *decl,
BOOL intrinsic) DECLSPEC_HIDDEN; BOOL intrinsic) DECLSPEC_HIDDEN;
BOOL type_is_void(const struct hlsl_type *type) DECLSPEC_HIDDEN; BOOL hlsl_add_var(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
int hlsl_compile(enum vkd3d_shader_type type, DWORD major, DWORD minor, const char *entrypoint,
struct vkd3d_shader_code *dxbc, struct vkd3d_shader_message_context *message_context) DECLSPEC_HIDDEN;
void hlsl_dump_function(const struct hlsl_ir_function_decl *func) DECLSPEC_HIDDEN;
void hlsl_free_instr(struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
void hlsl_free_instr_list(struct list *list) DECLSPEC_HIDDEN;
void hlsl_free_function_rb(struct rb_entry *entry, void *context) DECLSPEC_HIDDEN;
void hlsl_free_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
void hlsl_free_var(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
BOOL hlsl_get_function(const char *name) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_new_array_type(struct hlsl_type *basic_type, unsigned int array_size) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *hlsl_new_assignment(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_ir_node *rhs, unsigned int writemask, struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN;
struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
struct source_location *loc) DECLSPEC_HIDDEN;
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_type *return_type,
struct list *parameters, const char *semantic, struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *hlsl_new_simple_assignment(struct hlsl_ir_var *lhs,
struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_new_struct_type(const char *name, struct list *fields) DECLSPEC_HIDDEN;
struct hlsl_ir_swizzle *hlsl_new_swizzle(DWORD s, unsigned int components,
struct hlsl_ir_node *val, struct source_location *loc) DECLSPEC_HIDDEN;
struct hlsl_ir_var *hlsl_new_synthetic_var(const char *name, struct hlsl_type *type,
const struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_new_type(const char *name, enum hlsl_type_class type_class,
enum hlsl_base_type base_type, unsigned dimx, unsigned dimy) DECLSPEC_HIDDEN;
struct hlsl_ir_constant *hlsl_new_uint_constant(unsigned int n, const struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_node *hlsl_new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
struct source_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct source_location loc,
const char *semantic, unsigned int modifiers,
const struct hlsl_reg_reservation *reg_reservation) DECLSPEC_HIDDEN;
struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct source_location loc) DECLSPEC_HIDDEN;
void hlsl_message(const char *fmt, ...) VKD3D_PRINTF_FUNC(1,2) DECLSPEC_HIDDEN;
void hlsl_report_message(const struct source_location loc,
enum hlsl_error_level level, const char *fmt, ...) VKD3D_PRINTF_FUNC(3,4) DECLSPEC_HIDDEN;
void hlsl_push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
BOOL hlsl_pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_type_clone(struct hlsl_type *old, unsigned int default_majority) DECLSPEC_HIDDEN;
BOOL hlsl_type_compare(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
unsigned int hlsl_type_component_count(struct hlsl_type *type) DECLSPEC_HIDDEN;
BOOL hlsl_type_is_row_major(const struct hlsl_type *type) DECLSPEC_HIDDEN;
BOOL hlsl_type_is_void(const struct hlsl_type *type) DECLSPEC_HIDDEN;
int hlsl_lexer_compile(const char *text, enum vkd3d_shader_type type, DWORD major, DWORD minor, const char *entrypoint, int hlsl_lexer_compile(const char *text, enum vkd3d_shader_type type, DWORD major, DWORD minor, const char *entrypoint,
struct vkd3d_shader_code *dxbc, struct vkd3d_shader_message_context *message_context) DECLSPEC_HIDDEN; struct vkd3d_shader_code *dxbc, struct vkd3d_shader_message_context *message_context) DECLSPEC_HIDDEN;
int hlsl_parser_compile(enum vkd3d_shader_type type, DWORD major, DWORD minor, const char *entrypoint, int hlsl_parser_compile(enum vkd3d_shader_type type, DWORD major, DWORD minor, const char *entrypoint,
struct vkd3d_shader_code *dxbc, struct vkd3d_shader_message_context *message_context) DECLSPEC_HIDDEN; struct vkd3d_shader_code *dxbc, struct vkd3d_shader_message_context *message_context) DECLSPEC_HIDDEN;
const char *debug_base_type(const struct hlsl_type *type) DECLSPEC_HIDDEN;
const char *debug_hlsl_type(const struct hlsl_type *type) DECLSPEC_HIDDEN;
const char *debug_modifiers(DWORD modifiers) DECLSPEC_HIDDEN;
const char *debug_node_type(enum hlsl_ir_node_type type) DECLSPEC_HIDDEN;
void debug_dump_ir_function_decl(const struct hlsl_ir_function_decl *func) DECLSPEC_HIDDEN;
void free_hlsl_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
void free_instr(struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
void free_instr_list(struct list *list) DECLSPEC_HIDDEN;
void free_function_rb(struct rb_entry *entry, void *context) DECLSPEC_HIDDEN;
#endif #endif

View File

@ -172,10 +172,9 @@ row_major {return KW_ROW_MAJOR; }
{IDENTIFIER} { {IDENTIFIER} {
hlsl_lval.name = vkd3d_strdup(yytext); hlsl_lval.name = vkd3d_strdup(yytext);
if (get_variable(hlsl_ctx.cur_scope, yytext) if (hlsl_get_var(hlsl_ctx.cur_scope, yytext) || hlsl_get_function(yytext))
|| find_function(yytext))
return VAR_IDENTIFIER; return VAR_IDENTIFIER;
else if (get_type(hlsl_ctx.cur_scope, yytext, TRUE)) else if (hlsl_get_type(hlsl_ctx.cur_scope, yytext, TRUE))
return TYPE_IDENTIFIER; return TYPE_IDENTIFIER;
else else
return NEW_IDENTIFIER; return NEW_IDENTIFIER;

File diff suppressed because it is too large Load Diff