From 41d094c2cc1da09444830dca866d2be7f03ae5b4 Mon Sep 17 00:00:00 2001 From: George Ouzounoudis Date: Thu, 10 Aug 2023 00:03:24 +0300 Subject: [PATCH] nvk: Support dynamic state for enabling sample locations When switching dynamically we should also push the corresponding sample locations, the default when disabled or the custom ones when enabled. Part-of: --- src/nouveau/vulkan/nvk_cmd_draw.c | 15 +++++++++++---- src/nouveau/vulkan/nvk_physical_device.c | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 6eeb9c6..3e7c665 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -11,6 +11,7 @@ #include "nil_format.h" #include "util/bitpack_helpers.h" #include "vulkan/runtime/vk_render_pass.h" +#include "vulkan/runtime/vk_standard_sample_locations.h" #include "vulkan/util/vk_format.h" #include "nouveau_context.h" @@ -1206,8 +1207,8 @@ 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), + .x_u4 = util_bitpack_ufixed_clamp(loc.x, 0, 3, 4), + .y_u4 = util_bitpack_ufixed_clamp(loc.y, 0, 3, 4), }; } @@ -1217,8 +1218,14 @@ 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 (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_MS_SAMPLE_LOCATIONS) || + BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_MS_SAMPLE_LOCATIONS_ENABLE)) { + const struct vk_sample_locations_state *sl; + if (dyn->ms.sample_locations_enable) { + sl = dyn->ms.sample_locations; + } else { + sl = vk_standard_sample_locations_state(dyn->ms.rasterization_samples); + } if (nvk_cmd_buffer_3d_cls(cmd) >= MAXWELL_B) { struct nvk_sample_location loc[16]; diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index aa9b3a9..7e0834f 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -293,7 +293,7 @@ nvk_get_device_features(const struct nv_device_info *info, .extendedDynamicState3ConservativeRasterizationMode = false, .extendedDynamicState3ExtraPrimitiveOverestimationSize = false, .extendedDynamicState3DepthClipEnable = false, - .extendedDynamicState3SampleLocationsEnable = false, + .extendedDynamicState3SampleLocationsEnable = info->cls_eng3d >= MAXWELL_B, .extendedDynamicState3ColorBlendAdvanced = false, .extendedDynamicState3ProvokingVertexMode = true, .extendedDynamicState3LineRasterizationMode = true, -- 2.7.4