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 9 // TODO: Replace with thin3d's vendor enum. 10 enum { 11 GPU_VENDOR_NVIDIA = 1, 12 GPU_VENDOR_AMD = 2, 13 GPU_VENDOR_INTEL = 3, 14 GPU_VENDOR_ARM = 4, // Mali 15 GPU_VENDOR_IMGTEC = 5, // PowerVR 16 GPU_VENDOR_QUALCOMM = 6, // Adreno 17 GPU_VENDOR_BROADCOM = 7, // Raspberry PI etc 18 GPU_VENDOR_VIVANTE = 8, 19 GPU_VENDOR_APPLE = 9, 20 GPU_VENDOR_UNKNOWN = 0, 21 }; 22 23 // TODO: Move to Draw::Bugs 24 enum { 25 BUG_FBO_UNUSABLE = 1, 26 BUG_PVR_SHADER_PRECISION_BAD = 2, 27 BUG_PVR_SHADER_PRECISION_TERRIBLE = 4, 28 }; 29 30 // Extensions to look at using: 31 // GL_NV_map_buffer_range (same as GL_ARB_map_buffer_range ?) 32 33 // WARNING: This gets memset-d - so no strings please 34 // TODO: Rename this GLFeatures or something. 35 struct GLExtensions { 36 int ver[3]; 37 int gpuVendor; 38 char model[128]; 39 int modelNumber; 40 41 bool IsGLES; 42 bool IsCoreContext; 43 bool GLES3; // true if the full OpenGL ES 3.0 is supported 44 45 // OES 46 bool OES_depth24; 47 bool OES_packed_depth_stencil; 48 bool OES_depth_texture; 49 bool OES_texture_npot; // If this is set, can wrap non-pow-2 textures. Set on desktop. 50 bool OES_mapbuffer; 51 bool OES_vertex_array_object; 52 bool OES_copy_image; 53 bool OES_texture_float; 54 55 // ARB 56 bool ARB_framebuffer_object; 57 bool ARB_pixel_buffer_object; 58 bool ARB_blend_func_extended; // dual source blending 59 bool EXT_blend_func_extended; // dual source blending (GLES, new 2015) 60 bool ARB_explicit_attrib_location; 61 bool ARB_shader_image_load_store; 62 bool ARB_shading_language_420pack; 63 bool ARB_conservative_depth; 64 bool ARB_copy_image; 65 bool ARB_vertex_array_object; 66 bool ARB_texture_float; 67 bool ARB_draw_instanced; 68 bool ARB_buffer_storage; 69 bool ARB_cull_distance; 70 bool ARB_depth_clamp; 71 bool ARB_uniform_buffer_object; 72 73 // EXT 74 bool EXT_swap_control_tear; 75 bool EXT_discard_framebuffer; 76 bool EXT_unpack_subimage; // always supported on desktop and ES3 77 bool EXT_bgra; 78 bool EXT_shader_framebuffer_fetch; 79 bool EXT_gpu_shader4; 80 bool EXT_blend_minmax; 81 bool EXT_framebuffer_object; 82 bool EXT_copy_image; 83 bool EXT_texture_filter_anisotropic; 84 bool PBO_EXT; 85 bool EXT_draw_instanced; 86 bool EXT_buffer_storage; 87 bool EXT_clip_cull_distance; 88 89 // NV 90 bool NV_copy_image; 91 bool NV_framebuffer_blit; 92 bool NV_pixel_buffer_object; // GL_NV_pixel_buffer_object 93 94 // ARM 95 bool ARM_shader_framebuffer_fetch; 96 97 // EGL 98 bool EGL_NV_system_time; 99 bool EGL_NV_coverage_sample; 100 101 // Bugs 102 int bugs; 103 104 // Shader precision. Only fetched on ES for now. 105 int range[2][6][2]; // [vs,fs][lowf,mediumf,highf,lowi,mediumi,highi][min,max] 106 int precision[2][6]; // [vs,fs][lowf...] 107 108 int maxVertexTextureUnits; 109 110 // greater-or-equal than 111 bool VersionGEThan(int major, int minor, int sub = 0); 112 int GLSLVersion(); 113 }; 114 115 extern GLExtensions gl_extensions; 116 117 // Call this after filling out vendor etc to lookup the bugs etc. 118 // Only needs to be called once. Currently called by CheckGLExtensions(). 119 void ProcessGPUFeatures(); 120 121 extern std::string g_all_gl_extensions; 122 extern std::string g_all_egl_extensions; 123 124 void CheckGLExtensions(); 125 void SetGLCoreContext(bool flag); 126 void ResetGLExtensions(); 127 128 std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage); 129