ShaderConfig.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. namespace Ryujinx.Graphics.Shader.Translation
  3. {
  4. struct ShaderConfig
  5. {
  6. public ShaderStage Stage { get; }
  7. public OutputTopology OutputTopology { get; }
  8. public int MaxOutputVertices { get; }
  9. public int LocalMemorySize { get; }
  10. public ImapPixelType[] ImapTypes { get; }
  11. public OmapTarget[] OmapTargets { get; }
  12. public bool OmapSampleMask { get; }
  13. public bool OmapDepth { get; }
  14. public IGpuAccessor GpuAccessor { get; }
  15. public TranslationFlags Flags { get; }
  16. public ShaderConfig(IGpuAccessor gpuAccessor, TranslationFlags flags)
  17. {
  18. Stage = ShaderStage.Compute;
  19. OutputTopology = OutputTopology.PointList;
  20. MaxOutputVertices = 0;
  21. LocalMemorySize = 0;
  22. ImapTypes = null;
  23. OmapTargets = null;
  24. OmapSampleMask = false;
  25. OmapDepth = false;
  26. GpuAccessor = gpuAccessor;
  27. Flags = flags;
  28. }
  29. public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationFlags flags)
  30. {
  31. Stage = header.Stage;
  32. OutputTopology = header.OutputTopology;
  33. MaxOutputVertices = header.MaxOutputVertexCount;
  34. LocalMemorySize = header.ShaderLocalMemoryLowSize + header.ShaderLocalMemoryHighSize;
  35. ImapTypes = header.ImapTypes;
  36. OmapTargets = header.OmapTargets;
  37. OmapSampleMask = header.OmapSampleMask;
  38. OmapDepth = header.OmapDepth;
  39. GpuAccessor = gpuAccessor;
  40. Flags = flags;
  41. }
  42. public int GetDepthRegister()
  43. {
  44. int count = 0;
  45. for (int index = 0; index < OmapTargets.Length; index++)
  46. {
  47. for (int component = 0; component < 4; component++)
  48. {
  49. if (OmapTargets[index].ComponentEnabled(component))
  50. {
  51. count++;
  52. }
  53. }
  54. }
  55. // The depth register is always two registers after the last color output.
  56. return count + 1;
  57. }
  58. }
  59. }