Camera scrolling let textures flickering

Hey ppl, I updated my source to show the issue as simple as I can. If you use w,a,s,d to scroll you will see what I mean :slight_smile:

The texture

public class Camera2D
{
    public Vector2 Position { get; set; }
    public int ViewportWidth { get; set; }
    public int ViewportHeight { get; set; }

    public Vector2 ViewportCenter => new Vector2(this.ViewportWidth * 0.5f, this.ViewportHeight * 0.5f);

    public Matrix TranslationMatrix =>
        Matrix.CreateTranslation(-this.Position.X, -this.Position.Y, 0) *
        Matrix.CreateRotationZ(0) *
        Matrix.CreateScale(Vector3.One) *
        Matrix.CreateTranslation(new Vector3(this.ViewportCenter.X, this.ViewportCenter.Y, 0));   
}    

public class InputState
{
    public KeyboardState CurrentKeyboardState { get; private set; }
    public KeyboardState LastKeyboardState { get; private set; }

    public MouseState CurrentMouseState { get; private set; }
    public MouseState LastMouseState { get; private set; }

    public InputState()
    {
        this.CurrentMouseState = new MouseState();
        this.LastMouseState = new MouseState();
    }

    public void Update()
    {
        this.LastKeyboardState = this.CurrentKeyboardState;
        this.CurrentKeyboardState = Keyboard.GetState();
        this.LastMouseState = this.CurrentMouseState;
        this.CurrentMouseState = Mouse.GetState();
    }

    public bool IsKeyPressed(Keys key)
    {
        return this.CurrentKeyboardState.IsKeyDown(key);
    }

    public bool IsScrollLeft()
    {
        return this.IsKeyPressed(Keys.A);
    }

    public bool IsScrollRight()
    {
        return this.IsKeyPressed(Keys.D);
    }

    public bool IsScrollUp()
    {
        return this.IsKeyPressed(Keys.W);
    }

    public bool IsScrollDown()
    {
        return this.IsKeyPressed(Keys.S);
    }
}

public class Game1 : Game
{
    private readonly GraphicsDeviceManager graphics;
    private SpriteBatch spriteBatch;
    private Texture2D grasTexture;
    private readonly Camera2D camera = new Camera2D();
    private InputState inputState;

    public Game1()
    {
        this.graphics = new GraphicsDeviceManager(this);
        this.Content.RootDirectory = "Content";
        this.graphics.PreferredBackBufferWidth = 1280;
        this.graphics.PreferredBackBufferHeight = 720;
    }

    protected override void LoadContent()
    {
        this.spriteBatch = new SpriteBatch(this.GraphicsDevice);
        this.grasTexture = this.Content.Load<Texture2D>("floor");
        this.camera.ViewportWidth = this.graphics.GraphicsDevice.Viewport.Width;
        this.camera.ViewportHeight = this.graphics.GraphicsDevice.Viewport.Height;
        this.camera.Position = new Vector2(32 * 20, 32 * 20);
        this.inputState = new InputState();
    }

    private void HandleInput(GameTime gameTime, InputState inputState)
    {
        var cameraMovement = Vector2.Zero;

        if (inputState.IsScrollLeft())
        {
            cameraMovement.X = -1;
        }
        else if (inputState.IsScrollRight())
        {
            cameraMovement.X = 1;
        }

        if (inputState.IsScrollUp())
        {
            cameraMovement.Y = -1;
        }
        else if (inputState.IsScrollDown())
        {
            cameraMovement.Y = 1;
        }

        if (cameraMovement != Vector2.Zero)
        {
            cameraMovement.Normalize();

            var velocity = cameraMovement * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;
            this.camera.Position += velocity;
        }
    }

    protected override void Update(GameTime gameTime)
    {
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            this.Exit();

        this.inputState.Update();

        this.HandleInput(gameTime, this.inputState);
        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        this.GraphicsDevice.Clear(Color.Black);

        this.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap);
        this.spriteBatch.Draw(this.grasTexture, Vector2.Zero, new Rectangle((int)-this.camera.TranslationMatrix.Translation.X, (int)-this.camera.TranslationMatrix.Translation.Y, this.GraphicsDevice.Viewport.Width, this.GraphicsDevice.Viewport.Height), Color.White);
        this.spriteBatch.End();

        base.Draw(gameTime);
    }
}