From c99f26559a4cca1866da4891a3cfb27cd5236c3e Mon Sep 17 00:00:00 2001 From: Miici0 Date: Tue, 24 Nov 2026 21:40:33 +0100 Subject: [PATCH] d3d12_vulkan_device: detect and enable VK_EXT_transform_feedback Foundation for D3D-302 (stream output): read the physical device's transformFeedback/geometryStreams features where the extension is present, record them on VulkanDeviceInfo, and enable them on the logical device when supported, exactly the same pattern the existing VK_EXT_mesh_shader detection/enable code already follows. Device-capability plumbing only: no behaviour changes yet. A graphics PSO declaring StreamOutput is still refused and SOSetTargets is still not implemented, same as before this commit. Confirmed VK_EXT_transform_feedback is available (4 streams, 4 buffers) on an NVIDIA GeForce RTX 4070 SUPER, driver 621.24. Co-Authored-By: Claude Sonnet 5 --- runtime/shims/d3d12_com.h | 7 +++++++ runtime/shims/d3d12_vulkan_device.cpp | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/runtime/shims/d3d12_com.h b/runtime/shims/d3d12_com.h index c0ff3cf8da..b320fb88c9 100644 --- a/runtime/shims/d3d12_com.h +++ b/runtime/shims/d3d12_com.h @@ -178,6 +178,13 @@ struct VulkanDeviceInfo { // VK_EXT_mesh_shader's meshShaderQueries feature is enabled on `device`, so the clipping invocations of a mesh // segment come from a mesh-primitives query (D3D-MESH-CLIPPING-COUNTER). Without it they read 0. bool mesh_shader_queries = false; + // VK_EXT_transform_feedback with its transformFeedback feature is enabled on `device` (D3D-302): a graphics PSO + // that declares StreamOutput is accepted, SOSetTargets binds real buffers, and draws between them are captured + // with vkCmdBeginTransformFeedbackEXT/EndTransformFeedbackEXT. Without it, StreamOutput PSOs stay refused. + bool transform_feedback = false; + // VK_EXT_transform_feedback's geometryStreams feature is enabled: a StreamOutput RasterizedStream other than the + // vertex/geometry shader's stream 0 can be rasterized. Without it, only RasterizedStream 0 is accepted. + bool transform_feedback_geometry_streams = false; // The core features enabled on `device`. Graphics PSOs that need independentBlend, fillModeNonSolid, // depthBiasClamp or dualSrcBlend are refused unless it is set here. VkPhysicalDeviceFeatures features{}; diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index 97ed334a11..b7fc1dfa0a 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -9476,6 +9476,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR}; VkPhysicalDeviceRayQueryFeaturesKHR rq_features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR}; VkPhysicalDeviceMeshShaderFeaturesEXT mesh_features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT}; + VkPhysicalDeviceTransformFeedbackFeaturesEXT transform_feedback_features{ + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT}; { std::uint32_t extension_count = 0; vkEnumerateDeviceExtensionProperties(info.physical, nullptr, &extension_count, nullptr); @@ -9500,10 +9502,19 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin vkGetPhysicalDeviceFeatures2(info.physical, &features); info.mesh_shader = mesh_features.meshShader == VK_TRUE; info.mesh_shader_queries = mesh_features.meshShaderQueries == VK_TRUE; + } else if (!std::strcmp(e.extensionName, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME)) { + VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, + &transform_feedback_features}; + vkGetPhysicalDeviceFeatures2(info.physical, &features); + info.transform_feedback = transform_feedback_features.transformFeedback == VK_TRUE; + info.transform_feedback_geometry_streams = transform_feedback_features.geometryStreams == VK_TRUE; } } if (!info.mesh_shader) std::fprintf(stderr, "[rt] d3d12: the GPU has no VK_EXT_mesh_shader: mesh-shader PSOs are unsupported\n"); + if (!info.transform_feedback) + std::fprintf(stderr, + "[rt] d3d12: the GPU has no VK_EXT_transform_feedback: StreamOutput PSOs are unsupported\n"); if (has_as && has_dho && has_rq && chosen12.bufferDeviceAddress) { as_features.pNext = &rq_features; VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &as_features}; @@ -9539,11 +9550,22 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin // The mesh-primitives query, which counts the primitives a mesh shader emits (D3D-MESH-CLIPPING-COUNTER). enable_mesh.meshShaderQueries = info.mesh_shader_queries ? VK_TRUE : VK_FALSE; + // D3D-302: StreamOutput PSOs, SOSetTargets and real SO_STATISTICS queries need transformFeedback; geometryStreams + // is only requested when the device already offers it (RasterizedStream != 0 is the one thing it gates). + VkPhysicalDeviceTransformFeedbackFeaturesEXT enable_transform_feedback{ + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT}; + enable_transform_feedback.transformFeedback = VK_TRUE; + enable_transform_feedback.geometryStreams = info.transform_feedback_geometry_streams ? VK_TRUE : VK_FALSE; + void* ext_chain = nullptr; if (info.mesh_shader) { enable_mesh.pNext = ext_chain; ext_chain = &enable_mesh; } + if (info.transform_feedback) { + enable_transform_feedback.pNext = ext_chain; + ext_chain = &enable_transform_feedback; + } if (info.ray_tracing) { enable_rq.pNext = ext_chain; enable_as.pNext = &enable_rq; @@ -9932,6 +9954,7 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin if (has_swapchain && instance_has_surface) device_extensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); if (swapchain_m1_name) device_extensions.push_back(swapchain_m1_name); if (info.mesh_shader) device_extensions.push_back(VK_EXT_MESH_SHADER_EXTENSION_NAME); + if (info.transform_feedback) device_extensions.push_back(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); if (info.ray_tracing) { device_extensions.push_back(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME); device_extensions.push_back(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);