shader_info.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include "common/common_types.h"
  7. #include "shader_recompiler/frontend/ir/type.h"
  8. #include <boost/container/small_vector.hpp>
  9. #include <boost/container/static_vector.hpp>
  10. namespace Shader {
  11. enum class TextureType : u32 {
  12. Color1D,
  13. ColorArray1D,
  14. Color2D,
  15. ColorArray2D,
  16. Color3D,
  17. ColorCube,
  18. ColorArrayCube,
  19. Shadow1D,
  20. ShadowArray1D,
  21. Shadow2D,
  22. ShadowArray2D,
  23. Shadow3D,
  24. ShadowCube,
  25. ShadowArrayCube,
  26. Buffer,
  27. };
  28. enum class Interpolation {
  29. Smooth,
  30. Flat,
  31. NoPerspective,
  32. };
  33. struct InputVarying {
  34. Interpolation interpolation{Interpolation::Smooth};
  35. bool used{false};
  36. };
  37. struct TextureDescriptor {
  38. TextureType type;
  39. u32 cbuf_index;
  40. u32 cbuf_offset;
  41. u32 count;
  42. };
  43. using TextureDescriptors = boost::container::small_vector<TextureDescriptor, 12>;
  44. struct TextureBufferDescriptor {
  45. u32 cbuf_index;
  46. u32 cbuf_offset;
  47. u32 count;
  48. };
  49. using TextureBufferDescriptors = boost::container::small_vector<TextureBufferDescriptor, 2>;
  50. struct ConstantBufferDescriptor {
  51. u32 index;
  52. u32 count;
  53. };
  54. struct StorageBufferDescriptor {
  55. u32 cbuf_index;
  56. u32 cbuf_offset;
  57. u32 count;
  58. bool is_written;
  59. };
  60. struct Info {
  61. static constexpr size_t MAX_CBUFS{18};
  62. static constexpr size_t MAX_SSBOS{16};
  63. bool uses_workgroup_id{};
  64. bool uses_local_invocation_id{};
  65. bool uses_subgroup_invocation_id{};
  66. std::array<InputVarying, 32> input_generics{};
  67. bool loads_position{};
  68. bool loads_instance_id{};
  69. bool loads_vertex_id{};
  70. bool loads_front_face{};
  71. bool loads_point_coord{};
  72. bool loads_indexed_attributes{};
  73. std::array<bool, 8> stores_frag_color{};
  74. bool stores_frag_depth{};
  75. std::array<bool, 32> stores_generics{};
  76. bool stores_position{};
  77. bool stores_point_size{};
  78. bool stores_clip_distance{};
  79. bool stores_viewport_index{};
  80. bool stores_indexed_attributes{};
  81. bool uses_fp16{};
  82. bool uses_fp64{};
  83. bool uses_fp16_denorms_flush{};
  84. bool uses_fp16_denorms_preserve{};
  85. bool uses_fp32_denorms_flush{};
  86. bool uses_fp32_denorms_preserve{};
  87. bool uses_int8{};
  88. bool uses_int16{};
  89. bool uses_int64{};
  90. bool uses_image_1d{};
  91. bool uses_sampled_1d{};
  92. bool uses_sparse_residency{};
  93. bool uses_demote_to_helper_invocation{};
  94. bool uses_subgroup_vote{};
  95. bool uses_subgroup_mask{};
  96. bool uses_fswzadd{};
  97. IR::Type used_constant_buffer_types{};
  98. u32 constant_buffer_mask{};
  99. boost::container::static_vector<ConstantBufferDescriptor, MAX_CBUFS>
  100. constant_buffer_descriptors;
  101. boost::container::static_vector<StorageBufferDescriptor, MAX_SSBOS> storage_buffers_descriptors;
  102. TextureBufferDescriptors texture_buffer_descriptors;
  103. TextureDescriptors texture_descriptors;
  104. };
  105. } // namespace Shader