Merge pull request #2106 from nyquillerium/texture-loop-fix

Fix unloadable textures causing findPosition to never end
This commit is contained in:
Dan Balasescu
2019-01-23 19:28:50 +09:00
committed by GitHub
5 changed files with 34 additions and 3 deletions

View File

@@ -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.

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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
{
}
}

View File

@@ -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>