From 7eee877dd40b8e76250df9c4aaf00e7d5d663bf7 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Mon, 7 Oct 2024 17:21:32 -0300 Subject: [PATCH] vkd3d-shader/tpf: Make hlsl_sm4_register_from_semantic() independent of HLSL IR. --- libs/vkd3d-shader/hlsl.h | 3 --- libs/vkd3d-shader/hlsl_codegen.c | 4 ++-- libs/vkd3d-shader/tpf.c | 12 ++++++------ libs/vkd3d-shader/vkd3d_shader_private.h | 2 ++ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 7a163a73..fce51ada 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1629,9 +1629,6 @@ int d3dbc_compile(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_code *ctab, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context); -bool hlsl_sm4_register_from_semantic(const struct vkd3d_shader_version *version, - const struct hlsl_semantic *semantic, bool output, enum vkd3d_shader_register_type *type, bool *has_idx); - int tpf_compile(struct vsir_program *program, uint64_t config_flags, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context, struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func); diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index d36c0cc0..42ede1c1 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -5225,7 +5225,7 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var return; } - if ((builtin = hlsl_sm4_register_from_semantic(&version, &var->semantic, output, &type, &has_idx))) + if ((builtin = sm4_register_from_semantic_name(&version, var->semantic.name, output, &type, &has_idx))) reg = has_idx ? var->semantic.index : 0; } @@ -6306,7 +6306,7 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, if (sysval == ~0u) return; - if (hlsl_sm4_register_from_semantic(&program->shader_version, &var->semantic, output, &type, &has_idx)) + if (sm4_register_from_semantic_name(&program->shader_version, var->semantic.name, output, &type, &has_idx)) { register_index = has_idx ? var->semantic.index : ~0u; } diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 666c7b49..f63c3f6a 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -2997,8 +2997,8 @@ static bool type_is_integer(const struct hlsl_type *type) } } -bool hlsl_sm4_register_from_semantic(const struct vkd3d_shader_version *version, - const struct hlsl_semantic *semantic, bool output, enum vkd3d_shader_register_type *type, bool *has_idx) +bool sm4_register_from_semantic_name(const struct vkd3d_shader_version *version, + const char *semantic_name, bool output, enum vkd3d_shader_register_type *type, bool *has_idx) { unsigned int i; @@ -3030,7 +3030,7 @@ bool hlsl_sm4_register_from_semantic(const struct vkd3d_shader_version *version, for (i = 0; i < ARRAY_SIZE(register_table); ++i) { - if (!ascii_strcasecmp(semantic->name, register_table[i].semantic) + if (!ascii_strcasecmp(semantic_name, register_table[i].semantic) && output == register_table[i].output && version->type == register_table[i].shader_type) { @@ -4125,7 +4125,7 @@ static void sm4_register_from_deref(const struct tpf_compiler *tpf, struct vkd3d { bool has_idx; - if (hlsl_sm4_register_from_semantic(version, &var->semantic, false, ®->type, &has_idx)) + if (sm4_register_from_semantic_name(version, var->semantic.name, false, ®->type, &has_idx)) { unsigned int offset = hlsl_offset_from_deref_safe(ctx, deref); @@ -4154,7 +4154,7 @@ static void sm4_register_from_deref(const struct tpf_compiler *tpf, struct vkd3d { bool has_idx; - if (hlsl_sm4_register_from_semantic(version, &var->semantic, true, ®->type, &has_idx)) + if (sm4_register_from_semantic_name(version, var->semantic.name, true, ®->type, &has_idx)) { unsigned int offset = hlsl_offset_from_deref_safe(ctx, deref); @@ -4721,7 +4721,7 @@ static void write_sm4_dcl_semantic(const struct tpf_compiler *tpf, const struct .dst_count = 1, }; - if (hlsl_sm4_register_from_semantic(version, &var->semantic, output, &instr.dsts[0].reg.type, &has_idx)) + if (sm4_register_from_semantic_name(version, var->semantic.name, output, &instr.dsts[0].reg.type, &has_idx)) { if (has_idx) { diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 2df42c9b..4808eea1 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1606,6 +1606,8 @@ bool sm1_register_from_semantic_name(const struct vkd3d_shader_version *version, unsigned int semantic_index, bool output, enum vkd3d_shader_register_type *type, unsigned int *reg); bool sm1_usage_from_semantic_name(const char *semantic_name, uint32_t semantic_index, enum vkd3d_decl_usage *usage, uint32_t *usage_idx); +bool sm4_register_from_semantic_name(const struct vkd3d_shader_version *version, + const char *semantic_name, bool output, enum vkd3d_shader_register_type *type, bool *has_idx); bool sm4_sysval_semantic_from_semantic_name(enum vkd3d_shader_sysval_semantic *sysval_semantic, const struct vkd3d_shader_version *version, bool semantic_compat_mapping, const char *semantic_name, bool output);