summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2023-05-10 17:29:29 +0200
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>2023-05-15 08:14:31 +0200
commitc51c68ba4bc35a7800d7960f3bd3676fcc45ef8f (patch)
treecd86b92e20cc577f3502527a904f4c61b509229d
parent4a379f7637a940cb9bcefa95203bdaecda934f95 (diff)
downloadmesa-c51c68ba4bc35a7800d7960f3bd3676fcc45ef8f.tar.gz
radv: implement dynamic sample locations enable
VK_EXT_sample_locations is only supported on < GFX10 due to some weird issues on recent GPUs. extendedDynamicState3SampleLocationsEnable is only enabled on GFX6-GFX9 for the same reason. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22947>
-rw-r--r--docs/relnotes/new_features.txt1
-rw-r--r--src/amd/vulkan/radv_cmd_buffer.c21
-rw-r--r--src/amd/vulkan/radv_physical_device.c2
-rw-r--r--src/amd/vulkan/radv_pipeline_graphics.c11
-rw-r--r--src/amd/vulkan/radv_private.h25
5 files changed, 39 insertions, 21 deletions
diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt
index 9010653d6f7..6916f81b6fd 100644
--- a/docs/relnotes/new_features.txt
+++ b/docs/relnotes/new_features.txt
@@ -1 +1,2 @@
VK_EXT_attachment_feedback_loop_dynamic_state on RADV
+extendedDynamicState3SampleLocationsEnable on RADV
diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 3357af08234..15b6b7cbab7 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -203,6 +203,7 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer, const struct radv_dy
RADV_CMP_COPY(vk.ms.alpha_to_coverage_enable, RADV_DYNAMIC_ALPHA_TO_COVERAGE_ENABLE);
RADV_CMP_COPY(vk.ms.sample_mask, RADV_DYNAMIC_SAMPLE_MASK);
RADV_CMP_COPY(vk.ms.rasterization_samples, RADV_DYNAMIC_RASTERIZATION_SAMPLES);
+ RADV_CMP_COPY(vk.ms.sample_locations_enable, RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE);
RADV_CMP_COPY(vk.ds.depth.bounds_test.min, RADV_DYNAMIC_DEPTH_BOUNDS);
RADV_CMP_COPY(vk.ds.depth.bounds_test.max, RADV_DYNAMIC_DEPTH_BOUNDS);
@@ -1088,7 +1089,7 @@ radv_emit_sample_locations(struct radv_cmd_buffer *cmd_buffer)
VkOffset2D sample_locs[4][8]; /* 8 is the max. sample count supported */
uint64_t centroid_priority;
- if (!d->sample_location.count)
+ if (!d->sample_location.count || !d->vk.ms.sample_locations_enable)
return;
/* Convert the user sample locations to hardware sample locations. */
@@ -6485,8 +6486,6 @@ radv_bind_multisample_state(struct radv_cmd_buffer *cmd_buffer,
cmd_buffer->state.ms.sample_shading_enable = true;
cmd_buffer->state.ms.min_sample_shading = ms->min_sample_shading;
}
-
- cmd_buffer->state.ms.uses_user_sample_locations = ms->uses_user_sample_locations;
}
static void
@@ -7565,6 +7564,17 @@ radv_CmdSetColorBlendEquationEXT(VkCommandBuffer commandBuffer, uint32_t firstAt
}
VKAPI_ATTR void VKAPI_CALL
+radv_CmdSetSampleLocationsEnableEXT(VkCommandBuffer commandBuffer, VkBool32 sampleLocationsEnable)
+{
+ RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
+ struct radv_cmd_state *state = &cmd_buffer->state;
+
+ state->dynamic.vk.ms.sample_locations_enable = sampleLocationsEnable;
+
+ state->dirty |= RADV_CMD_DIRTY_DYNAMIC_SAMPLE_LOCATIONS_ENABLE;
+}
+
+VKAPI_ATTR void VKAPI_CALL
radv_CmdSetDiscardRectangleEnableEXT(VkCommandBuffer commandBuffer, VkBool32 discardRectangleEnable)
{
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
@@ -8953,7 +8963,7 @@ radv_get_ngg_culling_settings(struct radv_cmd_buffer *cmd_buffer, bool vp_y_inve
/* Small primitive culling assumes a sample position at (0.5, 0.5)
* so don't enable it with user sample locations.
*/
- if (!cmd_buffer->state.ms.uses_user_sample_locations) {
+ if (!d->vk.ms.sample_locations_enable) {
nggc_settings |= radv_nggc_small_primitives;
/* small_prim_precision = num_samples / 2^subpixel_bits
@@ -9061,7 +9071,8 @@ radv_emit_all_graphics_states(struct radv_cmd_buffer *cmd_buffer, const struct r
(RADV_CMD_DIRTY_PIPELINE | RADV_CMD_DIRTY_DYNAMIC_CULL_MODE |
RADV_CMD_DIRTY_DYNAMIC_FRONT_FACE | RADV_CMD_DIRTY_DYNAMIC_RASTERIZER_DISCARD_ENABLE |
RADV_CMD_DIRTY_DYNAMIC_VIEWPORT | RADV_CMD_DIRTY_DYNAMIC_CONSERVATIVE_RAST_MODE |
- RADV_CMD_DIRTY_DYNAMIC_RASTERIZATION_SAMPLES | RADV_CMD_DIRTY_DYNAMIC_PRIMITIVE_TOPOLOGY)) &&
+ RADV_CMD_DIRTY_DYNAMIC_RASTERIZATION_SAMPLES | RADV_CMD_DIRTY_DYNAMIC_PRIMITIVE_TOPOLOGY |
+ RADV_CMD_DIRTY_DYNAMIC_SAMPLE_LOCATIONS_ENABLE)) &&
cmd_buffer->state.has_nggc)
radv_emit_ngg_culling_state(cmd_buffer);
diff --git a/src/amd/vulkan/radv_physical_device.c b/src/amd/vulkan/radv_physical_device.c
index 2cb223a7444..aad6c6871f8 100644
--- a/src/amd/vulkan/radv_physical_device.c
+++ b/src/amd/vulkan/radv_physical_device.c
@@ -1244,7 +1244,7 @@ radv_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
features->extendedDynamicState3ColorWriteMask = true;
features->extendedDynamicState3RasterizationSamples = true;
features->extendedDynamicState3ColorBlendEquation = true;
- features->extendedDynamicState3SampleLocationsEnable = false; /* TODO */
+ features->extendedDynamicState3SampleLocationsEnable = pdevice->rad_info.gfx_level < GFX10;
features->extendedDynamicState3LineRasterizationMode = true;
features->extendedDynamicState3ExtraPrimitiveOverestimationSize = false;
features->extendedDynamicState3AlphaToOneEnable = false;
diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c
index 102edc946b9..03273681026 100644
--- a/src/amd/vulkan/radv_pipeline_graphics.c
+++ b/src/amd/vulkan/radv_pipeline_graphics.c
@@ -370,8 +370,6 @@ radv_pipeline_init_multisample_state(const struct radv_device *device,
ms->sample_shading_enable = true;
ms->min_sample_shading = state->ms->min_sample_shading;
}
-
- ms->uses_user_sample_locations = state->ms && state->ms->sample_locations_enable;
}
static uint32_t
@@ -515,6 +513,8 @@ radv_dynamic_state_mask(VkDynamicState state)
return RADV_DYNAMIC_DISCARD_RECTANGLE_MODE;
case VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT:
return RADV_DYNAMIC_ATTACHMENT_FEEDBACK_LOOP_ENABLE;
+ case VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_ENABLE_EXT:
+ return RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE;
default:
unreachable("Unhandled dynamic state");
}
@@ -590,7 +590,8 @@ radv_pipeline_needed_dynamic_state(const struct radv_graphics_pipeline *pipeline
!state->dr->rectangle_count)
states &= ~RADV_DYNAMIC_DISCARD_RECTANGLE;
- if (!state->ms || !state->ms->sample_locations_enable)
+ if (!(pipeline->dynamic_states & RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE) &&
+ (!state->ms || !state->ms->sample_locations_enable))
states &= ~RADV_DYNAMIC_SAMPLE_LOCATIONS;
if (!(pipeline->dynamic_states & RADV_DYNAMIC_LINE_STIPPLE_ENABLE) &&
@@ -1041,6 +1042,10 @@ radv_pipeline_init_dynamic_state(struct radv_graphics_pipeline *pipeline,
dynamic->vk.ms.rasterization_samples = state->ms->rasterization_samples;
}
+ if (states & RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE) {
+ dynamic->vk.ms.sample_locations_enable = state->ms->sample_locations_enable;
+ }
+
if (states & RADV_DYNAMIC_SAMPLE_LOCATIONS) {
unsigned count = state->ms->sample_locations->per_pixel *
state->ms->sample_locations->grid_size.width *
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 62dbd8ca7b1..0eddeb73015 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -1279,7 +1279,8 @@ enum radv_dynamic_state_bits {
RADV_DYNAMIC_DISCARD_RECTANGLE_ENABLE = 1ull << 46,
RADV_DYNAMIC_DISCARD_RECTANGLE_MODE = 1ull << 47,
RADV_DYNAMIC_ATTACHMENT_FEEDBACK_LOOP_ENABLE = 1ull << 48,
- RADV_DYNAMIC_ALL = (1ull << 49) - 1,
+ RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE = 1ull << 49,
+ RADV_DYNAMIC_ALL = (1ull << 50) - 1,
};
enum radv_cmd_dirty_bits {
@@ -1334,16 +1335,17 @@ enum radv_cmd_dirty_bits {
RADV_CMD_DIRTY_DYNAMIC_DISCARD_RECTANGLE_ENABLE = 1ull << 46,
RADV_CMD_DIRTY_DYNAMIC_DISCARD_RECTANGLE_MODE = 1ull << 47,
RADV_CMD_DIRTY_DYNAMIC_ATTACHMENT_FEEDBACK_LOOP_ENABLE = 1ull << 48,
- RADV_CMD_DIRTY_DYNAMIC_ALL = (1ull << 49) - 1,
- RADV_CMD_DIRTY_PIPELINE = 1ull << 49,
- RADV_CMD_DIRTY_INDEX_BUFFER = 1ull << 50,
- RADV_CMD_DIRTY_FRAMEBUFFER = 1ull << 51,
- RADV_CMD_DIRTY_VERTEX_BUFFER = 1ull << 52,
- RADV_CMD_DIRTY_STREAMOUT_BUFFER = 1ull << 53,
- RADV_CMD_DIRTY_GUARDBAND = 1ull << 54,
- RADV_CMD_DIRTY_RBPLUS = 1ull << 55,
- RADV_CMD_DIRTY_NGG_QUERY = 1ull << 56,
- RADV_CMD_DIRTY_OCCLUSION_QUERY = 1ull << 57,
+ RADV_CMD_DIRTY_DYNAMIC_SAMPLE_LOCATIONS_ENABLE = 1ull << 49,
+ RADV_CMD_DIRTY_DYNAMIC_ALL = (1ull << 50) - 1,
+ RADV_CMD_DIRTY_PIPELINE = 1ull << 50,
+ RADV_CMD_DIRTY_INDEX_BUFFER = 1ull << 51,
+ RADV_CMD_DIRTY_FRAMEBUFFER = 1ull << 52,
+ RADV_CMD_DIRTY_VERTEX_BUFFER = 1ull << 53,
+ RADV_CMD_DIRTY_STREAMOUT_BUFFER = 1ull << 54,
+ RADV_CMD_DIRTY_GUARDBAND = 1ull << 55,
+ RADV_CMD_DIRTY_RBPLUS = 1ull << 56,
+ RADV_CMD_DIRTY_NGG_QUERY = 1ull << 57,
+ RADV_CMD_DIRTY_OCCLUSION_QUERY = 1ull << 58,
};
enum radv_cmd_flush_bits {
@@ -1581,7 +1583,6 @@ enum rgp_flush_bits {
struct radv_multisample_state {
bool sample_shading_enable;
- bool uses_user_sample_locations;
float min_sample_shading;
};