### Godot version

4.0.2

### System information

Windows 10

### Issue description

I have a meshinstance3d with a shader attached, and this is inside a subviewport. ( I instanced a bunch to make the memory rise faster, for testing purposes ).
The shader uses render_mode wireframe.
Whenever the object is onscreen, the memory will increase continuously! If the object goes offscreen, it will stop.
If I remove render_mode wireframe from the shader, the memory won't increase.
If I set debug_mode to wireframe on the subviewport, the memory won't increase.

Edit: I originally thought a subviewport was required, but it isn't. It happens even when there are no subviewports being used!


### Steps to reproduce

Open the attached project, and run the test.tscn
Watch as your memory continues to go up.
It stops if you either remove render_mode wireframe from the shader, or if you set the subviewport debug_mode to wireframe.
It also stops if the object isn't onscreen.

### Minimal reproduction project

[subViewportWireframeBug.zip](https://github.com/godotengine/godot/files/11267138/subViewportWireframeBug.zip)

return pipeline;
}
void PipelineCacheRD::_clear() {
	
	if (versions) {
		for (uint32_t i = 0; i < version_count; i++) {
			
			if (RD::get_singleton()->render_pipeline_is_valid(versions[i].pipeline)) {
				RD::get_singleton()->free(versions[i].pipeline);
			}
		}
		version_count = 0;
		memfree(versions);
		versions = nullptr;
	}
}
void PipelineCacheRD::setup(RID p_shader, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags, const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants) {
	ERR_FAIL_COND(p_shader.is_null());
	_clear();
	shader = p_shader;
	input_mask = RD::get_singleton()->shader_get_vertex_input_attribute_mask(p_shader);
	render_primitive = p_primitive;
	rasterization_state = p_rasterization_state;
	multisample_state = p_multisample;
	depth_stencil_state = p_depth_stencil_state;
	blend_state = p_blend_state;
	dynamic_state_flags = p_dynamic_state_flags;
	base_specialization_constants = p_base_specialization_constants;
}
void PipelineCacheRD::update_specialization_constants(const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants) {