OpenGL -> GL

This commit is contained in:
Salman Ahmed
2022-08-26 08:44:20 +03:00
parent bdba48b208
commit d92664c0d0
26 changed files with 113 additions and 113 deletions

View File

@@ -333,6 +333,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IOS/@EntryIndexedValue">IOS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IOSGL/@EntryIndexedValue">IOSGL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IPC/@EntryIndexedValue">IPC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=JIT/@EntryIndexedValue">JIT</s:String>

View File

@@ -12,7 +12,7 @@ namespace osu.Framework.Tests.Graphics
[TestFixture]
public class ShaderRegexTest
{
private readonly Regex shaderAttributeRegex = new Regex(OpenGLShaderPart.SHADER_ATTRIBUTE_PATTERN);
private readonly Regex shaderAttributeRegex = new Regex(GLShaderPart.SHADER_ATTRIBUTE_PATTERN);
[Test]
public void TestComment()

View File

@@ -20,7 +20,7 @@ namespace osu.Framework.Tests.Shaders
public class TestSceneShaderDisposal : FrameworkTestScene
{
private ShaderManager manager;
private OpenGLShader shader;
private GLShader shader;
private WeakReference<IShader> shaderRef;
@@ -30,7 +30,7 @@ namespace osu.Framework.Tests.Shaders
AddStep("setup manager", () =>
{
manager = new TestShaderManager(new NamespacedResourceStore<byte[]>(new DllResourceStore(typeof(Game).Assembly), @"Resources/Shaders"));
shader = (OpenGLShader)manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE);
shader = (GLShader)manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE);
shaderRef = new WeakReference<IShader>(shader);
shader.EnsureShaderCompiled();
@@ -61,18 +61,18 @@ namespace osu.Framework.Tests.Shaders
private class TestShaderManager : ShaderManager
{
public TestShaderManager(IResourceStore<byte[]> store)
: base(new OpenGLRenderer(), store)
: base(new GLRenderer(), store)
{
}
internal override IShader CreateShader(IRenderer renderer, string name, params IShaderPart[] parts)
=> new TestOpenGLShader(renderer, name, parts.Cast<OpenGLShaderPart>().ToArray());
=> new TestGLShader(renderer, name, parts.Cast<GLShaderPart>().ToArray());
private class TestOpenGLShader : OpenGLShader
private class TestGLShader : GLShader
{
private readonly IRenderer renderer;
internal TestOpenGLShader(IRenderer renderer, string name, OpenGLShaderPart[] parts)
internal TestGLShader(IRenderer renderer, string name, GLShaderPart[] parts)
: base(renderer, name, parts)
{
this.renderer = renderer;

View File

@@ -1,16 +1,15 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.iOS;
using osu.Framework.Graphics.OpenGL;
namespace osu.Framework.iOS.Graphics
namespace osu.Framework.iOS.Graphics.OpenGL
{
internal class IOSOpenGLRenderer : OpenGLRenderer
internal class IOSGLRenderer : GLRenderer
{
private readonly IOSGameView gameView;
public IOSOpenGLRenderer(IOSGameView gameView)
public IOSGLRenderer(IOSGameView gameView)
{
this.gameView = gameView;
}

View File

@@ -15,7 +15,7 @@ using osu.Framework.Input.Bindings;
using osu.Framework.Input.Handlers;
using osu.Framework.Input.Handlers.Midi;
using osu.Framework.IO.Stores;
using osu.Framework.iOS.Graphics;
using osu.Framework.iOS.Graphics.OpenGL;
using osu.Framework.iOS.Graphics.Textures;
using osu.Framework.iOS.Graphics.Video;
using osu.Framework.iOS.Input;
@@ -36,7 +36,7 @@ namespace osu.Framework.iOS
this.gameView = gameView;
}
protected override IRenderer CreateRenderer() => new IOSOpenGLRenderer(gameView);
protected override IRenderer CreateRenderer() => new IOSGLRenderer(gameView);
protected override void SetupForRun()
{

View File

@@ -10,17 +10,17 @@ using osuTK.Graphics.ES30;
namespace osu.Framework.Graphics.OpenGL.Batches
{
internal class OpenGLLinearBatch<T> : OpenGLVertexBatch<T>
internal class GLLinearBatch<T> : GLVertexBatch<T>
where T : struct, IEquatable<T>, IVertex
{
private readonly PrimitiveType type;
public OpenGLLinearBatch(OpenGLRenderer renderer, int size, int maxBuffers, PrimitiveType type)
public GLLinearBatch(GLRenderer renderer, int size, int maxBuffers, PrimitiveType type)
: base(renderer, size, maxBuffers)
{
this.type = type;
}
protected override OpenGLVertexBuffer<T> CreateVertexBuffer(OpenGLRenderer renderer) => new OpenGLLinearBuffer<T>(renderer, Size, type, BufferUsageHint.DynamicDraw);
protected override GLVertexBuffer<T> CreateVertexBuffer(GLRenderer renderer) => new GLLinearBuffer<T>(renderer, Size, type, BufferUsageHint.DynamicDraw);
}
}

View File

@@ -10,14 +10,14 @@ using osuTK.Graphics.ES30;
namespace osu.Framework.Graphics.OpenGL.Batches
{
internal class OpenGLQuadBatch<T> : OpenGLVertexBatch<T>
internal class GLQuadBatch<T> : GLVertexBatch<T>
where T : struct, IEquatable<T>, IVertex
{
public OpenGLQuadBatch(OpenGLRenderer renderer, int size, int maxBuffers)
public GLQuadBatch(GLRenderer renderer, int size, int maxBuffers)
: base(renderer, size, maxBuffers)
{
}
protected override OpenGLVertexBuffer<T> CreateVertexBuffer(OpenGLRenderer renderer) => new OpenGLQuadBuffer<T>(renderer, Size, BufferUsageHint.DynamicDraw);
protected override GLVertexBuffer<T> CreateVertexBuffer(GLRenderer renderer) => new GLQuadBuffer<T>(renderer, Size, BufferUsageHint.DynamicDraw);
}
}

View File

@@ -12,10 +12,10 @@ using osu.Framework.Statistics;
namespace osu.Framework.Graphics.OpenGL.Batches
{
internal abstract class OpenGLVertexBatch<T> : IVertexBatch<T>
internal abstract class GLVertexBatch<T> : IVertexBatch<T>
where T : struct, IEquatable<T>, IVertex
{
public List<OpenGLVertexBuffer<T>> VertexBuffers = new List<OpenGLVertexBuffer<T>>();
public List<GLVertexBuffer<T>> VertexBuffers = new List<GLVertexBuffer<T>>();
/// <summary>
/// The number of vertices in each VertexBuffer.
@@ -28,12 +28,12 @@ namespace osu.Framework.Graphics.OpenGL.Batches
private int currentBufferIndex;
private int currentVertexIndex;
private readonly OpenGLRenderer renderer;
private readonly GLRenderer renderer;
private readonly int maxBuffers;
private OpenGLVertexBuffer<T> currentVertexBuffer => VertexBuffers[currentBufferIndex];
private GLVertexBuffer<T> currentVertexBuffer => VertexBuffers[currentBufferIndex];
protected OpenGLVertexBatch(OpenGLRenderer renderer, int bufferSize, int maxBuffers)
protected GLVertexBatch(GLRenderer renderer, int bufferSize, int maxBuffers)
{
Size = bufferSize;
this.renderer = renderer;
@@ -54,7 +54,7 @@ namespace osu.Framework.Graphics.OpenGL.Batches
{
if (disposing)
{
foreach (OpenGLVertexBuffer<T> vbo in VertexBuffers)
foreach (GLVertexBuffer<T> vbo in VertexBuffers)
vbo.Dispose();
}
}
@@ -68,10 +68,10 @@ namespace osu.Framework.Graphics.OpenGL.Batches
currentVertexIndex = 0;
}
protected abstract OpenGLVertexBuffer<T> CreateVertexBuffer(OpenGLRenderer renderer);
protected abstract GLVertexBuffer<T> CreateVertexBuffer(GLRenderer renderer);
/// <summary>
/// Adds a vertex to this <see cref="OpenGLVertexBatch{T}"/>.
/// Adds a vertex to this <see cref="GLVertexBatch{T}"/>.
/// </summary>
/// <param name="v">The vertex to add.</param>
public void Add(T v)
@@ -100,7 +100,7 @@ namespace osu.Framework.Graphics.OpenGL.Batches
}
/// <summary>
/// Adds a vertex to this <see cref="OpenGLVertexBatch{T}"/>.
/// Adds a vertex to this <see cref="GLVertexBatch{T}"/>.
/// This is a cached delegate of <see cref="Add"/> that should be used in memory-critical locations such as <see cref="DrawNode"/>s.
/// </summary>
public Action<T> AddAction { get; private set; }
@@ -110,7 +110,7 @@ namespace osu.Framework.Graphics.OpenGL.Batches
if (currentVertexIndex == 0)
return 0;
OpenGLVertexBuffer<T> vertexBuffer = currentVertexBuffer;
GLVertexBuffer<T> vertexBuffer = currentVertexBuffer;
if (changeBeginIndex >= 0)
vertexBuffer.UpdateRange(changeBeginIndex, changeEndIndex);

View File

@@ -8,7 +8,7 @@ using osuTK.Graphics.ES30;
namespace osu.Framework.Graphics.OpenGL.Buffers
{
public static class OpenGLBufferFormatExtensions
public static class GLBufferFormatExtensions
{
public static FramebufferAttachment GetAttachmentType(this RenderbufferInternalFormat format)
{

View File

@@ -11,16 +11,16 @@ using osuTK.Graphics.ES30;
namespace osu.Framework.Graphics.OpenGL.Buffers
{
internal class OpenGLFrameBuffer : IFrameBuffer
internal class GLFrameBuffer : IFrameBuffer
{
public Texture Texture { get; }
private readonly List<OpenGLRenderBuffer> attachedRenderBuffers = new List<OpenGLRenderBuffer>();
private readonly OpenGLRenderer renderer;
private readonly List<GLRenderBuffer> attachedRenderBuffers = new List<GLRenderBuffer>();
private readonly GLRenderer renderer;
private readonly TextureGL textureGL;
private readonly int frameBuffer;
public OpenGLFrameBuffer(OpenGLRenderer renderer, RenderbufferInternalFormat[]? renderBufferFormats = null, All filteringMode = All.Linear)
public GLFrameBuffer(GLRenderer renderer, RenderbufferInternalFormat[]? renderBufferFormats = null, All filteringMode = All.Linear)
{
this.renderer = renderer;
frameBuffer = GL.GenFramebuffer();
@@ -34,7 +34,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
if (renderBufferFormats != null)
{
foreach (var format in renderBufferFormats)
attachedRenderBuffers.Add(new OpenGLRenderBuffer(renderer, format));
attachedRenderBuffers.Add(new GLRenderBuffer(renderer, format));
}
renderer.UnbindFrameBuffer(frameBuffer);
@@ -90,7 +90,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
#region Disposal
~OpenGLFrameBuffer()
~GLFrameBuffer()
{
renderer.ScheduleDisposal(b => b.Dispose(false), this);
}
@@ -121,7 +121,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
private class FrameBufferTexture : TextureGL
{
public FrameBufferTexture(OpenGLRenderer renderer, All filteringMode = All.Linear)
public FrameBufferTexture(GLRenderer renderer, All filteringMode = All.Linear)
: base(renderer, 1, 1, true, filteringMode)
{
BypassTextureUploadQueueing = true;

View File

@@ -24,12 +24,12 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
/// <summary>
/// This type of vertex buffer lets the ith vertex be referenced by the ith index.
/// </summary>
internal class OpenGLLinearBuffer<T> : OpenGLVertexBuffer<T>
internal class GLLinearBuffer<T> : GLVertexBuffer<T>
where T : struct, IEquatable<T>, IVertex
{
private readonly int amountVertices;
public OpenGLLinearBuffer(OpenGLRenderer renderer, int amountVertices, PrimitiveType type, BufferUsageHint usage)
public GLLinearBuffer(GLRenderer renderer, int amountVertices, PrimitiveType type, BufferUsageHint usage)
: base(renderer, amountVertices, usage)
{
this.amountVertices = amountVertices;

View File

@@ -22,7 +22,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
public static int MaxAmountIndices;
}
internal class OpenGLQuadBuffer<T> : OpenGLVertexBuffer<T>
internal class GLQuadBuffer<T> : GLVertexBuffer<T>
where T : struct, IEquatable<T>, IVertex
{
private readonly int amountIndices;
@@ -34,7 +34,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
/// </summary>
public const int MAX_QUADS = ushort.MaxValue / indices_per_quad;
public OpenGLQuadBuffer(OpenGLRenderer renderer, int amountQuads, BufferUsageHint usage)
public GLQuadBuffer(GLRenderer renderer, int amountQuads, BufferUsageHint usage)
: base(renderer, amountQuads * IRenderer.VERTICES_PER_QUAD, usage)
{
amountIndices = amountQuads * indices_per_quad;

View File

@@ -10,16 +10,16 @@ using osuTK.Graphics.ES30;
namespace osu.Framework.Graphics.OpenGL.Buffers
{
internal class OpenGLRenderBuffer : IDisposable
internal class GLRenderBuffer : IDisposable
{
private readonly OpenGLRenderer renderer;
private readonly GLRenderer renderer;
private readonly RenderbufferInternalFormat format;
private readonly int renderBuffer;
private readonly int sizePerPixel;
private FramebufferAttachment attachment;
public OpenGLRenderBuffer(OpenGLRenderer renderer, RenderbufferInternalFormat format)
public GLRenderBuffer(GLRenderer renderer, RenderbufferInternalFormat format)
{
this.renderer = renderer;
this.format = format;
@@ -75,7 +75,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
#region Disposal
~OpenGLRenderBuffer()
~GLRenderBuffer()
{
renderer.ScheduleDisposal(b => b.Dispose(false), this);
}

View File

@@ -13,7 +13,7 @@ using SixLabors.ImageSharp.Memory;
namespace osu.Framework.Graphics.OpenGL.Buffers
{
internal abstract class OpenGLVertexBuffer<T> : IOpenGLVertexBuffer, IDisposable
internal abstract class GLVertexBuffer<T> : IGLVertexBuffer, IDisposable
where T : struct, IEquatable<T>, IVertex
{
/// <summary>
@@ -21,9 +21,9 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
/// </summary>
public const int MAX_VERTICES = ushort.MaxValue;
protected static readonly int STRIDE = OpenGLVertexUtils<DepthWrappingVertex<T>>.STRIDE;
protected static readonly int STRIDE = GLVertexUtils<DepthWrappingVertex<T>>.STRIDE;
protected readonly OpenGLRenderer Renderer;
protected readonly GLRenderer Renderer;
private readonly BufferUsageHint usage;
private Memory<DepthWrappingVertex<T>> vertexMemory;
@@ -31,7 +31,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
private int vboId = -1;
protected OpenGLVertexBuffer(OpenGLRenderer renderer, int amountVertices, BufferUsageHint usage)
protected GLVertexBuffer(GLRenderer renderer, int amountVertices, BufferUsageHint usage)
{
Renderer = renderer;
this.usage = usage;
@@ -40,7 +40,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
}
/// <summary>
/// Sets the vertex at a specific index of this <see cref="OpenGLVertexBuffer{T}"/>.
/// Sets the vertex at a specific index of this <see cref="GLVertexBuffer{T}"/>.
/// </summary>
/// <param name="vertexIndex">The index of the vertex.</param>
/// <param name="vertex">The vertex.</param>
@@ -58,12 +58,12 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
}
/// <summary>
/// Gets the number of vertices in this <see cref="OpenGLVertexBuffer{T}"/>.
/// Gets the number of vertices in this <see cref="GLVertexBuffer{T}"/>.
/// </summary>
public int Size { get; }
/// <summary>
/// Initialises this <see cref="OpenGLVertexBuffer{T}"/>. Guaranteed to be run on the draw thread.
/// Initialises this <see cref="GLVertexBuffer{T}"/>. Guaranteed to be run on the draw thread.
/// </summary>
protected virtual void Initialise()
{
@@ -72,14 +72,14 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
GL.GenBuffers(1, out vboId);
if (Renderer.BindBuffer(BufferTarget.ArrayBuffer, vboId))
OpenGLVertexUtils<DepthWrappingVertex<T>>.Bind();
GLVertexUtils<DepthWrappingVertex<T>>.Bind();
int size = Size * STRIDE;
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)size, IntPtr.Zero, usage);
}
~OpenGLVertexBuffer()
~GLVertexBuffer()
{
Renderer.ScheduleDisposal(v => v.Dispose(false), this);
}
@@ -97,7 +97,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
if (IsDisposed)
return;
((IOpenGLVertexBuffer)this).Free();
((IGLVertexBuffer)this).Free();
IsDisposed = true;
}
@@ -111,7 +111,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
Initialise();
if (Renderer.BindBuffer(BufferTarget.ArrayBuffer, vboId))
OpenGLVertexUtils<DepthWrappingVertex<T>>.Bind();
GLVertexUtils<DepthWrappingVertex<T>>.Bind();
}
public virtual void Unbind()
@@ -177,7 +177,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
public bool InUse => LastUseResetId > 0;
void IOpenGLVertexBuffer.Free()
void IGLVertexBuffer.Free()
{
if (vboId != -1)
{

View File

@@ -18,7 +18,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
/// <summary>
/// Helper method that provides functionality to enable and bind GL vertex attributes.
/// </summary>
internal static class OpenGLVertexUtils<T>
internal static class GLVertexUtils<T>
where T : struct, IVertex
{
/// <summary>
@@ -29,7 +29,7 @@ namespace osu.Framework.Graphics.OpenGL.Buffers
private static readonly List<VertexMemberAttribute> attributes = new List<VertexMemberAttribute>();
private static int amountEnabledAttributes;
static OpenGLVertexUtils()
static GLVertexUtils()
{
addAttributesRecursive(typeof(T), 0);
}

View File

@@ -6,22 +6,22 @@
namespace osu.Framework.Graphics.OpenGL.Buffers
{
/// <summary>
/// Internal interface for all <see cref="OpenGLVertexBuffer{T}"/>s.
/// Internal interface for all <see cref="GLVertexBuffer{T}"/>s.
/// </summary>
internal interface IOpenGLVertexBuffer
internal interface IGLVertexBuffer
{
/// <summary>
/// The <see cref="OpenGLRenderer.ResetId"/> when this <see cref="IOpenGLVertexBuffer"/> was last used.
/// The <see cref="GLRenderer.ResetId"/> when this <see cref="IGLVertexBuffer"/> was last used.
/// </summary>
ulong LastUseResetId { get; }
/// <summary>
/// Whether this <see cref="IOpenGLVertexBuffer"/> is currently in use.
/// Whether this <see cref="IGLVertexBuffer"/> is currently in use.
/// </summary>
bool InUse { get; }
/// <summary>
/// Frees all resources allocated by this <see cref="IOpenGLVertexBuffer"/>.
/// Frees all resources allocated by this <see cref="IGLVertexBuffer"/>.
/// </summary>
void Free();
}

View File

@@ -27,7 +27,7 @@ using SixLabors.ImageSharp.PixelFormats;
namespace osu.Framework.Graphics.OpenGL
{
internal class OpenGLRenderer : IRenderer
internal class GLRenderer : IRenderer
{
/// <summary>
/// The interval (in frames) before checking whether VBOs should be freed.
@@ -72,10 +72,10 @@ namespace osu.Framework.Graphics.OpenGL
protected virtual int BackbufferFramebuffer => 0;
private readonly GlobalStatistic<int> statExpensiveOperationsQueued = GlobalStatistics.Get<int>(nameof(OpenGLRenderer), "Expensive operation queue length");
private readonly GlobalStatistic<int> statTextureUploadsQueued = GlobalStatistics.Get<int>(nameof(OpenGLRenderer), "Texture upload queue length");
private readonly GlobalStatistic<int> statTextureUploadsDequeued = GlobalStatistics.Get<int>(nameof(OpenGLRenderer), "Texture uploads dequeued");
private readonly GlobalStatistic<int> statTextureUploadsPerformed = GlobalStatistics.Get<int>(nameof(OpenGLRenderer), "Texture uploads performed");
private readonly GlobalStatistic<int> statExpensiveOperationsQueued = GlobalStatistics.Get<int>(nameof(GLRenderer), "Expensive operation queue length");
private readonly GlobalStatistic<int> statTextureUploadsQueued = GlobalStatistics.Get<int>(nameof(GLRenderer), "Texture upload queue length");
private readonly GlobalStatistic<int> statTextureUploadsDequeued = GlobalStatistics.Get<int>(nameof(GLRenderer), "Texture uploads dequeued");
private readonly GlobalStatistic<int> statTextureUploadsPerformed = GlobalStatistics.Get<int>(nameof(GLRenderer), "Texture uploads performed");
private readonly ConcurrentQueue<ScheduledDelegate> expensiveOperationQueue = new ConcurrentQueue<ScheduledDelegate>();
private readonly ConcurrentQueue<TextureGL> textureUploadQueue = new ConcurrentQueue<TextureGL>();
@@ -84,7 +84,7 @@ namespace osu.Framework.Graphics.OpenGL
private readonly Scheduler resetScheduler = new Scheduler(() => ThreadSafety.IsDrawThread, new StopwatchClock(true)); // force no thread set until we are actually on the draw thread.
private readonly Stack<IVertexBatch<TexturedVertex2D>> quadBatches = new Stack<IVertexBatch<TexturedVertex2D>>();
private readonly List<IOpenGLVertexBuffer> vertexBuffersInUse = new List<IOpenGLVertexBuffer>();
private readonly List<IGLVertexBuffer> vertexBuffersInUse = new List<IGLVertexBuffer>();
private readonly List<IVertexBatch> batchResetList = new List<IVertexBatch>();
private readonly Stack<RectangleI> viewportStack = new Stack<RectangleI>();
private readonly Stack<Matrix4> projectionMatrixStack = new Stack<Matrix4>();
@@ -115,7 +115,7 @@ namespace osu.Framework.Graphics.OpenGL
private bool isInitialised;
private int lastActiveTextureUnit;
public OpenGLRenderer()
public GLRenderer()
{
whitePixel = new Lazy<TextureWhitePixel>(() =>
new TextureAtlas(this, TextureAtlas.WHITE_PIXEL_SIZE + TextureAtlas.PADDING, TextureAtlas.WHITE_PIXEL_SIZE + TextureAtlas.PADDING, true).WhitePixel);
@@ -319,7 +319,7 @@ namespace osu.Framework.Graphics.OpenGL
flushCurrentBatch();
GL.UseProgram((OpenGLShader)shader);
GL.UseProgram((GLShader)shader);
currentShader = shader;
}
@@ -723,7 +723,7 @@ namespace osu.Framework.Graphics.OpenGL
if (depthInfo.DepthTest)
{
GL.Enable(EnableCap.DepthTest);
GL.DepthFunc(OpenGLUtils.ToDepthFunction(depthInfo.Function));
GL.DepthFunc(GLUtils.ToDepthFunction(depthInfo.Function));
}
else
GL.Disable(EnableCap.DepthTest);
@@ -763,11 +763,11 @@ namespace osu.Framework.Graphics.OpenGL
if (stencilInfo.StencilTest)
{
GL.Enable(EnableCap.StencilTest);
GL.StencilFunc(OpenGLUtils.ToStencilFunction(stencilInfo.TestFunction), stencilInfo.TestValue, stencilInfo.Mask);
GL.StencilFunc(GLUtils.ToStencilFunction(stencilInfo.TestFunction), stencilInfo.TestValue, stencilInfo.Mask);
GL.StencilOp(
OpenGLUtils.ToStencilOperation(stencilInfo.StencilTestFailOperation),
OpenGLUtils.ToStencilOperation(stencilInfo.DepthTestFailOperation),
OpenGLUtils.ToStencilOperation(stencilInfo.TestPassedOperation));
GLUtils.ToStencilOperation(stencilInfo.StencilTestFailOperation),
GLUtils.ToStencilOperation(stencilInfo.DepthTestFailOperation),
GLUtils.ToStencilOperation(stencilInfo.TestPassedOperation));
}
else
GL.Disable(EnableCap.StencilTest);
@@ -853,10 +853,10 @@ namespace osu.Framework.Graphics.OpenGL
throw new ArgumentException($"Unsupported shader part type: {partType}", nameof(partType));
}
return new OpenGLShaderPart(this, name, rawData, glType, manager);
return new GLShaderPart(this, name, rawData, glType, manager);
}
IShader IRenderer.CreateShader(string name, params IShaderPart[] parts) => new OpenGLShader(this, name, parts.Cast<OpenGLShaderPart>().ToArray());
IShader IRenderer.CreateShader(string name, params IShaderPart[] parts) => new GLShader(this, name, parts.Cast<GLShaderPart>().ToArray());
public IFrameBuffer CreateFrameBuffer(RenderBufferFormat[]? renderBufferFormats = null, TextureFilteringMode filteringMode = TextureFilteringMode.Linear)
{
@@ -907,7 +907,7 @@ namespace osu.Framework.Graphics.OpenGL
}
}
return new OpenGLFrameBuffer(this, glFormats, glFilteringMode);
return new GLFrameBuffer(this, glFormats, glFilteringMode);
}
public Texture CreateTexture(int width, int height, bool manualMipmaps = false, TextureFilteringMode filteringMode = TextureFilteringMode.Linear, WrapMode wrapModeS = WrapMode.None,
@@ -950,13 +950,13 @@ namespace osu.Framework.Graphics.OpenGL
if (size <= 0)
throw new ArgumentException("Linear batch size must be > 0.", nameof(size));
if (size > OpenGLLinearBuffer<TVertex>.MAX_VERTICES)
throw new ArgumentException($"Linear batch may not have more than {OpenGLLinearBuffer<TVertex>.MAX_VERTICES} vertices.", nameof(size));
if (size > GLLinearBuffer<TVertex>.MAX_VERTICES)
throw new ArgumentException($"Linear batch may not have more than {GLLinearBuffer<TVertex>.MAX_VERTICES} vertices.", nameof(size));
if (maxBuffers <= 0)
throw new ArgumentException("Maximum number of buffers must be > 0.", nameof(maxBuffers));
return new OpenGLLinearBatch<TVertex>(this, size, maxBuffers, OpenGLUtils.ToPrimitiveType(topology));
return new GLLinearBatch<TVertex>(this, size, maxBuffers, GLUtils.ToPrimitiveType(topology));
}
public IVertexBatch<TVertex> CreateQuadBatch<TVertex>(int size, int maxBuffers) where TVertex : unmanaged, IEquatable<TVertex>, IVertex
@@ -964,13 +964,13 @@ namespace osu.Framework.Graphics.OpenGL
if (size <= 0)
throw new ArgumentException("Quad batch size must be > 0.", nameof(size));
if (size > OpenGLQuadBuffer<TVertex>.MAX_QUADS)
throw new ArgumentException($"Quad batch may not have more than {OpenGLQuadBuffer<TVertex>.MAX_QUADS} quads.", nameof(size));
if (size > GLQuadBuffer<TVertex>.MAX_QUADS)
throw new ArgumentException($"Quad batch may not have more than {GLQuadBuffer<TVertex>.MAX_QUADS} quads.", nameof(size));
if (maxBuffers <= 0)
throw new ArgumentException("Maximum number of buffers must be > 0.", nameof(maxBuffers));
return new OpenGLQuadBatch<TVertex>(this, size, maxBuffers);
return new GLQuadBatch<TVertex>(this, size, maxBuffers);
}
void IRenderer.SetUniform<T>(IUniformWithValue<T> uniform)
@@ -1019,10 +1019,10 @@ namespace osu.Framework.Graphics.OpenGL
}
/// <summary>
/// Notifies that a <see cref="IOpenGLVertexBuffer"/> has begun being used.
/// Notifies that a <see cref="IGLVertexBuffer"/> has begun being used.
/// </summary>
/// <param name="buffer">The <see cref="IOpenGLVertexBuffer"/> in use.</param>
public void RegisterVertexBufferUse(IOpenGLVertexBuffer buffer) => vertexBuffersInUse.Add(buffer);
/// <param name="buffer">The <see cref="IGLVertexBuffer"/> in use.</param>
public void RegisterVertexBufferUse(IGLVertexBuffer buffer) => vertexBuffersInUse.Add(buffer);
/// <summary>
/// Sets the last vertex batch used for drawing.

View File

@@ -7,7 +7,7 @@ using osuTK.Graphics.ES30;
namespace osu.Framework.Graphics.OpenGL
{
internal static class OpenGLUtils
internal static class GLUtils
{
public static PrimitiveType ToPrimitiveType(PrimitiveTopology topology)
{

View File

@@ -15,11 +15,11 @@ using static osu.Framework.Threading.ScheduledDelegate;
namespace osu.Framework.Graphics.OpenGL.Shaders
{
internal class OpenGLShader : IShader
internal class GLShader : IShader
{
private readonly IRenderer renderer;
private readonly string name;
private readonly OpenGLShaderPart[] parts;
private readonly GLShaderPart[] parts;
private readonly ScheduledDelegate shaderCompileDelegate;
@@ -36,7 +36,7 @@ namespace osu.Framework.Graphics.OpenGL.Shaders
private int programID = -1;
internal OpenGLShader(IRenderer renderer, string name, OpenGLShaderPart[] parts)
internal GLShader(IRenderer renderer, string name, GLShaderPart[] parts)
{
this.renderer = renderer;
this.name = name;
@@ -123,7 +123,7 @@ namespace osu.Framework.Graphics.OpenGL.Shaders
private protected virtual bool CompileInternal()
{
foreach (OpenGLShaderPart p in parts)
foreach (GLShaderPart p in parts)
{
if (!p.Compiled) p.Compile();
GL.AttachShader(this, p);
@@ -218,13 +218,13 @@ namespace osu.Framework.Graphics.OpenGL.Shaders
public override string ToString() => $@"{name} Shader (Compiled: {programID != -1})";
public static implicit operator int(OpenGLShader shader) => shader.programID;
public static implicit operator int(GLShader shader) => shader.programID;
#region IDisposable Support
protected internal bool IsDisposed { get; private set; }
~OpenGLShader()
~GLShader()
{
renderer.ScheduleDisposal(s => s.Dispose(false), this);
}
@@ -255,7 +255,7 @@ namespace osu.Framework.Graphics.OpenGL.Shaders
public class PartCompilationFailedException : Exception
{
public PartCompilationFailedException(string partName, string log)
: base($"A {typeof(OpenGLShaderPart)} failed to compile: {partName}:\n{log.Trim()}")
: base($"A {typeof(GLShaderPart)} failed to compile: {partName}:\n{log.Trim()}")
{
}
}
@@ -263,7 +263,7 @@ namespace osu.Framework.Graphics.OpenGL.Shaders
public class ProgramLinkingFailedException : Exception
{
public ProgramLinkingFailedException(string programName, string log)
: base($"A {typeof(OpenGLShader)} failed to link: {programName}:\n{log.Trim()}")
: base($"A {typeof(GLShader)} failed to link: {programName}:\n{log.Trim()}")
{
}
}

View File

@@ -13,7 +13,7 @@ using osuTK.Graphics.ES30;
namespace osu.Framework.Graphics.OpenGL.Shaders
{
internal class OpenGLShaderPart : IShaderPart
internal class GLShaderPart : IShaderPart
{
internal const string SHADER_ATTRIBUTE_PATTERN = "^\\s*(?>attribute|in)\\s+(?:(?:lowp|mediump|highp)\\s+)?\\w+\\s+(\\w+)";
@@ -39,7 +39,7 @@ namespace osu.Framework.Graphics.OpenGL.Shaders
private readonly ShaderManager manager;
internal OpenGLShaderPart(IRenderer renderer, string name, byte[] data, ShaderType type, ShaderManager manager)
internal GLShaderPart(IRenderer renderer, string name, byte[] data, ShaderType type, ShaderManager manager)
{
this.renderer = renderer;
Name = name;
@@ -148,18 +148,18 @@ namespace osu.Framework.Graphics.OpenGL.Shaders
Compiled = compileResult == 1;
if (!Compiled)
throw new OpenGLShader.PartCompilationFailedException(Name, GL.GetShaderInfoLog(this));
throw new GLShader.PartCompilationFailedException(Name, GL.GetShaderInfoLog(this));
return Compiled;
}
public static implicit operator int(OpenGLShaderPart program) => program.partID;
public static implicit operator int(GLShaderPart program) => program.partID;
#region IDisposable Support
protected internal bool IsDisposed { get; private set; }
~OpenGLShaderPart()
~GLShaderPart()
{
renderer.ScheduleDisposal(s => s.Dispose(false), this);
}

View File

@@ -19,7 +19,7 @@ namespace osu.Framework.Graphics.OpenGL.Textures
{
internal class TextureGL : INativeTexture
{
protected readonly OpenGLRenderer Renderer;
protected readonly GLRenderer Renderer;
private readonly Queue<ITextureUpload> uploadQueue = new Queue<ITextureUpload>();
IRenderer INativeTexture.Renderer => Renderer;
@@ -61,7 +61,7 @@ namespace osu.Framework.Graphics.OpenGL.Textures
/// <param name="manualMipmaps">Whether manual mipmaps will be uploaded to the texture. If false, the texture will compute mipmaps automatically.</param>
/// <param name="filteringMode">The filtering mode.</param>
/// <param name="initialisationColour">The colour to initialise texture levels with (in the case of sub region initial uploads).</param>
public TextureGL(OpenGLRenderer renderer, int width, int height, bool manualMipmaps = false, All filteringMode = All.Linear, Rgba32 initialisationColour = default)
public TextureGL(GLRenderer renderer, int width, int height, bool manualMipmaps = false, All filteringMode = All.Linear, Rgba32 initialisationColour = default)
{
Renderer = renderer;
Width = width;

View File

@@ -16,7 +16,7 @@ namespace osu.Framework.Graphics.OpenGL.Textures
{
private int[] textureIds;
public VideoTextureGL(OpenGLRenderer renderer, int width, int height)
public VideoTextureGL(GLRenderer renderer, int width, int height)
: base(renderer, width, height, true)
{
}

View File

@@ -304,7 +304,7 @@ namespace osu.Framework.Graphics.Rendering
/// <summary>
/// Sets the current draw depth.
/// The draw depth is written to every vertex added to <see cref="IOpenGLVertexBuffer"/>s.
/// The draw depth is written to every vertex added to <see cref="IGLVertexBuffer"/>s.
/// </summary>
/// <param name="drawDepth">The draw depth.</param>
internal void SetDrawDepth(float drawDepth);

View File

@@ -218,10 +218,10 @@ namespace osu.Framework.Graphics.Rendering
}
/// <summary>
/// Draws a <see cref="OpenGLFrameBuffer"/> to the screen.
/// Draws a <see cref="GLFrameBuffer"/> to the screen.
/// </summary>
/// <param name="renderer">The renderer to draw the framebuffer with.</param>
/// <param name="frameBuffer">The <see cref="OpenGLFrameBuffer"/> to draw.</param>
/// <param name="frameBuffer">The <see cref="GLFrameBuffer"/> to draw.</param>
/// <param name="vertexQuad">The destination vertices.</param>
/// <param name="drawColour">The colour to draw the <paramref name="frameBuffer"/> with.</param>
/// <param name="vertexAction">An action that adds vertices to a <see cref="IVertexBatch{T}"/>.</param>

View File

@@ -13,7 +13,7 @@ namespace osu.Framework.Graphics.Shaders
{
internal static class GlobalPropertyManager
{
private static readonly HashSet<OpenGLShader> all_shaders = new HashSet<OpenGLShader>();
private static readonly HashSet<GLShader> all_shaders = new HashSet<GLShader>();
private static readonly IUniformMapping[] global_properties;
static GlobalPropertyManager()
@@ -54,7 +54,7 @@ namespace osu.Framework.Graphics.Shaders
((UniformMapping<T>)global_properties[(int)property]).UpdateValue(ref value);
}
public static void Register(OpenGLShader shader)
public static void Register(GLShader shader)
{
if (!all_shaders.Add(shader)) return;
@@ -68,7 +68,7 @@ namespace osu.Framework.Graphics.Shaders
}
}
public static void Unregister(OpenGLShader shader)
public static void Unregister(GLShader shader)
{
if (!all_shaders.Remove(shader)) return;

View File

@@ -325,7 +325,7 @@ namespace osu.Framework.Platform
};
}
protected virtual IRenderer CreateRenderer() => new OpenGLRenderer();
protected virtual IRenderer CreateRenderer() => new GLRenderer();
/// <summary>
/// Performs a GC collection and frees all framework caches.