Skip to content

Commit

Permalink
Texture2dArrays should generate mipmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
deccer committed Nov 3, 2022
1 parent a5bd592 commit b204073
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/EngineKit/Graphics/TextureLibrary.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EngineKit.Mathematics;
Expand Down Expand Up @@ -68,7 +69,7 @@ public IReadOnlyCollection<ITexture> PrepareTextureArrays(
Label = $"TA_{textureIndex.Key}_{imageWidth}x{imageHeight}x{textureIndex.Value.Count}",
Size = new Int3(imageWidth, imageHeight, 1),
ArrayLayers = (uint)textureIndex.Value.Count,
MipLevels = 1,
MipLevels = 1 + (uint)MathF.Ceiling(MathF.Log2(MathF.Max(imageWidth, imageHeight))),
SampleCount = SampleCount.OneSample
};

Expand All @@ -90,13 +91,14 @@ public IReadOnlyCollection<ITexture> PrepareTextureArrays(
{
case Image<Rgb24> imageRgb24 when
imageRgb24.DangerousTryGetSinglePixelMemory(out var pixelSpan24):
texture.Update(textureUploadDescriptor, pixelSpan24.Pin());
texture!.Update(textureUploadDescriptor, pixelSpan24.Pin());
break;
case Image<Rgba32> imageRgba32 when
imageRgba32.DangerousTryGetSinglePixelMemory(out var pixelSpan32):
texture.Update(textureUploadDescriptor, pixelSpan32.Pin());
texture!.Update(textureUploadDescriptor, pixelSpan32.Pin());
break;
}
texture!.GenerateMipmaps();

if (!textureArrayIndices.TryGetValue(layer.ImageName, out var textureId))
{
Expand Down

0 comments on commit b204073

Please sign in to comment.