CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/GPU/OpenGL/GLFeatures.h
Views: 1401
// This file will not pull in the OpenGL headers but will still let you1// access information about the features of the current GPU, for auto-config2// and similar purposes.34#pragma once56#include <string>7#include <cstdint>89// TODO: Replace with thin3d's vendor enum.10enum {11GPU_VENDOR_NVIDIA = 1,12GPU_VENDOR_AMD = 2,13GPU_VENDOR_INTEL = 3,14GPU_VENDOR_ARM = 4, // Mali15GPU_VENDOR_IMGTEC = 5, // PowerVR16GPU_VENDOR_QUALCOMM = 6, // Adreno17GPU_VENDOR_BROADCOM = 7, // Raspberry PI etc18GPU_VENDOR_VIVANTE = 8,19GPU_VENDOR_APPLE = 9,20GPU_VENDOR_MESA = 10,21GPU_VENDOR_UNKNOWN = 0,22};2324// TODO: Move to Draw::Bugs25enum {26BUG_FBO_UNUSABLE = 1,27BUG_PVR_SHADER_PRECISION_BAD = 2,28BUG_PVR_SHADER_PRECISION_TERRIBLE = 4,29};3031// Extensions to look at using:32// GL_NV_map_buffer_range (same as GL_ARB_map_buffer_range ?)3334// WARNING: This gets memset-d - so no strings or other non-POD types please35// TODO: Rename this GLFeatures or something.36struct GLExtensions {37int ver[3];38int gpuVendor;39char model[128];40int modelNumber;4142bool IsGLES;43bool IsCoreContext;44bool GLES3; // true if the full OpenGL ES 3.0 is supported4546// OES47bool OES_depth24;48bool OES_packed_depth_stencil;49bool OES_depth_texture;50bool OES_texture_npot; // If this is set, can wrap non-pow-2 textures. Set on desktop.51bool OES_mapbuffer;52bool OES_vertex_array_object;53bool OES_copy_image;54bool OES_texture_float;55bool OES_texture_3D;56bool OES_texture_compression_astc;5758// ARB59bool ARB_framebuffer_object;60bool ARB_pixel_buffer_object;61bool ARB_blend_func_extended; // dual source blending62bool EXT_blend_func_extended; // dual source blending (GLES, new 2015)63bool ARB_explicit_attrib_location;64bool ARB_shader_image_load_store;65bool ARB_shading_language_420pack;66bool ARB_conservative_depth;67bool ARB_copy_image;68bool ARB_vertex_array_object;69bool ARB_texture_float;70bool ARB_draw_instanced;71bool ARB_buffer_storage;72bool ARB_cull_distance;73bool ARB_depth_clamp;74bool ARB_uniform_buffer_object;75bool ARB_texture_non_power_of_two;76bool ARB_stencil_texturing;77bool ARB_shader_stencil_export;78bool ARB_texture_compression_bptc;79bool ARB_texture_compression_rgtc;8081// KHR82bool KHR_texture_compression_astc_ldr;8384// EXT85bool EXT_texture_compression_s3tc;86bool EXT_swap_control_tear;87bool EXT_discard_framebuffer;88bool EXT_unpack_subimage; // always supported on desktop and ES389bool EXT_bgra;90bool EXT_shader_framebuffer_fetch;91bool EXT_gpu_shader4;92bool EXT_blend_minmax;93bool EXT_framebuffer_object;94bool EXT_copy_image;95bool EXT_texture_filter_anisotropic;96bool PBO_EXT;97bool EXT_draw_instanced;98bool EXT_buffer_storage;99bool EXT_clip_cull_distance;100bool EXT_depth_clamp;101102// NV103bool NV_copy_image;104bool NV_framebuffer_blit;105bool NV_pixel_buffer_object; // GL_NV_pixel_buffer_object106107// ARM108bool ARM_shader_framebuffer_fetch;109110// APPLE111bool APPLE_clip_distance;112113// EGL114bool EGL_NV_system_time;115bool EGL_NV_coverage_sample;116117// Bugs118int bugs;119120// Shader precision. Only fetched on ES for now.121int range[2][6][2]; // [vs,fs][lowf,mediumf,highf,lowi,mediumi,highi][min,max]122int precision[2][6]; // [vs,fs][lowf...]123124int maxVertexTextureUnits;125126bool supportsETC2;127bool supportsBC123;128bool supportsBC45;129bool supportsBC7;130bool supportsASTC;131132// greater-or-equal than133bool VersionGEThan(int major, int minor, int sub = 0);134int GLSLVersion();135};136137extern GLExtensions gl_extensions;138139// Call this after filling out vendor etc to lookup the bugs etc.140// Only needs to be called once. Currently called by CheckGLExtensions().141void ProcessGPUFeatures();142143extern std::string g_all_gl_extensions;144extern std::string g_all_egl_extensions;145146// If this returns false, we're not gonna be able to use a GL context.147bool CheckGLExtensions();148149void SetGLCoreContext(bool flag);150void ResetGLExtensions();151152std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage);153154155