mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 16:00:08 +01:00
nvk: Fill out sample locations on Maxwell B+
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
parent
7660e585f6
commit
a34edc7500
7 changed files with 77 additions and 2 deletions
|
|
@ -51,6 +51,8 @@ nvk_create_cmd_buffer(struct vk_command_pool *vk_pool,
|
|||
|
||||
cmd->vk.dynamic_graphics_state.vi =
|
||||
&cmd->state.gfx._dynamic_vi;
|
||||
cmd->vk.dynamic_graphics_state.ms.sample_locations =
|
||||
&cmd->state.gfx._dynamic_sl;
|
||||
|
||||
list_inithead(&cmd->bos);
|
||||
util_dynarray_init(&cmd->pushes, NULL);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ struct nvk_graphics_state {
|
|||
|
||||
/* Needed by vk_command_buffer::dynamic_graphics_state */
|
||||
struct vk_vertex_input_state _dynamic_vi;
|
||||
struct vk_sample_locations_state _dynamic_sl;
|
||||
};
|
||||
|
||||
struct nvk_compute_state {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "nvk_pipeline.h"
|
||||
|
||||
#include "nil_format.h"
|
||||
#include "util/bitpack_helpers.h"
|
||||
#include "vulkan/runtime/vk_render_pass.h"
|
||||
#include "vulkan/util/vk_format.h"
|
||||
|
||||
|
|
@ -909,6 +910,69 @@ nvk_flush_rs_state(struct nvk_cmd_buffer *cmd)
|
|||
}
|
||||
}
|
||||
|
||||
static VkSampleLocationEXT
|
||||
vk_sample_location(const struct vk_sample_locations_state *sl,
|
||||
uint32_t x, uint32_t y, uint32_t s)
|
||||
{
|
||||
x = x % sl->grid_size.width;
|
||||
y = y % sl->grid_size.height;
|
||||
|
||||
return sl->locations[(x + y * sl->grid_size.width) * sl->per_pixel + s];
|
||||
}
|
||||
|
||||
struct nvk_sample_location {
|
||||
uint8_t x_u4:4;
|
||||
uint8_t y_u4:4;
|
||||
};
|
||||
|
||||
static struct nvk_sample_location
|
||||
vk_to_nvk_sample_location(VkSampleLocationEXT loc)
|
||||
{
|
||||
return (struct nvk_sample_location) {
|
||||
.x_u4 = util_bitpack_ufixed(loc.x, 0, 3, 4),
|
||||
.y_u4 = util_bitpack_ufixed(loc.y, 0, 3, 4),
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
nvk_flush_ms_state(struct nvk_cmd_buffer *cmd)
|
||||
{
|
||||
const struct vk_dynamic_graphics_state *dyn =
|
||||
&cmd->vk.dynamic_graphics_state;
|
||||
|
||||
if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_MS_SAMPLE_LOCATIONS)) {
|
||||
const struct vk_sample_locations_state *sl = dyn->ms.sample_locations;
|
||||
|
||||
if (nvk_cmd_buffer_3d_cls(cmd) >= MAXWELL_B) {
|
||||
struct nvk_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));
|
||||
}
|
||||
|
||||
struct nv_push *p = nvk_cmd_buffer_push(cmd, 5);
|
||||
|
||||
P_MTHD(p, NVB197, SET_ANTI_ALIAS_SAMPLE_POSITIONS(0));
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
P_NVB197_SET_ANTI_ALIAS_SAMPLE_POSITIONS(p, i, {
|
||||
.x0 = loc[i * 4 + 0].x_u4,
|
||||
.y0 = loc[i * 4 + 0].y_u4,
|
||||
.x1 = loc[i * 4 + 1].x_u4,
|
||||
.y1 = loc[i * 4 + 1].y_u4,
|
||||
.x2 = loc[i * 4 + 2].x_u4,
|
||||
.y2 = loc[i * 4 + 2].y_u4,
|
||||
.x3 = loc[i * 4 + 3].x_u4,
|
||||
.y3 = loc[i * 4 + 3].y_u4,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
vk_to_nv9097_compare_op(VkCompareOp vk_op)
|
||||
{
|
||||
|
|
@ -1085,8 +1149,8 @@ nvk_flush_dynamic_state(struct nvk_cmd_buffer *cmd)
|
|||
nvk_flush_rs_state(cmd);
|
||||
|
||||
/* MESA_VK_DYNAMIC_FSR */
|
||||
/* MESA_VK_DYNAMIC_MS_SAMPLE_LOCATIONS */
|
||||
|
||||
nvk_flush_ms_state(cmd);
|
||||
nvk_flush_ds_state(cmd);
|
||||
nvk_flush_cb_state(cmd);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ nvk_device_finish_meta(struct nvk_device *dev)
|
|||
|
||||
struct nvk_meta_save {
|
||||
struct vk_vertex_input_state _dynamic_vi;
|
||||
struct vk_sample_locations_state _dynamic_sl;
|
||||
struct vk_dynamic_graphics_state dynamic;
|
||||
struct nvk_graphics_pipeline *pipeline;
|
||||
struct nvk_addr_range vb0;
|
||||
|
|
@ -61,6 +62,7 @@ nvk_meta_begin(struct nvk_cmd_buffer *cmd,
|
|||
{
|
||||
save->dynamic = cmd->vk.dynamic_graphics_state;
|
||||
save->_dynamic_vi = cmd->state.gfx._dynamic_vi;
|
||||
save->_dynamic_sl = cmd->state.gfx._dynamic_sl;
|
||||
|
||||
save->pipeline = cmd->state.gfx.pipeline;
|
||||
save->vb0 = cmd->state.gfx.vb0;
|
||||
|
|
@ -105,8 +107,10 @@ nvk_meta_end(struct nvk_cmd_buffer *cmd,
|
|||
|
||||
/* Restore the dynamic state */
|
||||
assert(save->dynamic.vi == &cmd->state.gfx._dynamic_vi);
|
||||
assert(save->dynamic.ms.sample_locations == &cmd->state.gfx._dynamic_sl);
|
||||
cmd->vk.dynamic_graphics_state = save->dynamic;
|
||||
cmd->state.gfx._dynamic_vi = save->_dynamic_vi;
|
||||
cmd->state.gfx._dynamic_sl = save->_dynamic_sl;
|
||||
memcpy(cmd->vk.dynamic_graphics_state.dirty,
|
||||
cmd->vk.dynamic_graphics_state.set,
|
||||
sizeof(cmd->vk.dynamic_graphics_state.set));
|
||||
|
|
|
|||
|
|
@ -355,6 +355,7 @@ nvk_graphics_pipeline_create(struct nvk_device *device,
|
|||
pipeline->push_dw_count = nv_push_dw_count(&push);
|
||||
|
||||
pipeline->dynamic.vi = &pipeline->_dynamic_vi;
|
||||
pipeline->dynamic.ms.sample_locations = &pipeline->_dynamic_sl;
|
||||
vk_dynamic_graphics_state_fill(&pipeline->dynamic, &state);
|
||||
|
||||
*pPipeline = nvk_pipeline_to_handle(&pipeline->base);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include "cla0c0.h"
|
||||
#include "cla1c0.h"
|
||||
#include "clb0c0.h"
|
||||
#include "clb197.h"
|
||||
#include "clb1c0.h"
|
||||
#include "clc0c0.h"
|
||||
#include "clc1c0.h"
|
||||
|
|
@ -355,7 +356,7 @@ vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance, const char *pName)
|
|||
}
|
||||
|
||||
static void
|
||||
nvk_get_device_extensions(const struct nvk_physical_device *device,
|
||||
nvk_get_device_extensions(const struct nvk_physical_device *pdev,
|
||||
struct vk_device_extension_table *ext)
|
||||
{
|
||||
*ext = (struct vk_device_extension_table) {
|
||||
|
|
@ -390,6 +391,7 @@ nvk_get_device_extensions(const struct nvk_physical_device *device,
|
|||
.EXT_inline_uniform_block = true,
|
||||
.EXT_pci_bus_info = true,
|
||||
.EXT_private_data = true,
|
||||
.EXT_sample_locations = pdev->info.cls_eng3d >= MAXWELL_B,
|
||||
.EXT_vertex_input_dynamic_state = true,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ struct nvk_graphics_pipeline {
|
|||
uint32_t push_dw_count;
|
||||
|
||||
struct vk_vertex_input_state _dynamic_vi;
|
||||
struct vk_sample_locations_state _dynamic_sl;
|
||||
struct vk_dynamic_graphics_state dynamic;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue