mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Output the candidates for ambiguous function calls.
This commit is contained in:
parent
4ca4dc0b2a
commit
74365417ac
Notes:
Henri Verbeet
2024-12-03 14:56:39 +01:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1290
@ -3111,7 +3111,7 @@ const char *debug_hlsl_swizzle(uint32_t swizzle, unsigned int size)
|
|||||||
return vkd3d_dbg_sprintf(".%s", string);
|
return vkd3d_dbg_sprintf(".%s", string);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hlsl_dump_ir_function_decl(struct hlsl_ctx *ctx,
|
void hlsl_dump_ir_function_decl(struct hlsl_ctx *ctx,
|
||||||
struct vkd3d_string_buffer *buffer, const struct hlsl_ir_function_decl *f)
|
struct vkd3d_string_buffer *buffer, const struct hlsl_ir_function_decl *f)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -1437,6 +1437,8 @@ void hlsl_block_cleanup(struct hlsl_block *block);
|
|||||||
bool hlsl_clone_block(struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block);
|
bool hlsl_clone_block(struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block);
|
||||||
|
|
||||||
void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *func);
|
void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *func);
|
||||||
|
void hlsl_dump_ir_function_decl(struct hlsl_ctx *ctx,
|
||||||
|
struct vkd3d_string_buffer *buffer, const struct hlsl_ir_function_decl *f);
|
||||||
void hlsl_dump_var_default_values(const struct hlsl_ir_var *var);
|
void hlsl_dump_var_default_values(const struct hlsl_ir_var *var);
|
||||||
|
|
||||||
bool hlsl_state_block_add_entry(struct hlsl_state_block *state_block,
|
bool hlsl_state_block_add_entry(struct hlsl_state_block *state_block,
|
||||||
|
@ -3012,9 +3012,16 @@ static struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *ctx,
|
|||||||
const char *name, const struct parse_initializer *args, bool is_compile,
|
const char *name, const struct parse_initializer *args, bool is_compile,
|
||||||
const struct vkd3d_shader_location *loc)
|
const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_function_decl *decl, *compatible_match = NULL;
|
struct hlsl_ir_function_decl *decl;
|
||||||
|
struct vkd3d_string_buffer *s;
|
||||||
struct hlsl_ir_function *func;
|
struct hlsl_ir_function *func;
|
||||||
struct rb_entry *entry;
|
struct rb_entry *entry;
|
||||||
|
size_t i;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct hlsl_ir_function_decl **candidates;
|
||||||
|
size_t count, capacity;
|
||||||
|
} candidates = {0};
|
||||||
|
|
||||||
if (!(entry = rb_get(&ctx->functions, name)))
|
if (!(entry = rb_get(&ctx->functions, name)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3022,18 +3029,41 @@ static struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *ctx,
|
|||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(decl, &func->overloads, struct hlsl_ir_function_decl, entry)
|
LIST_FOR_EACH_ENTRY(decl, &func->overloads, struct hlsl_ir_function_decl, entry)
|
||||||
{
|
{
|
||||||
if (func_is_compatible_match(ctx, decl, is_compile, args))
|
if (!func_is_compatible_match(ctx, decl, is_compile, args))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!(hlsl_array_reserve(ctx, (void **)&candidates.candidates,
|
||||||
|
&candidates.capacity, candidates.count + 1, sizeof(decl))))
|
||||||
{
|
{
|
||||||
if (compatible_match)
|
vkd3d_free(candidates.candidates);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
candidates.candidates[candidates.count++] = decl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!candidates.count)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (candidates.count > 1)
|
||||||
|
{
|
||||||
|
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_AMBIGUOUS_CALL, "Ambiguous function call.");
|
||||||
|
if ((s = hlsl_get_string_buffer(ctx)))
|
||||||
|
{
|
||||||
|
hlsl_note(ctx, loc, VKD3D_SHADER_LOG_ERROR, "Candidates are:");
|
||||||
|
for (i = 0; i < candidates.count; ++i)
|
||||||
{
|
{
|
||||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_AMBIGUOUS_CALL, "Ambiguous function call.");
|
hlsl_dump_ir_function_decl(ctx, s, candidates.candidates[i]);
|
||||||
break;
|
hlsl_note(ctx, loc, VKD3D_SHADER_LOG_ERROR, " %s;", s->buffer);
|
||||||
|
vkd3d_string_buffer_clear(s);
|
||||||
}
|
}
|
||||||
compatible_match = decl;
|
hlsl_release_string_buffer(ctx, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return compatible_match;
|
decl = candidates.candidates[0];
|
||||||
|
vkd3d_free(candidates.candidates);
|
||||||
|
|
||||||
|
return decl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct hlsl_ir_node *hlsl_new_void_expr(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc)
|
static struct hlsl_ir_node *hlsl_new_void_expr(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user