diff --git a/src/nouveau/compiler/nak.h b/src/nouveau/compiler/nak.h index afbeef14d7e..91266490fdb 100644 --- a/src/nouveau/compiler/nak.h +++ b/src/nouveau/compiler/nak.h @@ -58,6 +58,12 @@ struct nak_fs_key { bool force_sample_shading; bool uses_underestimate; + uint8_t pad; +}; +PRAGMA_DIAGNOSTIC_POP +static_assert(sizeof(struct nak_fs_key) == 4, "This struct has no holes"); + +struct nak_constant_offset_info { /** * The constant buffer index and offset at which the sample locations and * pass sample masks tables lives. @@ -80,9 +86,7 @@ struct nak_fs_key { */ uint32_t sample_masks_offset; }; -PRAGMA_DIAGNOSTIC_POP -static_assert(sizeof(struct nak_fs_key) == 12, "This struct has no holes"); - +const extern struct nak_constant_offset_info nak_const_offsets; void nak_postprocess_nir(nir_shader *nir, const struct nak_compiler *nak, nir_variable_mode robust2_modes, diff --git a/src/nouveau/compiler/nak_nir_lower_fs_inputs.c b/src/nouveau/compiler/nak_nir_lower_fs_inputs.c index 52814c77334..8a7d6f16d72 100644 --- a/src/nouveau/compiler/nak_nir_lower_fs_inputs.c +++ b/src/nouveau/compiler/nak_nir_lower_fs_inputs.c @@ -100,9 +100,9 @@ load_sample_pos_u4_at(nir_builder *b, nir_def *sample_id, const struct nak_fs_key *fs_key) { nir_def *loc = nir_ldc_nv(b, 1, 8, - nir_imm_int(b, fs_key->sample_info_cb), + nir_imm_int(b, nak_const_offsets.sample_info_cb), nir_iadd_imm(b, sample_id, - fs_key->sample_locations_offset), + nak_const_offsets.sample_locations_offset), .align_mul = 1, .align_offset = 0); /* The rest of these calculations are in 32-bit */ @@ -118,10 +118,10 @@ load_pass_sample_mask_at(nir_builder *b, nir_def *sample_id, { nir_def *offset = nir_imul_imm(b, sample_id, sizeof(struct nak_sample_mask)); - offset = nir_iadd_imm(b, offset, fs_key->sample_masks_offset); + offset = nir_iadd_imm(b, offset, nak_const_offsets.sample_masks_offset); return nir_ldc_nv(b, 1, 8 * sizeof(struct nak_sample_mask), - nir_imm_int(b, fs_key->sample_info_cb), offset, + nir_imm_int(b, nak_const_offsets.sample_info_cb), offset, .align_mul = sizeof(struct nak_sample_mask), .align_offset = 0); } diff --git a/src/nouveau/vulkan/nvk_shader.c b/src/nouveau/vulkan/nvk_shader.c index 1311497aeb8..49eb2d94ffa 100644 --- a/src/nouveau/vulkan/nvk_shader.c +++ b/src/nouveau/vulkan/nvk_shader.c @@ -34,6 +34,12 @@ #include "nv_push_clc397.h" #include "nv_push_clc797.h" +const struct nak_constant_offset_info nak_const_offsets = { + .sample_info_cb = 0, + .sample_locations_offset = nvk_root_descriptor_offset(draw.sample_locations), + .sample_masks_offset = nvk_root_descriptor_offset(draw.sample_masks), +}; + static void shared_var_info(const struct glsl_type *type, unsigned *size, unsigned *align) { @@ -152,10 +158,6 @@ nvk_populate_fs_key(struct nak_fs_key *key, { memset(key, 0, sizeof(*key)); - key->sample_info_cb = 0; - key->sample_locations_offset = nvk_root_descriptor_offset(draw.sample_locations); - key->sample_masks_offset = nvk_root_descriptor_offset(draw.sample_masks); - /* Turn underestimate on when no state is availaible or if explicitly set */ if (state == NULL || state->rs == NULL || state->rs->conservative_mode == VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT)