nvk: Add a macro for root descriptor table byte offsets

Use a helper macro instead of using offsetof directly.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
George Ouzounoudis
2022-11-09 20:13:26 +02:00
committed by Marge Bot
parent 0de4083544
commit 73f5ab5456
2 changed files with 7 additions and 3 deletions
+4
View File
@@ -38,6 +38,10 @@ struct nvk_root_descriptor_table {
struct nvk_buffer_address dynamic_buffers[NVK_MAX_DYNAMIC_BUFFERS];
};
/* helper macro for computing root descriptor byte offsets */
#define nvk_root_descriptor_offset(member)\
offsetof(struct nvk_root_descriptor_table, member)
struct nvk_descriptor_state {
struct nvk_root_descriptor_table root;
struct nvk_descriptor_set *sets[NVK_MAX_SETS];
@@ -20,7 +20,7 @@ load_descriptor_set_addr(nir_builder *b, uint32_t set,
UNUSED const struct lower_descriptors_ctx *ctx)
{
uint32_t set_addr_offset =
offsetof(struct nvk_root_descriptor_table, sets) + set * sizeof(uint64_t);
nvk_root_descriptor_offset(sets) + set * sizeof(uint64_t);
return nir_load_ubo(b, 1, 64, nir_imm_int(b, 0),
nir_imm_int(b, set_addr_offset),
@@ -56,7 +56,7 @@ load_descriptor(nir_builder *b, unsigned num_components, unsigned bit_size,
nir_ssa_def *root_desc_offset =
nir_iadd_imm(b, nir_imul_imm(b, index, sizeof(struct nvk_buffer_address)),
offsetof(struct nvk_root_descriptor_table, dynamic_buffers));
nvk_root_descriptor_offset(dynamic_buffers));
return nir_load_ubo(b, num_components, bit_size,
nir_imm_int(b, 0), root_desc_offset,
@@ -128,7 +128,7 @@ lower_load_push_constant(nir_builder *b, nir_intrinsic_instr *load,
const struct lower_descriptors_ctx *ctx)
{
const uint32_t push_region_offset =
offsetof(struct nvk_root_descriptor_table, push);
nvk_root_descriptor_offset(push);
const uint32_t base = nir_intrinsic_base(load);
b->cursor = nir_before_instr(&load->instr);