nvk: Move nvk_sample_location to NAK

It's part of the NAK compiler interface so that's where it should live.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29194>
This commit is contained in:
Faith Ekstrand
2024-08-05 09:04:12 -05:00
committed by Marge Bot
parent 644dcc0337
commit 315b788c7b
3 changed files with 25 additions and 19 deletions
+17 -4
View File
@@ -31,6 +31,13 @@ nak_nir_options(const struct nak_compiler *nak);
void nak_preprocess_nir(nir_shader *nir, const struct nak_compiler *nak);
struct nak_sample_location {
uint8_t x_u4 : 4;
uint8_t y_u4 : 4;
};
static_assert(sizeof(struct nak_sample_location) == 1,
"This struct has no holes");
PRAGMA_DIAGNOSTIC_PUSH
PRAGMA_DIAGNOSTIC_ERROR(-Wpadded)
struct nak_fs_key {
@@ -43,11 +50,17 @@ struct nak_fs_key {
bool uses_underestimate;
/**
* The constant buffer index and offset at which the sample locations table lives.
* Each sample location is two 4-bit unorm values packed into an 8-bit value
* with the bottom 4 bits for x and the top 4 bits for y.
*/
* The constant buffer index and offset at which the sample locations table
* lives.
*/
uint8_t sample_locations_cb;
/**
* The offset into sample_info_cb at which the sample locations live. The
* sample locations table is an array of nak_sample_location where each
* sample location is two 4-bit unorm values packed into an 8-bit value
* with the bottom 4 bits for x and the top 4 bits for y.
*/
uint32_t sample_locations_offset;
};
PRAGMA_DIAGNOSTIC_POP
+1 -8
View File
@@ -29,13 +29,6 @@ struct nvk_push_descriptor_set;
struct nvk_shader;
struct vk_shader;
struct nvk_sample_location {
uint8_t x_u4:4;
uint8_t y_u4:4;
};
static_assert(sizeof(struct nvk_sample_location) == 1,
"This struct has no holes");
/** Root descriptor table. This gets pushed to the GPU directly */
struct nvk_root_descriptor_table {
union {
@@ -44,7 +37,7 @@ struct nvk_root_descriptor_table {
uint32_t base_instance;
uint32_t draw_index;
uint32_t view_index;
struct nvk_sample_location sample_locations[NVK_MAX_SAMPLES];
struct nak_sample_location sample_locations[NVK_MAX_SAMPLES];
} draw;
struct {
uint32_t base_group[3];
+7 -7
View File
@@ -1941,10 +1941,10 @@ vk_sample_location(const struct vk_sample_locations_state *sl,
return sl->locations[(x + y * sl->grid_size.width) * sl->per_pixel + s];
}
static struct nvk_sample_location
vk_to_nvk_sample_location(VkSampleLocationEXT loc)
static struct nak_sample_location
vk_to_nak_sample_location(VkSampleLocationEXT loc)
{
return (struct nvk_sample_location) {
return (struct nak_sample_location) {
.x_u4 = util_bitpack_ufixed_clamp(loc.x, 0, 3, 4),
.y_u4 = util_bitpack_ufixed_clamp(loc.y, 0, 3, 4),
};
@@ -2013,23 +2013,23 @@ nvk_flush_ms_state(struct nvk_cmd_buffer *cmd)
sl = vk_standard_sample_locations_state(samples);
}
struct nvk_sample_location push_sl[NVK_MAX_SAMPLES];
struct nak_sample_location push_sl[NVK_MAX_SAMPLES];
for (uint32_t i = 0; i < sl->per_pixel; i++)
push_sl[i] = vk_to_nvk_sample_location(sl->locations[i]);
push_sl[i] = vk_to_nak_sample_location(sl->locations[i]);
nvk_descriptor_state_set_root_array(cmd, &cmd->state.gfx.descriptors,
draw.sample_locations,
0, NVK_MAX_SAMPLES, push_sl);
if (nvk_cmd_buffer_3d_cls(cmd) >= MAXWELL_B) {
struct nvk_sample_location loc[16];
struct nak_sample_location loc[16];
for (uint32_t n = 0; n < ARRAY_SIZE(loc); n++) {
const uint32_t s = n % sl->per_pixel;
const uint32_t px = n / sl->per_pixel;
const uint32_t x = px % 2;
const uint32_t y = px / 2;
loc[n] = vk_to_nvk_sample_location(vk_sample_location(sl, x, y, s));
loc[n] = vk_to_nak_sample_location(vk_sample_location(sl, x, y, s));
}
struct nv_push *p = nvk_cmd_buffer_push(cmd, 5);