Skip to content

Commit

Permalink
Merge pull request #5655 from smoogipoo/opengl-core-renderer
Browse files Browse the repository at this point in the history
Add OpenGL Core renderer and use as default
  • Loading branch information
peppy authored Mar 10, 2023
2 parents 66d562f + 86c00bc commit 3aa9920
Show file tree
Hide file tree
Showing 90 changed files with 1,315 additions and 966 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Contains required properties for osu!framework projects. -->
<Project>
<PropertyGroup Label="C#">
<LangVersion>9.0</LangVersion>
<LangVersion>10.0</LangVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions osu-framework.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UsePatternMatching/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseStringInterpolation/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseWithExpressionToCopyTuple/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VariableCanBeMadeConst/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VirtualMemberCallInConstructor/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VirtualMemberNeverOverridden_002EGlobal/@EntryIndexedValue">HINT</s:String>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added osu.Framework.Android/x86/libveldrid-spirv.so
Binary file not shown.
12 changes: 6 additions & 6 deletions osu.Framework.SourceGeneration.Tests/AbstractGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ protected void GetTestSources(
out (string filename, string content)[] commonGenerated,
out (string filename, string content)[] generated)
{
string commonSourcesNamespace = $"{resources_namespace}.CommonSources";
string commonGeneratedNamespace = $"{resources_namespace}.CommonGenerated";
const string common_sources_namespace = $"{resources_namespace}.CommonSources";
const string common_generated_namespace = $"{resources_namespace}.CommonGenerated";
string sourcesNamespace = $"{resources_namespace}.{name}.Sources";
string generatedNamespace = $"{resources_namespace}.{name}.Generated";

Expand All @@ -64,11 +64,11 @@ protected void GetTestSources(
var commonGeneratedFiles = new List<(string filename, string content)>();
var generatedFiles = new List<(string filename, string content)>();

foreach (string? file in resourceNames.Where(n => n.StartsWith(commonSourcesNamespace, StringComparison.Ordinal)))
commonSourceFiles.Add((getFileNameFromResourceName(commonSourcesNamespace, file), readResourceStream(assembly, file)));
foreach (string? file in resourceNames.Where(n => n.StartsWith(common_sources_namespace, StringComparison.Ordinal)))
commonSourceFiles.Add((getFileNameFromResourceName(common_sources_namespace, file), readResourceStream(assembly, file)));

foreach (string? file in resourceNames.Where(n => n.StartsWith(commonGeneratedNamespace, StringComparison.Ordinal)))
commonGeneratedFiles.Add((getFileNameFromResourceName(commonGeneratedNamespace, file), readResourceStream(assembly, file)));
foreach (string? file in resourceNames.Where(n => n.StartsWith(common_generated_namespace, StringComparison.Ordinal)))
commonGeneratedFiles.Add((getFileNameFromResourceName(common_generated_namespace, file), readResourceStream(assembly, file)));

foreach (string? file in resourceNames.Where(n => n.StartsWith(sourcesNamespace, StringComparison.Ordinal)))
sourceFiles.Add((getFileNameFromResourceName(sourcesNamespace, file), readResourceStream(assembly, file)));
Expand Down
17 changes: 7 additions & 10 deletions osu.Framework.Tests/Graphics/ShaderRegexTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#nullable disable

using System.Text.RegularExpressions;
using NUnit.Framework;
using osu.Framework.Graphics.OpenGL.Shaders;

Expand All @@ -12,8 +11,6 @@ namespace osu.Framework.Tests.Graphics
[TestFixture]
public class ShaderRegexTest
{
private readonly Regex shaderAttributeRegex = new Regex(GLShaderPart.SHADER_ATTRIBUTE_PATTERN);

[Test]
public void TestComment()
{
Expand All @@ -24,42 +21,42 @@ public void TestComment()
[Test]
public void TestNonAttribute()
{
const string test_string = "varying vec3 name;";
const string test_string = "wangs vec3 name;";
performInvalidAttributeTest(test_string);
}

[Test]
public void TestValidAttribute()
{
const string test_string = "attribute lowp float name;";
const string test_string = "layout(location = 0) in lowp float name;";
performValidAttributeTest(test_string);
}

[Test]
public void TestSpacedAttribute()
{
const string test_string = " attribute float name ;";
const string test_string = " layout( location =0 )in float name ;";
performValidAttributeTest(test_string);
}

[Test]
public void TestNoPrecisionQualifier()
{
const string test_string = "attribute float name;";
const string test_string = "layout(location = 0) in float name;";
performValidAttributeTest(test_string);
}

private void performValidAttributeTest(string testString)
{
var match = shaderAttributeRegex.Match(testString);
var match = GLShaderPart.SHADER_INPUT_PATTERN.Match(testString);

Assert.IsTrue(match.Success);
Assert.AreEqual("name", match.Groups[1].Value.Trim());
Assert.AreEqual("name", match.Groups[3].Value.Trim());
}

private void performInvalidAttributeTest(string testString)
{
var match = shaderAttributeRegex.Match(testString);
var match = GLShaderPart.SHADER_INPUT_PATTERN.Match(testString);

Assert.IsFalse(match.Success);
}
Expand Down
2 changes: 0 additions & 2 deletions osu.Framework.Tests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// 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.

#nullable disable

using System;
using System.Linq;
using osu.Framework.Platform;
Expand Down
8 changes: 2 additions & 6 deletions osu.Framework.Tests/Shaders/TestSceneShaderDisposal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,17 @@ internal override IShader CreateShader(IRenderer renderer, string name, params I

private class TestGLShader : GLShader
{
private readonly GLRenderer renderer;

internal TestGLShader(GLRenderer renderer, string name, GLShaderPart[] parts)
: base(renderer, name, parts)
: base(renderer, name, parts, null)
{
this.renderer = renderer;
}

private protected override int CreateProgram() => 1337;

private protected override bool CompileInternal() => true;

private protected override void SetupUniforms()
public override void BindUniformBlock(string blockName, IUniformBuffer buffer)
{
Uniforms.Add("test", new Uniform<int>(renderer, this, "test", 1));
}

private protected override string GetProgramLog() => string.Empty;
Expand Down
143 changes: 0 additions & 143 deletions osu.Framework.Tests/Visual/Sprites/TestSceneTextureUnit.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private void clickOutsideStep()
});
}

private void addBoxStep(Action<Drawable> boxFunc, int actionCount) => addBoxStep(boxFunc, Enumerable.Repeat<Action>(() => { }, actionCount).ToArray());
private void addBoxStep(Action<Drawable> boxFunc, int actionCount) => addBoxStep(boxFunc, Enumerable.Repeat(() => { }, actionCount).ToArray());

private void addBoxStep(Action<Drawable> boxFunc, params Action[] actions)
{
Expand Down
1 change: 1 addition & 0 deletions osu.Framework.iOS.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<NativeReference Include="$(MSBuildThisFileDirectory)osu.Framework.iOS\runtimes\ios\native\libavutil.xcframework" Kind="Framework" SmartLink="false" ForceLoad="true" />
<NativeReference Include="$(MSBuildThisFileDirectory)osu.Framework.iOS\runtimes\ios\native\libswresample.xcframework" Kind="Framework" SmartLink="false" ForceLoad="true" />
<NativeReference Include="$(MSBuildThisFileDirectory)osu.Framework.iOS\runtimes\ios\native\libswscale.xcframework" Kind="Framework" SmartLink="false" ForceLoad="true" />
<NativeReference Include="$(MSBuildThisFileDirectory)osu.Framework.iOS\runtimes\ios\native\veldrid-spirv.xcframework" Kind="Framework" SmartLink="false" ForceLoad="true" />
</ItemGroup>
<!-- Veldrid references libraries which cannot be AOT'd on iOS, replace them with stub assemblies.
See: https://github.com/mellinoe/veldrid/issues/472#issuecomment-1356461410 -->
Expand Down
2 changes: 2 additions & 0 deletions osu.Framework.iOS/GameAppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using UIKit;
using Veldrid.SPIRV;

namespace osu.Framework.iOS
{
Expand All @@ -37,6 +38,7 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l
NativeLibrary.SetDllImportResolver(typeof(Bass).Assembly, (_, assembly, path) => NativeLibrary.Load("@rpath/bass.framework/bass", assembly, path));
NativeLibrary.SetDllImportResolver(typeof(BassFx).Assembly, (_, assembly, path) => NativeLibrary.Load("@rpath/bass_fx.framework/bass_fx", assembly, path));
NativeLibrary.SetDllImportResolver(typeof(BassMix).Assembly, (_, assembly, path) => NativeLibrary.Load("@rpath/bassmix.framework/bassmix", assembly, path));
NativeLibrary.SetDllImportResolver(typeof(SpirvCompilation).Assembly, (_, assembly, path) => NativeLibrary.Load("@rpath/veldrid-spirv.framework/veldrid-spirv", assembly, path));

Window = new UIWindow(UIScreen.MainScreen.Bounds);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>veldrid-spirv.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>veldrid-spirv.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
26 changes: 26 additions & 0 deletions osu.Framework/FrameworkEnvironment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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 System;
using osu.Framework.Platform;

namespace osu.Framework
{
public static class FrameworkEnvironment
{
public static ExecutionMode? StartupExecutionMode { get; }
public static bool NoTestTimeout { get; }
public static bool ForceTestGC { get; }
public static GraphicsSurfaceType? PreferredGraphicsSurface { get; }
public static string? PreferredGraphicsRenderer { get; }

static FrameworkEnvironment()
{
StartupExecutionMode = Enum.TryParse<ExecutionMode>(Environment.GetEnvironmentVariable("OSU_EXECUTION_MODE"), true, out var mode) ? mode : null;
NoTestTimeout = Environment.GetEnvironmentVariable("OSU_TESTS_NO_TIMEOUT") == "1";
ForceTestGC = Environment.GetEnvironmentVariable("OSU_TESTS_FORCED_GC") == "1";
PreferredGraphicsSurface = Enum.TryParse<GraphicsSurfaceType>(Environment.GetEnvironmentVariable("OSU_GRAPHICS_SURFACE"), true, out var surface) ? surface : null;
PreferredGraphicsRenderer = Environment.GetEnvironmentVariable("OSU_GRAPHICS_RENDERER")?.ToLowerInvariant();
}
}
}
Loading

0 comments on commit 3aa9920

Please sign in to comment.