gl_device.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <cstddef>
  6. #include "common/common_types.h"
  7. #include "video_core/engines/shader_type.h"
  8. namespace OpenGL {
  9. static constexpr u32 EmulationUniformBlockBinding = 0;
  10. class Device final {
  11. public:
  12. struct BaseBindings final {
  13. u32 uniform_buffer{};
  14. u32 shader_storage_buffer{};
  15. u32 sampler{};
  16. u32 image{};
  17. };
  18. explicit Device();
  19. explicit Device(std::nullptr_t);
  20. u32 GetMaxUniformBuffers(Tegra::Engines::ShaderType shader_type) const noexcept {
  21. return max_uniform_buffers[static_cast<std::size_t>(shader_type)];
  22. }
  23. const BaseBindings& GetBaseBindings(std::size_t stage_index) const noexcept {
  24. return base_bindings[stage_index];
  25. }
  26. const BaseBindings& GetBaseBindings(Tegra::Engines::ShaderType shader_type) const noexcept {
  27. return GetBaseBindings(static_cast<std::size_t>(shader_type));
  28. }
  29. std::size_t GetUniformBufferAlignment() const {
  30. return uniform_buffer_alignment;
  31. }
  32. std::size_t GetShaderStorageBufferAlignment() const {
  33. return shader_storage_alignment;
  34. }
  35. u32 GetMaxVertexAttributes() const {
  36. return max_vertex_attributes;
  37. }
  38. u32 GetMaxVaryings() const {
  39. return max_varyings;
  40. }
  41. bool HasWarpIntrinsics() const {
  42. return has_warp_intrinsics;
  43. }
  44. bool HasShaderBallot() const {
  45. return has_shader_ballot;
  46. }
  47. bool HasVertexViewportLayer() const {
  48. return has_vertex_viewport_layer;
  49. }
  50. bool HasImageLoadFormatted() const {
  51. return has_image_load_formatted;
  52. }
  53. bool HasTextureShadowLod() const {
  54. return has_texture_shadow_lod;
  55. }
  56. bool HasVertexBufferUnifiedMemory() const {
  57. return has_vertex_buffer_unified_memory;
  58. }
  59. bool HasASTC() const {
  60. return has_astc;
  61. }
  62. bool HasVariableAoffi() const {
  63. return has_variable_aoffi;
  64. }
  65. bool HasComponentIndexingBug() const {
  66. return has_component_indexing_bug;
  67. }
  68. bool HasPreciseBug() const {
  69. return has_precise_bug;
  70. }
  71. bool HasFastBufferSubData() const {
  72. return has_fast_buffer_sub_data;
  73. }
  74. bool HasNvViewportArray2() const {
  75. return has_nv_viewport_array2;
  76. }
  77. bool UseAssemblyShaders() const {
  78. return use_assembly_shaders;
  79. }
  80. bool UseAsynchronousShaders() const {
  81. return use_asynchronous_shaders;
  82. }
  83. private:
  84. static bool TestVariableAoffi();
  85. static bool TestPreciseBug();
  86. std::array<u32, Tegra::Engines::MaxShaderTypes> max_uniform_buffers{};
  87. std::array<BaseBindings, Tegra::Engines::MaxShaderTypes> base_bindings{};
  88. std::size_t uniform_buffer_alignment{};
  89. std::size_t shader_storage_alignment{};
  90. u32 max_vertex_attributes{};
  91. u32 max_varyings{};
  92. bool has_warp_intrinsics{};
  93. bool has_shader_ballot{};
  94. bool has_vertex_viewport_layer{};
  95. bool has_image_load_formatted{};
  96. bool has_texture_shadow_lod{};
  97. bool has_vertex_buffer_unified_memory{};
  98. bool has_astc{};
  99. bool has_variable_aoffi{};
  100. bool has_component_indexing_bug{};
  101. bool has_precise_bug{};
  102. bool has_fast_buffer_sub_data{};
  103. bool has_nv_viewport_array2{};
  104. bool use_assembly_shaders{};
  105. bool use_asynchronous_shaders{};
  106. };
  107. } // namespace OpenGL