Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 1 - libs/vkd3d-shader/hlsl.h | 1 - libs/vkd3d-shader/hlsl.y | 15 +++++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 85859ada..4526348e 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -340,7 +340,6 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, u field->name = vkd3d_strdup(old_field->name); if (old_field->semantic) field->semantic = vkd3d_strdup(old_field->semantic); - field->modifiers = old_field->modifiers; field->reg_offset = reg_size; reg_size += field->type->reg_size; list_add_tail(type->e.elements, &field->entry); diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 819b8826..523d156d 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -134,7 +134,6 @@ struct hlsl_struct_field struct hlsl_type *type; const char *name; const char *semantic; - DWORD modifiers; unsigned int reg_offset; };
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 45767de9..4b0ddea4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -721,8 +721,7 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_ return new_type; }
-static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *type, - DWORD modifiers, struct list *fields) +static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *type, struct list *fields) { struct parse_variable_def *v, *v_next; struct hlsl_struct_field *field; @@ -748,7 +747,6 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty field->type = hlsl_new_array_type(ctx, field->type, v->arrays.sizes[i]); field->loc = v->loc; field->name = v->name; - field->modifiers = modifiers; field->semantic = v->semantic; if (v->initializer.args_count) { @@ -1937,7 +1935,16 @@ field:
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT; - $$ = gen_struct_fields(ctx, type, modifiers, $3); + if (modifiers) + { + struct vkd3d_string_buffer *string; + + if ((string = hlsl_modifiers_to_string(&ctx->string_buffers, modifiers))) + hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + "Modifiers '%s' are not allowed on struct fields.", string->buffer); + vkd3d_string_buffer_release(&ctx->string_buffers, string); + } + $$ = gen_struct_fields(ctx, type, $3); }
func_declaration:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 94 ++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 57 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 4b0ddea4..41fea19b 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -292,60 +292,6 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct return &cast->node; }
-static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local) -{ - struct hlsl_ir_function_decl *func; - bool ret; - - if (decl->data_type->type != HLSL_CLASS_MATRIX) - check_invalid_matrix_modifiers(ctx, decl->modifiers, decl->loc); - - if (local) - { - DWORD invalid = decl->modifiers & (HLSL_STORAGE_EXTERN | HLSL_STORAGE_SHARED - | HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM); - - if (invalid) - { - struct vkd3d_string_buffer *string; - - if ((string = hlsl_modifiers_to_string(&ctx->string_buffers, invalid))) - hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, - "Modifiers '%s' are not allowed on local variables.", string->buffer); - vkd3d_string_buffer_release(&ctx->string_buffers, string); - } - - if (decl->semantic) - { - hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, - "Semantics are not allowed on local variables."); - return false; - } - } - else - { - if ((func = hlsl_get_func_decl(ctx, decl->name))) - { - hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, - "Variable '%s' is already defined as a function.", decl->name); - hlsl_note(ctx, func->loc, VKD3D_SHADER_LOG_ERROR, - ""%s" was previously defined here.", decl->name); - return false; - } - } - ret = hlsl_add_var(ctx, decl, local); - if (!ret) - { - struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, decl->name); - - hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, - "Variable "%s" was already declared in this scope.", decl->name); - hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously declared here.", old->name); - return false; - } - return true; -} - static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, const struct vkd3d_shader_location loc) { if (modifiers & mod) @@ -1431,10 +1377,11 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t DWORD modifiers, struct list *var_list) { struct parse_variable_def *v, *v_next; + struct hlsl_ir_function_decl *func; struct list *statements_list; struct hlsl_ir_var *var; struct hlsl_type *type; - bool ret, local = true; + bool local = true;
if (basic_type->type == HLSL_CLASS_MATRIX) assert(basic_type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK); @@ -1464,10 +1411,39 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t continue; }
+ if (var->data_type->type != HLSL_CLASS_MATRIX) + check_invalid_matrix_modifiers(ctx, var->modifiers, var->loc); + if (ctx->cur_scope == ctx->globals) { var->modifiers |= HLSL_STORAGE_UNIFORM; local = false; + + if ((func = hlsl_get_func_decl(ctx, var->name))) + { + hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + "'%s' is already defined as a function.", var->name); + hlsl_note(ctx, func->loc, VKD3D_SHADER_LOG_ERROR, + "'%s' was previously defined here.", var->name); + } + } + else + { + static const unsigned int invalid = HLSL_STORAGE_EXTERN | HLSL_STORAGE_SHARED + | HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM; + + if (var->modifiers & invalid) + { + struct vkd3d_string_buffer *string; + + if ((string = hlsl_modifiers_to_string(&ctx->string_buffers, var->modifiers & invalid))) + hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + "Modifiers '%s' are not allowed on local variables.", string->buffer); + vkd3d_string_buffer_release(&ctx->string_buffers, string); + } + if (var->semantic) + hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, + "Semantics are not allowed on local variables."); }
if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count @@ -1480,9 +1456,13 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t continue; }
- ret = declare_variable(ctx, var, local); - if (!ret) + if (!hlsl_add_var(ctx, var, local)) { + struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name); + + hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + "Variable "%s" was already declared in this scope.", var->name); + hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously declared here.", old->name); hlsl_free_var(var); vkd3d_free(v); continue;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Mostly in order to make it clearer that these don't directly correspond to the modifiers with which the variable was declared.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 22 ++++++++-------------- libs/vkd3d-shader/hlsl.h | 8 +++++--- libs/vkd3d-shader/hlsl.y | 32 +++++++++++++++++++++++--------- libs/vkd3d-shader/hlsl_codegen.c | 4 ++-- 4 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 4526348e..794166dd 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -388,7 +388,7 @@ struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ir_node *node) }
struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc, - const char *semantic, unsigned int modifiers, const struct hlsl_reg_reservation *reg_reservation) + const char *semantic, const struct hlsl_reg_reservation *reg_reservation) { struct hlsl_ir_var *var;
@@ -399,7 +399,6 @@ struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const var->data_type = type; var->loc = loc; var->semantic = semantic; - var->modifiers = modifiers; var->reg_reservation = reg_reservation; return var; } @@ -407,7 +406,7 @@ struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc) { - struct hlsl_ir_var *var = hlsl_new_var(vkd3d_strdup(name), type, loc, NULL, 0, NULL); + struct hlsl_ir_var *var = hlsl_new_var(vkd3d_strdup(name), type, loc, NULL, NULL);
if (var) list_add_tail(&ctx->globals->vars, &var->scope_entry); @@ -869,17 +868,12 @@ static void dump_src(struct vkd3d_string_buffer *buffer, const struct hlsl_src *
static void dump_ir_var(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_var *var) { - if (var->modifiers) - { - struct vkd3d_string_buffer_cache string_buffers; - struct vkd3d_string_buffer *string; - - vkd3d_string_buffer_cache_init(&string_buffers); - if ((string = hlsl_modifiers_to_string(&string_buffers, var->modifiers))) - vkd3d_string_buffer_printf(buffer, "%s ", string->buffer); - vkd3d_string_buffer_release(&string_buffers, string); - vkd3d_string_buffer_cache_cleanup(&string_buffers); - } + if (var->is_input_varying) + vkd3d_string_buffer_printf(buffer, "in "); + if (var->is_output_varying) + vkd3d_string_buffer_printf(buffer, "out "); + if (var->is_uniform) + vkd3d_string_buffer_printf(buffer, "uniform "); vkd3d_string_buffer_printf(buffer, "%s %s", debug_hlsl_type(var->data_type), var->name); if (var->semantic) vkd3d_string_buffer_printf(buffer, " : %s", var->semantic); diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 523d156d..cc740eab 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -204,11 +204,14 @@ struct hlsl_ir_var struct vkd3d_shader_location loc; const char *name; const char *semantic; - unsigned int modifiers; const struct hlsl_reg_reservation *reg_reservation; struct list scope_entry, param_entry;
unsigned int first_write, last_read; + + uint32_t is_input_varying : 1; + uint32_t is_output_varying : 1; + uint32_t is_uniform : 1; };
struct hlsl_ir_function @@ -546,8 +549,7 @@ struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned i struct hlsl_ir_node *hlsl_new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN; struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc, - const char *semantic, unsigned int modifiers, - const struct hlsl_reg_reservation *reg_reservation) DECLSPEC_HIDDEN; + const char *semantic, const struct hlsl_reg_reservation *reg_reservation) DECLSPEC_HIDDEN; struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_error error, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 41fea19b..912064b2 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -763,9 +763,21 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list, if (param->type->type == HLSL_CLASS_MATRIX) assert(param->type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK);
- if (!(var = hlsl_new_var(param->name, param->type, loc, param->semantic, param->modifiers, param->reg_reservation))) + if (!(var = hlsl_new_var(param->name, param->type, loc, param->semantic, param->reg_reservation))) return false;
+ if (param->modifiers & HLSL_STORAGE_UNIFORM) + { + var->is_uniform = 1; + } + else + { + if (param->modifiers & HLSL_STORAGE_IN) + var->is_input_varying = 1; + if (param->modifiers & HLSL_STORAGE_OUT) + var->is_output_varying = 1; + } + if (!hlsl_add_var(ctx, var, false)) { hlsl_free_var(var); @@ -1405,18 +1417,20 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t for (i = 0; i < v->arrays.count; ++i) type = hlsl_new_array_type(ctx, type, v->arrays.sizes[i]);
- if (!(var = hlsl_new_var(v->name, type, v->loc, v->semantic, modifiers, v->reg_reservation))) + if (type->type != HLSL_CLASS_MATRIX) + check_invalid_matrix_modifiers(ctx, modifiers, v->loc); + + if (!(var = hlsl_new_var(v->name, type, v->loc, v->semantic, v->reg_reservation))) { free_parse_variable_def(v); continue; }
- if (var->data_type->type != HLSL_CLASS_MATRIX) - check_invalid_matrix_modifiers(ctx, var->modifiers, var->loc); - if (ctx->cur_scope == ctx->globals) { - var->modifiers |= HLSL_STORAGE_UNIFORM; + if (!(modifiers & HLSL_STORAGE_STATIC)) + var->is_uniform = 1; + local = false;
if ((func = hlsl_get_func_decl(ctx, var->name))) @@ -1432,11 +1446,11 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t static const unsigned int invalid = HLSL_STORAGE_EXTERN | HLSL_STORAGE_SHARED | HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM;
- if (var->modifiers & invalid) + if (modifiers & invalid) { struct vkd3d_string_buffer *string;
- if ((string = hlsl_modifiers_to_string(&ctx->string_buffers, var->modifiers & invalid))) + if ((string = hlsl_modifiers_to_string(&ctx->string_buffers, modifiers & invalid))) hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers '%s' are not allowed on local variables.", string->buffer); vkd3d_string_buffer_release(&ctx->string_buffers, string); @@ -1447,7 +1461,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t }
if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count - && !(var->modifiers & (HLSL_STORAGE_STATIC | HLSL_STORAGE_UNIFORM))) + && !(modifiers & (HLSL_STORAGE_STATIC | HLSL_STORAGE_UNIFORM))) { hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER, "Const variable "%s" is missing an initializer.", var->name); diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index b9f753a1..f27714c3 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -403,9 +403,9 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
LIST_FOR_EACH_ENTRY(var, entry_func->parameters, struct hlsl_ir_var, param_entry) { - if (var->modifiers & HLSL_STORAGE_IN) + if (var->is_input_varying) var->first_write = 1; - if (var->modifiers & HLSL_STORAGE_OUT) + if (var->is_output_varying) var->last_read = UINT_MAX; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 912064b2..ab7059d3 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -766,16 +766,19 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list, if (!(var = hlsl_new_var(param->name, param->type, loc, param->semantic, param->reg_reservation))) return false;
- if (param->modifiers & HLSL_STORAGE_UNIFORM) + if (param->type->type != HLSL_CLASS_OBJECT) { - var->is_uniform = 1; - } - else - { - if (param->modifiers & HLSL_STORAGE_IN) - var->is_input_varying = 1; - if (param->modifiers & HLSL_STORAGE_OUT) - var->is_output_varying = 1; + if (param->modifiers & HLSL_STORAGE_UNIFORM) + { + var->is_uniform = 1; + } + else + { + if (param->modifiers & HLSL_STORAGE_IN) + var->is_input_varying = 1; + if (param->modifiers & HLSL_STORAGE_OUT) + var->is_output_varying = 1; + } }
if (!hlsl_add_var(ctx, var, false)) @@ -1428,7 +1431,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if (ctx->cur_scope == ctx->globals) { - if (!(modifiers & HLSL_STORAGE_STATIC)) + if (type->type != HLSL_CLASS_OBJECT && !(modifiers & HLSL_STORAGE_STATIC)) var->is_uniform = 1;
local = false;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_codegen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index f27714c3..595e7da6 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -403,7 +403,7 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
LIST_FOR_EACH_ENTRY(var, entry_func->parameters, struct hlsl_ir_var, param_entry) { - if (var->is_input_varying) + if (var->is_input_varying || var->is_uniform) var->first_write = 1; if (var->is_output_varying) var->last_read = UINT_MAX;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_codegen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 595e7da6..21bd9ab8 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -398,7 +398,8 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry) { - var->first_write = 1; + if (var->is_uniform) + var->first_write = 1; }
LIST_FOR_EACH_ENTRY(var, entry_func->parameters, struct hlsl_ir_var, param_entry)
On Mon, Mar 22, 2021 at 11:03 PM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_codegen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 595e7da6..21bd9ab8 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -398,7 +398,8 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry) {
var->first_write = 1;
if (var->is_uniform)
}var->first_write = 1;
Some light testing suggests that static variables are implicitly initialized to 0, like in C.
On 3/23/21 4:35 PM, Matteo Bruni wrote:
On Mon, Mar 22, 2021 at 11:03 PM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_codegen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 595e7da6..21bd9ab8 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -398,7 +398,8 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry) {
var->first_write = 1;
if (var->is_uniform)
}var->first_write = 1;
Some light testing suggests that static variables are implicitly initialized to 0, like in C.
Yes, that's correct. I believe we should handle that by generating explicit assignments, which means that there's no need to handle it specially when calculating liveness.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Fair enough.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- It turns out that there are some weird cases where the native compiler allows them (sometimes even affecting the resulting shader) but I don't think those cases are very realistic or useful.