nvk: Move SET_HYBRID_ANTI_ALIAS_CONTROL to draw time

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27025>
This commit is contained in:
Faith Ekstrand
2024-01-11 18:17:31 -06:00
committed by Marge Bot
parent 148ea7792f
commit 0e33dba625
3 changed files with 22 additions and 19 deletions
+13 -2
View File
@@ -1428,13 +1428,13 @@ nvk_flush_ms_state(struct nvk_cmd_buffer *cmd)
&cmd->vk.dynamic_graphics_state;
if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_MS_RASTERIZATION_SAMPLES)) {
struct nv_push *p = nvk_cmd_buffer_push(cmd, 4);
/* When we don't have any attachments, we can't know the sample count
* from the render pass so we need to emit SET_ANTI_ALIAS here. See the
* comment in nvk_BeginRendering() for more details.
*/
if (render->samples == 0) {
struct nv_push *p = nvk_cmd_buffer_push(cmd, 2);
/* Multisample information MAY be missing (rasterizationSamples == 0)
* if rasterizer discard is enabled. However, this isn't valid in
* the hardware so always use at least one sample.
@@ -1449,6 +1449,17 @@ nvk_flush_ms_state(struct nvk_cmd_buffer *cmd)
assert(dyn->ms.rasterization_samples == 0 ||
dyn->ms.rasterization_samples == render->samples);
}
const struct nvk_graphics_pipeline *pipeline = cmd->state.gfx.pipeline;
uint32_t min_samples = ceilf(dyn->ms.rasterization_samples *
pipeline->min_sample_shading);
min_samples = util_next_power_of_two(MAX2(1, min_samples));
P_IMMD(p, NV9097, SET_HYBRID_ANTI_ALIAS_CONTROL, {
.passes = min_samples,
.centroid = min_samples > 1 ? CENTROID_PER_PASS
: CENTROID_PER_FRAGMENT,
});
}
if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_MS_ALPHA_TO_COVERAGE_ENABLE) ||
+7 -17
View File
@@ -46,22 +46,6 @@ nvk_populate_fs_key(struct nak_fs_key *key,
key->force_sample_shading = true;
}
static void
emit_pipeline_ms_state(struct nv_push *p,
const struct vk_multisample_state *ms,
bool force_max_samples)
{
const float min_sample_shading = force_max_samples ? 1 :
(ms->sample_shading_enable ? CLAMP(ms->min_sample_shading, 0, 1) : 0);
uint32_t min_samples = ceilf(ms->rasterization_samples * min_sample_shading);
min_samples = util_next_power_of_two(MAX2(1, min_samples));
P_IMMD(p, NV9097, SET_HYBRID_ANTI_ALIAS_CONTROL, {
.passes = min_samples,
.centroid = min_samples > 1 ? CENTROID_PER_PASS : CENTROID_PER_FRAGMENT,
});
}
static void
emit_pipeline_ct_write_state(struct nv_push *p,
const struct vk_color_blend_state *cb,
@@ -435,11 +419,17 @@ nvk_graphics_pipeline_create(struct nvk_device *dev,
emit_pipeline_xfb_state(&push, &last_geom->info.vtg.xfb);
if (state.ms) emit_pipeline_ms_state(&push, state.ms, force_max_samples);
emit_pipeline_ct_write_state(&push, state.cb, state.rp);
pipeline->push_dw_count = nv_push_dw_count(&push);
if (force_max_samples)
pipeline->min_sample_shading = 1;
else if (state.ms != NULL && state.ms->sample_shading_enable)
pipeline->min_sample_shading = CLAMP(state.ms->min_sample_shading, 0, 1);
else
pipeline->min_sample_shading = 0;
pipeline->dynamic.vi = &pipeline->_dynamic_vi;
pipeline->dynamic.ms.sample_locations = &pipeline->_dynamic_sl;
vk_dynamic_graphics_state_fill(&pipeline->dynamic, &state);
+2
View File
@@ -57,6 +57,8 @@ struct nvk_graphics_pipeline {
uint32_t push_data[192];
uint32_t push_dw_count;
float min_sample_shading;
struct vk_vertex_input_state _dynamic_vi;
struct vk_sample_locations_state _dynamic_sl;
struct vk_dynamic_graphics_state dynamic;