mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Store original semantic name.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
47d077e5ce
commit
1124ea46ee
Notes:
Henri Verbeet
2024-06-11 17:09:32 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/902
@ -3352,9 +3352,25 @@ void hlsl_free_attribute(struct hlsl_attribute *attr)
|
|||||||
void hlsl_cleanup_semantic(struct hlsl_semantic *semantic)
|
void hlsl_cleanup_semantic(struct hlsl_semantic *semantic)
|
||||||
{
|
{
|
||||||
vkd3d_free((void *)semantic->name);
|
vkd3d_free((void *)semantic->name);
|
||||||
|
vkd3d_free((void *)semantic->raw_name);
|
||||||
memset(semantic, 0, sizeof(*semantic));
|
memset(semantic, 0, sizeof(*semantic));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hlsl_clone_semantic(struct hlsl_ctx *ctx, struct hlsl_semantic *dst, const struct hlsl_semantic *src)
|
||||||
|
{
|
||||||
|
*dst = *src;
|
||||||
|
dst->name = dst->raw_name = NULL;
|
||||||
|
if (src->name && !(dst->name = hlsl_strdup(ctx, src->name)))
|
||||||
|
return false;
|
||||||
|
if (src->raw_name && !(dst->raw_name = hlsl_strdup(ctx, src->raw_name)))
|
||||||
|
{
|
||||||
|
hlsl_cleanup_semantic(dst);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void free_function_decl(struct hlsl_ir_function_decl *decl)
|
static void free_function_decl(struct hlsl_ir_function_decl *decl)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -222,6 +222,8 @@ struct hlsl_semantic
|
|||||||
const char *name;
|
const char *name;
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
|
|
||||||
|
/* Name exactly as it appears in the sources. */
|
||||||
|
const char *raw_name;
|
||||||
/* If the variable or field that stores this hlsl_semantic has already reported that it is missing. */
|
/* If the variable or field that stores this hlsl_semantic has already reported that it is missing. */
|
||||||
bool reported_missing;
|
bool reported_missing;
|
||||||
/* In case the variable or field that stores this semantic has already reported to use a
|
/* In case the variable or field that stores this semantic has already reported to use a
|
||||||
@ -1284,7 +1286,9 @@ bool hlsl_init_deref_from_index_chain(struct hlsl_ctx *ctx, struct hlsl_deref *d
|
|||||||
bool hlsl_copy_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, const struct hlsl_deref *other);
|
bool hlsl_copy_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, const struct hlsl_deref *other);
|
||||||
|
|
||||||
void hlsl_cleanup_deref(struct hlsl_deref *deref);
|
void hlsl_cleanup_deref(struct hlsl_deref *deref);
|
||||||
|
|
||||||
void hlsl_cleanup_semantic(struct hlsl_semantic *semantic);
|
void hlsl_cleanup_semantic(struct hlsl_semantic *semantic);
|
||||||
|
bool hlsl_clone_semantic(struct hlsl_ctx *ctx, struct hlsl_semantic *dst, const struct hlsl_semantic *src);
|
||||||
|
|
||||||
void hlsl_cleanup_ir_switch_cases(struct list *cases);
|
void hlsl_cleanup_ir_switch_cases(struct list *cases);
|
||||||
void hlsl_free_ir_switch_case(struct hlsl_ir_switch_case *c);
|
void hlsl_free_ir_switch_case(struct hlsl_ir_switch_case *c);
|
||||||
|
@ -2335,15 +2335,11 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
|
|||||||
if (!(var_name = vkd3d_strdup(v->name)))
|
if (!(var_name = vkd3d_strdup(v->name)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new_semantic = v->semantic;
|
if (!hlsl_clone_semantic(ctx, &new_semantic, &v->semantic))
|
||||||
if (v->semantic.name)
|
|
||||||
{
|
|
||||||
if (!(new_semantic.name = vkd3d_strdup(v->semantic.name)))
|
|
||||||
{
|
{
|
||||||
vkd3d_free(var_name);
|
vkd3d_free(var_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!(var = hlsl_new_var(ctx, var_name, type, &v->loc, &new_semantic, modifiers, &v->reg_reservation)))
|
if (!(var = hlsl_new_var(ctx, var_name, type, &v->loc, &new_semantic, modifiers, &v->reg_reservation)))
|
||||||
{
|
{
|
||||||
@ -6433,6 +6429,9 @@ semantic:
|
|||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
|
if (!($$.raw_name = hlsl_strdup(ctx, $2)))
|
||||||
|
YYABORT;
|
||||||
|
|
||||||
for (p = $2 + strlen($2); p > $2 && isdigit(p[-1]); --p)
|
for (p = $2 + strlen($2); p > $2 && isdigit(p[-1]); --p)
|
||||||
;
|
;
|
||||||
$$.name = $2;
|
$$.name = $2;
|
||||||
|
@ -320,7 +320,7 @@ static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(new_semantic.name = hlsl_strdup(ctx, semantic->name)))
|
if (!(hlsl_clone_semantic(ctx, &new_semantic, semantic)))
|
||||||
{
|
{
|
||||||
vkd3d_free(new_name);
|
vkd3d_free(new_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user