2013-10-25 10:57:26 +02:00
|
|
|
// This file will not pull in the OpenGL headers but will still let you
|
|
|
|
// access information about the features of the current GPU, for auto-config
|
|
|
|
// and similar purposes.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-09-20 12:22:01 -07:00
|
|
|
#include <string>
|
2023-04-05 00:20:14 +02:00
|
|
|
#include <cstdint>
|
2013-10-25 10:57:26 +02:00
|
|
|
|
2020-12-14 22:10:18 +01:00
|
|
|
// TODO: Replace with thin3d's vendor enum.
|
2013-10-25 10:57:26 +02:00
|
|
|
enum {
|
|
|
|
GPU_VENDOR_NVIDIA = 1,
|
|
|
|
GPU_VENDOR_AMD = 2,
|
|
|
|
GPU_VENDOR_INTEL = 3,
|
|
|
|
GPU_VENDOR_ARM = 4, // Mali
|
2020-10-04 23:24:14 +02:00
|
|
|
GPU_VENDOR_IMGTEC = 5, // PowerVR
|
|
|
|
GPU_VENDOR_QUALCOMM = 6, // Adreno
|
|
|
|
GPU_VENDOR_BROADCOM = 7, // Raspberry PI etc
|
2019-01-03 12:43:00 +01:00
|
|
|
GPU_VENDOR_VIVANTE = 8,
|
2020-12-14 22:10:18 +01:00
|
|
|
GPU_VENDOR_APPLE = 9,
|
2013-10-25 10:57:26 +02:00
|
|
|
GPU_VENDOR_UNKNOWN = 0,
|
|
|
|
};
|
|
|
|
|
2019-01-03 12:43:00 +01:00
|
|
|
// TODO: Move to Draw::Bugs
|
2013-10-25 10:57:26 +02:00
|
|
|
enum {
|
2014-12-15 01:12:28 +01:00
|
|
|
BUG_FBO_UNUSABLE = 1,
|
|
|
|
BUG_PVR_SHADER_PRECISION_BAD = 2,
|
|
|
|
BUG_PVR_SHADER_PRECISION_TERRIBLE = 4,
|
2013-10-25 10:57:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Extensions to look at using:
|
|
|
|
// GL_NV_map_buffer_range (same as GL_ARB_map_buffer_range ?)
|
|
|
|
|
2022-12-29 00:37:51 +01:00
|
|
|
// WARNING: This gets memset-d - so no strings or other non-POD types please
|
2013-10-25 10:57:26 +02:00
|
|
|
// TODO: Rename this GLFeatures or something.
|
|
|
|
struct GLExtensions {
|
|
|
|
int ver[3];
|
|
|
|
int gpuVendor;
|
2014-12-15 01:12:28 +01:00
|
|
|
char model[128];
|
2020-11-11 22:34:31 +01:00
|
|
|
int modelNumber;
|
2013-12-07 12:23:41 +01:00
|
|
|
|
2015-08-23 21:34:11 -07:00
|
|
|
bool IsGLES;
|
2015-12-14 21:12:50 -08:00
|
|
|
bool IsCoreContext;
|
2013-10-25 10:57:26 +02:00
|
|
|
bool GLES3; // true if the full OpenGL ES 3.0 is supported
|
2014-05-06 15:13:33 +08:00
|
|
|
|
|
|
|
// OES
|
2013-10-25 10:57:26 +02:00
|
|
|
bool OES_depth24;
|
|
|
|
bool OES_packed_depth_stencil;
|
|
|
|
bool OES_depth_texture;
|
2014-01-02 00:08:22 +01:00
|
|
|
bool OES_texture_npot; // If this is set, can wrap non-pow-2 textures. Set on desktop.
|
2014-05-06 15:13:33 +08:00
|
|
|
bool OES_mapbuffer;
|
|
|
|
bool OES_vertex_array_object;
|
2015-12-06 10:39:21 -08:00
|
|
|
bool OES_copy_image;
|
2017-01-31 23:11:40 +09:00
|
|
|
bool OES_texture_float;
|
2022-07-31 00:18:28 +02:00
|
|
|
bool OES_texture_3D;
|
2023-03-12 12:18:55 +01:00
|
|
|
bool OES_texture_compression_astc;
|
2014-05-06 15:13:33 +08:00
|
|
|
|
|
|
|
// ARB
|
2015-09-05 22:08:46 +02:00
|
|
|
bool ARB_framebuffer_object;
|
|
|
|
bool ARB_pixel_buffer_object;
|
2014-05-06 15:13:33 +08:00
|
|
|
bool ARB_blend_func_extended; // dual source blending
|
2015-09-05 19:57:52 +02:00
|
|
|
bool EXT_blend_func_extended; // dual source blending (GLES, new 2015)
|
2020-11-05 00:48:35 +01:00
|
|
|
bool ARB_explicit_attrib_location;
|
2014-05-06 15:13:33 +08:00
|
|
|
bool ARB_shader_image_load_store;
|
2019-02-22 06:34:37 +03:00
|
|
|
bool ARB_shading_language_420pack;
|
2015-08-27 19:28:10 +02:00
|
|
|
bool ARB_conservative_depth;
|
2015-12-06 10:39:21 -08:00
|
|
|
bool ARB_copy_image;
|
2015-12-13 09:25:22 -08:00
|
|
|
bool ARB_vertex_array_object;
|
2017-01-31 23:11:40 +09:00
|
|
|
bool ARB_texture_float;
|
2017-03-26 19:00:20 +09:00
|
|
|
bool ARB_draw_instanced;
|
2018-02-11 13:14:28 -08:00
|
|
|
bool ARB_buffer_storage;
|
2018-10-28 13:27:44 -07:00
|
|
|
bool ARB_cull_distance;
|
2020-10-31 10:41:49 +01:00
|
|
|
bool ARB_depth_clamp;
|
|
|
|
bool ARB_uniform_buffer_object;
|
2022-08-06 23:46:14 +02:00
|
|
|
bool ARB_texture_non_power_of_two;
|
2022-10-10 17:09:14 -07:00
|
|
|
bool ARB_stencil_texturing;
|
2022-11-24 18:48:46 -08:00
|
|
|
bool ARB_shader_stencil_export;
|
2023-03-12 12:18:55 +01:00
|
|
|
bool ARB_texture_compression_bptc;
|
|
|
|
bool ARB_texture_compression_rgtc;
|
|
|
|
|
|
|
|
// KHR
|
|
|
|
bool KHR_texture_compression_astc_ldr;
|
2014-05-06 15:13:33 +08:00
|
|
|
|
|
|
|
// EXT
|
2023-03-12 12:18:55 +01:00
|
|
|
bool EXT_texture_compression_s3tc;
|
2013-10-25 10:57:26 +02:00
|
|
|
bool EXT_swap_control_tear;
|
2014-05-06 15:13:33 +08:00
|
|
|
bool EXT_discard_framebuffer;
|
|
|
|
bool EXT_unpack_subimage; // always supported on desktop and ES3
|
|
|
|
bool EXT_bgra;
|
2013-10-25 10:57:26 +02:00
|
|
|
bool EXT_shader_framebuffer_fetch;
|
2014-09-04 00:38:13 -07:00
|
|
|
bool EXT_gpu_shader4;
|
2013-10-25 10:57:26 +02:00
|
|
|
bool EXT_blend_minmax;
|
2015-09-05 22:08:46 +02:00
|
|
|
bool EXT_framebuffer_object;
|
2015-12-06 10:39:21 -08:00
|
|
|
bool EXT_copy_image;
|
2017-03-03 13:58:27 +01:00
|
|
|
bool EXT_texture_filter_anisotropic;
|
2014-05-06 15:13:33 +08:00
|
|
|
bool PBO_EXT;
|
2017-03-26 19:00:20 +09:00
|
|
|
bool EXT_draw_instanced;
|
2018-02-11 13:14:28 -08:00
|
|
|
bool EXT_buffer_storage;
|
2018-10-28 13:27:44 -07:00
|
|
|
bool EXT_clip_cull_distance;
|
2022-10-09 23:19:31 -07:00
|
|
|
bool EXT_depth_clamp;
|
2014-05-06 15:13:33 +08:00
|
|
|
|
|
|
|
// NV
|
2013-10-25 10:57:26 +02:00
|
|
|
bool NV_copy_image;
|
2014-05-02 18:25:56 +08:00
|
|
|
bool NV_framebuffer_blit;
|
2015-09-05 22:08:46 +02:00
|
|
|
bool NV_pixel_buffer_object; // GL_NV_pixel_buffer_object
|
2013-10-25 10:57:26 +02:00
|
|
|
|
2015-03-07 16:09:17 -08:00
|
|
|
// ARM
|
|
|
|
bool ARM_shader_framebuffer_fetch;
|
|
|
|
|
2021-09-19 23:32:05 -07:00
|
|
|
// APPLE
|
|
|
|
bool APPLE_clip_distance;
|
|
|
|
|
2014-05-06 15:13:33 +08:00
|
|
|
// EGL
|
2013-10-25 10:57:26 +02:00
|
|
|
bool EGL_NV_system_time;
|
|
|
|
bool EGL_NV_coverage_sample;
|
|
|
|
|
|
|
|
// Bugs
|
|
|
|
int bugs;
|
2013-12-07 12:23:41 +01:00
|
|
|
|
2014-12-15 23:00:02 +01:00
|
|
|
// Shader precision. Only fetched on ES for now.
|
|
|
|
int range[2][6][2]; // [vs,fs][lowf,mediumf,highf,lowi,mediumi,highi][min,max]
|
2014-12-15 23:11:27 +01:00
|
|
|
int precision[2][6]; // [vs,fs][lowf...]
|
2014-12-15 23:00:02 +01:00
|
|
|
|
2018-01-20 00:05:59 +01:00
|
|
|
int maxVertexTextureUnits;
|
|
|
|
|
2023-03-12 12:18:55 +01:00
|
|
|
bool supportsETC2;
|
|
|
|
bool supportsBC123;
|
|
|
|
bool supportsBC45;
|
|
|
|
bool supportsBC7;
|
|
|
|
bool supportsASTC;
|
|
|
|
|
2013-12-07 12:23:41 +01:00
|
|
|
// greater-or-equal than
|
|
|
|
bool VersionGEThan(int major, int minor, int sub = 0);
|
2018-06-14 20:31:58 -07:00
|
|
|
int GLSLVersion();
|
2013-10-25 10:57:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern GLExtensions gl_extensions;
|
|
|
|
|
|
|
|
// Call this after filling out vendor etc to lookup the bugs etc.
|
2015-08-23 21:34:11 -07:00
|
|
|
// Only needs to be called once. Currently called by CheckGLExtensions().
|
2013-10-25 10:57:26 +02:00
|
|
|
void ProcessGPUFeatures();
|
|
|
|
|
2015-09-06 12:21:15 +02:00
|
|
|
extern std::string g_all_gl_extensions;
|
|
|
|
extern std::string g_all_egl_extensions;
|
|
|
|
|
2022-12-22 23:07:30 +01:00
|
|
|
// If this returns false, we're not gonna be able to use a GL context.
|
|
|
|
bool CheckGLExtensions();
|
|
|
|
|
2016-08-06 20:19:50 -07:00
|
|
|
void SetGLCoreContext(bool flag);
|
2020-05-09 12:20:42 -07:00
|
|
|
void ResetGLExtensions();
|
2017-09-20 12:22:01 -07:00
|
|
|
|
|
|
|
std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage);
|