mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
Merge pull request #2106 from nyquillerium/texture-loop-fix
Fix unloadable textures causing findPosition to never end
This commit is contained in:
@@ -38,9 +38,9 @@ namespace osu.Framework.Graphics.OpenGL
|
||||
/// </summary>
|
||||
public static bool HasContext => GraphicsContext.CurrentContext != null;
|
||||
|
||||
public static int MaxTextureSize { get; private set; }
|
||||
public static int MaxTextureSize { get; private set; } = 4096; // default value is to allow roughly normal flow in cases we don't have a GL context, like headless CI.
|
||||
|
||||
private static readonly Scheduler reset_scheduler = new Scheduler(null); //force no thread set until we are actually on the draw thread.
|
||||
private static readonly Scheduler reset_scheduler = new Scheduler(null); // force no thread set until we are actually on the draw thread.
|
||||
|
||||
/// <summary>
|
||||
/// A queue from which a maximum of one operation is invoked per draw frame.
|
||||
|
||||
@@ -105,6 +105,12 @@ namespace osu.Framework.Graphics.Textures
|
||||
|
||||
internal TextureGL Add(int width, int height)
|
||||
{
|
||||
if (width > atlasWidth)
|
||||
throw new ArgumentOutOfRangeException(nameof(width), width, $"Must be less than this atlas' width ({atlasWidth}px).");
|
||||
|
||||
if (height > atlasHeight)
|
||||
throw new ArgumentOutOfRangeException(nameof(height), height, $"Must be less than this atlas' height ({atlasHeight}px).");
|
||||
|
||||
lock (textureRetrievalLock)
|
||||
{
|
||||
if (AtlasTexture == null)
|
||||
|
||||
@@ -6,6 +6,7 @@ using osu.Framework.Graphics.OpenGL.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Logging;
|
||||
using osuTK.Graphics.ES30;
|
||||
|
||||
namespace osu.Framework.Graphics.Textures
|
||||
@@ -70,7 +71,16 @@ namespace osu.Framework.Graphics.Textures
|
||||
{
|
||||
// refresh the texture if no longer available (may have been previously disposed).
|
||||
if (!textureCache.TryGetValue(name, out var tex) || tex?.Available == false)
|
||||
textureCache[name] = tex = getTexture(name);
|
||||
{
|
||||
try
|
||||
{
|
||||
textureCache[name] = tex = getTexture(name);
|
||||
}
|
||||
catch (TextureTooLargeForGLException)
|
||||
{
|
||||
Logger.Log($"Texture \"{name}\" exceeds the maximum size supported by this device ({GLWrapper.MaxTextureSize}px).", level: LogLevel.Error);
|
||||
}
|
||||
}
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
|
||||
|
||||
using System;
|
||||
|
||||
namespace osu.Framework.Graphics.Textures
|
||||
{
|
||||
public class TextureTooLargeForGLException : InvalidOperationException
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using osu.Framework.Graphics.OpenGL;
|
||||
using osu.Framework.Graphics.OpenGL.Buffers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osuTK.Graphics.ES30;
|
||||
@@ -51,6 +52,9 @@ namespace osu.Framework.Graphics.Textures
|
||||
public TextureUpload(Image<Rgba32> image)
|
||||
{
|
||||
this.image = image;
|
||||
|
||||
if (image.Width > GLWrapper.MaxTextureSize || image.Height > GLWrapper.MaxTextureSize)
|
||||
throw new TextureTooLargeForGLException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user