mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Separate hlsl_report_message() into helpers for individual log levels.
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:
parent
df3773ff7e
commit
28b1d68ce3
@ -25,15 +25,24 @@ void hlsl_message(const char *fmt, ...)
|
|||||||
/* FIXME */
|
/* FIXME */
|
||||||
}
|
}
|
||||||
|
|
||||||
void hlsl_report_message(struct hlsl_ctx *ctx, const struct source_location loc,
|
void hlsl_note(struct hlsl_ctx *ctx, const struct source_location loc,
|
||||||
enum hlsl_error_level level, const char *fmt, ...)
|
enum vkd3d_shader_log_level level, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
/* FIXME */
|
||||||
|
}
|
||||||
|
|
||||||
|
void hlsl_error(struct hlsl_ctx *ctx, const struct source_location loc, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
|
|
||||||
if (level == HLSL_LEVEL_ERROR)
|
set_parse_status(&ctx->status, PARSE_ERR);
|
||||||
set_parse_status(&ctx->status, PARSE_ERR);
|
}
|
||||||
else if (level == HLSL_LEVEL_WARNING)
|
|
||||||
set_parse_status(&ctx->status, PARSE_WARN);
|
void hlsl_warning(struct hlsl_ctx *ctx, const struct source_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)
|
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var)
|
||||||
|
@ -568,8 +568,13 @@ struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const
|
|||||||
struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct source_location loc) 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_message(const char *fmt, ...) VKD3D_PRINTF_FUNC(1,2) DECLSPEC_HIDDEN;
|
||||||
void hlsl_report_message(struct hlsl_ctx *ctx, const struct source_location loc,
|
|
||||||
enum hlsl_error_level level, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
|
void hlsl_error(struct hlsl_ctx *ctx, const struct source_location loc,
|
||||||
|
const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
|
||||||
|
void hlsl_warning(struct hlsl_ctx *ctx, const struct source_location loc,
|
||||||
|
const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
|
||||||
|
void hlsl_note(struct hlsl_ctx *ctx, const struct source_location loc, enum vkd3d_shader_log_level level,
|
||||||
|
const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
void hlsl_push_scope(struct hlsl_ctx *ctx) DECLSPEC_HIDDEN;
|
void hlsl_push_scope(struct hlsl_ctx *ctx) DECLSPEC_HIDDEN;
|
||||||
void hlsl_pop_scope(struct hlsl_ctx *ctx) DECLSPEC_HIDDEN;
|
void hlsl_pop_scope(struct hlsl_ctx *ctx) DECLSPEC_HIDDEN;
|
||||||
|
@ -65,8 +65,7 @@ ANY (.)
|
|||||||
{RESERVED4} {
|
{RESERVED4} {
|
||||||
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
|
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
|
||||||
|
|
||||||
hlsl_report_message(ctx, *yylloc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, *yylloc, "Reserved keyword \"%s\" used.\n", yytext);
|
||||||
"Reserved keyword \"%s\" used.\n", yytext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlendState {return KW_BLENDSTATE; }
|
BlendState {return KW_BLENDSTATE; }
|
||||||
|
@ -113,7 +113,7 @@ int yylex(HLSL_YYSTYPE *yylval_param, HLSL_YYLTYPE *yylloc_param, void *yyscanne
|
|||||||
|
|
||||||
static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const char *s)
|
static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const char *s)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, *loc, HLSL_LEVEL_ERROR, "%s", s);
|
hlsl_error(ctx, *loc, "%s", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct hlsl_ir_node *node_from_list(struct list *list)
|
static struct hlsl_ir_node *node_from_list(struct list *list)
|
||||||
@ -132,8 +132,7 @@ static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char
|
|||||||
static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct source_location loc)
|
static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct source_location loc)
|
||||||
{
|
{
|
||||||
if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
|
if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
|
||||||
hlsl_report_message(ctx, loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, loc, "'row_major' or 'column_major' modifiers are only allowed for matrices.");
|
||||||
"'row_major' or 'column_major' modifiers are only allowed for matrices.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool convertible_data_type(struct hlsl_type *type)
|
static bool convertible_data_type(struct hlsl_type *type)
|
||||||
@ -263,13 +262,13 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
|
|||||||
|
|
||||||
if (!implicit_compatible_data_types(src_type, dst_type))
|
if (!implicit_compatible_data_types(src_type, dst_type))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, *loc, HLSL_LEVEL_ERROR, "can't implicitly convert %s to %s",
|
hlsl_error(ctx, *loc, "can't implicitly convert %s to %s",
|
||||||
debug_hlsl_type(src_type), debug_hlsl_type(dst_type));
|
debug_hlsl_type(src_type), debug_hlsl_type(dst_type));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy)
|
if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy)
|
||||||
hlsl_report_message(ctx, *loc, HLSL_LEVEL_WARNING, "implicit truncation of vector type");
|
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));
|
TRACE("Implicit conversion from %s to %s.\n", debug_hlsl_type(src_type), debug_hlsl_type(dst_type));
|
||||||
|
|
||||||
@ -294,13 +293,11 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
|
|||||||
|
|
||||||
if (invalid)
|
if (invalid)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, decl->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, decl->loc, "modifier '%s' invalid for local variables", hlsl_debug_modifiers(invalid));
|
||||||
"modifier '%s' invalid for local variables", hlsl_debug_modifiers(invalid));
|
|
||||||
}
|
}
|
||||||
if (decl->semantic)
|
if (decl->semantic)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, decl->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, decl->loc, "semantics are not allowed on local variables");
|
||||||
"semantics are not allowed on local variables");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,7 +305,7 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
|
|||||||
{
|
{
|
||||||
if (hlsl_get_function(ctx, decl->name))
|
if (hlsl_get_function(ctx, decl->name))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, decl->loc, HLSL_LEVEL_ERROR, "redefinition of '%s'", decl->name);
|
hlsl_error(ctx, decl->loc, "redefinition of '%s'", decl->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,8 +314,8 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
|
|||||||
{
|
{
|
||||||
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, decl->name);
|
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, decl->name);
|
||||||
|
|
||||||
hlsl_report_message(ctx, decl->loc, HLSL_LEVEL_ERROR, "\"%s\" already declared", decl->name);
|
hlsl_error(ctx, decl->loc, "\"%s\" already declared", decl->name);
|
||||||
hlsl_report_message(ctx, old->loc, HLSL_LEVEL_NOTE, "\"%s\" was previously declared here", old->name);
|
hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here", old->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -328,12 +325,12 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con
|
|||||||
{
|
{
|
||||||
if (modifiers & mod)
|
if (modifiers & mod)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, loc, HLSL_LEVEL_ERROR, "modifier '%s' already specified", hlsl_debug_modifiers(mod));
|
hlsl_error(ctx, loc, "modifier '%s' already specified", hlsl_debug_modifiers(mod));
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
if ((mod & HLSL_MODIFIERS_MAJORITY_MASK) && (modifiers & HLSL_MODIFIERS_MAJORITY_MASK))
|
if ((mod & HLSL_MODIFIERS_MAJORITY_MASK) && (modifiers & HLSL_MODIFIERS_MAJORITY_MASK))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, loc, HLSL_LEVEL_ERROR, "more than one matrix majority keyword");
|
hlsl_error(ctx, loc, "more than one matrix majority keyword");
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
return modifiers | mod;
|
return modifiers | mod;
|
||||||
@ -542,7 +539,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
|
|||||||
}
|
}
|
||||||
else if (!hlsl_type_is_void(return_type))
|
else if (!hlsl_type_is_void(return_type))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, loc, HLSL_LEVEL_ERROR, "non-void function must return a value");
|
hlsl_error(ctx, loc, "non-void function must return a value");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,9 +633,9 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (expr_type->type == HLSL_CLASS_SCALAR)
|
if (expr_type->type == HLSL_CLASS_SCALAR)
|
||||||
hlsl_report_message(ctx, loc, HLSL_LEVEL_ERROR, "array-indexed expression is scalar");
|
hlsl_error(ctx, loc, "array-indexed expression is scalar");
|
||||||
else
|
else
|
||||||
hlsl_report_message(ctx, loc, HLSL_LEVEL_ERROR, "expression is not array-indexable");
|
hlsl_error(ctx, loc, "expression is not array-indexable");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,7 +736,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty
|
|||||||
field->semantic = v->semantic;
|
field->semantic = v->semantic;
|
||||||
if (v->initializer.args_count)
|
if (v->initializer.args_count)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, v->loc, HLSL_LEVEL_ERROR, "struct field with an initializer.\n");
|
hlsl_error(ctx, v->loc, "struct field with an initializer.\n");
|
||||||
free_parse_initializer(&v->initializer);
|
free_parse_initializer(&v->initializer);
|
||||||
}
|
}
|
||||||
list_add_tail(list, &field->entry);
|
list_add_tail(list, &field->entry);
|
||||||
@ -774,11 +771,11 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type
|
|||||||
|
|
||||||
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
|
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
|
||||||
&& (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
|
&& (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
|
||||||
hlsl_report_message(ctx, v->loc, HLSL_LEVEL_ERROR, "more than one matrix majority keyword");
|
hlsl_error(ctx, v->loc, "more than one matrix majority keyword");
|
||||||
|
|
||||||
ret = hlsl_scope_add_type(ctx->cur_scope, type);
|
ret = hlsl_scope_add_type(ctx->cur_scope, type);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
hlsl_report_message(ctx, v->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, v->loc,
|
||||||
"redefinition of custom type '%s'", v->name);
|
"redefinition of custom type '%s'", v->name);
|
||||||
vkd3d_free(v);
|
vkd3d_free(v);
|
||||||
}
|
}
|
||||||
@ -1014,7 +1011,7 @@ static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type
|
|||||||
|
|
||||||
if (t1->type > HLSL_CLASS_LAST_NUMERIC || t2->type > HLSL_CLASS_LAST_NUMERIC)
|
if (t1->type > HLSL_CLASS_LAST_NUMERIC || t2->type > HLSL_CLASS_LAST_NUMERIC)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, *loc, HLSL_LEVEL_ERROR, "non scalar/vector/matrix data type in expression");
|
hlsl_error(ctx, *loc, "non scalar/vector/matrix data type in expression");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,7 +1020,7 @@ static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type
|
|||||||
|
|
||||||
if (!expr_compatible_data_types(t1, t2))
|
if (!expr_compatible_data_types(t1, t2))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, *loc, HLSL_LEVEL_ERROR, "expression data types are incompatible");
|
hlsl_error(ctx, *loc, "expression data types are incompatible");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1128,7 +1125,7 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
|
|||||||
if (operands[i]->data_type->dimx * operands[i]->data_type->dimy != 1
|
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)
|
&& operands[i]->data_type->dimx * operands[i]->data_type->dimy != type->dimx * type->dimy)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, operands[i]->loc, HLSL_LEVEL_WARNING, "implicit truncation of vector/matrix type");
|
hlsl_warning(ctx, operands[i]->loc, "implicit truncation of vector/matrix type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cast = hlsl_new_cast(operands[i], type, &operands[i]->loc)))
|
if (!(cast = hlsl_new_cast(operands[i], type, &operands[i]->loc)))
|
||||||
@ -1267,7 +1264,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
|
|||||||
hlsl_src_from_node(&swizzle->val, rhs);
|
hlsl_src_from_node(&swizzle->val, rhs);
|
||||||
if (!invert_swizzle(&swizzle->swizzle, &writemask, &width))
|
if (!invert_swizzle(&swizzle->swizzle, &writemask, &width))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, lhs->loc, HLSL_LEVEL_ERROR, "invalid writemask");
|
hlsl_error(ctx, lhs->loc, "invalid writemask");
|
||||||
vkd3d_free(assign);
|
vkd3d_free(assign);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1278,7 +1275,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, lhs->loc, HLSL_LEVEL_ERROR, "invalid lvalue");
|
hlsl_error(ctx, lhs->loc, "invalid lvalue");
|
||||||
vkd3d_free(assign);
|
vkd3d_free(assign);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1315,7 +1312,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
|
|||||||
|
|
||||||
if (initializer_size(initializer) != hlsl_type_component_count(type))
|
if (initializer_size(initializer) != hlsl_type_component_count(type))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, var->loc, HLSL_LEVEL_ERROR, "structure initializer mismatch");
|
hlsl_error(ctx, var->loc, "structure initializer mismatch");
|
||||||
free_parse_initializer(initializer);
|
free_parse_initializer(initializer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1404,7 +1401,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
|
|||||||
|
|
||||||
if (type->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer.args_count)
|
if (type->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer.args_count)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, v->loc, HLSL_LEVEL_ERROR, "const variable without initializer");
|
hlsl_error(ctx, v->loc, "const variable without initializer");
|
||||||
hlsl_free_var(var);
|
hlsl_free_var(var);
|
||||||
vkd3d_free(v);
|
vkd3d_free(v);
|
||||||
continue;
|
continue;
|
||||||
@ -1430,7 +1427,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
|
|||||||
{
|
{
|
||||||
if (size < type->dimx * type->dimy)
|
if (size < type->dimx * type->dimy)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, v->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, v->loc,
|
||||||
"'%s' initializer does not match", v->name);
|
"'%s' initializer does not match", v->name);
|
||||||
free_parse_initializer(&v->initializer);
|
free_parse_initializer(&v->initializer);
|
||||||
vkd3d_free(v);
|
vkd3d_free(v);
|
||||||
@ -1440,7 +1437,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
|
|||||||
if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY)
|
if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY)
|
||||||
&& hlsl_type_component_count(type) != size)
|
&& hlsl_type_component_count(type) != size)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, v->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, v->loc,
|
||||||
"'%s' initializer does not match", v->name);
|
"'%s' initializer does not match", v->name);
|
||||||
free_parse_initializer(&v->initializer);
|
free_parse_initializer(&v->initializer);
|
||||||
vkd3d_free(v);
|
vkd3d_free(v);
|
||||||
@ -1720,16 +1717,16 @@ hlsl_prog:
|
|||||||
{
|
{
|
||||||
if (decl->body && $2.decl->body)
|
if (decl->body && $2.decl->body)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, $2.decl->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, $2.decl->loc,
|
||||||
"redefinition of function %s", debugstr_a($2.name));
|
"redefinition of function %s", debugstr_a($2.name));
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
else if (!hlsl_type_compare(decl->return_type, $2.decl->return_type))
|
else if (!hlsl_type_compare(decl->return_type, $2.decl->return_type))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, $2.decl->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, $2.decl->loc,
|
||||||
"redefining function %s with a different return type",
|
"redefining function %s with a different return type",
|
||||||
debugstr_a($2.name));
|
debugstr_a($2.name));
|
||||||
hlsl_report_message(ctx, decl->loc, HLSL_LEVEL_NOTE,
|
hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR,
|
||||||
"%s previously declared here",
|
"%s previously declared here",
|
||||||
debugstr_a($2.name));
|
debugstr_a($2.name));
|
||||||
YYABORT;
|
YYABORT;
|
||||||
@ -1738,7 +1735,7 @@ hlsl_prog:
|
|||||||
|
|
||||||
if (hlsl_type_is_void($2.decl->return_type) && $2.decl->semantic)
|
if (hlsl_type_is_void($2.decl->return_type) && $2.decl->semantic)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, $2.decl->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, $2.decl->loc,
|
||||||
"void function with a semantic");
|
"void function with a semantic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1792,12 +1789,12 @@ struct_declaration:
|
|||||||
{
|
{
|
||||||
if (!$2->name)
|
if (!$2->name)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @2,
|
||||||
"anonymous struct declaration with no variables");
|
"anonymous struct declaration with no variables");
|
||||||
}
|
}
|
||||||
if (modifiers)
|
if (modifiers)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @1, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @1,
|
||||||
"modifier not allowed on struct type declaration");
|
"modifier not allowed on struct type declaration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1821,14 +1818,14 @@ named_struct_spec:
|
|||||||
|
|
||||||
if (hlsl_get_var(ctx->cur_scope, $2))
|
if (hlsl_get_var(ctx->cur_scope, $2))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR, "redefinition of '%s'", $2);
|
hlsl_error(ctx, @2, "redefinition of '%s'", $2);
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = hlsl_scope_add_type(ctx->cur_scope, $$);
|
ret = hlsl_scope_add_type(ctx->cur_scope, $$);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR, "redefinition of struct '%s'", $2);
|
hlsl_error(ctx, @2, "redefinition of struct '%s'", $2);
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1862,8 +1859,7 @@ fields_list:
|
|||||||
ret = add_struct_field($$, field);
|
ret = add_struct_field($$, field);
|
||||||
if (ret == false)
|
if (ret == false)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2,
|
hlsl_error(ctx, @2, "redefinition of '%s'", field->name);
|
||||||
HLSL_LEVEL_ERROR, "redefinition of '%s'", field->name);
|
|
||||||
vkd3d_free(field);
|
vkd3d_free(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1906,18 +1902,17 @@ func_prototype:
|
|||||||
{
|
{
|
||||||
if ($1)
|
if ($1)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @1, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @1, "unexpected modifiers on a function");
|
||||||
"unexpected modifiers on a function");
|
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
if (hlsl_get_var(ctx->globals, $3))
|
if (hlsl_get_var(ctx->globals, $3))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR, "redefinition of '%s'\n", $3);
|
hlsl_error(ctx, @3, "redefinition of '%s'\n", $3);
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
if (hlsl_type_is_void($2) && $7.semantic)
|
if (hlsl_type_is_void($2) && $7.semantic)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @7, HLSL_LEVEL_ERROR, "void function with a semantic");
|
hlsl_error(ctx, @7, "void function with a semantic");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($7.reg_reservation)
|
if ($7.reg_reservation)
|
||||||
@ -2020,7 +2015,7 @@ param_list:
|
|||||||
$$ = $1;
|
$$ = $1;
|
||||||
if (!add_func_parameter(ctx, $$, &$3, @3))
|
if (!add_func_parameter(ctx, $$, &$3, @3))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR, "duplicate parameter %s", $3.name);
|
hlsl_error(ctx, @3, "duplicate parameter %s", $3.name);
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2051,7 +2046,7 @@ input_mods:
|
|||||||
{
|
{
|
||||||
if ($1 & $2)
|
if ($1 & $2)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @2,
|
||||||
"duplicate input-output modifiers");
|
"duplicate input-output modifiers");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
@ -2081,13 +2076,13 @@ type:
|
|||||||
{
|
{
|
||||||
if ($3->type != HLSL_CLASS_SCALAR)
|
if ($3->type != HLSL_CLASS_SCALAR)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @3,
|
||||||
"vectors of non-scalar types are not allowed\n");
|
"vectors of non-scalar types are not allowed\n");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
if ($5 < 1 || $5 > 4)
|
if ($5 < 1 || $5 > 4)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @5, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @5,
|
||||||
"vector size must be between 1 and 4\n");
|
"vector size must be between 1 and 4\n");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
@ -2098,19 +2093,19 @@ type:
|
|||||||
{
|
{
|
||||||
if ($3->type != HLSL_CLASS_SCALAR)
|
if ($3->type != HLSL_CLASS_SCALAR)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @3,
|
||||||
"matrices of non-scalar types are not allowed\n");
|
"matrices of non-scalar types are not allowed\n");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
if ($5 < 1 || $5 > 4)
|
if ($5 < 1 || $5 > 4)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @5, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @5,
|
||||||
"matrix row count must be between 1 and 4\n");
|
"matrix row count must be between 1 and 4\n");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
if ($7 < 1 || $7 > 4)
|
if ($7 < 1 || $7 > 4)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @7, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @7,
|
||||||
"matrix column count must be between 1 and 4\n");
|
"matrix column count must be between 1 and 4\n");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
@ -2152,7 +2147,7 @@ base_type:
|
|||||||
{
|
{
|
||||||
$$ = hlsl_get_type(ctx->cur_scope, $2, true);
|
$$ = hlsl_get_type(ctx->cur_scope, $2, true);
|
||||||
if ($$->type != HLSL_CLASS_STRUCT)
|
if ($$->type != HLSL_CLASS_STRUCT)
|
||||||
hlsl_report_message(ctx, @1, HLSL_LEVEL_ERROR, "'%s' redefined as a structure\n", $2);
|
hlsl_error(ctx, @1, "'%s' redefined as a structure\n", $2);
|
||||||
vkd3d_free($2);
|
vkd3d_free($2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2176,7 +2171,7 @@ typedef:
|
|||||||
if ($2 & ~HLSL_TYPE_MODIFIERS_MASK)
|
if ($2 & ~HLSL_TYPE_MODIFIERS_MASK)
|
||||||
{
|
{
|
||||||
struct parse_variable_def *v, *v_next;
|
struct parse_variable_def *v, *v_next;
|
||||||
hlsl_report_message(ctx, @1, HLSL_LEVEL_ERROR, "modifier not allowed on typedefs");
|
hlsl_error(ctx, @1, "modifier not allowed on typedefs");
|
||||||
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry)
|
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry)
|
||||||
vkd3d_free(v);
|
vkd3d_free(v);
|
||||||
vkd3d_free($4);
|
vkd3d_free($4);
|
||||||
@ -2274,7 +2269,7 @@ array:
|
|||||||
|
|
||||||
if (!size)
|
if (!size)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @2,
|
||||||
"array size is not a positive integer constant\n");
|
"array size is not a positive integer constant\n");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
@ -2282,7 +2277,7 @@ array:
|
|||||||
|
|
||||||
if (size > 65536)
|
if (size > 65536)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @2,
|
||||||
"array size must be between 1 and 65536");
|
"array size must be between 1 and 65536");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
@ -2435,7 +2430,7 @@ selection_statement:
|
|||||||
vkd3d_free($5.then_instrs);
|
vkd3d_free($5.then_instrs);
|
||||||
vkd3d_free($5.else_instrs);
|
vkd3d_free($5.else_instrs);
|
||||||
if (condition->data_type->dimx > 1 || condition->data_type->dimy > 1)
|
if (condition->data_type->dimx > 1 || condition->data_type->dimy > 1)
|
||||||
hlsl_report_message(ctx, instr->node.loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, instr->node.loc,
|
||||||
"if condition requires a scalar");
|
"if condition requires a scalar");
|
||||||
$$ = $3;
|
$$ = $3;
|
||||||
list_add_tail($$, &instr->node.entry);
|
list_add_tail($$, &instr->node.entry);
|
||||||
@ -2470,8 +2465,7 @@ loop_statement:
|
|||||||
| KW_FOR '(' scope_start declaration expr_statement expr ')' statement
|
| KW_FOR '(' scope_start declaration expr_statement expr ')' statement
|
||||||
{
|
{
|
||||||
if (!$4)
|
if (!$4)
|
||||||
hlsl_report_message(ctx, @4, HLSL_LEVEL_WARNING,
|
hlsl_warning(ctx, @4, "no expressions in for loop initializer");
|
||||||
"no expressions in for loop initializer");
|
|
||||||
$$ = create_loop(LOOP_FOR, $4, $5, $6, $8, @1);
|
$$ = create_loop(LOOP_FOR, $4, $5, $6, $8, @1);
|
||||||
hlsl_pop_scope(ctx);
|
hlsl_pop_scope(ctx);
|
||||||
}
|
}
|
||||||
@ -2528,7 +2522,7 @@ primary_expr:
|
|||||||
|
|
||||||
if (!(var = hlsl_get_var(ctx->cur_scope, $1)))
|
if (!(var = hlsl_get_var(ctx->cur_scope, $1)))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @1, HLSL_LEVEL_ERROR, "variable '%s' is not declared\n", $1);
|
hlsl_error(ctx, @1, "variable '%s' is not declared\n", $1);
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
if ((load = hlsl_new_var_load(var, @1)))
|
if ((load = hlsl_new_var_load(var, @1)))
|
||||||
@ -2552,7 +2546,7 @@ postfix_expr:
|
|||||||
|
|
||||||
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
|
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR, "modifying a const expression");
|
hlsl_error(ctx, @2, "modifying a const expression");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
inc = hlsl_new_unary_expr(HLSL_IR_UNOP_POSTINC, node_from_list($1), @2);
|
inc = hlsl_new_unary_expr(HLSL_IR_UNOP_POSTINC, node_from_list($1), @2);
|
||||||
@ -2567,7 +2561,7 @@ postfix_expr:
|
|||||||
|
|
||||||
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
|
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR, "modifying a const expression");
|
hlsl_error(ctx, @2, "modifying a const expression");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
inc = hlsl_new_unary_expr(HLSL_IR_UNOP_POSTDEC, node_from_list($1), @2);
|
inc = hlsl_new_unary_expr(HLSL_IR_UNOP_POSTDEC, node_from_list($1), @2);
|
||||||
@ -2598,7 +2592,7 @@ postfix_expr:
|
|||||||
}
|
}
|
||||||
if (!$$)
|
if (!$$)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR, "invalid subscript %s", debugstr_a($3));
|
hlsl_error(ctx, @3, "invalid subscript %s", debugstr_a($3));
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2608,14 +2602,14 @@ postfix_expr:
|
|||||||
|
|
||||||
if (!(swizzle = get_swizzle(ctx, node, $3, &@3)))
|
if (!(swizzle = get_swizzle(ctx, node, $3, &@3)))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR, "invalid swizzle %s", debugstr_a($3));
|
hlsl_error(ctx, @3, "invalid swizzle %s", debugstr_a($3));
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
$$ = append_unop($1, &swizzle->node);
|
$$ = append_unop($1, &swizzle->node);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR, "invalid subscript %s", debugstr_a($3));
|
hlsl_error(ctx, @3, "invalid subscript %s", debugstr_a($3));
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2628,7 +2622,7 @@ postfix_expr:
|
|||||||
|
|
||||||
if (index->data_type->type != HLSL_CLASS_SCALAR)
|
if (index->data_type->type != HLSL_CLASS_SCALAR)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR, "array index is not scalar");
|
hlsl_error(ctx, @3, "array index is not scalar");
|
||||||
hlsl_free_instr_list($1);
|
hlsl_free_instr_list($1);
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
@ -2653,19 +2647,19 @@ postfix_expr:
|
|||||||
|
|
||||||
if ($1)
|
if ($1)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @1, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @1,
|
||||||
"unexpected modifier on a constructor\n");
|
"unexpected modifier on a constructor\n");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
if ($2->type > HLSL_CLASS_LAST_NUMERIC)
|
if ($2->type > HLSL_CLASS_LAST_NUMERIC)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @2,
|
||||||
"constructors may only be used with numeric data types\n");
|
"constructors may only be used with numeric data types\n");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
if ($2->dimx * $2->dimy != initializer_size(&$4))
|
if ($2->dimx * $2->dimy != initializer_size(&$4))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @4, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, @4,
|
||||||
"expected %u components in constructor, but got %u\n",
|
"expected %u components in constructor, but got %u\n",
|
||||||
$2->dimx * $2->dimy, initializer_size(&$4));
|
$2->dimx * $2->dimy, initializer_size(&$4));
|
||||||
YYABORT;
|
YYABORT;
|
||||||
@ -2684,7 +2678,7 @@ postfix_expr:
|
|||||||
|
|
||||||
if (arg->data_type->type == HLSL_CLASS_OBJECT)
|
if (arg->data_type->type == HLSL_CLASS_OBJECT)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, arg->loc, HLSL_LEVEL_ERROR, "invalid constructor argument");
|
hlsl_error(ctx, arg->loc, "invalid constructor argument");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
width = hlsl_type_component_count(arg->data_type);
|
width = hlsl_type_component_count(arg->data_type);
|
||||||
@ -2717,7 +2711,7 @@ unary_expr:
|
|||||||
{
|
{
|
||||||
if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
|
if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @1, HLSL_LEVEL_ERROR, "modifying a const expression");
|
hlsl_error(ctx, @1, "modifying a const expression");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
$$ = append_unop($2, hlsl_new_unary_expr(HLSL_IR_UNOP_PREINC, node_from_list($2), @1));
|
$$ = append_unop($2, hlsl_new_unary_expr(HLSL_IR_UNOP_PREINC, node_from_list($2), @1));
|
||||||
@ -2726,7 +2720,7 @@ unary_expr:
|
|||||||
{
|
{
|
||||||
if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
|
if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @1, HLSL_LEVEL_ERROR, "modifying a const expression");
|
hlsl_error(ctx, @1, "modifying a const expression");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
$$ = append_unop($2, hlsl_new_unary_expr(HLSL_IR_UNOP_PREDEC, node_from_list($2), @1));
|
$$ = append_unop($2, hlsl_new_unary_expr(HLSL_IR_UNOP_PREDEC, node_from_list($2), @1));
|
||||||
@ -2750,7 +2744,7 @@ unary_expr:
|
|||||||
|
|
||||||
if ($2)
|
if ($2)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR, "unexpected modifier in a cast");
|
hlsl_error(ctx, @3, "unexpected modifier in a cast");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2761,7 +2755,7 @@ unary_expr:
|
|||||||
|
|
||||||
if (!compatible_data_types(src_type, dst_type))
|
if (!compatible_data_types(src_type, dst_type))
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @3, HLSL_LEVEL_ERROR, "can't cast from %s to %s",
|
hlsl_error(ctx, @3, "can't cast from %s to %s",
|
||||||
debug_hlsl_type(src_type), debug_hlsl_type(dst_type));
|
debug_hlsl_type(src_type), debug_hlsl_type(dst_type));
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
@ -2905,7 +2899,7 @@ assignment_expr:
|
|||||||
|
|
||||||
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST)
|
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, @2, HLSL_LEVEL_ERROR, "l-value is const");
|
hlsl_error(ctx, @2, "l-value is const");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
list_move_tail($3, $1);
|
list_move_tail($3, $1);
|
||||||
@ -3129,7 +3123,7 @@ int hlsl_parser_compile(struct hlsl_ctx *ctx, const char *entrypoint)
|
|||||||
if (!hlsl_type_is_void(entry_func->return_type)
|
if (!hlsl_type_is_void(entry_func->return_type)
|
||||||
&& entry_func->return_type->type != HLSL_CLASS_STRUCT && !entry_func->semantic)
|
&& entry_func->return_type->type != HLSL_CLASS_STRUCT && !entry_func->semantic)
|
||||||
{
|
{
|
||||||
hlsl_report_message(ctx, entry_func->loc, HLSL_LEVEL_ERROR,
|
hlsl_error(ctx, entry_func->loc,
|
||||||
"entry point \"%s\" is missing a return value semantic", entry_func->func->name);
|
"entry point \"%s\" is missing a return value semantic", entry_func->func->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user