TextureBindingInfo.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 handle.
  21. /// This is an index into the texture constant buffer.
  22. /// </summary>
  23. public int Handle { get; }
  24. /// <summary>
  25. /// Indicates if the texture is a bindless texture.
  26. /// </summary>
  27. /// <remarks>
  28. /// For those textures, Handle is ignored.
  29. /// </remarks>
  30. public bool IsBindless { get; }
  31. /// <summary>
  32. /// Constant buffer slot with the bindless texture handle, for bindless texture.
  33. /// </summary>
  34. public int CbufSlot { get; }
  35. /// <summary>
  36. /// Constant buffer offset of the bindless texture handle, for bindless texture.
  37. /// </summary>
  38. public int CbufOffset { get; }
  39. /// <summary>
  40. /// Flags from the texture descriptor that indicate how the texture is used.
  41. /// </summary>
  42. public TextureUsageFlags Flags { get; }
  43. /// <summary>
  44. /// Constructs the texture binding information structure.
  45. /// </summary>
  46. /// <param name="target">The shader sampler target type</param>
  47. /// <param name="format">Format of the image as declared on the shader</param>
  48. /// <param name="handle">The shader texture handle (read index into the texture constant buffer)</param>
  49. /// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
  50. public TextureBindingInfo(Target target, Format format, int handle, TextureUsageFlags flags)
  51. {
  52. Target = target;
  53. Format = format;
  54. Handle = handle;
  55. IsBindless = false;
  56. CbufSlot = 0;
  57. CbufOffset = 0;
  58. Flags = flags;
  59. }
  60. /// <summary>
  61. /// Constructs the texture binding information structure.
  62. /// </summary>
  63. /// <param name="target">The shader sampler target type</param>
  64. /// <param name="handle">The shader texture handle (read index into the texture constant buffer)</param>
  65. /// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
  66. public TextureBindingInfo(Target target, int handle, TextureUsageFlags flags) : this(target, (Format)0, handle, flags)
  67. {
  68. }
  69. /// <summary>
  70. /// Constructs the bindless texture binding information structure.
  71. /// </summary>
  72. /// <param name="target">The shader sampler target type</param>
  73. /// <param name="cbufSlot">Constant buffer slot where the bindless texture handle is located</param>
  74. /// <param name="cbufOffset">Constant buffer offset of the bindless texture handle</param>
  75. /// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
  76. public TextureBindingInfo(Target target, int cbufSlot, int cbufOffset, TextureUsageFlags flags)
  77. {
  78. Target = target;
  79. Format = 0;
  80. Handle = 0;
  81. IsBindless = true;
  82. CbufSlot = cbufSlot;
  83. CbufOffset = cbufOffset;
  84. Flags = flags;
  85. }
  86. }
  87. }