[PATCH vkd3d v2] vkd3d: Do not attempt to enable primitive restart for non-strip topology.

Conor McCarthy cmccarthy at codeweavers.com
Mon Sep 13 21:58:17 CDT 2021


Prevents a validation failure if a d3d12 strip cut value is supplied.
Based on a vkd3d-proton patch by Hans-Kristian Arntzen.

Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
v2: Also handle topologies with adjacency (currently not used in vkd3d).
---
 libs/vkd3d/state.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 4eccf1e3..9e554b44 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2762,6 +2762,23 @@ static enum VkPrimitiveTopology vk_topology_from_d3d12_topology(D3D12_PRIMITIVE_
     }
 }
 
+static bool vk_topology_can_restart(VkPrimitiveTopology topology)
+{
+    switch (topology)
+    {
+        case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+        case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+        case VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+        case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+        case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+        case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+            return false;
+
+        default:
+            return true;
+    }
+}
+
 static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(const struct d3d12_pipeline_state *state,
         const struct vkd3d_pipeline_key *key, VkRenderPass *vk_render_pass)
 {
@@ -2938,7 +2955,8 @@ VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_sta
     ia_desc.pNext = NULL;
     ia_desc.flags = 0;
     ia_desc.topology = vk_topology_from_d3d12_topology(topology);
-    ia_desc.primitiveRestartEnable = !!graphics->index_buffer_strip_cut_value;
+    ia_desc.primitiveRestartEnable = graphics->index_buffer_strip_cut_value
+            && vk_topology_can_restart(ia_desc.topology);
 
     if (ia_desc.topology == VK_PRIMITIVE_TOPOLOGY_MAX_ENUM)
     {
-- 
2.32.0




More information about the wine-devel mailing list