Commit f8542546 authored by apatrick@chromium.org's avatar apatrick@chromium.org

Added booleans that indicate which GL extensions are available.

This is because some implementations of eglGetProcAddress do not return null for entry points that are not available. This gives a convenient and efficient way of determining whether a particular entry point can be called.
Review URL: http://codereview.chromium.org/8416054

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108153 0039d316-1c4b-4281-b951-d872f2087c98
parent 269cd38b
......@@ -62,7 +62,7 @@ void GpuScheduler::PutChanged() {
// Check that the GPU has passed all fences.
if (!unschedule_fences_.empty()) {
if (glGenFencesNV) {
if (gfx::g_GL_NV_fence) {
while (!unschedule_fences_.empty()) {
if (glTestFenceNV(unschedule_fences_.front().fence)) {
glDeleteFencesNV(1, &unschedule_fences_.front().fence);
......@@ -181,7 +181,7 @@ void GpuScheduler::DeferToFence(base::Closure task) {
// This follows the semantics for texture object names before
// they are bound, in that they acquire their state upon binding.
// We will arbitrarily return TRUE for consistency.
if (glGenFencesNV) {
if (gfx::g_GL_NV_fence) {
glGenFencesNV(1, &fence.fence);
glSetFenceNV(fence.fence, GL_ALL_COMPLETED_NV);
}
......
......@@ -476,7 +476,7 @@ FUNCTION_SETS = [
'../../../third_party/mesa/MesaLib/include/GL/glxext.h']],
]
def GenerateHeader(file, functions, set_name):
def GenerateHeader(file, functions, set_name, used_extension_functions):
"""Generates gl_binding_autogen_x.h"""
# Write file header.
......@@ -507,6 +507,11 @@ def GenerateHeader(file, functions, set_name):
file.write('typedef %s (GL_BINDING_CALL *%sProc)(%s);\n' %
(return_type, names[0], arguments))
# Write declarations for booleans indicating which extensions are available.
file.write('\n')
for extension, ext_functions in used_extension_functions:
file.write('GL_EXPORT extern bool g_%s;\n' % extension)
# Write declarations for function pointers. Always use the GL name for the
# declaration.
file.write('\n')
......@@ -541,10 +546,15 @@ def GenerateSource(file, functions, set_name, used_extension_functions):
file.write('#include "ui/gfx/gl/gl_context.h"\n')
file.write('#include "ui/gfx/gl/gl_implementation.h"\n')
# Write definitions of function pointers.
# Write definitions for booleans indicating which extensions are available.
file.write('\n')
file.write('namespace gfx {\n')
file.write('\n')
for extension, ext_functions in used_extension_functions:
file.write('bool g_%s;\n' % extension)
# Write definitions of function pointers.
file.write('\n')
file.write('static bool g_debugBindingsInitialized;\n')
file.write('static void UpdateDebugGLExtensionBindings();\n')
file.write('\n')
......@@ -576,7 +586,8 @@ def GenerateSource(file, functions, set_name, used_extension_functions):
set_name.upper())
file.write(' DCHECK(context && context->IsCurrent(NULL));\n')
for extension, ext_functions in used_extension_functions:
file.write(' if (context->HasExtension("%s")) {\n' % extension)
file.write(' if ((g_%s = context->HasExtension("%s"))) {\n' %
(extension, extension))
queried_entry_points = set()
for entry_point_name, function_name in ext_functions:
# Replace the pointer unconditionally unless this extension has several
......@@ -836,15 +847,16 @@ def main(argv):
dir = '.'
for [functions, set_name, extension_headers] in FUNCTION_SETS:
used_extension_functions = GetUsedExtensionFunctions(
functions, extension_headers)
header_file = open(
os.path.join(dir, 'gl_bindings_autogen_%s.h' % set_name), 'wb')
GenerateHeader(header_file, functions, set_name)
GenerateHeader(header_file, functions, set_name, used_extension_functions)
header_file.close()
source_file = open(
os.path.join(dir, 'gl_bindings_autogen_%s.cc' % set_name), 'wb')
used_extension_functions = GetUsedExtensionFunctions(
functions, extension_headers)
GenerateSource(source_file, functions, set_name, used_extension_functions)
source_file.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment