MoonWorks/src/Graphics/TextureSlice.cs

34 lines
706 B
C#
Raw Normal View History

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