mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Merge branch 'irenderer-batches' into irenderer-textures
This commit is contained in:
commit
a2a913ab52
@ -9,9 +9,9 @@ using System.Runtime.InteropServices;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.EnumExtensions;
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Batches;
|
|
||||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Graphics.Rendering;
|
||||||
using osu.Framework.Graphics.Shaders;
|
using osu.Framework.Graphics.Shaders;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -222,7 +222,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
private Vector2 size;
|
private Vector2 size;
|
||||||
private Vector2 originPosition;
|
private Vector2 originPosition;
|
||||||
|
|
||||||
private readonly QuadBatch<TexturedTrailVertex> vertexBatch = new QuadBatch<TexturedTrailVertex>(max_sprites, 1);
|
private IVertexBatch<TexturedTrailVertex> vertexBatch;
|
||||||
|
|
||||||
public TrailDrawNode(CursorTrail source)
|
public TrailDrawNode(CursorTrail source)
|
||||||
: base(source)
|
: base(source)
|
||||||
@ -254,9 +254,11 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
Source.parts.CopyTo(parts, 0);
|
Source.parts.CopyTo(parts, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Action<TexturedVertex2D> vertexAction)
|
public override void Draw(IRenderer renderer)
|
||||||
{
|
{
|
||||||
base.Draw(vertexAction);
|
base.Draw(renderer);
|
||||||
|
|
||||||
|
vertexBatch ??= renderer.CreateQuadBatch<TexturedTrailVertex>(max_sprites, 1);
|
||||||
|
|
||||||
shader.Bind();
|
shader.Bind();
|
||||||
shader.GetUniform<float>("g_FadeClock").UpdateValue(ref time);
|
shader.GetUniform<float>("g_FadeClock").UpdateValue(ref time);
|
||||||
@ -319,7 +321,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
vertexBatch.Dispose();
|
vertexBatch?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,8 @@ using osu.Framework.Graphics.Colour;
|
|||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics.Batches;
|
|
||||||
using osu.Framework.Graphics.OpenGL.Buffers;
|
|
||||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||||
|
using osu.Framework.Graphics.Rendering;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Backgrounds
|
namespace osu.Game.Graphics.Backgrounds
|
||||||
@ -184,8 +183,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
|
|
||||||
private void addTriangles(bool randomY)
|
private void addTriangles(bool randomY)
|
||||||
{
|
{
|
||||||
// limited by the maximum size of QuadVertexBuffer for safety.
|
// Limited by the maximum size of QuadVertexBuffer for safety.
|
||||||
const int max_triangles = QuadVertexBuffer<TexturedVertex2D>.MAX_QUADS;
|
const int max_triangles = ushort.MaxValue / (IRenderer.VERTICES_PER_QUAD + 2);
|
||||||
|
|
||||||
AimCount = (int)Math.Min(max_triangles, (DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio));
|
AimCount = (int)Math.Min(max_triangles, (DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio));
|
||||||
|
|
||||||
@ -251,7 +250,7 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
private readonly List<TriangleParticle> parts = new List<TriangleParticle>();
|
private readonly List<TriangleParticle> parts = new List<TriangleParticle>();
|
||||||
private Vector2 size;
|
private Vector2 size;
|
||||||
|
|
||||||
private QuadBatch<TexturedVertex2D> vertexBatch;
|
private IVertexBatch<TexturedVertex2D> vertexBatch;
|
||||||
|
|
||||||
public TrianglesDrawNode(Triangles source)
|
public TrianglesDrawNode(Triangles source)
|
||||||
: base(source)
|
: base(source)
|
||||||
@ -270,14 +269,14 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
parts.AddRange(Source.parts);
|
parts.AddRange(Source.parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Action<TexturedVertex2D> vertexAction)
|
public override void Draw(IRenderer renderer)
|
||||||
{
|
{
|
||||||
base.Draw(vertexAction);
|
base.Draw(renderer);
|
||||||
|
|
||||||
if (Source.AimCount > 0 && (vertexBatch == null || vertexBatch.Size != Source.AimCount))
|
if (Source.AimCount > 0 && (vertexBatch == null || vertexBatch.Size != Source.AimCount))
|
||||||
{
|
{
|
||||||
vertexBatch?.Dispose();
|
vertexBatch?.Dispose();
|
||||||
vertexBatch = new QuadBatch<TexturedVertex2D>(Source.AimCount, 1);
|
vertexBatch = renderer.CreateQuadBatch<TexturedVertex2D>(Source.AimCount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
shader.Bind();
|
shader.Bind();
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Graphics.Rendering;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -89,7 +89,7 @@ namespace osu.Game.Graphics
|
|||||||
currentTime = source.Time.Current;
|
currentTime = source.Time.Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Blit(Action<TexturedVertex2D> vertexAction)
|
protected override void Blit(IRenderer renderer)
|
||||||
{
|
{
|
||||||
double time = currentTime - startTime;
|
double time = currentTime - startTime;
|
||||||
|
|
||||||
@ -112,9 +112,9 @@ namespace osu.Game.Graphics
|
|||||||
Vector2Extensions.Transform(rect.BottomRight, DrawInfo.Matrix)
|
Vector2Extensions.Transform(rect.BottomRight, DrawInfo.Matrix)
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawQuad(Texture, quad, DrawColourInfo.Colour.MultiplyAlpha(alpha), null, vertexAction,
|
DrawQuad(Texture, quad, DrawColourInfo.Colour.MultiplyAlpha(alpha),
|
||||||
new Vector2(InflationAmount.X / DrawRectangle.Width, InflationAmount.Y / DrawRectangle.Height),
|
inflationPercentage: new Vector2(InflationAmount.X / DrawRectangle.Width, InflationAmount.Y / DrawRectangle.Height),
|
||||||
null, TextureCoords);
|
textureCoords: TextureCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ using System;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.EnumExtensions;
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Graphics.Rendering;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -107,7 +107,7 @@ namespace osu.Game.Graphics
|
|||||||
sourceSize = Source.DrawSize;
|
sourceSize = Source.DrawSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Blit(Action<TexturedVertex2D> vertexAction)
|
protected override void Blit(IRenderer renderer)
|
||||||
{
|
{
|
||||||
foreach (var p in particles)
|
foreach (var p in particles)
|
||||||
{
|
{
|
||||||
@ -136,9 +136,9 @@ namespace osu.Game.Graphics
|
|||||||
transformPosition(rect.BottomRight, rect.Centre, angle)
|
transformPosition(rect.BottomRight, rect.Centre, angle)
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawQuad(Texture, quad, DrawColourInfo.Colour.MultiplyAlpha(alpha), null, vertexAction,
|
DrawQuad(Texture, quad, DrawColourInfo.Colour.MultiplyAlpha(alpha),
|
||||||
new Vector2(InflationAmount.X / DrawRectangle.Width, InflationAmount.Y / DrawRectangle.Height),
|
inflationPercentage: new Vector2(InflationAmount.X / DrawRectangle.Width, InflationAmount.Y / DrawRectangle.Height),
|
||||||
null, TextureCoords);
|
textureCoords: TextureCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
using osu.Framework.Graphics.Rendering;
|
||||||
using osu.Framework.Graphics.Shaders;
|
using osu.Framework.Graphics.Shaders;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
|
||||||
@ -57,11 +56,11 @@ namespace osu.Game.Graphics.Sprites
|
|||||||
progress = source.animationProgress;
|
progress = source.animationProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Blit(Action<TexturedVertex2D> vertexAction)
|
protected override void Blit(IRenderer renderer)
|
||||||
{
|
{
|
||||||
Shader.GetUniform<float>("progress").UpdateValue(ref progress);
|
Shader.GetUniform<float>("progress").UpdateValue(ref progress);
|
||||||
|
|
||||||
base.Blit(vertexAction);
|
base.Blit(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool CanDrawOpaqueInterior => false;
|
protected override bool CanDrawOpaqueInterior => false;
|
||||||
|
@ -6,9 +6,9 @@ using System.Collections.Generic;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Batches;
|
|
||||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Graphics.Rendering;
|
||||||
using osu.Framework.Graphics.Shaders;
|
using osu.Framework.Graphics.Shaders;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
@ -211,17 +211,12 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
private Vector2 flashlightSize;
|
private Vector2 flashlightSize;
|
||||||
private float flashlightDim;
|
private float flashlightDim;
|
||||||
|
|
||||||
private readonly VertexBatch<PositionAndColourVertex> quadBatch = new QuadBatch<PositionAndColourVertex>(1, 1);
|
private IVertexBatch<PositionAndColourVertex>? quadBatch;
|
||||||
private readonly Action<TexturedVertex2D> addAction;
|
private Action<TexturedVertex2D>? addAction;
|
||||||
|
|
||||||
public FlashlightDrawNode(Flashlight source)
|
public FlashlightDrawNode(Flashlight source)
|
||||||
: base(source)
|
: base(source)
|
||||||
{
|
{
|
||||||
addAction = v => quadBatch.Add(new PositionAndColourVertex
|
|
||||||
{
|
|
||||||
Position = v.Position,
|
|
||||||
Colour = v.Colour
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ApplyState()
|
public override void ApplyState()
|
||||||
@ -235,9 +230,19 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
flashlightDim = Source.FlashlightDim;
|
flashlightDim = Source.FlashlightDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Action<TexturedVertex2D> vertexAction)
|
public override void Draw(IRenderer renderer)
|
||||||
{
|
{
|
||||||
base.Draw(vertexAction);
|
base.Draw(renderer);
|
||||||
|
|
||||||
|
if (quadBatch == null)
|
||||||
|
{
|
||||||
|
quadBatch = renderer.CreateQuadBatch<PositionAndColourVertex>(1, 1);
|
||||||
|
addAction = v => quadBatch.Add(new PositionAndColourVertex
|
||||||
|
{
|
||||||
|
Position = v.Position,
|
||||||
|
Colour = v.Colour
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
shader.Bind();
|
shader.Bind();
|
||||||
|
|
||||||
@ -253,7 +258,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
quadBatch.Dispose();
|
quadBatch?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Batches;
|
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
@ -22,6 +21,7 @@ using osu.Framework.Audio.Track;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics.Rendering;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Menu
|
namespace osu.Game.Screens.Menu
|
||||||
{
|
{
|
||||||
@ -180,7 +180,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
private readonly float[] audioData = new float[256];
|
private readonly float[] audioData = new float[256];
|
||||||
|
|
||||||
private readonly QuadBatch<TexturedVertex2D> vertexBatch = new QuadBatch<TexturedVertex2D>(100, 10);
|
private IVertexBatch<TexturedVertex2D> vertexBatch;
|
||||||
|
|
||||||
public VisualisationDrawNode(LogoVisualisation source)
|
public VisualisationDrawNode(LogoVisualisation source)
|
||||||
: base(source)
|
: base(source)
|
||||||
@ -198,9 +198,11 @@ namespace osu.Game.Screens.Menu
|
|||||||
Source.frequencyAmplitudes.AsSpan().CopyTo(audioData);
|
Source.frequencyAmplitudes.AsSpan().CopyTo(audioData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Action<TexturedVertex2D> vertexAction)
|
public override void Draw(IRenderer renderer)
|
||||||
{
|
{
|
||||||
base.Draw(vertexAction);
|
base.Draw(renderer);
|
||||||
|
|
||||||
|
vertexBatch ??= renderer.CreateQuadBatch<TexturedVertex2D>(100, 10);
|
||||||
|
|
||||||
shader.Bind();
|
shader.Bind();
|
||||||
|
|
||||||
@ -256,7 +258,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
vertexBatch.Dispose();
|
vertexBatch?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user