MoonWorks/src/Graphics/TextureSlice.cs

32 lines
666 B
C#
Raw Normal View History

2024-06-05 19:34:24 +00:00
using RefreshCS;
2024-06-04 17:20:07 +00:00
namespace MoonWorks.Graphics;
2024-06-04 17:20:07 +00:00
/// <summary>
/// A texture slice specifies a subresource of a texture.
/// </summary>
public struct TextureSlice
{
2024-06-04 17:20:07 +00:00
public Texture Texture;
public uint MipLevel;
public uint Layer;
2024-06-04 17:20:07 +00:00
public uint Size => (Texture.Width * Texture.Height * Texture.Depth * Texture.BytesPerPixel(Texture.Format) / Texture.BlockSizeSquared(Texture.Format)) >> (int) MipLevel;
2024-06-04 17:20:07 +00:00
public TextureSlice(Texture texture)
{
Texture = texture;
MipLevel = 0;
Layer = 0;
}
2024-06-05 19:34:24 +00:00
public Refresh.TextureSlice ToRefresh()
2024-06-04 17:20:07 +00:00
{
2024-06-05 19:34:24 +00:00
return new Refresh.TextureSlice
2022-02-23 05:14:32 +00:00
{
2024-06-04 17:20:07 +00:00
Texture = Texture.Handle,
MipLevel = MipLevel,
Layer = Layer
};
2022-02-23 05:14:32 +00:00
}
}