{"record":{"id":"995c5fd5e94b1d02","repo":"gfx-rs/wgpu","slug":"clamp-to-border-is-not-supported","errorCode":null,"errorMessage":"Clamp to border is not supported","messagePattern":"Clamp to border is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu/src/backend/webgpu.rs","lineNumber":775,"sourceCode":"    match mode {\n        wgt::FilterMode::Nearest => webgpu_sys::GpuFilterMode::Nearest,\n        wgt::FilterMode::Linear => webgpu_sys::GpuFilterMode::Linear,\n    }\n}\n\nfn map_mipmap_filter_mode(mode: wgt::MipmapFilterMode) -> webgpu_sys::GpuMipmapFilterMode {\n    match mode {\n        wgt::MipmapFilterMode::Nearest => webgpu_sys::GpuMipmapFilterMode::Nearest,\n        wgt::MipmapFilterMode::Linear => webgpu_sys::GpuMipmapFilterMode::Linear,\n    }\n}\n\nfn map_address_mode(mode: wgt::AddressMode) -> webgpu_sys::GpuAddressMode {\n    match mode {\n        wgt::AddressMode::ClampToEdge => webgpu_sys::GpuAddressMode::ClampToEdge,\n        wgt::AddressMode::Repeat => webgpu_sys::GpuAddressMode::Repeat,\n        wgt::AddressMode::MirrorRepeat => webgpu_sys::GpuAddressMode::MirrorRepeat,\n        wgt::AddressMode::ClampToBorder => panic!(\"Clamp to border is not supported\"),\n    }\n}\n\nfn map_color(color: wgt::Color) -> webgpu_sys::GpuColorDict {\n    webgpu_sys::GpuColorDict::new(color.a, color.b, color.g, color.r)\n}\n\nfn map_store_op(store: crate::StoreOp) -> webgpu_sys::GpuStoreOp {\n    match store {\n        crate::StoreOp::Store => webgpu_sys::GpuStoreOp::Store,\n        crate::StoreOp::Discard => webgpu_sys::GpuStoreOp::Discard,\n    }\n}\n\nfn map_map_mode(mode: crate::MapMode) -> u32 {\n    match mode {\n        crate::MapMode::Read => webgpu_sys::gpu_map_mode::READ,\n        crate::MapMode::Write => webgpu_sys::gpu_map_mode::WRITE,","sourceCodeStart":757,"sourceCodeEnd":793,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu/src/backend/webgpu.rs#L757-L793","documentation":"Raised by map_address_mode in the WebGPU (browser) backend when a sampler is created with AddressMode::ClampToBorder. The browser WebGPU API only supports ClampToEdge, Repeat, and MirrorRepeat address modes, so the backend cannot map ClampToBorder and panics. This is a backend capability limitation, not a validation error.","triggerScenarios":"Calling device.create_sampler with address_mode (or any of address_mode_u/v/w) set to wgpu::AddressMode::ClampToBorder on the web backend.","commonSituations":"Sharing sampler configuration between native and web builds; using border-color-based effects like mirrored UI padding or shadow-map comparison sampling that rely on ClampToBorder; porting native engines to WASM.","solutions":["Change the sampler's address mode to ClampToEdge, Repeat, or MirrorRepeat on web.","Emulate ClampToBorder in-shader: clamp UVs and manually blend with the border color at edges.","Pad the texture with the border color in its own pixels and use ClampToEdge to approximate the behavior."],"exampleFix":"// before\nlet sampler = device.create_sampler(&wgpu::SamplerDescriptor { address_mode: wgpu::AddressMode::ClampToBorder, ..Default::default() });\n// after\nlet sampler = device.create_sampler(&wgpu::SamplerDescriptor { address_mode: wgpu::AddressMode::ClampToEdge, ..Default::default() });","handlingStrategy":"validation","validationCode":"assert_ne!(address_mode, wgpu::AddressMode::ClampToBorder, \"ClampToBorder unsupported on web backend\");","typeGuard":"fn is_web_safe_address_mode(m: wgpu::AddressMode) -> bool {\n    matches!(m, wgpu::AddressMode::ClampToEdge | wgpu::AddressMode::Repeat | wgpu::AddressMode::MirrorRepeat)\n}","tryCatchPattern":null,"preventionTips":["Default shared sampler configs to ClampToEdge unless a native backend is confirmed.","Emulate border behavior in shaders when edge transparency is needed.","Add a unit test that validates all sampler descriptors against backend capabilities."],"tags":["webgpu","wasm","sampler","unsupported-feature"],"backgroundTag":"unsupported-address-mode","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}