using AcDream.App.Rendering.Wb; using Chorizite.Core.Render.Enums; using Silk.NET.OpenGL; namespace AcDream.App.Tests.Rendering.Wb; public sealed class TextureAtlasCapacityTests { [Theory] [InlineData(128, 128, 32)] [InlineData(256, 256, 24)] [InlineData(512, 512, 6)] [InlineData(1024, 1024, 1)] public void RgbaCapacityTargetsEightMiBIncludingMipChain( int width, int height, int expected) { Assert.Equal( expected, TextureAtlasManager.CalculateInitialCapacity(width, height, TextureFormat.RGBA8)); } [Fact] public void SmallCompressedLayersRemainCountCapped() { Assert.Equal( TextureAtlasManager.MaximumArrayLayers, TextureAtlasManager.CalculateInitialCapacity(32, 32, TextureFormat.DXT1)); } [Fact] public void DirectUploadAcceptsExactRgbaPayload() { ManagedGLTextureArray.ValidateUploadPayload( TextureFormat.RGBA8, 2, 2, 16, PixelFormat.Rgba, PixelType.UnsignedByte); } [Theory] [InlineData(15)] [InlineData(17)] public void DirectUploadRejectsNonExactPayloadLength(int bytes) { Assert.Throws(() => ManagedGLTextureArray.ValidateUploadPayload( TextureFormat.RGBA8, 2, 2, bytes, PixelFormat.Rgba, PixelType.UnsignedByte)); } [Fact] public void DirectUploadRejectsMismatchedTransferTuple() { Assert.Throws(() => ManagedGLTextureArray.ValidateUploadPayload( TextureFormat.RGBA8, 2, 2, 16, PixelFormat.Rgb, PixelType.UnsignedByte)); Assert.Throws(() => ManagedGLTextureArray.ValidateUploadPayload( TextureFormat.RGBA8, 2, 2, 16, PixelFormat.Rgba, PixelType.Float)); } [Fact] public void CompressedUploadRejectsUncompressedDescriptorOverride() { int bytes = ManagedGLTextureArray.CalculateExpectedDataSize(TextureFormat.DXT1, 4, 4); Assert.Throws(() => ManagedGLTextureArray.ValidateUploadPayload( TextureFormat.DXT1, 4, 4, bytes, PixelFormat.Rgba, PixelType.UnsignedByte)); } [Fact] public void RgbPayloadUsesTightlyPackedRows() { Assert.Equal(18, ManagedGLTextureArray.CalculateExpectedDataSize(TextureFormat.RGB8, 3, 2)); ManagedGLTextureArray.ValidateUploadPayload( TextureFormat.RGB8, 3, 2, 18, PixelFormat.Rgb, PixelType.UnsignedByte); } }