{"record":{"id":"b34962cf38320623","repo":"FyroxEngine/Fyrox","slug":"failed-to-create-backbuffer-depth-stencil-e","errorCode":null,"errorMessage":"Failed to create backbuffer depth-stencil: {e}","messagePattern":"Failed to create backbuffer depth-stencil: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"fyrox-graphics-wgpu/src/server.rs","lineNumber":585,"sourceCode":"\n        let mut cache = self.backbuffer_depth_stencil.borrow_mut();\n        let needs_recreate = match cache.as_ref() {\n            Some((cw, ch, _)) => *cw != w || *ch != h,\n            None => true,\n        };\n        if needs_recreate {\n            if w > 0 && h > 0 {\n                match self.create_2d_render_target(\n                    \"BackbufferDepthStencil\",\n                    fyrox_graphics::gpu_texture::PixelKind::D24S8,\n                    w as usize,\n                    h as usize,\n                ) {\n                    Ok(tex) => {\n                        *cache = Some((w, h, tex));\n                    }\n                    Err(e) => {\n                        Log::warn(format!(\"Failed to create backbuffer depth-stencil: {e}\"));\n                        *cache = None;\n                    }\n                }\n            } else {\n                *cache = None;\n            }\n        }\n        let depth_attachment = cache\n            .as_ref()\n            .map(|(_, _, tex)| Attachment::depth_stencil(tex.clone()));\n        GpuFrameBuffer(Rc::new(WgpuFrameBuffer::backbuffer(self, depth_attachment)))\n    }\n    fn create_query(&self) -> Result<GpuQuery, FrameworkError> {\n        Ok(GpuQuery(Rc::new(WgpuQuery::new(self)?)))\n    }\n    fn create_shader(\n        &self,\n        name: String,","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-graphics-wgpu/src/server.rs#L567-L603","documentation":"The wgpu server lazily creates a depth-stencil texture matching the back buffer's size and caches it. If texture creation fails (e.g. the requested size is zero or exceeds device limits), the failure is logged with this message and the cache is set to None, meaning depth testing against the backbuffer will not work for that size.","triggerScenarios":"Requesting a back buffer with a width/height whose depth-stencil texture creation fails — typically 0-sized or over device-limit dimensions (e.g. window minimized to 0x0 before depth buffer creation).","commonSituations":"Window resize events delivering 0 width/height; allocating framebuffers larger than max_texture_dimension; GPU memory exhaustion.","solutions":["Guard against zero-sized dimensions before creating/resizing the back buffer","Clamp requested width/height to the device's max texture dimensions","Check the underlying error {e} for the exact creation failure cause"],"exampleFix":"// before\nlet (w, h) = window.inner_size();\n// after\nlet (w, h) = window.inner_size();\nlet (w, h) = (w.max(1), h.max(1));","handlingStrategy":"fallback","validationCode":"let (w, h) = (size.width.max(1), size.height.max(1));\ndebug_assert!(w <= max_texture_dim && h <= max_texture_dim);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass zero-sized dimensions to the renderer","Clamp framebuffer/backbuffer sizes to device limits","Monitor the log for backbuffer depth-stencil failures during window resize"],"tags":["wgpu","depth-stencil","backbuffer","texture-creation"],"backgroundTag":"texture-creation-failed","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}