vkd3d-shader/hlsl: Skip functions that don't have a body when looking for the entry point.

This commit is contained in:
Zebediah Figura 2021-09-11 18:18:50 -05:00 committed by Alexandre Julliard
parent 09c5ed27fe
commit bb41c3b5fe
Notes: Alexandre Julliard 2023-02-13 22:20:34 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/85
3 changed files with 25 additions and 5 deletions

View File

@ -554,9 +554,13 @@ struct hlsl_type *hlsl_get_type(struct hlsl_scope *scope, const char *name, bool
return NULL;
}
bool hlsl_get_function(struct hlsl_ctx *ctx, const char *name)
struct hlsl_ir_function *hlsl_get_function(struct hlsl_ctx *ctx, const char *name)
{
return rb_get(&ctx->functions, name) != NULL;
struct rb_entry *entry;
if ((entry = rb_get(&ctx->functions, name)))
return RB_ENTRY_VALUE(entry, struct hlsl_ir_function, entry);
return NULL;
}
struct hlsl_ir_function_decl *hlsl_get_func_decl(struct hlsl_ctx *ctx, const char *name)
@ -2628,8 +2632,9 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
{
const struct vkd3d_shader_hlsl_source_info *hlsl_source_info;
struct hlsl_ir_function_decl *entry_func;
struct hlsl_ir_function_decl *decl, *entry_func = NULL;
const struct hlsl_profile_info *profile;
struct hlsl_ir_function *func;
const char *entry_point;
struct hlsl_ctx ctx;
int ret;
@ -2685,7 +2690,18 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
return VKD3D_ERROR_NOT_IMPLEMENTED;
}
if (!(entry_func = hlsl_get_func_decl(&ctx, entry_point)))
if ((func = hlsl_get_function(&ctx, entry_point)))
{
RB_FOR_EACH_ENTRY(decl, &func->overloads, struct hlsl_ir_function_decl, entry)
{
if (!decl->has_body)
continue;
entry_func = decl;
break;
}
}
if (!entry_func)
{
const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name};

View File

@ -988,7 +988,7 @@ void hlsl_free_instr_list(struct list *list);
void hlsl_free_type(struct hlsl_type *type);
void hlsl_free_var(struct hlsl_ir_var *decl);
bool hlsl_get_function(struct hlsl_ctx *ctx, const char *name);
struct hlsl_ir_function *hlsl_get_function(struct hlsl_ctx *ctx, const char *name);
struct hlsl_ir_function_decl *hlsl_get_func_decl(struct hlsl_ctx *ctx, const char *name);
struct hlsl_type *hlsl_get_type(struct hlsl_scope *scope, const char *name, bool recursive);
struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name);

View File

@ -264,3 +264,7 @@ float4 main() : sv_target
{
return 1.0;
}
[pixel shader fail]
float4 main() : sv_target;