aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-11-03 20:58:24 -0300
committerGitHub <noreply@github.com>2021-11-03 20:58:24 -0300
commitf78bcb80485419466fde56812425a53e22705765 (patch)
tree4e7674da6d1ace1be146d5f3b6dacaf94ed98bfc /Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs
parentf41687f4c1948e9e111afd70e979e98ea5de52fa (diff)
Clamp number of mipmap levels to avoid API errors due to invalid textures (#2808)
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs')
-rw-r--r--Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs16
1 files changed, 9 insertions, 7 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs b/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs
index ce4616e4..215446ec 100644
--- a/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs
+++ b/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs
@@ -50,12 +50,14 @@ namespace Ryujinx.Graphics.OpenGL.Image
internalFormat = (SizedInternalFormat)format.PixelInternalFormat;
}
+ int levels = Info.GetLevelsClamped();
+
switch (Info.Target)
{
case Target.Texture1D:
GL.TexStorage1D(
TextureTarget1d.Texture1D,
- Info.Levels,
+ levels,
internalFormat,
Info.Width);
break;
@@ -63,7 +65,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
case Target.Texture1DArray:
GL.TexStorage2D(
TextureTarget2d.Texture1DArray,
- Info.Levels,
+ levels,
internalFormat,
Info.Width,
Info.Height);
@@ -72,7 +74,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
case Target.Texture2D:
GL.TexStorage2D(
TextureTarget2d.Texture2D,
- Info.Levels,
+ levels,
internalFormat,
Info.Width,
Info.Height);
@@ -81,7 +83,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
case Target.Texture2DArray:
GL.TexStorage3D(
TextureTarget3d.Texture2DArray,
- Info.Levels,
+ levels,
internalFormat,
Info.Width,
Info.Height,
@@ -112,7 +114,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
case Target.Texture3D:
GL.TexStorage3D(
TextureTarget3d.Texture3D,
- Info.Levels,
+ levels,
internalFormat,
Info.Width,
Info.Height,
@@ -122,7 +124,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
case Target.Cubemap:
GL.TexStorage2D(
TextureTarget2d.TextureCubeMap,
- Info.Levels,
+ levels,
internalFormat,
Info.Width,
Info.Height);
@@ -131,7 +133,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
case Target.CubemapArray:
GL.TexStorage3D(
(TextureTarget3d)All.TextureCubeMapArray,
- Info.Levels,
+ levels,
internalFormat,
Info.Width,
Info.Height,