gl_device.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. class Device {
  10. public:
  11. struct BaseBindings {
  12. u32 uniform_buffer{};
  13. u32 shader_storage_buffer{};
  14. u32 sampler{};
  15. u32 image{};
  16. };
  17. explicit Device();
  18. explicit Device(std::nullptr_t);
  19. [[nodiscard]] std::string GetVendorName() const;
  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. size_t GetUniformBufferAlignment() const {
  30. return uniform_buffer_alignment;
  31. }
  32. 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. u32 GetMaxComputeSharedMemorySize() const {
  42. return max_compute_shared_memory_size;
  43. }
  44. bool HasWarpIntrinsics() const {
  45. return has_warp_intrinsics;
  46. }
  47. bool HasShaderBallot() const {
  48. return has_shader_ballot;
  49. }
  50. bool HasVertexViewportLayer() const {
  51. return has_vertex_viewport_layer;
  52. }
  53. bool HasImageLoadFormatted() const {
  54. return has_image_load_formatted;
  55. }
  56. bool HasTextureShadowLod() const {
  57. return has_texture_shadow_lod;
  58. }
  59. bool HasVertexBufferUnifiedMemory() const {
  60. return has_vertex_buffer_unified_memory;
  61. }
  62. bool HasASTC() const {
  63. return has_astc;
  64. }
  65. bool HasVariableAoffi() const {
  66. return has_variable_aoffi;
  67. }
  68. bool HasComponentIndexingBug() const {
  69. return has_component_indexing_bug;
  70. }
  71. bool HasPreciseBug() const {
  72. return has_precise_bug;
  73. }
  74. bool HasBrokenTextureViewFormats() const {
  75. return has_broken_texture_view_formats;
  76. }
  77. bool HasFastBufferSubData() const {
  78. return has_fast_buffer_sub_data;
  79. }
  80. bool HasNvViewportArray2() const {
  81. return has_nv_viewport_array2;
  82. }
  83. bool HasDebuggingToolAttached() const {
  84. return has_debugging_tool_attached;
  85. }
  86. bool UseAssemblyShaders() const {
  87. return use_assembly_shaders;
  88. }
  89. bool UseAsynchronousShaders() const {
  90. return use_asynchronous_shaders;
  91. }
  92. bool UseDriverCache() const {
  93. return use_driver_cache;
  94. }
  95. bool HasDepthBufferFloat() const {
  96. return has_depth_buffer_float;
  97. }
  98. private:
  99. static bool TestVariableAoffi();
  100. static bool TestPreciseBug();
  101. std::string vendor_name;
  102. std::array<u32, Tegra::Engines::MaxShaderTypes> max_uniform_buffers{};
  103. std::array<BaseBindings, Tegra::Engines::MaxShaderTypes> base_bindings{};
  104. size_t uniform_buffer_alignment{};
  105. size_t shader_storage_alignment{};
  106. u32 max_vertex_attributes{};
  107. u32 max_varyings{};
  108. u32 max_compute_shared_memory_size{};
  109. bool has_warp_intrinsics{};
  110. bool has_shader_ballot{};
  111. bool has_vertex_viewport_layer{};
  112. bool has_image_load_formatted{};
  113. bool has_texture_shadow_lod{};
  114. bool has_vertex_buffer_unified_memory{};
  115. bool has_astc{};
  116. bool has_variable_aoffi{};
  117. bool has_component_indexing_bug{};
  118. bool has_precise_bug{};
  119. bool has_broken_texture_view_formats{};
  120. bool has_fast_buffer_sub_data{};
  121. bool has_nv_viewport_array2{};
  122. bool has_debugging_tool_attached{};
  123. bool use_assembly_shaders{};
  124. bool use_asynchronous_shaders{};
  125. bool use_driver_cache{};
  126. bool has_depth_buffer_float{};
  127. };
  128. } // namespace OpenGL