From: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Resent without changes, as this clashes with a later patch in this series.
libs/vkd3d-shader/hlsl_codegen.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 366b8bda..54c91bf8 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -843,7 +843,12 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx, struct list * if (!hlsl_array_reserve(ctx, (void **)&defs->values, &defs->size, constant->reg.id + reg_size, sizeof(*defs->values))) return; - defs->count = max(defs->count, constant->reg.id + reg_size); + if (constant->reg.id + reg_size > defs->count) + { + memset(&defs->values[defs->count], 0, + sizeof(*defs->values) * (constant->reg.id + reg_size - defs->count)); + defs->count = constant->reg.id + reg_size; + }
assert(type->type <= HLSL_CLASS_LAST_NUMERIC);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index d9e51b8d..8c542023 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -213,7 +213,7 @@ struct hlsl_src struct hlsl_reg_reservation { char type; - DWORD regnum; + unsigned int index; };
struct hlsl_ir_var diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 2e631fac..1a102a56 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -784,7 +784,7 @@ static struct hlsl_reg_reservation parse_reg_reservation(const char *reg_string) { struct hlsl_reg_reservation reservation = {0};
- if (!sscanf(reg_string + 1, "%u", &reservation.regnum)) + if (!sscanf(reg_string + 1, "%u", &reservation.index)) { FIXME("Unsupported register reservation syntax.\n"); return reservation;
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.c | 2 -- libs/vkd3d-shader/hlsl.h | 2 -- 2 files changed, 4 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index e9bfc374..c8ca4bbf 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1015,8 +1015,6 @@ static const char *debug_expr_op(const struct hlsl_ir_expr *expr) "pow",
"lerp", - - ",", };
return op_names[expr->op]; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 8c542023..b159cbbc 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -329,8 +329,6 @@ enum hlsl_ir_expr_op HLSL_IR_BINOP_POW,
HLSL_IR_TEROP_LERP, - - HLSL_IR_SEQUENCE, };
struct hlsl_ir_expr
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.c | 24 ++++++++++++++++++++++++ libs/vkd3d-shader/hlsl.h | 18 ++++++++++++++++++ libs/vkd3d-shader/hlsl.y | 30 ++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index c8ca4bbf..aa95a431 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -592,6 +592,22 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl return decl; }
+struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type type, const char *name, + const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc) +{ + struct hlsl_buffer *buffer; + + if (!(buffer = hlsl_alloc(ctx, sizeof(*buffer)))) + return NULL; + buffer->type = type; + buffer->name = name; + if (reservation) + buffer->reservation = *reservation; + buffer->loc = loc; + list_add_tail(&ctx->buffers, &buffer->entry); + return buffer; +} + static int compare_hlsl_types_rb(const void *key, const struct rb_entry *entry) { const struct hlsl_type *type = RB_ENTRY_VALUE(entry, const struct hlsl_type, scope_entry); @@ -1583,12 +1599,14 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct hlsl_profile_info *
list_init(&ctx->static_initializers); list_init(&ctx->extern_vars); + list_init(&ctx->buffers);
return true; }
static void hlsl_ctx_cleanup(struct hlsl_ctx *ctx) { + struct hlsl_buffer *buffer, *next_buffer; struct hlsl_scope *scope, *next_scope; struct hlsl_ir_var *var, *next_var; struct hlsl_type *type, *next_type; @@ -1611,6 +1629,12 @@ static void hlsl_ctx_cleanup(struct hlsl_ctx *ctx)
LIST_FOR_EACH_ENTRY_SAFE(type, next_type, &ctx->types, struct hlsl_type, entry) hlsl_free_type(type); + + LIST_FOR_EACH_ENTRY_SAFE(buffer, next_buffer, &ctx->buffers, struct hlsl_buffer, entry) + { + vkd3d_free((void *)buffer->name); + vkd3d_free(buffer); + } }
int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d_shader_compile_info *compile_info, diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index b159cbbc..16ec976a 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -417,6 +417,21 @@ struct hlsl_vec4 float f[4]; };
+enum hlsl_buffer_type +{ + HLSL_BUFFER_CONSTANT, + HLSL_BUFFER_TEXTURE, +}; + +struct hlsl_buffer +{ + struct vkd3d_shader_location loc; + enum hlsl_buffer_type type; + const char *name; + struct hlsl_reg_reservation reservation; + struct list entry; +}; + struct hlsl_ctx { const struct hlsl_profile_info *profile; @@ -435,6 +450,7 @@ struct hlsl_ctx struct list scopes; struct list extern_vars;
+ struct list buffers; struct list types; struct rb_tree functions; const struct hlsl_ir_function_decl *cur_function; @@ -609,6 +625,8 @@ struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *ba unsigned int array_size) DECLSPEC_HIDDEN; struct hlsl_ir_node *hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN; +struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type type, const char *name, + const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN; struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type, struct vkd3d_shader_location *loc) DECLSPEC_HIDDEN; struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node) DECLSPEC_HIDDEN; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1a102a56..6f83648a 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1561,6 +1561,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t struct hlsl_reg_reservation reg_reservation; struct parse_colon_attribute colon_attribute; struct hlsl_semantic semantic; + enum hlsl_buffer_type buffer_type; }
%token KW_BLENDSTATE @@ -1711,6 +1712,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
%type <boolval> boolean
+%type <buffer_type> buffer_type + %type <colon_attribute> colon_attribute
%type <function> func_declaration @@ -1776,6 +1779,7 @@ hlsl_prog:
hlsl_add_function(ctx, $2.name, $2.decl, false); } + | hlsl_prog buffer_declaration | hlsl_prog declaration_statement { if (!list_empty($2)) @@ -1785,6 +1789,32 @@ hlsl_prog: | hlsl_prog preproc_directive | hlsl_prog ';'
+buffer_declaration: + buffer_type any_identifier colon_attribute '{' declaration_statement_list '}' + { + struct hlsl_buffer *buffer; + + if ($3.semantic.name) + hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers."); + + if (!(buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2))) + YYABORT; + } + +buffer_type: + KW_CBUFFER + { + $$ = HLSL_BUFFER_CONSTANT; + } + | KW_TBUFFER + { + $$ = HLSL_BUFFER_TEXTURE; + } + +declaration_statement_list: + declaration_statement + | declaration_statement_list declaration_statement + preproc_directive: PRE_LINE STRING {
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.c | 6 ++++++ libs/vkd3d-shader/hlsl.h | 2 ++ libs/vkd3d-shader/hlsl.y | 16 +++++++++++----- libs/vkd3d-shader/hlsl_codegen.c | 1 + 4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index aa95a431..c36fe602 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1599,8 +1599,14 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct hlsl_profile_info *
list_init(&ctx->static_initializers); list_init(&ctx->extern_vars); + list_init(&ctx->buffers);
+ if (!(ctx->globals_buffer = hlsl_new_buffer(ctx, HLSL_BUFFER_CONSTANT, + hlsl_strdup(ctx, "$Globals"), NULL, ctx->location))) + return false; + ctx->cur_buffer = ctx->globals_buffer; + return true; }
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 16ec976a..e2ac0a77 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -222,6 +222,7 @@ struct hlsl_ir_var struct vkd3d_shader_location loc; const char *name; struct hlsl_semantic semantic; + struct hlsl_buffer *buffer; unsigned int modifiers; struct hlsl_reg_reservation reg_reservation; struct list scope_entry, param_entry, extern_entry; @@ -451,6 +452,7 @@ struct hlsl_ctx struct list extern_vars;
struct list buffers; + struct hlsl_buffer *cur_buffer, *globals_buffer; struct list types; struct rb_tree functions; const struct hlsl_ir_function_decl *cur_function; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 6f83648a..4355b9a2 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1393,6 +1393,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t continue; }
+ var->buffer = ctx->cur_buffer; + if (ctx->cur_scope == ctx->globals) { local = false; @@ -1779,7 +1781,7 @@ hlsl_prog:
hlsl_add_function(ctx, $2.name, $2.decl, false); } - | hlsl_prog buffer_declaration + | hlsl_prog buffer_declaration buffer_body | hlsl_prog declaration_statement { if (!list_empty($2)) @@ -1790,17 +1792,21 @@ hlsl_prog: | hlsl_prog ';'
buffer_declaration: - buffer_type any_identifier colon_attribute '{' declaration_statement_list '}' + buffer_type any_identifier colon_attribute { - struct hlsl_buffer *buffer; - if ($3.semantic.name) hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers.");
- if (!(buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2))) + if (!(ctx->cur_buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2))) YYABORT; }
+buffer_body: + '{' declaration_statement_list '}' + { + ctx->cur_buffer = ctx->globals_buffer; + } + buffer_type: KW_CBUFFER { diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 54c91bf8..068fb167 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -41,6 +41,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru list_add_tail(&ctx->extern_vars, &uniform->extern_entry); uniform->is_uniform = 1; uniform->is_param = temp->is_param; + uniform->buffer = temp->buffer;
if (!(name = hlsl_get_string_buffer(ctx))) return;
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.c | 8 ++++---- libs/vkd3d-shader/hlsl.y | 10 +++++----- libs/vkd3d-shader/hlsl_codegen.c | 33 ++++++++++++++++---------------- 3 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index c36fe602..ee73b05f 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -111,9 +111,9 @@ struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, enum hls type->dimx = dimx; type->dimy = dimy; if (type_class == HLSL_CLASS_MATRIX) - type->reg_size = hlsl_type_is_row_major(type) ? dimy : dimx; + type->reg_size = (hlsl_type_is_row_major(type) ? dimy : dimx) * 4; else - type->reg_size = 1; + type->reg_size = 4;
list_add_tail(&ctx->types, &type->entry);
@@ -306,7 +306,7 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, u case HLSL_CLASS_ARRAY: type->e.array.type = hlsl_type_clone(ctx, old->e.array.type, default_majority); type->e.array.elements_count = old->e.array.elements_count; - type->reg_size = type->e.array.elements_count * type->e.array.type->reg_size; + type->reg_size = (type->e.array.elements_count * type->e.array.type->reg_size) * 4; break;
case HLSL_CLASS_STRUCT: @@ -356,7 +356,7 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, u break;
default: - type->reg_size = 1; + type->reg_size = 4; break; }
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 4355b9a2..828b19a4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -567,7 +567,7 @@ static struct hlsl_ir_load *add_record_load(struct hlsl_ctx *ctx, struct list *i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset * 4, loc))) + if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, loc))) return NULL; list_add_tail(instrs, &c->node.entry);
@@ -601,7 +601,7 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in return NULL; }
- if (!(c = hlsl_new_uint_constant(ctx, data_type->reg_size * 4, loc))) + if (!(c = hlsl_new_uint_constant(ctx, data_type->reg_size, loc))) return NULL; list_add_tail(instrs, &c->node.entry); if (!(mul = hlsl_new_binary_expr(ctx, HLSL_IR_BINOP_MUL, index, &c->node))) @@ -663,7 +663,7 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_ *modifiers &= ~HLSL_TYPE_MODIFIERS_MASK;
if (new_type->type == HLSL_CLASS_MATRIX) - new_type->reg_size = hlsl_type_is_row_major(new_type) ? new_type->dimy : new_type->dimx; + new_type->reg_size = (hlsl_type_is_row_major(new_type) ? new_type->dimy : new_type->dimx) * 4; return new_type; }
@@ -738,7 +738,7 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type if (type->type != HLSL_CLASS_MATRIX) check_invalid_matrix_modifiers(ctx, type->modifiers, v->loc); else - type->reg_size = hlsl_type_is_row_major(type) ? type->dimy : type->dimx; + type->reg_size = (hlsl_type_is_row_major(type) ? type->dimy : type->dimx) * 4;
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR) && (type->modifiers & HLSL_MODIFIER_ROW_MAJOR)) @@ -1328,7 +1328,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (hlsl_type_component_count(field->type) == hlsl_type_component_count(node->data_type)) { - if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset * 4, node->loc))) + if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, node->loc))) break; list_add_tail(list, &c->node.entry);
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 068fb167..dcd127ea 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -93,7 +93,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; list_add_head(instrs, &load->node.entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset * 4, var->loc))) + if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc))) return; list_add_after(&load->node.entry, &offset->node.entry);
@@ -160,7 +160,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct list_add_before(&var->scope_entry, &output->scope_entry); list_add_tail(&ctx->extern_vars, &output->extern_entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset * 4, var->loc))) + if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc))) return; list_add_tail(instrs, &offset->node.entry);
@@ -291,7 +291,7 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr struct hlsl_ir_load *field_load; struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset * 4, instr->loc))) + if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, instr->loc))) return false; list_add_before(&instr->entry, &c->node.entry);
@@ -714,9 +714,8 @@ static bool is_range_available(struct liveness *liveness, unsigned int first_wri }
static struct hlsl_reg allocate_range(struct hlsl_ctx *ctx, struct liveness *liveness, - unsigned int first_write, unsigned int last_read, unsigned int reg_count) + unsigned int first_write, unsigned int last_read, unsigned int component_count) { - const unsigned int component_count = reg_count * 4; unsigned int i, component_idx; struct hlsl_reg ret = {0};
@@ -738,9 +737,9 @@ static struct hlsl_reg allocate_range(struct hlsl_ctx *ctx, struct liveness *liv
static const char *debug_register(char class, struct hlsl_reg reg, const struct hlsl_type *type) { - if (type->reg_size > 1) + if (type->reg_size > 4) return vkd3d_dbg_sprintf("%c%u-%c%u", class, reg.id, class, - reg.id + type->reg_size - 1); + reg.id + (type->reg_size / 4) - 1); return vkd3d_dbg_sprintf("%c%u%s", class, reg.id, debug_hlsl_writemask(reg.writemask)); }
@@ -751,7 +750,7 @@ static void allocate_variable_temp_register(struct hlsl_ctx *ctx, struct hlsl_ir
if (!var->reg.allocated && var->last_read) { - if (var->data_type->reg_size > 1) + if (var->data_type->reg_size > 4) var->reg = allocate_range(ctx, liveness, var->first_write, var->last_read, var->data_type->reg_size); else @@ -770,7 +769,7 @@ static void allocate_temp_registers_recurse(struct hlsl_ctx *ctx, struct list *i { if (!instr->reg.allocated && instr->last_read) { - if (instr->data_type->reg_size > 1) + if (instr->data_type->reg_size > 4) instr->reg = allocate_range(ctx, liveness, instr->index, instr->last_read, instr->data_type->reg_size); else @@ -832,23 +831,23 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx, struct list * { struct hlsl_ir_constant *constant = hlsl_ir_constant(instr); const struct hlsl_type *type = instr->data_type; + unsigned int x, y, i, writemask, end_reg; unsigned int reg_size = type->reg_size; - unsigned int x, y, i, writemask;
- if (reg_size > 1) + if (reg_size > 4) constant->reg = allocate_range(ctx, liveness, 1, UINT_MAX, reg_size); else constant->reg = allocate_register(ctx, liveness, 1, UINT_MAX, type->dimx); TRACE("Allocated constant @%u to %s.\n", instr->index, debug_register('c', constant->reg, type));
if (!hlsl_array_reserve(ctx, (void **)&defs->values, &defs->size, - constant->reg.id + reg_size, sizeof(*defs->values))) + constant->reg.id + reg_size / 4, sizeof(*defs->values))) return; - if (constant->reg.id + reg_size > defs->count) + end_reg = constant->reg.id + reg_size / 4; + if (end_reg > defs->count) { - memset(&defs->values[defs->count], 0, - sizeof(*defs->values) * (constant->reg.id + reg_size - defs->count)); - defs->count = constant->reg.id + reg_size; + memset(&defs->values[defs->count], 0, sizeof(*defs->values) * (end_reg - defs->count)); + defs->count = end_reg; }
assert(type->type <= HLSL_CLASS_LAST_NUMERIC); @@ -931,7 +930,7 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi { if (var->is_uniform && var->last_read) { - if (var->data_type->reg_size > 1) + if (var->data_type->reg_size > 4) var->reg = allocate_range(ctx, &liveness, 1, UINT_MAX, var->data_type->reg_size); else {