panvk: implement sampleRateShading

It doesn't feel great that we need to compile multiple identical shaders
just because we're going to toggle a bit in the command-stream, but this
seems to be the current state-of-art in mesa, so hmpf...

It makes state-validation trivial, so there's that.

This is loosely based on what NVK does.

Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32004>
This commit is contained in:
Erik Faye-Lund 2024-11-06 13:39:34 +01:00 committed by Marge Bot
parent 83c2d82637
commit 60146cc57c
5 changed files with 18 additions and 1 deletions

View file

@ -2793,3 +2793,7 @@ dEQP-VK.api.info.unsupported_image_usage.optimal.input_attachment_eac_r11_snorm_
dEQP-VK.api.info.unsupported_image_usage.optimal.input_attachment_etc2_r8g8b8a1_unorm_block,Fail
dEQP-VK.draw.dynamic_rendering.primary_cmd_buff.multiple_interpolation.separate.no_sample_decoration.1_sample,Fail
dEQP-VK.wsi.xcb.swapchain.simulate_oom.image_extent,Crash
# New with sampleRateShading
dEQP-VK.pipeline.monolithic.multisample_shader_builtin.write_sample_mask.1_samples,Fail
dEQP-VK.draw.dynamic_rendering.complete_secondary_cmd_buff.linear_interpolation.offset_max_1_sample,Fail

View file

@ -1160,6 +1160,7 @@ prepare_dcd(struct panvk_cmd_buffer *cmdbuf)
cfg.pixel_kill_operation = earlyzs.kill;
cfg.zs_update_operation = earlyzs.update;
cfg.evaluate_per_sample = fs->info.fs.sample_shading;
} else {
cfg.allow_forward_pixel_to_kill = true;
cfg.allow_forward_pixel_to_be_killed = true;

View file

@ -391,6 +391,7 @@ panvk_draw_prepare_fs_rsd(struct panvk_cmd_buffer *cmdbuf,
cfg.properties.pixel_kill_operation = earlyzs.kill;
cfg.properties.zs_update_operation = earlyzs.update;
cfg.multisample_misc.evaluate_per_sample = fs->info.fs.sample_shading;
} else {
cfg.properties.depth_source = MALI_DEPTH_SOURCE_FIXED_FUNCTION;
cfg.properties.allow_forward_pixel_to_kill = true;

View file

@ -264,6 +264,7 @@ get_features(const struct panvk_physical_device *device,
.robustBufferAccess = true,
.fullDrawIndexUint32 = true,
.independentBlend = true,
.sampleRateShading = true,
.logicOp = true,
.wideLines = true,
.largePoints = true,

View file

@ -364,7 +364,13 @@ panvk_hash_graphics_state(struct vk_physical_device *device,
struct mesa_blake3 blake3_ctx;
_mesa_blake3_init(&blake3_ctx);
/* We don't need to do anything here yet */
/* This doesn't impact the shader compile but it does go in the
* panvk_shader and gets [de]serialized along with the binary so
* we need to hash it.
*/
bool sample_shading_enable = state->ms && state->ms->sample_shading_enable;
_mesa_blake3_update(&blake3_ctx, &sample_shading_enable,
sizeof(sample_shading_enable));
_mesa_blake3_final(&blake3_ctx, blake3_out);
}
@ -846,6 +852,10 @@ panvk_compile_shader(struct panvk_device *dev,
return result;
}
if (info->stage == MESA_SHADER_FRAGMENT && state != NULL &&
state->ms != NULL && state->ms->sample_shading_enable)
shader->info.fs.sample_shading = true;
*shader_out = &shader->vk;
return result;