diff options
Diffstat (limited to 'gfx/angle/src/libGLESv2')
-rwxr-xr-x | gfx/angle/src/libGLESv2/entry_points_egl.cpp | 467 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/entry_points_egl_ext.cpp | 260 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/entry_points_egl_ext.h | 7 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/entry_points_gles_2_0.cpp | 1338 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp | 1494 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.h | 332 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/entry_points_gles_3_0.cpp | 342 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/global_state.cpp | 250 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/global_state.h | 28 | ||||
-rwxr-xr-x | gfx/angle/src/libGLESv2/moz.build | 8 |
10 files changed, 1963 insertions, 2563 deletions
diff --git a/gfx/angle/src/libGLESv2/entry_points_egl.cpp b/gfx/angle/src/libGLESv2/entry_points_egl.cpp index dc0ccb5f7..1ed04eaf1 100755 --- a/gfx/angle/src/libGLESv2/entry_points_egl.cpp +++ b/gfx/angle/src/libGLESv2/entry_points_egl.cpp @@ -17,15 +17,12 @@ #include "libANGLE/Context.h" #include "libANGLE/Display.h" #include "libANGLE/Texture.h" -#include "libANGLE/Thread.h" #include "libANGLE/Surface.h" #include "libANGLE/validationEGL.h" #include "common/debug.h" #include "common/version.h" -#include "platform/Platform.h" - #include <EGL/eglext.h> namespace egl @@ -35,10 +32,9 @@ namespace egl EGLint EGLAPIENTRY GetError(void) { EVENT("()"); - Thread *thread = GetCurrentThread(); - EGLint error = thread->getError(); - thread->setError(Error(EGL_SUCCESS)); + EGLint error = GetGlobalError(); + SetGlobalError(Error(EGL_SUCCESS)); return error; } @@ -51,58 +47,58 @@ EGLDisplay EGLAPIENTRY GetDisplay(EGLNativeDisplayType display_id) EGLBoolean EGLAPIENTRY Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)", dpy, - major, minor); - Thread *thread = GetCurrentThread(); + EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)", + dpy, major, minor); Display *display = static_cast<Display *>(dpy); if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display)) { - thread->setError(Error(EGL_BAD_DISPLAY)); + SetGlobalError(Error(EGL_BAD_DISPLAY)); return EGL_FALSE; } Error error = display->initialize(); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (major) *major = 1; if (minor) *minor = 4; - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY Terminate(EGLDisplay dpy) { EVENT("(EGLDisplay dpy = 0x%0.8p)", dpy); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display)) { - thread->setError(Error(EGL_BAD_DISPLAY)); + SetGlobalError(Error(EGL_BAD_DISPLAY)); return EGL_FALSE; } - if (display->isValidContext(thread->getContext())) + gl::Context *context = GetGlobalContext(); + + if (display->isValidContext(context)) { - thread->setCurrent(nullptr, nullptr, nullptr, nullptr); + SetGlobalContext(NULL); + SetGlobalDisplay(NULL); } display->terminate(); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } const char *EGLAPIENTRY QueryString(EGLDisplay dpy, EGLint name) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint name = %d)", dpy, name); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); if (!(display == EGL_NO_DISPLAY && name == EGL_EXTENSIONS)) @@ -110,7 +106,7 @@ const char *EGLAPIENTRY QueryString(EGLDisplay dpy, EGLint name) Error error = ValidateDisplay(display); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return NULL; } } @@ -138,34 +134,32 @@ const char *EGLAPIENTRY QueryString(EGLDisplay dpy, EGLint name) result = "1.4 (ANGLE " ANGLE_VERSION_STRING ")"; break; default: - thread->setError(Error(EGL_BAD_PARAMETER)); - return NULL; + SetGlobalError(Error(EGL_BAD_PARAMETER)); + return NULL; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return result; } EGLBoolean EGLAPIENTRY GetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { - EVENT( - "(EGLDisplay dpy = 0x%0.8p, EGLConfig *configs = 0x%0.8p, " - "EGLint config_size = %d, EGLint *num_config = 0x%0.8p)", - dpy, configs, config_size, num_config); - Thread *thread = GetCurrentThread(); + EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig *configs = 0x%0.8p, " + "EGLint config_size = %d, EGLint *num_config = 0x%0.8p)", + dpy, configs, config_size, num_config); Display *display = static_cast<Display*>(dpy); Error error = ValidateDisplay(display); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (!num_config) { - thread->setError(Error(EGL_BAD_PARAMETER)); + SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } @@ -180,30 +174,28 @@ EGLBoolean EGLAPIENTRY GetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint con } *num_config = static_cast<EGLint>(filteredConfigs.size()); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY ChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) { - EVENT( - "(EGLDisplay dpy = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p, " - "EGLConfig *configs = 0x%0.8p, EGLint config_size = %d, EGLint *num_config = 0x%0.8p)", - dpy, attrib_list, configs, config_size, num_config); - Thread *thread = GetCurrentThread(); + EVENT("(EGLDisplay dpy = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p, " + "EGLConfig *configs = 0x%0.8p, EGLint config_size = %d, EGLint *num_config = 0x%0.8p)", + dpy, attrib_list, configs, config_size, num_config); Display *display = static_cast<Display*>(dpy); Error error = ValidateDisplay(display); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (!num_config) { - thread->setError(Error(EGL_BAD_PARAMETER)); + SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } @@ -219,17 +211,14 @@ EGLBoolean EGLAPIENTRY ChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, E } *num_config = static_cast<EGLint>(filteredConfigs.size()); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) { - EVENT( - "(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLint attribute = %d, EGLint " - "*value = 0x%0.8p)", - dpy, config, attribute, value); - Thread *thread = GetCurrentThread(); + EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)", + dpy, config, attribute, value); Display *display = static_cast<Display*>(dpy); Config *configuration = static_cast<Config*>(config); @@ -237,27 +226,24 @@ EGLBoolean EGLAPIENTRY GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint Error error = ValidateConfig(display, configuration); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (!display->getConfigAttrib(configuration, attribute, value)) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLSurface EGLAPIENTRY CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) { - EVENT( - "(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativeWindowType win = 0x%0.8p, " - "const EGLint *attrib_list = 0x%0.8p)", - dpy, config, win, attrib_list); - Thread *thread = GetCurrentThread(); + EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativeWindowType win = 0x%0.8p, " + "const EGLint *attrib_list = 0x%0.8p)", dpy, config, win, attrib_list); Display *display = static_cast<Display*>(dpy); Config *configuration = static_cast<Config*>(config); @@ -266,7 +252,7 @@ EGLSurface EGLAPIENTRY CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGL Error error = ValidateCreateWindowSurface(display, configuration, win, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_SURFACE; } @@ -274,7 +260,7 @@ EGLSurface EGLAPIENTRY CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGL error = display->createWindowSurface(configuration, win, attributes, &surface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_SURFACE; } @@ -283,11 +269,8 @@ EGLSurface EGLAPIENTRY CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGL EGLSurface EGLAPIENTRY CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { - EVENT( - "(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, const EGLint *attrib_list = " - "0x%0.8p)", - dpy, config, attrib_list); - Thread *thread = GetCurrentThread(); + EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)", + dpy, config, attrib_list); Display *display = static_cast<Display*>(dpy); Config *configuration = static_cast<Config*>(config); @@ -296,7 +279,7 @@ EGLSurface EGLAPIENTRY CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, co Error error = ValidateCreatePbufferSurface(display, configuration, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_SURFACE; } @@ -304,7 +287,7 @@ EGLSurface EGLAPIENTRY CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, co error = display->createPbufferSurface(configuration, attributes, &surface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_SURFACE; } @@ -315,7 +298,6 @@ EGLSurface EGLAPIENTRY CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGL { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativePixmapType pixmap = 0x%0.8p, " "const EGLint *attrib_list = 0x%0.8p)", dpy, config, pixmap, attrib_list); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Config *configuration = static_cast<Config*>(config); @@ -323,20 +305,19 @@ EGLSurface EGLAPIENTRY CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGL Error error = ValidateConfig(display, configuration); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_SURFACE; } UNIMPLEMENTED(); // FIXME - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_NO_SURFACE; } EGLBoolean EGLAPIENTRY DestroySurface(EGLDisplay dpy, EGLSurface surface) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); @@ -344,19 +325,19 @@ EGLBoolean EGLAPIENTRY DestroySurface(EGLDisplay dpy, EGLSurface surface) Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { - thread->setError(Error(EGL_BAD_SURFACE)); + SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } display->destroySurface((Surface*)surface); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } @@ -364,7 +345,6 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)", dpy, surface, attribute, value); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = (Surface*)surface; @@ -372,13 +352,13 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { - thread->setError(Error(EGL_BAD_SURFACE)); + SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } @@ -435,7 +415,7 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a case EGL_POST_SUB_BUFFER_SUPPORTED_NV: if (!display->getExtensions().postSubBuffer) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } *value = eglSurface->isPostSubBufferSupported(); @@ -443,7 +423,7 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a case EGL_FIXED_SIZE_ANGLE: if (!display->getExtensions().windowFixedSize) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } *value = eglSurface->isFixedSize(); @@ -451,7 +431,7 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a case EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE: if (!display->getExtensions().flexibleSurfaceCompatibility) { - thread->setError( + SetGlobalError( Error(EGL_BAD_ATTRIBUTE, "EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE cannot be used without " "EGL_ANGLE_flexible_surface_compatibility support.")); @@ -462,9 +442,9 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a case EGL_SURFACE_ORIENTATION_ANGLE: if (!display->getExtensions().surfaceOrientation) { - thread->setError(Error(EGL_BAD_ATTRIBUTE, - "EGL_SURFACE_ORIENTATION_ANGLE cannot be queried without " - "EGL_ANGLE_surface_orientation support.")); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE, + "EGL_SURFACE_ORIENTATION_ANGLE cannot be queried without " + "EGL_ANGLE_surface_orientation support.")); return EGL_FALSE; } *value = eglSurface->getOrientation(); @@ -472,19 +452,19 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a case EGL_DIRECT_COMPOSITION_ANGLE: if (!display->getExtensions().directComposition) { - thread->setError(Error(EGL_BAD_ATTRIBUTE, - "EGL_DIRECT_COMPOSITION_ANGLE cannot be used without " - "EGL_ANGLE_direct_composition support.")); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE, + "EGL_DIRECT_COMPOSITION_ANGLE cannot be used without " + "EGL_ANGLE_direct_composition support.")); return EGL_FALSE; } *value = eglSurface->directComposition(); break; default: - thread->setError(Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); + return EGL_FALSE; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } @@ -492,7 +472,6 @@ EGLContext EGLAPIENTRY CreateContext(EGLDisplay dpy, EGLConfig config, EGLContex { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLContext share_context = 0x%0.8p, " "const EGLint *attrib_list = 0x%0.8p)", dpy, config, share_context, attrib_list); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Config *configuration = static_cast<Config*>(config); @@ -502,7 +481,7 @@ EGLContext EGLAPIENTRY CreateContext(EGLDisplay dpy, EGLConfig config, EGLContex Error error = ValidateCreateContext(display, configuration, sharedGLContext, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_CONTEXT; } @@ -510,18 +489,17 @@ EGLContext EGLAPIENTRY CreateContext(EGLDisplay dpy, EGLConfig config, EGLContex error = display->createContext(configuration, sharedGLContext, attributes, &context); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_CONTEXT; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return static_cast<EGLContext>(context); } EGLBoolean EGLAPIENTRY DestroyContext(EGLDisplay dpy, EGLContext ctx) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, ctx); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); gl::Context *context = static_cast<gl::Context*>(ctx); @@ -529,24 +507,25 @@ EGLBoolean EGLAPIENTRY DestroyContext(EGLDisplay dpy, EGLContext ctx) Error error = ValidateContext(display, context); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (ctx == EGL_NO_CONTEXT) { - thread->setError(Error(EGL_BAD_CONTEXT)); + SetGlobalError(Error(EGL_BAD_CONTEXT)); return EGL_FALSE; } - if (context == thread->getContext()) + if (context == GetGlobalContext()) { - thread->setCurrent(nullptr, thread->getDrawSurface(), thread->getReadSurface(), nullptr); + SetGlobalDisplay(NULL); + SetGlobalContext(NULL); } display->destroyContext(context); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } @@ -554,7 +533,6 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, draw, read, ctx); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); gl::Context *context = static_cast<gl::Context*>(ctx); @@ -563,13 +541,13 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r // error is generated. if (ctx == EGL_NO_CONTEXT && (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE)) { - thread->setError(Error(EGL_BAD_MATCH)); + SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } if (ctx != EGL_NO_CONTEXT && draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE) { - thread->setError(Error(EGL_BAD_MATCH)); + SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } @@ -577,21 +555,21 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r // EGL_BAD_MATCH error is generated. if ((read == EGL_NO_SURFACE) != (draw == EGL_NO_SURFACE)) { - thread->setError(Error( + SetGlobalError(Error( EGL_BAD_MATCH, "read and draw must both be valid surfaces, or both be EGL_NO_SURFACE")); return EGL_FALSE; } if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display)) { - thread->setError(Error(EGL_BAD_DISPLAY, "'dpy' not a valid EGLDisplay handle")); + SetGlobalError(Error(EGL_BAD_DISPLAY, "'dpy' not a valid EGLDisplay handle")); return EGL_FALSE; } // EGL 1.5 spec: dpy can be uninitialized if all other parameters are null if (!display->isInitialized() && (ctx != EGL_NO_CONTEXT || draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE)) { - thread->setError(Error(EGL_NOT_INITIALIZED, "'dpy' not initialized")); + SetGlobalError(Error(EGL_NOT_INITIALIZED, "'dpy' not initialized")); return EGL_FALSE; } @@ -600,14 +578,14 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r Error error = ValidateContext(display, context); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } } if (display->isInitialized() && display->testDeviceLost()) { - thread->setError(Error(EGL_CONTEXT_LOST)); + SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } @@ -617,7 +595,7 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r Error error = ValidateSurface(display, drawSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } } @@ -628,7 +606,7 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r Error error = ValidateSurface(display, readSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } } @@ -640,7 +618,7 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r context->getConfig(), readSurface->getType()); if (readCompatError.isError()) { - thread->setError(readCompatError); + SetGlobalError(readCompatError); return EGL_FALSE; } } @@ -656,7 +634,7 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r context->getConfig(), drawSurface->getType()); if (drawCompatError.isError()) { - thread->setError(drawCompatError); + SetGlobalError(drawCompatError); return EGL_FALSE; } } @@ -665,12 +643,16 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r Error makeCurrentError = display->makeCurrent(drawSurface, readSurface, context); if (makeCurrentError.isError()) { - thread->setError(makeCurrentError); + SetGlobalError(makeCurrentError); return EGL_FALSE; } - gl::Context *previousContext = thread->getContext(); - thread->setCurrent(display, drawSurface, readSurface, context); + gl::Context *previousContext = GetGlobalContext(); + + SetGlobalDisplay(display); + SetGlobalDrawSurface(drawSurface); + SetGlobalReadSurface(readSurface); + SetGlobalContext(context); // Release the surface from the previously-current context, to allow // destroyed surfaces to delete themselves. @@ -679,28 +661,27 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r previousContext->releaseSurface(); } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLSurface EGLAPIENTRY GetCurrentSurface(EGLint readdraw) { EVENT("(EGLint readdraw = %d)", readdraw); - Thread *thread = GetCurrentThread(); if (readdraw == EGL_READ) { - thread->setError(Error(EGL_SUCCESS)); - return thread->getReadSurface(); + SetGlobalError(Error(EGL_SUCCESS)); + return GetGlobalReadSurface(); } else if (readdraw == EGL_DRAW) { - thread->setError(Error(EGL_SUCCESS)); - return thread->getDrawSurface(); + SetGlobalError(Error(EGL_SUCCESS)); + return GetGlobalDrawSurface(); } else { - thread->setError(Error(EGL_BAD_PARAMETER)); + SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_NO_SURFACE; } } @@ -708,11 +689,10 @@ EGLSurface EGLAPIENTRY GetCurrentSurface(EGLint readdraw) EGLDisplay EGLAPIENTRY GetCurrentDisplay(void) { EVENT("()"); - Thread *thread = GetCurrentThread(); - EGLDisplay dpy = thread->getDisplay(); + EGLDisplay dpy = GetGlobalDisplay(); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return dpy; } @@ -720,7 +700,6 @@ EGLBoolean EGLAPIENTRY QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attri { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)", dpy, ctx, attribute, value); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); gl::Context *context = static_cast<gl::Context*>(ctx); @@ -728,7 +707,7 @@ EGLBoolean EGLAPIENTRY QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attri Error error = ValidateContext(display, context); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } @@ -747,25 +726,24 @@ EGLBoolean EGLAPIENTRY QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attri *value = context->getRenderBuffer(); break; default: - thread->setError(Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); + return EGL_FALSE; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY WaitGL(void) { EVENT("()"); - Thread *thread = GetCurrentThread(); - Display *display = thread->getDisplay(); + Display *display = GetGlobalDisplay(); Error error = ValidateDisplay(display); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } @@ -774,49 +752,47 @@ EGLBoolean EGLAPIENTRY WaitGL(void) error = display->waitClient(); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY WaitNative(EGLint engine) { EVENT("(EGLint engine = %d)", engine); - Thread *thread = GetCurrentThread(); - Display *display = thread->getDisplay(); + Display *display = GetGlobalDisplay(); Error error = ValidateDisplay(display); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (engine != EGL_CORE_NATIVE_ENGINE) { - thread->setError( + SetGlobalError( Error(EGL_BAD_PARAMETER, "the 'engine' parameter has an unrecognized value")); } - error = display->waitNative(engine, thread->getDrawSurface(), thread->getReadSurface()); + error = display->waitNative(engine, GetGlobalDrawSurface(), GetGlobalReadSurface()); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = (Surface*)surface; @@ -824,37 +800,36 @@ EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface) Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (display->testDeviceLost()) { - thread->setError(Error(EGL_CONTEXT_LOST)); + SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { - thread->setError(Error(EGL_BAD_SURFACE)); + SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } error = eglSurface->swap(); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLNativePixmapType target = 0x%0.8p)", dpy, surface, target); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); @@ -862,19 +837,19 @@ EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNative Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (display->testDeviceLost()) { - thread->setError(Error(EGL_CONTEXT_LOST)); + SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } UNIMPLEMENTED(); // FIXME - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return 0; } @@ -882,7 +857,6 @@ EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNative EGLBoolean EGLAPIENTRY BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); @@ -890,35 +864,35 @@ EGLBoolean EGLAPIENTRY BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint b Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (buffer != EGL_BACK_BUFFER) { - thread->setError(Error(EGL_BAD_PARAMETER)); + SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE || eglSurface->getType() == EGL_WINDOW_BIT) { - thread->setError(Error(EGL_BAD_SURFACE)); + SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } if (eglSurface->getBoundTexture()) { - thread->setError(Error(EGL_BAD_ACCESS)); + SetGlobalError(Error(EGL_BAD_ACCESS)); return EGL_FALSE; } if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) { - thread->setError(Error(EGL_BAD_MATCH)); + SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } - gl::Context *context = thread->getContext(); + gl::Context *context = GetGlobalContext(); if (context) { gl::Texture *textureObject = context->getTargetTexture(GL_TEXTURE_2D); @@ -926,19 +900,19 @@ EGLBoolean EGLAPIENTRY BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint b if (textureObject->getImmutableFormat()) { - thread->setError(Error(EGL_BAD_MATCH)); + SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } error = eglSurface->bindTexImage(textureObject, buffer); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } @@ -946,7 +920,6 @@ EGLBoolean EGLAPIENTRY SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint value = %d)", dpy, surface, attribute, value); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); @@ -954,20 +927,19 @@ EGLBoolean EGLAPIENTRY SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } UNIMPLEMENTED(); // FIXME - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); @@ -975,25 +947,25 @@ EGLBoolean EGLAPIENTRY ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLin Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (buffer != EGL_BACK_BUFFER) { - thread->setError(Error(EGL_BAD_PARAMETER)); + SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE || eglSurface->getType() == EGL_WINDOW_BIT) { - thread->setError(Error(EGL_BAD_SURFACE)); + SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) { - thread->setError(Error(EGL_BAD_MATCH)); + SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } @@ -1004,34 +976,33 @@ EGLBoolean EGLAPIENTRY ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLin error = eglSurface->releaseTexImage(buffer); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY SwapInterval(EGLDisplay dpy, EGLint interval) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint interval = %d)", dpy, interval); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Error error = ValidateDisplay(display); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - Surface *draw_surface = static_cast<Surface *>(thread->getDrawSurface()); + Surface *draw_surface = static_cast<Surface*>(GetGlobalDrawSurface()); if (draw_surface == NULL) { - thread->setError(Error(EGL_BAD_SURFACE)); + SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } @@ -1040,7 +1011,7 @@ EGLBoolean EGLAPIENTRY SwapInterval(EGLDisplay dpy, EGLint interval) draw_surface->setSwapInterval(clampedInterval); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } @@ -1049,35 +1020,33 @@ EGLBoolean EGLAPIENTRY SwapInterval(EGLDisplay dpy, EGLint interval) EGLBoolean EGLAPIENTRY BindAPI(EGLenum api) { EVENT("(EGLenum api = 0x%X)", api); - Thread *thread = GetCurrentThread(); switch (api) { case EGL_OPENGL_API: case EGL_OPENVG_API: - thread->setError(Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; // Not supported by this implementation + SetGlobalError(Error(EGL_BAD_PARAMETER)); + return EGL_FALSE; // Not supported by this implementation case EGL_OPENGL_ES_API: break; default: - thread->setError(Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; + SetGlobalError(Error(EGL_BAD_PARAMETER)); + return EGL_FALSE; } - thread->setAPI(api); + SetGlobalAPI(api); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLenum EGLAPIENTRY QueryAPI(void) { EVENT("()"); - Thread *thread = GetCurrentThread(); - EGLenum API = thread->getAPI(); + EGLenum API = GetGlobalAPI(); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return API; } @@ -1086,7 +1055,6 @@ EGLSurface EGLAPIENTRY CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buf EVENT("(EGLDisplay dpy = 0x%0.8p, EGLenum buftype = 0x%X, EGLClientBuffer buffer = 0x%0.8p, " "EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)", dpy, buftype, buffer, config, attrib_list); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Config *configuration = static_cast<Config*>(config); @@ -1095,16 +1063,15 @@ EGLSurface EGLAPIENTRY CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buf Error error = ValidateCreatePbufferFromClientBuffer(display, buftype, buffer, configuration, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_SURFACE; } egl::Surface *surface = nullptr; - error = display->createPbufferFromClientBuffer(configuration, buftype, buffer, attributes, - &surface); + error = display->createPbufferFromClientBuffer(configuration, buffer, attributes, &surface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_SURFACE; } @@ -1114,36 +1081,34 @@ EGLSurface EGLAPIENTRY CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buf EGLBoolean EGLAPIENTRY ReleaseThread(void) { EVENT("()"); - Thread *thread = GetCurrentThread(); MakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } EGLBoolean EGLAPIENTRY WaitClient(void) { EVENT("()"); - Thread *thread = GetCurrentThread(); - Display *display = thread->getDisplay(); + Display *display = GetGlobalDisplay(); Error error = ValidateDisplay(display); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } error = display->waitClient(); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } @@ -1151,11 +1116,10 @@ EGLBoolean EGLAPIENTRY WaitClient(void) EGLContext EGLAPIENTRY GetCurrentContext(void) { EVENT("()"); - Thread *thread = GetCurrentThread(); - gl::Context *context = thread->getContext(); + gl::Context *context = GetGlobalContext(); - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return static_cast<EGLContext>(context); } @@ -1163,40 +1127,32 @@ EGLContext EGLAPIENTRY GetCurrentContext(void) EGLSync EGLAPIENTRY CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLenum type = 0x%X, const EGLint* attrib_list = 0x%0.8p)", dpy, type, attrib_list); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglCreateSync unimplemented.")); return EGL_NO_SYNC; } EGLBoolean EGLAPIENTRY DestroySync(EGLDisplay dpy, EGLSync sync) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSync sync = 0x%0.8p)", dpy, sync); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglDestroySync unimplemented.")); return EGL_FALSE; } EGLint EGLAPIENTRY ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSync sync = 0x%0.8p, EGLint flags = 0x%X, EGLTime timeout = %d)", dpy, sync, flags, timeout); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglClientWaitSync unimplemented.")); return 0; } EGLBoolean EGLAPIENTRY GetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSync sync = 0x%0.8p, EGLint attribute = 0x%X, EGLAttrib *value = 0x%0.8p)", dpy, sync, attribute, value); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglSyncAttrib unimplemented.")); return EGL_FALSE; } @@ -1205,20 +1161,16 @@ EGLImage EGLAPIENTRY CreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLenum target = 0x%X, " "EGLClientBuffer buffer = 0x%0.8p, const EGLAttrib *attrib_list = 0x%0.8p)", dpy, ctx, target, buffer, attrib_list); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglCreateImage unimplemented.")); return EGL_NO_IMAGE; } EGLBoolean EGLAPIENTRY DestroyImage(EGLDisplay dpy, EGLImage image) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLImage image = 0x%0.8p)", dpy, image); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglDestroyImage unimplemented.")); return EGL_FALSE; } @@ -1226,10 +1178,8 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplay(EGLenum platform, void *native_display { EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)", platform, native_display, attrib_list); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglGetPlatformDisplay unimplemented.")); return EGL_NO_DISPLAY; } @@ -1237,10 +1187,8 @@ EGLSurface EGLAPIENTRY CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig con { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, void* native_window = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)", dpy, config, native_window, attrib_list); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglCreatePlatformWindowSurface unimplemented.")); return EGL_NO_SURFACE; } @@ -1248,27 +1196,22 @@ EGLSurface EGLAPIENTRY CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig con { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, void* native_pixmap = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)", dpy, config, native_pixmap, attrib_list); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglCraetePlatformPixmaSurface unimplemented.")); return EGL_NO_SURFACE; } EGLBoolean EGLAPIENTRY WaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSync sync = 0x%0.8p, EGLint flags = 0x%X)", dpy, sync, flags); - Thread *thread = GetCurrentThread(); UNIMPLEMENTED(); - thread->setError(Error(EGL_BAD_DISPLAY, "eglWaitSync unimplemented.")); return EGL_FALSE; } __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char *procname) { EVENT("(const char *procname = \"%s\")", procname); - Thread *thread = GetCurrentThread(); typedef std::map<std::string, __eglMustCastToProperFunctionPointerType> ProcAddressMap; auto generateProcAddressMap = []() @@ -1277,9 +1220,6 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char * #define INSERT_PROC_ADDRESS(ns, proc) \ map[#ns #proc] = reinterpret_cast<__eglMustCastToProperFunctionPointerType>(ns::proc) -#define INSERT_PROC_ADDRESS_NO_NS(name, proc) \ - map[name] = reinterpret_cast<__eglMustCastToProperFunctionPointerType>(proc) - // GLES2 core INSERT_PROC_ADDRESS(gl, ActiveTexture); INSERT_PROC_ADDRESS(gl, AttachShader); @@ -1532,74 +1472,6 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char * INSERT_PROC_ADDRESS(gl, CopyTextureCHROMIUM); INSERT_PROC_ADDRESS(gl, CopySubTextureCHROMIUM); - // GL_CHROMIUM_copy_compressed_texture - INSERT_PROC_ADDRESS(gl, CompressedCopyTextureCHROMIUM); - - // GL_ANGLE_webgl_compatibility - INSERT_PROC_ADDRESS(gl, EnableExtensionANGLE); - - // GL_ANGLE_robust_client_memory - INSERT_PROC_ADDRESS(gl, GetBooleanvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetBufferParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetFloatvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetFramebufferAttachmentParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetIntegervRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetProgramivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetRenderbufferParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetShaderivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetTexParameterfvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetTexParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetUniformfvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetUniformivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetVertexAttribfvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetVertexAttribivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetVertexAttribPointervRobustANGLE); - INSERT_PROC_ADDRESS(gl, ReadPixelsRobustANGLE); - INSERT_PROC_ADDRESS(gl, TexImage2DRobustANGLE); - INSERT_PROC_ADDRESS(gl, TexParameterfvRobustANGLE); - INSERT_PROC_ADDRESS(gl, TexParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, TexSubImage2DRobustANGLE); - INSERT_PROC_ADDRESS(gl, TexImage3DRobustANGLE); - INSERT_PROC_ADDRESS(gl, TexSubImage3DRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetQueryivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetQueryObjectuivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetBufferPointervRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetIntegeri_vRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetInternalformativRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetVertexAttribIivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetVertexAttribIuivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetUniformuivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetActiveUniformBlockivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetInteger64vRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetInteger64i_vRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetBufferParameteri64vRobustANGLE); - INSERT_PROC_ADDRESS(gl, SamplerParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, SamplerParameterfvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetSamplerParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetSamplerParameterfvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetFramebufferParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetProgramInterfaceivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetBooleani_vRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetMultisamplefvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetTexLevelParameterivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetTexLevelParameterfvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetPointervRobustANGLERobustANGLE); - INSERT_PROC_ADDRESS(gl, ReadnPixelsRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetnUniformfvRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetnUniformivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetnUniformuivRobustANGLE); - INSERT_PROC_ADDRESS(gl, TexParameterIivRobustANGLE); - INSERT_PROC_ADDRESS(gl, TexParameterIuivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetTexParameterIivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetTexParameterIuivRobustANGLE); - INSERT_PROC_ADDRESS(gl, SamplerParameterIivRobustANGLE); - INSERT_PROC_ADDRESS(gl, SamplerParameterIuivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetSamplerParameterIivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetSamplerParameterIuivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetQueryObjectivRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetQueryObjecti64vRobustANGLE); - INSERT_PROC_ADDRESS(gl, GetQueryObjectui64vRobustANGLE); - // GLES3 core INSERT_PROC_ADDRESS(gl, ReadBuffer); INSERT_PROC_ADDRESS(gl, DrawRangeElements); @@ -1671,8 +1543,8 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char * INSERT_PROC_ADDRESS(gl, UniformBlockBinding); INSERT_PROC_ADDRESS(gl, DrawArraysInstanced); INSERT_PROC_ADDRESS(gl, DrawElementsInstanced); - // FenceSync is the name of a class, the function has an added _ to prevent a name conflict. - INSERT_PROC_ADDRESS_NO_NS("glFenceSync", gl::FenceSync_); + map["glFenceSync"] = + reinterpret_cast<__eglMustCastToProperFunctionPointerType>(gl::FenceSync_); INSERT_PROC_ADDRESS(gl, IsSync); INSERT_PROC_ADDRESS(gl, DeleteSync); INSERT_PROC_ADDRESS(gl, ClientWaitSync); @@ -1872,24 +1744,21 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char * INSERT_PROC_ADDRESS(egl, CreateStreamProducerD3DTextureNV12ANGLE); INSERT_PROC_ADDRESS(egl, StreamPostD3DTextureNV12ANGLE); - // EGL_EXT_swap_buffers_with_damage - INSERT_PROC_ADDRESS(egl, SwapBuffersWithDamageEXT); - - // angle::Platform related entry points - INSERT_PROC_ADDRESS_NO_NS("ANGLEPlatformInitialize", ANGLEPlatformInitialize); - INSERT_PROC_ADDRESS_NO_NS("ANGLEPlatformShutdown", ANGLEPlatformShutdown); - #undef INSERT_PROC_ADDRESS -#undef INSERT_PROC_ADDRESS_NO_NS - return map; }; static const ProcAddressMap procAddressMap = generateProcAddressMap(); - thread->setError(Error(EGL_SUCCESS)); auto iter = procAddressMap.find(procname); - return iter != procAddressMap.end() ? iter->second : nullptr; + if (iter != procAddressMap.end()) + { + return iter->second; + } + else + { + return nullptr; + } } } diff --git a/gfx/angle/src/libGLESv2/entry_points_egl_ext.cpp b/gfx/angle/src/libGLESv2/entry_points_egl_ext.cpp index b18a10d92..3b7a9c870 100755 --- a/gfx/angle/src/libGLESv2/entry_points_egl_ext.cpp +++ b/gfx/angle/src/libGLESv2/entry_points_egl_ext.cpp @@ -14,7 +14,6 @@ #include "libANGLE/Device.h" #include "libANGLE/Surface.h" #include "libANGLE/Stream.h" -#include "libANGLE/Thread.h" #include "libANGLE/validationEGL.h" #include "common/debug.h" @@ -27,7 +26,6 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)", dpy, surface, attribute, value); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); @@ -35,19 +33,19 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (!display->getExtensions().querySurfacePointer) { - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { - thread->setError(Error(EGL_BAD_SURFACE)); + SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } @@ -57,24 +55,24 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE: if (!display->getExtensions().surfaceD3DTexture2DShareHandle) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } break; case EGL_DXGI_KEYED_MUTEX_ANGLE: if (!display->getExtensions().keyedMutex) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } break; default: - thread->setError(Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); + return EGL_FALSE; } error = eglSurface->querySurfacePointerANGLE(attribute, value); - thread->setError(error); + SetGlobalError(error); return (error.isError() ? EGL_FALSE : EGL_TRUE); } @@ -83,11 +81,10 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa EGLBoolean EGLAPIENTRY 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); - Thread *thread = GetCurrentThread(); if (x < 0 || y < 0 || width < 0 || height < 0) { - thread->setError(Error(EGL_BAD_PARAMETER)); + SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } @@ -97,37 +94,37 @@ EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLin Error error = ValidateSurface(display, eglSurface); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (display->testDeviceLost()) { - thread->setError(Error(EGL_CONTEXT_LOST)); + SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { - thread->setError(Error(EGL_BAD_SURFACE)); + SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } if (!display->getExtensions().postSubBuffer) { // Spec is not clear about how this should be handled. - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } error = eglSurface->postSubBuffer(x, y, width, height); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } @@ -136,7 +133,6 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp { EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)", platform, native_display, attrib_list); - Thread *thread = GetCurrentThread(); const ClientExtensions &clientExtensions = Display::getClientExtensions(); @@ -145,20 +141,20 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp case EGL_PLATFORM_ANGLE_ANGLE: if (!clientExtensions.platformANGLE) { - thread->setError(Error(EGL_BAD_PARAMETER)); + SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_NO_DISPLAY; } break; case EGL_PLATFORM_DEVICE_EXT: if (!clientExtensions.platformDevice) { - thread->setError(Error(EGL_BAD_PARAMETER, "Platform Device extension is not active")); + SetGlobalError(Error(EGL_BAD_PARAMETER, "Platform Device extension is not active")); return EGL_NO_DISPLAY; } break; default: - thread->setError(Error(EGL_BAD_CONFIG)); - return EGL_NO_DISPLAY; + SetGlobalError(Error(EGL_BAD_CONFIG)); + return EGL_NO_DISPLAY; } if (platform == EGL_PLATFORM_ANGLE_ANGLE) @@ -187,7 +183,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE: if (!clientExtensions.platformANGLED3D) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_NO_DISPLAY; } break; @@ -196,25 +192,14 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: if (!clientExtensions.platformANGLEOpenGL) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); - return EGL_NO_DISPLAY; - } - break; - - case EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE: - if (!clientExtensions.platformANGLENULL) - { - thread->setError(Error(EGL_BAD_ATTRIBUTE, - "Display type " - "EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE " - "requires EGL_ANGLE_platform_angle_null.")); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_NO_DISPLAY; } break; default: - thread->setError(Error(EGL_BAD_ATTRIBUTE)); - return EGL_NO_DISPLAY; + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); + return EGL_NO_DISPLAY; } platformType = curAttrib[1]; break; @@ -240,8 +225,8 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp case EGL_FALSE: break; default: - thread->setError(Error(EGL_BAD_ATTRIBUTE)); - return EGL_NO_DISPLAY; + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); + return EGL_NO_DISPLAY; } enableAutoTrimSpecified = true; break; @@ -249,7 +234,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp case EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE: if (!clientExtensions.experimentalPresentPath) { - thread->setError( + SetGlobalError( Error(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_experimental_present_path extension not active")); return EGL_NO_DISPLAY; @@ -261,7 +246,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp case EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE: break; default: - thread->setError( + SetGlobalError( Error(EGL_BAD_ATTRIBUTE, "Invalid value for EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE")); return EGL_NO_DISPLAY; @@ -283,10 +268,10 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp break; default: - thread->setError(Error(EGL_BAD_ATTRIBUTE, - "Invalid value for " - "EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE " - "attrib")); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE, + "Invalid value for " + "EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE " + "attrib")); return EGL_NO_DISPLAY; } deviceType = curAttrib[1]; @@ -300,14 +285,14 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp if (!majorVersionSpecified && minorVersionSpecified) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_NO_DISPLAY; } if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) { - thread->setError( + SetGlobalError( Error(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE requires a device type of " "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE.")); @@ -316,7 +301,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp if (enableAutoTrimSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) { - thread->setError( + SetGlobalError( Error(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE requires a device type of " "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE.")); @@ -325,23 +310,23 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp if (presentPathSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) { - thread->setError(Error(EGL_BAD_ATTRIBUTE, - "EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE requires a device type of " - "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE.")); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE, + "EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE requires a device type of " + "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE.")); return EGL_NO_DISPLAY; } if (deviceTypeSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) { - thread->setError( + SetGlobalError( Error(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE requires a device type of " "EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE or EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE.")); return EGL_NO_DISPLAY; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return Display::GetDisplayFromAttribs(native_display, AttributeMap::CreateFromIntArray(attrib_list)); } @@ -350,13 +335,13 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp Device *eglDevice = reinterpret_cast<Device *>(native_display); if (eglDevice == nullptr || !Device::IsValidDevice(eglDevice)) { - thread->setError(Error(EGL_BAD_ATTRIBUTE, - "native_display should be a valid EGL device if platform equals " - "EGL_PLATFORM_DEVICE_EXT")); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE, + "native_display should be a valid EGL device if platform equals " + "EGL_PLATFORM_DEVICE_EXT")); return EGL_NO_DISPLAY; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return Display::GetDisplayFromDevice(native_display); } else @@ -371,12 +356,11 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut { EVENT("(EGLDeviceEXT device = 0x%0.8p, EGLint attribute = %d, EGLAttrib *value = 0x%0.8p)", device, attribute, value); - Thread *thread = GetCurrentThread(); Device *dev = static_cast<Device*>(device); if (dev == EGL_NO_DEVICE_EXT || !Device::IsValidDevice(dev)) { - thread->setError(Error(EGL_BAD_ACCESS)); + SetGlobalError(Error(EGL_BAD_ACCESS)); return EGL_FALSE; } @@ -385,9 +369,9 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut Display *owningDisplay = dev->getOwningDisplay(); if (owningDisplay != nullptr && !owningDisplay->getExtensions().deviceQuery) { - thread->setError(Error(EGL_BAD_ACCESS, - "Device wasn't created using eglCreateDeviceANGLE, and the Display " - "that created it doesn't support device querying")); + SetGlobalError(Error(EGL_BAD_ACCESS, + "Device wasn't created using eglCreateDeviceANGLE, and the Display " + "that created it doesn't support device querying")); return EGL_FALSE; } @@ -400,17 +384,17 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut case EGL_D3D9_DEVICE_ANGLE: if (!dev->getExtensions().deviceD3D || dev->getType() != attribute) { - thread->setError(Error(EGL_BAD_ATTRIBUTE)); + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } error = dev->getDevice(value); break; default: - thread->setError(Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); + return EGL_FALSE; } - thread->setError(error); + SetGlobalError(error); return (error.isError() ? EGL_FALSE : EGL_TRUE); } @@ -419,12 +403,11 @@ const char * EGLAPIENTRY QueryDeviceStringEXT(EGLDeviceEXT device, EGLint name) { EVENT("(EGLDeviceEXT device = 0x%0.8p, EGLint name = %d)", device, name); - Thread *thread = GetCurrentThread(); Device *dev = static_cast<Device*>(device); if (dev == EGL_NO_DEVICE_EXT || !Device::IsValidDevice(dev)) { - thread->setError(Error(EGL_BAD_DEVICE_EXT)); + SetGlobalError(Error(EGL_BAD_DEVICE_EXT)); return nullptr; } @@ -435,11 +418,11 @@ const char * EGLAPIENTRY QueryDeviceStringEXT(EGLDeviceEXT device, EGLint name) result = dev->getExtensionString().c_str(); break; default: - thread->setError(Error(EGL_BAD_DEVICE_EXT)); - return nullptr; + SetGlobalError(Error(EGL_BAD_DEVICE_EXT)); + return nullptr; } - thread->setError(Error(EGL_SUCCESS)); + SetGlobalError(Error(EGL_SUCCESS)); return result; } @@ -448,20 +431,19 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint attribute = %d, EGLAttrib *value = 0x%0.8p)", dpy, attribute, value); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display*>(dpy); Error error = ValidateDisplay(display); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } if (!display->getExtensions().deviceQuery) { - thread->setError(Error(EGL_BAD_ACCESS)); + SetGlobalError(Error(EGL_BAD_ACCESS)); return EGL_FALSE; } @@ -473,11 +455,11 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E break; default: - thread->setError(Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; + SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); + return EGL_FALSE; } - thread->setError(error); + SetGlobalError(error); return (error.isError() ? EGL_FALSE : EGL_TRUE); } @@ -491,7 +473,6 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy, "(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLenum target = 0x%X, " "EGLClientBuffer buffer = 0x%0.8p, const EGLAttrib *attrib_list = 0x%0.8p)", dpy, ctx, target, buffer, attrib_list); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); gl::Context *context = static_cast<gl::Context *>(ctx); @@ -500,7 +481,7 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy, Error error = ValidateCreateImageKHR(display, context, target, buffer, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_IMAGE; } @@ -508,7 +489,7 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy, error = display->createImage(context, target, buffer, attributes, &image); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_IMAGE; } @@ -518,7 +499,6 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy, ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLImage image = 0x%0.8p)", dpy, image); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Image *img = static_cast<Image *>(image); @@ -526,7 +506,7 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyImageKHR(EGLDisplay dpy, EGLImageKHR Error error = ValidateDestroyImageKHR(display, img); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } @@ -543,12 +523,11 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type, "(EGLint device_type = %d, void* native_device = 0x%0.8p, const EGLAttrib* attrib_list = " "0x%0.8p)", device_type, native_device, attrib_list); - Thread *thread = GetCurrentThread(); Error error = ValidateCreateDeviceANGLE(device_type, native_device, attrib_list); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_DEVICE_EXT; } @@ -557,7 +536,7 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type, if (error.isError()) { ASSERT(device == nullptr); - thread->setError(error); + SetGlobalError(error); return EGL_NO_DEVICE_EXT; } @@ -567,14 +546,13 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type, ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseDeviceANGLE(EGLDeviceEXT device) { EVENT("(EGLDeviceEXT device = 0x%0.8p)", device); - Thread *thread = GetCurrentThread(); Device *dev = static_cast<Device *>(device); Error error = ValidateReleaseDeviceANGLE(dev); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } @@ -587,7 +565,6 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseDeviceANGLE(EGLDeviceEXT device) EGLStreamKHR EGLAPIENTRY CreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list) { EVENT("(EGLDisplay dpy = 0x%0.8p, const EGLAttrib* attrib_list = 0x%0.8p)", dpy, attrib_list); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); AttributeMap attributes = AttributeMap::CreateFromIntArray(attrib_list); @@ -595,7 +572,7 @@ EGLStreamKHR EGLAPIENTRY CreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_li Error error = ValidateCreateStreamKHR(display, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_STREAM_KHR; } @@ -603,18 +580,17 @@ EGLStreamKHR EGLAPIENTRY CreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_li error = display->createStream(attributes, &stream); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_NO_STREAM_KHR; } - thread->setError(error); + SetGlobalError(error); return static_cast<EGLStreamKHR>(stream); } EGLBoolean EGLAPIENTRY DestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, stream); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); @@ -622,12 +598,12 @@ EGLBoolean EGLAPIENTRY DestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream) Error error = ValidateDestroyStreamKHR(display, streamObject); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } display->destroyStream(streamObject); - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } @@ -640,7 +616,6 @@ EGLBoolean EGLAPIENTRY StreamAttribKHR(EGLDisplay dpy, "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, " "EGLint value = 0x%X)", dpy, stream, attribute, value); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); @@ -648,7 +623,7 @@ EGLBoolean EGLAPIENTRY StreamAttribKHR(EGLDisplay dpy, Error error = ValidateStreamAttribKHR(display, streamObject, attribute, value); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } @@ -664,7 +639,7 @@ EGLBoolean EGLAPIENTRY StreamAttribKHR(EGLDisplay dpy, UNREACHABLE(); } - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } @@ -677,7 +652,6 @@ EGLBoolean EGLAPIENTRY QueryStreamKHR(EGLDisplay dpy, "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, " "EGLint value = 0x%0.8p)", dpy, stream, attribute, value); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); @@ -685,7 +659,7 @@ EGLBoolean EGLAPIENTRY QueryStreamKHR(EGLDisplay dpy, Error error = ValidateQueryStreamKHR(display, streamObject, attribute, value); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } @@ -704,7 +678,7 @@ EGLBoolean EGLAPIENTRY QueryStreamKHR(EGLDisplay dpy, UNREACHABLE(); } - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } @@ -717,7 +691,6 @@ EGLBoolean EGLAPIENTRY QueryStreamu64KHR(EGLDisplay dpy, "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, " "EGLuint64KHR value = 0x%0.8p)", dpy, stream, attribute, value); - Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); @@ -725,7 +698,7 @@ EGLBoolean EGLAPIENTRY QueryStreamu64KHR(EGLDisplay dpy, Error error = ValidateQueryStreamu64KHR(display, streamObject, attribute, value); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } @@ -741,15 +714,13 @@ EGLBoolean EGLAPIENTRY QueryStreamu64KHR(EGLDisplay dpy, UNREACHABLE(); } - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, stream); - Thread *thread = GetCurrentThread(); - Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); gl::Context *context = gl::GetValidGlobalContext(); @@ -757,26 +728,24 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStr Error error = ValidateStreamConsumerGLTextureExternalKHR(display, context, streamObject); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } error = streamObject->createConsumerGLTextureExternal(AttributeMap(), context); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } EGLBoolean EGLAPIENTRY StreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, stream); - Thread *thread = GetCurrentThread(); - Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); gl::Context *context = gl::GetValidGlobalContext(); @@ -784,26 +753,24 @@ EGLBoolean EGLAPIENTRY StreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR str Error error = ValidateStreamConsumerAcquireKHR(display, context, streamObject); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } error = streamObject->consumerAcquire(); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } EGLBoolean EGLAPIENTRY StreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, stream); - Thread *thread = GetCurrentThread(); - Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); gl::Context *context = gl::GetValidGlobalContext(); @@ -811,18 +778,18 @@ EGLBoolean EGLAPIENTRY StreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR str Error error = ValidateStreamConsumerReleaseKHR(display, context, streamObject); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } error = streamObject->consumerRelease(); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } @@ -833,8 +800,6 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLAttrib attrib_list = 0x%0.8p", dpy, stream, attrib_list); - Thread *thread = GetCurrentThread(); - Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); gl::Context *context = gl::GetValidGlobalContext(); @@ -844,18 +809,18 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } error = streamObject->createConsumerGLTextureExternal(attributes, context); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } @@ -866,8 +831,6 @@ EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLAttrib attrib_list = 0x%0.8p", dpy, stream, attrib_list); - Thread *thread = GetCurrentThread(); - Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list); @@ -876,18 +839,18 @@ EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, ValidateCreateStreamProducerD3DTextureNV12ANGLE(display, streamObject, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } error = streamObject->createProducerD3D11TextureNV12(attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } - thread->setError(error); + SetGlobalError(error); return EGL_TRUE; } @@ -900,8 +863,6 @@ EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, void* texture = 0x%0.8p, " "EGLAttrib attrib_list = 0x%0.8p", dpy, stream, texture, attrib_list); - Thread *thread = GetCurrentThread(); - Display *display = static_cast<Display *>(dpy); Stream *streamObject = static_cast<Stream *>(stream); AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list); @@ -909,49 +870,18 @@ EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, Error error = ValidateStreamPostD3DTextureNV12ANGLE(display, streamObject, texture, attributes); if (error.isError()) { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } error = streamObject->postD3D11NV12Texture(texture, attributes); if (error.isError()) { - thread->setError(error); - return EGL_FALSE; - } - - thread->setError(error); - return EGL_TRUE; -} - -ANGLE_EXPORT EGLBoolean SwapBuffersWithDamageEXT(EGLDisplay dpy, - EGLSurface surface, - EGLint *rects, - EGLint n_rects) -{ - EVENT( - "(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint *rects = 0x%0.8p, EGLint " - "n_rects = %d)", - dpy, surface, rects, n_rects); - Thread *thread = GetCurrentThread(); - - Display *display = static_cast<Display *>(dpy); - Surface *eglSurface = static_cast<Surface *>(surface); - - Error error = ValidateSwapBuffersWithDamageEXT(display, eglSurface, rects, n_rects); - if (error.isError()) - { - thread->setError(error); - return EGL_FALSE; - } - - error = eglSurface->swapWithDamage(rects, n_rects); - if (error.isError()) - { - thread->setError(error); + SetGlobalError(error); return EGL_FALSE; } + SetGlobalError(error); return EGL_TRUE; } } diff --git a/gfx/angle/src/libGLESv2/entry_points_egl_ext.h b/gfx/angle/src/libGLESv2/entry_points_egl_ext.h index eb57ad05e..4ec0450bf 100755 --- a/gfx/angle/src/libGLESv2/entry_points_egl_ext.h +++ b/gfx/angle/src/libGLESv2/entry_points_egl_ext.h @@ -79,13 +79,6 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy EGLStreamKHR stream, void *texture, const EGLAttrib *attrib_list); - -// EGL_EXT_swap_buffers_with_damage -ANGLE_EXPORT EGLBoolean SwapBuffersWithDamageEXT(EGLDisplay dpy, - EGLSurface surface, - EGLint *rects, - EGLint n_rects); - } // namespace egl #endif // LIBGLESV2_ENTRYPOINTSEGLEXT_H_ diff --git a/gfx/angle/src/libGLESv2/entry_points_gles_2_0.cpp b/gfx/angle/src/libGLESv2/entry_points_gles_2_0.cpp index ca6129800..c3e9ad875 100755 --- a/gfx/angle/src/libGLESv2/entry_points_gles_2_0.cpp +++ b/gfx/angle/src/libGLESv2/entry_points_gles_2_0.cpp @@ -28,7 +28,6 @@ #include "libANGLE/validationES2.h" #include "libANGLE/validationES3.h" #include "libANGLE/queryconversions.h" -#include "libANGLE/queryutils.h" #include "common/debug.h" #include "common/utilities.h" @@ -44,8 +43,9 @@ void GL_APIENTRY ActiveTexture(GLenum texture) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateActiveTexture(context, texture)) + if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1) { + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -60,12 +60,23 @@ void GL_APIENTRY AttachShader(GLuint program, GLuint shader) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateAttachShader(context, program, shader)) + Program *programObject = GetValidProgram(context, program); + if (!programObject) { return; } - context->attachShader(program, shader); + Shader *shaderObject = GetValidShader(context, shader); + if (!shaderObject) + { + return; + } + + if (!programObject->attachShader(shaderObject)) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } } } @@ -76,13 +87,26 @@ void GL_APIENTRY BindAttribLocation(GLuint program, GLuint index, const GLchar* Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateBindAttribLocation(context, program, index, name)) + if (index >= MAX_VERTEX_ATTRIBS) { + context->handleError(Error(GL_INVALID_VALUE)); return; } - context->bindAttribLocation(program, index, name); + Program *programObject = GetValidProgram(context, program); + + if (!programObject) + { + return; + } + + if (strncmp(name, "gl_", 3) == 0) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + programObject->bindAttributeLocation(index, name); } } @@ -93,12 +117,43 @@ void GL_APIENTRY BindBuffer(GLenum target, GLuint buffer) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateBindBuffer(context, target, buffer)) + if (!ValidBufferTarget(context, target)) { + context->handleError(Error(GL_INVALID_ENUM)); return; } - context->bindBuffer(target, buffer); + switch (target) + { + case GL_ARRAY_BUFFER: + context->bindArrayBuffer(buffer); + return; + case GL_ELEMENT_ARRAY_BUFFER: + context->bindElementArrayBuffer(buffer); + return; + case GL_COPY_READ_BUFFER: + context->bindCopyReadBuffer(buffer); + return; + case GL_COPY_WRITE_BUFFER: + context->bindCopyWriteBuffer(buffer); + return; + case GL_PIXEL_PACK_BUFFER: + context->bindPixelPackBuffer(buffer); + return; + case GL_PIXEL_UNPACK_BUFFER: + context->bindPixelUnpackBuffer(buffer); + return; + case GL_UNIFORM_BUFFER: + context->bindGenericUniformBuffer(buffer); + return; + case GL_TRANSFORM_FEEDBACK_BUFFER: + context->bindGenericTransformFeedbackBuffer(buffer); + return; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } } } @@ -109,12 +164,21 @@ void GL_APIENTRY BindFramebuffer(GLenum target, GLuint framebuffer) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateBindFramebuffer(context, target, framebuffer)) + if (!ValidFramebufferTarget(target)) { + context->handleError(Error(GL_INVALID_ENUM)); return; } - context->bindFramebuffer(target, framebuffer); + if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) + { + context->bindReadFramebuffer(framebuffer); + } + + if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) + { + context->bindDrawFramebuffer(framebuffer); + } } } @@ -125,12 +189,13 @@ void GL_APIENTRY BindRenderbuffer(GLenum target, GLuint renderbuffer) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateBindRenderbuffer(context, target, renderbuffer)) + if (target != GL_RENDERBUFFER) { + context->handleError(Error(GL_INVALID_ENUM)); return; } - context->bindRenderbuffer(target, renderbuffer); + context->bindRenderbuffer(renderbuffer); } } @@ -141,7 +206,7 @@ void GL_APIENTRY BindTexture(GLenum target, GLuint texture) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateBindTexture(context, target, texture)) + if (!ValidateBindTexture(context, target, texture)) { return; } @@ -164,18 +229,7 @@ void GL_APIENTRY BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclamp void GL_APIENTRY BlendEquation(GLenum mode) { - EVENT("(GLenum mode = 0x%X)", mode); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!context->skipValidation() && !ValidateBlendEquation(context, mode)) - { - return; - } - - context->blendEquation(mode); - } + BlendEquationSeparate(mode, mode); } void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) @@ -185,9 +239,31 @@ void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateBlendEquationSeparate(context, modeRGB, modeAlpha)) + switch (modeRGB) { + case GL_FUNC_ADD: + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + case GL_MIN: + case GL_MAX: + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + switch (modeAlpha) + { + case GL_FUNC_ADD: + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + case GL_MIN: + case GL_MAX: + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -197,18 +273,7 @@ void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) void GL_APIENTRY BlendFunc(GLenum sfactor, GLenum dfactor) { - EVENT("(GLenum sfactor = 0x%X, GLenum dfactor = 0x%X)", sfactor, dfactor); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!context->skipValidation() && !ValidateBlendFunc(context, sfactor, dfactor)) - { - return; - } - - context->blendFunc(sfactor, dfactor); - } + BlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); } void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) @@ -219,10 +284,135 @@ void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateBlendFuncSeparate(context, srcRGB, dstRGB, srcAlpha, dstAlpha)) + switch (srcRGB) { - return; + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + switch (dstRGB) + { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + + case GL_SRC_ALPHA_SATURATE: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + switch (srcAlpha) + { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + switch (dstAlpha) + { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + + case GL_SRC_ALPHA_SATURATE: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + if (context->getLimitations().noSimultaneousConstantColorAndAlphaBlendFunc) + { + bool constantColorUsed = + (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || + dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); + + bool constantAlphaUsed = + (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || + dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); + + if (constantColorUsed && constantAlphaUsed) + { + ERR( + "Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and " + "GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR not supported by this " + "implementation."); + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } } context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); @@ -237,12 +427,57 @@ void GL_APIENTRY BufferData(GLenum target, GLsizeiptr size, const GLvoid* data, Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateBufferData(context, target, size, data, usage)) + if (size < 0) + { + context->handleError(Error(GL_INVALID_VALUE)); + return; + } + + switch (usage) + { + case GL_STREAM_DRAW: + case GL_STATIC_DRAW: + case GL_DYNAMIC_DRAW: + break; + + case GL_STREAM_READ: + case GL_STREAM_COPY: + case GL_STATIC_READ: + case GL_STATIC_COPY: + case GL_DYNAMIC_READ: + case GL_DYNAMIC_COPY: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + if (!ValidBufferTarget(context, target)) { + context->handleError(Error(GL_INVALID_ENUM)); return; } - context->bufferData(target, size, data, usage); + Buffer *buffer = context->getGLState().getTargetBuffer(target); + + if (!buffer) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + Error error = buffer->bufferData(data, size, usage); + if (error.isError()) + { + context->handleError(error); + return; + } } } @@ -254,13 +489,58 @@ void GL_APIENTRY BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateBufferSubData(context, target, offset, size, data)) + if (size < 0 || offset < 0) + { + context->handleError(Error(GL_INVALID_VALUE)); + return; + } + + if (!ValidBufferTarget(context, target)) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + Buffer *buffer = context->getGLState().getTargetBuffer(target); + + if (!buffer) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + if (buffer->isMapped()) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + // Check for possible overflow of size + offset + angle::CheckedNumeric<size_t> checkedSize(size); + checkedSize += offset; + if (!checkedSize.IsValid()) + { + context->handleError(Error(GL_OUT_OF_MEMORY)); + return; + } + + if (size + offset > buffer->getSize()) + { + context->handleError(Error(GL_INVALID_VALUE)); + return; + } + + if (data == NULL) { return; } - context->bufferSubData(target, offset, size, data); + Error error = buffer->bufferSubData(data, size, offset); + if (error.isError()) + { + context->handleError(error); + return; + } } } @@ -360,7 +640,7 @@ void GL_APIENTRY CompileShader(GLuint shader) { return; } - shaderObject->compile(context); + shaderObject->compile(context->getCompiler()); } } @@ -727,8 +1007,9 @@ void GL_APIENTRY Disable(GLenum cap) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateDisable(context, cap)) + if (!ValidCap(context, cap)) { + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -760,7 +1041,7 @@ void GL_APIENTRY DrawArrays(GLenum mode, GLint first, GLsizei count) Context *context = GetValidGlobalContext(); if (context) { - if (!ValidateDrawArrays(context, mode, first, count, 1)) + if (!ValidateDrawArrays(context, mode, first, count, 0)) { return; } @@ -783,7 +1064,7 @@ void GL_APIENTRY DrawElements(GLenum mode, GLsizei count, GLenum type, const GLv if (context) { IndexRange indexRange; - if (!ValidateDrawElements(context, mode, count, type, indices, 1, &indexRange)) + if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange)) { return; } @@ -804,11 +1085,26 @@ void GL_APIENTRY Enable(GLenum cap) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateEnable(context, cap)) + if (!ValidCap(context, cap)) { + context->handleError(Error(GL_INVALID_ENUM)); return; } + if (context->getLimitations().noSampleAlphaToCoverageSupport) + { + if (cap == GL_SAMPLE_ALPHA_TO_COVERAGE) + { + const char *errorMessage = "Current renderer doesn't support alpha-to-coverage"; + context->handleError(Error(GL_INVALID_OPERATION, errorMessage)); + + // We also output an error message to the debugger window if tracing is active, so that developers can see the error message. + ERR("%s", errorMessage); + + return; + } + } + context->enable(cap); } } @@ -1160,14 +1456,53 @@ void GL_APIENTRY GetBufferParameteriv(GLenum target, GLenum pname, GLint* params Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetBufferParameteriv(context, target, pname, params)) + if (!ValidBufferTarget(context, target)) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + if (!ValidBufferParameter(context, pname)) { + context->handleError(Error(GL_INVALID_ENUM)); return; } Buffer *buffer = context->getGLState().getTargetBuffer(target); - QueryBufferParameteriv(buffer, pname, params); + + if (!buffer) + { + // A null buffer means that "0" is bound to the requested buffer target + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + switch (pname) + { + case GL_BUFFER_USAGE: + *params = static_cast<GLint>(buffer->getUsage()); + break; + case GL_BUFFER_SIZE: + *params = clampCast<GLint>(buffer->getSize()); + break; + case GL_BUFFER_ACCESS_FLAGS: + *params = buffer->getAccessFlags(); + break; + case GL_BUFFER_ACCESS_OES: + *params = buffer->getAccess(); + break; + case GL_BUFFER_MAPPED: + static_assert(GL_BUFFER_MAPPED == GL_BUFFER_MAPPED_OES, "GL enums should be equal."); + *params = static_cast<GLint>(buffer->isMapped()); + break; + case GL_BUFFER_MAP_OFFSET: + *params = clampCast<GLint>(buffer->getMapOffset()); + break; + case GL_BUFFER_MAP_LENGTH: + *params = clampCast<GLint>(buffer->getMapLength()); + break; + default: UNREACHABLE(); break; + } } } @@ -1218,16 +1553,259 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!context->skipValidation() && - !ValidateGetFramebufferAttachmentParameteriv(context, target, attachment, pname, - &numParams)) + if (!ValidFramebufferTarget(target)) { + context->handleError(Error(GL_INVALID_ENUM)); return; } + int clientVersion = context->getClientMajorVersion(); + + switch (pname) + { + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: + break; + + case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: + if (clientVersion < 3 && !context->getExtensions().sRGB) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + break; + + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: + if (clientVersion < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + // Determine if the attachment is a valid enum + switch (attachment) + { + case GL_BACK: + case GL_FRONT: + case GL_DEPTH: + case GL_STENCIL: + case GL_DEPTH_STENCIL_ATTACHMENT: + if (clientVersion < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + break; + + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + + default: + if (attachment < GL_COLOR_ATTACHMENT0_EXT || + (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + break; + } + const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target); - QueryFramebufferAttachmentParameteriv(framebuffer, attachment, pname, params); + ASSERT(framebuffer); + + if (framebuffer->id() == 0) + { + if (clientVersion < 3) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + switch (attachment) + { + case GL_BACK: + case GL_DEPTH: + case GL_STENCIL: + break; + + default: + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + } + else + { + if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) + { + // Valid attachment query + } + else + { + switch (attachment) + { + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + + case GL_DEPTH_STENCIL_ATTACHMENT: + if (!framebuffer->hasValidDepthStencil()) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + break; + + default: + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + } + } + + const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment); + if (attachmentObject) + { + ASSERT(attachmentObject->type() == GL_RENDERBUFFER || + attachmentObject->type() == GL_TEXTURE || + attachmentObject->type() == GL_FRAMEBUFFER_DEFAULT); + + switch (pname) + { + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: + *params = attachmentObject->type(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: + if (attachmentObject->type() != GL_RENDERBUFFER && attachmentObject->type() != GL_TEXTURE) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = attachmentObject->id(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: + if (attachmentObject->type() != GL_TEXTURE) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = attachmentObject->mipLevel(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: + if (attachmentObject->type() != GL_TEXTURE) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = attachmentObject->cubeMapFace(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + *params = attachmentObject->getRedSize(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + *params = attachmentObject->getGreenSize(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + *params = attachmentObject->getBlueSize(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + *params = attachmentObject->getAlphaSize(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + *params = attachmentObject->getDepthSize(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + *params = attachmentObject->getStencilSize(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + *params = attachmentObject->getComponentType(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: + *params = attachmentObject->getColorEncoding(); + break; + + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: + if (attachmentObject->type() != GL_TEXTURE) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = attachmentObject->layer(); + break; + + default: + UNREACHABLE(); + break; + } + } + else + { + // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE + // is NONE, then querying any other pname will generate INVALID_ENUM. + + // ES 3.0.2 spec pg 235 states that if the attachment type is none, + // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an + // INVALID_OPERATION for all other pnames + + switch (pname) + { + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: + *params = GL_NONE; + break; + + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: + if (clientVersion < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = 0; + break; + + default: + if (clientVersion < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + else + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + } + } } } @@ -1264,15 +1842,83 @@ void GL_APIENTRY GetProgramiv(GLuint program, GLenum pname, GLint* params) Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!context->skipValidation() && - !ValidateGetProgramiv(context, program, pname, &numParams)) + Program *programObject = GetValidProgram(context, program); + + if (!programObject) { return; } - Program *programObject = context->getProgram(program); - QueryProgramiv(programObject, pname, params); + if (context->getClientMajorVersion() < 3) + { + switch (pname) + { + case GL_ACTIVE_UNIFORM_BLOCKS: + case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: + case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: + case GL_TRANSFORM_FEEDBACK_VARYINGS: + case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: + case GL_PROGRAM_BINARY_RETRIEVABLE_HINT: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + } + + switch (pname) + { + case GL_DELETE_STATUS: + *params = programObject->isFlaggedForDeletion(); + return; + case GL_LINK_STATUS: + *params = programObject->isLinked(); + return; + case GL_VALIDATE_STATUS: + *params = programObject->isValidated(); + return; + case GL_INFO_LOG_LENGTH: + *params = programObject->getInfoLogLength(); + return; + case GL_ATTACHED_SHADERS: + *params = programObject->getAttachedShadersCount(); + return; + case GL_ACTIVE_ATTRIBUTES: + *params = programObject->getActiveAttributeCount(); + return; + case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: + *params = programObject->getActiveAttributeMaxLength(); + return; + case GL_ACTIVE_UNIFORMS: + *params = programObject->getActiveUniformCount(); + return; + case GL_ACTIVE_UNIFORM_MAX_LENGTH: + *params = programObject->getActiveUniformMaxLength(); + return; + case GL_PROGRAM_BINARY_LENGTH_OES: + *params = programObject->getBinaryLength(); + return; + case GL_ACTIVE_UNIFORM_BLOCKS: + *params = programObject->getActiveUniformBlockCount(); + return; + case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: + *params = programObject->getActiveUniformBlockMaxLength(); + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: + *params = programObject->getTransformFeedbackBufferMode(); + break; + case GL_TRANSFORM_FEEDBACK_VARYINGS: + *params = programObject->getTransformFeedbackVaryingCount(); + break; + case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: + *params = programObject->getTransformFeedbackVaryingMaxLength(); + break; + case GL_PROGRAM_BINARY_RETRIEVABLE_HINT: + *params = programObject->getBinaryRetrievableHint(); + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } } } @@ -1307,14 +1953,64 @@ void GL_APIENTRY GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetRenderbufferParameteriv(context, target, pname, params)) + if (target != GL_RENDERBUFFER) { + context->handleError(Error(GL_INVALID_ENUM)); return; } - Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer(); - QueryRenderbufferiv(renderbuffer, pname, params); + if (context->getGLState().getRenderbufferId() == 0) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + Renderbuffer *renderbuffer = + context->getRenderbuffer(context->getGLState().getRenderbufferId()); + + switch (pname) + { + case GL_RENDERBUFFER_WIDTH: + *params = renderbuffer->getWidth(); + break; + case GL_RENDERBUFFER_HEIGHT: + *params = renderbuffer->getHeight(); + break; + case GL_RENDERBUFFER_INTERNAL_FORMAT: + *params = renderbuffer->getFormat().info->internalFormat; + break; + case GL_RENDERBUFFER_RED_SIZE: + *params = renderbuffer->getRedSize(); + break; + case GL_RENDERBUFFER_GREEN_SIZE: + *params = renderbuffer->getGreenSize(); + break; + case GL_RENDERBUFFER_BLUE_SIZE: + *params = renderbuffer->getBlueSize(); + break; + case GL_RENDERBUFFER_ALPHA_SIZE: + *params = renderbuffer->getAlphaSize(); + break; + case GL_RENDERBUFFER_DEPTH_SIZE: + *params = renderbuffer->getDepthSize(); + break; + case GL_RENDERBUFFER_STENCIL_SIZE: + *params = renderbuffer->getStencilSize(); + break; + + case GL_RENDERBUFFER_SAMPLES_ANGLE: + if (!context->getExtensions().framebufferMultisample) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = renderbuffer->getSamples(); + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } } } @@ -1325,13 +2021,37 @@ void GL_APIENTRY GetShaderiv(GLuint shader, GLenum pname, GLint* params) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateGetShaderiv(context, shader, pname, params)) + Shader *shaderObject = GetValidShader(context, shader); + if (!shaderObject) { return; } - Shader *shaderObject = context->getShader(shader); - QueryShaderiv(shaderObject, pname, params); + switch (pname) + { + case GL_SHADER_TYPE: + *params = shaderObject->getType(); + return; + case GL_DELETE_STATUS: + *params = shaderObject->isFlaggedForDeletion(); + return; + case GL_COMPILE_STATUS: + *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; + return; + case GL_INFO_LOG_LENGTH: + *params = shaderObject->getInfoLogLength(); + return; + case GL_SHADER_SOURCE_LENGTH: + *params = shaderObject->getSourceLength(); + return; + case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: + *params = shaderObject->getTranslatedSourceWithDebugInfoLength(); + return; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } } } @@ -1471,7 +2191,7 @@ const GLubyte *GL_APIENTRY GetString(GLenum name) return reinterpret_cast<const GLubyte *>("Google Inc."); case GL_RENDERER: - return reinterpret_cast<const GLubyte *>(context->getRendererString()); + return reinterpret_cast<const GLubyte *>(context->getRendererString().c_str()); case GL_VERSION: if (context->getClientMajorVersion() == 2) @@ -1498,7 +2218,7 @@ const GLubyte *GL_APIENTRY GetString(GLenum name) } case GL_EXTENSIONS: - return reinterpret_cast<const GLubyte *>(context->getExtensionString()); + return reinterpret_cast<const GLubyte *>(context->getExtensionString().c_str()); default: context->handleError(Error(GL_INVALID_ENUM)); @@ -1516,14 +2236,153 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetTexParameterfv(context, target, pname, params)) + if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) { + context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); return; } Texture *texture = context->getTargetTexture(target); - QueryTexParameterfv(texture, pname, params); + + if (!texture) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + switch (pname) + { + case GL_TEXTURE_MAG_FILTER: + *params = (GLfloat)texture->getMagFilter(); + break; + case GL_TEXTURE_MIN_FILTER: + *params = (GLfloat)texture->getMinFilter(); + break; + case GL_TEXTURE_WRAP_S: + *params = (GLfloat)texture->getWrapS(); + break; + case GL_TEXTURE_WRAP_T: + *params = (GLfloat)texture->getWrapT(); + break; + case GL_TEXTURE_WRAP_R: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getWrapR(); + break; + case GL_TEXTURE_IMMUTABLE_FORMAT: + // Exposed to ES2.0 through EXT_texture_storage, no client version validation. + *params = (GLfloat)(texture->getImmutableFormat() ? GL_TRUE : GL_FALSE); + break; + case GL_TEXTURE_IMMUTABLE_LEVELS: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getImmutableLevels(); + break; + case GL_TEXTURE_USAGE_ANGLE: + *params = (GLfloat)texture->getUsage(); + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (!context->getExtensions().textureFilterAnisotropic) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getMaxAnisotropy(); + break; + case GL_TEXTURE_SWIZZLE_R: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getSwizzleRed(); + break; + case GL_TEXTURE_SWIZZLE_G: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getSwizzleGreen(); + break; + case GL_TEXTURE_SWIZZLE_B: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getSwizzleBlue(); + break; + case GL_TEXTURE_SWIZZLE_A: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getSwizzleAlpha(); + break; + case GL_TEXTURE_BASE_LEVEL: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getBaseLevel(); + break; + case GL_TEXTURE_MAX_LEVEL: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLfloat)texture->getMaxLevel(); + break; + case GL_TEXTURE_MIN_LOD: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getSamplerState().minLod; + break; + case GL_TEXTURE_MAX_LOD: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getSamplerState().maxLod; + break; + case GL_TEXTURE_COMPARE_MODE: + if (context->getClientMajorVersion() < 3) + { + context->handleError( + Error(GL_INVALID_ENUM, + "GL_TEXTURE_COMPARE_MODE not available in ES versions < 3.0")); + return; + } + *params = static_cast<GLfloat>(texture->getCompareMode()); + break; + case GL_TEXTURE_COMPARE_FUNC: + if (context->getClientMajorVersion() < 3) + { + context->handleError( + Error(GL_INVALID_ENUM, + "GL_TEXTURE_COMPARE_FUNC not available in ES versions < 3.0")); + return; + } + *params = static_cast<GLfloat>(texture->getCompareFunc()); + break; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } } } @@ -1534,14 +2393,153 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetTexParameteriv(context, target, pname, params)) + if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) { + context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); return; } Texture *texture = context->getTargetTexture(target); - QueryTexParameteriv(texture, pname, params); + + if (!texture) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + switch (pname) + { + case GL_TEXTURE_MAG_FILTER: + *params = texture->getSamplerState().magFilter; + break; + case GL_TEXTURE_MIN_FILTER: + *params = texture->getSamplerState().minFilter; + break; + case GL_TEXTURE_WRAP_S: + *params = texture->getSamplerState().wrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = texture->getSamplerState().wrapT; + break; + case GL_TEXTURE_WRAP_R: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getSamplerState().wrapR; + break; + case GL_TEXTURE_IMMUTABLE_FORMAT: + // Exposed to ES2.0 through EXT_texture_storage, no client version validation. + *params = texture->getImmutableFormat() ? GL_TRUE : GL_FALSE; + break; + case GL_TEXTURE_IMMUTABLE_LEVELS: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = static_cast<GLint>(texture->getImmutableLevels()); + break; + case GL_TEXTURE_USAGE_ANGLE: + *params = texture->getUsage(); + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (!context->getExtensions().textureFilterAnisotropic) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = (GLint)texture->getMaxAnisotropy(); + break; + case GL_TEXTURE_SWIZZLE_R: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getSwizzleRed(); + break; + case GL_TEXTURE_SWIZZLE_G: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getSwizzleGreen(); + break; + case GL_TEXTURE_SWIZZLE_B: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getSwizzleBlue(); + break; + case GL_TEXTURE_SWIZZLE_A: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getSwizzleAlpha(); + break; + case GL_TEXTURE_BASE_LEVEL: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getBaseLevel(); + break; + case GL_TEXTURE_MAX_LEVEL: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = texture->getMaxLevel(); + break; + case GL_TEXTURE_MIN_LOD: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = iround<GLint>(texture->getMinLod()); + break; + case GL_TEXTURE_MAX_LOD: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + *params = iround<GLint>(texture->getMaxLod()); + break; + case GL_TEXTURE_COMPARE_MODE: + if (context->getClientMajorVersion() < 3) + { + context->handleError( + Error(GL_INVALID_ENUM, + "GL_TEXTURE_COMPARE_MODE not available in ES versions < 3.0")); + return; + } + *params = texture->getCompareMode(); + break; + case GL_TEXTURE_COMPARE_FUNC: + if (context->getClientMajorVersion() < 3) + { + context->handleError( + Error(GL_INVALID_ENUM, + "GL_TEXTURE_COMPARE_FUNC not available in ES versions < 3.0")); + return; + } + *params = texture->getCompareFunc(); + break; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } } } @@ -1621,16 +2619,32 @@ void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateGetVertexAttribfv(context, index, pname, params)) + if (index >= MAX_VERTEX_ATTRIBS) { + context->handleError(Error(GL_INVALID_VALUE)); return; } - const VertexAttribCurrentValueData ¤tValues = - context->getGLState().getVertexAttribCurrentValue(index); - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribfv(attrib, currentValues, pname, params); + if (!ValidateGetVertexAttribParameters(context, pname)) + { + return; + } + + if (pname == GL_CURRENT_VERTEX_ATTRIB) + { + const VertexAttribCurrentValueData ¤tValueData = + context->getGLState().getVertexAttribCurrentValue(index); + for (int i = 0; i < 4; ++i) + { + params[i] = currentValueData.FloatValues[i]; + } + } + else + { + const VertexAttribute &attribState = + context->getGLState().getVertexArray()->getVertexAttribute(index); + *params = QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname); + } } } @@ -1641,16 +2655,33 @@ void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateGetVertexAttribiv(context, index, pname, params)) + if (index >= MAX_VERTEX_ATTRIBS) { + context->handleError(Error(GL_INVALID_VALUE)); return; } - const VertexAttribCurrentValueData ¤tValues = - context->getGLState().getVertexAttribCurrentValue(index); - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribiv(attrib, currentValues, pname, params); + if (!ValidateGetVertexAttribParameters(context, pname)) + { + return; + } + + if (pname == GL_CURRENT_VERTEX_ATTRIB) + { + const VertexAttribCurrentValueData ¤tValueData = + context->getGLState().getVertexAttribCurrentValue(index); + for (int i = 0; i < 4; ++i) + { + float currentValue = currentValueData.FloatValues[i]; + params[i] = iround<GLint>(currentValue); + } + } + else + { + const VertexAttribute &attribState = + context->getGLState().getVertexArray()->getVertexAttribute(index); + *params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname); + } } } @@ -1661,15 +2692,19 @@ void GL_APIENTRY GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** po Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetVertexAttribPointerv(context, index, pname, pointer)) + if (index >= MAX_VERTEX_ATTRIBS) { + context->handleError(Error(GL_INVALID_VALUE)); return; } - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribPointerv(attrib, pname, pointer); + if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + *pointer = const_cast<GLvoid *>(context->getGLState().getVertexAttribPointer(index)); } } @@ -1732,8 +2767,9 @@ GLboolean GL_APIENTRY IsEnabled(GLenum cap) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateIsEnabled(context, cap)) + if (!ValidCap(context, cap)) { + context->handleError(Error(GL_INVALID_ENUM)); return GL_FALSE; } @@ -2288,34 +3324,56 @@ void GL_APIENTRY TexParameterf(GLenum target, GLenum pname, GLfloat param) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateTexParameterf(context, target, pname, param)) + if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) { + context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); return; } - Texture *texture = context->getTargetTexture(target); - SetTexParameterf(texture, pname, param); - } -} + if (!ValidateTexParamParameters(context, target, pname, static_cast<GLint>(param))) + { + return; + } -void GL_APIENTRY TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, const GLfloat* params = 0x%0.8p)", target, - pname, params); + Texture *texture = context->getTargetTexture(target); - Context *context = GetValidGlobalContext(); - if (context) - { - if (!context->skipValidation() && !ValidateTexParameterfv(context, target, pname, params)) + if (!texture) { + context->handleError(Error(GL_INVALID_ENUM)); return; } - Texture *texture = context->getTargetTexture(target); - SetTexParameterfv(texture, pname, params); + // clang-format off + switch (pname) + { + case GL_TEXTURE_WRAP_S: texture->setWrapS(uiround<GLenum>(param)); break; + case GL_TEXTURE_WRAP_T: texture->setWrapT(uiround<GLenum>(param)); break; + case GL_TEXTURE_WRAP_R: texture->setWrapR(uiround<GLenum>(param)); break; + case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(uiround<GLenum>(param)); break; + case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(uiround<GLenum>(param)); break; + case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(uiround<GLenum>(param)); break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(std::min(param, context->getExtensions().maxTextureAnisotropy)); break; + case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(uiround<GLenum>(param)); break; + case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc(uiround<GLenum>(param)); break; + case GL_TEXTURE_SWIZZLE_R: texture->setSwizzleRed(uiround<GLenum>(param)); break; + case GL_TEXTURE_SWIZZLE_G: texture->setSwizzleGreen(uiround<GLenum>(param)); break; + case GL_TEXTURE_SWIZZLE_B: texture->setSwizzleBlue(uiround<GLenum>(param)); break; + case GL_TEXTURE_SWIZZLE_A: texture->setSwizzleAlpha(uiround<GLenum>(param)); break; + case GL_TEXTURE_BASE_LEVEL: texture->setBaseLevel(uiround<GLuint>(param)); break; + case GL_TEXTURE_MAX_LEVEL: texture->setMaxLevel(uiround<GLuint>(param)); break; + case GL_TEXTURE_MIN_LOD: texture->setMinLod(param); break; + case GL_TEXTURE_MAX_LOD: texture->setMaxLod(param); break; + default: UNREACHABLE(); break; + } + // clang-format on } } +void GL_APIENTRY TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) +{ + TexParameterf(target, pname, (GLfloat)*params); +} + void GL_APIENTRY TexParameteri(GLenum target, GLenum pname, GLint param) { EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param); @@ -2323,34 +3381,56 @@ void GL_APIENTRY TexParameteri(GLenum target, GLenum pname, GLint param) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateTexParameteri(context, target, pname, param)) + if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) { + context->handleError(Error(GL_INVALID_ENUM, "Invalid Texture target")); return; } - Texture *texture = context->getTargetTexture(target); - SetTexParameteri(texture, pname, param); - } -} + if (!ValidateTexParamParameters(context, target, pname, param)) + { + return; + } -void GL_APIENTRY TexParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, const GLint* params = 0x%0.8p)", target, - pname, params); + Texture *texture = context->getTargetTexture(target); - Context *context = GetValidGlobalContext(); - if (context) - { - if (!context->skipValidation() && !ValidateTexParameteriv(context, target, pname, params)) + if (!texture) { + context->handleError(Error(GL_INVALID_ENUM)); return; } - Texture *texture = context->getTargetTexture(target); - SetTexParameteriv(texture, pname, params); + // clang-format off + switch (pname) + { + case GL_TEXTURE_WRAP_S: texture->setWrapS(static_cast<GLenum>(param)); break; + case GL_TEXTURE_WRAP_T: texture->setWrapT(static_cast<GLenum>(param)); break; + case GL_TEXTURE_WRAP_R: texture->setWrapR(static_cast<GLenum>(param)); break; + case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(static_cast<GLenum>(param)); break; + case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(static_cast<GLenum>(param)); break; + case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(static_cast<GLenum>(param)); break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(std::min(static_cast<GLfloat>(param), context->getExtensions().maxTextureAnisotropy)); break; + case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(static_cast<GLenum>(param)); break; + case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc(static_cast<GLenum>(param)); break; + case GL_TEXTURE_SWIZZLE_R: texture->setSwizzleRed(static_cast<GLenum>(param)); break; + case GL_TEXTURE_SWIZZLE_G: texture->setSwizzleGreen(static_cast<GLenum>(param)); break; + case GL_TEXTURE_SWIZZLE_B: texture->setSwizzleBlue(static_cast<GLenum>(param)); break; + case GL_TEXTURE_SWIZZLE_A: texture->setSwizzleAlpha(static_cast<GLenum>(param)); break; + case GL_TEXTURE_BASE_LEVEL: texture->setBaseLevel(static_cast<GLuint>(param)); break; + case GL_TEXTURE_MAX_LEVEL: texture->setMaxLevel(static_cast<GLuint>(param)); break; + case GL_TEXTURE_MIN_LOD: texture->setMinLod(static_cast<GLfloat>(param)); break; + case GL_TEXTURE_MAX_LOD: texture->setMaxLod(static_cast<GLfloat>(param)); break; + default: UNREACHABLE(); break; + } + // clang-format on } } +void GL_APIENTRY TexParameteriv(GLenum target, GLenum pname, const GLint* params) +{ + TexParameteri(target, pname, *params); +} + void GL_APIENTRY TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) { diff --git a/gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp b/gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp index bf96affdb..cfd64c8f5 100755 --- a/gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp +++ b/gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp @@ -16,15 +16,10 @@ #include "libANGLE/Framebuffer.h" #include "libANGLE/Shader.h" #include "libANGLE/Query.h" -#include "libANGLE/queryconversions.h" -#include "libANGLE/queryutils.h" -#include "libANGLE/Thread.h" -#include "libANGLE/VertexArray.h" #include "libANGLE/validationES.h" #include "libANGLE/validationES2.h" #include "libANGLE/validationES3.h" -#include "libANGLE/validationES31.h" #include "common/debug.h" #include "common/utilities.h" @@ -32,19 +27,6 @@ namespace gl { -namespace -{ - -void SetRobustLengthParam(GLsizei *length, GLsizei value) -{ - if (length) - { - *length = value; - } -} - -} // anonymous namespace - void GL_APIENTRY GenQueriesEXT(GLsizei n, GLuint *ids) { EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); @@ -188,7 +170,12 @@ void GL_APIENTRY GetQueryObjectivEXT(GLuint id, GLenum pname, GLint *params) return; } - context->getQueryObjectiv(id, pname, params); + Error error = context->getQueryObjectiv(id, pname, params); + if (error.isError()) + { + context->handleError(error); + return; + } } } @@ -204,7 +191,12 @@ void GL_APIENTRY GetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) return; } - context->getQueryObjectuiv(id, pname, params); + Error error = context->getQueryObjectuiv(id, pname, params); + if (error.isError()) + { + context->handleError(error); + return; + } } } @@ -220,7 +212,12 @@ void GL_APIENTRY GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64 *params) return; } - context->getQueryObjecti64v(id, pname, params); + Error error = context->getQueryObjecti64v(id, pname, params); + if (error.isError()) + { + context->handleError(error); + return; + } } } @@ -236,7 +233,12 @@ void GL_APIENTRY GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64 *param return; } - context->getQueryObjectui64v(id, pname, params); + Error error = context->getQueryObjectui64v(id, pname, params); + if (error.isError()) + { + context->handleError(error); + return; + } } } @@ -991,11 +993,10 @@ ANGLE_EXPORT void GL_APIENTRY EGLImageTargetTexture2DOES(GLenum target, GLeglIma { EVENT("(GLenum target = 0x%X, GLeglImageOES image = 0x%0.8p)", target, image); - egl::Thread *thread = egl::GetCurrentThread(); - Context *context = thread->getValidContext(); + Context *context = GetValidGlobalContext(); if (context) { - egl::Display *display = thread->getDisplay(); + egl::Display *display = egl::GetGlobalDisplay(); egl::Image *imageObject = reinterpret_cast<egl::Image *>(image); if (!ValidateEGLImageTargetTexture2DOES(context, display, target, imageObject)) { @@ -1017,11 +1018,10 @@ ANGLE_EXPORT void GL_APIENTRY EGLImageTargetRenderbufferStorageOES(GLenum target { EVENT("(GLenum target = 0x%X, GLeglImageOES image = 0x%0.8p)", target, image); - egl::Thread *thread = egl::GetCurrentThread(); - Context *context = thread->getValidContext(); + Context *context = GetValidGlobalContext(); if (context) { - egl::Display *display = thread->getDisplay(); + egl::Display *display = egl::GetGlobalDisplay(); egl::Image *imageObject = reinterpret_cast<egl::Image *>(image); if (!ValidateEGLImageTargetRenderbufferStorageOES(context, display, target, imageObject)) { @@ -1935,1442 +1935,4 @@ ANGLE_EXPORT void GL_APIENTRY CopySubTextureCHROMIUM(GLuint sourceId, } } -ANGLE_EXPORT void GL_APIENTRY CompressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId) -{ - EVENT("(GLuint sourceId = %u, GLuint destId = %u)", sourceId, destId); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!context->skipValidation() && - !ValidateCompressedCopyTextureCHROMIUM(context, sourceId, destId)) - { - return; - } - - context->compressedCopyTextureCHROMIUM(sourceId, destId); - } -} - -GL_APICALL GLboolean GL_APIENTRY EnableExtensionANGLE(const GLchar *name) -{ - EVENT("(const GLchar *name = %p)", name); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!context->skipValidation() && !ValidateEnableExtensionANGLE(context, name)) - { - return GL_FALSE; - } - - return context->enableExtension(name) ? GL_TRUE : GL_FALSE; - } - - return GL_FALSE; -} - -ANGLE_EXPORT void GL_APIENTRY GetBooleanvRobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLboolean *params) -{ - EVENT( - "(GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLboolean* params " - "= 0x%0.8p)", - pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLenum nativeType; - unsigned int numParams = 0; - if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) - { - return; - } - - if (nativeType == GL_BOOL) - { - context->getBooleanv(pname, params); - } - else - { - CastStateValues(context, nativeType, pname, numParams, params); - } - - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetBufferParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, - params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetBufferParameterivRobustANGLE(context, target, pname, bufSize, &numParams, - params)) - { - return; - } - - Buffer *buffer = context->getGLState().getTargetBuffer(target); - QueryBufferParameteriv(buffer, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetFloatvRobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - EVENT( - "(GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLfloat* params = " - "0x%0.8p)", - pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLenum nativeType; - unsigned int numParams = 0; - if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) - { - return; - } - - if (nativeType == GL_FLOAT) - { - context->getFloatv(pname, params); - } - else - { - CastStateValues(context, nativeType, pname, numParams, params); - } - - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetFramebufferAttachmentParameterivRobustANGLE(GLenum target, - GLenum attachment, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = " - "%d, GLsizei* length = 0x%0.8p, GLint* params = 0x%0.8p)", - target, attachment, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetFramebufferAttachmentParameterivRobustANGLE(context, target, attachment, - pname, bufSize, &numParams)) - { - return; - } - - const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target); - QueryFramebufferAttachmentParameteriv(framebuffer, attachment, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetIntegervRobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *data) -{ - EVENT( - "(GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLint* params = " - "0x%0.8p)", - pname, bufSize, length, data); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLenum nativeType; - unsigned int numParams = 0; - if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) - { - return; - } - - if (nativeType == GL_INT) - { - context->getIntegerv(pname, data); - } - else - { - CastStateValues(context, nativeType, pname, numParams, data); - } - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetProgramivRobustANGLE(GLuint program, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint program = %d, GLenum pname = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLint* params = 0x%0.8p)", - program, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetProgramivRobustANGLE(context, program, pname, bufSize, &numParams)) - { - return; - } - - Program *programObject = context->getProgram(program); - QueryProgramiv(programObject, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetRenderbufferParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint* params = 0x%0.8p)", - target, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetRenderbufferParameterivRobustANGLE(context, target, pname, bufSize, - &numParams, params)) - { - return; - } - - Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer(); - QueryRenderbufferiv(renderbuffer, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY -GetShaderivRobustANGLE(GLuint shader, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *params) -{ - EVENT( - "(GLuint shader = %d, GLenum pname = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLint* params = 0x%0.8p)", - shader, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetShaderivRobustANGLE(context, shader, pname, bufSize, &numParams, params)) - { - return; - } - - Shader *shaderObject = context->getShader(shader); - QueryShaderiv(shaderObject, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetTexParameterfvRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLfloat* params = 0x%0.8p)", - target, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetTexParameterfvRobustANGLE(context, target, pname, bufSize, &numParams, - params)) - { - return; - } - - Texture *texture = context->getTargetTexture(target); - QueryTexParameterfv(texture, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetTexParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLfloat* params = 0x%0.8p)", - target, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetTexParameterivRobustANGLE(context, target, pname, bufSize, &numParams, - params)) - { - return; - } - - Texture *texture = context->getTargetTexture(target); - QueryTexParameteriv(texture, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetUniformfvRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - EVENT( - "(GLuint program = %d, GLint location = %d, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLfloat* params = 0x%0.8p)", - program, location, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetUniformfvRobustANGLE(context, program, location, bufSize, &writeLength, - params)) - { - return; - } - - Program *programObject = context->getProgram(program); - ASSERT(programObject); - - programObject->getUniformfv(location, params); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetUniformivRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint program = %d, GLint location = %d, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint* params = 0x%0.8p)", - program, location, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetUniformivRobustANGLE(context, program, location, bufSize, &writeLength, - params)) - { - return; - } - - Program *programObject = context->getProgram(program); - ASSERT(programObject); - - programObject->getUniformiv(location, params); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribfvRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - EVENT( - "(GLuint index = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLfloat* params = 0x%0.8p)", - index, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribfvRobustANGLE(context, index, pname, bufSize, &writeLength, - params)) - { - return; - } - - const VertexAttribCurrentValueData ¤tValues = - context->getGLState().getVertexAttribCurrentValue(index); - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribfv(attrib, currentValues, pname, params); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribivRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint index = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLint* params = 0x%0.8p)", - index, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribivRobustANGLE(context, index, pname, bufSize, &writeLength, - params)) - { - return; - } - - const VertexAttribCurrentValueData ¤tValues = - context->getGLState().getVertexAttribCurrentValue(index); - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribiv(attrib, currentValues, pname, params); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribPointervRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - void **pointer) -{ - EVENT( - "(GLuint index = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLvoid** pointer = 0x%0.8p)", - index, pname, bufSize, length, pointer); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribPointervRobustANGLE(context, index, pname, bufSize, - &writeLength, pointer)) - { - return; - } - - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribPointerv(attrib, pname, pointer); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY ReadPixelsRobustANGLE(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - void *pixels) -{ - EVENT( - "(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " - "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLvoid* pixels = 0x%0.8p)", - x, y, width, height, format, type, bufSize, length, pixels); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateReadPixelsRobustANGLE(context, x, y, width, height, format, type, bufSize, - &writeLength, pixels)) - { - return; - } - - context->readPixels(x, y, width, height, format, type, pixels); - - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY TexImage2DRobustANGLE(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - GLsizei bufSize, - const void *pixels) -{ - EVENT( - "(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " - "GLsizei height = %d, GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, GLsizei " - "bufSize = %d, const GLvoid* pixels = 0x%0.8p)", - target, level, internalformat, width, height, border, format, type, bufSize, pixels); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!ValidateTexImage2DRobust(context, target, level, internalformat, width, height, border, - format, type, bufSize, pixels)) - { - return; - } - - context->texImage2D(target, level, internalformat, width, height, border, format, type, - pixels); - } -} - -ANGLE_EXPORT void GL_APIENTRY TexParameterfvRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - const GLfloat *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLfloat* params = " - "0x%0.8p)", - target, pname, bufSize, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!ValidateTexParameterfvRobustANGLE(context, target, pname, bufSize, params)) - { - return; - } - - Texture *texture = context->getTargetTexture(target); - SetTexParameterfv(texture, pname, params); - } -} - -ANGLE_EXPORT void GL_APIENTRY TexParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - const GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLfloat* params = " - "0x%0.8p)", - target, pname, bufSize, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!ValidateTexParameterivRobustANGLE(context, target, pname, bufSize, params)) - { - return; - } - - Texture *texture = context->getTargetTexture(target); - SetTexParameteriv(texture, pname, params); - } -} - -ANGLE_EXPORT void GL_APIENTRY TexSubImage2DRobustANGLE(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - const void *pixels) -{ - EVENT( - "(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " - "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, " - "GLsizei bufsize = %d, const GLvoid* pixels = 0x%0.8p)", - target, level, xoffset, yoffset, width, height, format, type, bufSize, pixels); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!ValidateTexSubImage2DRobustANGLE(context, target, level, xoffset, yoffset, width, - height, format, type, bufSize, pixels)) - { - return; - } - - context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, - pixels); - } -} - -ANGLE_EXPORT void GL_APIENTRY TexImage3DRobustANGLE(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - GLsizei bufSize, - const void *pixels) -{ - EVENT( - "(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " - "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " - "GLenum type = 0x%X, GLsizei bufsize = %d, const GLvoid* pixels = 0x%0.8p)", - target, level, internalformat, width, height, depth, border, format, type, bufSize, pixels); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!ValidateTexImage3DRobustANGLE(context, target, level, internalformat, width, height, - depth, border, format, type, bufSize, pixels)) - { - return; - } - - context->texImage3D(target, level, internalformat, width, height, depth, border, format, - type, pixels); - } -} - -ANGLE_EXPORT void GL_APIENTRY TexSubImage3DRobustANGLE(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLenum type, - GLsizei bufSize, - const void *pixels) -{ - EVENT( - "(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " - "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " - "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufsize = %d, const GLvoid* pixels = " - "0x%0.8p)", - target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, bufSize, - pixels); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!ValidateTexSubImage3DRobustANGLE(context, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type, bufSize, pixels)) - { - return; - } - - context->texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, - format, type, pixels); - } -} - -ANGLE_EXPORT void GL_APIENTRY -GetQueryivRobustANGLE(GLenum target, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint* params = 0x%0.8p)", - target, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetQueryivRobustANGLE(context, target, pname, bufSize, &numParams, params)) - { - return; - } - - context->getQueryiv(target, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetQueryObjectuivRobustANGLE(GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - EVENT( - "(GLuint id = %u, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLint* params = 0x%0.8p)", - id, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetQueryObjectuivRobustANGLE(context, id, pname, bufSize, &numParams, params)) - { - return; - } - - context->getQueryObjectuiv(id, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetBufferPointervRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - void **params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLvoid** params = 0x%0.8p)", - target, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetBufferPointervRobustANGLE(context, target, pname, bufSize, &numParams, - params)) - { - return; - } - - context->getBufferPointerv(target, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY -GetIntegeri_vRobustANGLE(GLenum target, GLuint index, GLsizei bufSize, GLsizei *length, GLint *data) -{ - EVENT( - "(GLenum target = 0x%X, GLuint index = %u, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint* data = 0x%0.8p)", - target, index, bufSize, length, data); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetIntegeri_vRobustANGLE(context, target, index, bufSize, &numParams, data)) - { - return; - } - - context->getIntegeri_v(target, index, data); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetInternalformativRobustANGLE(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize " - "= %d, GLsizei* length = 0x%0.8p, GLint* params = 0x%0.8p)", - target, internalformat, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetInternalFormativRobustANGLE(context, target, internalformat, pname, bufSize, - &numParams, params)) - { - return; - } - - const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); - QueryInternalFormativ(formatCaps, pname, bufSize, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribIivRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint index = %u, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLint* params = 0x%0.8p)", - index, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribIivRobustANGLE(context, index, pname, bufSize, &writeLength, - params)) - { - return; - } - - const VertexAttribCurrentValueData ¤tValues = - context->getGLState().getVertexAttribCurrentValue(index); - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribIiv(attrib, currentValues, pname, params); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribIuivRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - EVENT( - "(GLuint index = %u, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLuint* params = 0x%0.8p)", - index, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribIuivRobustANGLE(context, index, pname, bufSize, &writeLength, - params)) - { - return; - } - - const VertexAttribCurrentValueData ¤tValues = - context->getGLState().getVertexAttribCurrentValue(index); - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribIuiv(attrib, currentValues, pname, params); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetUniformuivRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - EVENT( - "(GLuint program = %u, GLint location = %d, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLuint* params = 0x%0.8p)", - program, location, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetUniformuivRobustANGLE(context, program, location, bufSize, &writeLength, - params)) - { - return; - } - - Program *programObject = context->getProgram(program); - ASSERT(programObject); - - programObject->getUniformuiv(location, params); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetActiveUniformBlockivRobustANGLE(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLsizei bufsize " - "= %d, GLsizei* length = 0x%0.8p, GLint* params = 0x%0.8p)", - program, uniformBlockIndex, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateGetActiveUniformBlockivRobustANGLE(context, program, uniformBlockIndex, pname, - bufSize, &writeLength, params)) - { - return; - } - - const Program *programObject = context->getProgram(program); - QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetInteger64vRobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *data) -{ - EVENT( - "(GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLint64* params = " - "0x%0.8p)", - pname, bufSize, length, data); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLenum nativeType; - unsigned int numParams = 0; - if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) - { - return; - } - - if (nativeType == GL_INT_64_ANGLEX) - { - context->getInteger64v(pname, data); - } - else - { - CastStateValues(context, nativeType, pname, numParams, data); - } - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetInteger64i_vRobustANGLE(GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLint64 *data) -{ - EVENT( - "(GLenum target = 0x%X, GLuint index = %u, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint64* data = 0x%0.8p)", - target, index, bufSize, length, data); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetInteger64i_vRobustANGLE(context, target, index, bufSize, &numParams, data)) - { - return; - } - - context->getInteger64i_v(target, index, data); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetBufferParameteri64vRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *params) -{ - EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", target, pname, - bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetBufferParameteri64vRobustANGLE(context, target, pname, bufSize, &numParams, - params)) - { - return; - } - - Buffer *buffer = context->getGLState().getTargetBuffer(target); - QueryBufferParameteri64v(buffer, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY SamplerParameterivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLint *param) -{ - EVENT( - "(GLuint sampler = %u, GLenum pname = 0x%X, GLsizei bufsize = %d, const GLint* params = " - "0x%0.8p)", - sampler, pname, bufSize, param); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!ValidateSamplerParameterivRobustANGLE(context, sampler, pname, bufSize, param)) - { - return; - } - - context->samplerParameteriv(sampler, pname, param); - } -} - -ANGLE_EXPORT void GL_APIENTRY SamplerParameterfvRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLfloat *param) -{ - EVENT( - "(GLuint sampler = %u, GLenum pname = 0x%X, GLsizei bufsize = %d, const GLfloat* params = " - "0x%0.8p)", - sampler, pname, bufSize, param); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!ValidateSamplerParameterfvRobustANGLE(context, sampler, pname, bufSize, param)) - { - return; - } - - context->samplerParameterfv(sampler, pname, param); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint sampler = %u, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint* params = 0x%0.8p)", - sampler, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetSamplerParameterivRobustANGLE(context, sampler, pname, bufSize, &numParams, - params)) - { - return; - } - - context->getSamplerParameteriv(sampler, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterfvRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - EVENT( - "(GLuint sample = %ur, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLfloat* params = 0x%0.8p)", - sampler, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetSamplerParameterfvRobustANGLE(context, sampler, pname, bufSize, &numParams, - params)) - { - return; - } - - context->getSamplerParameterfv(sampler, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetFramebufferParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint* params = 0x%0.8p)", - target, pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetProgramInterfaceivRobustANGLE(GLuint program, - GLenum programInterface, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint program = %u, GLenum programInterface = 0x%X, GLenum pname = 0x%X, GLsizei " - "bufsize = %d, GLsizei* length = 0x%0.8p, GLint* params = 0x%0.8p)", - program, programInterface, pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetBooleani_vRobustANGLE(GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLboolean *data) -{ - EVENT( - "(GLenum target = 0x%X, GLuint index = %u, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLboolean* data = 0x%0.8p)", - target, index, bufSize, length, data); - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetBooleani_vRobustANGLE(context, target, index, bufSize, &numParams, data)) - { - return; - } - - context->getBooleani_v(target, index, data); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetMultisamplefvRobustANGLE(GLenum pname, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLfloat *val) -{ - EVENT( - "(GLenum pname = 0x%X, GLuint index = %u, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLfloat* val = 0x%0.8p)", - pname, index, bufSize, length, val); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetTexLevelParameterivRobustANGLE(GLenum target, - GLint level, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLint level = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, " - "GLsizei* length = 0x%0.8p, GLint* params = 0x%0.8p)", - target, level, pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetTexLevelParameterfvRobustANGLE(GLenum target, - GLint level, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - EVENT( - "(GLenum target = 0x%X, GLint level = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, " - "GLsizei* length = 0x%0.8p, GLfloat* params = 0x%0.8p)", - target, level, pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetPointervRobustANGLERobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - void **params) -{ - EVENT( - "(GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, void **params = " - "0x%0.8p)", - pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY ReadnPixelsRobustANGLE(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - void *data) -{ - EVENT( - "(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " - "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLvoid *data = 0x%0.8p)", - x, y, width, height, format, type, bufSize, length, data); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei writeLength = 0; - if (!ValidateReadnPixelsRobustANGLE(context, x, y, width, height, format, type, bufSize, - &writeLength, data)) - { - return; - } - - context->readPixels(x, y, width, height, format, type, data); - - SetRobustLengthParam(length, writeLength); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetnUniformfvRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - EVENT( - "(GLuint program = %d, GLint location = %d, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLfloat* params = 0x%0.8p)", - program, location, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetnUniformivRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint program = %d, GLint location = %d, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint* params = 0x%0.8p)", - program, location, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetnUniformuivRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - EVENT( - "(GLuint program = %u, GLint location = %d, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLuint* params = 0x%0.8p)", - program, location, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY TexParameterIivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - const GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, const GLint *params = " - "0x%0.8p)", - target, pname, bufSize, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY TexParameterIuivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - const GLuint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, const GLuint *params = " - "0x%0.8p)", - target, pname, bufSize, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetTexParameterIivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint *params = 0x%0.8p)", - target, pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetTexParameterIuivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - EVENT( - "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLuint *params = 0x%0.8p)", - target, pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY SamplerParameterIivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLint *param) -{ - EVENT( - "(GLuint sampler = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, const GLint *param = " - "0x%0.8p)", - sampler, pname, bufSize, param); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY SamplerParameterIuivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLuint *param) -{ - EVENT( - "(GLuint sampler = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, const GLuint *param = " - "0x%0.8p)", - sampler, pname, bufSize, param); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterIivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint sampler = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLint *params = 0x%0.8p)", - sampler, pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterIuivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - EVENT( - "(GLuint sampler = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " - "0x%0.8p, GLuint *params = 0x%0.8p)", - sampler, pname, bufSize, length, params); - UNIMPLEMENTED(); -} - -ANGLE_EXPORT void GL_APIENTRY GetQueryObjectivRobustANGLE(GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - EVENT( - "(GLuint id = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLuint *params = 0x%0.8p)", - id, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetQueryObjectivRobustANGLE(context, id, pname, bufSize, &numParams, params)) - { - return; - } - - context->getQueryObjectiv(id, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetQueryObjecti64vRobustANGLE(GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *params) -{ - EVENT( - "(GLuint id = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLint64 *params = 0x%0.8p)", - id, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetQueryObjecti64vRobustANGLE(context, id, pname, bufSize, &numParams, params)) - { - return; - } - - context->getQueryObjecti64v(id, pname, params); - SetRobustLengthParam(length, numParams); - } -} - -ANGLE_EXPORT void GL_APIENTRY GetQueryObjectui64vRobustANGLE(GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint64 *params) -{ - EVENT( - "(GLuint id = %d, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, " - "GLuint64 *params = 0x%0.8p)", - id, pname, bufSize, length, params); - - Context *context = GetValidGlobalContext(); - if (context) - { - GLsizei numParams = 0; - if (!ValidateGetQueryObjectui64vRobustANGLE(context, id, pname, bufSize, &numParams, - params)) - { - return; - } - - context->getQueryObjectui64v(id, pname, params); - SetRobustLengthParam(length, numParams); - } -} - } // gl diff --git a/gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.h b/gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.h index 69d549224..86216d2a5 100755 --- a/gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.h +++ b/gfx/angle/src/libGLESv2/entry_points_gles_2_0_ext.h @@ -259,338 +259,6 @@ ANGLE_EXPORT void GL_APIENTRY CopySubTextureCHROMIUM(GLuint sourceId, GLboolean unpackPremultiplyAlpha, GLboolean unpackUnmultiplyAlpha); -// GL_CHROMIUM_copy_compressed_texture -ANGLE_EXPORT void GL_APIENTRY CompressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId); - -// GL_ANGLE_webgl_compatibility -GL_APICALL GLboolean GL_APIENTRY EnableExtensionANGLE(const GLchar *name); - -// GL_ANGLE_robust_client_memory -ANGLE_EXPORT void GL_APIENTRY GetBooleanvRobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLboolean *data); -ANGLE_EXPORT void GL_APIENTRY GetBufferParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetFloatvRobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *data); -ANGLE_EXPORT void GL_APIENTRY GetFramebufferAttachmentParameterivRobustANGLE(GLenum target, - GLenum attachment, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetIntegervRobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *data); -ANGLE_EXPORT void GL_APIENTRY GetProgramivRobustANGLE(GLuint program, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetRenderbufferParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetShaderivRobustANGLE(GLuint shader, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetTexParameterfvRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); -ANGLE_EXPORT void GL_APIENTRY GetTexParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetUniformfvRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); -ANGLE_EXPORT void GL_APIENTRY GetUniformivRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribfvRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribivRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribPointervRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - void **pointer); -ANGLE_EXPORT void GL_APIENTRY ReadPixelsRobustANGLE(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - void *pixels); -ANGLE_EXPORT void GL_APIENTRY TexImage2DRobustANGLE(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - GLsizei bufSize, - const void *pixels); -ANGLE_EXPORT void GL_APIENTRY TexParameterfvRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - const GLfloat *params); -ANGLE_EXPORT void GL_APIENTRY TexParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - const GLint *params); -ANGLE_EXPORT void GL_APIENTRY TexSubImage2DRobustANGLE(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - const void *pixels); - -ANGLE_EXPORT void GL_APIENTRY TexImage3DRobustANGLE(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - GLsizei bufSize, - const void *pixels); -ANGLE_EXPORT void GL_APIENTRY TexSubImage3DRobustANGLE(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLenum type, - GLsizei bufSize, - const void *pixels); -ANGLE_EXPORT void GL_APIENTRY -GetQueryivRobustANGLE(GLenum target, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetQueryObjectuivRobustANGLE(GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params); -ANGLE_EXPORT void GL_APIENTRY GetBufferPointervRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - void **params); -ANGLE_EXPORT void GL_APIENTRY GetIntegeri_vRobustANGLE(GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLint *data); -ANGLE_EXPORT void GL_APIENTRY GetInternalformativRobustANGLE(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribIivRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetVertexAttribIuivRobustANGLE(GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params); -ANGLE_EXPORT void GL_APIENTRY GetUniformuivRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLuint *params); -ANGLE_EXPORT void GL_APIENTRY GetActiveUniformBlockivRobustANGLE(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetInteger64vRobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *data); -ANGLE_EXPORT void GL_APIENTRY GetInteger64i_vRobustANGLE(GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLint64 *data); -ANGLE_EXPORT void GL_APIENTRY GetBufferParameteri64vRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *params); -ANGLE_EXPORT void GL_APIENTRY SamplerParameterivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLint *param); -ANGLE_EXPORT void GL_APIENTRY SamplerParameterfvRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLfloat *param); -ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterfvRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); - -ANGLE_EXPORT void GL_APIENTRY GetFramebufferParameterivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetProgramInterfaceivRobustANGLE(GLuint program, - GLenum programInterface, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetBooleani_vRobustANGLE(GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLboolean *data); -ANGLE_EXPORT void GL_APIENTRY GetMultisamplefvRobustANGLE(GLenum pname, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLfloat *val); -ANGLE_EXPORT void GL_APIENTRY GetTexLevelParameterivRobustANGLE(GLenum target, - GLint level, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetTexLevelParameterfvRobustANGLE(GLenum target, - GLint level, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); - -ANGLE_EXPORT void GL_APIENTRY GetPointervRobustANGLERobustANGLE(GLenum pname, - GLsizei bufSize, - GLsizei *length, - void **params); -ANGLE_EXPORT void GL_APIENTRY ReadnPixelsRobustANGLE(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - void *data); -ANGLE_EXPORT void GL_APIENTRY GetnUniformfvRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); -ANGLE_EXPORT void GL_APIENTRY GetnUniformivRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetnUniformuivRobustANGLE(GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLuint *params); -ANGLE_EXPORT void GL_APIENTRY TexParameterIivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - const GLint *params); -ANGLE_EXPORT void GL_APIENTRY TexParameterIuivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - const GLuint *params); -ANGLE_EXPORT void GL_APIENTRY GetTexParameterIivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetTexParameterIuivRobustANGLE(GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params); -ANGLE_EXPORT void GL_APIENTRY SamplerParameterIivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLint *param); -ANGLE_EXPORT void GL_APIENTRY SamplerParameterIuivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLuint *param); -ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterIivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterIuivRobustANGLE(GLuint sampler, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params); -ANGLE_EXPORT void GL_APIENTRY GetQueryObjectivRobustANGLE(GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -ANGLE_EXPORT void GL_APIENTRY GetQueryObjecti64vRobustANGLE(GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *params); -ANGLE_EXPORT void GL_APIENTRY GetQueryObjectui64vRobustANGLE(GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint64 *params); - } // namespace gl #endif // LIBGLESV2_ENTRYPOINTGLES20EXT_H_ diff --git a/gfx/angle/src/libGLESv2/entry_points_gles_3_0.cpp b/gfx/angle/src/libGLESv2/entry_points_gles_3_0.cpp index b0b485e36..dabb33452 100755 --- a/gfx/angle/src/libGLESv2/entry_points_gles_3_0.cpp +++ b/gfx/angle/src/libGLESv2/entry_points_gles_3_0.cpp @@ -22,7 +22,6 @@ #include "libANGLE/validationES.h" #include "libANGLE/validationES3.h" #include "libANGLE/queryconversions.h" -#include "libANGLE/queryutils.h" #include "common/debug.h" @@ -310,7 +309,12 @@ void GL_APIENTRY GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) return; } - context->getQueryObjectuiv(id, pname, params); + Error error = context->getQueryObjectuiv(id, pname, params); + if (error.isError()) + { + context->handleError(error); + return; + } } } @@ -755,13 +759,6 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi return; } - if (!context->getGLState().isBindGeneratesResourceEnabled() && - !context->isBufferGenerated(buffer)) - { - context->handleError(Error(GL_INVALID_OPERATION, "Buffer was not generated")); - return; - } - switch (target) { case GL_TRANSFORM_FEEDBACK_BUFFER: @@ -844,13 +841,6 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer) return; } - if (!context->getGLState().isBindGeneratesResourceEnabled() && - !context->isBufferGenerated(buffer)) - { - context->handleError(Error(GL_INVALID_OPERATION, "Buffer was not generated")); - return; - } - switch (target) { case GL_TRANSFORM_FEEDBACK_BUFFER: @@ -1033,17 +1023,38 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetVertexAttribIiv(context, index, pname, params)) + if (context->getClientMajorVersion() < 3) { + context->handleError(Error(GL_INVALID_OPERATION)); return; } - const VertexAttribCurrentValueData ¤tValues = - context->getGLState().getVertexAttribCurrentValue(index); - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribIiv(attrib, currentValues, pname, params); + if (index >= MAX_VERTEX_ATTRIBS) + { + context->handleError(Error(GL_INVALID_VALUE)); + return; + } + + if (!ValidateGetVertexAttribParameters(context, pname)) + { + return; + } + + if (pname == GL_CURRENT_VERTEX_ATTRIB) + { + const VertexAttribCurrentValueData ¤tValueData = + context->getGLState().getVertexAttribCurrentValue(index); + for (int i = 0; i < 4; ++i) + { + params[i] = currentValueData.IntValues[i]; + } + } + else + { + const VertexAttribute &attribState = + context->getGLState().getVertexArray()->getVertexAttribute(index); + *params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname); + } } } @@ -1055,17 +1066,38 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetVertexAttribIuiv(context, index, pname, params)) + if (context->getClientMajorVersion() < 3) { + context->handleError(Error(GL_INVALID_OPERATION)); return; } - const VertexAttribCurrentValueData ¤tValues = - context->getGLState().getVertexAttribCurrentValue(index); - const VertexAttribute &attrib = - context->getGLState().getVertexArray()->getVertexAttribute(index); - QueryVertexAttribIuiv(attrib, currentValues, pname, params); + if (index >= MAX_VERTEX_ATTRIBS) + { + context->handleError(Error(GL_INVALID_VALUE)); + return; + } + + if (!ValidateGetVertexAttribParameters(context, pname)) + { + return; + } + + if (pname == GL_CURRENT_VERTEX_ATTRIB) + { + const VertexAttribCurrentValueData ¤tValueData = + context->getGLState().getVertexAttribCurrentValue(index); + for (int i = 0; i < 4; ++i) + { + params[i] = currentValueData.UnsignedIntValues[i]; + } + } + else + { + const VertexAttribute &attribState = + context->getGLState().getVertexArray()->getVertexAttribute(index); + *params = QuerySingleVertexAttributeParameter<GLuint>(attribState, pname); + } } } @@ -1409,7 +1441,7 @@ const GLubyte *GL_APIENTRY GetStringi(GLenum name, GLuint index) return NULL; } - return reinterpret_cast<const GLubyte *>(context->getExtensionString(index)); + return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str()); } return NULL; @@ -1423,14 +1455,58 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateCopyBufferSubData(context, readTarget, writeTarget, readOffset, writeOffset, - size)) + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + if (!ValidBufferTarget(context, readTarget) || !ValidBufferTarget(context, writeTarget)) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + Buffer *readBuffer = context->getGLState().getTargetBuffer(readTarget); + Buffer *writeBuffer = context->getGLState().getTargetBuffer(writeTarget); + + if (!readBuffer || !writeBuffer) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + // Verify that readBuffer and writeBuffer are not currently mapped + if (readBuffer->isMapped() || writeBuffer->isMapped()) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + if (readOffset < 0 || writeOffset < 0 || size < 0 || + static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() || + static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize()) + { + context->handleError(Error(GL_INVALID_VALUE)); + return; + } + + if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size) { + context->handleError(Error(GL_INVALID_VALUE)); return; } - context->copyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size); + // if size is zero, the copy is a successful no-op + if (size > 0) + { + Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); + if (error.isError()) + { + context->handleError(error); + return; + } + } } } @@ -1580,14 +1656,43 @@ void GL_APIENTRY GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockInde Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetActiveUniformBlockiv(context, program, uniformBlockIndex, pname, params)) + if (context->getClientMajorVersion() < 3) { + context->handleError(Error(GL_INVALID_OPERATION)); return; } + Program *programObject = GetValidProgram(context, program); + + if (!programObject) + { + return; + } + + if (uniformBlockIndex >= programObject->getActiveUniformBlockCount()) + { + context->handleError(Error(GL_INVALID_VALUE)); + return; + } + + switch (pname) + { + case GL_UNIFORM_BLOCK_BINDING: + *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); + break; + + case GL_UNIFORM_BLOCK_DATA_SIZE: + case GL_UNIFORM_BLOCK_NAME_LENGTH: + case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: + case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: + case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: + case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: + programObject->getActiveUniformBlockiv(uniformBlockIndex, pname, params); + break; - const Program *programObject = context->getProgram(program); - QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } } } @@ -1994,14 +2099,55 @@ void GL_APIENTRY GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* pa Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetBufferParameteri64v(context, target, pname, params)) + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + if (!ValidBufferTarget(context, target)) { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + if (!ValidBufferParameter(context, pname)) + { + context->handleError(Error(GL_INVALID_ENUM)); return; } Buffer *buffer = context->getGLState().getTargetBuffer(target); - QueryBufferParameteri64v(buffer, pname, params); + + if (!buffer) + { + // A null buffer means that "0" is bound to the requested buffer target + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + switch (pname) + { + case GL_BUFFER_USAGE: + *params = static_cast<GLint64>(buffer->getUsage()); + break; + case GL_BUFFER_SIZE: + *params = buffer->getSize(); + break; + case GL_BUFFER_ACCESS_FLAGS: + *params = static_cast<GLint64>(buffer->getAccessFlags()); + break; + case GL_BUFFER_MAPPED: + *params = static_cast<GLint64>(buffer->isMapped()); + break; + case GL_BUFFER_MAP_OFFSET: + *params = buffer->getMapOffset(); + break; + case GL_BUFFER_MAP_LENGTH: + *params = buffer->getMapLength(); + break; + default: UNREACHABLE(); break; + } } } @@ -2110,20 +2256,7 @@ void GL_APIENTRY SamplerParameteri(GLuint sampler, GLenum pname, GLint param) void GL_APIENTRY SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) { - EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* params = 0x%0.8p)", sampler, - pname, param); - - Context *context = GetValidGlobalContext(); - if (context) - { - if (!context->skipValidation() && - !ValidateSamplerParameteriv(context, sampler, pname, param)) - { - return; - } - - context->samplerParameteriv(sampler, pname, param); - } + SamplerParameteri(sampler, pname, *param); } void GL_APIENTRY SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) @@ -2145,37 +2278,34 @@ void GL_APIENTRY SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) void GL_APIENTRY SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) { - EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* params = 0x%0.8p)", sampler, - pname, param); + SamplerParameterf(sampler, pname, *param); +} + +void GL_APIENTRY GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) +{ + EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateSamplerParameterfv(context, sampler, pname, param)) + if (context->getClientMajorVersion() < 3) { + context->handleError(Error(GL_INVALID_OPERATION)); return; } - context->samplerParameterfv(sampler, pname, param); - } -} - -void GL_APIENTRY GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) -{ - EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, - params); + if (!ValidateSamplerObjectParameter(context, pname)) + { + return; + } - Context *context = GetValidGlobalContext(); - if (context) - { - if (!context->skipValidation() && - !ValidateGetSamplerParameteriv(context, sampler, pname, params)) + if (!context->isSampler(sampler)) { + context->handleError(Error(GL_INVALID_OPERATION)); return; } - context->getSamplerParameteriv(sampler, pname, params); + *params = context->getSamplerParameteri(sampler, pname); } } @@ -2186,13 +2316,24 @@ void GL_APIENTRY GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* pa Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetSamplerParameterfv(context, sampler, pname, params)) + if (context->getClientMajorVersion() < 3) { + context->handleError(Error(GL_INVALID_OPERATION)); return; } - context->getSamplerParameterfv(sampler, pname, params); + if (!ValidateSamplerObjectParameter(context, pname)) + { + return; + } + + if (!context->isSampler(sampler)) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return; + } + + *params = context->getSamplerParameterf(sampler, pname); } } @@ -2561,14 +2702,55 @@ void GL_APIENTRY GetInternalformativ(GLenum target, GLenum internalformat, GLenu Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && - !ValidateGetInternalFormativ(context, target, internalformat, pname, bufSize, params)) + if (context->getClientMajorVersion() < 3) { + context->handleError(Error(GL_INVALID_OPERATION)); return; } const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); - QueryInternalFormativ(formatCaps, pname, bufSize, params); + if (!formatCaps.renderable) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + if (target != GL_RENDERBUFFER) + { + context->handleError(Error(GL_INVALID_ENUM)); + return; + } + + if (bufSize < 0) + { + context->handleError(Error(GL_INVALID_VALUE)); + return; + } + + switch (pname) + { + case GL_NUM_SAMPLE_COUNTS: + if (bufSize != 0) + { + *params = static_cast<GLint>(formatCaps.sampleCounts.size()); + } + break; + + case GL_SAMPLES: + { + size_t returnCount = std::min<size_t>(bufSize, formatCaps.sampleCounts.size()); + auto sampleReverseIt = formatCaps.sampleCounts.rbegin(); + for (size_t sampleIndex = 0; sampleIndex < returnCount; ++sampleIndex) + { + params[sampleIndex] = *sampleReverseIt++;; + } + } + break; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return; + } } } diff --git a/gfx/angle/src/libGLESv2/global_state.cpp b/gfx/angle/src/libGLESv2/global_state.cpp index bc776b1f7..fa681bde1 100755 --- a/gfx/angle/src/libGLESv2/global_state.cpp +++ b/gfx/angle/src/libGLESv2/global_state.cpp @@ -8,141 +8,229 @@ #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" -#include "libANGLE/Thread.h" - -namespace gl +namespace { -Context *GetGlobalContext() +static TLSIndex currentTLS = TLS_INVALID_INDEX; + +struct Current +{ + EGLint error; + EGLenum API; + egl::Display *display; + egl::Surface *drawSurface; + egl::Surface *readSurface; + gl::Context *context; +}; + +Current *AllocateCurrent() { - egl::Thread *thread = egl::GetCurrentThread(); - return thread->getContext(); + ASSERT(currentTLS != TLS_INVALID_INDEX); + if (currentTLS == TLS_INVALID_INDEX) + { + return NULL; + } + + Current *current = new Current(); + 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)) + { + ERR("Could not set thread local storage."); + return NULL; + } + + return current; } -Context *GetValidGlobalContext() +Current *GetCurrentData() { - egl::Thread *thread = egl::GetCurrentThread(); - return thread->getValidContext(); + // 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()); } -} // namespace gl +#ifdef ANGLE_PLATFORM_WINDOWS -namespace egl +void DeallocateCurrent() { + Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS)); + SafeDelete(current); + SetTLSValue(currentTLS, NULL); +} -namespace +extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID) { + switch (reason) + { + case DLL_PROCESS_ATTACH: + currentTLS = CreateTLSIndex(); + if (currentTLS == TLS_INVALID_INDEX) + { + return FALSE; + } + AllocateCurrent(); + break; -static TLSIndex threadTLS = TLS_INVALID_INDEX; + case DLL_THREAD_ATTACH: + AllocateCurrent(); + break; -Thread *AllocateCurrentThread() -{ - ASSERT(threadTLS != TLS_INVALID_INDEX); - if (threadTLS == TLS_INVALID_INDEX) - { - return nullptr; - } + case DLL_THREAD_DETACH: + DeallocateCurrent(); + break; - Thread *thread = new Thread(); - if (!SetTLSValue(threadTLS, thread)) - { - ERR("Could not set thread local storage."); - return nullptr; + case DLL_PROCESS_DETACH: + DeallocateCurrent(); + if (currentTLS != TLS_INVALID_INDEX) + { + DestroyTLSIndex(currentTLS); + currentTLS = TLS_INVALID_INDEX; + } + break; } - return thread; + return TRUE; } +#endif -} // anonymous namespace +} -Thread *GetCurrentThread() +namespace gl { - // Create a TLS index if one has not been created for this DLL - if (threadTLS == TLS_INVALID_INDEX) + +Context *GetGlobalContext() +{ + Current *current = GetCurrentData(); + + return current->context; +} + +Context *GetValidGlobalContext() +{ + gl::Context *context = GetGlobalContext(); + if (context) { - threadTLS = CreateTLSIndex(); + if (context->isContextLost()) + { + context->handleError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost.")); + return nullptr; + } + else + { + return context; + } } + return nullptr; +} - Thread *current = static_cast<Thread *>(GetTLSValue(threadTLS)); +} - // ANGLE issue 488: when the dll is loaded after thread initialization, - // thread local storage (current) might not exist yet. - return (current ? current : AllocateCurrentThread()); +namespace egl +{ + +void SetGlobalError(const Error &error) +{ + Current *current = GetCurrentData(); + + current->error = error.getCode(); } -} // namespace egl +EGLint GetGlobalError() +{ + Current *current = GetCurrentData(); -#ifdef ANGLE_PLATFORM_WINDOWS -namespace egl + return current->error; +} + +EGLenum GetGlobalAPI() { + Current *current = GetCurrentData(); -namespace + return current->API; +} + +void SetGlobalAPI(EGLenum API) { + Current *current = GetCurrentData(); -bool DeallocateCurrentThread() + current->API = API; +} + +void SetGlobalDisplay(Display *dpy) { - Thread *thread = static_cast<Thread *>(GetTLSValue(threadTLS)); - SafeDelete(thread); - return SetTLSValue(threadTLS, nullptr); + Current *current = GetCurrentData(); + + current->display = dpy; } -bool InitializeProcess() +Display *GetGlobalDisplay() { - threadTLS = CreateTLSIndex(); - if (threadTLS == TLS_INVALID_INDEX) - { - return false; - } + Current *current = GetCurrentData(); - return AllocateCurrentThread() != nullptr; + return current->display; } -bool TerminateProcess() +void SetGlobalDrawSurface(Surface *surface) { - if (!DeallocateCurrentThread()) - { - return false; - } + Current *current = GetCurrentData(); - if (threadTLS != TLS_INVALID_INDEX) - { - TLSIndex tlsCopy = threadTLS; - threadTLS = TLS_INVALID_INDEX; + current->drawSurface = surface; +} - if (!DestroyTLSIndex(tlsCopy)) - { - return false; - } - } +Surface *GetGlobalDrawSurface() +{ + Current *current = GetCurrentData(); + + return current->drawSurface; +} - return true; +void SetGlobalReadSurface(Surface *surface) +{ + Current *current = GetCurrentData(); + + current->readSurface = surface; } -} // anonymous namespace +Surface *GetGlobalReadSurface() +{ + Current *current = GetCurrentData(); -} // namespace egl + return current->readSurface; +} -extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID) +void SetGlobalContext(gl::Context *context) { - switch (reason) - { - case DLL_PROCESS_ATTACH: - return static_cast<BOOL>(egl::InitializeProcess()); + Current *current = GetCurrentData(); - case DLL_THREAD_ATTACH: - return static_cast<BOOL>(egl::AllocateCurrentThread() != nullptr); + current->context = context; +} - case DLL_THREAD_DETACH: - return static_cast<BOOL>(egl::DeallocateCurrentThread()); +gl::Context *GetGlobalContext() +{ + Current *current = GetCurrentData(); - case DLL_PROCESS_DETACH: - return static_cast<BOOL>(egl::TerminateProcess()); - } + return current->context; +} - return TRUE; } -#endif // ANGLE_PLATFORM_WINDOWS diff --git a/gfx/angle/src/libGLESv2/global_state.h b/gfx/angle/src/libGLESv2/global_state.h index 3e3740c90..db202539c 100755 --- a/gfx/angle/src/libGLESv2/global_state.h +++ b/gfx/angle/src/libGLESv2/global_state.h @@ -9,6 +9,8 @@ #ifndef LIBGLESV2_GLOBALSTATE_H_ #define LIBGLESV2_GLOBALSTATE_H_ +#include <EGL/egl.h> + namespace gl { class Context; @@ -16,14 +18,32 @@ class Context; Context *GetGlobalContext(); Context *GetValidGlobalContext(); -} // namespace gl +} namespace egl { -class Thread; +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(); -Thread *GetCurrentThread(); +void SetGlobalContext(gl::Context *context); +gl::Context *GetGlobalContext(); -} // namespace egl +} #endif // LIBGLESV2_GLOBALSTATE_H_ diff --git a/gfx/angle/src/libGLESv2/moz.build b/gfx/angle/src/libGLESv2/moz.build index 08c60c213..1d40b3b67 100755 --- a/gfx/angle/src/libGLESv2/moz.build +++ b/gfx/angle/src/libGLESv2/moz.build @@ -39,6 +39,9 @@ if CONFIG['GNU_CXX']: '-Wno-shadow-local', ] +if CONFIG['MOZ_DIRECTX_SDK_PATH'] and not CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: + LOCAL_INCLUDES += ['%' + '%s/include/' % CONFIG['MOZ_DIRECTX_SDK_PATH']] + DEFINES['_CRT_SECURE_NO_DEPRECATE'] = True DEFINES['_HAS_EXCEPTIONS'] = 0 @@ -70,6 +73,11 @@ DEFINES['ANGLE_ENABLE_KEYEDMUTEX'] = "1" if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: OS_LIBS += [ 'd3d9', 'dxguid' ] +else: + EXTRA_DSO_LDOPTS += [ + '\'%s/lib/%s/d3d9.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']), + '\'%s/lib/%s/dxguid.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']), + ] GeckoSharedLibrary('libGLESv2', linkage=None) |