Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/GPU/OpenGL/GLFeatures.h
5675 views
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
int maxTextureSize;
48
int maxClipPlanes;
49
50
// OES
51
bool OES_depth24;
52
bool OES_packed_depth_stencil;
53
bool OES_depth_texture;
54
bool OES_texture_npot; // If this is set, can wrap non-pow-2 textures. Set on desktop.
55
bool OES_mapbuffer;
56
bool OES_vertex_array_object;
57
bool OES_copy_image;
58
bool OES_texture_float;
59
bool OES_texture_3D;
60
bool OES_texture_compression_astc;
61
62
// ARB
63
bool ARB_framebuffer_object;
64
bool ARB_pixel_buffer_object;
65
bool ARB_blend_func_extended; // dual source blending
66
bool EXT_blend_func_extended; // dual source blending (GLES, new 2015)
67
bool ARB_explicit_attrib_location;
68
bool ARB_shader_image_load_store;
69
bool ARB_shading_language_420pack;
70
bool ARB_conservative_depth;
71
bool ARB_copy_image;
72
bool ARB_vertex_array_object;
73
bool ARB_texture_float;
74
bool ARB_draw_instanced;
75
bool ARB_buffer_storage;
76
bool ARB_cull_distance;
77
bool ARB_depth_clamp;
78
bool ARB_uniform_buffer_object;
79
bool ARB_texture_non_power_of_two;
80
bool ARB_stencil_texturing;
81
bool ARB_shader_stencil_export;
82
bool ARB_texture_compression_bptc;
83
bool ARB_texture_compression_rgtc;
84
85
// KHR
86
bool KHR_texture_compression_astc_ldr;
87
88
// EXT
89
bool EXT_texture_compression_s3tc;
90
bool EXT_swap_control_tear;
91
bool EXT_discard_framebuffer;
92
bool EXT_unpack_subimage; // always supported on desktop and ES3
93
bool EXT_bgra;
94
bool EXT_shader_framebuffer_fetch;
95
bool EXT_gpu_shader4;
96
bool EXT_blend_minmax;
97
bool EXT_framebuffer_object;
98
bool EXT_copy_image;
99
bool EXT_texture_filter_anisotropic;
100
bool PBO_EXT;
101
bool EXT_draw_instanced;
102
bool EXT_buffer_storage;
103
bool EXT_clip_cull_distance;
104
bool EXT_depth_clamp;
105
106
// NV
107
bool NV_copy_image;
108
bool NV_framebuffer_blit;
109
bool NV_pixel_buffer_object; // GL_NV_pixel_buffer_object
110
111
// ARM
112
bool ARM_shader_framebuffer_fetch;
113
114
// APPLE
115
bool APPLE_clip_distance;
116
117
// EGL
118
bool EGL_NV_system_time;
119
bool EGL_NV_coverage_sample;
120
121
// Bugs
122
int bugs;
123
124
// Shader precision. Only fetched on ES for now.
125
int range[2][6][2]; // [vs,fs][lowf,mediumf,highf,lowi,mediumi,highi][min,max]
126
int precision[2][6]; // [vs,fs][lowf...]
127
128
int maxVertexTextureUnits;
129
130
bool supportsETC2;
131
bool supportsBC123;
132
bool supportsBC45;
133
bool supportsBC7;
134
bool supportsASTC;
135
136
// greater-or-equal than
137
bool VersionGEThan(int major, int minor, int sub = 0);
138
int GLSLVersion();
139
};
140
141
extern GLExtensions gl_extensions;
142
143
// Call this after filling out vendor etc to lookup the bugs etc.
144
// Only needs to be called once. Currently called by CheckGLExtensions().
145
void ProcessGPUFeatures();
146
147
extern std::string g_all_gl_extensions;
148
extern std::string g_all_egl_extensions;
149
150
// If this returns false, we're not gonna be able to use a GL context.
151
bool CheckGLExtensions();
152
153
void SetGLCoreContext(bool flag);
154
void ResetGLExtensions();
155
156
std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage);
157
158