gl_device.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. const BaseBindings& GetBaseBindings(std::size_t stage_index) const noexcept {
  21. return base_bindings[stage_index];
  22. }
  23. const BaseBindings& GetBaseBindings(Tegra::Engines::ShaderType shader_type) const noexcept {
  24. return GetBaseBindings(static_cast<std::size_t>(shader_type));
  25. }
  26. std::size_t GetUniformBufferAlignment() const {
  27. return uniform_buffer_alignment;
  28. }
  29. std::size_t GetShaderStorageBufferAlignment() const {
  30. return shader_storage_alignment;
  31. }
  32. u32 GetMaxVertexAttributes() const {
  33. return max_vertex_attributes;
  34. }
  35. u32 GetMaxVaryings() const {
  36. return max_varyings;
  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 HasVariableAoffi() const {
  51. return has_variable_aoffi;
  52. }
  53. bool HasComponentIndexingBug() const {
  54. return has_component_indexing_bug;
  55. }
  56. bool HasPreciseBug() const {
  57. return has_precise_bug;
  58. }
  59. bool HasBrokenCompute() const {
  60. return has_broken_compute;
  61. }
  62. bool HasFastBufferSubData() const {
  63. return has_fast_buffer_sub_data;
  64. }
  65. private:
  66. static bool TestVariableAoffi();
  67. static bool TestPreciseBug();
  68. std::array<BaseBindings, Tegra::Engines::MaxShaderTypes> base_bindings;
  69. std::size_t uniform_buffer_alignment{};
  70. std::size_t shader_storage_alignment{};
  71. u32 max_vertex_attributes{};
  72. u32 max_varyings{};
  73. bool has_warp_intrinsics{};
  74. bool has_shader_ballot{};
  75. bool has_vertex_viewport_layer{};
  76. bool has_image_load_formatted{};
  77. bool has_variable_aoffi{};
  78. bool has_component_indexing_bug{};
  79. bool has_precise_bug{};
  80. bool has_broken_compute{};
  81. bool has_fast_buffer_sub_data{};
  82. };
  83. } // namespace OpenGL