vkd3d-shader/hlsl: Pass a vkd3d_shader_location pointer to message reporting functions.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@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-12-01 17:14:57 +01:00 committed by Alexandre Julliard
parent a33439f1a0
commit 943bd2fede
7 changed files with 144 additions and 144 deletions

View File

@ -22,40 +22,40 @@
#include "hlsl.h" #include "hlsl.h"
#include <stdio.h> #include <stdio.h>
void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc,
enum vkd3d_shader_log_level level, const char *fmt, ...) enum vkd3d_shader_log_level level, const char *fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vkd3d_shader_vnote(ctx->message_context, &loc, level, fmt, args); vkd3d_shader_vnote(ctx->message_context, loc, level, fmt, args);
va_end(args); va_end(args);
} }
void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc,
enum vkd3d_shader_error error, const char *fmt, ...) enum vkd3d_shader_error error, const char *fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vkd3d_shader_verror(ctx->message_context, &loc, error, fmt, args); vkd3d_shader_verror(ctx->message_context, loc, error, fmt, args);
va_end(args); va_end(args);
if (!ctx->result) if (!ctx->result)
ctx->result = VKD3D_ERROR_INVALID_SHADER; ctx->result = VKD3D_ERROR_INVALID_SHADER;
} }
void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc,
enum vkd3d_shader_error error, const char *fmt, ...) enum vkd3d_shader_error error, const char *fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vkd3d_shader_vwarning(ctx->message_context, &loc, error, fmt, args); vkd3d_shader_vwarning(ctx->message_context, loc, error, fmt, args);
va_end(args); va_end(args);
} }
void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...) void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt, ...)
{ {
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
va_list args; va_list args;
@ -64,7 +64,7 @@ void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, co
string = hlsl_get_string_buffer(ctx); string = hlsl_get_string_buffer(ctx);
vkd3d_string_buffer_printf(string, "Aborting due to not yet implemented feature: "); vkd3d_string_buffer_printf(string, "Aborting due to not yet implemented feature: ");
vkd3d_string_buffer_vprintf(string, fmt, args); vkd3d_string_buffer_vprintf(string, fmt, args);
vkd3d_shader_error(ctx->message_context, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED, "%s", string->buffer); vkd3d_shader_error(ctx->message_context, loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED, "%s", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
va_end(args); va_end(args);
@ -1960,7 +1960,7 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
{ {
const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name}; const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name};
hlsl_error(&ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, hlsl_error(&ctx, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED,
"Entry point \"%s\" is not defined.", entry_point); "Entry point \"%s\" is not defined.", entry_point);
hlsl_ctx_cleanup(&ctx); hlsl_ctx_cleanup(&ctx);
return VKD3D_ERROR_INVALID_SHADER; return VKD3D_ERROR_INVALID_SHADER;

View File

@ -728,13 +728,13 @@ struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct
struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var,
const struct vkd3d_shader_location loc); const struct vkd3d_shader_location loc);
void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc,
enum vkd3d_shader_error error, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5); enum vkd3d_shader_error error, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5);
void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc,
const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4); const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4);
void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc,
enum vkd3d_shader_error error, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5); enum vkd3d_shader_error error, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5);
void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc,
enum vkd3d_shader_log_level level, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5); enum vkd3d_shader_log_level level, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5);
void hlsl_push_scope(struct hlsl_ctx *ctx); void hlsl_push_scope(struct hlsl_ctx *ctx);

View File

@ -65,7 +65,7 @@ ANY (.)
{RESERVED4} { {RESERVED4} {
struct hlsl_ctx *ctx = yyget_extra(yyscanner); struct hlsl_ctx *ctx = yyget_extra(yyscanner);
hlsl_error(ctx, *yylloc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, hlsl_error(ctx, yylloc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
"Reserved keyword \"%s\" used.", yytext); "Reserved keyword \"%s\" used.", yytext);
} }

View File

@ -111,7 +111,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_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "%s", s); hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "%s", s);
} }
static struct hlsl_ir_node *node_from_list(struct list *list) static struct hlsl_ir_node *node_from_list(struct list *list)
@ -137,7 +137,7 @@ static void destroy_instr_list(struct list *list)
static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct vkd3d_shader_location loc) static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct vkd3d_shader_location loc)
{ {
if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK) if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"'row_major' and 'column_major' modifiers are only allowed for matrices."); "'row_major' and 'column_major' modifiers are only allowed for matrices.");
} }
@ -281,7 +281,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
src_string = hlsl_type_to_string(ctx, src_type); src_string = hlsl_type_to_string(ctx, src_type);
dst_string = hlsl_type_to_string(ctx, dst_type); dst_string = hlsl_type_to_string(ctx, dst_type);
if (src_string && dst_string) if (src_string && dst_string)
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Can't implicitly convert from %s to %s.", src_string->buffer, dst_string->buffer); "Can't implicitly convert from %s to %s.", src_string->buffer, dst_string->buffer);
hlsl_release_string_buffer(ctx, src_string); hlsl_release_string_buffer(ctx, src_string);
hlsl_release_string_buffer(ctx, dst_string); hlsl_release_string_buffer(ctx, dst_string);
@ -289,7 +289,7 @@ 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) if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy)
hlsl_warning(ctx, *loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.", hlsl_warning(ctx, loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.",
src_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix"); src_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix");
if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc))) if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc)))
@ -305,14 +305,14 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, mod))) if ((string = hlsl_modifiers_to_string(ctx, mod)))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifier '%s' was already specified.", string->buffer); "Modifier '%s' was already specified.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
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_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"'row_major' and 'column_major' modifiers are mutually exclusive."); "'row_major' and 'column_major' modifiers are mutually exclusive.");
return modifiers; return modifiers;
} }
@ -516,7 +516,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
} }
else if (ctx->cur_function->return_var) else if (ctx->cur_function->return_var)
{ {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value."); hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value.");
return NULL; return NULL;
} }
@ -601,9 +601,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_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Scalar expressions cannot be array-indexed."); hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Scalar expressions cannot be array-indexed.");
else else
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Expression cannot be array-indexed."); hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Expression cannot be array-indexed.");
return NULL; return NULL;
} }
@ -661,7 +661,7 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_
*modifiers &= ~HLSL_TYPE_MODIFIERS_MASK; *modifiers &= ~HLSL_TYPE_MODIFIERS_MASK;
if ((new_type->modifiers & HLSL_MODIFIER_ROW_MAJOR) && (new_type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)) if ((new_type->modifiers & HLSL_MODIFIER_ROW_MAJOR) && (new_type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"'row_major' and 'column_major' modifiers are mutually exclusive."); "'row_major' and 'column_major' modifiers are mutually exclusive.");
return new_type; return new_type;
@ -696,7 +696,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_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field."); hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field.");
free_parse_initializer(&v->initializer); free_parse_initializer(&v->initializer);
} }
list_add_tail(list, &field->entry); list_add_tail(list, &field->entry);
@ -739,12 +739,12 @@ 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_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"'row_major' and 'column_major' modifiers are mutually exclusive."); "'row_major' and 'column_major' modifiers are mutually exclusive.");
ret = hlsl_scope_add_type(ctx->cur_scope, type); ret = hlsl_scope_add_type(ctx->cur_scope, type);
if (!ret) if (!ret)
hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Type '%s' is already defined.", v->name); "Type '%s' is already defined.", v->name);
vkd3d_free(v); vkd3d_free(v);
} }
@ -761,7 +761,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list,
assert(param->type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK); assert(param->type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK);
if ((param->modifiers & HLSL_STORAGE_OUT) && (param->modifiers & HLSL_STORAGE_UNIFORM)) if ((param->modifiers & HLSL_STORAGE_OUT) && (param->modifiers & HLSL_STORAGE_UNIFORM))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Parameter '%s' is declared as both \"out\" and \"uniform\".", param->name); "Parameter '%s' is declared as both \"out\" and \"uniform\".", param->name);
if (!(var = hlsl_new_var(ctx, param->name, param->type, loc, &param->semantic, param->modifiers, &param->reg_reservation))) if (!(var = hlsl_new_var(ctx, param->name, param->type, loc, &param->semantic, param->modifiers, &param->reg_reservation)))
@ -928,7 +928,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, t1))) if ((string = hlsl_type_to_string(ctx, t1)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Expression of type \"%s\" cannot be used in a numeric expression.", string->buffer); "Expression of type \"%s\" cannot be used in a numeric expression.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
return false; return false;
@ -939,7 +939,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, t2))) if ((string = hlsl_type_to_string(ctx, t2)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Expression of type \"%s\" cannot be used in a numeric expression.", string->buffer); "Expression of type \"%s\" cannot be used in a numeric expression.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
return false; return false;
@ -951,7 +951,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct
struct vkd3d_string_buffer *t2_string = hlsl_type_to_string(ctx, t2); struct vkd3d_string_buffer *t2_string = hlsl_type_to_string(ctx, t2);
if (t1_string && t2_string) if (t1_string && t2_string)
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Expression data types \"%s\" and \"%s\" are incompatible.", "Expression data types \"%s\" and \"%s\" are incompatible.",
t1_string->buffer, t2_string->buffer); t1_string->buffer, t2_string->buffer);
hlsl_release_string_buffer(ctx, t1_string); hlsl_release_string_buffer(ctx, t1_string);
@ -1191,7 +1191,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
{ {
if (lhs->type == HLSL_IR_EXPR && hlsl_ir_expr(lhs)->op == HLSL_OP1_CAST) if (lhs->type == HLSL_IR_EXPR && hlsl_ir_expr(lhs)->op == HLSL_OP1_CAST)
{ {
hlsl_fixme(ctx, lhs->loc, "Cast on the LHS."); hlsl_fixme(ctx, &lhs->loc, "Cast on the LHS.");
vkd3d_free(store); vkd3d_free(store);
return NULL; return NULL;
} }
@ -1201,11 +1201,11 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
unsigned int width, s = swizzle->swizzle; unsigned int width, s = swizzle->swizzle;
if (lhs->data_type->type == HLSL_CLASS_MATRIX) if (lhs->data_type->type == HLSL_CLASS_MATRIX)
hlsl_fixme(ctx, lhs->loc, "Matrix assignment with a writemask."); hlsl_fixme(ctx, &lhs->loc, "Matrix assignment with a writemask.");
if (!invert_swizzle(&s, &writemask, &width)) if (!invert_swizzle(&s, &writemask, &width))
{ {
hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask."); hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask.");
vkd3d_free(store); vkd3d_free(store);
return NULL; return NULL;
} }
@ -1222,7 +1222,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
} }
else else
{ {
hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue."); hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue.");
vkd3d_free(store); vkd3d_free(store);
return NULL; return NULL;
} }
@ -1251,7 +1251,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem
struct hlsl_ir_constant *one; struct hlsl_ir_constant *one;
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST) if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST)
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST,
"Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in"); "Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
if (!(one = hlsl_new_uint_constant(ctx, 1, loc))) if (!(one = hlsl_new_uint_constant(ctx, 1, loc)))
@ -1286,7 +1286,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_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
"Expected %u components in initializer, but got %u.", "Expected %u components in initializer, but got %u.",
hlsl_type_component_count(type), initializer_size(initializer)); hlsl_type_component_count(type), initializer_size(initializer));
free_parse_initializer(initializer); free_parse_initializer(initializer);
@ -1317,7 +1317,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
} }
else else
{ {
hlsl_fixme(ctx, node->loc, "Implicit cast in structure initializer."); hlsl_fixme(ctx, &node->loc, "Implicit cast in structure initializer.");
} }
} }
@ -1381,7 +1381,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
local = false; local = false;
if ((modifiers & HLSL_STORAGE_UNIFORM) && (modifiers & HLSL_STORAGE_STATIC)) if ((modifiers & HLSL_STORAGE_UNIFORM) && (modifiers & HLSL_STORAGE_STATIC))
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Variable '%s' is declared as both \"uniform\" and \"static\".", var->name); "Variable '%s' is declared as both \"uniform\" and \"static\".", var->name);
/* Mark it as uniform. We need to do this here since synthetic /* Mark it as uniform. We need to do this here since synthetic
@ -1392,9 +1392,9 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if ((func = hlsl_get_func_decl(ctx, var->name))) if ((func = hlsl_get_func_decl(ctx, var->name)))
{ {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"'%s' is already defined as a function.", var->name); "'%s' is already defined as a function.", var->name);
hlsl_note(ctx, func->loc, VKD3D_SHADER_LOG_ERROR, hlsl_note(ctx, &func->loc, VKD3D_SHADER_LOG_ERROR,
"'%s' was previously defined here.", var->name); "'%s' was previously defined here.", var->name);
} }
} }
@ -1408,19 +1408,19 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, modifiers & invalid))) if ((string = hlsl_modifiers_to_string(ctx, modifiers & invalid)))
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers '%s' are not allowed on local variables.", string->buffer); "Modifiers '%s' are not allowed on local variables.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
} }
if (var->semantic.name) if (var->semantic.name)
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
"Semantics are not allowed on local variables."); "Semantics are not allowed on local variables.");
} }
if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count
&& !(modifiers & (HLSL_STORAGE_STATIC | HLSL_STORAGE_UNIFORM))) && !(modifiers & (HLSL_STORAGE_STATIC | HLSL_STORAGE_UNIFORM)))
{ {
hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER, hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER,
"Const variable \"%s\" is missing an initializer.", var->name); "Const variable \"%s\" is missing an initializer.", var->name);
hlsl_free_var(var); hlsl_free_var(var);
vkd3d_free(v); vkd3d_free(v);
@ -1431,9 +1431,9 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
{ {
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name); struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Variable \"%s\" was already declared in this scope.", var->name); "Variable \"%s\" was already declared in this scope.", var->name);
hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name); hlsl_note(ctx, &old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name);
hlsl_free_var(var); hlsl_free_var(var);
vkd3d_free(v); vkd3d_free(v);
continue; continue;
@ -1449,7 +1449,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_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
"Expected %u components in numeric initializer, but got %u.", "Expected %u components in numeric initializer, but got %u.",
type->dimx * type->dimy, size); type->dimx * type->dimy, size);
free_parse_initializer(&v->initializer); free_parse_initializer(&v->initializer);
@ -1460,7 +1460,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_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
"Expected %u components in initializer, but got %u.", hlsl_type_component_count(type), size); "Expected %u components in initializer, but got %u.", hlsl_type_component_count(type), size);
free_parse_initializer(&v->initializer); free_parse_initializer(&v->initializer);
vkd3d_free(v); vkd3d_free(v);
@ -1482,14 +1482,14 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
} }
if (v->arrays.count) if (v->arrays.count)
{ {
hlsl_fixme(ctx, v->loc, "Array initializer."); hlsl_fixme(ctx, &v->loc, "Array initializer.");
free_parse_initializer(&v->initializer); free_parse_initializer(&v->initializer);
vkd3d_free(v); vkd3d_free(v);
continue; continue;
} }
if (v->initializer.args_count > 1) if (v->initializer.args_count > 1)
{ {
hlsl_fixme(ctx, v->loc, "Complex initializer."); hlsl_fixme(ctx, &v->loc, "Complex initializer.");
free_parse_initializer(&v->initializer); free_parse_initializer(&v->initializer);
vkd3d_free(v); vkd3d_free(v);
continue; continue;
@ -1711,7 +1711,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
if ((decl = find_function_call(ctx, name, params))) if ((decl = find_function_call(ctx, name, params)))
{ {
hlsl_fixme(ctx, loc, "Call to user-defined function \"%s\".", name); hlsl_fixme(ctx, &loc, "Call to user-defined function \"%s\".", name);
free_parse_initializer(params); free_parse_initializer(params);
return NULL; return NULL;
} }
@ -1720,7 +1720,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
{ {
if (intrinsic->param_count >= 0 && params->args_count != intrinsic->param_count) if (intrinsic->param_count >= 0 && params->args_count != intrinsic->param_count)
{ {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
"Wrong number of arguments to function '%s': expected %u, but got %u.\n", "Wrong number of arguments to function '%s': expected %u, but got %u.\n",
name, intrinsic->param_count, params->args_count); name, intrinsic->param_count, params->args_count);
free_parse_initializer(params); free_parse_initializer(params);
@ -1738,7 +1738,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, params->args[i]->data_type))) if ((string = hlsl_type_to_string(ctx, params->args[i]->data_type)))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Wrong type for argument %u of '%s': expected a numeric type, but got '%s'.\n", "Wrong type for argument %u of '%s': expected a numeric type, but got '%s'.\n",
i + 1, name, string->buffer); i + 1, name, string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
@ -1756,7 +1756,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
} }
else else
{ {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Function \"%s\" is not defined.", name); hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Function \"%s\" is not defined.", name);
free_parse_initializer(params); free_parse_initializer(params);
return NULL; return NULL;
} }
@ -1775,7 +1775,7 @@ static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type
char name[23]; char name[23];
if (type->type == HLSL_CLASS_MATRIX) if (type->type == HLSL_CLASS_MATRIX)
hlsl_fixme(ctx, loc, "Matrix constructor."); hlsl_fixme(ctx, &loc, "Matrix constructor.");
sprintf(name, "<constructor-%x>", counter++); sprintf(name, "<constructor-%x>", counter++);
if (!(var = hlsl_new_synthetic_var(ctx, name, type, loc))) if (!(var = hlsl_new_synthetic_var(ctx, name, type, loc)))
@ -1791,7 +1791,7 @@ static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, arg->data_type))) if ((string = hlsl_type_to_string(ctx, arg->data_type)))
hlsl_error(ctx, arg->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, &arg->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Invalid type %s for constructor argument.", string->buffer); "Invalid type %s for constructor argument.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
continue; continue;
@ -1836,7 +1836,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, object_type))) if ((string = hlsl_type_to_string(ctx, object_type)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Type '%s' does not have methods.", string->buffer); "Type '%s' does not have methods.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
return false; return false;
@ -1853,7 +1853,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
if (params->args_count < 1 || params->args_count > 3) if (params->args_count < 1 || params->args_count > 3)
{ {
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
"Wrong number of arguments to method 'Load': expected 1, 2, or 3, but got %u.", params->args_count); "Wrong number of arguments to method 'Load': expected 1, 2, or 3, but got %u.", params->args_count);
return false; return false;
} }
@ -1881,7 +1881,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
if (params->args_count != 2 && params->args_count != 3) if (params->args_count != 2 && params->args_count != 3)
{ {
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
"Wrong number of arguments to method 'Sample': expected 2 or 3, but got %u.", params->args_count); "Wrong number of arguments to method 'Sample': expected 2 or 3, but got %u.", params->args_count);
return false; return false;
} }
@ -1895,7 +1895,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, sampler_type))) if ((string = hlsl_type_to_string(ctx, sampler_type)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Wrong type for argument 0 of Sample(): expected 'sampler', but got '%s'.", string->buffer); "Wrong type for argument 0 of Sample(): expected 'sampler', but got '%s'.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
return false; return false;
@ -1920,7 +1920,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, object_type))) if ((string = hlsl_type_to_string(ctx, object_type)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED,
"Method '%s' is not defined on type '%s'.", name, string->buffer); "Method '%s' is not defined on type '%s'.", name, string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
return false; return false;
@ -2162,16 +2162,16 @@ hlsl_prog:
{ {
if (decl->has_body && $2.decl->has_body) if (decl->has_body && $2.decl->has_body)
{ {
hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, hlsl_error(ctx, &$2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Function \"%s\" is already defined.", $2.name); "Function \"%s\" is already defined.", $2.name);
hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously defined here.", $2.name); hlsl_note(ctx, &decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously defined here.", $2.name);
YYABORT; YYABORT;
} }
else if (!hlsl_types_are_equal(decl->return_type, $2.decl->return_type)) else if (!hlsl_types_are_equal(decl->return_type, $2.decl->return_type))
{ {
hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, hlsl_error(ctx, &$2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Function \"%s\" was already declared with a different return type.", $2.name); "Function \"%s\" was already declared with a different return type.", $2.name);
hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", $2.name); hlsl_note(ctx, &decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", $2.name);
YYABORT; YYABORT;
} }
} }
@ -2182,7 +2182,7 @@ hlsl_prog:
| hlsl_prog declaration_statement | hlsl_prog declaration_statement
{ {
if (!list_empty($2)) if (!list_empty($2))
hlsl_fixme(ctx, @2, "Uniform initializer."); hlsl_fixme(ctx, &@2, "Uniform initializer.");
destroy_instr_list($2); destroy_instr_list($2);
} }
| hlsl_prog preproc_directive | hlsl_prog preproc_directive
@ -2192,7 +2192,7 @@ buffer_declaration:
buffer_type any_identifier colon_attribute buffer_type any_identifier colon_attribute
{ {
if ($3.semantic.name) if ($3.semantic.name)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers."); hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers.");
if (!(ctx->cur_buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2))) if (!(ctx->cur_buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2)))
YYABORT; YYABORT;
@ -2249,10 +2249,10 @@ struct_declaration:
if (!$3) if (!$3)
{ {
if (!$2->name) if (!$2->name)
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
"Anonymous struct type must declare a variable."); "Anonymous struct type must declare a variable.");
if (modifiers) if (modifiers)
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers are not allowed on struct type declarations."); "Modifiers are not allowed on struct type declarations.");
} }
@ -2274,14 +2274,14 @@ named_struct_spec:
if (hlsl_get_var(ctx->cur_scope, $2)) if (hlsl_get_var(ctx->cur_scope, $2))
{ {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is already declared as a variable.", $2); hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is already declared as a variable.", $2);
YYABORT; YYABORT;
} }
ret = hlsl_scope_add_type(ctx->cur_scope, $$); ret = hlsl_scope_add_type(ctx->cur_scope, $$);
if (!ret) if (!ret)
{ {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Struct \"%s\" is already defined.", $2); hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Struct \"%s\" is already defined.", $2);
YYABORT; YYABORT;
} }
} }
@ -2312,9 +2312,9 @@ fields_list:
{ {
if ((existing = get_struct_field($$, field->name))) if ((existing = get_struct_field($$, field->name)))
{ {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Field \"%s\" is already defined.", field->name); "Field \"%s\" is already defined.", field->name);
hlsl_note(ctx, existing->loc, VKD3D_SHADER_LOG_ERROR, hlsl_note(ctx, &existing->loc, VKD3D_SHADER_LOG_ERROR,
"'%s' was previously defined here.", field->name); "'%s' was previously defined here.", field->name);
vkd3d_free(field); vkd3d_free(field);
} }
@ -2343,7 +2343,7 @@ field:
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, modifiers))) if ((string = hlsl_modifiers_to_string(ctx, modifiers)))
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers '%s' are not allowed on struct fields.", string->buffer); "Modifiers '%s' are not allowed on struct fields.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
} }
@ -2373,21 +2373,21 @@ func_prototype:
if ($1) if ($1)
{ {
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers are not allowed on functions."); "Modifiers are not allowed on functions.");
YYABORT; YYABORT;
} }
if ((var = hlsl_get_var(ctx->globals, $3))) if ((var = hlsl_get_var(ctx->globals, $3)))
{ {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"\"%s\" is already declared as a variable.", $3); "\"%s\" is already declared as a variable.", $3);
hlsl_note(ctx, var->loc, VKD3D_SHADER_LOG_ERROR, hlsl_note(ctx, &var->loc, VKD3D_SHADER_LOG_ERROR,
"\"%s\" was previously declared here.", $3); "\"%s\" was previously declared here.", $3);
YYABORT; YYABORT;
} }
if (hlsl_types_are_equal($2, ctx->builtin_types.Void) && $7.semantic.name) if (hlsl_types_are_equal($2, ctx->builtin_types.Void) && $7.semantic.name)
{ {
hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, hlsl_error(ctx, &@7, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
"Semantics are not allowed on void functions."); "Semantics are not allowed on void functions.");
} }
@ -2494,7 +2494,7 @@ param_list:
$$ = $1; $$ = $1;
if (!add_func_parameter(ctx, $$, &$3, @3)) if (!add_func_parameter(ctx, $$, &$3, @3))
{ {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Parameter \"%s\" is already declared.", $3.name); "Parameter \"%s\" is already declared.", $3.name);
YYABORT; YYABORT;
} }
@ -2529,7 +2529,7 @@ input_mods:
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, $2))) if ((string = hlsl_modifiers_to_string(ctx, $2)))
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifier \"%s\" was already specified.", string->buffer); "Modifier \"%s\" was already specified.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
YYABORT; YYABORT;
@ -2578,14 +2578,14 @@ type:
string = hlsl_type_to_string(ctx, $3); string = hlsl_type_to_string(ctx, $3);
if (string) if (string)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Vector base type %s is not scalar.", string->buffer); "Vector base type %s is not scalar.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
YYABORT; YYABORT;
} }
if ($5 < 1 || $5 > 4) if ($5 < 1 || $5 > 4)
{ {
hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, hlsl_error(ctx, &@5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
"Vector size %d is not between 1 and 4.", $5); "Vector size %d is not between 1 and 4.", $5);
YYABORT; YYABORT;
} }
@ -2604,20 +2604,20 @@ type:
string = hlsl_type_to_string(ctx, $3); string = hlsl_type_to_string(ctx, $3);
if (string) if (string)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Matrix base type %s is not scalar.", string->buffer); "Matrix base type %s is not scalar.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
YYABORT; YYABORT;
} }
if ($5 < 1 || $5 > 4) if ($5 < 1 || $5 > 4)
{ {
hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, hlsl_error(ctx, &@5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
"Matrix row count %d is not between 1 and 4.", $5); "Matrix row count %d is not between 1 and 4.", $5);
YYABORT; YYABORT;
} }
if ($7 < 1 || $7 > 4) if ($7 < 1 || $7 > 4)
{ {
hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, hlsl_error(ctx, &@7, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
"Matrix column count %d is not between 1 and 4.", $7); "Matrix column count %d is not between 1 and 4.", $7);
YYABORT; YYABORT;
} }
@ -2668,7 +2668,7 @@ type:
string = hlsl_type_to_string(ctx, $3); string = hlsl_type_to_string(ctx, $3);
if (string) if (string)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Texture data type %s is not scalar or vector.\n", string->buffer); "Texture data type %s is not scalar or vector.\n", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
} }
@ -2683,7 +2683,7 @@ 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_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" redefined as a structure.", $2); hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" redefined as a structure.", $2);
vkd3d_free($2); vkd3d_free($2);
} }
@ -2706,7 +2706,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_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Storage modifiers are not allowed on typedefs."); "Storage modifiers are 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);
@ -2828,7 +2828,7 @@ arrays:
if (!size) if (!size)
{ {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
"Array size is not a positive integer constant."); "Array size is not a positive integer constant.");
vkd3d_free($$.sizes); vkd3d_free($$.sizes);
YYABORT; YYABORT;
@ -2836,7 +2836,7 @@ arrays:
if (size > 65536) if (size > 65536)
{ {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
"Array size %u is not between 1 and 65536.", size); "Array size %u is not between 1 and 65536.", size);
vkd3d_free($$.sizes); vkd3d_free($$.sizes);
YYABORT; YYABORT;
@ -3001,7 +3001,7 @@ selection_statement:
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, condition->data_type))) if ((string = hlsl_type_to_string(ctx, condition->data_type)))
hlsl_error(ctx, instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, &instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"if condition type %s is not scalar.", string->buffer); "if condition type %s is not scalar.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
} }
@ -3103,7 +3103,7 @@ primary_expr:
if (!(var = hlsl_get_var(ctx->cur_scope, $1))) if (!(var = hlsl_get_var(ctx->cur_scope, $1)))
{ {
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable \"%s\" is not defined.", $1); hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable \"%s\" is not defined.", $1);
YYABORT; YYABORT;
} }
if (!(load = hlsl_new_var_load(ctx, var, @1))) if (!(load = hlsl_new_var_load(ctx, var, @1)))
@ -3137,7 +3137,7 @@ primary_expr:
} }
else else
{ {
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Identifier \"%s\" is not declared.\n", $1); hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Identifier \"%s\" is not declared.\n", $1);
YYABORT; YYABORT;
} }
} }
@ -3173,7 +3173,7 @@ postfix_expr:
if (!(field = get_struct_field(type->e.elements, $3))) if (!(field = get_struct_field(type->e.elements, $3)))
{ {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field \"%s\" is not defined.", $3); hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field \"%s\" is not defined.", $3);
YYABORT; YYABORT;
} }
@ -3187,7 +3187,7 @@ postfix_expr:
if (!(swizzle = get_swizzle(ctx, node, $3, &@3))) if (!(swizzle = get_swizzle(ctx, node, $3, &@3)))
{ {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle \"%s\".", $3); hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle \"%s\".", $3);
YYABORT; YYABORT;
} }
list_add_tail($1, &swizzle->node.entry); list_add_tail($1, &swizzle->node.entry);
@ -3195,7 +3195,7 @@ postfix_expr:
} }
else else
{ {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript \"%s\".", $3); hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript \"%s\".", $3);
YYABORT; YYABORT;
} }
} }
@ -3209,7 +3209,7 @@ postfix_expr:
if (index->data_type->type != HLSL_CLASS_SCALAR) if (index->data_type->type != HLSL_CLASS_SCALAR)
{ {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Array index is not scalar."); hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Array index is not scalar.");
destroy_instr_list($1); destroy_instr_list($1);
YYABORT; YYABORT;
} }
@ -3234,7 +3234,7 @@ postfix_expr:
{ {
if ($1) if ($1)
{ {
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers are not allowed on constructors."); "Modifiers are not allowed on constructors.");
free_parse_initializer(&$4); free_parse_initializer(&$4);
YYABORT; YYABORT;
@ -3244,7 +3244,7 @@ postfix_expr:
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, $2))) if ((string = hlsl_type_to_string(ctx, $2)))
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Constructor data type %s is not numeric.", string->buffer); "Constructor data type %s is not numeric.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
free_parse_initializer(&$4); free_parse_initializer(&$4);
@ -3252,7 +3252,7 @@ postfix_expr:
} }
if ($2->dimx * $2->dimy != initializer_size(&$4)) if ($2->dimx * $2->dimy != initializer_size(&$4))
{ {
hlsl_error(ctx, @4, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, hlsl_error(ctx, &@4, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
"Expected %u components in constructor, but got %u.", "Expected %u components in constructor, but got %u.",
$2->dimx * $2->dimy, initializer_size(&$4)); $2->dimx * $2->dimy, initializer_size(&$4));
free_parse_initializer(&$4); free_parse_initializer(&$4);
@ -3331,7 +3331,7 @@ unary_expr:
if ($2) if ($2)
{ {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers are not allowed on casts."); "Modifiers are not allowed on casts.");
YYABORT; YYABORT;
} }
@ -3347,7 +3347,7 @@ unary_expr:
src_string = hlsl_type_to_string(ctx, src_type); src_string = hlsl_type_to_string(ctx, src_type);
dst_string = hlsl_type_to_string(ctx, dst_type); dst_string = hlsl_type_to_string(ctx, dst_type);
if (src_string && dst_string) if (src_string && dst_string)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't cast from %s to %s.", hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't cast from %s to %s.",
src_string->buffer, dst_string->buffer); src_string->buffer, dst_string->buffer);
hlsl_release_string_buffer(ctx, src_string); hlsl_release_string_buffer(ctx, src_string);
hlsl_release_string_buffer(ctx, dst_string); hlsl_release_string_buffer(ctx, dst_string);
@ -3398,11 +3398,11 @@ shift_expr:
add_expr add_expr
| shift_expr OP_LEFTSHIFT add_expr | shift_expr OP_LEFTSHIFT add_expr
{ {
hlsl_fixme(ctx, @$, "Left shift."); hlsl_fixme(ctx, &@$, "Left shift.");
} }
| shift_expr OP_RIGHTSHIFT add_expr | shift_expr OP_RIGHTSHIFT add_expr
{ {
hlsl_fixme(ctx, @$, "Right shift."); hlsl_fixme(ctx, &@$, "Right shift.");
} }
relational_expr: relational_expr:
@ -3439,42 +3439,42 @@ bitand_expr:
equality_expr equality_expr
| bitand_expr '&' equality_expr | bitand_expr '&' equality_expr
{ {
hlsl_fixme(ctx, @$, "Bitwise AND."); hlsl_fixme(ctx, &@$, "Bitwise AND.");
} }
bitxor_expr: bitxor_expr:
bitand_expr bitand_expr
| bitxor_expr '^' bitand_expr | bitxor_expr '^' bitand_expr
{ {
hlsl_fixme(ctx, @$, "Bitwise XOR."); hlsl_fixme(ctx, &@$, "Bitwise XOR.");
} }
bitor_expr: bitor_expr:
bitxor_expr bitxor_expr
| bitor_expr '|' bitxor_expr | bitor_expr '|' bitxor_expr
{ {
hlsl_fixme(ctx, @$, "Bitwise OR."); hlsl_fixme(ctx, &@$, "Bitwise OR.");
} }
logicand_expr: logicand_expr:
bitor_expr bitor_expr
| logicand_expr OP_AND bitor_expr | logicand_expr OP_AND bitor_expr
{ {
hlsl_fixme(ctx, @$, "Logical AND."); hlsl_fixme(ctx, &@$, "Logical AND.");
} }
logicor_expr: logicor_expr:
logicand_expr logicand_expr
| logicor_expr OP_OR logicand_expr | logicor_expr OP_OR logicand_expr
{ {
hlsl_fixme(ctx, @$, "Logical OR."); hlsl_fixme(ctx, &@$, "Logical OR.");
} }
conditional_expr: conditional_expr:
logicor_expr logicor_expr
| logicor_expr '?' expr ':' assignment_expr | logicor_expr '?' expr ':' assignment_expr
{ {
hlsl_fixme(ctx, @$, "Ternary operator."); hlsl_fixme(ctx, &@$, "Ternary operator.");
} }
assignment_expr: assignment_expr:
@ -3486,7 +3486,7 @@ assignment_expr:
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST) if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST)
{ {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression."); hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT; YYABORT;
} }
list_move_tail($3, $1); list_move_tail($3, $1);

View File

@ -113,7 +113,7 @@ static void prepend_input_struct_copy(struct hlsl_ctx *ctx, struct list *instrs,
else if (field->semantic.name) else if (field->semantic.name)
prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic);
else else
hlsl_error(ctx, field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
"Field '%s' is missing a semantic.", field->name); "Field '%s' is missing a semantic.", field->name);
} }
} }
@ -184,7 +184,7 @@ static void append_output_struct_copy(struct hlsl_ctx *ctx, struct list *instrs,
else if (field->semantic.name) else if (field->semantic.name)
append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic);
else else
hlsl_error(ctx, field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
"Field '%s' is missing a semantic.", field->name); "Field '%s' is missing a semantic.", field->name);
} }
} }
@ -1365,7 +1365,7 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
if (!hlsl_sm1_usage_from_semantic(&var->semantic, &usage, &usage_idx)) if (!hlsl_sm1_usage_from_semantic(&var->semantic, &usage, &usage_idx))
{ {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
"Invalid semantic '%s'.", var->semantic.name); "Invalid semantic '%s'.", var->semantic.name);
return; return;
} }
@ -1382,7 +1382,7 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
if (!hlsl_sm4_usage_from_semantic(ctx, &var->semantic, output, &usage)) if (!hlsl_sm4_usage_from_semantic(ctx, &var->semantic, output, &usage))
{ {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
"Invalid semantic '%s'.", var->semantic.name); "Invalid semantic '%s'.", var->semantic.name);
return; return;
} }
@ -1473,9 +1473,9 @@ static void allocate_buffers(struct hlsl_ctx *ctx)
if (reserved_buffer && reserved_buffer != buffer) if (reserved_buffer && reserved_buffer != buffer)
{ {
hlsl_error(ctx, buffer->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, hlsl_error(ctx, &buffer->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS,
"Multiple buffers bound to cb%u.", buffer->reservation.index); "Multiple buffers bound to cb%u.", buffer->reservation.index);
hlsl_note(ctx, reserved_buffer->loc, VKD3D_SHADER_LOG_ERROR, hlsl_note(ctx, &reserved_buffer->loc, VKD3D_SHADER_LOG_ERROR,
"Buffer %s is already bound to cb%u.", reserved_buffer->name, buffer->reservation.index); "Buffer %s is already bound to cb%u.", reserved_buffer->name, buffer->reservation.index);
} }
@ -1495,7 +1495,7 @@ static void allocate_buffers(struct hlsl_ctx *ctx)
} }
else else
{ {
hlsl_error(ctx, buffer->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, hlsl_error(ctx, &buffer->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
"Constant buffers must be allocated to register type 'b'."); "Constant buffers must be allocated to register type 'b'.");
} }
} }
@ -1560,10 +1560,10 @@ static void allocate_objects(struct hlsl_ctx *ctx, enum hlsl_base_type type)
if (reserved_object && reserved_object != var) if (reserved_object && reserved_object != var)
{ {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS,
"Multiple objects bound to %c%u.", type_info->reg_name, "Multiple objects bound to %c%u.", type_info->reg_name,
var->reg_reservation.index); var->reg_reservation.index);
hlsl_note(ctx, reserved_object->loc, VKD3D_SHADER_LOG_ERROR, hlsl_note(ctx, &reserved_object->loc, VKD3D_SHADER_LOG_ERROR,
"Object '%s' is already bound to %c%u.", reserved_object->name, "Object '%s' is already bound to %c%u.", reserved_object->name,
type_info->reg_name, var->reg_reservation.index); type_info->reg_name, var->reg_reservation.index);
} }
@ -1587,7 +1587,7 @@ static void allocate_objects(struct hlsl_ctx *ctx, enum hlsl_base_type type)
struct vkd3d_string_buffer *type_string; struct vkd3d_string_buffer *type_string;
type_string = hlsl_type_to_string(ctx, var->data_type); type_string = hlsl_type_to_string(ctx, var->data_type);
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
"Object of type '%s' must be bound to register type '%c'.", "Object of type '%s' must be bound to register type '%c'.",
type_string->buffer, type_info->reg_name); type_string->buffer, type_info->reg_name);
hlsl_release_string_buffer(ctx, type_string); hlsl_release_string_buffer(ctx, type_string);
@ -1628,7 +1628,7 @@ unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl
if (hlsl_offset_from_deref(deref, &offset)) if (hlsl_offset_from_deref(deref, &offset))
return offset; return offset;
hlsl_fixme(ctx, deref->offset.node->loc, "Dereference with non-constant offset of type %s.", hlsl_fixme(ctx, &deref->offset.node->loc, "Dereference with non-constant offset of type %s.",
hlsl_node_type_to_string(deref->offset.node->type)); hlsl_node_type_to_string(deref->offset.node->type));
return 0; return 0;
@ -1679,7 +1679,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
else else
{ {
if (var->data_type->type != HLSL_CLASS_STRUCT && !var->semantic.name) if (var->data_type->type != HLSL_CLASS_STRUCT && !var->semantic.name)
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
"Parameter \"%s\" is missing a semantic.", var->name); "Parameter \"%s\" is missing a semantic.", var->name);
if (var->modifiers & HLSL_STORAGE_IN) if (var->modifiers & HLSL_STORAGE_IN)
@ -1691,7 +1691,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
if (entry_func->return_var) if (entry_func->return_var)
{ {
if (entry_func->return_var->data_type->type != HLSL_CLASS_STRUCT && !entry_func->return_var->semantic.name) if (entry_func->return_var->data_type->type != HLSL_CLASS_STRUCT && !entry_func->return_var->semantic.name)
hlsl_error(ctx, entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, hlsl_error(ctx, &entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
"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);
append_output_var_copy(ctx, &body->instrs, entry_func->return_var); append_output_var_copy(ctx, &body->instrs, entry_func->return_var);

View File

@ -617,7 +617,7 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
if (instr->data_type->base_type != HLSL_TYPE_FLOAT) if (instr->data_type->base_type != HLSL_TYPE_FLOAT)
{ {
/* These need to be lowered. */ /* These need to be lowered. */
hlsl_fixme(ctx, instr->loc, "SM1 non-float expression."); hlsl_fixme(ctx, &instr->loc, "SM1 non-float expression.");
return; return;
} }
@ -655,7 +655,7 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
break; break;
default: default:
hlsl_fixme(ctx, instr->loc, "SM1 \"%s\" expression.", debug_hlsl_expr_op(expr->op)); hlsl_fixme(ctx, &instr->loc, "SM1 \"%s\" expression.", debug_hlsl_expr_op(expr->op));
break; break;
} }
} }
@ -785,12 +785,12 @@ static void write_sm1_instructions(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b
if (instr->data_type->type == HLSL_CLASS_MATRIX) if (instr->data_type->type == HLSL_CLASS_MATRIX)
{ {
/* These need to be lowered. */ /* These need to be lowered. */
hlsl_fixme(ctx, instr->loc, "SM1 matrix expression."); hlsl_fixme(ctx, &instr->loc, "SM1 matrix expression.");
continue; continue;
} }
else if (instr->data_type->type == HLSL_CLASS_OBJECT) else if (instr->data_type->type == HLSL_CLASS_OBJECT)
{ {
hlsl_fixme(ctx, instr->loc, "Object copy.\n"); hlsl_fixme(ctx, &instr->loc, "Object copy.\n");
break; break;
} }

View File

@ -191,7 +191,7 @@ static void write_sm4_signature(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
default: default:
if ((string = hlsl_type_to_string(ctx, var->data_type))) if ((string = hlsl_type_to_string(ctx, var->data_type)))
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Invalid data type %s for semantic variable %s.", string->buffer, var->name); "Invalid data type %s for semantic variable %s.", string->buffer, var->name);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
put_u32(&buffer, D3D_REGISTER_COMPONENT_UNKNOWN); put_u32(&buffer, D3D_REGISTER_COMPONENT_UNKNOWN);
@ -1317,11 +1317,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
break; break;
case HLSL_TYPE_BOOL: case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, expr->node.loc, "Casts from bool to float are not implemented.\n"); hlsl_fixme(ctx, &expr->node.loc, "Casts from bool to float are not implemented.\n");
break; break;
case HLSL_TYPE_DOUBLE: case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, expr->node.loc, "Casts from double to float are not implemented.\n"); hlsl_fixme(ctx, &expr->node.loc, "Casts from double to float are not implemented.\n");
break; break;
default: default:
@ -1373,7 +1373,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
break; break;
default: default:
hlsl_fixme(ctx, expr->node.loc, "SM4 float \"%s\" expression.", debug_hlsl_expr_op(expr->op)); hlsl_fixme(ctx, &expr->node.loc, "SM4 float \"%s\" expression.", debug_hlsl_expr_op(expr->op));
break; break;
} }
break; break;
@ -1403,11 +1403,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
break; break;
case HLSL_TYPE_BOOL: case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, expr->node.loc, "SM4 cast from bool to int."); hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int.");
break; break;
case HLSL_TYPE_DOUBLE: case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, expr->node.loc, "SM4 cast from double to int."); hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int.");
break; break;
default: default:
@ -1417,7 +1417,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
} }
default: default:
hlsl_fixme(ctx, expr->node.loc, "SM4 int \"%s\" expression.", debug_hlsl_expr_op(expr->op)); hlsl_fixme(ctx, &expr->node.loc, "SM4 int \"%s\" expression.", debug_hlsl_expr_op(expr->op));
break; break;
} }
break; break;
@ -1447,11 +1447,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
break; break;
case HLSL_TYPE_BOOL: case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, expr->node.loc, "SM4 cast from bool to uint.\n"); hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n");
break; break;
case HLSL_TYPE_DOUBLE: case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, expr->node.loc, "SM4 cast from double to uint.\n"); hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n");
break; break;
default: default:
@ -1461,7 +1461,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
} }
default: default:
hlsl_fixme(ctx, expr->node.loc, "SM4 uint \"%s\" expression.\n", debug_hlsl_expr_op(expr->op)); hlsl_fixme(ctx, &expr->node.loc, "SM4 uint \"%s\" expression.\n", debug_hlsl_expr_op(expr->op));
break; break;
} }
break; break;
@ -1472,7 +1472,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, expr->node.data_type))) if ((string = hlsl_type_to_string(ctx, expr->node.data_type)))
hlsl_fixme(ctx, expr->node.loc, "SM4 %s expression.", string->buffer); hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", string->buffer);
hlsl_release_string_buffer(ctx, string); hlsl_release_string_buffer(ctx, string);
break; break;
} }
@ -1561,14 +1561,14 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
if (!load->sampler.var->is_uniform) if (!load->sampler.var->is_uniform)
{ {
hlsl_fixme(ctx, load->node.loc, "Sample using non-uniform sampler variable."); hlsl_fixme(ctx, &load->node.loc, "Sample using non-uniform sampler variable.");
return; return;
} }
} }
if (!load->resource.var->is_uniform) if (!load->resource.var->is_uniform)
{ {
hlsl_fixme(ctx, load->node.loc, "Load from non-uniform resource variable."); hlsl_fixme(ctx, &load->node.loc, "Load from non-uniform resource variable.");
return; return;
} }
@ -1580,7 +1580,7 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
case HLSL_RESOURCE_SAMPLE: case HLSL_RESOURCE_SAMPLE:
if (!load->sampler.var) if (!load->sampler.var)
hlsl_fixme(ctx, load->node.loc, "SM4 combined sample expression."); hlsl_fixme(ctx, &load->node.loc, "SM4 combined sample expression.");
write_sm4_sample(ctx, buffer, resource_type, &load->node, &load->resource, &load->sampler, coords); write_sm4_sample(ctx, buffer, resource_type, &load->node, &load->resource, &load->sampler, coords);
break; break;
} }
@ -1595,7 +1595,7 @@ static void write_sm4_store(struct hlsl_ctx *ctx,
if (store->lhs.var->data_type->type == HLSL_CLASS_MATRIX) if (store->lhs.var->data_type->type == HLSL_CLASS_MATRIX)
{ {
hlsl_fixme(ctx, store->node.loc, "Store to a matrix variable.\n"); hlsl_fixme(ctx, &store->node.loc, "Store to a matrix variable.\n");
return; return;
} }
@ -1649,7 +1649,7 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *
} }
else if (instr->data_type->type == HLSL_CLASS_OBJECT) else if (instr->data_type->type == HLSL_CLASS_OBJECT)
{ {
hlsl_fixme(ctx, instr->loc, "Object copy.\n"); hlsl_fixme(ctx, &instr->loc, "Object copy.\n");
break; break;
} }