TextureBindingInfo.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Ryujinx.Graphics.GAL;
  2. using Ryujinx.Graphics.Shader;
  3. namespace Ryujinx.Graphics.Gpu.Image
  4. {
  5. /// <summary>
  6. /// Texture binding information.
  7. /// This is used for textures that needs to be accessed from shaders.
  8. /// </summary>
  9. struct TextureBindingInfo
  10. {
  11. /// <summary>
  12. /// Shader sampler target type.
  13. /// </summary>
  14. public Target Target { get; }
  15. /// <summary>
  16. /// For images, indicates the format specified on the shader.
  17. /// </summary>
  18. public Format Format { get; }
  19. /// <summary>
  20. /// Shader texture host binding point.
  21. /// </summary>
  22. public int Binding { get; }
  23. /// <summary>
  24. /// Shader texture handle.
  25. /// This is an index into the texture constant buffer.
  26. /// </summary>
  27. public int Handle { get; }
  28. /// <summary>
  29. /// Indicates if the texture is a bindless texture.
  30. /// </summary>
  31. /// <remarks>
  32. /// For those textures, Handle is ignored.
  33. /// </remarks>
  34. public bool IsBindless { get; }
  35. /// <summary>
  36. /// Constant buffer slot with the bindless texture handle, for bindless texture.
  37. /// </summary>
  38. public int CbufSlot { get; }
  39. /// <summary>
  40. /// Constant buffer offset of the bindless texture handle, for bindless texture.
  41. /// </summary>
  42. public int CbufOffset { get; }
  43. /// <summary>
  44. /// Flags from the texture descriptor that indicate how the texture is used.
  45. /// </summary>
  46. public TextureUsageFlags Flags { get; }
  47. /// <summary>
  48. /// Constructs the texture binding information structure.
  49. /// </summary>
  50. /// <param name="target">The shader sampler target type</param>
  51. /// <param name="format">Format of the image as declared on the shader</param>
  52. /// <param name="binding">The shader texture binding point</param>
  53. /// <param name="handle">The shader texture handle (read index into the texture constant buffer)</param>
  54. /// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
  55. public TextureBindingInfo(Target target, Format format, int binding, int handle, TextureUsageFlags flags)
  56. {
  57. Target = target;
  58. Format = format;
  59. Binding = binding;
  60. Handle = handle;
  61. IsBindless = false;
  62. CbufSlot = 0;
  63. CbufOffset = 0;
  64. Flags = flags;
  65. }
  66. /// <summary>
  67. /// Constructs the texture binding information structure.
  68. /// </summary>
  69. /// <param name="target">The shader sampler target type</param>
  70. /// <param name="binding">The shader texture binding point</param>
  71. /// <param name="handle">The shader texture handle (read index into the texture constant buffer)</param>
  72. /// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
  73. public TextureBindingInfo(Target target, int binding, int handle, TextureUsageFlags flags) : this(target, (Format)0, binding, handle, flags)
  74. {
  75. }
  76. /// <summary>
  77. /// Constructs the bindless texture binding information structure.
  78. /// </summary>
  79. /// <param name="target">The shader sampler target type</param>
  80. /// <param name="binding">The shader texture binding point</param>
  81. /// <param name="cbufSlot">Constant buffer slot where the bindless texture handle is located</param>
  82. /// <param name="cbufOffset">Constant buffer offset of the bindless texture handle</param>
  83. /// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
  84. public TextureBindingInfo(Target target, int binding, int cbufSlot, int cbufOffset, TextureUsageFlags flags)
  85. {
  86. Target = target;
  87. Format = 0;
  88. Binding = binding;
  89. Handle = 0;
  90. IsBindless = true;
  91. CbufSlot = cbufSlot;
  92. CbufOffset = cbufOffset;
  93. Flags = flags;
  94. }
  95. }
  96. }