shader_info.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. };
  27. enum class Interpolation {
  28. Smooth,
  29. Flat,
  30. NoPerspective,
  31. };
  32. struct InputVarying {
  33. Interpolation interpolation{Interpolation::Smooth};
  34. bool used{false};
  35. };
  36. struct TextureDescriptor {
  37. TextureType type;
  38. u32 cbuf_index;
  39. u32 cbuf_offset;
  40. u32 count;
  41. };
  42. using TextureDescriptors = boost::container::small_vector<TextureDescriptor, 12>;
  43. struct ConstantBufferDescriptor {
  44. u32 index;
  45. u32 count;
  46. };
  47. struct StorageBufferDescriptor {
  48. u32 cbuf_index;
  49. u32 cbuf_offset;
  50. u32 count;
  51. };
  52. struct Info {
  53. static constexpr size_t MAX_CBUFS{18};
  54. static constexpr size_t MAX_SSBOS{16};
  55. bool uses_workgroup_id{};
  56. bool uses_local_invocation_id{};
  57. bool uses_subgroup_invocation_id{};
  58. std::array<InputVarying, 32> input_generics{};
  59. bool loads_position{};
  60. bool loads_instance_id{};
  61. bool loads_vertex_id{};
  62. bool loads_front_face{};
  63. bool loads_point_coord{};
  64. std::array<bool, 8> stores_frag_color{};
  65. bool stores_frag_depth{};
  66. std::array<bool, 32> stores_generics{};
  67. bool stores_position{};
  68. bool stores_point_size{};
  69. bool uses_fp16{};
  70. bool uses_fp64{};
  71. bool uses_fp16_denorms_flush{};
  72. bool uses_fp16_denorms_preserve{};
  73. bool uses_fp32_denorms_flush{};
  74. bool uses_fp32_denorms_preserve{};
  75. bool uses_int8{};
  76. bool uses_int16{};
  77. bool uses_int64{};
  78. bool uses_image_1d{};
  79. bool uses_sampled_1d{};
  80. bool uses_sparse_residency{};
  81. bool uses_demote_to_helper_invocation{};
  82. bool uses_subgroup_vote{};
  83. bool uses_fswzadd{};
  84. IR::Type used_constant_buffer_types{};
  85. u32 constant_buffer_mask{};
  86. boost::container::static_vector<ConstantBufferDescriptor, MAX_CBUFS>
  87. constant_buffer_descriptors;
  88. boost::container::static_vector<StorageBufferDescriptor, MAX_SSBOS> storage_buffers_descriptors;
  89. TextureDescriptors texture_descriptors;
  90. };
  91. } // namespace Shader