mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Add variables for techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
committed by
Alexandre Julliard
parent
8494342fa0
commit
f7a02a5da2
Notes:
Alexandre Julliard
2024-01-11 23:13:27 +01: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/443
@@ -98,19 +98,22 @@ bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var
|
||||
struct hlsl_scope *scope = ctx->cur_scope;
|
||||
struct hlsl_ir_var *var;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &scope->vars, struct hlsl_ir_var, scope_entry)
|
||||
if (decl->name)
|
||||
{
|
||||
if (!strcmp(decl->name, var->name))
|
||||
return false;
|
||||
}
|
||||
if (local_var && scope->upper->upper == ctx->globals)
|
||||
{
|
||||
/* Check whether the variable redefines a function parameter. */
|
||||
LIST_FOR_EACH_ENTRY(var, &scope->upper->vars, struct hlsl_ir_var, scope_entry)
|
||||
LIST_FOR_EACH_ENTRY(var, &scope->vars, struct hlsl_ir_var, scope_entry)
|
||||
{
|
||||
if (!strcmp(decl->name, var->name))
|
||||
if (var->name && !strcmp(decl->name, var->name))
|
||||
return false;
|
||||
}
|
||||
if (local_var && scope->upper->upper == ctx->globals)
|
||||
{
|
||||
/* Check whether the variable redefines a function parameter. */
|
||||
LIST_FOR_EACH_ENTRY(var, &scope->upper->vars, struct hlsl_ir_var, scope_entry)
|
||||
{
|
||||
if (var->name && !strcmp(decl->name, var->name))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_add_tail(&scope->vars, &decl->scope_entry);
|
||||
@@ -123,7 +126,7 @@ struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name)
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &scope->vars, struct hlsl_ir_var, scope_entry)
|
||||
{
|
||||
if (!strcmp(name, var->name))
|
||||
if (var->name && !strcmp(name, var->name))
|
||||
return var;
|
||||
}
|
||||
if (!scope->upper)
|
||||
@@ -915,6 +918,11 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2
|
||||
if (t1->class == HLSL_CLASS_ARRAY)
|
||||
return t1->e.array.elements_count == t2->e.array.elements_count
|
||||
&& hlsl_types_are_equal(t1->e.array.type, t2->e.array.type);
|
||||
if (t1->class == HLSL_CLASS_OBJECT)
|
||||
{
|
||||
if (t1->base_type == HLSL_TYPE_TECHNIQUE && t1->e.version != t2->e.version)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -993,6 +1001,13 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
|
||||
break;
|
||||
}
|
||||
|
||||
case HLSL_CLASS_OBJECT:
|
||||
{
|
||||
if (type->base_type == HLSL_TYPE_TECHNIQUE)
|
||||
type->e.version = old->e.version;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -3357,6 +3372,18 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
|
||||
{"VERTEXSHADER", HLSL_CLASS_OBJECT, HLSL_TYPE_VERTEXSHADER, 1, 1},
|
||||
};
|
||||
|
||||
static const struct
|
||||
{
|
||||
char *name;
|
||||
unsigned int version;
|
||||
}
|
||||
technique_types[] =
|
||||
{
|
||||
{"technique", 9},
|
||||
{"technique10", 10},
|
||||
{"technique11", 11},
|
||||
};
|
||||
|
||||
for (bt = 0; bt <= HLSL_TYPE_LAST_SCALAR; ++bt)
|
||||
{
|
||||
for (y = 1; y <= 4; ++y)
|
||||
@@ -3461,6 +3488,13 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
|
||||
effect_types[i].base_type, effect_types[i].dimx, effect_types[i].dimy);
|
||||
hlsl_scope_add_type(ctx->globals, type);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(technique_types); ++i)
|
||||
{
|
||||
type = hlsl_new_type(ctx, technique_types[i].name, HLSL_CLASS_OBJECT, HLSL_TYPE_TECHNIQUE, 1, 1);
|
||||
type->e.version = technique_types[i].version;
|
||||
hlsl_scope_add_type(ctx->globals, type);
|
||||
}
|
||||
}
|
||||
|
||||
static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compile_info *compile_info,
|
||||
|
Reference in New Issue
Block a user