nvk/cmd_buffer: Pass count to set_root_array

Previously, we were passing the end index which was incorrect.
Also, improve the macros so that they can take an expression for
the count.

Fixes: b2d85ca36f ("nvk: Use helper macros for accessing root descriptors")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
(cherry picked from commit 64f17c1391)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32119>
This commit is contained in:
M Henning 2024-11-11 18:06:37 -05:00 committed by Dylan Baker
parent 97d974a3ad
commit e7ebb97fdf
3 changed files with 9 additions and 7 deletions

View file

@ -634,7 +634,7 @@
"description": "nvk/cmd_buffer: Pass count to set_root_array",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "b2d85ca36f9522689f55f2193936507b74af094d",
"notes": null

View file

@ -749,7 +749,7 @@ nvk_bind_descriptor_sets(struct nvk_cmd_buffer *cmd,
assert(next_dyn_offset <= info->dynamicOffsetCount);
nvk_descriptor_state_set_root_array(cmd, desc, dynamic_buffers,
dyn_buffer_start, dyn_buffer_end,
dyn_buffer_start, dyn_buffer_end - dyn_buffer_start,
&dynamic_buffers[dyn_buffer_start]);
/* We need to set everything above first_set because later calls to

View file

@ -103,8 +103,9 @@ struct nvk_descriptor_state {
const struct nvk_root_descriptor_table *root = \
(const struct nvk_root_descriptor_table *)(desc)->root; \
unsigned _start = start; \
assert(_start + count <= ARRAY_SIZE(root->member)); \
for (unsigned i = 0; i < count; i++) \
unsigned _count = count; \
assert(_start + _count <= ARRAY_SIZE(root->member)); \
for (unsigned i = 0; i < _count; i++) \
(dst)[i] = root->member[i + _start]; \
} while (0)
@ -125,13 +126,14 @@ struct nvk_descriptor_state {
struct nvk_root_descriptor_table *root = \
(struct nvk_root_descriptor_table *)_desc->root; \
unsigned _start = start; \
assert(_start + count <= ARRAY_SIZE(root->member)); \
for (unsigned i = 0; i < count; i++) \
unsigned _count = count; \
assert(_start + _count <= ARRAY_SIZE(root->member)); \
for (unsigned i = 0; i < _count; i++) \
root->member[i + _start] = (src)[i]; \
if (_desc->flush_root != NULL) { \
size_t offset = (char *)&root->member[_start] - (char *)root; \
_desc->flush_root((cmd), _desc, offset, \
count * sizeof(root->member[0])); \
_count * sizeof(root->member[0])); \
} \
} while (0)