Commit e7c6e43c by Geoff Lang

Implement all entry points in libGLES and have libEGL act as a shim.

This allows libANGLE to only be included in libGLESv2 and moves all TLS data to libGLESv2.dll. BUG=angle:733 Change-Id: I34f0b47987a5efbe906c290d3ca656142e69ea9a Reviewed-on: https://chromium-review.googlesource.com/232962Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 6c85047a
......@@ -207,11 +207,6 @@ if (is_win) {
"//build/config/compiler:no_chromium_code",
]
direct_dependent_configs = [
":commit_id_config",
":libANGLE_config",
]
deps = [
":commit_id",
":includes",
......@@ -221,22 +216,7 @@ if (is_win) {
}
shared_library("libGLESv2") {
sources = [
"src/common/angleutils.cpp",
"src/common/angleutils.h",
"src/common/debug.cpp",
"src/common/debug.h",
"src/common/event_tracer.cpp",
"src/common/event_tracer.h",
"src/common/tls.cpp",
"src/common/tls.h",
"src/libGLESv2/libGLESv2.cpp",
"src/libGLESv2/libGLESv2.def",
"src/libGLESv2/libGLESv2.rc",
"src/libGLESv2/main.cpp",
"src/libGLESv2/main.h",
"src/libGLESv2/resource.h",
]
sources = rebase_path(gles_gypi.libglesv2_sources, ".", "src")
ldflags = [ "/DEF:" +
rebase_path("src/libGLESv2/libGLESv2.def", root_build_dir) ]
......@@ -244,6 +224,8 @@ if (is_win) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":internal_config",
":commit_id_config",
":libANGLE_config",
"//build/config/compiler:no_chromium_code",
]
......@@ -258,22 +240,7 @@ if (is_win) {
}
shared_library("libEGL") {
sources = [
"src/common/angleutils.cpp",
"src/common/angleutils.h",
"src/common/debug.cpp",
"src/common/debug.h",
"src/common/event_tracer.cpp",
"src/common/event_tracer.h",
"src/common/tls.cpp",
"src/common/tls.h",
"src/libEGL/libEGL.cpp",
"src/libEGL/libEGL.def",
"src/libEGL/libEGL.rc",
"src/libEGL/main.cpp",
"src/libEGL/main.h",
"src/libEGL/resource.h",
]
sources = rebase_path(gles_gypi.libegl_sources, ".", "src")
ldflags = [ "/DEF:" +
rebase_path("src/libEGL/libEGL.def", root_build_dir) ]
......@@ -281,6 +248,8 @@ if (is_win) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":internal_config",
":commit_id_config",
":libANGLE_config",
"//build/config/compiler:no_chromium_code",
]
......@@ -290,7 +259,6 @@ if (is_win) {
deps = [
":includes",
":libANGLE",
":libGLESv2",
]
}
......
......@@ -14,7 +14,7 @@
{
'target_name': 'libEGL',
'type': 'shared_library',
'dependencies': [ 'libGLESv2', 'libANGLE', ],
'dependencies': [ 'libGLESv2', ],
'includes': [ '../build/common_defines.gypi', ],
'include_dirs':
[
......@@ -23,23 +23,13 @@
],
'sources':
[
'common/angleutils.cpp',
'common/angleutils.h',
'common/debug.cpp',
'common/debug.h',
'common/event_tracer.cpp',
'common/event_tracer.h',
'common/tls.cpp',
'common/tls.h',
'libEGL/libEGL.cpp',
'libEGL/libEGL.def',
'libEGL/libEGL.rc',
'libEGL/main.cpp',
'libEGL/main.h',
'libEGL/resource.h',
'<@(libegl_sources)',
],
'defines':
[
'GL_APICALL=',
'GL_GLEXT_PROTOTYPES=',
'EGLAPI=',
'LIBEGL_IMPLEMENTATION',
],
'conditions':
......
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// main.cpp: DLL entry point and management of thread-local data.
#include "libEGL/main.h"
#include "common/debug.h"
#include "common/tls.h"
static TLSIndex currentTLS = TLS_OUT_OF_INDEXES;
namespace egl
{
struct Current
{
EGLint error;
EGLenum API;
EGLDisplay display;
EGLSurface drawSurface;
EGLSurface readSurface;
};
Current *AllocateCurrent()
{
ASSERT(currentTLS != TLS_OUT_OF_INDEXES);
if (currentTLS == TLS_OUT_OF_INDEXES)
{
return NULL;
}
Current *current = new Current();
current->error = EGL_SUCCESS;
current->API = EGL_OPENGL_ES_API;
current->display = EGL_NO_DISPLAY;
current->drawSurface = EGL_NO_SURFACE;
current->readSurface = EGL_NO_SURFACE;
if (!SetTLSValue(currentTLS, current))
{
ERR("Could not set thread local storage.");
return NULL;
}
return current;
}
void DeallocateCurrent()
{
Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
SafeDelete(current);
SetTLSValue(currentTLS, NULL);
}
}
extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
currentTLS = CreateTLSIndex();
if (currentTLS == TLS_OUT_OF_INDEXES)
{
return FALSE;
}
}
// Fall through to initialize index
case DLL_THREAD_ATTACH:
{
egl::AllocateCurrent();
}
break;
case DLL_THREAD_DETACH:
{
egl::DeallocateCurrent();
}
break;
case DLL_PROCESS_DETACH:
{
egl::DeallocateCurrent();
DestroyTLSIndex(currentTLS);
}
break;
default:
break;
}
return TRUE;
}
namespace egl
{
Current *GetCurrentData()
{
Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
// ANGLE issue 488: when the dll is loaded after thread initialization,
// thread local storage (current) might not exist yet.
return (current ? current : AllocateCurrent());
}
void recordError(const Error &error)
{
Current *current = GetCurrentData();
current->error = error.getCode();
}
EGLint getCurrentError()
{
Current *current = GetCurrentData();
return current->error;
}
void setCurrentAPI(EGLenum API)
{
Current *current = GetCurrentData();
current->API = API;
}
EGLenum getCurrentAPI()
{
Current *current = GetCurrentData();
return current->API;
}
void setCurrentDisplay(EGLDisplay dpy)
{
Current *current = GetCurrentData();
current->display = dpy;
}
EGLDisplay getCurrentDisplay()
{
Current *current = GetCurrentData();
return current->display;
}
void setCurrentDrawSurface(EGLSurface surface)
{
Current *current = GetCurrentData();
current->drawSurface = surface;
}
EGLSurface getCurrentDrawSurface()
{
Current *current = GetCurrentData();
return current->drawSurface;
}
void setCurrentReadSurface(EGLSurface surface)
{
Current *current = GetCurrentData();
current->readSurface = surface;
}
EGLSurface getCurrentReadSurface()
{
Current *current = GetCurrentData();
return current->readSurface;
}
}
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// main.h: Management of thread-local data.
#ifndef LIBEGL_MAIN_H_
#define LIBEGL_MAIN_H_
#include "libANGLE/Error.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
namespace egl
{
void recordError(const Error &error);
EGLint getCurrentError();
void setCurrentAPI(EGLenum API);
EGLenum getCurrentAPI();
void setCurrentDisplay(EGLDisplay dpy);
EGLDisplay getCurrentDisplay();
void setCurrentDrawSurface(EGLSurface surface);
EGLSurface getCurrentDrawSurface();
void setCurrentReadSurface(EGLSurface surface);
EGLSurface getCurrentReadSurface();
}
#endif // LIBEGL_MAIN_H_
......@@ -17,8 +17,6 @@
'common/mathutil.cpp',
'common/mathutil.h',
'common/platform.h',
'common/tls.cpp',
'common/tls.h',
'common/utilities.cpp',
'common/utilities.h',
'common/version.h',
......@@ -351,6 +349,38 @@
'libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp',
'libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h',
],
'libglesv2_sources':
[
'common/angleutils.h',
'common/debug.h',
'common/tls.h',
'libGLESv2/entry_points_egl.cpp',
'libGLESv2/entry_points_egl.h',
'libGLESv2/entry_points_egl_ext.cpp',
'libGLESv2/entry_points_egl_ext.h',
'libGLESv2/entry_points_gles_2_0.cpp',
'libGLESv2/entry_points_gles_2_0.h',
'libGLESv2/entry_points_gles_2_0_ext.cpp',
'libGLESv2/entry_points_gles_2_0_ext.h',
'libGLESv2/entry_points_gles_3_0.cpp',
'libGLESv2/entry_points_gles_3_0.h',
'libGLESv2/entry_points_gles_3_0_ext.cpp',
'libGLESv2/entry_points_gles_3_0_ext.h',
'libGLESv2/export.h',
'libGLESv2/global_state.cpp',
'libGLESv2/global_state.h',
'libGLESv2/libGLESv2.cpp',
'libGLESv2/libGLESv2.def',
'libGLESv2/libGLESv2.rc',
'libGLESv2/resource.h',
],
'libegl_sources':
[
'libEGL/libEGL.cpp',
'libEGL/libEGL.def',
'libEGL/libEGL.rc',
'libEGL/resource.h',
],
},
# Everything below this is duplicated in the GN build. If you change
# anything also change angle/BUILD.gn
......@@ -561,18 +591,13 @@
'includes': [ '../build/common_defines.gypi', ],
'sources':
[
'common/angleutils.h',
'common/debug.h',
'common/tls.h',
'libGLESv2/libGLESv2.cpp',
'libGLESv2/libGLESv2.def',
'libGLESv2/libGLESv2.rc',
'libGLESv2/main.cpp',
'libGLESv2/main.h',
'libGLESv2/resource.h',
'<@(libglesv2_sources)',
],
'defines':
[
'GL_APICALL=',
'GL_GLEXT_PROTOTYPES=',
'EGLAPI=',
'LIBGLESV2_IMPLEMENTATION',
],
'conditions':
......
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_egl.h : Defines the EGL entry points.
#ifndef LIBGLESV2_ENTRYPOINTSEGL_H_
#define LIBGLESV2_ENTRYPOINTSEGL_H_
#include "libGLESv2/export.h"
#include <EGL/egl.h>
namespace egl
{
// EGL 1.0
ANGLE_EXPORT EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
ANGLE_EXPORT EGLBoolean CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
ANGLE_EXPORT EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
ANGLE_EXPORT EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
ANGLE_EXPORT EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
ANGLE_EXPORT EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
ANGLE_EXPORT EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx);
ANGLE_EXPORT EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface);
ANGLE_EXPORT EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
ANGLE_EXPORT EGLBoolean GetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
ANGLE_EXPORT EGLDisplay GetCurrentDisplay(void);
ANGLE_EXPORT EGLSurface GetCurrentSurface(EGLint readdraw);
ANGLE_EXPORT EGLDisplay GetDisplay(EGLNativeDisplayType display_id);
ANGLE_EXPORT EGLint GetError(void);
ANGLE_EXPORT __eglMustCastToProperFunctionPointerType GetProcAddress(const char *procname);
ANGLE_EXPORT EGLBoolean Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
ANGLE_EXPORT EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
ANGLE_EXPORT EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
ANGLE_EXPORT const char *QueryString(EGLDisplay dpy, EGLint name);
ANGLE_EXPORT EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
ANGLE_EXPORT EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface surface);
ANGLE_EXPORT EGLBoolean Terminate(EGLDisplay dpy);
ANGLE_EXPORT EGLBoolean WaitGL(void);
ANGLE_EXPORT EGLBoolean WaitNative(EGLint engine);
// EGL 1.1
ANGLE_EXPORT EGLBoolean BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
ANGLE_EXPORT EGLBoolean ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
ANGLE_EXPORT EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
ANGLE_EXPORT EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval);
// EGL 1.2
ANGLE_EXPORT EGLBoolean BindAPI(EGLenum api);
ANGLE_EXPORT EGLenum QueryAPI(void);
ANGLE_EXPORT EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
ANGLE_EXPORT EGLBoolean ReleaseThread(void);
ANGLE_EXPORT EGLBoolean WaitClient(void);
// EGL 1.4
ANGLE_EXPORT EGLContext GetCurrentContext(void);
// EGL 1.5
ANGLE_EXPORT EGLSync CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
ANGLE_EXPORT EGLBoolean DestroySync(EGLDisplay dpy, EGLSync sync);
ANGLE_EXPORT EGLint ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
ANGLE_EXPORT EGLBoolean GetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
ANGLE_EXPORT EGLDisplay GetPlatformDisplay(EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
ANGLE_EXPORT EGLSurface CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
ANGLE_EXPORT EGLSurface CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
ANGLE_EXPORT EGLBoolean WaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags);
}
#endif // LIBGLESV2_ENTRYPOINTSEGL_H_
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_ext.cpp : Implements the EGL extension entry points.
#include "libGLESv2/entry_points_egl_ext.h"
#include "libGLESv2/global_state.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
#include "common/debug.h"
namespace egl
{
// EGL object validation
static bool ValidateDisplay(Display *display)
{
if (display == EGL_NO_DISPLAY)
{
SetGlobalError(Error(EGL_BAD_DISPLAY));
return false;
}
if (!display->isInitialized())
{
SetGlobalError(Error(EGL_NOT_INITIALIZED));
return false;
}
return true;
}
static bool ValidateSurface(Display *display, Surface *surface)
{
if (!ValidateDisplay(display))
{
return false;
}
if (!display->isValidSurface(surface))
{
SetGlobalError(Error(EGL_BAD_SURFACE));
return false;
}
return true;
}
// EGL_ANGLE_query_surface_pointer
EGLBoolean QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)",
dpy, surface, attribute, value);
Display *display = static_cast<Display*>(dpy);
Surface *eglSurface = (Surface*)surface;
if (!ValidateSurface(display, eglSurface))
{
return EGL_FALSE;
}
if (surface == EGL_NO_SURFACE)
{
SetGlobalError(Error(EGL_BAD_SURFACE));
return EGL_FALSE;
}
// validate the attribute parameter
switch (attribute)
{
case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
break;
default:
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
return EGL_FALSE;
}
Error error = eglSurface->querySurfacePointerANGLE(attribute, value);
SetGlobalError(error);
return (error.isError() ? EGL_FALSE : EGL_TRUE);
}
// EGL_NV_post_sub_buffer
EGLBoolean PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint x = %d, EGLint y = %d, EGLint width = %d, EGLint height = %d)", dpy, surface, x, y, width, height);
if (x < 0 || y < 0 || width < 0 || height < 0)
{
SetGlobalError(Error(EGL_BAD_PARAMETER));
return EGL_FALSE;
}
Display *display = static_cast<Display*>(dpy);
Surface *eglSurface = static_cast<Surface*>(surface);
if (!ValidateSurface(display, eglSurface))
{
return EGL_FALSE;
}
if (display->getRenderer()->isDeviceLost())
{
SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
}
if (surface == EGL_NO_SURFACE)
{
SetGlobalError(Error(EGL_BAD_SURFACE));
return EGL_FALSE;
}
Error error = eglSurface->postSubBuffer(x, y, width, height);
if (error.isError())
{
SetGlobalError(error);
return EGL_FALSE;
}
SetGlobalError(Error(EGL_SUCCESS));
return EGL_TRUE;
}
// EGL_EXT_platform_base
EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list)
{
EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
platform, native_display, attrib_list);
switch (platform)
{
case EGL_PLATFORM_ANGLE_ANGLE:
break;
default:
SetGlobalError(Error(EGL_BAD_CONFIG));
return EGL_NO_DISPLAY;
}
EGLint platformType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
bool majorVersionSpecified = false;
bool minorVersionSpecified = false;
bool requestedWARP = false;
if (attrib_list)
{
for (const EGLint *curAttrib = attrib_list; curAttrib[0] != EGL_NONE; curAttrib += 2)
{
switch (curAttrib[0])
{
case EGL_PLATFORM_ANGLE_TYPE_ANGLE:
switch (curAttrib[1])
{
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
break;
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
if (!Display::supportsPlatformD3D())
{
SetGlobalError(Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
}
break;
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
if (!Display::supportsPlatformOpenGL())
{
SetGlobalError(Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
}
break;
default:
SetGlobalError(Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
}
platformType = curAttrib[1];
break;
case EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE:
if (curAttrib[1] != EGL_DONT_CARE)
{
majorVersionSpecified = true;
}
break;
case EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE:
if (curAttrib[1] != EGL_DONT_CARE)
{
minorVersionSpecified = true;
}
break;
case EGL_PLATFORM_ANGLE_USE_WARP_ANGLE:
if (!Display::supportsPlatformD3D())
{
SetGlobalError(Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
}
switch (curAttrib[1])
{
case EGL_FALSE:
case EGL_TRUE:
break;
default:
SetGlobalError(Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
}
requestedWARP = (curAttrib[1] == EGL_TRUE);
break;
default:
break;
}
}
}
if (!majorVersionSpecified && minorVersionSpecified)
{
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
return EGL_NO_DISPLAY;
}
if (platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE && requestedWARP)
{
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
return EGL_NO_DISPLAY;
}
SetGlobalError(Error(EGL_SUCCESS));
EGLNativeDisplayType displayId = static_cast<EGLNativeDisplayType>(native_display);
return Display::getDisplay(displayId, AttributeMap(attrib_list));
}
}
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_egl_ext.h : Defines the EGL extension entry points.
#ifndef LIBGLESV2_ENTRYPOINTSEGLEXT_H_
#define LIBGLESV2_ENTRYPOINTSEGLEXT_H_
#include "libGLESv2/export.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
namespace egl
{
// EGL_ANGLE_query_surface_pointer
ANGLE_EXPORT EGLBoolean QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
// EGL_NV_post_sub_buffer
ANGLE_EXPORT EGLBoolean PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
// EGL_EXT_platform_base
ANGLE_EXPORT EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list);
}
#endif // LIBGLESV2_ENTRYPOINTSEGLEXT_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_gles_2_0_ext.h : Defines the GLES 2.0 extension entry points.
#ifndef LIBGLESV2_ENTRYPOINTGLES20EXT_H_
#define LIBGLESV2_ENTRYPOINTGLES20EXT_H_
#include "libGLESv2/export.h"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
namespace gl
{
// GL_ANGLE_framebuffer_blit
ANGLE_EXPORT void BlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
// GL_ANGLE_framebuffer_multisample
ANGLE_EXPORT void RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
// GL_NV_fence
ANGLE_EXPORT void DeleteFencesNV(GLsizei n, const GLuint* fences);
ANGLE_EXPORT void GenFencesNV(GLsizei n, GLuint* fences);
ANGLE_EXPORT GLboolean IsFenceNV(GLuint fence);
ANGLE_EXPORT GLboolean TestFenceNV(GLuint fence);
ANGLE_EXPORT void GetFenceivNV(GLuint fence, GLenum pname, GLint *params);
ANGLE_EXPORT void FinishFenceNV(GLuint fence);
ANGLE_EXPORT void SetFenceNV(GLuint fence, GLenum condition);
// GL_ANGLE_translated_shader_source
ANGLE_EXPORT void GetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
// GL_EXT_texture_storage
ANGLE_EXPORT void TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
// GL_EXT_robustness
ANGLE_EXPORT GLenum GetGraphicsResetStatusEXT(void);
ANGLE_EXPORT void ReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
ANGLE_EXPORT void GetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, float *params);
ANGLE_EXPORT void GetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint *params);
// GL_EXT_occlusion_query_boolean
ANGLE_EXPORT void GenQueriesEXT(GLsizei n, GLuint *ids);
ANGLE_EXPORT void DeleteQueriesEXT(GLsizei n, const GLuint *ids);
ANGLE_EXPORT GLboolean IsQueryEXT(GLuint id);
ANGLE_EXPORT void BeginQueryEXT(GLenum target, GLuint id);
ANGLE_EXPORT void EndQueryEXT(GLenum target);
ANGLE_EXPORT void GetQueryivEXT(GLenum target, GLenum pname, GLint *params);
ANGLE_EXPORT void GetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params);
// GL_EXT_draw_buffers
ANGLE_EXPORT void DrawBuffersEXT(GLsizei n, const GLenum *bufs);
// GL_ANGLE_instanced_arrays
ANGLE_EXPORT void DrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
ANGLE_EXPORT void DrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
ANGLE_EXPORT void VertexAttribDivisorANGLE(GLuint index, GLuint divisor);
// GL_OES_get_program_binary
ANGLE_EXPORT void GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
ANGLE_EXPORT void ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
// GL_OES_mapbuffer
ANGLE_EXPORT void *MapBufferOES(GLenum target, GLenum access);
ANGLE_EXPORT GLboolean UnmapBufferOES(GLenum target);
ANGLE_EXPORT void GetBufferPointervOES(GLenum target, GLenum pname, GLvoid **params);
// GL_EXT_map_buffer_range
ANGLE_EXPORT void *MapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
ANGLE_EXPORT void FlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length);
}
#endif // LIBGLESV2_ENTRYPOINTGLES20EXT_H_
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_gles_3_0_ext.cpp : Implements the GLES 3.0 extension entry points.
#include "libGLESv2/entry_points_gles_3_0_ext.h"
#include "libGLESv2/global_state.h"
namespace gl
{
}
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_gles_3_0_ext.h : Defines the GLES 3.0 extension entry points.
#ifndef LIBGLESV2_ENTRYPOINTGLES30EXT_H_
#define LIBGLESV2_ENTRYPOINTGLES30EXT_H_
#include "libGLESv2/export.h"
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
namespace gl
{
// No GLES 3.0 extensions yet
}
#endif // LIBGLESV2_ENTRYPOINTGLES30EXT_H_
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// export.h : Defines ANGLE_EXPORT, a macro for exporting functions from the DLL
#ifndef LIBGLESV2_EXPORT_H_
#define LIBGLESV2_EXPORT_H_
#if defined(_WIN32)
# if defined(LIBGLESV2_IMPLEMENTATION)
# define ANGLE_EXPORT __declspec(dllexport)
# else
# define ANGLE_EXPORT __declspec(dllimport)
# endif
#elif defined(__GNUC__)
# if defined(LIBGLESV2_IMPLEMENTATION)
# define ANGLE_EXPORT __attribute__((visibility ("default")))
# else
# define ANGLE_EXPORT
# endif
#else
# define ANGLE_EXPORT
#endif
#endif // LIBGLESV2_EXPORT_H_
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// main.cpp: DLL entry point and management of thread-local data.
// global_state.cpp : Implements functions for querying the thread-local GL and EGL state.
#include "libGLESv2/main.h"
#include "libGLESv2/global_state.h"
#include "libANGLE/Context.h"
#include "libANGLE/Error.h"
#include "common/debug.h"
#include "common/platform.h"
#include "common/tls.h"
static TLSIndex currentTLS = TLS_INVALID_INDEX;
namespace gl
namespace
{
static TLSIndex currentTLS = TLS_INVALID_INDEX;
struct Current
{
Context *context;
EGLint error;
EGLenum API;
egl::Display *display;
egl::Surface *drawSurface;
egl::Surface *readSurface;
gl::Context *context;
};
// TODO(kbr): figure out how these are going to be managed on
// non-Windows platforms. These routines would need to be exported
// from ANGLE and called cooperatively when users create and destroy
// threads -- or the initialization of the TLS index, and allocation
// of thread-local data, will have to be done lazily. Will have to use
// destructor function with pthread_create_key on POSIX platforms to
// clean up thread-local data.
// Call this exactly once at process startup.
bool CreateThreadLocalIndex()
{
currentTLS = CreateTLSIndex();
if (currentTLS == TLS_INVALID_INDEX)
{
return false;
}
return true;
}
// Call this exactly once at process shutdown.
void DestroyThreadLocalIndex()
{
DestroyTLSIndex(currentTLS);
currentTLS = TLS_INVALID_INDEX;
}
// Call this upon thread startup.
Current *AllocateCurrent()
{
ASSERT(currentTLS != TLS_INVALID_INDEX);
......@@ -59,8 +39,12 @@ Current *AllocateCurrent()
}
Current *current = new Current();
current->context = NULL;
current->display = NULL;
current->error = EGL_SUCCESS;
current->API = EGL_OPENGL_ES_API;
current->display = reinterpret_cast<egl::Display*>(EGL_NO_DISPLAY);
current->drawSurface = reinterpret_cast<egl::Surface*>(EGL_NO_SURFACE);
current->readSurface = reinterpret_cast<egl::Surface*>(EGL_NO_SURFACE);
current->context = reinterpret_cast<gl::Context*>(EGL_NO_CONTEXT);
if (!SetTLSValue(currentTLS, current))
{
......@@ -71,7 +55,6 @@ Current *AllocateCurrent()
return current;
}
// Call this upon thread shutdown.
void DeallocateCurrent()
{
Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
......@@ -79,116 +62,174 @@ void DeallocateCurrent()
SetTLSValue(currentTLS, NULL);
}
Current *GetCurrentData()
{
// Create a TLS index if one has not been created for this DLL
if (currentTLS == TLS_INVALID_INDEX)
{
currentTLS = CreateTLSIndex();
}
Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
// ANGLE issue 488: when the dll is loaded after thread initialization,
// thread local storage (current) might not exist yet.
return (current ? current : AllocateCurrent());
}
#ifdef ANGLE_PLATFORM_WINDOWS
extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
currentTLS = CreateTLSIndex();
if (currentTLS == TLS_INVALID_INDEX)
{
if (!gl::CreateThreadLocalIndex())
{
return FALSE;
}
return FALSE;
}
// Fall through to initialize index
AllocateCurrent();
break;
case DLL_THREAD_ATTACH:
{
gl::AllocateCurrent();
}
AllocateCurrent();
break;
case DLL_THREAD_DETACH:
{
gl::DeallocateCurrent();
}
DeallocateCurrent();
break;
case DLL_PROCESS_DETACH:
DeallocateCurrent();
if (currentTLS != TLS_INVALID_INDEX)
{
gl::DeallocateCurrent();
gl::DestroyThreadLocalIndex();
DestroyTLSIndex(currentTLS);
currentTLS = TLS_INVALID_INDEX;
}
break;
default:
break;
}
return TRUE;
}
#endif
namespace gl
{
Current *GetCurrentData()
{
Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
// ANGLE issue 488: when the dll is loaded after thread initialization,
// thread local storage (current) might not exist yet.
return (current ? current : AllocateCurrent());
}
void makeCurrent(Context *context, egl::Display *display, egl::Surface *surface)
namespace gl
{
Current *current = GetCurrentData();
current->context = context;
current->display = display;
if (context && display && surface)
{
context->makeCurrent(surface);
}
}
Context *getContext()
Context *GetGlobalContext()
{
Current *current = GetCurrentData();
return current->context;
}
Context *getNonLostContext()
Context *GetValidGlobalContext()
{
Context *context = getContext();
gl::Context *context = GetGlobalContext();
if (context)
{
if (context->isContextLost())
{
context->recordError(Error(GL_OUT_OF_MEMORY, "Context has been lost."));
return NULL;
context->recordError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost."));
return nullptr;
}
else
{
return context;
}
}
return NULL;
return nullptr;
}
}
namespace egl
{
void SetGlobalError(const Error &error)
{
Current *current = GetCurrentData();
current->error = error.getCode();
}
EGLint GetGlobalError()
{
Current *current = GetCurrentData();
return current->error;
}
EGLenum GetGlobalAPI()
{
Current *current = GetCurrentData();
return current->API;
}
void SetGlobalAPI(EGLenum API)
{
Current *current = GetCurrentData();
current->API = API;
}
void SetGlobalDisplay(Display *dpy)
{
Current *current = GetCurrentData();
current->display = dpy;
}
egl::Display *getDisplay()
Display *GetGlobalDisplay()
{
Current *current = GetCurrentData();
return current->display;
}
void SetGlobalDrawSurface(Surface *surface)
{
Current *current = GetCurrentData();
current->drawSurface = surface;
}
Surface *GetGlobalDrawSurface()
{
Current *current = GetCurrentData();
return current->drawSurface;
}
void SetGlobalReadSurface(Surface *surface)
{
Current *current = GetCurrentData();
current->readSurface = surface;
}
extern "C"
Surface *GetGlobalReadSurface()
{
Current *current = GetCurrentData();
return current->readSurface;
}
void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface)
void SetGlobalContext(gl::Context *context)
{
gl::makeCurrent(context, display, surface);
Current *current = GetCurrentData();
current->context = context;
}
gl::Context *glGetCurrentContext()
gl::Context *GetGlobalContext()
{
return gl::getContext();
Current *current = GetCurrentData();
return current->context;
}
}
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// global_state.h : Defines functions for querying the thread-local GL and EGL state.
#ifndef LIBGLESV2_GLOBALSTATE_H_
#define LIBGLESV2_GLOBALSTATE_H_
#include <EGL/egl.h>
namespace gl
{
class Context;
Context *GetGlobalContext();
Context *GetValidGlobalContext();
}
namespace egl
{
class Error;
class Display;
class Surface;
void SetGlobalError(const Error &error);
EGLint GetGlobalError();
void SetGlobalAPI(EGLenum API);
EGLenum GetGlobalAPI();
void SetGlobalDisplay(Display *dpy);
Display *GetGlobalDisplay();
void SetGlobalDrawSurface(Surface *surface);
Surface *GetGlobalDrawSurface();
void SetGlobalReadSurface(Surface *surface);
Surface *GetGlobalReadSurface();
void SetGlobalContext(gl::Context *context);
gl::Context *GetGlobalContext();
}
#endif // LIBGLESV2_GLOBALSTATE_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -144,7 +144,6 @@ EXPORTS
glViewport @142
; Extensions
glTexImage3DOES @143
glBlitFramebufferANGLE @149
glRenderbufferStorageMultisampleANGLE @150
glDeleteFencesNV @151
......@@ -285,9 +284,5 @@ EXPORTS
glTexStorage3D @282
glGetInternalformativ @283
; EGL dependencies
glMakeCurrent @146 NONAME
glGetCurrentContext @147 NONAME
; Setting up TRACE macro callbacks
SetTraceFunctionPointers @284
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// main.h: Management of thread-local data.
#ifndef LIBGLESV2_MAIN_H_
#define LIBGLESV2_MAIN_H_
#include <GLES2/gl2.h>
#include <EGL/egl.h>
namespace egl
{
class Display;
class Surface;
class AttributeMap;
}
namespace gl
{
class Context;
void makeCurrent(Context *context, egl::Display *display, egl::Surface *surface);
Context *getContext();
Context *getNonLostContext();
egl::Display *getDisplay();
}
extern "C"
{
// Exported functions for use by EGL
void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
gl::Context *glGetCurrentContext();
}
#endif // LIBGLESV2_MAIN_H_
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