-
Notifications
You must be signed in to change notification settings - Fork 1
/
GPUDecoder.cs
38 lines (33 loc) · 1.07 KB
/
GPUDecoder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using SlimDX.Direct3D11;
namespace VVVV.DX11.ImagePlayer
{
class GPUDecoder : IDecoder
{
ImageLoadInformation ilf;
Texture2D tex;
public Device Device { get; set; }
public Texture2DDescription Description { get; private set; }
public ShaderResourceView SRV { get; private set; }
public GPUDecoder()
{
ilf = ImageLoadInformation.FromDefaults();
ilf.BindFlags = BindFlags.ShaderResource;
ilf.CpuAccessFlags = CpuAccessFlags.None;
ilf.FirstMipLevel = 0;
ilf.MipLevels = 1;
ilf.Usage = ResourceUsage.Default;
}
public void Load(string filename, System.Threading.CancellationToken token)
{
tex = Texture2D.FromFile(Device, filename, ilf);
Description = tex.Description;
token.ThrowIfCancellationRequested();
SRV = new ShaderResourceView(Device, tex);
}
public void Dispose()
{
tex?.Dispose();
SRV?.Dispose();
}
}
}