zed-industries/zed · error
DirectX instance range exceeds the
Error message
DirectX instance range exceeds the {} buffer What it means
Guard in `draw_range`: `first_instance + instance_count` would run past the end of the allocated D3D11 instance buffer, so DrawInstanced would read out of bounds; the draw is rejected. Indicates an internal batching/offset bookkeeping bug rather than bad user input.
Solutions
- Fix upstream batch computation so ranges always fit the uploaded buffer.
- Add assertions where instance ranges are computed to catch misbookkeeping early.
- Re-upload the buffer if the previous frame's data was smaller than the requested range.
- Log the buffer size vs requested range to locate the off-by-N bug.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/gpui_windows/src/directx_renderer.rs:1119 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/0b41c12350e811d3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gpui_windows/src/directx_renderer.rs:1119
let vertex = {
let raw_shader = RawShaderBytes::new(shader_module, ShaderTarget::Vertex)?;
create_vertex_shader(device, raw_shader.as_bytes())?
};
let fragment = {
let raw_shader = RawShaderBytes::new(shader_module, ShaderTarget::Fragment)?;
create_fragment_shader(device, raw_shader.as_bytes())?
};
let buffer = create_buffer(device, std::mem::size_of::<T>(), buffer_size)?;
let view = create_buffer_view(device, &buffer)?;
Ok(PipelineState {
label,
vertex,
fragment,
buffer,
buffer_size,
view,
blend_state,
_marker: std::marker::PhantomData,
})
}
fn update_buffer(
&mut self,
device: &ID3D11Device,
device_context: &ID3D11DeviceContext,
data: &[T],
) -> Result<()> {
if self.buffer_size < data.len() {
let element_size = std::mem::size_of::<T>();
let required_size = std::mem::size_of_val(data);
anyhow::ensure!(
required_size <= MAX_INSTANCE_BUFFER_SIZE,
"{} buffer needs {required_size} bytes, above the maximum of {MAX_INSTANCE_BUFFER_SIZE}",
self.label
);View on GitHub (pinned to 916fc2b8cb)