{"record":{"id":"72b855e205c9056f","repo":"gfx-rs/wgpu","slug":"is-not-enabled-for-this-backend-72b855","errorCode":null,"errorMessage":"{:?} is not enabled for this backend","messagePattern":"(.+?) is not enabled for this backend","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu/src/backend/webgpu.rs","lineNumber":423,"sourceCode":"    mapped.set_front_face(map_front_face(primitive.front_face));\n\n    if let Some(format) = primitive.strip_index_format {\n        mapped.set_strip_index_format(map_index_format(format));\n    }\n\n    mapped.set_topology(match primitive.topology {\n        PrimitiveTopology::PointList => pt::PointList,\n        PrimitiveTopology::LineList => pt::LineList,\n        PrimitiveTopology::LineStrip => pt::LineStrip,\n        PrimitiveTopology::TriangleList => pt::TriangleList,\n        PrimitiveTopology::TriangleStrip => pt::TriangleStrip,\n    });\n\n    mapped.set_unclipped_depth(primitive.unclipped_depth);\n\n    match primitive.polygon_mode {\n        wgt::PolygonMode::Fill => {}\n        wgt::PolygonMode::Line => panic!(\n            \"{:?} is not enabled for this backend\",\n            wgt::Features::POLYGON_MODE_LINE\n        ),\n        wgt::PolygonMode::Point => panic!(\n            \"{:?} is not enabled for this backend\",\n            wgt::Features::POLYGON_MODE_POINT\n        ),\n    }\n\n    mapped\n}\n\nfn map_compare_function(compare_fn: wgt::CompareFunction) -> webgpu_sys::GpuCompareFunction {\n    use webgpu_sys::GpuCompareFunction as cf;\n    use wgt::CompareFunction;\n    match compare_fn {\n        CompareFunction::Never => cf::Never,\n        CompareFunction::Less => cf::Less,","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu/src/backend/webgpu.rs#L405-L441","documentation":"The WebGPU (browser) backend's map_primitive_state panics when a render pipeline requests PolygonMode::Line, because the browser WebGPU API has no line polygon mode. This mode is gated behind the POLYGON_MODE_LINE feature, which this backend cannot support.","triggerScenarios":"Creating a render pipeline with primitive.polygon_mode = PolygonMode::Line through a device backed by the web (WebGPU) backend.","commonSituations":"Sharing pipeline descriptors between native (Vulkan/Metal, which support line mode behind a feature) and web builds; porting a wireframe-rendering native app to wasm.","solutions":["Use PolygonMode::Fill on web, or emulate wireframes with index buffers / a geometry technique.","Gate the pipeline: check adapter features for POLYGON_MODE_LINE and choose Fill when absent.","Build a wireframe variant of the mesh (edge list) instead of relying on polygon mode."],"exampleFix":"// before\nlet mut primitive = wgpu::PrimitiveState::default();\nprimitive.polygon_mode = wgpu::PolygonMode::Line;\n// after\nlet polygon_mode = if device.features().contains(wgpu::Features::POLYGON_MODE_LINE) {\n    wgpu::PolygonMode::Line\n} else {\n    wgpu::PolygonMode::Fill\n};\nprimitive.polygon_mode = polygon_mode;","handlingStrategy":"fallback","validationCode":"let line_mode = device.features().contains(wgpu::Features::POLYGON_MODE_LINE);\nlet polygon_mode = if line_mode { wgpu::PolygonMode::Line } else { wgpu::PolygonMode::Fill };","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hardcode PolygonMode::Line in code shared with wasm targets.","Check adapter/device features before building pipelines with non-default polygon modes.","Maintain a wireframe fallback (edge-index mesh) for backends without line mode."],"tags":["panic","rust","webgpu","render-pipeline","unsupported-feature"],"backgroundTag":"unsupported-backend-feature","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}