mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Introduce hlsl_new_synthetic_var_named().
This commit is contained in:
parent
866c5d9531
commit
c4f074d25d
Notes:
Alexandre Julliard
2023-07-17 23:25:21 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/209
@ -1039,20 +1039,31 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *tem
|
||||
struct vkd3d_string_buffer *string;
|
||||
struct hlsl_ir_var *var;
|
||||
static LONG counter;
|
||||
const char *name;
|
||||
|
||||
if (!(string = hlsl_get_string_buffer(ctx)))
|
||||
return NULL;
|
||||
vkd3d_string_buffer_printf(string, "<%s-%u>", template, InterlockedIncrement(&counter));
|
||||
if (!(name = hlsl_strdup(ctx, string->buffer)))
|
||||
{
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
return NULL;
|
||||
}
|
||||
var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL);
|
||||
var = hlsl_new_synthetic_var_named(ctx, string->buffer, type, loc, true);
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
return var;
|
||||
}
|
||||
|
||||
struct hlsl_ir_var *hlsl_new_synthetic_var_named(struct hlsl_ctx *ctx, const char *name,
|
||||
struct hlsl_type *type, const struct vkd3d_shader_location *loc, bool dummy_scope)
|
||||
{
|
||||
struct hlsl_ir_var *var;
|
||||
const char *name_copy;
|
||||
|
||||
if (!(name_copy = hlsl_strdup(ctx, name)))
|
||||
return NULL;
|
||||
var = hlsl_new_var(ctx, name_copy, type, loc, NULL, 0, NULL);
|
||||
if (var)
|
||||
list_add_tail(&ctx->dummy_scope->vars, &var->scope_entry);
|
||||
{
|
||||
if (dummy_scope)
|
||||
list_add_tail(&ctx->dummy_scope->vars, &var->scope_entry);
|
||||
else
|
||||
list_add_tail(&ctx->globals->vars, &var->scope_entry);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
|
@ -1173,6 +1173,8 @@ struct hlsl_ir_node *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned in
|
||||
struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *template,
|
||||
struct hlsl_type *type, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_var *hlsl_new_synthetic_var_named(struct hlsl_ctx *ctx, const char *name,
|
||||
struct hlsl_type *type, const struct vkd3d_shader_location *loc, bool dummy_scope);
|
||||
struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format,
|
||||
unsigned int sample_count);
|
||||
struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format);
|
||||
|
Loading…
x
Reference in New Issue
Block a user