Sampler.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Ryujinx.Graphics.GAL;
  2. using Ryujinx.Graphics.GAL.Color;
  3. using Ryujinx.Graphics.GAL.Sampler;
  4. using System;
  5. namespace Ryujinx.Graphics.Gpu.Image
  6. {
  7. class Sampler : IDisposable
  8. {
  9. public ISampler HostSampler { get; }
  10. public Sampler(GpuContext context, SamplerDescriptor descriptor)
  11. {
  12. MinFilter minFilter = descriptor.UnpackMinFilter();
  13. MagFilter magFilter = descriptor.UnpackMagFilter();
  14. AddressMode addressU = descriptor.UnpackAddressU();
  15. AddressMode addressV = descriptor.UnpackAddressV();
  16. AddressMode addressP = descriptor.UnpackAddressP();
  17. CompareMode compareMode = descriptor.UnpackCompareMode();
  18. CompareOp compareOp = descriptor.UnpackCompareOp();
  19. ColorF color = new ColorF(0, 0, 0, 0);
  20. float minLod = descriptor.UnpackMinLod();
  21. float maxLod = descriptor.UnpackMaxLod();
  22. float mipLodBias = descriptor.UnpackMipLodBias();
  23. float maxAnisotropy = descriptor.UnpackMaxAnisotropy();
  24. HostSampler = context.Renderer.CreateSampler(new SamplerCreateInfo(
  25. minFilter,
  26. magFilter,
  27. addressU,
  28. addressV,
  29. addressP,
  30. compareMode,
  31. compareOp,
  32. color,
  33. minLod,
  34. maxLod,
  35. mipLodBias,
  36. maxAnisotropy));
  37. }
  38. public void Dispose()
  39. {
  40. HostSampler.Dispose();
  41. }
  42. }
  43. }