feat: remove basically every direct call to setrendertarget
This commit is contained in:
1 parent
f84d82fc01
commit
fda6dca5af
7 files changed
+70
-77
No files matched your search
@@ -151,10 +151,9 @@ namespace CalamityMod.Backgrounds
|
||||
DrawBurrowsBG();
|
||||
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.graphics.GraphicsDevice.SetRenderTarget(null);
|
||||
CurrentlyRendering = false;
|
||||
}
|
||||
|
||||
CurrentlyRendering = false;
|
||||
}
|
||||
|
||||
private void On_Main_DrawBackgroundBlackFill(On_Main.orig_DrawBackgroundBlackFill orig, Main self)
|
||||
|
||||
@@ -96,14 +96,14 @@ namespace CalamityMod.FluidSimulation
|
||||
|
||||
internal void ApplyThingToTarget(RenderTarget2D currentField, Action shaderPreparationsAction)
|
||||
{
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(TemporaryAuxilaryTarget);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
using (TemporaryAuxilaryTarget.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
|
||||
shaderPreparationsAction();
|
||||
Main.spriteBatch.Draw(currentField, currentField.Bounds, Color.White);
|
||||
Main.spriteBatch.End();
|
||||
shaderPreparationsAction();
|
||||
Main.spriteBatch.Draw(currentField, currentField.Bounds, Color.White);
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
|
||||
currentField.CopyContentsFrom(TemporaryAuxilaryTarget);
|
||||
}
|
||||
@@ -202,8 +202,7 @@ namespace CalamityMod.FluidSimulation
|
||||
});
|
||||
|
||||
// Clear the Poisson values and then calculate them, for use in the divergence clearance pass.
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(DivergencePoissonField);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
using (DivergencePoissonField.Scope(clearColor: Color.Transparent)) { }
|
||||
|
||||
for (int i = 0; i < GaussSeidelIterations; i++)
|
||||
{
|
||||
@@ -275,16 +274,14 @@ namespace CalamityMod.FluidSimulation
|
||||
|
||||
public void UpdateOutputTarget()
|
||||
{
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(OutputTarget);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
Main.instance.GraphicsDevice.Textures[5] = ColorField.NextState.Target;
|
||||
CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["DrawFluidPass"].Apply();
|
||||
Main.spriteBatch.Draw(DensityField.NextState.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, 0, 0f);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(null);
|
||||
using (OutputTarget.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
Main.instance.GraphicsDevice.Textures[5] = ColorField.NextState.Target;
|
||||
CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["DrawFluidPass"].Apply();
|
||||
Main.spriteBatch.Draw(DensityField.NextState.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, 0, 0f);
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Systems.Graphic;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
@@ -72,18 +73,17 @@ namespace CalamityMod.Graphics.Metaballs
|
||||
// Draw the raw contents of the metaball to each of its render targets.
|
||||
foreach (var target in metaball.LayerTargets)
|
||||
{
|
||||
gd.SetRenderTarget(target);
|
||||
gd.Clear(Color.Transparent);
|
||||
metaball.DrawInstances();
|
||||
using (target.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
metaball.DrawInstances();
|
||||
|
||||
// Flush metaball contents to its render target and reset the sprite batch for the next iteration.
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform);
|
||||
// Flush metaball contents to its render target and reset the sprite batch for the next iteration.
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return to the backbuffer and end the sprite batch.
|
||||
gd.SetRenderTarget(null);
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Systems.Graphic;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
@@ -93,9 +94,8 @@ namespace CalamityMod.Graphics.Renderers
|
||||
continue;
|
||||
|
||||
using (Main.spriteBatch.Scope())
|
||||
using (renderer.MainTarget.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(renderer.MainTarget);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
Main.spriteBatch.Begin(
|
||||
SpriteSortMode.Deferred,
|
||||
BlendState.AlphaBlend,
|
||||
@@ -109,8 +109,6 @@ namespace CalamityMod.Graphics.Renderers
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
}
|
||||
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
@@ -58,32 +59,33 @@ namespace CalamityMod.Systems.Graphic.LiquidSystem
|
||||
if (!Initialized || !TextureArrayReady || Main.gameMenu)
|
||||
return;
|
||||
|
||||
var graphicsDevice = Main.instance.GraphicsDevice;
|
||||
graphicsDevice.SetRenderTarget(LavaRT);
|
||||
graphicsDevice.Clear(Color.Transparent);
|
||||
Begin();
|
||||
DrawTextures(Textures);
|
||||
End();
|
||||
using (LavaRT.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Begin();
|
||||
DrawTextures(Textures);
|
||||
End();
|
||||
}
|
||||
|
||||
graphicsDevice.SetRenderTarget(LavaBlockRT);
|
||||
graphicsDevice.Clear(Color.Transparent);
|
||||
Begin();
|
||||
DrawTextures(BlockTextures);
|
||||
End();
|
||||
using (LavaBlockRT.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Begin();
|
||||
DrawTextures(BlockTextures);
|
||||
End();
|
||||
}
|
||||
|
||||
graphicsDevice.SetRenderTarget(LavaSlopeRT);
|
||||
graphicsDevice.Clear(Color.Transparent);
|
||||
Begin();
|
||||
DrawTextures(SlopeTextures);
|
||||
End();
|
||||
using (LavaSlopeRT.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Begin();
|
||||
DrawTextures(SlopeTextures);
|
||||
End();
|
||||
}
|
||||
|
||||
graphicsDevice.SetRenderTarget(LavaWaterfallRT);
|
||||
graphicsDevice.Clear(Color.Transparent);
|
||||
Begin();
|
||||
DrawTextures(WaterfallTextures);
|
||||
End();
|
||||
|
||||
graphicsDevice.SetRenderTarget(null);
|
||||
using (LavaWaterfallRT.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Begin();
|
||||
DrawTextures(WaterfallTextures);
|
||||
End();
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly BlendState ActualAdditive = new()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
@@ -62,20 +63,17 @@ namespace CalamityMod.Systems
|
||||
var renderTarget = BakedBlendTexture;
|
||||
if (renderTarget != null && !renderTarget.IsDisposed && !renderTarget.IsContentLost)
|
||||
{
|
||||
graphicsDevice.SetRenderTarget(renderTarget);
|
||||
if (_ShouldClearRT)
|
||||
using (renderTarget.Scope(clearColor: _ShouldClearRT ? Color.Transparent : null))
|
||||
{
|
||||
graphicsDevice.Clear(Color.Transparent);
|
||||
_ShouldClearRT = false;
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone);
|
||||
|
||||
BakeBlendTextureCache(v);
|
||||
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone);
|
||||
|
||||
BakeBlendTextureCache(v);
|
||||
|
||||
Main.spriteBatch.End();
|
||||
graphicsDevice.SetRenderTarget(null);
|
||||
|
||||
_RequestedVariants[variant] = false;
|
||||
_IsBaked[variant] = true;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
@@ -356,16 +357,14 @@ namespace CalamityMod
|
||||
/// </summary>
|
||||
public static void CopyContentsFrom(this RenderTarget2D to, RenderTarget2D from)
|
||||
{
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(to);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
using (to.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
Main.spriteBatch.Draw(from, Vector2.Zero, null, Color.White);
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
Main.spriteBatch.Draw(from, Vector2.Zero, null, Color.White);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(from);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(null);
|
||||
using (from.Scope(clearColor: Color.Transparent)) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user