### 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)

SpinLock spin_lock;
	RID shader;
	uint32_t input_mask;
	RD::RenderPrimitive render_primitive;
	RD::PipelineRasterizationState rasterization_state;
	RD::PipelineMultisampleState multisample_state;
	RD::PipelineDepthStencilState depth_stencil_state;
	RD::PipelineColorBlendState blend_state;
	int dynamic_state_flags = 0;
	Vector<RD::PipelineSpecializationConstant> base_specialization_constants;
	struct Version {
		RD::VertexFormatID vertex_id;
		RD::FramebufferFormatID framebuffer_id;
		uint32_t render_pass;
		bool wireframe;
		uint32_t bool_specializations;
		RID pipeline;
	};
	Version *versions = nullptr;
	uint32_t version_count;
	RID _generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass, uint32_t p_bool_specializations = 0);
	void _clear();
public:
	void 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 = 0, const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants = Vector<RD::PipelineSpecializationConstant>());
	void update_specialization_constants(const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants);
	void update_shader(RID p_shader);
	_FORCE_INLINE_ RID get_render_pipeline(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe = false, uint32_t p_render_pass = 0, uint32_t p_bool_specializations = 0) {