### Godot version

4.0rc1 gl_compatibility only.

### System information

Windows 10, Nvidia 527.56 RTX3090, gl_compatibility
OpenGL API 3.3.0 NVIDIA 527.56 - Compatibility

### Issue description

Assigning a `CanvasItemMatrial` with `blend_mode = BLEND_MODE_SUB` in opengl causes the entire editor to turn black and break, even if later unassigned.

In case it matters, I'm using Single Window Mode in the editor.

### Steps to reproduce

1. Open the attached Project. Make sure it is using **Compatibility** on the top right.
2. On the root "Level" node, click the `Use Standard` checkbox which runs the tool script (it actually sets a CanvasItemMaterial, not standard. the checkbox was badly named). The editor turns black.
3. Without moving the mouse, click again to toggle this material off and return to a ShaderMaterial. The editor is still black / broken.
4. Press Ctrl-S to save the scene so you aren't bombarded with an invisible save dialog.
5. Close the editor.

If you edit the script and try other blend_mode values, this issue does not happen.

### Minimal reproduction project

[black_screen_test.zip](https://github.com/godotengine/godot/files/10689627/black_screen_test.zip)

instance_color_offset = mesh_storage->multimesh_get_color_offset(multimesh);
				instance_uses_color = mesh_storage->multimesh_uses_colors(multimesh);
				instance_uses_custom_data = mesh_storage->multimesh_uses_custom_data(multimesh);
			} else if (state.canvas_instance_batches[p_index].command_type == Item::Command::TYPE_PARTICLES) {
				const Item::CommandParticles *pt = static_cast<const Item::CommandParticles *>(state.canvas_instance_batches[p_index].command);
				RID particles = pt->particles;
				mesh = particles_storage->particles_get_draw_pass_mesh(particles, 0);
				ERR_BREAK(particles_storage->particles_get_mode(particles) != RS::PARTICLES_MODE_2D);
				particles_storage->particles_request_process(particles);
				if (particles_storage->particles_is_inactive(particles)) {
					break;
				}
				RenderingServerDefault::redraw_request(); 
				int dpc = particles_storage->particles_get_draw_passes(particles);
				if (dpc == 0) {
					break; 
				}
				instance_count = particles_storage->particles_get_amount(particles);
				instance_buffer = particles_storage->particles_get_gl_buffer(particles);
				instance_stride = 12; 
				instance_color_offset = 8; 
				instance_uses_color = true;
				instance_uses_custom_data = true;
			}
			ERR_FAIL_COND(mesh.is_null());
			uint32_t surf_count = mesh_storage->mesh_get_surface_count(mesh);
			for (uint32_t j = 0; j < surf_count; j++) {
				void *surface = mesh_storage->mesh_get_surface(mesh, j);
				RS::PrimitiveType primitive = mesh_storage->mesh_surface_get_primitive(surface);
				ERR_CONTINUE(primitive < 0 || primitive >= RS::PRIMITIVE_MAX);