gl_device.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <cstddef>
  5. #include "common/common_types.h"
  6. #include "core/frontend/emu_window.h"
  7. #include "shader_recompiler/stage.h"
  8. namespace Settings {
  9. enum class ShaderBackend : u32;
  10. };
  11. namespace OpenGL {
  12. class Device {
  13. public:
  14. explicit Device(Core::Frontend::EmuWindow& emu_window);
  15. [[nodiscard]] std::string GetVendorName() const;
  16. u64 GetCurrentDedicatedVideoMemory() const;
  17. u32 GetMaxUniformBuffers(Shader::Stage stage) const noexcept {
  18. return max_uniform_buffers[static_cast<size_t>(stage)];
  19. }
  20. size_t GetUniformBufferAlignment() const {
  21. return uniform_buffer_alignment;
  22. }
  23. size_t GetShaderStorageBufferAlignment() const {
  24. return shader_storage_alignment;
  25. }
  26. u32 GetMaxVertexAttributes() const {
  27. return max_vertex_attributes;
  28. }
  29. u32 GetMaxVaryings() const {
  30. return max_varyings;
  31. }
  32. u32 GetMaxComputeSharedMemorySize() const {
  33. return max_compute_shared_memory_size;
  34. }
  35. u32 GetMaxGLASMStorageBufferBlocks() const {
  36. return max_glasm_storage_buffer_blocks;
  37. }
  38. bool HasWarpIntrinsics() const {
  39. return has_warp_intrinsics;
  40. }
  41. bool HasShaderBallot() const {
  42. return has_shader_ballot;
  43. }
  44. bool HasVertexViewportLayer() const {
  45. return has_vertex_viewport_layer;
  46. }
  47. bool HasImageLoadFormatted() const {
  48. return has_image_load_formatted;
  49. }
  50. bool HasTextureShadowLod() const {
  51. return has_texture_shadow_lod;
  52. }
  53. bool HasVertexBufferUnifiedMemory() const {
  54. return has_vertex_buffer_unified_memory;
  55. }
  56. bool HasASTC() const {
  57. return has_astc;
  58. }
  59. bool HasVariableAoffi() const {
  60. return has_variable_aoffi;
  61. }
  62. bool HasComponentIndexingBug() const {
  63. return has_component_indexing_bug;
  64. }
  65. bool HasPreciseBug() const {
  66. return has_precise_bug;
  67. }
  68. bool HasBrokenTextureViewFormats() const {
  69. return has_broken_texture_view_formats;
  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 HasDerivativeControl() const {
  78. return has_derivative_control;
  79. }
  80. bool HasDebuggingToolAttached() const {
  81. return has_debugging_tool_attached;
  82. }
  83. bool UseAssemblyShaders() const {
  84. return use_assembly_shaders;
  85. }
  86. bool UseAsynchronousShaders() const {
  87. return use_asynchronous_shaders;
  88. }
  89. bool UseDriverCache() const {
  90. return use_driver_cache;
  91. }
  92. bool HasDepthBufferFloat() const {
  93. return has_depth_buffer_float;
  94. }
  95. bool HasGeometryShaderPassthrough() const {
  96. return has_geometry_shader_passthrough;
  97. }
  98. bool HasNvGpuShader5() const {
  99. return has_nv_gpu_shader_5;
  100. }
  101. bool HasShaderInt64() const {
  102. return has_shader_int64;
  103. }
  104. bool HasAmdShaderHalfFloat() const {
  105. return has_amd_shader_half_float;
  106. }
  107. bool HasSparseTexture2() const {
  108. return has_sparse_texture_2;
  109. }
  110. bool IsWarpSizePotentiallyLargerThanGuest() const {
  111. return warp_size_potentially_larger_than_guest;
  112. }
  113. bool NeedsFastmathOff() const {
  114. return need_fastmath_off;
  115. }
  116. bool HasCbufFtouBug() const {
  117. return has_cbuf_ftou_bug;
  118. }
  119. bool HasBoolRefBug() const {
  120. return has_bool_ref_bug;
  121. }
  122. Settings::ShaderBackend GetShaderBackend() const {
  123. return shader_backend;
  124. }
  125. bool IsAmd() const {
  126. return vendor_name == "ATI Technologies Inc.";
  127. }
  128. bool CanReportMemoryUsage() const {
  129. return can_report_memory;
  130. }
  131. bool StrictContextRequired() const {
  132. return strict_context_required;
  133. }
  134. private:
  135. static bool TestVariableAoffi();
  136. static bool TestPreciseBug();
  137. std::array<u32, Shader::MaxStageTypes> max_uniform_buffers{};
  138. size_t uniform_buffer_alignment{};
  139. size_t shader_storage_alignment{};
  140. u32 max_vertex_attributes{};
  141. u32 max_varyings{};
  142. u32 max_compute_shared_memory_size{};
  143. u32 max_glasm_storage_buffer_blocks{};
  144. Settings::ShaderBackend shader_backend{};
  145. bool has_warp_intrinsics{};
  146. bool has_shader_ballot{};
  147. bool has_vertex_viewport_layer{};
  148. bool has_image_load_formatted{};
  149. bool has_texture_shadow_lod{};
  150. bool has_vertex_buffer_unified_memory{};
  151. bool has_astc{};
  152. bool has_variable_aoffi{};
  153. bool has_component_indexing_bug{};
  154. bool has_precise_bug{};
  155. bool has_broken_texture_view_formats{};
  156. bool has_fast_buffer_sub_data{};
  157. bool has_nv_viewport_array2{};
  158. bool has_derivative_control{};
  159. bool has_debugging_tool_attached{};
  160. bool use_assembly_shaders{};
  161. bool use_asynchronous_shaders{};
  162. bool use_driver_cache{};
  163. bool has_depth_buffer_float{};
  164. bool has_geometry_shader_passthrough{};
  165. bool has_nv_gpu_shader_5{};
  166. bool has_shader_int64{};
  167. bool has_amd_shader_half_float{};
  168. bool has_sparse_texture_2{};
  169. bool warp_size_potentially_larger_than_guest{};
  170. bool need_fastmath_off{};
  171. bool has_cbuf_ftou_bug{};
  172. bool has_bool_ref_bug{};
  173. bool can_report_memory{};
  174. bool strict_context_required{};
  175. std::string vendor_name;
  176. };
  177. } // namespace OpenGL