2021-01-20 03:33:27 +00:00
|
|
|
|
using RefreshCS;
|
|
|
|
|
|
|
|
|
|
namespace MoonWorks.Graphics
|
|
|
|
|
{
|
2022-02-23 05:14:32 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A texture slice specifies a subregion of a texture.
|
|
|
|
|
/// Many operations can use texture slices in place of textures for the sake of convenience.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public struct TextureSlice
|
|
|
|
|
{
|
2024-02-23 08:06:04 +00:00
|
|
|
|
public Texture Texture;
|
|
|
|
|
public uint MipLevel;
|
|
|
|
|
public uint BaseLayer;
|
|
|
|
|
public uint LayerCount;
|
|
|
|
|
public uint X;
|
|
|
|
|
public uint Y;
|
|
|
|
|
public uint Z;
|
|
|
|
|
public uint Width;
|
|
|
|
|
public uint Height;
|
|
|
|
|
public uint Depth;
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2024-02-23 08:06:04 +00:00
|
|
|
|
public uint Size => (Width * Height * Depth * LayerCount * Texture.BytesPerPixel(Texture.Format) / Texture.BlockSizeSquared(Texture.Format)) >> (int) MipLevel;
|
2024-01-16 06:19:59 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
public TextureSlice(Texture texture)
|
|
|
|
|
{
|
|
|
|
|
Texture = texture;
|
2024-02-23 08:06:04 +00:00
|
|
|
|
MipLevel = 0;
|
|
|
|
|
BaseLayer = 0;
|
|
|
|
|
LayerCount = (uint) (texture.IsCube ? 6 : 1);
|
|
|
|
|
X = 0;
|
|
|
|
|
Y = 0;
|
|
|
|
|
Z = 0;
|
|
|
|
|
Width = texture.Width;
|
|
|
|
|
Height = texture.Height;
|
|
|
|
|
Depth = texture.Depth;
|
2022-02-23 05:14:32 +00:00
|
|
|
|
}
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
public Refresh.TextureSlice ToRefreshTextureSlice()
|
|
|
|
|
{
|
|
|
|
|
Refresh.TextureSlice textureSlice = new Refresh.TextureSlice
|
|
|
|
|
{
|
|
|
|
|
texture = Texture.Handle,
|
2024-02-23 08:06:04 +00:00
|
|
|
|
mipLevel = MipLevel,
|
|
|
|
|
baseLayer = BaseLayer,
|
|
|
|
|
layerCount = LayerCount,
|
|
|
|
|
x = X,
|
|
|
|
|
y = Y,
|
|
|
|
|
z = Z,
|
|
|
|
|
w = Width,
|
|
|
|
|
h = Height,
|
|
|
|
|
d = Depth
|
2022-02-23 05:14:32 +00:00
|
|
|
|
};
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
return textureSlice;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-20 03:33:27 +00:00
|
|
|
|
}
|