{"record":{"id":"7430415080eea52f","repo":"gfx-rs/wgpu","slug":"extendeddisplayp3-is-never-reported-in-the-vulka","errorCode":null,"errorMessage":"`ExtendedDisplayP3` is never reported in the Vulkan surface capabilities","messagePattern":"`ExtendedDisplayP3` is never reported in the Vulkan surface capabilities","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu-hal/src/vulkan/conv.rs","lineNumber":207,"sourceCode":"        vk::ColorSpaceKHR::DISPLAY_P3_NONLINEAR_EXT => Scs::DisplayP3,\n        vk::ColorSpaceKHR::HDR10_ST2084_EXT => Scs::Bt2100Pq,\n        vk::ColorSpaceKHR::HDR10_HLG_EXT => Scs::Bt2100Hlg,\n        _ => return None,\n    })\n}\n\npub fn map_surface_color_space(color_space: wgt::SurfaceColorSpace) -> vk::ColorSpaceKHR {\n    use wgt::SurfaceColorSpace as Scs;\n    match color_space {\n        Scs::Auto => unreachable!(\"wgpu-core resolves `Auto` before configuring the surface\"),\n        Scs::Srgb => vk::ColorSpaceKHR::SRGB_NONLINEAR,\n        Scs::ExtendedSrgbLinear => vk::ColorSpaceKHR::EXTENDED_SRGB_LINEAR_EXT,\n        Scs::ExtendedSrgb => vk::ColorSpaceKHR::EXTENDED_SRGB_NONLINEAR_EXT,\n        Scs::DisplayP3 => vk::ColorSpaceKHR::DISPLAY_P3_NONLINEAR_EXT,\n        Scs::Bt2100Pq => vk::ColorSpaceKHR::HDR10_ST2084_EXT,\n        Scs::Bt2100Hlg => vk::ColorSpaceKHR::HDR10_HLG_EXT,\n        Scs::ExtendedDisplayP3 => {\n            unreachable!(\"`ExtendedDisplayP3` is never reported in the Vulkan surface capabilities\")\n        }\n    }\n}\n\nimpl crate::Attachment<'_, super::TextureView> {\n    pub(super) fn make_attachment_key(&self, ops: crate::AttachmentOps) -> super::AttachmentKey {\n        super::AttachmentKey {\n            format: self.view.raw_format,\n            layout: derive_image_layout(self.usage, self.view.format),\n            ops,\n        }\n    }\n}\n\nimpl crate::ColorAttachment<'_, super::TextureView> {\n    pub(super) unsafe fn make_vk_clear_color(&self) -> vk::ClearColorValue {\n        let cv = &self.clear_value;\n        match self.target.view.format.sample_type(None, None).unwrap() {","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu-hal/src/vulkan/conv.rs#L189-L225","documentation":"`map_surface_color_space` panics on `SurfaceColorSpace::ExtendedDisplayP3` because that color space is never reported in Vulkan surface capabilities, meaning the Vulkan backend cannot honor it. Selecting it for a Vulkan-configured surface is an unsupported configuration and trips an unreachable!.","triggerScenarios":"Requesting `SurfaceConfiguration { color_space: SurfaceColorSpace::ExtendedDisplayP3, .. }` on a surface whose adapter is backed by Vulkan (directly or by constructing configuration through internal APIs).","commonSituations":"Porting an app from Metal (where Display P3 extended variants may exist) to Vulkan/Windows/Linux and keeping the same color space setting; picking a color space from a hardcoded constant without checking what the surface capabilities report.","solutions":["Choose a supported Vulkan color space such as `ExtendedSrgb`, `ExtendedSrgbLinear`, `Bt2100Pq`, `Bt2100Hlg`, or `DisplayP3`","Query the surface/adapter capabilities first and only request color spaces the backend reports","Guard with a runtime check: if the adapter backend is Vulkan, avoid ExtendedDisplayP3"],"exampleFix":"// before\nconfig.color_space = wgpu::SurfaceColorSpace::ExtendedDisplayP3;\n// after\nconfig.color_space = wgpu::SurfaceColorSpace::ExtendedSrgbLinear; // supported on Vulkan","handlingStrategy":"validation","validationCode":"let supported = match adapter.get_info().backend {\n    wgpu::Backend::Vulkan => config.color_space != wgpu::SurfaceColorSpace::ExtendedDisplayP3,\n    _ => true,\n};\nassert!(supported, \"ExtendedDisplayP3 unsupported on Vulkan\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check surface capabilities before picking exotic color spaces","Avoid hardcoding color spaces across platforms; query per adapter backend","Use ExtendedSrgbLinear as the HDR fallback on Vulkan"],"tags":["vulkan","surface","color-space","unsupported","unreachable"],"backgroundTag":"unsupported-color-space","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}