The size and surface formats of the render targets don’t matter. Why does switching between render targets increase GPU usage when no changes have been made?
For the record:
Platform: Windows 10 cross-platform desktop project
MonoGame version: 3.7.0.1708
Graphics card: ASUS GeForce GTX 1060 6GB Dual OC
But if you create a new MonoGame project and paste this into Game1.cs I reckon you get the same results (high GPU usage)
Is there any other way of applying a render target than swapping it with something else?
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Test
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
RenderTarget2D renderTarget1, renderTarget2;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 1920;
graphics.PreferredBackBufferHeight = 1080;
graphics.ApplyChanges();
Content.RootDirectory = "Content";
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
renderTarget1 = new RenderTarget2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color,
DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
renderTarget2 = new RenderTarget2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color,
DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
for (int i = 0; i < 1000; i++)
{
GraphicsDevice.SetRenderTarget(renderTarget1);
GraphicsDevice.SetRenderTarget(renderTarget2);
}
GraphicsDevice.SetRenderTarget(null);
base.Draw(gameTime);
}
}
}