Weird glitch in 2D

Godot Version

4.2

Question

Greetings!

I’m trying to create a simple video FX that’s basic just a copy of the viewport, rescaled by twice and then color added over the original viewport. For that, I created a Sprite2D under a canvas, and then I used this code:

extends Sprite2D

func _process(delta):
await RenderingServer.frame_post_draw
texture = get_viewport().get_texture()#.get_image()
pass

However, the result looks very glitchy. Is there anything wrong with my code?

[EDIT] Apparently, it works correctly at the first 1024 x 1024 pixels of the viewport. Is it a texture size problem?