From 9e14c16e1acdab8d2ee302fc0d193d2a61a22567 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 26 Dec 2015 20:07:28 +0100 Subject: [PATCH] Collect supported shader binary formats --- .../glstuff/glGraphicsStateGuardian_src.cxx | 30 +++++++++++++++++++ .../src/glstuff/glGraphicsStateGuardian_src.h | 1 + 2 files changed, 31 insertions(+) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index a55a03561c..943ee4e7d5 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -2487,6 +2487,7 @@ reset() { #ifndef OPENGLES _supports_get_program_binary = false; + _program_binary_formats.clear(); if (is_at_least_gl_version(4, 1) || has_extension("GL_ARB_get_program_binary")) { _glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC) @@ -2494,8 +2495,20 @@ reset() { _glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) get_extension_func("glProgramParameteri"); + GLint num_binary_formats = 0; if (_glGetProgramBinary != NULL && _glProgramParameteri != NULL) { + glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num_binary_formats); + } + + if (num_binary_formats > 0) { _supports_get_program_binary = true; + + GLenum *binary_formats = (GLenum *)alloca(sizeof(GLenum) * num_binary_formats); + glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, (GLint *)binary_formats); + + for (int i = 0; i < num_binary_formats; ++i) { + _program_binary_formats.insert(binary_formats[i]); + } } } #endif @@ -2683,6 +2696,23 @@ reset() { report_my_gl_errors(); +#ifndef OPENGLES + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Supported shader binary formats:\n"; + GLCAT.debug() << " "; + + pset::const_iterator it; + for (it = _program_binary_formats.begin(); + it != _program_binary_formats.end(); ++it) { + char number[16]; + sprintf(number, "0x%04X", *it); + GLCAT.debug(false) << " " << number << ""; + } + GLCAT.debug(false) << "\n"; + } +#endif + #ifndef OPENGLES if (_gl_shadlang_ver_major >= 4 || has_extension("GL_NV_gpu_program5")) { // gp5fp - OpenGL fragment profile for GeForce 400 Series and up diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 76fec0f546..894dd05439 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -671,6 +671,7 @@ protected: GLint _max_image_units; bool _supports_multi_bind; bool _supports_get_program_binary; + pset _program_binary_formats; #ifdef OPENGLES bool _supports_depth24;