diff --git a/docs/pipeline_check.md b/docs/pipeline_check.md index d5d76cb931..c3c6a28b20 100644 --- a/docs/pipeline_check.md +++ b/docs/pipeline_check.md @@ -457,6 +457,10 @@ driver gives it the same cache key in both programs. Measured on Windows with an `VK_KHR_maintenance8` into the pipeline cache key even for compute shaders, so the checker enables both whenever supported and keeps `meshShaderQueries` on. - On a Windows RTX 5070 Ti (617.42), a compute-only seed missed with mesh features omitted and hit with the supported mesh and mesh-query features enabled on both devices. The shader, push constants and pipeline layout were identical. Cache-producing runs request this device configuration for every selected shader batch. +- On Windows with an AMD Radeon RX 7900 XT, `VK_EXT_transform_feedback` (with `transformFeedback` enabled, and + `geometryStreams` when the device offers it) is part of the key: the runtime enables it whenever the extension is + present (D3D-302), so the checker enables it too. Without it, `pipeline_cache_seed` failed 3 of 3 on that GPU and + passed 3 of 3 on `main`. NVIDIA leaves it out of the key, which is why it did not show up on the RTX 3080 Ti. - The executable's file name is part of the key; its folder is not. A copy of the checker under another name misses the cache the original wrote, and the runtime's device hits the checker's cache only from a program with the checker's file name. So on this driver a cache written by `vk_pipeline_check.exe` does not hit in diff --git a/runtime/shims/d3d12_com.h b/runtime/shims/d3d12_com.h index 849791a262..1d34573e19 100644 --- a/runtime/shims/d3d12_com.h +++ b/runtime/shims/d3d12_com.h @@ -215,6 +215,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 detected and enabled on `device` (D3D-302). + // Nothing uses it yet: a graphics PSO that declares StreamOutput is still refused and SOSetTargets is still not + // implemented. (#1630 adds the SO_STATISTICS query pools, which use it.) + bool transform_feedback = false; + // VK_EXT_transform_feedback's geometryStreams feature is enabled when the device offers it. Nothing rasterizes a + // StreamOutput RasterizedStream yet; it is here for the capture implementation that follows. + 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 aeecf05b0d..49e8dd3e65 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -17727,6 +17727,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); @@ -17751,10 +17753,20 @@ 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: stream output is unsupported and " + "SO_STATISTICS pools read zero\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}; @@ -17790,11 +17802,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; @@ -18297,6 +18320,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); diff --git a/runtime/test/vk_pipeline_check.cpp b/runtime/test/vk_pipeline_check.cpp index 0e39d0f621..26eb5030cf 100644 --- a/runtime/test/vk_pipeline_check.cpp +++ b/runtime/test/vk_pipeline_check.cpp @@ -7,10 +7,10 @@ // descriptor-free shaders with the standard push-constant range // - ps/vs/ms/gs: graphics pipeline via vkCreateGraphicsPipelines (Vulkan 1.3 dynamic rendering, no render pass) // paired with minimal partner stubs from /stubs/ (generated by tools/spirv_stubs.py) -// VK_EXT_mesh_shader (with meshShaderQueries) and VK_KHR_maintenance8 are always enabled when supported so the -// saved pipeline cache matches the runtime's device key; other optional device extensions are enabled only when -// needed by the selected shaders. Shaders whose required features or partner stubs are unavailable are reported as -// skipped rather than failed. +// VK_EXT_mesh_shader (with meshShaderQueries), VK_KHR_maintenance8 and VK_EXT_transform_feedback are always enabled +// when supported so the saved pipeline cache matches the runtime's device key; other optional device extensions are +// enabled only when needed by the selected shaders. Shaders whose required features or partner stubs are unavailable +// are reported as skipped rather than failed. // [cache.bin] loaded first if it exists (a stopped run resumes: cached pipelines are instant), saved every // 10 minutes and at the end // --jobs N compile on up to N worker threads (default: half the hardware threads) @@ -1122,6 +1122,7 @@ int main(int argc, char** argv) { // Query the core and optional device features used by the checker. VkPhysicalDeviceMeshShaderFeaturesEXT mesh{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT}; + VkPhysicalDeviceTransformFeedbackFeaturesEXT tf{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT}; VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR bary{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR}; VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT lock{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT}; #ifdef VK_KHR_MAINTENANCE_8_EXTENSION_NAME @@ -1144,6 +1145,10 @@ int main(int argc, char** argv) { link(&f12, reinterpret_cast(&f12), nullptr, true); link(&f13, reinterpret_cast(&f13), nullptr, true); const bool ext_mesh = link(&mesh, reinterpret_cast(&mesh), VK_EXT_MESH_SHADER_EXTENSION_NAME, true); + // The runtime's device enables VK_EXT_transform_feedback (transformFeedback, and geometryStreams when the device + // offers it) whenever the extension is present (D3D-302), and a driver makes it part of a pipeline's cache key, so + // the checker enables it too (docs/pipeline_check.md, "The cache and the runtime's device"). + link(&tf, reinterpret_cast(&tf), VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, true); const bool ext_bary = link(&bary, reinterpret_cast(&bary), VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME, want_bary); const bool ext_lock = link(&lock, reinterpret_cast(&lock), VK_EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME, want_lock); #ifdef VK_KHR_MAINTENANCE_8_EXTENSION_NAME