Compare commits

...

2 Commits

Author SHA1 Message Date
Mary Guillemard
e59dba42ef Set PointSize in shader on OpenGL (#6292)
Previously we were only doing it for Vulkan, but it turns out that
not setting it when PROGRAM_POINT_SIZE is set is considered UB
on OpenGL Core.

Signed-off-by: Mary <mary@mary.zone>
2024-02-10 20:27:17 +01:00
Mary Guillemard
bd6937ae5c Make IOpenGLContext.HasContext context dependent (#6290)
This makes IOpenGLContext.HasContext not static and be implementable.

By doing this, we can support more than WGL and WGL.

This also allows the SDL2 headless version to run under Wayland.

Signed-off-by: Mary <mary@mary.zone>
2024-02-10 20:13:10 +01:00
7 changed files with 13 additions and 19 deletions

View File

@@ -29,6 +29,8 @@ namespace Ryujinx.Ava.UI.Renderer
_context.MakeCurrent(_window); _context.MakeCurrent(_window);
} }
public bool HasContext() => _context.IsCurrent;
public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext) public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext)
{ {
OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext); OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext);

View File

@@ -30,6 +30,8 @@ namespace Ryujinx.Graphics.OpenGL
_thread.Start(); _thread.Start();
} }
public bool HasContext() => _backgroundContext.HasContext();
private void Run() private void Run()
{ {
InBackground = true; InBackground = true;

View File

@@ -7,21 +7,6 @@ namespace Ryujinx.Graphics.OpenGL
{ {
void MakeCurrent(); void MakeCurrent();
// TODO: Support more APIs per platform. bool HasContext();
static bool HasContext()
{
if (OperatingSystem.IsWindows())
{
return WGLHelper.GetCurrentContext() != IntPtr.Zero;
}
else if (OperatingSystem.IsLinux())
{
return GLXHelper.GetCurrentContext() != IntPtr.Zero;
}
else
{
return false;
}
}
} }
} }

View File

@@ -248,7 +248,7 @@ namespace Ryujinx.Graphics.OpenGL
{ {
// alwaysBackground is ignored, since we cannot switch from the current context. // alwaysBackground is ignored, since we cannot switch from the current context.
if (IOpenGLContext.HasContext()) if (_window.BackgroundContext.HasContext())
{ {
action(); // We have a context already - use that (assuming it is the main one). action(); // We have a context already - use that (assuming it is the main one).
} }

View File

@@ -80,9 +80,10 @@ namespace Ryujinx.Graphics.Shader.Translation
return; return;
} }
if (TranslatorContext.Definitions.Stage == ShaderStage.Vertex && TranslatorContext.Options.TargetApi == TargetApi.Vulkan) // Vulkan requires the point size to be always written on the shader if the primitive topology is points.
// OpenGL requires the point size to be always written on the shader if PROGRAM_POINT_SIZE is set.
if (TranslatorContext.Definitions.Stage == ShaderStage.Vertex)
{ {
// Vulkan requires the point size to be always written on the shader if the primitive topology is points.
this.Store(StorageKind.Output, IoVariable.PointSize, null, ConstF(TranslatorContext.Definitions.PointSize)); this.Store(StorageKind.Output, IoVariable.PointSize, null, ConstF(TranslatorContext.Definitions.PointSize));
} }

View File

@@ -96,6 +96,8 @@ namespace Ryujinx.Headless.SDL2.OpenGL
} }
} }
public bool HasContext() => SDL_GL_GetCurrentContext() != IntPtr.Zero;
public void Dispose() public void Dispose()
{ {
SDL_GL_DeleteContext(_context); SDL_GL_DeleteContext(_context);

View File

@@ -29,6 +29,8 @@ namespace Ryujinx.Ui
_context.MakeCurrent(_window); _context.MakeCurrent(_window);
} }
public bool HasContext() => _context.IsCurrent;
public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext) public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext)
{ {
OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext); OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext);