diff options
author | Sven Gothel <[email protected]> | 2013-11-04 15:07:14 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-11-04 15:07:14 +0100 |
commit | 613e33ee8ffc1f2b9c5db1e1b5bb5253a159ed6d (patch) | |
tree | 761c21e05e274bcea3852406fdbc63c25f266b10 /make/config/jogl/glx-CustomCCode.c | |
parent | 7433e513c1f109f75aa34c224b1f5f14b612cba8 (diff) |
Bug 888 - Validate CPU Runtime Performance: X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(..)
X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(..) ran over all FB configs and for each it grabbed
native config values separately. Fetching them in bulk mode saves around 7% of this function's cost.
Also reuse XRenderPictFormat instance for 'XRenderDirectFormat XRenderFindVisualFormat(..)' call,
saving a few NIO creation cycles w/ StructAccessor.
Biggest savior is X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationFBConfig()'s
fast path w/o chooser and usable 1st FBConfig. Here we only issue 'GLXFBConfig2GLCapabilities(..)'
on the first valid entry.
Test w/ 50 X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationFBConfig() invocations:
- pre change: 1.708 ms
- post change: 650 ms
Time is no spent almost solely on native glXChooseFBConfig (546ms).
Diffstat (limited to 'make/config/jogl/glx-CustomCCode.c')
-rw-r--r-- | make/config/jogl/glx-CustomCCode.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/make/config/jogl/glx-CustomCCode.c b/make/config/jogl/glx-CustomCCode.c index 71dc68b08..5c73dfea6 100644 --- a/make/config/jogl/glx-CustomCCode.c +++ b/make/config/jogl/glx-CustomCCode.c @@ -61,6 +61,31 @@ static void _initClazzAccess(JNIEnv *env) { /* Java->C glue code: * Java package: jogamp.opengl.x11.glx.GLX + * Java method: int glXGetFBConfigAttributes(long dpy, long config, IntBuffer attributes, IntBuffer values) + */ +JNIEXPORT jint JNICALL +Java_jogamp_opengl_x11_glx_GLX_dispatch_1glXGetFBConfigAttributes(JNIEnv *env, jclass _unused, jlong dpy, jlong config, jint attributeCount, jobject attributes, jint attributes_byte_offset, jobject values, jint values_byte_offset, jlong procAddress) { + typedef int (APIENTRY*_local_PFNGLXGETFBCONFIGATTRIBPROC)(Display * dpy, GLXFBConfig config, int attribute, int * value); + _local_PFNGLXGETFBCONFIGATTRIBPROC ptr_glXGetFBConfigAttrib = (_local_PFNGLXGETFBCONFIGATTRIBPROC) (intptr_t) procAddress; + assert(ptr_glXGetFBConfigAttrib != NULL); + + int err = 0; + if ( attributeCount > 0 && NULL != attributes ) { + int i; + int * attributes_ptr = (int *) (((char*) (*env)->GetDirectBufferAddress(env, attributes)) + attributes_byte_offset); + int * values_ptr = (int *) (((char*) (*env)->GetDirectBufferAddress(env, values)) + values_byte_offset); + for(i=0; 0 == err && i<attributeCount; i++) { + err = (* ptr_glXGetFBConfigAttrib) ((Display *) (intptr_t) dpy, (GLXFBConfig) (intptr_t) config, attributes_ptr[i], &values_ptr[i]); + } + if( 0 != err ) { + values_ptr[0] = i; + } + } + return (jint)err; +} + +/* Java->C glue code: + * Java package: jogamp.opengl.x11.glx.GLX * Java method: XVisualInfo glXGetVisualFromFBConfig(long dpy, long config) * C function: XVisualInfo * glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config); */ |