TextureBindingInfo.cs 2.8 KB

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