Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 4 +--- libs/vkd3d-shader/hlsl.h | 17 +---------------- libs/vkd3d-shader/hlsl.y | 6 +++--- 3 files changed, 5 insertions(+), 22 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index a129e847..4151c84b 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -35,14 +35,12 @@ void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, co { /* FIXME */
- set_parse_status(&ctx->status, PARSE_ERR); + ctx->failed = true; }
void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...) { /* FIXME */ - - set_parse_status(&ctx->status, PARSE_WARN); }
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var) diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 067aae86..88e7df5e 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -23,13 +23,6 @@ #include "vkd3d_shader_private.h" #include "rbtree.h"
-enum parse_status -{ - PARSE_SUCCESS = 0, - PARSE_WARN = 1, - PARSE_ERR = 2 -}; - /* The general IR structure is inspired by Mesa GLSL hir, even though the code * ends up being quite different in practice. Anyway, here comes the relevant * licensing information. @@ -396,8 +389,8 @@ struct hlsl_ctx const char **source_files; unsigned int source_files_count; struct vkd3d_shader_location location; - enum parse_status status; struct vkd3d_shader_message_context *message_context; + bool failed;
void *scanner;
@@ -501,14 +494,6 @@ static inline void hlsl_src_remove(struct hlsl_src *src) src->node = NULL; }
-static inline void set_parse_status(enum parse_status *current, enum parse_status update) -{ - if (update == PARSE_ERR) - *current = PARSE_ERR; - else if (update == PARSE_WARN && *current == PARSE_SUCCESS) - *current = PARSE_WARN; -} - 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; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index d7201f58..2fda89e9 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2006,7 +2006,7 @@ param_list: if (!add_func_parameter(ctx, $$, &$1, @1)) { ERR("Error adding function parameter %s.\n", $1.name); - set_parse_status(&ctx->status, PARSE_ERR); + ctx->failed = true; YYABORT; } } @@ -3111,7 +3111,7 @@ int hlsl_parser_compile(struct hlsl_ctx *ctx, const char *entrypoint)
yyparse(ctx->scanner, ctx);
- if (ctx->status == PARSE_ERR) + if (ctx->failed) return VKD3D_ERROR_INVALID_SHADER;
if (!(entry_func = get_func_entry(ctx, entrypoint))) @@ -3140,7 +3140,7 @@ int hlsl_parser_compile(struct hlsl_ctx *ctx, const char *entrypoint)
compute_liveness(ctx, entry_func);
- if (ctx->status == PARSE_ERR) + if (ctx->failed) return VKD3D_ERROR_INVALID_SHADER; return VKD3D_ERROR_NOT_IMPLEMENTED; }
It is perfectly valid.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 2 -- 1 file changed, 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 2fda89e9..1bda8df2 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2464,8 +2464,6 @@ loop_statement: } | KW_FOR '(' scope_start declaration expr_statement expr ')' statement { - if (!$4) - hlsl_warning(ctx, @4, "no expressions in for loop initializer"); $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, @1); hlsl_pop_scope(ctx); }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- No idea why that warning was there in the first place...
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
This patch can be freely ignored. I have not found any of these messages to be useful when debugging, but others may.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 1 - libs/vkd3d-shader/hlsl.l | 2 -- libs/vkd3d-shader/hlsl.y | 38 -------------------------------------- 3 files changed, 41 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 4151c84b..c4e06143 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1255,7 +1255,6 @@ void hlsl_add_function(struct rb_tree *funcs, char *name, struct hlsl_ir_functio ERR("Redeclaring a user defined function as an intrinsic.\n"); return; } - TRACE("Function %s redeclared as a user defined function.\n", debugstr_a(name)); func->intrinsic = intrinsic; rb_destroy(&func->overloads, free_function_decl_rb, NULL); rb_init(&func->overloads, compare_function_decl_rb); diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index a0e0beda..933c9b88 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -218,7 +218,6 @@ row_major {return KW_ROW_MAJOR; } }
<pp>pragma{WS}+ { - TRACE("Got a #pragma.\n"); BEGIN(pp_pragma); } <pp_pragma>pack_matrix{WS}*({WS}*row_major{WS}*) { @@ -243,7 +242,6 @@ row_major {return KW_ROW_MAJOR; } } <pp_pragma>{ANY} {} <pp>[0-9]+ { - TRACE("Preprocessor line info.\n"); BEGIN(pp_line); yylval->intval = (atoi(yytext)); return PRE_LINE; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1bda8df2..6e0669b4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -121,14 +121,6 @@ static struct hlsl_ir_node *node_from_list(struct list *list) return LIST_ENTRY(list_tail(list), struct hlsl_ir_node, entry); }
-static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char *declname, unsigned int line_no) -{ - TRACE("Line %u: ", line_no); - if (modifiers) - TRACE("%s ", hlsl_debug_modifiers(modifiers)); - TRACE("%s %s;\n", debug_hlsl_type(type), declname); -} - static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct vkd3d_shader_location loc) { if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK) @@ -270,8 +262,6 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy) hlsl_warning(ctx, *loc, "implicit truncation of vector type");
- TRACE("Implicit conversion from %s to %s.\n", debug_hlsl_type(src_type), debug_hlsl_type(dst_type)); - if (!(cast = hlsl_new_cast(node, dst_type, loc))) return NULL; list_add_tail(instrs, &cast->node.entry); @@ -282,7 +272,6 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo { bool ret;
- TRACE("Declaring variable %s.\n", decl->name); if (decl->data_type->type != HLSL_CLASS_MATRIX) check_invalid_matrix_modifiers(ctx, decl->modifiers, decl->loc);
@@ -428,7 +417,6 @@ static unsigned int initializer_size(const struct parse_initializer *initializer { count += hlsl_type_component_count(initializer->args[i]->data_type); } - TRACE("Initializer size = %u.\n", count); return count; }
@@ -581,8 +569,6 @@ static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, struct list *instrs, if (!(var = hlsl_new_synthetic_var(ctx, name, var_node->data_type, var_node->loc))) return NULL;
- TRACE("Synthesized variable %p for %s node.\n", var, hlsl_node_type_to_string(var_node->type)); - if (!(assign = hlsl_new_simple_assignment(var, var_node))) return NULL;
@@ -618,8 +604,6 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in struct hlsl_ir_constant *c; struct hlsl_ir_node *mul;
- TRACE("Array load from type %s.\n", debug_hlsl_type(expr_type)); - if (expr_type->type == HLSL_CLASS_ARRAY) { data_type = expr_type->e.array.type; @@ -721,7 +705,6 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty list_init(list); LIST_FOR_EACH_ENTRY_SAFE(v, v_next, fields, struct parse_variable_def, entry) { - debug_dump_decl(type, 0, v->name, v->loc.line); if (!(field = vkd3d_calloc(1, sizeof(*field)))) { vkd3d_free(v); @@ -1121,7 +1104,6 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs, break; if (hlsl_type_compare(operands[i]->data_type, type)) continue; - TRACE("Implicitly converting %s into %s in an expression.\n", debug_hlsl_type(operands[i]->data_type), debug_hlsl_type(type)); if (operands[i]->data_type->dimx * operands[i]->data_type->dimy != 1 && operands[i]->data_type->dimx * operands[i]->data_type->dimy != type->dimx * type->dimy) { @@ -1292,7 +1274,6 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in enum hlsl_ir_expr_op op = op_from_assignment(assign_op); struct hlsl_ir_node *expr;
- TRACE("Adding an expression for the compound assignment.\n"); expr = hlsl_new_binary_expr(op, lhs, rhs); list_add_after(&rhs->entry, &expr->entry); rhs = expr; @@ -1391,7 +1372,6 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t free_parse_variable_def(v); continue; } - debug_dump_decl(type, modifiers, v->name, v->loc.line);
if (ctx->cur_scope == ctx->globals) { @@ -1414,14 +1394,12 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t vkd3d_free(v); continue; } - TRACE("Declared variable %s.\n", var->name);
if (v->initializer.args_count) { unsigned int size = initializer_size(&v->initializer); struct hlsl_ir_load *load;
- TRACE("Variable with initializer.\n"); if (type->type <= HLSL_CLASS_LAST_NUMERIC && type->dimx * type->dimy != size && size != 1) { @@ -1739,29 +1717,22 @@ hlsl_prog: "void function with a semantic"); }
- TRACE("Adding function '%s' to the function list.\n", $2.name); hlsl_add_function(&ctx->functions, $2.name, $2.decl, false); } | hlsl_prog declaration_statement { - TRACE("Declaration statement parsed.\n"); - if (!list_empty($2)) FIXME("Uniform initializer.\n"); hlsl_free_instr_list($2); } | hlsl_prog preproc_directive | hlsl_prog ';' - { - TRACE("Skipping stray semicolon.\n"); - }
preproc_directive: PRE_LINE STRING { const char **new_array = NULL;
- TRACE("Updating line information to file %s, line %u.\n", debugstr_a($2), $1); ctx->location.line = $1; if (strcmp($2, ctx->location.source_name)) new_array = vkd3d_realloc(ctx->source_files, @@ -1813,7 +1784,6 @@ named_struct_spec: { bool ret;
- TRACE("Structure %s declaration.\n", debugstr_a($2)); $$ = hlsl_new_struct_type(ctx, $2, $4);
if (hlsl_get_var(ctx->cur_scope, $2)) @@ -1833,7 +1803,6 @@ named_struct_spec: unnamed_struct_spec: KW_STRUCT '{' fields_list '}' { - TRACE("Anonymous structure declaration.\n"); $$ = hlsl_new_struct_type(ctx, NULL, $3); }
@@ -1884,14 +1853,12 @@ field: func_declaration: func_prototype compound_statement { - TRACE("Function %s parsed.\n", $1.name); $$ = $1; $$.decl->body = $2; hlsl_pop_scope(ctx); } | func_prototype ';' { - TRACE("Function prototype for %s.\n", $1.name); $$ = $1; hlsl_pop_scope(ctx); } @@ -2246,7 +2213,6 @@ variable_def: } | any_identifier array colon_attribute '=' complex_initializer { - TRACE("Declaration with initializer.\n"); $$ = vkd3d_calloc(1, sizeof(*$$)); $$->loc = @1; $$->name = $1; @@ -2273,7 +2239,6 @@ array: "array size is not a positive integer constant\n"); YYABORT; } - TRACE("Array size %u.\n", size);
if (size > 65536) { @@ -3131,10 +3096,7 @@ int hlsl_parser_compile(struct hlsl_ctx *ctx, const char *entrypoint) index_instructions(entry_func->body, 2);
if (TRACE_ON()) - { - TRACE("IR dump.\n"); rb_for_each_entry(&ctx->functions, dump_function, NULL); - }
compute_liveness(ctx, entry_func);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 49 +++++++++++++++++++++++++--------------- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 14 ++++++++++-- 3 files changed, 44 insertions(+), 21 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index c4e06143..4bdcd184 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -694,41 +694,48 @@ const char *debug_hlsl_type(const struct hlsl_type *type) return "unexpected_type"; }
-const char *hlsl_debug_modifiers(DWORD modifiers) +char *hlsl_modifiers_to_string(unsigned int modifiers) { - char string[110]; + char *string; + size_t len; + + if (!(string = vkd3d_malloc(110))) + return NULL;
string[0] = 0; if (modifiers & HLSL_STORAGE_EXTERN) - strcat(string, " extern"); /* 7 */ + strcat(string, "extern "); /* 7 */ if (modifiers & HLSL_STORAGE_NOINTERPOLATION) - strcat(string, " nointerpolation"); /* 16 */ + strcat(string, "nointerpolation "); /* 16 */ if (modifiers & HLSL_MODIFIER_PRECISE) - strcat(string, " precise"); /* 8 */ + strcat(string, "precise "); /* 8 */ if (modifiers & HLSL_STORAGE_SHARED) - strcat(string, " shared"); /* 7 */ + strcat(string, "shared "); /* 7 */ if (modifiers & HLSL_STORAGE_GROUPSHARED) - strcat(string, " groupshared"); /* 12 */ + strcat(string, "groupshared "); /* 12 */ if (modifiers & HLSL_STORAGE_STATIC) - strcat(string, " static"); /* 7 */ + strcat(string, "static "); /* 7 */ if (modifiers & HLSL_STORAGE_UNIFORM) - strcat(string, " uniform"); /* 8 */ + strcat(string, "uniform "); /* 8 */ if (modifiers & HLSL_STORAGE_VOLATILE) - strcat(string, " volatile"); /* 9 */ + strcat(string, "volatile "); /* 9 */ if (modifiers & HLSL_MODIFIER_CONST) - strcat(string, " const"); /* 6 */ + strcat(string, "const "); /* 6 */ if (modifiers & HLSL_MODIFIER_ROW_MAJOR) - strcat(string, " row_major"); /* 10 */ + strcat(string, "row_major "); /* 10 */ if (modifiers & HLSL_MODIFIER_COLUMN_MAJOR) - strcat(string, " column_major"); /* 13 */ + strcat(string, "column_major "); /* 13 */ if ((modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)) == (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)) - strcat(string, " inout"); /* 6 */ + strcat(string, "inout "); /* 6 */ else if (modifiers & HLSL_STORAGE_IN) - strcat(string, " in"); /* 3 */ + strcat(string, "in "); /* 3 */ else if (modifiers & HLSL_STORAGE_OUT) - strcat(string, " out"); /* 4 */ + strcat(string, "out "); /* 4 */ + + if ((len = strlen(string))) + string[len - 1] = 0;
- return vkd3d_dbg_sprintf("%s", string[0] ? string + 1 : ""); + return string; }
const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type) @@ -774,7 +781,13 @@ static void dump_src(struct vkd3d_string_buffer *buffer, const struct hlsl_src * static void dump_ir_var(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_var *var) { if (var->modifiers) - vkd3d_string_buffer_printf(buffer, "%s ", hlsl_debug_modifiers(var->modifiers)); + { + char *string; + + if ((string = hlsl_modifiers_to_string(var->modifiers))) + vkd3d_string_buffer_printf(buffer, "%s ", string); + vkd3d_free(string); + } vkd3d_string_buffer_printf(buffer, "%s %s", debug_hlsl_type(var->data_type), var->name); if (var->semantic) vkd3d_string_buffer_printf(buffer, " : %s", var->semantic); diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 88e7df5e..2ca432ab 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -496,7 +496,7 @@ static inline void hlsl_src_remove(struct hlsl_src *src)
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; +char *hlsl_modifiers_to_string(unsigned int 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, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 6e0669b4..32a37e2f 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -282,8 +282,14 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
if (invalid) { - hlsl_error(ctx, decl->loc, "modifier '%s' invalid for local variables", hlsl_debug_modifiers(invalid)); + char *string; + + if ((string = hlsl_modifiers_to_string(invalid))) + hlsl_error(ctx, decl->loc, + "Modifiers '%s' are not allowed on local variables.", string); + vkd3d_free(string); } + if (decl->semantic) { hlsl_error(ctx, decl->loc, "semantics are not allowed on local variables"); @@ -314,7 +320,11 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con { if (modifiers & mod) { - hlsl_error(ctx, loc, "modifier '%s' already specified", hlsl_debug_modifiers(mod)); + char *string; + + if ((string = hlsl_modifiers_to_string(mod))) + hlsl_error(ctx, loc, "Modifier '%s' was already specified.", string); + vkd3d_free(string); return modifiers; } if ((mod & HLSL_MODIFIERS_MAJORITY_MASK) && (modifiers & HLSL_MODIFIERS_MAJORITY_MASK))
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- There's the alternative of using and passing around a vkd3d_string_buffer instead. This also works though.
On Mon, 15 Feb 2021 at 20:22, Matteo Bruni mbruni@codeweavers.com wrote:
There's the alternative of using and passing around a vkd3d_string_buffer instead. This also works though.
Yes, in the longer term I'd probably feel safer about using vkd3d_string_buffer in more places than always getting buffer sizes right in places like these. Note that for temporary strings we could do something along the lines of wined3d's string_buffer_get().
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 65 +++++++++++++++++++++++++--------------- libs/vkd3d-shader/hlsl.h | 4 ++- libs/vkd3d-shader/hlsl.y | 16 +++++++--- 3 files changed, 56 insertions(+), 29 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 4bdcd184..f181439c 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -667,31 +667,55 @@ const char *hlsl_base_type_to_string(const struct hlsl_type *type) return name; }
-const char *debug_hlsl_type(const struct hlsl_type *type) +char *hlsl_type_to_string(const struct hlsl_type *type) { const char *name; + char *string;
if (type->name) - return debugstr_a(type->name); - - if (type->type == HLSL_CLASS_STRUCT) - return "<anonymous struct>"; + return vkd3d_strdup(type->name);
- if (type->type == HLSL_CLASS_ARRAY) + switch (type->type) { - return vkd3d_dbg_sprintf("%s[%u]", hlsl_base_type_to_string(type->e.array.type), - type->e.array.elements_count); + case HLSL_CLASS_SCALAR: + return vkd3d_strdup(hlsl_base_type_to_string(type)); + + case HLSL_CLASS_VECTOR: + name = hlsl_base_type_to_string(type); + if ((string = malloc(strlen(name) + 2))) + sprintf(string, "%s%u", name, type->dimx); + return string; + + case HLSL_CLASS_MATRIX: + name = hlsl_base_type_to_string(type); + if ((string = malloc(strlen(name) + 4))) + sprintf(string, "%s%ux%u", name, type->dimx, type->dimy); + return string; + + case HLSL_CLASS_ARRAY: + name = hlsl_base_type_to_string(type->e.array.type); + if ((string = malloc(strlen(name) + 15))) + sprintf(string, "%s[%u]", name, type->e.array.elements_count); + return string; + + case HLSL_CLASS_STRUCT: + return vkd3d_strdup("<anonymous struct>"); + + default: + return vkd3d_strdup("<unexpected type>"); } +}
- name = hlsl_base_type_to_string(type); +const char *debug_hlsl_type(const struct hlsl_type *type) +{ + const char *ret; + char *string;
- if (type->type == HLSL_CLASS_SCALAR) - return vkd3d_dbg_sprintf("%s", name); - if (type->type == HLSL_CLASS_VECTOR) - return vkd3d_dbg_sprintf("%s%u", name, type->dimx); - if (type->type == HLSL_CLASS_MATRIX) - return vkd3d_dbg_sprintf("%s%ux%u", name, type->dimx, type->dimy); - return "unexpected_type"; + if (!(string = hlsl_type_to_string(type))) + return NULL; + ret = vkd3d_dbg_sprintf("%s", string); + vkd3d_free(string); + return ret; }
char *hlsl_modifiers_to_string(unsigned int modifiers) @@ -795,11 +819,7 @@ static void dump_ir_var(struct vkd3d_string_buffer *buffer, const struct hlsl_ir
static void dump_deref(struct vkd3d_string_buffer *buffer, const struct hlsl_deref *deref) { - if (deref->offset.node) - /* Print the variable's type for convenience. */ - vkd3d_string_buffer_printf(buffer, "(%s %s)", debug_hlsl_type(deref->var->data_type), deref->var->name); - else - vkd3d_string_buffer_printf(buffer, "%s", deref->var->name); + vkd3d_string_buffer_printf(buffer, "%s", deref->var->name); if (deref->offset.node) { vkd3d_string_buffer_printf(buffer, "["); @@ -948,9 +968,6 @@ static const char *debug_expr_op(const struct hlsl_ir_expr *expr) ",", };
- if (expr->op == HLSL_IR_UNOP_CAST) - return debug_hlsl_type(expr->node.data_type); - return op_names[expr->op]; }
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 2ca432ab..b2b7daf0 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -494,8 +494,10 @@ static inline void hlsl_src_remove(struct hlsl_src *src) src->node = NULL; }
-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_base_type_to_string(const struct hlsl_type *type) DECLSPEC_HIDDEN; +char *hlsl_type_to_string(const struct hlsl_type *type) DECLSPEC_HIDDEN; char *hlsl_modifiers_to_string(unsigned int modifiers) DECLSPEC_HIDDEN; const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 32a37e2f..8b91ff5d 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -254,8 +254,12 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
if (!implicit_compatible_data_types(src_type, dst_type)) { - hlsl_error(ctx, *loc, "can't implicitly convert %s to %s", - debug_hlsl_type(src_type), debug_hlsl_type(dst_type)); + char *src_string = hlsl_type_to_string(src_type), *dst_string = hlsl_type_to_string(dst_type); + + if (src_string && dst_string) + hlsl_error(ctx, *loc, "Can't implicitly convert from %s to %s.", src_string, dst_string); + vkd3d_free(src_string); + vkd3d_free(dst_string); return NULL; }
@@ -2728,8 +2732,12 @@ unary_expr:
if (!compatible_data_types(src_type, dst_type)) { - hlsl_error(ctx, @3, "can't cast from %s to %s", - debug_hlsl_type(src_type), debug_hlsl_type(dst_type)); + char *src_string = hlsl_type_to_string(src_type), *dst_string = hlsl_type_to_string(dst_type); + + if (src_string && dst_string) + hlsl_error(ctx, @3, "Can't cast from %s to %s.", src_string, dst_string); + vkd3d_free(src_string); + vkd3d_free(dst_string); YYABORT; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com