vkd3d-shader/dxil: Pre-allocate instruction space for globals in sm6_parser_globals_init().

For simplicity, declaration handlers assume instruction allocation will
not fail.
This commit is contained in:
Conor McCarthy 2023-12-01 14:46:21 +10:00 committed by Alexandre Julliard
parent 8aa6e2228e
commit 111818eabb
Notes: Alexandre Julliard 2024-01-03 23:09:35 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/505

View File

@ -2877,8 +2877,8 @@ static const struct vkd3d_shader_immediate_constant_buffer *resolve_forward_init
static enum vkd3d_result sm6_parser_globals_init(struct sm6_parser *sm6)
{
size_t i, count, base_value_idx = sm6->value_count;
const struct dxil_block *block = &sm6->root_block;
size_t i, base_value_idx = sm6->value_count;
struct vkd3d_shader_instruction *ins;
const struct dxil_record *record;
enum vkd3d_result ret;
@ -2887,6 +2887,10 @@ static enum vkd3d_result sm6_parser_globals_init(struct sm6_parser *sm6)
sm6->p.location.line = block->id;
sm6->p.location.column = 0;
for (i = 0, count = 0; i < block->record_count; ++i)
count += block->records[i]->code == MODULE_CODE_GLOBALVAR;
sm6_parser_require_space(sm6, count);
for (i = 0; i < block->record_count; ++i)
{
sm6->p.location.column = i;