CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/GPU/OpenGL/GLFeatures.h
Views: 1401
1
// This file will not pull in the OpenGL headers but will still let you
2
// access information about the features of the current GPU, for auto-config
3
// and similar purposes.
4
5
#pragma once
6
7
#include <string>
8
#include <cstdint>
9
10
// TODO: Replace with thin3d's vendor enum.
11
enum {
12
GPU_VENDOR_NVIDIA = 1,
13
GPU_VENDOR_AMD = 2,
14
GPU_VENDOR_INTEL = 3,
15
GPU_VENDOR_ARM = 4, // Mali
16
GPU_VENDOR_IMGTEC = 5, // PowerVR
17
GPU_VENDOR_QUALCOMM = 6, // Adreno
18
GPU_VENDOR_BROADCOM = 7, // Raspberry PI etc
19
GPU_VENDOR_VIVANTE = 8,
20
GPU_VENDOR_APPLE = 9,
21
GPU_VENDOR_MESA = 10,
22
GPU_VENDOR_UNKNOWN = 0,
23
};
24
25
// TODO: Move to Draw::Bugs
26
enum {
27
BUG_FBO_UNUSABLE = 1,
28
BUG_PVR_SHADER_PRECISION_BAD = 2,
29
BUG_PVR_SHADER_PRECISION_TERRIBLE = 4,
30
};
31
32
// Extensions to look at using:
33
// GL_NV_map_buffer_range (same as GL_ARB_map_buffer_range ?)
34
35
// WARNING: This gets memset-d - so no strings or other non-POD types please
36
// TODO: Rename this GLFeatures or something.
37
struct GLExtensions {
38
int ver[3];
39
int gpuVendor;
40
char model[128];
41
int modelNumber;
42
43
bool IsGLES;
44
bool IsCoreContext;
45
bool GLES3; // true if the full OpenGL ES 3.0 is supported
46
47
// OES
48
bool OES_depth24;
49
bool OES_packed_depth_stencil;
50
bool OES_depth_texture;
51
bool OES_texture_npot; // If this is set, can wrap non-pow-2 textures. Set on desktop.
52
bool OES_mapbuffer;
53
bool OES_vertex_array_object;
54
bool OES_copy_image;
55
bool OES_texture_float;
56
bool OES_texture_3D;
57
bool OES_texture_compression_astc;
58
59
// ARB
60
bool ARB_framebuffer_object;
61
bool ARB_pixel_buffer_object;
62
bool ARB_blend_func_extended; // dual source blending
63
bool EXT_blend_func_extended; // dual source blending (GLES, new 2015)
64
bool ARB_explicit_attrib_location;
65
bool ARB_shader_image_load_store;
66
bool ARB_shading_language_420pack;
67
bool ARB_conservative_depth;
68
bool ARB_copy_image;
69
bool ARB_vertex_array_object;
70
bool ARB_texture_float;
71
bool ARB_draw_instanced;
72
bool ARB_buffer_storage;
73
bool ARB_cull_distance;
74
bool ARB_depth_clamp;
75
bool ARB_uniform_buffer_object;
76
bool ARB_texture_non_power_of_two;
77
bool ARB_stencil_texturing;
78
bool ARB_shader_stencil_export;
79
bool ARB_texture_compression_bptc;
80
bool ARB_texture_compression_rgtc;
81
82
// KHR
83
bool KHR_texture_compression_astc_ldr;
84
85
// EXT
86
bool EXT_texture_compression_s3tc;
87
bool EXT_swap_control_tear;
88
bool EXT_discard_framebuffer;
89
bool EXT_unpack_subimage; // always supported on desktop and ES3
90
bool EXT_bgra;
91
bool EXT_shader_framebuffer_fetch;
92
bool EXT_gpu_shader4;
93
bool EXT_blend_minmax;
94
bool EXT_framebuffer_object;
95
bool EXT_copy_image;
96
bool EXT_texture_filter_anisotropic;
97
bool PBO_EXT;
98
bool EXT_draw_instanced;
99
bool EXT_buffer_storage;
100
bool EXT_clip_cull_distance;
101
bool EXT_depth_clamp;
102
103
// NV
104
bool NV_copy_image;
105
bool NV_framebuffer_blit;
106
bool NV_pixel_buffer_object; // GL_NV_pixel_buffer_object
107
108
// ARM
109
bool ARM_shader_framebuffer_fetch;
110
111
// APPLE
112
bool APPLE_clip_distance;
113
114
// EGL
115
bool EGL_NV_system_time;
116
bool EGL_NV_coverage_sample;
117
118
// Bugs
119
int bugs;
120
121
// Shader precision. Only fetched on ES for now.
122
int range[2][6][2]; // [vs,fs][lowf,mediumf,highf,lowi,mediumi,highi][min,max]
123
int precision[2][6]; // [vs,fs][lowf...]
124
125
int maxVertexTextureUnits;
126
127
bool supportsETC2;
128
bool supportsBC123;
129
bool supportsBC45;
130
bool supportsBC7;
131
bool supportsASTC;
132
133
// greater-or-equal than
134
bool VersionGEThan(int major, int minor, int sub = 0);
135
int GLSLVersion();
136
};
137
138
extern GLExtensions gl_extensions;
139
140
// Call this after filling out vendor etc to lookup the bugs etc.
141
// Only needs to be called once. Currently called by CheckGLExtensions().
142
void ProcessGPUFeatures();
143
144
extern std::string g_all_gl_extensions;
145
extern std::string g_all_egl_extensions;
146
147
// If this returns false, we're not gonna be able to use a GL context.
148
bool CheckGLExtensions();
149
150
void SetGLCoreContext(bool flag);
151
void ResetGLExtensions();
152
153
std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage);
154
155