zed-industries/zed · error
DirectX instance range exceeds the {} buffer
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.
Source
Thrown at crates/gpui_windows/src/directx_renderer.rs:1119
);
unsafe {
device_context.PSSetSamplers(0, Some(sampler));
device_context.VSSetShaderResources(0, Some(texture));
device_context.PSSetShaderResources(0, Some(texture));
device_context.DrawInstanced(4, instance_count, 0, 0);
}
Ok(())
}
fn draw_range(
&self,
device_context: &ID3D11DeviceContext,
batch_params_buffer: &ID3D11Buffer,
first_instance: u32,
instance_count: u32,
) -> Result<()> {
anyhow::ensure!(
first_instance as usize + instance_count as usize <= self.buffer_size,
"DirectX instance range exceeds the {} buffer",
self.label
);
update_batch_start(device_context, batch_params_buffer, first_instance)?;
set_pipeline_state(
device_context,
slice::from_ref(&self.view),
D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP,
&self.vertex,
&self.fragment,
&self.blend_state,
);
unsafe {
device_context.DrawInstanced(4, instance_count, 0, 0);
}
Ok(())
}View on GitHub (pinned to f4178619ac)
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@f4178619ac (2026-08-20).
Data as JSON: /api/errors/0b41c12350e811d3.
Report an issue: GitHub.