{"record":{"id":"6dd7d950818f0aeb","repo":"zed-industries/zed","slug":"buffer-needs-required-size-bytes-above-the-m","errorCode":null,"errorMessage":"{} buffer needs {required_size} bytes, above the maximum of {MAX_INSTANCE_BUFFER_SIZE}","messagePattern":"(.+?) buffer needs (.+?) bytes, above the maximum of (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_windows/src/directx_renderer.rs","lineNumber":1042,"sourceCode":"            fragment,\n            buffer,\n            buffer_size,\n            view,\n            blend_state,\n            _marker: std::marker::PhantomData,\n        })\n    }\n\n    fn update_buffer(\n        &mut self,\n        device: &ID3D11Device,\n        device_context: &ID3D11DeviceContext,\n        data: &[T],\n    ) -> Result<()> {\n        if self.buffer_size < data.len() {\n            let element_size = std::mem::size_of::<T>();\n            let required_size = std::mem::size_of_val(data);\n            anyhow::ensure!(\n                required_size <= MAX_INSTANCE_BUFFER_SIZE,\n                \"{} buffer needs {required_size} bytes, above the maximum of {MAX_INSTANCE_BUFFER_SIZE}\",\n                self.label\n            );\n            let new_buffer_size = data\n                .len()\n                .next_power_of_two()\n                .min(MAX_INSTANCE_BUFFER_SIZE / element_size);\n            log::debug!(\n                \"Updating {} buffer size from {} to {}\",\n                self.label,\n                self.buffer_size,\n                new_buffer_size\n            );\n            let buffer = create_buffer(device, std::mem::size_of::<T>(), new_buffer_size)?;\n            let view = create_buffer_view(device, &buffer)?;\n            self.buffer = buffer;\n            self.view = view;","sourceCodeStart":1024,"sourceCodeEnd":1060,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/gpui_windows/src/directx_renderer.rs#L1024-L1060","documentation":"Validation in `update_buffer`: the instance buffer would need to grow to `required_size` bytes (data.len() * size_of::<T>()) which exceeds MAX_INSTANCE_BUFFER_SIZE, so the resize is refused. Fires when a draw batch's per-instance data is larger than the fixed maximum instance buffer.","triggerScenarios":"Thrown at crates/gpui_windows/src/directx_renderer.rs:1042 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Split the instance batch into multiple draw calls within the buffer limit.","Raise MAX_INSTANCE_BUFFER_SIZE if legitimate workloads exceed it.","Clamp or tessellate the upstream data producing the oversized batch.","Log element count and struct size to identify the pathological batch type."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}