mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl: remove boilerplate of extension check
* Use GLExtension::Has in cold path * Throw error at first error * Remove aniso check, all hardware support it. Bonus add GL4.6 extension support * Remove viewport array check. We replace the function pointer anyway
This commit is contained in:
parent
86a10969f3
commit
6282c3d263
|
@ -409,11 +409,9 @@ void GSdxApp::Init()
|
|||
m_default_configuration["override_GL_ARB_shader_storage_buffer_object"] = "-1";
|
||||
m_default_configuration["override_GL_ARB_sparse_texture"] = "-1";
|
||||
m_default_configuration["override_GL_ARB_sparse_texture2"] = "-1";
|
||||
m_default_configuration["override_GL_ARB_viewport_array"] = "-1";
|
||||
m_default_configuration["override_GL_ARB_texture_view"] = "-1";
|
||||
m_default_configuration["override_GL_ARB_vertex_attrib_binding"] = "-1";
|
||||
m_default_configuration["override_GL_ARB_texture_barrier"] = "-1";
|
||||
m_default_configuration["override_GL_EXT_texture_filter_anisotropic"] = "-1";
|
||||
m_default_configuration["paltex"] = "0";
|
||||
m_default_configuration["png_compression_level"] = std::to_string(Z_BEST_SPEED);
|
||||
m_default_configuration["preload_frame_with_gs_data"] = "0";
|
||||
|
|
|
@ -149,24 +149,16 @@ namespace GLLoader {
|
|||
bool buggy_sso_dual_src = false;
|
||||
|
||||
bool found_geometry_shader = true; // we require GL3.3 so geometry must be supported by default
|
||||
bool found_GL_EXT_texture_filter_anisotropic = false;
|
||||
bool found_GL_ARB_clear_texture = false;
|
||||
bool found_GL_ARB_get_texture_sub_image = false; // Not yet used
|
||||
// DX11 GPU
|
||||
bool found_GL_ARB_gpu_shader5 = false; // Require IvyBridge
|
||||
bool found_GL_ARB_shader_image_load_store = false; // Intel IB. Nvidia/AMD miss Mesa implementation.
|
||||
bool found_GL_ARB_viewport_array = false; // Intel IB. AMD/NVIDIA DX10
|
||||
bool found_GL_ARB_shader_storage_buffer_object = false;
|
||||
bool found_GL_ARB_sparse_texture = false;
|
||||
bool found_GL_ARB_sparse_texture2 = false;
|
||||
bool found_GL_ARB_compute_shader = false;
|
||||
bool found_GL_ARB_texture_view = false; // maybe older gpu can support it ?
|
||||
// Bonus to monitor the VRAM
|
||||
bool found_GL_NVX_gpu_memory_info = false;
|
||||
|
||||
// Mandatory in the future
|
||||
bool found_GL_ARB_direct_state_access = false;
|
||||
bool found_GL_ARB_texture_barrier = false;
|
||||
bool found_GL_ARB_multi_bind = false;
|
||||
bool found_GL_ARB_vertex_attrib_binding = false;
|
||||
|
||||
|
@ -174,18 +166,19 @@ namespace GLLoader {
|
|||
bool found_compatible_GL_ARB_sparse_texture2 = false;
|
||||
bool found_compatible_sparse_depth = false;
|
||||
|
||||
static bool mandatory(const std::string& ext)
|
||||
static void mandatory(const std::string& ext)
|
||||
{
|
||||
bool found = GLExtension::Has(ext);
|
||||
if (!found)
|
||||
if (!GLExtension::Has(ext)) {
|
||||
fprintf(stderr, "ERROR: %s is NOT SUPPORTED\n", ext.c_str());
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
return found;
|
||||
return;
|
||||
}
|
||||
|
||||
static bool optional(bool& found, const std::string& name)
|
||||
static bool optional(const std::string& name)
|
||||
{
|
||||
found = GLExtension::Has(name);
|
||||
bool found = GLExtension::Has(name);
|
||||
|
||||
if (!found) {
|
||||
fprintf_once(stdout, "INFO: %s is NOT SUPPORTED\n", name.c_str());
|
||||
|
@ -202,15 +195,15 @@ namespace GLLoader {
|
|||
GLExtension::Set(name);
|
||||
}
|
||||
|
||||
return true;
|
||||
return found;
|
||||
}
|
||||
|
||||
bool check_gl_version(int major, int minor)
|
||||
void check_gl_version(int major, int minor)
|
||||
{
|
||||
const GLubyte* s = glGetString(GL_VERSION);
|
||||
if (s == NULL) {
|
||||
fprintf(stderr, "Error: GLLoader failed to get GL version\n");
|
||||
return false;
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
GLuint v = 1;
|
||||
while (s[v] != '\0' && s[v-1] != ' ') v++;
|
||||
|
@ -258,13 +251,11 @@ namespace GLLoader {
|
|||
glGetIntegerv(GL_MINOR_VERSION, &minor_gl);
|
||||
if ( (major_gl < major) || ( major_gl == major && minor_gl < minor ) ) {
|
||||
fprintf(stderr, "OpenGL %d.%d is not supported. Only OpenGL %d.%d\n was found", major, minor, major_gl, minor_gl);
|
||||
return false;
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool check_gl_supported_extension()
|
||||
void check_gl_supported_extension()
|
||||
{
|
||||
int max_ext = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);
|
||||
|
@ -277,53 +268,48 @@ namespace GLLoader {
|
|||
}
|
||||
}
|
||||
|
||||
bool status = true;
|
||||
|
||||
// Mandatory for both renderer
|
||||
{
|
||||
// GL4.1
|
||||
status &= mandatory("GL_ARB_separate_shader_objects");
|
||||
mandatory("GL_ARB_separate_shader_objects");
|
||||
// GL4.2
|
||||
status &= mandatory("GL_ARB_shading_language_420pack");
|
||||
status &= mandatory("GL_ARB_texture_storage");
|
||||
mandatory("GL_ARB_shading_language_420pack");
|
||||
mandatory("GL_ARB_texture_storage");
|
||||
// GL4.3
|
||||
status &= mandatory("GL_KHR_debug");
|
||||
mandatory("GL_KHR_debug");
|
||||
// GL4.4
|
||||
status &= mandatory("GL_ARB_buffer_storage");
|
||||
mandatory("GL_ARB_buffer_storage");
|
||||
}
|
||||
|
||||
// Only for HW renderer
|
||||
if (theApp.GetCurrentRendererType() == GSRendererType::OGL_HW) {
|
||||
status &= mandatory("GL_ARB_copy_image");
|
||||
status &= mandatory("GL_ARB_clip_control");
|
||||
mandatory("GL_ARB_copy_image");
|
||||
mandatory("GL_ARB_clip_control");
|
||||
}
|
||||
|
||||
// Extra
|
||||
{
|
||||
// Bonus
|
||||
status &= optional(found_GL_EXT_texture_filter_anisotropic, "GL_EXT_texture_filter_anisotropic"); // ARB extension in 4.6
|
||||
status &= optional(found_GL_ARB_sparse_texture, "GL_ARB_sparse_texture");
|
||||
status &= optional(found_GL_ARB_sparse_texture2, "GL_ARB_sparse_texture2");
|
||||
optional("GL_ARB_sparse_texture");
|
||||
optional("GL_ARB_sparse_texture2");
|
||||
// GL4.0
|
||||
status &= optional(found_GL_ARB_gpu_shader5, "GL_ARB_gpu_shader5");
|
||||
// GL4.1
|
||||
status &= optional(found_GL_ARB_viewport_array, "GL_ARB_viewport_array");
|
||||
found_GL_ARB_gpu_shader5 = optional("GL_ARB_gpu_shader5");
|
||||
// GL4.2
|
||||
status &= optional(found_GL_ARB_shader_image_load_store, "GL_ARB_shader_image_load_store");
|
||||
found_GL_ARB_shader_image_load_store = optional("GL_ARB_shader_image_load_store");
|
||||
// GL4.3
|
||||
status &= optional(found_GL_ARB_compute_shader, "GL_ARB_compute_shader");
|
||||
status &= optional(found_GL_ARB_shader_storage_buffer_object, "GL_ARB_shader_storage_buffer_object");
|
||||
status &= optional(found_GL_ARB_texture_view, "GL_ARB_texture_view");
|
||||
status &= optional(found_GL_ARB_vertex_attrib_binding, "GL_ARB_vertex_attrib_binding");
|
||||
found_GL_ARB_compute_shader = optional("GL_ARB_compute_shader");
|
||||
found_GL_ARB_shader_storage_buffer_object = optional("GL_ARB_shader_storage_buffer_object");
|
||||
found_GL_ARB_texture_view = optional("GL_ARB_texture_view");
|
||||
found_GL_ARB_vertex_attrib_binding = optional("GL_ARB_vertex_attrib_binding");
|
||||
// GL4.4
|
||||
status &= optional(found_GL_ARB_clear_texture,"GL_ARB_clear_texture");
|
||||
status &= optional(found_GL_ARB_multi_bind,"GL_ARB_multi_bind");
|
||||
found_GL_ARB_clear_texture = optional("GL_ARB_clear_texture");
|
||||
found_GL_ARB_multi_bind = optional("GL_ARB_multi_bind");
|
||||
// GL4.5
|
||||
status &= optional(found_GL_ARB_direct_state_access, "GL_ARB_direct_state_access");
|
||||
optional("GL_ARB_direct_state_access");
|
||||
// Mandatory for the advance HW renderer effect. Unfortunately Mesa LLVMPIPE/SWR renderers doesn't support this extension.
|
||||
// Rendering might be corrupted but it could be good enough for test/virtual machine.
|
||||
status &= optional(found_GL_ARB_texture_barrier, "GL_ARB_texture_barrier");
|
||||
status &= optional(found_GL_ARB_get_texture_sub_image, "GL_ARB_get_texture_sub_image");
|
||||
optional("GL_ARB_texture_barrier");
|
||||
found_GL_ARB_get_texture_sub_image = optional("GL_ARB_get_texture_sub_image");
|
||||
}
|
||||
|
||||
if (vendor_id_amd) {
|
||||
|
@ -332,32 +318,30 @@ namespace GLLoader {
|
|||
"https://github.com/PCSX2/pcsx2/wiki/OpenGL-and-AMD-GPUs---All-you-need-to-know\n");
|
||||
}
|
||||
|
||||
if (vendor_id_intel && !found_GL_ARB_texture_barrier && !found_GL_ARB_direct_state_access) {
|
||||
if (vendor_id_intel && !GLExtension::Has("GL_ARB_texture_barrier") && !GLExtension::Has("GL_ARB_direct_state_access")) {
|
||||
// Assume that driver support is good when texture barrier and DSA is supported, disable the log then.
|
||||
fprintf_once(stderr, "The OpenGL renderer is inefficient on Intel GPUs due to an inefficient driver.\n"
|
||||
"Check out the link below for further information.\n"
|
||||
"https://github.com/PCSX2/pcsx2/wiki/OpenGL-and-Intel-GPUs-All-you-need-to-know\n");
|
||||
}
|
||||
|
||||
if (!found_GL_ARB_viewport_array) {
|
||||
if (!GLExtension::Has("GL_ARB_viewport_array")) {
|
||||
glScissorIndexed = ReplaceGL::ScissorIndexed;
|
||||
glViewportIndexedf = ReplaceGL::ViewportIndexedf;
|
||||
fprintf_once(stderr, "GL_ARB_viewport_array is not supported! Function pointer will be replaced\n");
|
||||
}
|
||||
|
||||
if (!found_GL_ARB_texture_barrier) {
|
||||
if (!GLExtension::Has("GL_ARB_texture_barrier")) {
|
||||
glTextureBarrier = ReplaceGL::TextureBarrier;
|
||||
fprintf_once(stderr, "GL_ARB_texture_barrier is not supported! Blending emulation will not be supported\n");
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Thank you Intel for not providing support of basic features on your IGPUs.
|
||||
if (!found_GL_ARB_direct_state_access) {
|
||||
if (!GLExtension::Has("GL_ARB_direct_state_access")) {
|
||||
Emulate_DSA::Init();
|
||||
}
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool is_sparse2_compatible(const char* name, GLenum internal_fmt, int x_max, int y_max)
|
||||
|
@ -418,11 +402,9 @@ namespace GLLoader {
|
|||
|
||||
void check_gl_requirements()
|
||||
{
|
||||
if (!GLLoader::check_gl_version(3, 3))
|
||||
throw GSDXRecoverableError();
|
||||
check_gl_version(3, 3);
|
||||
|
||||
if (!GLLoader::check_gl_supported_extension())
|
||||
throw GSDXRecoverableError();
|
||||
check_gl_supported_extension();
|
||||
|
||||
// Bonus for sparse texture
|
||||
check_sparse_compatibility();
|
||||
|
|
|
@ -142,10 +142,6 @@ namespace GLLoader {
|
|||
extern bool found_GL_ARB_gpu_shader5;
|
||||
extern bool found_GL_ARB_shader_image_load_store;
|
||||
extern bool found_GL_ARB_clear_texture;
|
||||
extern bool found_GL_ARB_direct_state_access;
|
||||
extern bool found_GL_EXT_texture_filter_anisotropic;
|
||||
extern bool found_GL_NVX_gpu_memory_info;
|
||||
extern bool found_GL_ATI_meminfo;
|
||||
|
||||
extern bool found_compatible_GL_ARB_sparse_texture2;
|
||||
extern bool found_compatible_sparse_depth;
|
||||
|
|
|
@ -527,7 +527,7 @@ bool GSDeviceOGL::Create(const std::shared_ptr<GSWnd> &wnd)
|
|||
if (GLLoader::vendor_id_amd) {
|
||||
// Full vram, remove a small margin for others buffer
|
||||
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, vram);
|
||||
} else if (GLLoader::found_GL_NVX_gpu_memory_info) {
|
||||
} else if (GLExtension::Has("GL_NVX_gpu_memory_info")) {
|
||||
// GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX <= give full memory
|
||||
// Available vram
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, vram);
|
||||
|
@ -837,8 +837,12 @@ GLuint GSDeviceOGL::CreateSampler(PSSamplerSelector sel)
|
|||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
|
||||
int anisotropy = theApp.GetConfigI("MaxAnisotropy");
|
||||
if (GLLoader::found_GL_EXT_texture_filter_anisotropic && anisotropy && sel.aniso)
|
||||
glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)anisotropy);
|
||||
if (anisotropy && sel.aniso) {
|
||||
if (GLExtension::Has("GL_ARB_texture_filter_anisotropic"))
|
||||
glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY, (float)anisotropy);
|
||||
else if (GLExtension::Has("GL_EXT_texture_filter_anisotropic"))
|
||||
glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)anisotropy);
|
||||
}
|
||||
|
||||
return sampler;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue