You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sp...@us...> - 2011-08-16 22:17:39
|
Revision: 3616 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3616&view=rev Author: spasi Date: 2011-08-16 22:17:32 +0000 (Tue, 16 Aug 2011) Log Message: ----------- Added unicode support on Windows. Fixed AL and GLES native stub bindings. Replaced many GetStringNativeChars usages with a Java implementation. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/util/generator/SignatureTranslator.java trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_GLContext.c trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c trunk/LWJGL/src/native/windows/Window.h trunk/LWJGL/src/native/windows/opengl/context.c trunk/LWJGL/src/native/windows/opengl/context.h trunk/LWJGL/src/native/windows/opengles/context.c trunk/LWJGL/src/native/windows/opengles/context.h trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-08-16 22:17:32 UTC (rev 3616) @@ -33,6 +33,8 @@ import java.lang.reflect.Field; import java.nio.*; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; /** * [INTERNAL USE ONLY] @@ -43,6 +45,16 @@ */ public final class MemoryUtil { + private static final CharsetEncoder textEncoder; + + static { + CharsetEncoder encoder = Charset.defaultCharset().newEncoder(); + if ( 1.0f < encoder.maxBytesPerChar() ) + encoder = Charset.forName("ISO-8859-1").newEncoder(); + + textEncoder = encoder; + } + private static final Accessor memUtil; static { @@ -92,10 +104,6 @@ private MemoryUtil() { } - public static String wrap(final String test) { - return "MemoryUtil.getAddress(" + test + ")"; - } - /** * Returns the memory address of the specified buffer. [INTERNAL USE ONLY] * @@ -179,6 +187,66 @@ public static long getAddressSafe(PointerBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + // --- [ String utilities ] --- + + /** + * Returns the specified text as a null-terminated CharBuffer. + * + * @param text the text to encode + * + * @return the encoded text + */ + public static CharBuffer encodeUTF16(final CharSequence text) { + CharBuffer buffer = BufferUtils.createCharBuffer(text.length() + 1); + buffer.append(text).append('\0'); + buffer.flip(); + return buffer; + } + + /** + * Returns the specified text array as a CharBuffer. The CharBuffer is packed + * and each text is null-terminated. + * + * @param text the text array to encode + * + * @return the encoded text + */ + public static CharBuffer encodeUTF16(final CharSequence... text) { + int len = 0; + for ( CharSequence cs : text ) + len += cs.length(); + + final CharBuffer buffer = BufferUtils.createCharBuffer(len + text.length); + for ( CharSequence cs : text ) + buffer.append(cs).append('\0'); + + buffer.flip(); + return buffer; + } + + /** + * Encodes and null-terminated the specified text and returns a ByteBuffer. + * If text is null, null is returned. + * + * @param text the text to encode + * + * @return the encoded text or null + * + * @see String#getBytes() + */ + public static ByteBuffer encodeASCII(final CharSequence text) { + if ( text == null ) + return null; + + final ByteBuffer buffer = BufferUtils.createByteBuffer(text.length() + 1); + + textEncoder.encode(CharBuffer.wrap(text), buffer, true); + buffer.put((byte)0); + buffer.flip(); + + return buffer; + } + interface Accessor { long getAddress(Buffer buffer); Modified: trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2011-08-16 22:17:32 UTC (rev 3616) @@ -31,6 +31,7 @@ */ package org.lwjgl; +import java.nio.CharBuffer; import java.security.PrivilegedExceptionAction; import java.security.PrivilegedActionException; import java.security.AccessController; @@ -95,9 +96,15 @@ if(!Display.isCreated()) { initCommonControls(); } - nAlert(getHwnd(), title, message); + + LWJGLUtil.log(String.format("*** Alert *** %s\n%s\n", title, message)); + + // Pack both strings in the same buffer + final CharBuffer buffer = MemoryUtil.encodeUTF16(title, message); + final long address = MemoryUtil.getAddress0(buffer); + nAlert(getHwnd(), address, address + (title.length() + 1) * 2); } - private static native void nAlert(long parent_hwnd, String title, String message); + private static native void nAlert(long parent_hwnd, long title, long message); private static native void initCommonControls(); public boolean openURL(final String url) { Modified: trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java 2011-08-16 22:17:32 UTC (rev 3616) @@ -31,7 +31,7 @@ */ package org.lwjgl.openal; -import java.nio.Buffer; +import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.HashMap; @@ -199,7 +199,8 @@ * @return opened device, or null */ public static ALCdevice alcOpenDevice(String devicename) { - long device_address = nalcOpenDevice(devicename); + ByteBuffer buffer = MemoryUtil.encodeASCII(devicename); + long device_address = nalcOpenDevice(MemoryUtil.getAddressSafe(buffer)); if(device_address != 0) { ALCdevice device = new ALCdevice(device_address); synchronized (ALC10.devices) { @@ -209,7 +210,7 @@ } return null; } - static native long nalcOpenDevice(String devicename); + static native long nalcOpenDevice(long devicename); /** * The <code>alcCloseDevice</code> function allows the application (i.e. the client program) to @@ -395,11 +396,12 @@ * @return true if extension is available, false if not */ public static boolean alcIsExtensionPresent(ALCdevice device, String extName) { - boolean result = nalcIsExtensionPresent(getDevice(device), extName); + ByteBuffer buffer = MemoryUtil.encodeASCII(extName); + boolean result = nalcIsExtensionPresent(getDevice(device), MemoryUtil.getAddress(buffer)); Util.checkALCError(device); return result; } - static native boolean nalcIsExtensionPresent(long device, String extName); + private static native boolean nalcIsExtensionPresent(long device, long extName); /** * Enumeration/token values are device independend, but tokens defined for @@ -412,11 +414,12 @@ * @return value of enumeration */ public static int alcGetEnumValue(ALCdevice device, String enumName) { - int result = nalcGetEnumValue(getDevice(device), enumName); + ByteBuffer buffer = MemoryUtil.encodeASCII(enumName); + int result = nalcGetEnumValue(getDevice(device), MemoryUtil.getAddress(buffer)); Util.checkALCError(device); return result; } - static native int nalcGetEnumValue(long device, String enumName); + private static native int nalcGetEnumValue(long device, long enumName); static long getDevice(ALCdevice device) { if(device != null) { Modified: trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java 2011-08-16 22:17:32 UTC (rev 3616) @@ -92,7 +92,8 @@ * @return ALCdevice if it was possible to open a device */ public static ALCdevice alcCaptureOpenDevice(String devicename, int frequency, int format, int buffersize) { - long device_address = nalcCaptureOpenDevice(devicename, frequency, format, buffersize); + ByteBuffer buffer = MemoryUtil.encodeASCII(devicename); + long device_address = nalcCaptureOpenDevice(MemoryUtil.getAddress(buffer), frequency, format, buffersize); if(device_address != 0) { ALCdevice device = new ALCdevice(device_address); synchronized (ALC10.devices) { @@ -102,7 +103,7 @@ } return null; } - static native long nalcCaptureOpenDevice( String devicename, int frequency, int format, int buffersize); + private static native long nalcCaptureOpenDevice(long devicename, int frequency, int format, int buffersize); /** * The alcCaptureCloseDevice function allows the application to disconnect from a capture Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java 2011-08-16 22:17:32 UTC (rev 3616) @@ -33,6 +33,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.MemoryUtil; import org.lwjgl.Sys; import java.nio.ByteBuffer; @@ -143,7 +144,12 @@ return 0; } - static native long getFunctionAddress(String name); + /** Helper method to get a pointer to a named function in the OpenCL library. */ + static long getFunctionAddress(String name) { + ByteBuffer buffer = MemoryUtil.encodeASCII(name); + return ngetFunctionAddress(MemoryUtil.getAddress(buffer)); + } + private static native long ngetFunctionAddress(long name); static native ByteBuffer getHostBuffer(final long address, final int size); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java 2011-08-16 22:17:32 UTC (rev 3616) @@ -33,9 +33,11 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.MemoryUtil; import org.lwjgl.Sys; import java.lang.reflect.Method; +import java.nio.ByteBuffer; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; @@ -187,8 +189,12 @@ return 0; } - /** Helper method to get a pointer to a named function in the OpenGL library */ - static native long getFunctionAddress(String name); + /** Helper method to get a pointer to a named function in the OpenGL library. */ + static long getFunctionAddress(String name) { + ByteBuffer buffer = MemoryUtil.encodeASCII(name); + return ngetFunctionAddress(MemoryUtil.getAddress(buffer)); + } + private static native long ngetFunctionAddress(long name); /** * Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities. Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-08-16 22:17:32 UTC (rev 3616) @@ -38,15 +38,13 @@ * @author elias_naur */ -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.nio.LongBuffer; +import java.nio.*; import java.awt.Canvas; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.BufferUtils; +import org.lwjgl.MemoryUtil; import org.lwjgl.input.Cursor; import org.lwjgl.input.Mouse; import org.lwjgl.opengles.EGL; @@ -141,11 +139,11 @@ private static final int SWP_FRAMECHANGED = 0x0020; private static final int GWL_STYLE = -16; - private static final int GWL_EXSTYLE = -20; - + private static final int GWL_EXSTYLE = -20; + private static final int WS_THICKFRAME = 0x00040000; - + private static WindowsDisplay current_display; private static boolean cursor_clipped; @@ -217,9 +215,9 @@ } peer_info.initDC(getHwnd(), getHdc()); showWindow(getHwnd(), SW_SHOWDEFAULT); - + updateWidthAndHeight(); - + if ( parent == null ) { if(Display.isResizable()) { setResizable(true); @@ -233,7 +231,7 @@ throw e; } } - + private void updateWidthAndHeight() { getClientRect(hwnd, rect_buffer); rect.copyFromBuffer(rect_buffer); @@ -440,9 +438,10 @@ private static native DisplayMode getCurrentDisplayMode() throws LWJGLException; public void setTitle(String title) { - nSetTitle(hwnd, title); + CharBuffer buffer = MemoryUtil.encodeUTF16(title); + nSetTitle(hwnd, MemoryUtil.getAddress0(buffer)); } - private static native void nSetTitle(long hwnd, String title); + private static native void nSetTitle(long hwnd, long title); public boolean isCloseRequested() { boolean saved = close_requested; @@ -786,7 +785,7 @@ byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); boolean repeat = state == previous_state; if (keyboard != null) - keyboard.handleChar((int)(wParam & 0xFF), millis, repeat); + keyboard.handleChar((int)(wParam & 0xFFFF), millis, repeat); } private void handleKeyButton(long wParam, long lParam, long millis) { @@ -991,12 +990,12 @@ public boolean isInsideWindow() { return mouseInside; } - + public void setResizable(boolean resizable) { if(this.resizable != resizable) { long style = getWindowLongPtr(hwnd, GWL_STYLE); long styleex = getWindowLongPtr(hwnd, GWL_EXSTYLE); - + // update frame style if(resizable) { setWindowLongPtr(hwnd, GWL_STYLE, style |= WS_THICKFRAME); @@ -1010,16 +1009,16 @@ rect.copyFromBuffer(rect_buffer); adjustWindowRectEx(rect_buffer, style, false, styleex); rect.copyFromBuffer(rect_buffer); - + // force a frame update and resize accordingly setWindowPos(hwnd, HWND_TOP, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); - + updateWidthAndHeight(); resized = false; } - this.resizable = resizable; + this.resizable = resizable; } - + private native boolean adjustWindowRectEx(IntBuffer rectBuffer, long style, boolean menu, long styleex); public boolean wasResized() { Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/SignatureTranslator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/SignatureTranslator.java 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/SignatureTranslator.java 2011-08-16 22:17:32 UTC (rev 3616) @@ -91,11 +91,13 @@ } else type_name = t.getDeclaration().getQualifiedName(); - signature.append("L"); - signature.append(getNativeNameFromClassName(type_name)); - signature.append(";"); - if ( add_position_signature && Utils.isAddressableType(type) && !String.class.equals(type) ) - signature.append("I"); + if ( Utils.isAddressableType(type) && !String.class.equals(type) ) + signature.append("J"); + else { + signature.append("L"); + signature.append(getNativeNameFromClassName(type_name)); + signature.append(";"); + } } public void visitDeclaredType(DeclaredType t) { Modified: trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_GLContext.c =================================================================== --- trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_GLContext.c 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_GLContext.c 2011-08-16 22:17:32 UTC (rev 3616) @@ -1,31 +1,31 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -35,13 +35,8 @@ #include "org_lwjgl_opengl_GLContext.h" #include "extgl.h" -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_GLContext_getFunctionAddress(JNIEnv *env, jclass clazz, jstring function_name) { - jlong address_jlong; - char *function_name_pointer = GetStringNativeChars(env, function_name); - void *address = extgl_GetProcAddress(function_name_pointer); - free(function_name_pointer); - address_jlong = (jlong)(intptr_t)address; - return address_jlong; +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_GLContext_ngetFunctionAddress(JNIEnv *env, jclass clazz, jlong function_name) { + return (jlong)(intptr_t)extgl_GetProcAddress((char *)(intptr_t)function_name); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nLoadOpenGLLibrary(JNIEnv * env, jclass clazz) { Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2011-08-16 22:17:32 UTC (rev 3616) @@ -131,24 +131,8 @@ * C Specification: * ALCdevice *alcOpenDevice( const ALubyte *tokstr ); */ -static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcOpenDevice (JNIEnv *env, jclass clazz, jstring tokstr) { - char * tokenstring; - ALCdevice* device; - - if(tokstr != NULL) { - tokenstring = GetStringNativeChars(env, tokstr); - } else { - tokenstring = NULL; - } - - /* get device */ - device = alcOpenDevice((ALubyte *) tokenstring); - - if(tokenstring != NULL) { - free(tokenstring); - } - - return (jlong)((intptr_t)device); +static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcOpenDevice (JNIEnv *env, jclass clazz, jlong tokstr) { + return (jlong)(intptr_t)alcOpenDevice((ALubyte *)(intptr_t)tokstr); } /** @@ -255,15 +239,8 @@ * C Specification: * ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName); */ -static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring extName) { - /* get extension */ - ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName); - - jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), functionname); - - free(functionname); - - return result; +static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jlong extName) { + return (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), (ALubyte*)(intptr_t)extName); } /** @@ -272,15 +249,8 @@ * C Specification: * ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName); */ -static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring enumName) { - /* get extension */ - ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName); - - jint result = (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), enumerationname); - - free(enumerationname); - - return result; +static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jlong enumName) { + return (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), (ALubyte*)(intptr_t)enumName); } /** @@ -294,10 +264,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC10_initNativeStubs(JNIEnv *env, jclass clazz) { JavaMethodAndExtFunction functions[] = { {"nalcGetString", "(JI)Ljava/lang/String;", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetString, "alcGetString", (void*)&alcGetString}, - {"nalcGetIntegerv", "(JIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv}, - {"nalcOpenDevice", "(Ljava/lang/String;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice}, + {"nalcGetIntegerv", "(JIIJ)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv}, + {"nalcOpenDevice", "(J)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice}, {"nalcCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcCloseDevice, "alcCloseDevice", (void*)&alcCloseDevice}, - {"nalcCreateContext", "(JLjava/nio/IntBuffer;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext}, + {"nalcCreateContext", "(JJ)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext}, {"nalcMakeContextCurrent", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent, "alcMakeContextCurrent", (void*)&alcMakeContextCurrent}, {"nalcProcessContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcProcessContext, "alcProcessContext", (void*)&alcProcessContext}, {"nalcGetCurrentContext", "()J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext, "alcGetCurrentContext", (void*)&alcGetCurrentContext}, @@ -305,8 +275,8 @@ {"nalcSuspendContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcSuspendContext, "alcSuspendContext", (void*)&alcSuspendContext}, {"nalcDestroyContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcDestroyContext, "alcDestroyContext", (void*)&alcDestroyContext}, {"nalcGetError", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetError, "alcGetError", (void*)&alcGetError}, - {"nalcIsExtensionPresent", "(JLjava/lang/String;)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent}, - {"nalcGetEnumValue", "(JLjava/lang/String;)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue} + {"nalcIsExtensionPresent", "(JJ)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent}, + {"nalcGetEnumValue", "(JJ)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue} }; int num_functions = NUMFUNCTIONS(functions); extal_InitializeClass(env, clazz, num_functions, functions); Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c 2011-08-16 22:17:32 UTC (rev 3616) @@ -60,18 +60,8 @@ * Method: nalcCaptureOpenDevice * Signature: (Ljava/lang/String;III)J */ -static jlong JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice(JNIEnv *env, jclass clazz, jstring devicename, jint frequency, jint format, jint buffersize) { - ALubyte* dev_name = NULL; - ALCdevice* device = NULL; - - if(devicename != NULL) { - dev_name = (ALubyte*) GetStringNativeChars(env, devicename); - } - - device = alcCaptureOpenDevice((const char *)dev_name, (unsigned int) frequency, format, buffersize); - - free(dev_name); - return (jlong) ((intptr_t)device); +static jlong JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice(JNIEnv *env, jclass clazz, jlong devicename, jint frequency, jint format, jint buffersize) { + return (jlong)(intptr_t)alcCaptureOpenDevice((const char *)(intptr_t)devicename, (unsigned int) frequency, format, buffersize); } /* @@ -121,11 +111,11 @@ #endif JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC11_initNativeStubs(JNIEnv *env, jclass clazz) { JavaMethodAndExtFunction functions[] = { - {"nalcCaptureOpenDevice", "(Ljava/lang/String;III)J", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice, "alcCaptureOpenDevice", (void*)&alcCaptureOpenDevice}, + {"nalcCaptureOpenDevice", "(JIII)J", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice, "alcCaptureOpenDevice", (void*)&alcCaptureOpenDevice}, {"nalcCaptureCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureCloseDevice, "alcCaptureCloseDevice", (void*)&alcCaptureCloseDevice}, {"nalcCaptureStart", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStart, "alcCaptureStart", (void*)&alcCaptureStart}, {"nalcCaptureStop", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStop, "alcCaptureStop", (void*)&alcCaptureStop}, - {"nalcCaptureSamples", "(JLjava/nio/ByteBuffer;II)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureSamples, "alcCaptureSamples", (void*)&alcCaptureSamples} + {"nalcCaptureSamples", "(JJI)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureSamples, "alcCaptureSamples", (void*)&alcCaptureSamples} }; int num_functions = NUMFUNCTIONS(functions); extal_InitializeClass(env, clazz, num_functions, functions); Modified: trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c 2011-08-16 22:17:32 UTC (rev 3616) @@ -42,13 +42,8 @@ extcl_UnloadLibrary(); } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_getFunctionAddress(JNIEnv *env, jclass clazz, jstring function_name) { - jlong address_jlong; - char *function_name_pointer = GetStringNativeChars(env, function_name); - void *address = extcl_GetProcAddress(function_name_pointer); - free(function_name_pointer); - address_jlong = (jlong)(intptr_t)address; - return address_jlong; +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_ngetFunctionAddress(JNIEnv *env, jclass clazz, jlong function_name) { + return (jlong)(intptr_t)extcl_GetProcAddress((char *)(intptr_t)function_name); } JNIEXPORT jobject JNICALL Java_org_lwjgl_opencl_CL_getHostBuffer(JNIEnv *env, jclass clazz, jlong address, jint size) { Modified: trunk/LWJGL/src/native/windows/Window.h =================================================================== --- trunk/LWJGL/src/native/windows/Window.h 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/windows/Window.h 2011-08-16 22:17:32 UTC (rev 3616) @@ -1,35 +1,35 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + /** * $Id$ * @@ -52,6 +52,10 @@ #define _WIN32_WINNT 0x0400 #endif + #define _UNICODE + #include <tchar.h> + + #define UNICODE #include <windows.h> #include <jni.h> #include "common_tools.h" Modified: trunk/LWJGL/src/native/windows/opengl/context.c =================================================================== --- trunk/LWJGL/src/native/windows/opengl/context.c 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/windows/opengl/context.c 2011-08-16 22:17:32 UTC (rev 3616) @@ -1,31 +1,31 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -38,15 +38,14 @@ */ #include <malloc.h> -#include <jni.h> -#include "common_tools.h" +#include "Window.h" #include "extgl.h" #include "extgl_wgl.h" #include "context.h" extern HINSTANCE dll_handle; // Handle to the LWJGL dll -#define _CONTEXT_PRIVATE_CLASS_NAME "__lwjgl_context_class_name" +#define _CONTEXT_PRIVATE_CLASS_NAME _T("__lwjgl_context_class_name") /* * Register the LWJGL window class. @@ -85,7 +84,7 @@ return false; } - // make that the pixel format of the device context + // make that the pixel format of the device context if (SetPixelFormat(hdc, iPixelFormat, &desc) == FALSE) { throwFormattedException(env, "SetPixelFormat failed (%d)", GetLastError()); return false; @@ -134,14 +133,14 @@ RECT clientSize; DWORD exstyle, windowflags; HWND new_hwnd; - + getWindowFlags(&windowflags, &exstyle, undecorated, child_window); clientSize.bottom = height; clientSize.left = 0; clientSize.right = width; clientSize.top = 0; - + AdjustWindowRectEx( &clientSize, // client-rectangle structure windowflags, // window styles @@ -150,9 +149,9 @@ ); // Create the window now, using that class: new_hwnd = CreateWindowEx ( - exstyle, + exstyle, window_class_name, - "", + _T(""), windowflags, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, parent, @@ -191,12 +190,12 @@ int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); - + jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); jboolean floating_point = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); jboolean floating_point_packed = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); jboolean sRGB = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); - + int pixel_type; int iPixelFormat; unsigned int num_formats_returned; @@ -206,18 +205,18 @@ BOOL result; jlong i; int bpe = convertToBPE(bpp); - + if ( floating_point ) pixel_type = WGL_TYPE_RGBA_FLOAT_ARB; else if ( floating_point_packed ) pixel_type = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT; else pixel_type = WGL_TYPE_RGBA_ARB; - + initAttribList(&attrib_list); if (window) { putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE); - } + } if (pbuffer) { putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE); } @@ -299,31 +298,31 @@ int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); - unsigned int flags = PFD_DRAW_TO_WINDOW | // support window + unsigned int flags = PFD_DRAW_TO_WINDOW | // support window PFD_SUPPORT_OPENGL | (double_buffer ? PFD_DOUBLEBUFFER : 0) | (stereo ? PFD_STEREO : 0); PIXELFORMATDESCRIPTOR desc; int iPixelFormat; - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd - 1, // version number - flags, // RGBA type + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd + 1, // version number + flags, // RGBA type PFD_TYPE_RGBA, - (BYTE)bpp, - 0, 0, 0, 0, 0, 0, // color bits ignored - (BYTE)alpha, - 0, // shift bit ignored - accum_bpp + accum_alpha, // no accumulation buffer - 0, 0, 0, 0, // accum bits ignored - (BYTE)depth, - (BYTE)stencil, - num_aux_buffers, + (BYTE)bpp, + 0, 0, 0, 0, 0, 0, // color bits ignored + (BYTE)alpha, + 0, // shift bit ignored + accum_bpp + accum_alpha, // no accumulation buffer + 0, 0, 0, 0, // accum bits ignored + (BYTE)depth, + (BYTE)stencil, + num_aux_buffers, PFD_MAIN_PLANE, // main layer - 0, // reserved + 0, // reserved 0, 0, 0 // layer masks ignored }; - // get the best available match of pixel format for the device context + // get the best available match of pixel format for the device context iPixelFormat = ChoosePixelFormat(hdc, &pfd); if (iPixelFormat == 0) { throwException(env, "Failed to choose pixel format"); @@ -442,14 +441,14 @@ HDC dummy_hdc; int pixel_format_id; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - + int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I")); bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); bool use_arb_selection = samples > 0 || floating_point || floating_point_packed || sRGB || pbuffer || pixelFormatCaps != NULL; - + pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer); if (!(*env)->ExceptionOccurred(env) && use_arb_selection) { dummy_hwnd = createDummyWindow(origin_x, origin_y); Modified: trunk/LWJGL/src/native/windows/opengl/context.h =================================================================== --- trunk/LWJGL/src/native/windows/opengl/context.h 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/windows/opengl/context.h 2011-08-16 22:17:32 UTC (rev 3616) @@ -40,9 +40,7 @@ #ifndef __LWJGL_CONTEXT_H #define __LWJGL_CONTEXT_H -#include <windows.h> -#include <jni.h> -#include "common_tools.h" +#include "Window.h" #include "extgl.h" #include "extgl_wgl.h" Modified: trunk/LWJGL/src/native/windows/opengles/context.c =================================================================== --- trunk/LWJGL/src/native/windows/opengles/context.c 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/windows/opengles/context.c 2011-08-16 22:17:32 UTC (rev 3616) @@ -38,15 +38,14 @@ */ #include <malloc.h> -#include <jni.h> -#include "common_tools.h" +#include "Window.h" #include "extgl.h" /*#include "extgl_wgl.h"*/ #include "context.h" extern HINSTANCE dll_handle; // Handle to the LWJGL dll -#define _CONTEXT_PRIVATE_CLASS_NAME "__lwjgl_context_class_name" +#define _CONTEXT_PRIVATE_CLASS_NAME _T("__lwjgl_context_class_name") /* * Register the LWJGL window class. @@ -154,7 +153,7 @@ new_hwnd = CreateWindowEx ( exstyle, window_class_name, - "", + _T(""), windowflags, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, parent, Modified: trunk/LWJGL/src/native/windows/opengles/context.h =================================================================== --- trunk/LWJGL/src/native/windows/opengles/context.h 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/windows/opengles/context.h 2011-08-16 22:17:32 UTC (rev 3616) @@ -40,9 +40,7 @@ #ifndef __LWJGL_CONTEXT_H #define __LWJGL_CONTEXT_H -#include <windows.h> -#include <jni.h> -#include "common_tools.h" +#include "Window.h" #include "extgl.h" typedef struct { Modified: trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c 2011-08-16 22:17:32 UTC (rev 3616) @@ -1,35 +1,35 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + /** * $Id$ * @@ -56,16 +56,9 @@ return time; } -JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title, jstring message) { +JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jlong title, jlong message) { HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; - char * eMessageText = GetStringNativeChars(env, message); - char * cTitleBarText = GetStringNativeChars(env, title); - MessageBox(hwnd, eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); - - printfDebugJava(env, "*** Alert ***%s\n%s\n", cTitleBarText, eMessageText); - - free(eMessageText); - free(cTitleBarText); + MessageBox(hwnd, (LPCTSTR)(intptr_t)message, (LPCTSTR)(intptr_t)title, MB_OK | MB_TOPMOST); } JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_initCommonControls(JNIEnv * env, jclass unused) { Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2011-08-15 19:24:39 UTC (rev 3615) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2011-08-16 22:17:32 UTC (rev 3616) @@ -40,9 +40,9 @@ */ #define _PRIVATE_WINDOW_H_ -#include <windowsx.h> #include <malloc.h> #include "Window.h" +#include <windowsx.h> /*#include "extgl_wgl.h"*/ #include "common_tools.h" #include "display.h" @@ -51,7 +51,7 @@ #include "context.h" #include <commctrl.h> -#define WINDOWCLASSNAME "LWJGL" +#define WINDOWCLASSNAME _T("LWJGL") /* * WindowProc for the GL window. @@ -134,11 +134,9 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetTitle - (JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title_obj) { + (JNIEnv * env, jclass unused, jlong hwnd_ptr, jlong title) { HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; - char * title = GetStringNativeChars(env, title_obj); - SetWindowText(hwnd, title); - free(title); + SetWindowText(hwnd, (LPCTSTR)(intptr_t)title); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nUpdate(JNIEnv * env, jclass class) { @@ -429,22 +427,19 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowLongPtr (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex, jlong longPtr) { - HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; return SetWindowLongPtr(hwnd, nindex, (LONG_PTR) longPtr); } JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowLongPtr (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex) { - HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; jlong result = GetWindowLongPtr(hwnd, nindex); return result; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowPos - (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hwnd_after_ptr, jint x, jint y, jint width, jint height, jlong uflags) { - + (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hwnd_after_ptr, jint x, jint y, jint width, jint height, jlong uflags) { jboolean result; HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; HWND hwnd_after = (HWND)(INT_PTR)hwnd_after_ptr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2011-08-15 19:24:45
|
Revision: 3615 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3615&view=rev Author: matzon Date: 2011-08-15 19:24:39 +0000 (Mon, 15 Aug 2011) Log Message: ----------- Updating version to 2.8.0, still some stuff to do tho Modified Paths: -------------- trunk/LWJGL/platform_build/build-definitions.xml trunk/LWJGL/src/java/org/lwjgl/Sys.java Modified: trunk/LWJGL/platform_build/build-definitions.xml =================================================================== --- trunk/LWJGL/platform_build/build-definitions.xml 2011-08-14 17:07:23 UTC (rev 3614) +++ trunk/LWJGL/platform_build/build-definitions.xml 2011-08-15 19:24:39 UTC (rev 3615) @@ -12,7 +12,7 @@ <property name="lwjgl.docs" location="doc" /> <property name="lwjgl.temp" location="temp" /> <property name="lwjgl.res" location="res" /> - <property name="lwjgl.version" value="2.7.1" /> + <property name="lwjgl.version" value="2.8.0" /> <property name="lwjgl.web" location="www" /> <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/AMD*.java,org/lwjgl/opengl/APPLE*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/NVX*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java,org/lwjgl/opengl/GREMEDY*.java"/> Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2011-08-14 17:07:23 UTC (rev 3614) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2011-08-15 19:24:39 UTC (rev 3615) @@ -54,7 +54,7 @@ private static final String JNI_LIBRARY_NAME = "lwjgl"; /** Current version of library */ - private static final String VERSION = "2.7.1"; + private static final String VERSION = "2.8.0"; private static final String POSTFIX64BIT = "64"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-08-14 17:07:29
|
Revision: 3614 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3614&view=rev Author: kappa1 Date: 2011-08-14 17:07:23 +0000 (Sun, 14 Aug 2011) Log Message: ----------- AppletLoader: al_version tag now uses a case insensitive String (instead of float), much nicer for specifying application versions (e.g. "10.3.3.1 Beta"), still backwards compatible too :) Modified Paths: -------------- trunk/LWJGL/applet/advance/appletloader.html trunk/LWJGL/applet/basic/basicapplet.html trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/applet/advance/appletloader.html =================================================================== --- trunk/LWJGL/applet/advance/appletloader.html 2011-08-14 10:46:00 UTC (rev 3613) +++ trunk/LWJGL/applet/advance/appletloader.html 2011-08-14 17:07:23 UTC (rev 3614) @@ -32,12 +32,12 @@ <!-- Tags under here are optional --> - <!-- Version of Applet, important otherwise applet won't be cached, version change will update applet, must be int or float --> - <!-- <param name="al_version" value="0.1"> --> - <!-- whether to use cache - defaults to true --> <!-- <param name="al_cache" value="true"> --> + <!-- Version of Applet (case insensitive String), applet files not redownloaded if same version already in cache --> + <!-- <param name="al_version" value="0.1"> --> + <!-- background color to paint with, defaults to white --> <!-- <param name="boxbgcolor" value="#000000"> --> Modified: trunk/LWJGL/applet/basic/basicapplet.html =================================================================== --- trunk/LWJGL/applet/basic/basicapplet.html 2011-08-14 10:46:00 UTC (rev 3613) +++ trunk/LWJGL/applet/basic/basicapplet.html 2011-08-14 17:07:23 UTC (rev 3614) @@ -32,12 +32,12 @@ <!-- Tags under here are optional --> - <!-- Version of Applet, important otherwise applet won't be cached, version change will update applet, must be int or float --> - <!-- <param name="al_version" value="0.1"> --> - <!-- whether to use cache - defaults to true --> <!-- <param name="al_cache" value="true"> --> + <!-- Version of Applet (case insensitive String), applet files not redownloaded if same version already in cache --> + <!-- <param name="al_version" value="0.1"> --> + <!-- background color to paint with, defaults to white --> <!-- <param name="boxbgcolor" value="#000000"> --> Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-08-14 10:46:00 UTC (rev 3613) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-08-14 17:07:23 UTC (rev 3614) @@ -144,6 +144,7 @@ * <li>Bobjob</li> * <li>Dashiva</li> * <li>Dr_evil</li> + * <li>Elias Naur</li> * <li>Kevin Glass</li> * <li>Matthias Mann</li> * <li>Mickelukas</li> @@ -808,14 +809,12 @@ // if specified applet version already available don't download anything boolean versionAvailable = false; - // version of applet + // version string of applet String version = getParameter("al_version"); - float latestVersion = 0; - + // if applet version specifed, compare with version in the cache if (version != null) { - latestVersion = Float.parseFloat(version); - versionAvailable = compareVersion(versionFile, latestVersion); + versionAvailable = compareVersion(versionFile, version.toLowerCase()); } // if jars not available or need updating download them @@ -838,7 +837,7 @@ // save version information once jars downloaded successfully if (version != null) { percentage = 90; - writeObjectFile(versionFile, latestVersion); + writeObjectFile(versionFile, version.toLowerCase()); } // save file names with last modified info once downloaded successfully @@ -883,21 +882,23 @@ /** * This method will return true if the version stored in the file - * matches the supplied float version. + * matches the supplied String version. * * @param versionFile - location to file containing version information - * @param version - float version that needs to be compared + * @param version - String version that needs to be compared * @return returns true if the version in file matches specified version */ - protected boolean compareVersion(File versionFile, float version) { + protected boolean compareVersion(File versionFile, String version) { // if version file exists if (versionFile.exists()) { + String s = readStringFile(versionFile); + // compare to version with file - if (version == readFloatFile(versionFile)) { + if (s != null && s.equals(version)) { percentage = 90; // not need to download cache files again if(debugMode) { - System.out.println("Loading Cached Applet Version " + version); + System.out.println("Loading Cached Applet Version: " + version); } debug_sleep(2000); @@ -980,22 +981,21 @@ } /** - * read float from File + * read String object from File * * @param file to be read - * @return the float stored in the file or 0 if it fails + * @return the String stored in the file or null if it fails */ - protected float readFloatFile(File file) { + protected String readStringFile(File file) { try { - Float version = (Float)readObjectFile(file); - return version.floatValue(); + return (String)readObjectFile(file); } catch (Exception e) { // failed to read version file e.printStackTrace(); } - // return 0 if failed to read file - return 0; + // return null if failed to read file + return null; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-14 10:46:06
|
Revision: 3613 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3613&view=rev Author: spasi Date: 2011-08-14 10:46:00 +0000 (Sun, 14 Aug 2011) Log Message: ----------- Added support for AMD_pinned_memory. Added Paths: ----------- trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_pinned_memory.java Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_pinned_memory.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_pinned_memory.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_pinned_memory.java 2011-08-14 10:46:00 UTC (rev 3613) @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface AMD_pinned_memory { + + /** + * <strong>Official spec not released yet. Info from AMD developer forums:</strong><br/> + * Create a buffer object, bind it to the GL_EXTERNAL_VIRTUAL_MEMORY_AMD target and call glBufferData to 'allocate' space. + * When the driver sees you do this, it will use the pointer you supply directly rather than copying the data (that is, the + * GPU will access your application's memory). You can then use the buffer for other purposes such as a UBO, TBO or VBO by + * binding it to the appropriate targets. Synchronization is left to the application - make use of glFenceSync and glWaitSync. + * To release the memory, simply call glBufferData again on the buffer object on a different target, or delete the buffer + * object. Don't free the memory in the application until you've detached it from the buffer object or bad stuff will happen. + * <p/> + * Keep in mind that any memory you access will go over the PCIe bus which will be limited to 3-4 GB/s. This will work much + * better on Fusion systems (APUs). Theoretically, there isn't a limit to the amount of memory that can be pinned. However, + * when the OS pins memory, it removes it from the regular pagable pool and cannot swap it to disk (this is what pinning + * means). If you ask for too much, the OS will refuse to do it and the call will fail (the GL driver will return generate + * a GL_OUT_OF_MEMORY error). It is very likely that you'll hit this limit long before you run out of address space on the + * GPU, although in practice we do impose a moderate limit on the amount of pinned memory so as to not impact system stability + * and performance. + */ + int GL_EXTERNAL_VIRTUAL_MEMORY_AMD = 0x9160; + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-13 19:17:04
|
Revision: 3612 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3612&view=rev Author: spasi Date: 2011-08-13 19:16:58 +0000 (Sat, 13 Aug 2011) Log Message: ----------- Replaced Arrays.copyof with custom implementation for Java 5 compatibility. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-08-13 18:53:54 UTC (rev 3611) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-08-13 19:16:58 UTC (rev 3612) @@ -38,7 +38,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URLClassLoader; -import java.util.Arrays; /** * This classloader is responsible for applying the bytecode transformation to mapped objects. @@ -167,7 +166,7 @@ try { while ( true ) { if ( bytecode.length == len ) - bytecode = Arrays.copyOf(bytecode, len * 2); + bytecode = copyOf(bytecode, len * 2); int got = in.read(bytecode, len, bytecode.length - len); if ( got == -1 ) break; @@ -182,7 +181,13 @@ // ignore... } } - return Arrays.copyOf(bytecode, len); + return copyOf(bytecode, len); } + private static byte[] copyOf(byte[] original, int newLength) { + byte[] copy = new byte[newLength]; + System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength)); + return copy; + } + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-08-13 18:54:00
|
Revision: 3611 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3611&view=rev Author: kappa1 Date: 2011-08-13 18:53:54 +0000 (Sat, 13 Aug 2011) Log Message: ----------- Fix issue with Mouse getWidth/getHeight values being wrongly clipped when using Display.setParent(), thx to MatthiasM for finding this. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2011-08-13 17:20:59 UTC (rev 3610) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2011-08-13 18:53:54 UTC (rev 3611) @@ -362,8 +362,8 @@ y = poll_coord2; } if(clipMouseCoordinatesToWindow) { - x = Math.min(implementation.getWidth() - 1, Math.max(0, x)); - y = Math.min(implementation.getHeight() - 1, Math.max(0, y)); + x = Math.min(Display.getWidth() - 1, Math.max(0, x)); + y = Math.min(Display.getHeight() - 1, Math.max(0, y)); } dwheel += poll_dwheel; read(); @@ -453,8 +453,8 @@ last_event_raw_y = new_event_y; } if(clipMouseCoordinatesToWindow) { - event_x = Math.min(implementation.getWidth() - 1, Math.max(0, event_x)); - event_y = Math.min(implementation.getHeight() - 1, Math.max(0, event_y)); + event_x = Math.min(Display.getWidth() - 1, Math.max(0, event_x)); + event_y = Math.min(Display.getHeight() - 1, Math.max(0, event_y)); } event_dwheel = readBuffer.getInt(); event_nanos = readBuffer.getLong(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-13 17:21:06
|
Revision: 3610 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3610&view=rev Author: spasi Date: 2011-08-13 17:20:59 +0000 (Sat, 13 Aug 2011) Log Message: ----------- Fixed GL42 detection and added an @Optional so that AMD's beta driver works. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL42.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java 2011-08-10 17:27:49 UTC (rev 3609) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java 2011-08-13 17:20:59 UTC (rev 3610) @@ -221,7 +221,7 @@ { 1, 2, 3, 4, 5 }, // OpenGL 1 { 0, 1 }, // OpenGL 2 { 0, 1, 2, 3 }, // OpenGL 3 - { 0, 1 }, // OpenGL 4 + { 0, 1, 2 }, // OpenGL 4 }; for ( int major = 1; major <= GL_VERSIONS.length; major++ ) { Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL42.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL42.java 2011-08-10 17:27:49 UTC (rev 3609) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL42.java 2011-08-13 17:20:59 UTC (rev 3610) @@ -127,6 +127,7 @@ /** Returned in <params> by GetActiveUniform and GetActiveUniformsiv: */ int GL_UNSIGNED_INT_ATOMIC_COUNTER = 0x92DB; + @Optional(reason = "AMD's beta 4.2 driver (11.8) does not expose this") @StripPostfix("params") void glGetActiveAtomicCounterBufferiv(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-10 17:27:55
|
Revision: 3609 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3609&view=rev Author: spasi Date: 2011-08-10 17:27:49 +0000 (Wed, 10 Aug 2011) Log Message: ----------- Added EXT_texture_storage alias. Modified Paths: -------------- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java 2011-08-10 16:05:46 UTC (rev 3608) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java 2011-08-10 17:27:49 UTC (rev 3609) @@ -31,6 +31,7 @@ */ package org.lwjgl.opengl; +import org.lwjgl.util.generator.Alias; import org.lwjgl.util.generator.Dependent; import org.lwjgl.util.generator.Reuse; import org.lwjgl.util.generator.opengl.GLenum; @@ -38,6 +39,7 @@ import org.lwjgl.util.generator.opengl.GLuint; @Dependent +@Alias(value = "EXT_texture_storage", postfix = "EXT") public interface ARB_texture_storage { /** Accepted by the <value> parameter of GetTexParameter{if}v: */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-10 16:05:54
|
Revision: 3608 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3608&view=rev Author: spasi Date: 2011-08-10 16:05:46 +0000 (Wed, 10 Aug 2011) Log Message: ----------- Added support for cache-line padding and alignment. Made byteOffset() in MappedField optional. Misc fixes and improvements. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheLinePad.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheLineSize.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheUtil.java Modified: trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -449,15 +449,45 @@ * Gets a boolean property as a privileged action. */ public static boolean getPrivilegedBoolean(final String property_name) { - Boolean value = AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { public Boolean run() { return Boolean.getBoolean(property_name); } }); - return value; } /** + * Gets an integer property as a privileged action. + * + * @param property_name the integer property name + * + * @return the property value + */ + public static Integer getPrivilegedInteger(final String property_name) { + return AccessController.doPrivileged(new PrivilegedAction<Integer>() { + public Integer run() { + return Integer.getInteger(property_name); + } + }); + } + + /** + * Gets an integer property as a privileged action. + * + * @param property_name the integer property name + * @param default_val the default value to use if the property is not defined + * + * @return the property value + */ + public static Integer getPrivilegedInteger(final String property_name, final int default_val) { + return AccessController.doPrivileged(new PrivilegedAction<Integer>() { + public Integer run() { + return Integer.getInteger(property_name, default_val); + } + }); + } + + /** * Prints the given message to System.err if DEBUG is true. * * @param msg Message to print Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -60,6 +60,16 @@ assert (addr2 - addr1 == 4); assert (mapped.capacity() == MappedSomething.SIZEOF - 4); + { + assert (some.shared == 0); + assert (mapped.getInt(8) == 0); + + some.shared = 1234; + + assert (some.shared == 1234); + assert (mapped.getInt(8) == 1234); + } + some.view++; mapped = some.data; // creates new ByteBuffer instance Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -34,10 +34,10 @@ import org.lwjgl.MemoryUtil; import org.lwjgl.PointerBuffer; import org.lwjgl.opengl.Display; -import org.lwjgl.util.mapped.MappedObject; -import org.lwjgl.util.mapped.Pointer; +import org.lwjgl.util.mapped.*; import java.io.File; +import java.lang.reflect.Field; import java.nio.ByteBuffer; /** @author Riven */ @@ -145,4 +145,109 @@ } } + @MappedType(cacheLinePadding = true) + public static class MappedCacheLinePadded extends MappedObject { + + int foo; + int bar; + + } + + public static void testCacheLineAlignment() { + MappedCacheLinePadded data = MappedCacheLinePadded.malloc(10); + + assert (data.backingByteBuffer().capacity() == 10 * CacheUtil.getCacheLineSize()); + assert (MemoryUtil.getAddress(data.backingByteBuffer()) % CacheUtil.getCacheLineSize() == 0); + + for ( int i = 0; i < 10; i++ ) { + data.view = i; + + data.foo = i; + data.bar = i * 2; + } + + for ( int i = 0; i < 10; i++ ) { + data.view = i; + + assert (data.foo == i); + assert (data.bar == i * 2); + } + } + + public static class MappedFieldCacheLinePadded extends MappedObject { + + // If we assume CacheUtil.getCacheLineSize() == 64 + // 0 - 63 + @CacheLinePad long longBar; + // 64 - 71 + long longFoo; + // 72 - 75 + int intFoo; + // 128 - 131 + @CacheLinePad(before = true) int intBar; + // 192 - 195 + int foo; + // 256 - 267 + @CacheLinePad(before = true, after = false) + @MappedField(byteLength = 12) + ByteBuffer buffer; + // 268 - 271 + int bar; + + } + + public static void testCacheLinePadding() { + MappedFieldCacheLinePadded data = MappedFieldCacheLinePadded.map(CacheUtil.createByteBuffer(10 * MappedFieldCacheLinePadded.SIZEOF)); + + final int sizeof = + CacheUtil.getCacheLineSize() + + 8 + + (CacheUtil.getCacheLineSize() - 8) + + CacheUtil.getCacheLineSize() + + 4 + + (CacheUtil.getCacheLineSize() - 4) + + 12 + + 4; + + assert (MappedFieldCacheLinePadded.SIZEOF == sizeof); + assert (data.backingByteBuffer().capacity() == sizeof * 10); + + for ( int i = 0; i < 10; i++ ) { + data.view = i; + + data.longFoo = i * 1000000000L; + data.longBar = i * 2000000000L; + data.intFoo = i * 1000; + data.intBar = i * 2000; + data.foo = i; + } + + for ( int i = 0; i < 10; i++ ) { + data.view = i; + + assert (data.longFoo == i * 1000000000L); + assert (data.longBar == i * 2000000000L); + assert (data.intFoo == i * 1000); + assert (data.intBar == i * 2000); + assert (data.foo == i); + } + } + + public static class POJOFieldCacheLinePadded { + + @CacheLinePad long longBar; + long longFoo; + int intFoo; + @CacheLinePad(before = true) int intBar; + int foo; + @CacheLinePad boolean bool; + int bar; + + } + + public static void testCacheLinePaddingPOJO() { + Field[] fields = new POJOFieldCacheLinePadded().getClass().getDeclaredFields(); + assert (fields.length == (1 + 7) + 1 + 1 + (15 + 1 + 15) + 1 + (1 + 63) + 1); + } + } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -42,9 +42,12 @@ @MappedField(byteOffset = 0) public int used; - @MappedField(byteOffset = 4, byteLength = 64 - 4) + @MappedField(byteLength = 64 - 4) // optional byteOffset public ByteBuffer data; + @MappedField(byteOffset = 12) // inside data + public int shared; + @Override public String toString() { return "MappedSomething[" + used + "]"; Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -52,6 +52,8 @@ MappedObjectTransformer.register(MappedSomething.class); MappedObjectTransformer.register(MappedObjectTests3.Xyz.class); MappedObjectTransformer.register(MappedObjectTests4.MappedPointer.class); + MappedObjectTransformer.register(MappedObjectTests4.MappedCacheLinePadded.class); + MappedObjectTransformer.register(MappedObjectTests4.MappedFieldCacheLinePadded.class); if ( MappedObjectClassLoader.fork(TestMappedObject.class, args) ) { return; @@ -75,6 +77,9 @@ MappedObjectTests4.testLocalView(); //MappedObjectTests4.testLWJGL(); MappedObjectTests4.testPointer(); + MappedObjectTests4.testCacheLineAlignment(); + MappedObjectTests4.testCacheLinePadding(); + MappedObjectTests4.testCacheLinePaddingPOJO(); System.out.println("done"); } Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -86,6 +86,8 @@ private int texBigID; private int texSmallID; + long animateTime; + private SpriteShootout() { } @@ -276,6 +278,8 @@ long timeUsed = 5000 + (startTime - System.currentTimeMillis()); startTime = System.currentTimeMillis() + 5000; System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount); + System.out.println("\tAnimation: " + (animateTime / fps / 1000) + "us"); + animateTime = 0; fps = 0; } } @@ -582,8 +586,12 @@ if ( animate ) { final ByteBuffer buffer = animVBO.map(batchSize * (2 * 4)); + long t0 = System.nanoTime(); animate(transform, buffer.asFloatBuffer(), ballSize, ballIndex, batchSize, delta); + long t1 = System.nanoTime(); + animateTime += t1 - t0; + animVBO.unmap(); } Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -89,6 +89,8 @@ private int texBigID; private int texSmallID; + long animateTime; + private SpriteShootoutMapped() { } @@ -312,6 +314,8 @@ long timeUsed = 5000 + (startTime - System.currentTimeMillis()); startTime = System.currentTimeMillis() + 5000; System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount); + System.out.println("Animation: " + animateTime / fps); + animateTime = 0; fps = 0; } } @@ -414,8 +418,8 @@ public static class Sprite extends MappedObject { - public float x, dx; - public float y, dy; + public float dx, x; + public float dy, y; } @@ -527,8 +531,8 @@ final Sprite[] sprites = sprite.asArray(); final SpriteRender[] spritesRender = spriteRender.asArray(); for ( int b = ballIndex, r = 0, len = (ballIndex + batchSize); b < len; b++, r++ ) { + float dx = sprites[b].dx; float x = sprites[b].x; - float dx = sprites[b].dx; x += dx * delta; if ( x < ballRadius ) { @@ -539,12 +543,12 @@ dx = -dx; } + sprites[b].dx = dx; sprites[b].x = x; - sprites[b].dx = dx; spritesRender[r].x = x; + float dy = sprites[b].dy; float y = sprites[b].y; - float dy = sprites[b].dy; y += dy * delta; if ( y < ballRadius ) { @@ -555,8 +559,8 @@ dy = -dy; } + sprites[b].dy = dy; sprites[b].y = y; - sprites[b].dy = dy; spritesRender[r].y = y; } } @@ -654,8 +658,12 @@ if ( animate ) { final ByteBuffer buffer = animVBO.map(batchSize * (2 * 4)); + long t0 = System.nanoTime(); animate(sprites, SpriteRender.<SpriteRender>map(buffer), ballSize, ballIndex, batchSize, delta); + long t1 = System.nanoTime(); + animateTime += t1 - t0; + animVBO.unmap(); } Added: trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheLinePad.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheLinePad.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheLinePad.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.mapped; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * When this annotation is used on a field, automatic cache-line-sized padding + * will be inserted around the field. This is useful in multi-threaded algorithms + * to avoid cache line false sharing. The annotation defaults to padding after + * the field, but can be changed to before or both before and after. It can be + * applied to both mapped object fields and POJO primitive fields. + * + * @author Spasi + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface CacheLinePad { + + /** + * When true, cache-line padding will be inserted before the field. + * + * @return + */ + boolean before() default false; + + /** + * When true, cache-line padding will be inserted after the field. + * + * @return + */ + boolean after() default true; + +} \ No newline at end of file Added: trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheLineSize.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheLineSize.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheLineSize.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -0,0 +1,141 @@ +package org.lwjgl.util.mapped; + +import org.lwjgl.LWJGLUtil; +import org.lwjgl.MemoryUtil; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorCompletionService; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import static org.lwjgl.util.mapped.MappedHelper.*; + +/** + * This micro-benchmark tries to detect the CPU's cache line size. This is + * done by exploiting cache line false sharing in multi-threaded code: + * When 2 threads simultaneously access the same cache line (and at least + * 1 access is a write), performance drops considerably. We detect this + * performance drop while decreasing the memory padding in every test step. + * + * @author Spasi + */ +final class CacheLineSize { + + private CacheLineSize() { + } + + static int getCacheLineSize() { + final int THREADS = 2; + final int REPEATS = 100000 * THREADS; + final int LOCAL_REPEATS = REPEATS / THREADS; + + // Detection will start from CacheLineMaxSize bytes. + final int MAX_SIZE = LWJGLUtil.getPrivilegedInteger("org.lwjgl.util.mapped.CacheLineMaxSize", 1024) / 4; // in # of integers + // Detection will stop when the execution time increases by more than CacheLineTimeThreshold %. + final double TIME_THRESHOLD = 1.0 + LWJGLUtil.getPrivilegedInteger("org.lwjgl.util.mapped.CacheLineTimeThreshold", 50) / 100.0; + + final ExecutorService executorService = Executors.newFixedThreadPool(THREADS); + final ExecutorCompletionService<Long> completionService = new ExecutorCompletionService<Long>(executorService); + + try { + // We need to use a NIO buffer in order to guarantee memory alignment. + final IntBuffer memory = getMemory(MAX_SIZE); + + // -- WARMUP -- + + final int WARMUP = 10; + for ( int i = 0; i < WARMUP; i++ ) + doTest(THREADS, LOCAL_REPEATS, 0, memory, completionService); + + // -- CACHE LINE SIZE DETECTION -- + + long totalTime = 0; + int count = 0; + int cacheLineSize = 64; // fallback to the most common size these days + boolean found = false; + for ( int i = MAX_SIZE; i >= 1; i >>= 1 ) { + final long time = doTest(THREADS, LOCAL_REPEATS, i, memory, completionService); + if ( totalTime > 0 ) { // Ignore first run + final long avgTime = totalTime / count; + if ( (double)time / (double)avgTime > TIME_THRESHOLD ) { // Try to detect a noticeable jump in execution time + cacheLineSize = (i << 1) * 4; + found = true; + break; + } + } + totalTime += time; + count++; + } + + if ( LWJGLUtil.DEBUG ) { + if ( found ) + LWJGLUtil.log("Cache line size detected: " + cacheLineSize + " bytes"); + else + LWJGLUtil.log("Failed to detect cache line size, assuming " + cacheLineSize + " bytes"); + } + + return cacheLineSize; + } finally { + executorService.shutdown(); + } + } + + public static void main(String[] args) { + CacheUtil.getCacheLineSize(); + } + + static long memoryLoop(final int index, final int repeats, final IntBuffer memory, final int padding) { + final long address = MemoryUtil.getAddress(memory) + (index * padding * 4); + + final long time = System.nanoTime(); + for ( int i = 0; i < repeats; i++ ) { + // Use volatile access to avoid server VM optimizations. + ivput(ivget(address) + 1, address); + } + + return System.nanoTime() - time; + } + + private static IntBuffer getMemory(final int START_SIZE) { + final int PAGE_SIZE = MappedObjectUnsafe.INSTANCE.pageSize(); + + final ByteBuffer buffer = ByteBuffer.allocateDirect((START_SIZE * 4) + PAGE_SIZE).order(ByteOrder.nativeOrder()); + + // Align to page and, consequently, to cache line. Otherwise results will be inconsistent. + if ( MemoryUtil.getAddress(buffer) % PAGE_SIZE != 0 ) { + // Round up to page boundary + buffer.position(PAGE_SIZE - (int)(MemoryUtil.getAddress(buffer) & (PAGE_SIZE - 1))); + } + + return buffer.asIntBuffer(); + } + + private static long doTest(final int threads, final int repeats, final int padding, final IntBuffer memory, final ExecutorCompletionService<Long> completionService) { + for ( int i = 0; i < threads; i++ ) + submitTest(completionService, i, repeats, memory, padding); + return waitForResults(threads, completionService); + } + + private static void submitTest(final ExecutorCompletionService<Long> completionService, final int index, final int repeats, final IntBuffer memory, final int padding) { + completionService.submit(new Callable<Long>() { + public Long call() throws Exception { + return memoryLoop(index, repeats, memory, padding); + } + }); + } + + private static long waitForResults(final int count, final ExecutorCompletionService<Long> completionService) { + try { + long totalTime = 0; + for ( int i = 0; i < count; i++ ) + totalTime += completionService.take().get(); + return totalTime; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} \ No newline at end of file Added: trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheUtil.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/CacheUtil.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.mapped; + +import org.lwjgl.LWJGLUtil; +import org.lwjgl.MemoryUtil; +import org.lwjgl.PointerBuffer; + +import java.nio.*; + +/** + * This class provides utility methods for allocating cache-line-aligned + * NIO buffers. The CPU cache line size is detected using a micro-benchmark + * that exploits the performation degredation that occurs when different + * threads write to different locations of the same cache line. The detection + * should be reasonably robust on both the server and client VM, but there + * are a few system properties that can be used to tune it. + * + * @author Spasi + */ +public final class CacheUtil { + + private static final int CACHE_LINE_SIZE; + + static { + final Integer size = LWJGLUtil.getPrivilegedInteger("org.lwjgl.util.mapped.CacheLineSize"); // forces a specific cache line size + + if ( size != null ) { + if ( size < 1 ) + throw new IllegalStateException("Invalid CacheLineSize specified: " + size); + CACHE_LINE_SIZE = size; + } else if ( Runtime.getRuntime().availableProcessors() == 1 ) { // We cannot use false sharing to detect it + /* + Spasi: + + I have implemented a single-threaded benchmark for this, but it requires + lots of memory allocations and could not tune it for both the client and + server VM. It's not a big deal anyway, 64 bytes should be ok for any + single-core CPU. + */ + if ( LWJGLUtil.DEBUG ) + LWJGLUtil.log("Cannot detect cache line size on single-core CPUs, assuming 64 bytes."); + CACHE_LINE_SIZE = 64; + } else + CACHE_LINE_SIZE = CacheLineSize.getCacheLineSize(); + } + + private CacheUtil() { + } + + /** + * Returns the CPU cache line size, in number of bytes. + * + * @return the cache line size + */ + public static int getCacheLineSize() { + return CACHE_LINE_SIZE; + } + + /** + * Construct a direct, native-ordered and cache-line-aligned bytebuffer with the specified size. + * + * @param size The size, in bytes + * + * @return a ByteBuffer + */ + public static ByteBuffer createByteBuffer(int size) { + ByteBuffer buffer = ByteBuffer.allocateDirect(size + CACHE_LINE_SIZE); + + // Align to cache line. + if ( MemoryUtil.getAddress(buffer) % CACHE_LINE_SIZE != 0 ) { + // Round up to cache line boundary + buffer.position(CACHE_LINE_SIZE - (int)(MemoryUtil.getAddress(buffer) & (CACHE_LINE_SIZE - 1))); + } + + buffer.limit(buffer.position() + size); + return buffer.slice().order(ByteOrder.nativeOrder()); + } + + /** + * Construct a direct, native-ordered and cache-line-aligned shortbuffer with the specified number + * of elements. + * + * @param size The size, in shorts + * + * @return a ShortBuffer + */ + public static ShortBuffer createShortBuffer(int size) { + return createByteBuffer(size << 1).asShortBuffer(); + } + + /** + * Construct a direct, native-ordered and cache-line-aligned charbuffer with the specified number + * of elements. + * + * @param size The size, in chars + * + * @return an CharBuffer + */ + public static CharBuffer createCharBuffer(int size) { + return createByteBuffer(size << 1).asCharBuffer(); + } + + /** + * Construct a direct, native-ordered and cache-line-aligned intbuffer with the specified number + * of elements. + * + * @param size The size, in ints + * + * @return an IntBuffer + */ + public static IntBuffer createIntBuffer(int size) { + return createByteBuffer(size << 2).asIntBuffer(); + } + + /** + * Construct a direct, native-ordered and cache-line-aligned longbuffer with the specified number + * of elements. + * + * @param size The size, in longs + * + * @return an LongBuffer + */ + public static LongBuffer createLongBuffer(int size) { + return createByteBuffer(size << 3).asLongBuffer(); + } + + /** + * Construct a direct, native-ordered and cache-line-aligned floatbuffer with the specified number + * of elements. + * + * @param size The size, in floats + * + * @return a FloatBuffer + */ + public static FloatBuffer createFloatBuffer(int size) { + return createByteBuffer(size << 2).asFloatBuffer(); + } + + /** + * Construct a direct, native-ordered and cache-line-aligned doublebuffer with the specified number + * of elements. + * + * @param size The size, in floats + * + * @return a FloatBuffer + */ + public static DoubleBuffer createDoubleBuffer(int size) { + return createByteBuffer(size << 3).asDoubleBuffer(); + } + + /** + * Construct a cache-line-aligned PointerBuffer with the specified number + * of elements. + * + * @param size The size, in memory addresses + * + * @return a PointerBuffer + */ + public static PointerBuffer createPointerBuffer(int size) { + return new PointerBuffer(createByteBuffer(size * PointerBuffer.getPointerSize())); + } + +} \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -53,7 +53,7 @@ * * @return the field byte offset */ - long byteOffset(); + long byteOffset() default -1; /** * Specifies the field byte length. Required for {@link java.nio.ByteBuffer} fields. Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -68,7 +68,7 @@ mo.baseAddress = mo.viewAddress = addr; } - public static void checkAddress(MappedObject mapped, long viewAddress) { + public static void checkAddress(long viewAddress, MappedObject mapped) { mapped.checkAddress(viewAddress); } @@ -317,7 +317,7 @@ return INSTANCE.getLong(addr); } - public static long lget(MappedObject mapped, int fieldOffset) { + public static long jget(MappedObject mapped, int fieldOffset) { return INSTANCE.getLong(mapped.viewAddress + fieldOffset); } @@ -333,7 +333,7 @@ return INSTANCE.getLongVolatile(null, addr); } - public static long lvget(MappedObject mapped, int fieldOffset) { + public static long jvget(MappedObject mapped, int fieldOffset) { return INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset); } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -48,12 +48,8 @@ */ public class MappedObjectClassLoader extends URLClassLoader { - static final String MAPPEDOBJECT_PACKAGE_PREFIX; + static final String MAPPEDOBJECT_PACKAGE_PREFIX = MappedObjectClassLoader.class.getPackage().getName() + "."; - static { - MAPPEDOBJECT_PACKAGE_PREFIX = MappedObjectClassLoader.class.getPackage().getName() + "."; - } - static boolean FORKED; /** @@ -115,28 +111,28 @@ @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { - if ( name.startsWith("java.") ) + if ( name.startsWith("java.") + || name.startsWith("javax.") + || name.startsWith("sun.") + || name.startsWith("sunw.") + || name.startsWith("org.objectweb.asm.") + ) return super.loadClass(name, resolve); - if ( name.startsWith("javax.") ) - return super.loadClass(name, resolve); - if ( name.startsWith("sun.") ) - return super.loadClass(name, resolve); - if ( name.startsWith("sunw.") ) - return super.loadClass(name, resolve); + final String className = name.replace('.', '/'); + final boolean inThisPackage = name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX); - if ( name.startsWith("org.objectweb.asm.") ) + if ( inThisPackage && ( + name.equals(MappedObjectClassLoader.class.getName()) + || name.equals((MappedObjectTransformer.class.getName())) + || name.equals((CacheUtil.class.getName())) + ) ) return super.loadClass(name, resolve); - if ( name.equals(MappedObjectClassLoader.class.getName()) || name.equals((MappedObjectTransformer.class.getName())) ) - return super.loadClass(name, resolve); - - String className = name.replace('.', '/'); - byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class"))); // Classes in this package do not get transformed, but need to go through here because we have transformed MappedObject. - if ( !(name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX) && name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1) ) { + if ( !(inThisPackage && name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1) ) { long t0 = System.nanoTime(); final byte[] newBytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode); long t1 = System.nanoTime(); Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -31,6 +31,7 @@ */ package org.lwjgl.util.mapped; +import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLUtil; import org.lwjgl.MemoryUtil; import org.objectweb.asm.*; @@ -79,6 +80,8 @@ static final String MAPPED_SET3_JVM = jvmClassName(MappedSet3.class); static final String MAPPED_SET4_JVM = jvmClassName(MappedSet4.class); + static final String CACHE_LINE_PAD_JVM = "L" + jvmClassName(CacheLinePad.class) + ";"; + // Public methods static final String VIEWADDRESS_METHOD_NAME = "getViewAddress"; static final String NEXT_METHOD_NAME = "next"; @@ -115,7 +118,7 @@ // => IADD // => PUTFIELD MyMappedType.view // - className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1, -1)); + className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1, -1, false)); } final String vmName = System.getProperty("java.vm.name"); @@ -145,30 +148,44 @@ final String className = jvmClassName(type); final Map<String, FieldInfo> fields = new HashMap<String, FieldInfo>(); - int advancingOffset = 0; long sizeof = 0; for ( Field field : type.getDeclaredFields() ) { - FieldInfo fieldInfo = registerField(mapped == null || mapped.autoGenerateOffsets(), className, advancingOffset, field); + FieldInfo fieldInfo = registerField(mapped == null || mapped.autoGenerateOffsets(), className, sizeof, field); if ( fieldInfo == null ) continue; fields.put(field.getName(), fieldInfo); - advancingOffset += fieldInfo.length; - sizeof = Math.max(sizeof, fieldInfo.offset + fieldInfo.length); + sizeof = Math.max(sizeof, fieldInfo.offset + fieldInfo.lengthPadded); } - final int align = mapped == null ? 4 : mapped.align(); - final int padding = mapped == null ? 0 : mapped.padding(); + int align = 4; + int padding = 0; + boolean cacheLinePadded = false; + if ( mapped != null ) { + align = mapped.align(); + if ( mapped.cacheLinePadding() ) { + if ( mapped.padding() != 0 ) + throw new ClassFormatError("Mapped type padding cannot be specified together with cacheLinePadding."); + + final int cacheLineMod = (int)(sizeof % CacheUtil.getCacheLineSize()); + if ( cacheLineMod != 0 ) + padding = CacheUtil.getCacheLineSize() - cacheLineMod; + + cacheLinePadded = true; + } else + padding = mapped.padding(); + } + sizeof += padding; - final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, align, padding); + final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, align, padding, cacheLinePadded); if ( className_to_subtype.put(className, mappedType) != null ) throw new InternalError("duplicate mapped type: " + mappedType.className); } - private static FieldInfo registerField(final boolean autoGenerateOffsets, final String className, int advancingOffset, final Field field) { + private static FieldInfo registerField(final boolean autoGenerateOffsets, final String className, long advancingOffset, final Field field) { if ( Modifier.isStatic(field.getModifiers()) ) // static fields are never mapped return null; @@ -188,7 +205,6 @@ throw new ClassFormatError("The volatile keyword is not supported for @Pointer or ByteBuffer fields. Volatile field found: " + className + "." + field.getName() + ": " + field.getType()); // quick hack - long byteOffset = meta == null ? advancingOffset : meta.byteOffset(); long byteLength; if ( field.getType() == long.class || field.getType() == double.class ) { if ( pointer == null ) @@ -213,10 +229,36 @@ if ( field.getType() != ByteBuffer.class && (advancingOffset % byteLength) != 0 ) throw new IllegalStateException("misaligned mapped type: " + className + "." + field.getName()); + CacheLinePad pad = field.getAnnotation(CacheLinePad.class); + + long byteOffset = advancingOffset; + if ( meta != null && meta.byteOffset() != -1 ) { + if ( meta.byteOffset() < 0 ) + throw new ClassFormatError("Invalid field byte offset: " + className + "." + field.getName() + " [byteOffset=" + meta.byteOffset() + "]"); + if ( pad != null ) + throw new ClassFormatError("A field byte offset cannot be specified together with cache-line padding: " + className + "." + field.getName()); + + byteOffset = meta.byteOffset(); + } + + long byteLengthPadded = byteLength; + if ( pad != null ) { + // Pad before + if ( pad.before() && byteOffset % CacheUtil.getCacheLineSize() != 0 ) + byteOffset += CacheUtil.getCacheLineSize() - (byteOffset & (CacheUtil.getCacheLineSize() - 1)); + + // Pad after + if ( pad.after() && (byteOffset + byteLength) % CacheUtil.getCacheLineSize() != 0 ) + byteLengthPadded += CacheUtil.getCacheLineSize() - (byteOffset + byteLength) % CacheUtil.getCacheLineSize(); + + assert !pad.before() || (byteOffset % CacheUtil.getCacheLineSize() == 0); + assert !pad.after() || ((byteOffset + byteLengthPadded) % CacheUtil.getCacheLineSize() == 0); + } + if ( PRINT_ACTIVITY ) LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]"); - return new FieldInfo(byteOffset, byteLength, Type.getType(field.getType()), Modifier.isVolatile(field.getModifiers()), pointer != null); + return new FieldInfo(byteOffset, byteLength, byteLengthPadded, Type.getType(field.getType()), Modifier.isVolatile(field.getModifiers()), pointer != null); } /** Removes final from methods that will be overriden by subclasses. */ @@ -318,17 +360,12 @@ mv.visitInsn(I2L); mv.visitInsn(LADD); if ( MappedObject.CHECKS ) { - mv.visitVarInsn(LSTORE, 2); + mv.visitInsn(DUP2); mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(LLOAD, 2); - mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "checkAddress", "(L" + MAPPED_OBJECT_JVM + ";J)V"); - mv.visitVarInsn(LLOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "checkAddress", "(JL" + MAPPED_OBJECT_JVM + ";)V"); } mv.visitInsn(LRETURN); - if ( MappedObject.CHECKS ) - mv.visitMaxs(3, 4); - else - mv.visitMaxs(3, 2); + mv.visitMaxs(3, 2); mv.visitEnd(); } @@ -477,7 +514,71 @@ return null; } - return super.visitField(access, name, desc, signature, value); + if ( (access & ACC_STATIC) == 0 ) { + return new FieldNode(access, name, desc, signature, value) { + public void visitEnd() { + if ( visibleAnnotations == null ) { // early-out + accept(cv); + return; + } + + boolean before = false; + boolean after = false; + int byteLength = 0; + for ( AnnotationNode pad : visibleAnnotations ) { + if ( CACHE_LINE_PAD_JVM.equals(pad.desc) ) { + if ( "J".equals(desc) || "D".equals(desc) ) + byteLength = 8; + else if ( "I".equals(desc) || "F".equals(desc) ) + byteLength = 4; + else if ( "S".equals(desc) || "C".equals(desc) ) + byteLength = 2; + else if ( "B".equals(desc) || "Z".equals(desc) ) + byteLength = 1; + else + throw new ClassFormatError("The @CacheLinePad annotation cannot be used on non-primitive fields: " + className + "." + name); + + transformed = true; + + after = true; + if ( pad.values != null ) { + for ( int i = 0; i < pad.values.size(); i += 2 ) { + final boolean value = pad.values.get(i + 1).equals(Boolean.TRUE); + if ( "before".equals(pad.values.get(i)) ) + before = value; + else + after = value; + } + } + break; + } + } + + /* + We make the fields public to force the JVM to keep the fields in the object. + Instead of using only longs or integers, we use the same type as the original + field. That's because modern JVMs usually reorder fields by type: + longs, then doubles, then integers, then booleans, etc. This way it's more + likely that the padding will work as expected. + */ + + if ( before ) { + final int count = CacheUtil.getCacheLineSize() / byteLength - 1; + for ( int i = count; i >= 1; i-- ) + cv.visitField(access | ACC_PUBLIC | ACC_SYNTHETIC, name + "$PAD_" + i, desc, signature, null); + } + + accept(cv); + + if ( after ) { + final int count = CacheUtil.getCacheLineSize() / byteLength - 1; + for ( int i = 1; i <= count; i++ ) + cv.visitField(access | ACC_PUBLIC | ACC_SYNTHETIC, name + "$PAD" + i, desc, signature, null); + } + } + }; + } else + return super.visitField(access, name, desc, signature, value); } @Override @@ -762,7 +863,7 @@ // stack: sizeof, count trg.add(new InsnNode(IMUL)); // stack: bytes - trg.add(new MethodInsnNode(INVOKESTATIC, jvmClassName(ByteBuffer.class), "allocateDirect", "(I)L" + jvmClassName(ByteBuffer.class) + ";")); + trg.add(new MethodInsnNode(INVOKESTATIC, mappedType.cacheLinePadded ? jvmClassName(CacheUtil.class) : jvmClassName(BufferUtils.class), "createByteBuffer", "(I)L" + jvmClassName(ByteBuffer.class) + ";")); // stack: buffer } else if ( mapDirectMethod ) { // stack: capacity, address @@ -1061,13 +1162,15 @@ final long offset; final long length; + final long lengthPadded; final Type type; final boolean isVolatile; final boolean isPointer; - FieldInfo(final long offset, final long length, final Type type, final boolean isVolatile, final boolean isPointer) { + FieldInfo(final long offset, final long length, final long lengthPadded, final Type type, final boolean isVolatile, final boolean isPointer) { this.offset = offset; this.length = length; + this.lengthPadded = lengthPadded; this.type = type; this.isVolatile = isVolatile; this.isPointer = isPointer; @@ -1083,14 +1186,15 @@ final String className; - final int sizeof; - final int sizeof_shift; - final int align; - final int padding; + final int sizeof; + final int sizeof_shift; + final int align; + final int padding; + final boolean cacheLinePadded; final Map<String, FieldInfo> fields; - MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align, int padding) { + MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align, int padding, final boolean cacheLinePadded) { this.className = className; this.sizeof = sizeof; @@ -1100,6 +1204,7 @@ this.sizeof_shift = 0; this.align = align; this.padding = padding; + this.cacheLinePadded = cacheLinePadded; this.fields = fields; } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -34,6 +34,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import sun.misc.Unsafe; @@ -55,7 +56,7 @@ if ( address <= 0L || capacity < 0 ) throw new IllegalStateException("you almost crashed the jvm"); - ByteBuffer buffer = global.duplicate(); + ByteBuffer buffer = global.duplicate().order(ByteOrder.nativeOrder()); INSTANCE.putLong(buffer, BUFFER_ADDRESS_OFFSET, address); INSTANCE.putInt(buffer, BUFFER_CAPACITY_OFFSET, capacity); buffer.position(0); Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java 2011-08-08 17:02:20 UTC (rev 3607) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java 2011-08-10 16:05:46 UTC (rev 3608) @@ -61,13 +61,28 @@ /** * The number of bytes to add to the total byte size. - * SIZEOF will be calculated as <code>SIZEOF = max(field_offset + field_length) + padding</code> + * SIZEOF will be calculated as <code>SIZEOF = max(field_offset + field_length) + padding</code>. + * <p/> + * Cannot be used with {@link #cacheLinePadding()}. * * @return the padding amount */ int padding() default 0; /** + * When true, SIZEOF will be increased (if necessary) so that it's a multiple of the CPU cache line size. + * Additionally, {@link MappedObject#malloc(int)} on the mapped object type will automatically use + * {@link CacheUtil#createByteBuffer(int)} instead of the unaligned {@link org.lwjgl.BufferUtils#createByteBuffer(int)}. + * <p/> + * Cannot be used with {@link #padding()}. + * + * @return if cache-line padding should be applied + * + * @see CacheUtil + */ + boolean cacheLinePadding() default false; + + /** * The mapped data memory alignment, in bytes. * * @return the memory alignment This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-08 17:02:26
|
Revision: 3607 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3607&view=rev Author: spasi Date: 2011-08-08 17:02:20 +0000 (Mon, 08 Aug 2011) Log Message: ----------- Added missing annotation and import. Modified Paths: -------------- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java 2011-08-08 16:42:37 UTC (rev 3606) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java 2011-08-08 17:02:20 UTC (rev 3607) @@ -35,7 +35,9 @@ import org.lwjgl.util.generator.Reuse; import org.lwjgl.util.generator.opengl.GLenum; import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; +@Dependent public interface ARB_texture_storage { /** Accepted by the <value> parameter of GetTexParameter{if}v: */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-08 16:42:43
|
Revision: 3606 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3606&view=rev Author: spasi Date: 2011-08-08 16:42:37 +0000 (Mon, 08 Aug 2011) Log Message: ----------- Added DSA functions. Modified Paths: -------------- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java 2011-08-08 10:48:14 UTC (rev 3605) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java 2011-08-08 16:42:37 UTC (rev 3606) @@ -31,6 +31,7 @@ */ package org.lwjgl.opengl; +import org.lwjgl.util.generator.Dependent; import org.lwjgl.util.generator.Reuse; import org.lwjgl.util.generator.opengl.GLenum; import org.lwjgl.util.generator.opengl.GLsizei; @@ -55,4 +56,19 @@ @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth); -} + @Dependent("EXT_direct_state_access") + void glTextureStorage1DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width); + + @Dependent("EXT_direct_state_access") + void glTextureStorage2DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height); + + @Dependent("EXT_direct_state_access") + void glTextureStorage3DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height, @GLsizei int depth); + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-08 10:48:23
|
Revision: 3605 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3605&view=rev Author: spasi Date: 2011-08-08 10:48:14 +0000 (Mon, 08 Aug 2011) Log Message: ----------- Added support for OpenGL 4.2 Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/ContextAttribs.java trunk/LWJGL/src/native/common/common_tools.c trunk/LWJGL/src/templates/org/lwjgl/opencl/KHR_icd.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL40.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL41.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_half_float.java Added Paths: ----------- trunk/LWJGL/src/templates/org/lwjgl/opencl/AMD_vec3.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_base_instance.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_compressed_texture_pixel_storage.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_conservative_depth.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_internalformat_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_map_buffer_alignment.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_atomic_counters.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_image_load_store.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_420pack.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_packing.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback_instanced.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL42.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ContextAttribs.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/ContextAttribs.java 2011-08-06 13:18:49 UTC (rev 3604) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/ContextAttribs.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -87,7 +87,7 @@ public ContextAttribs(final int majorVersion, final int minorVersion) { if ( majorVersion < 0 || 4 < majorVersion || minorVersion < 0 || - (majorVersion == 4 && 1 < minorVersion) || + (majorVersion == 4 && 2 < minorVersion) || (majorVersion == 3 && 3 < minorVersion) || (majorVersion == 2 && 1 < minorVersion) || (majorVersion == 1 && 5 < minorVersion) ) Modified: trunk/LWJGL/src/native/common/common_tools.c =================================================================== --- trunk/LWJGL/src/native/common/common_tools.c 2011-08-06 13:18:49 UTC (rev 3604) +++ trunk/LWJGL/src/native/common/common_tools.c 2011-08-08 10:48:14 UTC (rev 3605) @@ -120,7 +120,7 @@ org_lwjgl_LWJGLUtil_class = (*env)->FindClass(env, "org/lwjgl/LWJGLUtil"); if (org_lwjgl_LWJGLUtil_class == NULL) return; - log_method = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "log", "(Ljava/lang/String;)V"); + log_method = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "log", "(Ljava/lang/CharSequence;)V"); if (log_method == NULL) return; (*env)->CallStaticVoidMethod(env, org_lwjgl_LWJGLUtil_class, log_method, str); Added: trunk/LWJGL/src/templates/org/lwjgl/opencl/AMD_vec3.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opencl/AMD_vec3.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opencl/AMD_vec3.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opencl; + +import org.lwjgl.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface AMD_vec3 { + +} \ No newline at end of file Modified: trunk/LWJGL/src/templates/org/lwjgl/opencl/KHR_icd.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opencl/KHR_icd.java 2011-08-06 13:18:49 UTC (rev 3604) +++ trunk/LWJGL/src/templates/org/lwjgl/opencl/KHR_icd.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -49,7 +49,7 @@ /** Returned by clGetPlatformIDs when no platforms are found */ int CL_PLATFORM_NOT_FOUND_KHR = -1001; - @Optional(reason = "AMD Stream does not expose this (version tested: 2.2)") + @Optional(reason = "AMD Stream does not expose this (version tested: 2.5)") @cl_int int clIcdGetPlatformIDsKHR(@AutoSize(value = "platforms", canBeNull = true) @cl_uint int num_entries, @OutParameter @Check(canBeNull = true) @NativeType("cl_platform_id") PointerBuffer platforms, Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_base_instance.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_base_instance.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_base_instance.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; + +import java.nio.Buffer; + +public interface ARB_base_instance { + + @Reuse("GL42") + void glDrawArraysInstancedBaseInstance(@GLenum int mode, + int first, + @GLsizei int count, + @GLsizei int primcount, + @GLuint int baseinstance); + + @Reuse("GL42") + void glDrawElementsInstancedBaseInstance(@GLenum int mode, + @AutoSize("indices") @GLsizei int count, + @AutoType("indices") @GLenum int type, + @Const + @BufferObject(BufferKind.ElementVBO) + @GLubyte + @GLushort + @GLuint Buffer indices, + @GLsizei int primcount, + @GLuint int baseinstance); + + @Reuse("GL42") + void glDrawElementsInstancedBaseVertexBaseInstance(@GLenum int mode, + @AutoSize("indices") @GLsizei int count, + @AutoType("indices") @GLenum int type, + @Const + @BufferObject(BufferKind.ElementVBO) + @GLubyte + @GLushort + @GLuint Buffer indices, + @GLsizei int primcount, + int basevertex, + @GLuint int baseinstance); + +} \ No newline at end of file Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_compressed_texture_pixel_storage.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_compressed_texture_pixel_storage.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_compressed_texture_pixel_storage.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface ARB_compressed_texture_pixel_storage { + + /** + * Accepted by the <pname> parameter of PixelStore[fi], GetBooleanv, + * GetIntegerv, GetInteger64v, GetFloatv, and GetDoublev: + */ + int GL_UNPACK_COMPRESSED_BLOCK_WIDTH = 0x9127, + GL_UNPACK_COMPRESSED_BLOCK_HEIGHT = 0x9128, + GL_UNPACK_COMPRESSED_BLOCK_DEPTH = 0x9129, + GL_UNPACK_COMPRESSED_BLOCK_SIZE = 0x912A, + GL_PACK_COMPRESSED_BLOCK_WIDTH = 0x912B, + GL_PACK_COMPRESSED_BLOCK_HEIGHT = 0x912C, + GL_PACK_COMPRESSED_BLOCK_DEPTH = 0x912D, + GL_PACK_COMPRESSED_BLOCK_SIZE = 0x912E; + +} \ No newline at end of file Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_conservative_depth.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_conservative_depth.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_conservative_depth.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface ARB_conservative_depth { +} \ No newline at end of file Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_internalformat_query.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_internalformat_query.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_internalformat_query.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; + +import java.nio.IntBuffer; + +@Extension(postfix = "") +public interface ARB_internalformat_query { + + /** Accepted by the <pname> parameter of GetInternalformativ: */ + int GL_NUM_SAMPLE_COUNTS = 0x9380; + + @StripPostfix("params") + @Reuse("GL42") + void glGetInternalformativ(@GLenum int target, @GLenum int internalformat, + @GLenum int pname, @AutoSize("params") @GLsizei int bufSize, @OutParameter IntBuffer params); + + @Alternate("glGetInternalformativ") + @StripPostfix("params") + @GLreturn("params") + @Reuse("GL42") + void glGetInternalformativ2(@GLenum int target, @GLenum int internalformat, + @GLenum int pname, @Constant("1") @GLsizei int bufSize, @OutParameter IntBuffer params); + +} \ No newline at end of file Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_map_buffer_alignment.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_map_buffer_alignment.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_map_buffer_alignment.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface ARB_map_buffer_alignment { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv, and GetDoublev: + */ + int GL_MIN_MAP_BUFFER_ALIGNMENT = 0x90BC; + +} \ No newline at end of file Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_atomic_counters.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_atomic_counters.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_atomic_counters.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLuint; + +import java.nio.IntBuffer; + +@Extension(postfix = "") +public interface ARB_shader_atomic_counters { + + /** Accepted by the <target> parameter of BindBufferBase and BindBufferRange: */ + int GL_ATOMIC_COUNTER_BUFFER = 0x92C0; + + /** + * Accepted by the <pname> parameter of GetBooleani_v, GetIntegeri_v, + * GetFloati_v, GetDoublei_v, GetInteger64i_v, GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv, GetDoublev, and GetActiveAtomicCounterBufferiv: + */ + int GL_ATOMIC_COUNTER_BUFFER_BINDING = 0x92C1; + + /** Accepted by the <pname> parameter of GetIntegeri_64v: */ + int GL_ATOMIC_COUNTER_BUFFER_START = 0x92C2, + GL_ATOMIC_COUNTER_BUFFER_SIZE = 0x92C3; + + /** Accepted by the <pname> parameter of GetActiveAtomicCounterBufferiv: */ + int GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE = 0x92C4, + GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS = 0x92C5, + GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES = 0x92C6, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER = 0x92C7, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER = 0x92C8, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x92C9, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER = 0x92CA, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER = 0x92CB; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv, and GetDoublev: + */ + int GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS = 0x92CC, + GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS = 0x92CD, + GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS = 0x92CE, + GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS = 0x92CF, + GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS = 0x92D0, + GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS = 0x92D1, + GL_MAX_VERTEX_ATOMIC_COUNTERS = 0x92D2, + GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS = 0x92D3, + GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS = 0x92D4, + GL_MAX_GEOMETRY_ATOMIC_COUNTERS = 0x92D5, + GL_MAX_FRAGMENT_ATOMIC_COUNTERS = 0x92D6, + GL_MAX_COMBINED_ATOMIC_COUNTERS = 0x92D7, + GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE = 0x92D8, + GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS = 0x92DC; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_ACTIVE_ATOMIC_COUNTER_BUFFERS = 0x92D9; + + /** Accepted by the <pname> parameter of GetActiveUniformsiv: */ + int GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX = 0x92DA; + + /** Returned in <params> by GetActiveUniform and GetActiveUniformsiv: */ + int GL_UNSIGNED_INT_ATOMIC_COUNTER = 0x92DB; + + @StripPostfix("params") + @Reuse("GL42") + void glGetActiveAtomicCounterBufferiv(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); + + @Alternate("glGetActiveAtomicCounterBufferiv") + @StripPostfix("params") + @GLreturn("params") + @Reuse("GL42") + void glGetActiveAtomicCounterBufferiv2(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @OutParameter IntBuffer params); + +} \ No newline at end of file Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_image_load_store.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_image_load_store.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_image_load_store.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.Reuse; +import org.lwjgl.util.generator.opengl.GLbitfield; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; + +public interface ARB_shader_image_load_store { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, GetDoublev, and GetInteger64v: + */ + int GL_MAX_IMAGE_UNITS = 0x8F38, + GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS = 0x8F39, + GL_MAX_IMAGE_SAMPLES = 0x906D, + GL_MAX_VERTEX_IMAGE_UNIFORMS = 0x90CA, + GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS = 0x90CB, + GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS = 0x90CC, + GL_MAX_GEOMETRY_IMAGE_UNIFORMS = 0x90CD, + GL_MAX_FRAGMENT_IMAGE_UNIFORMS = 0x90CE, + GL_MAX_COMBINED_IMAGE_UNIFORMS = 0x90CF; + + /** Accepted by the <target> parameter of GetIntegeri_v and GetBooleani_v: */ + int GL_IMAGE_BINDING_NAME = 0x8F3A, + GL_IMAGE_BINDING_LEVEL = 0x8F3B, + GL_IMAGE_BINDING_LAYERED = 0x8F3C, + GL_IMAGE_BINDING_LAYER = 0x8F3D, + GL_IMAGE_BINDING_ACCESS = 0x8F3E, + GL_IMAGE_BINDING_FORMAT = 0x906E; + + /** Accepted by the <barriers> parameter of MemoryBarrier: */ + int GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT = 0x00000001, + GL_ELEMENT_ARRAY_BARRIER_BIT = 0x00000002, + GL_UNIFORM_BARRIER_BIT = 0x00000004, + GL_TEXTURE_FETCH_BARRIER_BIT = 0x00000008, + GL_SHADER_IMAGE_ACCESS_BARRIER_BIT = 0x00000020, + GL_COMMAND_BARRIER_BIT = 0x00000040, + GL_PIXEL_BUFFER_BARRIER_BIT = 0x00000080, + GL_TEXTURE_UPDATE_BARRIER_BIT = 0x00000100, + GL_BUFFER_UPDATE_BARRIER_BIT = 0x00000200, + GL_FRAMEBUFFER_BARRIER_BIT = 0x00000400, + GL_TRANSFORM_FEEDBACK_BARRIER_BIT = 0x00000800, + GL_ATOMIC_COUNTER_BARRIER_BIT = 0x00001000, + GL_ALL_BARRIER_BITS = 0xFFFFFFFF; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_IMAGE_1D = 0x904C, + GL_IMAGE_2D = 0x904D, + GL_IMAGE_3D = 0x904E, + GL_IMAGE_2D_RECT = 0x904F, + GL_IMAGE_CUBE = 0x9050, + GL_IMAGE_BUFFER = 0x9051, + GL_IMAGE_1D_ARRAY = 0x9052, + GL_IMAGE_2D_ARRAY = 0x9053, + GL_IMAGE_CUBE_MAP_ARRAY = 0x9054, + GL_IMAGE_2D_MULTISAMPLE = 0x9055, + GL_IMAGE_2D_MULTISAMPLE_ARRAY = 0x9056, + GL_INT_IMAGE_1D = 0x9057, + GL_INT_IMAGE_2D = 0x9058, + GL_INT_IMAGE_3D = 0x9059, + GL_INT_IMAGE_2D_RECT = 0x905A, + GL_INT_IMAGE_CUBE = 0x905B, + GL_INT_IMAGE_BUFFER = 0x905C, + GL_INT_IMAGE_1D_ARRAY = 0x905D, + GL_INT_IMAGE_2D_ARRAY = 0x905E, + GL_INT_IMAGE_CUBE_MAP_ARRAY = 0x905F, + GL_INT_IMAGE_2D_MULTISAMPLE = 0x9060, + GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY = 0x9061, + GL_UNSIGNED_INT_IMAGE_1D = 0x9062, + GL_UNSIGNED_INT_IMAGE_2D = 0x9063, + GL_UNSIGNED_INT_IMAGE_3D = 0x9064, + GL_UNSIGNED_INT_IMAGE_2D_RECT = 0x9065, + GL_UNSIGNED_INT_IMAGE_CUBE = 0x9066, + GL_UNSIGNED_INT_IMAGE_BUFFER = 0x9067, + GL_UNSIGNED_INT_IMAGE_1D_ARRAY = 0x9068, + GL_UNSIGNED_INT_IMAGE_2D_ARRAY = 0x9069, + GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY = 0x906A, + GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE = 0x906B, + GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY = 0x906C; + + /** + * Accepted by the <value> parameter of GetTexParameteriv, GetTexParameterfv, + * GetTexParameterIiv, and GetTexParameterIuiv: + */ + int GL_IMAGE_FORMAT_COMPATIBILITY_TYPE = 0x90C7; + + /** + * Returned in the <data> parameter of GetTexParameteriv, GetTexParameterfv, + * GetTexParameterIiv, and GetTexParameterIuiv when <value> is + * IMAGE_FORMAT_COMPATIBILITY_TYPE: + */ + int GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE = 0x90C8, + IMAGE_FORMAT_COMPATIBILITY_BY_CLASS = 0x90C9; + + @Reuse("GL42") + void glBindImageTexture(@GLuint int unit, @GLuint int texture, int level, + boolean layered, int layer, @GLenum int access, + @GLenum int format); + + @Reuse("GL42") + void glMemoryBarrier(@GLbitfield int barriers); + +} \ No newline at end of file Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_420pack.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_420pack.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_420pack.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface ARB_shading_language_420pack { + +} Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_packing.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_packing.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_packing.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface ARB_shading_language_packing { + +} Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_storage.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.Reuse; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; + +public interface ARB_texture_storage { + + /** Accepted by the <value> parameter of GetTexParameter{if}v: */ + int GL_TEXTURE_IMMUTABLE_FORMAT = 0x912F; + + @Reuse("GL42") + void glTexStorage1D(@GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width); + + @Reuse("GL42") + void glTexStorage2D(@GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height); + + @Reuse("GL42") + void glTexStorage3D(@GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height, @GLsizei int depth); + +} Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback_instanced.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback_instanced.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback_instanced.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.Reuse; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; + +public interface ARB_transform_feedback_instanced { + + @Reuse("GL42") + void glDrawTransformFeedbackInstanced(@GLenum int mode, @GLuint int id, @GLsizei int primcount); + + @Reuse("GL42") + void glDrawTransformFeedbackStreamInstanced(@GLenum int mode, @GLuint int id, @GLuint int stream, @GLsizei int primcount); + +} \ No newline at end of file Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java 2011-08-06 13:18:49 UTC (rev 3604) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -520,11 +520,11 @@ value parameters */ - @Optional(reason = "AMD does not expose this (last driver checked: 10.9)") + @Optional(reason = "AMD does not expose this (last driver checked: 11.7)") @Dependent("OpenGL30") void glEnableClientStateiEXT(@GLenum int array, @GLuint int index); - @Optional(reason = "AMD does not expose this (last driver checked: 10.9)") + @Optional(reason = "AMD does not expose this (last driver checked: 11.7)") @Dependent("OpenGL30") void glDisableClientStateiEXT(@GLenum int array, @GLuint int index); @@ -566,7 +566,7 @@ and before state value parameters */ - @Optional(reason = "AMD does not expose this (last driver checked: 10.9)") + @Optional(reason = "AMD does not expose this (last driver checked: 11.7)") @Dependent("OpenGL30") @StripPostfix("params") void glGetFloati_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params); @@ -577,7 +577,7 @@ @StripPostfix("params") void glGetFloati_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params); - @Optional(reason = "AMD does not expose this (last driver checked: 10.9)") + @Optional(reason = "AMD does not expose this (last driver checked: 11.7)") @Dependent("OpenGL30") @StripPostfix("params") void glGetDoublei_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params); @@ -588,7 +588,7 @@ @StripPostfix("params") void glGetDoublei_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params); - @Optional(reason = "AMD does not expose this (last driver checked: 10.9)") + @Optional(reason = "AMD does not expose this (last driver checked: 11.7)") @Dependent("OpenGL30") @StripPostfix(value = "params", hasPostfix = false) void glGetPointeri_vEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL40.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL40.java 2011-08-06 13:18:49 UTC (rev 3604) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL40.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -184,7 +184,6 @@ */ int GL_MIN_SAMPLE_SHADING_VALUE = 0x8C37; - @Optional(reason = "AMD does not expose this (last driver checked: 10.9)") void glMinSampleShading(@GLclampf float value); // --------------------------------------------------------------------- Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL41.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL41.java 2011-08-06 13:18:49 UTC (rev 3604) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL41.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -68,22 +68,17 @@ GL_MEDIUM_INT = 0x8DF4, GL_HIGH_INT = 0x8DF5; - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glReleaseShaderCompiler(); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glShaderBinary(@AutoSize("shaders") @GLsizei int count, @Const @GLuint IntBuffer shaders, @GLenum int binaryformat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glGetShaderPrecisionFormat(@GLenum int shadertype, @GLenum int precisiontype, @OutParameter @Check("2") IntBuffer range, @OutParameter @Check("1") IntBuffer precision); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glDepthRangef(@GLclampf float n, @GLclampf float f); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glClearDepthf(@GLclampf float d); // ---------------------------------------------------------------------- @@ -360,41 +355,31 @@ int GL_DOUBLE_MAT4x2 = 0x8F4D; int GL_DOUBLE_MAT4x3 = 0x8F4E; - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glVertexAttribL1d(@GLuint int index, double x); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glVertexAttribL2d(@GLuint int index, double x, double y); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glVertexAttribL3d(@GLuint int index, double x, double y, double z); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glVertexAttribL4d(@GLuint int index, double x, double y, double z, double w); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") @StripPostfix("v") void glVertexAttribL1dv(@GLuint int index, @Const @Check("1") DoubleBuffer v); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") @StripPostfix("v") void glVertexAttribL2dv(@GLuint int index, @Const @Check("2") DoubleBuffer v); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") @StripPostfix("v") void glVertexAttribL3dv(@GLuint int index, @Const @Check("3") DoubleBuffer v); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") @StripPostfix("v") void glVertexAttribL4dv(@GLuint int index, @Const @Check("4") DoubleBuffer v); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") void glVertexAttribLPointer(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride, @CachedReference(index = "index", name = "glVertexAttribPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @Check @Const @GLdouble Buffer pointer); - @Optional(reason = "Not exposed in ATI Catalyst 10.10c") @StripPostfix("params") void glGetVertexAttribLdv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL42.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL42.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL42.java 2011-08-08 10:48:14 UTC (rev 3605) @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; + +import java.nio.Buffer; +import java.nio.IntBuffer; + +public interface GL42 { + + // ---------------------------------------------------------------------------- + // ----------------------[ ARB_texture_compression_bptc ]---------------------- + // ---------------------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage2D, TexImage3D, + * CopyTexImage2D, CopyTexImage3D, CompressedTexImage2DARB, and + * CompressedTexImage3DARB and the <format> parameter of + * CompressedTexSubImage2DARB and CompressedTexSubImage3DARB: + */ + int GL_COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C; + int GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM = 0x8E8D; + int GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 0x8E8E; + int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F; + + // ------------------------------------------------------------------------------------ + // ----------------------[ ARB_compressed_texture_pixel_storage ]---------------------- + // ------------------------------------------------------------------------------------ + + /** + * Accepted by the <pname> parameter of PixelStore[fi], GetBooleanv, + * GetIntegerv, GetInteger64v, GetFloatv, and GetDoublev: + */ + int GL_UNPACK_COMPRESSED_BLOCK_WIDTH = 0x9127, + GL_UNPACK_COMPRESSED_BLOCK_HEIGHT = 0x9128, + GL_UNPACK_COMPRESSED_BLOCK_DEPTH = 0x9129, + GL_UNPACK_COMPRESSED_BLOCK_SIZE = 0x912A, + GL_PACK_COMPRESSED_BLOCK_WIDTH = 0x912B, + GL_PACK_COMPRESSED_BLOCK_HEIGHT = 0x912C, + GL_PACK_COMPRESSED_BLOCK_DEPTH = 0x912D, + GL_PACK_COMPRESSED_BLOCK_SIZE = 0x912E; + + // -------------------------------------------------------------------------- + // ----------------------[ ARB_shader_atomic_counters ]---------------------- + // -------------------------------------------------------------------------- + + /** Accepted by the <target> parameter of BindBufferBase and BindBufferRange: */ + int GL_ATOMIC_COUNTER_BUFFER = 0x92C0; + + /** + * Accepted by the <pname> parameter of GetBooleani_v, GetIntegeri_v, + * GetFloati_v, GetDoublei_v, GetInteger64i_v, GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv, GetDoublev, and GetActiveAtomicCounterBufferiv: + */ + int GL_ATOMIC_COUNTER_BUFFER_BINDING = 0x92C1; + + /** Accepted by the <pname> parameter of GetIntegeri_64v: */ + int GL_ATOMIC_COUNTER_BUFFER_START = 0x92C2, + GL_ATOMIC_COUNTER_BUFFER_SIZE = 0x92C3; + + /** Accepted by the <pname> parameter of GetActiveAtomicCounterBufferiv: */ + int GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE = 0x92C4, + GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS = 0x92C5, + GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES = 0x92C6, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER = 0x92C7, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER = 0x92C8, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x92C9, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER = 0x92CA, + GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER = 0x92CB; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv, and GetDoublev: + */ + int GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS = 0x92CC, + GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS = 0x92CD, + GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS = 0x92CE, + GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS = 0x92CF, + GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS = 0x92D0, + GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS = 0x92D1, + GL_MAX_VERTEX_ATOMIC_COUNTERS = 0x92D2, + GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS = 0x92D3, + GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS = 0x92D4, + GL_MAX_GEOMETRY_ATOMIC_COUNTERS = 0x92D5, + GL_MAX_FRAGMENT_ATOMIC_COUNTERS = 0x92D6, + GL_MAX_COMBINED_ATOMIC_COUNTERS = 0x92D7, + GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE = 0x92D8, + GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS = 0x92DC; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_ACTIVE_ATOMIC_COUNTER_BUFFERS = 0x92D9; + + /** Accepted by the <pname> parameter of GetActiveUniformsiv: */ + int GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX = 0x92DA; + + /** Returned in <params> by GetActiveUniform and GetActiveUniformsiv: */ + int GL_UNSIGNED_INT_ATOMIC_COUNTER = 0x92DB; + + @StripPostfix("params") + void glGetActiveAtomicCounterBufferiv(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); + + @Alternate("glGetActiveAtomicCounterBufferiv") + @StripPostfix("params") + @GLreturn("params") + void glGetActiveAtomicCounterBufferiv2(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @OutParameter IntBuffer params); + + // ------------------------------------------------------------------- + // ----------------------[ ARB_texture_storage ]---------------------- + // ------------------------------------------------------------------- + + /** Accepted by the <value> parameter of GetTexParameter{if}v: */ + int GL_TEXTURE_IMMUTABLE_FORMAT = 0x912F; + + void glTexStorage1D(@GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width); + + void glTexStorage2D(@GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height); + + void glTexStorage3D(@GLenum int target, @GLsizei int levels, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height, @GLsizei int depth); + + // -------------------------------------------------------------------------------- + // ----------------------[ ARB_transform_feedback_instanced ]---------------------- + // -------------------------------------------------------------------------------- + + void glDrawTransformFeedbackInstanced(@GLenum int mode, @GLuint int id, @GLsizei int primcount); + + void glDrawTransformFeedbackStreamInstanced(@GLenum int mode, @GLuint int id, @GLuint int stream, @GLsizei int primcount); + + // ----------------------------------------------------------------- + // ----------------------[ ARB_base_instance ]---------------------- + // ----------------------------------------------------------------- + + void glDrawArraysInstancedBaseInstance(@GLenum int mode, + int first, + @GLsizei int count, + @GLsizei int primcount, + @GLuint int baseinstance); + + void glDrawElementsInstancedBaseInstance(@GLenum int mode, + @AutoSize("indices") @GLsizei int count, + @AutoType("indices") @GLenum int type, + @Const + @BufferObject(BufferKind.ElementVBO) + @GLubyte + @GLushort + @GLuint Buffer indices, + @GLsizei int primcount, + @GLuint int baseinstance); + + void glDrawElementsInstancedBaseVertexBaseInstance(@GLenum int mode, + @AutoSize("indices") @GLsizei int count, + @AutoType("indices") @GLenum int type, + @Const + @BufferObject(BufferKind.ElementVBO) + @GLubyte + @GLushort + @GLuint Buffer indices, + @GLsizei int primcount, + int basevertex, + @GLuint int baseinstance); + + // --------------------------------------------------------------------------- + // ----------------------[ ARB_shader_image_load_store ]---------------------- + // --------------------------------------------------------------------------- + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, GetDoublev, and GetInteger64v: + */ + int GL_MAX_IMAGE_UNITS = 0x8F38, + GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS = 0x8F39, + GL_MAX_IMAGE_SAMPLES = 0x906D, + GL_MAX_VERTEX_IMAGE_UNIFORMS = 0x90CA, + GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS = 0x90CB, + GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS = 0x90CC, + GL_MAX_GEOMETRY_IMAGE_UNIFORMS = 0x90CD, + GL_MAX_FRAGMENT_IMAGE_UNIFORMS = 0x90CE, + GL_MAX_COMBINED_IMAGE_UNIFORMS = 0x90CF; + + /** Accepted by the <target> parameter of GetIntegeri_v and GetBooleani_v: */ + int GL_IMAGE_BINDING_NAME = 0x8F3A, + GL_IMAGE_BINDING_LEVEL = 0x8F3B, + GL_IMAGE_BINDING_LAYERED = 0x8F3C, + GL_IMAGE_BINDING_LAYER = 0x8F3D, + GL_IMAGE_BINDING_ACCESS = 0x8F3E, + GL_IMAGE_BINDING_FORMAT = 0x906E; + + /** Accepted by the <barriers> parameter of MemoryBarrier: */ + int GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT = 0x00000001, + GL_ELEMENT_ARRAY_BARRIER_BIT = 0x00000002, + GL_UNIFORM_BARRIER_BIT = 0x00000004, + GL_TEXTURE_FETCH_BARRIER_BIT = 0x00000008, + GL_SHADER_IMAGE_ACCESS_BARRIER_BIT = 0x00000020, + GL_COMMAND_BARRIER_BIT = 0x00000040, + GL_PIXEL_BUFFER_BARRIER_BIT = 0x00000080, + GL_TEXTURE_UPDATE_BARRIER_BIT = 0x00000100, + GL_BUFFER_UPDATE_BARRIER_BIT = 0x00000200, + GL_FRAMEBUFFER_BARRIER_BIT = 0x00000400, + GL_TRANSFORM_FEEDBACK_BARRIER_BIT = 0x00000800, + GL_ATOMIC_COUNTER_BARRIER_BIT = 0x00001000, + GL_ALL_BARRIER_BITS = 0xFFFFFFFF; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_IMAGE_1D = 0x904C, + GL_IMAGE_2D ... [truncated message content] |
From: <ka...@us...> - 2011-08-06 13:18:55
|
Revision: 3604 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3604&view=rev Author: kappa1 Date: 2011-08-06 13:18:49 +0000 (Sat, 06 Aug 2011) Log Message: ----------- Fix issue with Linux and Java 7 where libjawt.so was failing to load. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java Modified: trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java 2011-08-02 23:45:19 UTC (rev 3603) +++ trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java 2011-08-06 13:18:49 UTC (rev 3604) @@ -31,6 +31,10 @@ */ package org.lwjgl; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.lang.UnsatisfiedLinkError; /** * @@ -42,7 +46,21 @@ private static final int JNI_VERSION = 19; static { - java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded + // Load libawt.so and libmawt.so, needed for libjawt.so + java.awt.Toolkit.getDefaultToolkit(); + + // manually load libjawt.so into vm, needed since Java 7 + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + try { + System.loadLibrary("jawt"); + } catch (UnsatisfiedLinkError e) { + // catch and ignore an already loaded in another classloader + // exception, as vm already has it loaded + } + return null; + } + }); } public int getRequiredJNIVersion() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-08-02 23:45:26
|
Revision: 3603 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3603&view=rev Author: spasi Date: 2011-08-02 23:45:19 +0000 (Tue, 02 Aug 2011) Log Message: ----------- CL: Cleaned-up callbacks and object registries. Mapped: Added .capacity() and .foreach() with default elementCount. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLCommandQueue.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLContext.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLEvent.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLEventCallback.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLMemObjectDestructorCallback.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLNativeKernel.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLPlatform.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java trunk/LWJGL/src/templates/org/lwjgl/opencl/CL10.java trunk/LWJGL/src/templates/org/lwjgl/opencl/CL11.java Removed Paths: ------------- trunk/LWJGL/src/java/org/lwjgl/opencl/CLCallback.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -31,24 +31,39 @@ */ package org.lwjgl.opencl; +import org.lwjgl.PointerWrapperAbstract; + /** * Instances of this class can be used to receive OpenCL program build notifications. + * A single CLBuildProgramCallback instance should only be used with programs created + * in the same CLContext. * * @author Spasi */ -public abstract class CLBuildProgramCallback extends CLCallback { +public abstract class CLBuildProgramCallback extends PointerWrapperAbstract { + private CLContext context; + protected CLBuildProgramCallback() { super(CallbackUtil.getBuildProgramCallback()); } /** + * Sets the context that contains the CLPrograms to which we're registered. + * + * @param context the CLContext object + */ + void setContext(final CLContext context) { + this.context = context; + } + + /** * Called from native code. * * @param program_address the CLProgram object pointer */ private void handleMessage(long program_address) { - handleMessage(CLContext.getCLProgramGlobal(program_address)); + handleMessage(context.getCLProgram(program_address)); } /** Deleted: trunk/LWJGL/src/java/org/lwjgl/opencl/CLCallback.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLCallback.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLCallback.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2002-2010 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opencl; - -import org.lwjgl.PointerWrapperAbstract; - -/** - * Base class for OpenCL callback objects. - * - * @author Spasi - */ -abstract class CLCallback extends PointerWrapperAbstract { - - private final boolean custom; - - protected CLCallback(final long pointer) { - this(pointer, false); - } - - protected CLCallback(final long pointer, final boolean custom) { - super(pointer); - - this.custom = custom; - } - - final boolean isCustom() { - return custom; - } - -} \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CLCommandQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLCommandQueue.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLCommandQueue.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -50,7 +50,7 @@ super(pointer, context); if ( isValid() ) { this.device = device; - this.clEvents = new CLObjectRegistryGlobal<CLEvent>(CLContext.clEventsGlobal); + this.clEvents = new CLObjectRegistry<CLEvent>(); context.getCLCommandQueueRegistry().registerObject(this); } else { this.device = null; Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CLContext.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLContext.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLContext.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -54,12 +54,6 @@ private final CLObjectRegistry<CLProgram> clPrograms; private final CLObjectRegistry<CLEvent> clEvents; - /** Global registry for build callbacks. */ - static final FastLongMap<CLProgram> clProgramsGlobal = new FastLongMap<CLProgram>(); - - /** Global registry for event callbacks. */ - static final FastLongMap<CLEvent> clEventsGlobal = new FastLongMap<CLEvent>(); - CLContext(final long pointer, final CLPlatform platform) { super(pointer, platform); @@ -70,8 +64,8 @@ clCommandQueues = new CLObjectRegistry<CLCommandQueue>(); clMems = new CLObjectRegistry<CLMem>(); clSamplers = new CLObjectRegistry<CLSampler>(); - clPrograms = new CLObjectRegistryGlobal<CLProgram>(clProgramsGlobal); - clEvents = new CLObjectRegistryGlobal<CLEvent>(clEventsGlobal); + clPrograms = new CLObjectRegistry<CLProgram>(); + clEvents = new CLObjectRegistry<CLEvent>(); } else { clCommandQueues = null; clMems = null; @@ -275,8 +269,4 @@ CLObjectRegistry<CLEvent> getCLEventRegistry() { return clEvents; } - static CLProgram getCLProgramGlobal(final long id) { return clProgramsGlobal.get(id); } - - static CLEvent getCLEventGlobal(final long id) { return clEventsGlobal.get(id); } - } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CLEvent.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLEvent.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLEvent.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -108,6 +108,13 @@ // -------[ IMPLEMENTATION STUFF BELOW ]------- + CLObjectRegistry<CLEvent> getParentRegistry() { + if ( queue == null ) + return getParent().getCLEventRegistry(); + else + return queue.getCLEventRegistry(); + } + int release() { try { return super.release(); Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CLEventCallback.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLEventCallback.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLEventCallback.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -31,30 +31,46 @@ */ package org.lwjgl.opencl; +import org.lwjgl.PointerWrapperAbstract; + /** - * Instances of this class can be used to receive OpenCL memory object destruction notifications. + * Instances of this class can be used to handle OpenCL event callbacks. A single + * CLEventCallback instance should only be used on events generated from the same + * CLCommandQueue or on user events associated with the same CLContext. * * @author Spasi */ -public abstract class CLEventCallback extends CLCallback { +public abstract class CLEventCallback extends PointerWrapperAbstract { + private CLObjectRegistry<CLEvent> eventRegistry; + protected CLEventCallback() { super(CallbackUtil.getEventCallback()); } /** + * Sets the eventRegistry that contains the CLEvents to which we're registered. + * + * @param eventRegistry the CLEvent object registry + */ + void setRegistry(final CLObjectRegistry<CLEvent> eventRegistry) { + this.eventRegistry = eventRegistry; + } + + /** * Called from native code. * * @param event_address the CLEvent object pointer */ private void handleMessage(long event_address, int event_command_exec_status) { - handleMessage(CLContext.getCLEventGlobal(event_address), event_command_exec_status); + handleMessage(eventRegistry.getObject(event_address), event_command_exec_status); } /** * The callback method. * - * @param event the CLEvent object + * @param event the CLEvent object + * @param event_command_exec_status the execution status */ protected abstract void handleMessage(CLEvent event, int event_command_exec_status); Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CLMemObjectDestructorCallback.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLMemObjectDestructorCallback.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLMemObjectDestructorCallback.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -31,12 +31,14 @@ */ package org.lwjgl.opencl; +import org.lwjgl.PointerWrapperAbstract; + /** * Instances of this class can be used to receive OpenCL memory object destruction notifications. * * @author Spasi */ -public abstract class CLMemObjectDestructorCallback extends CLCallback { +public abstract class CLMemObjectDestructorCallback extends PointerWrapperAbstract { protected CLMemObjectDestructorCallback() { super(CallbackUtil.getMemObjectDestructorCallback()); Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CLNativeKernel.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLNativeKernel.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLNativeKernel.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -31,6 +31,8 @@ */ package org.lwjgl.opencl; +import org.lwjgl.PointerWrapperAbstract; + import java.nio.ByteBuffer; /** @@ -43,7 +45,7 @@ * @see CL10#clEnqueueNativeKernel * @see #execute(java.nio.ByteBuffer[]) */ -public abstract class CLNativeKernel extends CLCallback { +public abstract class CLNativeKernel extends PointerWrapperAbstract { protected CLNativeKernel() { super(CallbackUtil.getNativeKernelCallback()); Deleted: trunk/LWJGL/src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2002-2010 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opencl; - -/** - * A CLObject registry that also registers/unregisters objects to/from a global registry. - * - * @author Spasi - */ -final class CLObjectRegistryGlobal<T extends CLObjectChild> extends CLObjectRegistry<T> { - - private final FastLongMap<T> globalRegistry; - - CLObjectRegistryGlobal(final FastLongMap<T> globalRegistry) { - this.globalRegistry = globalRegistry; - } - - void registerObject(final T object) { - super.registerObject(object); - globalRegistry.put(object.getPointer(), object); - } - - void unregisterObject(final T object) { - super.unregisterObject(object); - globalRegistry.remove(object.getPointerUnsafe()); - } - -} \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CLPlatform.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opencl/CLPlatform.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/opencl/CLPlatform.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -53,9 +53,6 @@ private final CLObjectRegistry<CLDevice> clDevices; - /** Global registry for build callbacks. */ - static final FastLongMap<CLDevice> clDevicesGlobal = new FastLongMap<CLDevice>(); - private Object caps; CLPlatform(final long pointer) { @@ -63,7 +60,7 @@ if ( isValid() ) { clPlatforms.put(pointer, this); - clDevices = new CLObjectRegistryGlobal<CLDevice>(clDevicesGlobal); + clDevices = new CLObjectRegistry<CLDevice>(); } else clDevices = null; } @@ -195,8 +192,6 @@ CLObjectRegistry<CLDevice> getCLDeviceRegistry() { return clDevices; } - static CLDevice getCLDeviceGlobal(final long id) { return clDevicesGlobal.get(id); } - /** * Called from <code>clGetDeviceIDs</code> to register new devices. * Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -55,13 +55,20 @@ ByteBuffer bb = ByteBuffer.allocateDirect(200); MappedFloat vecs = MappedFloat.map(bb); - // verify 'malloc' and SIZEOF + // verify 'malloc', SIZEOF and capacity() { MappedFloat vecs1 = MappedFloat.malloc(1234); assert (vecs1.getSizeof() == MappedFloat.SIZEOF); assert (vecs1.getSizeof() * 1234 == vecs1.backingByteBuffer().capacity()); assert (MappedFloat.SIZEOF * 1234 == vecs1.backingByteBuffer().capacity()); + assert(vecs1.capacity() == vecs1.backingByteBuffer().capacity() / MappedFloat.SIZEOF); + + ByteBuffer buf = ByteBuffer.allocateDirect(200); + buf.position(10 * MappedFloat.SIZEOF); + + MappedFloat vecs2 = MappedFloat.map(buf); + assert(vecs2.capacity() == (vecs2.backingByteBuffer().capacity() / MappedFloat.SIZEOF) - 10); } // manipulate 'mapped.value' Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -70,15 +70,21 @@ } static void testForeach() { - int elementCount = 4; + int elementCount = 10; MappedSomething some = MappedSomething.malloc(elementCount); int i = 0; - for ( MappedSomething item : foreach(some, elementCount) ) { + for ( MappedSomething item : foreach(some, elementCount / 2) ) { assert (item.view == i++); } - assert (some.view != elementCount); - System.out.println("current.view=" + some.view + ", not " + elementCount + ", as you might expect"); + assert (some.view == (elementCount / 2) - 1); + System.out.println("current.view=" + some.view + ", not " + (elementCount / 2) + ", as you might expect"); + + i = 0; + for ( MappedSomething item : foreach(some) ) { + assert (item.view == i++); + } + assert (some.view == elementCount - 1); } public static class Xyz extends MappedObject { Modified: trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -143,23 +143,41 @@ System.out.println("-TRYING TO EXEC NATIVE KERNEL-"); final CLCommandQueue queue = clCreateCommandQueue(context, device, 0, null); + final PointerBuffer ev = BufferUtils.createPointerBuffer(1); + clEnqueueNativeKernel(queue, new CLNativeKernel() { protected void execute(final ByteBuffer[] memobjs) { - if ( memobjs == null ) - System.out.println("OK, it's null"); - else { - System.out.println("memobjs = " + memobjs.length); - for ( int k = 0; k < memobjs.length; k++ ) { - System.out.println("memobjs[" + k + "].remaining() = " + memobjs[k].remaining()); - for ( int l = memobjs[k].position(); l < memobjs[k].limit(); l++ ) { - memobjs[k].put(l, (byte)l); - } + System.out.println("\tmemobjs.length = " + memobjs.length); + for ( int k = 0; k < memobjs.length; k++ ) { + System.out.println("\tmemobjs[" + k + "].remaining() = " + memobjs[k].remaining()); + for ( int l = memobjs[k].position(); l < memobjs[k].limit(); l++ ) { + memobjs[k].put(l, (byte)l); } } + System.out.println("\tNative kernel done."); } - }, new CLMem[] { buffer }, new long[] { 128 }, null, null); + }, new CLMem[] { buffer }, new long[] { 128 }, null, ev); - clFinish(queue); + final CLEvent e = queue.getCLEvent(ev.get(0)); + + clSetEventCallback(e, CL_COMPLETE, new CLEventCallback() { + protected void handleMessage(final CLEvent event, final int event_command_exec_status) { + System.out.println("\t\tEvent callback status: " + getEventStatusName(event_command_exec_status)); + } + }); + + int status = e.getInfoInt(CL_EVENT_COMMAND_EXECUTION_STATUS); + System.out.println("NATIVE KERNEL STATUS: " + getEventStatusName(status)); + clFlush(queue); + do { + int newStatus = e.getInfoInt(CL_EVENT_COMMAND_EXECUTION_STATUS); + if ( newStatus != status ) { + status = newStatus; + System.out.println("NATIVE KERNEL STATUS: " + getEventStatusName(status)); + } + } while ( status != CL_SUCCESS ); // Busy-spin until we're done + + clReleaseEvent(e); } } @@ -182,6 +200,19 @@ System.out.println("\t" + param_name + " = " + device.getInfoString(param)); } + private static String getEventStatusName(final int status) { + switch ( status ) { + case CL_QUEUED: + return "CL_QUEUED"; + case CL_SUBMITTED: + return "CL_SUBMITTED"; + case CL_RUNNING: + return "CL_RUNNING"; + default: + return "CL_COMPLETE"; + } + } + private static void die(String kind, String description) { System.out.println(kind + " error " + description + " occured"); } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -133,6 +133,16 @@ } /** + * Returns the number of mapped objects that fit in the mapped buffer. + * + * @return the mapped object capacity + */ + public final int capacity() { + // No call-site modification for this, we override in every subclass instead. + throw new InternalError("type not registered"); + } + + /** * Creates a MappedObject instance, mapping the memory region of the specified direct ByteBuffer. * <p/> * The behavior of this (transformed) method does not follow the normal Java behavior.<br> @@ -200,7 +210,7 @@ /** * Any code in the default constructor will not run automatically. This method - * can be used to run execute that code on the current view. + * can be used to execute that code on the current view. */ public final void runViewConstructor() { // any method that calls this method will have its call-site modified @@ -237,6 +247,18 @@ /** * Creates an {@link Iterable} <MappedObject> that will step through + * <code>capacity()</code> views, leaving the <code>view</code> at + * the last valid value.<br> + * <p/> + * For convenience you are encouraged to static-import this specific method: + * <code>import static org.lwjgl.util.mapped.MappedObject.foreach;</code> + */ + public static <T extends MappedObject> Iterable<T> foreach(T mapped) { + return foreach(mapped, mapped.capacity()); + } + + /** + * Creates an {@link Iterable} <MappedObject> that will step through * <code>elementCount</code> views, leaving the <code>view</code> at * the last valid value.<br> * <p/> Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -32,6 +32,7 @@ package org.lwjgl.util.mapped; import org.lwjgl.LWJGLUtil; +import org.lwjgl.MemoryUtil; import org.objectweb.asm.*; import org.objectweb.asm.tree.*; import org.objectweb.asm.tree.analysis.*; @@ -42,6 +43,7 @@ import java.io.StringWriter; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Map; @@ -82,9 +84,9 @@ static final String NEXT_METHOD_NAME = "next"; static final String ALIGN_METHOD_NAME = "getAlign"; static final String SIZEOF_METHOD_NAME = "getSizeof"; + static final String CAPACITY_METHOD_NAME = "capacity"; // Used for .asArray().length // Internal methods - static final String LENGTH_METHOD_NAME = "length$LWJGL"; // Used for .asArray().length static final String VIEW_CONSTRUCTOR_NAME = "constructView$LWJGL"; // Used by runViewConstructor static final Map<Integer, String> OPCODE_TO_NAME = new HashMap<Integer, String>(); @@ -228,6 +230,7 @@ NEXT_METHOD_NAME, ALIGN_METHOD_NAME, SIZEOF_METHOD_NAME, + CAPACITY_METHOD_NAME, }; public MethodVisitor visitMethod(int access, final String name, final String desc, final String signature, final String[] exceptions) { @@ -285,7 +288,7 @@ final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); generateViewAddressGetter(); - generateLengthGetter(); + generateCapacity(); generateAlignGetter(mappedSubtype); generateSizeofGetter(); generateNext(); @@ -329,16 +332,25 @@ mv.visitEnd(); } - private void generateLengthGetter() { - MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, LENGTH_METHOD_NAME, "(L" + className + ";)I", null, null); + private void generateCapacity() { + // return (backingByteBuffer().capacity() + (int)(MemoryUtil.getAddress0(backingByteBuffer()) - baseAddress)) / SIZEOF; + MethodVisitor mv = super.visitMethod(ACC_PUBLIC, CAPACITY_METHOD_NAME, "()I", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEVIRTUAL, MAPPED_OBJECT_JVM, "backingByteBuffer", "()L" + jvmClassName(ByteBuffer.class) + ";"); + mv.visitInsn(DUP); mv.visitMethodInsn(INVOKEVIRTUAL, jvmClassName(ByteBuffer.class), "capacity", "()I"); + mv.visitInsn(SWAP); + mv.visitMethodInsn(INVOKESTATIC, jvmClassName(MemoryUtil.class), "getAddress0", "(L" + jvmClassName(Buffer.class) + ";)J"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, MAPPED_OBJECT_JVM, "baseAddress", "J"); + mv.visitInsn(LSUB); + mv.visitInsn(L2I); + mv.visitInsn(IADD); mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I"); mv.visitInsn(IDIV); mv.visitInsn(IRETURN); - mv.visitMaxs(2, 1); + mv.visitMaxs(3, 1); mv.visitEnd(); } @@ -1037,7 +1049,7 @@ instructions.remove(nextInsn); loadInsn.var = var; - instructions.insert(loadInsn, new MethodInsnNode(INVOKESTATIC, mappedSubtype.className, LENGTH_METHOD_NAME, "(L" + mappedSubtype.className + ";)I")); + instructions.insert(loadInsn, new MethodInsnNode(INVOKEVIRTUAL, mappedSubtype.className, CAPACITY_METHOD_NAME, "()I")); return i + 1; } else if ( stackSize < loadStackSize ) // Consumed by something other than AALOAD or ARRAYLENGTH Modified: trunk/LWJGL/src/templates/org/lwjgl/opencl/CL10.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opencl/CL10.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/templates/org/lwjgl/opencl/CL10.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -432,7 +432,7 @@ @Code( tryBlock = true, // Create a GlobalRef to the callback object. - javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);", // Associate context with the GlobalRef, so we can delete it later. javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);" ) @@ -845,7 +845,8 @@ @Code( tryBlock = true, // Create a GlobalRef to the callback object. - javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());", // Check if we need to delete the GlobalRef. javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" ) @@ -861,7 +862,8 @@ @Code( tryBlock = true, // Create a GlobalRef to the callback object. - javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());", // Check if we need to delete the GlobalRef. javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" ) @@ -877,7 +879,8 @@ @Code( tryBlock = true, // Create a GlobalRef to the callback object. - javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());", // Check if we need to delete the GlobalRef. javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" ) Modified: trunk/LWJGL/src/templates/org/lwjgl/opencl/CL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opencl/CL11.java 2011-07-29 11:30:14 UTC (rev 3602) +++ trunk/LWJGL/src/templates/org/lwjgl/opencl/CL11.java 2011-08-02 23:45:19 UTC (rev 3603) @@ -190,7 +190,8 @@ @Code( tryBlock = true, // Create a GlobalRef to the callback object. - javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tpfn_notify.setRegistry(event.getParentRegistry());", // Check if we need to delete the GlobalRef. javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-29 11:30:22
|
Revision: 3602 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3602&view=rev Author: spasi Date: 2011-07-29 11:30:14 +0000 (Fri, 29 Jul 2011) Log Message: ----------- Added support for NV_path_rendering. Made MappedObjectUnsafe package private. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java trunk/LWJGL/src/java/org/lwjgl/util/generator/AutoSize.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java Added Paths: ----------- trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_path_rendering.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java 2011-07-24 09:38:46 UTC (rev 3601) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -31,11 +31,12 @@ */ package org.lwjgl.opengl; -import java.nio.Buffer; - import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLUtil; +import java.nio.Buffer; +import java.nio.FloatBuffer; + import static org.lwjgl.opengl.ARBBufferObject.*; import static org.lwjgl.opengl.ATIVertexArrayObject.*; import static org.lwjgl.opengl.EXTAbgr.*; @@ -43,6 +44,7 @@ import static org.lwjgl.opengl.EXTDirectStateAccess.*; import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL15.*; +import static org.lwjgl.opengl.NVPathRendering.*; /** * A class to check buffer boundaries in GL methods. Many GL @@ -55,7 +57,7 @@ * * @author cix_foo <ci...@us...> * @version $Revision$ - * $Id$ + * $Id$ */ class GLChecks { @@ -81,25 +83,25 @@ /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ static void ensureArrayVBOdisabled(ContextCapabilities caps) { - if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 ) + if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 ) throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled"); } /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ static void ensureArrayVBOenabled(ContextCapabilities caps) { - if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 ) + if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 ) throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled"); } /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ static void ensureElementVBOdisabled(ContextCapabilities caps) { - if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 ) + if ( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 ) throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled"); } /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ static void ensureElementVBOenabled(ContextCapabilities caps) { - if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 ) + if ( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 ) throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled"); } @@ -209,10 +211,10 @@ case GL_FLOAT: bpe = 4; break; - default : + default: // TODO: Add more types (like the GL12 types GL_UNSIGNED_INT_8_8_8_8 return 0; - // throw new IllegalArgumentException("Unknown type " + type); + // throw new IllegalArgumentException("Unknown type " + type); } int epp; switch ( format ) { @@ -233,7 +235,7 @@ case GL_BGRA_EXT: epp = 4; break; - default : + default: // TODO: Add more formats. Assuming 4 is too wasteful on buffer sizes where e.g. 1 is enough (like GL_DEPTH_COMPONENT) return 0; /* // Assume 4 elements per pixel @@ -242,4 +244,116 @@ return bpe * epp; } -} + + // NV_path_rendering checks + + static int calculateBytesPerCharCode(int type) { + switch ( type ) { + case GL_UNSIGNED_BYTE: + case GL_UTF8_NV: + return 1; + case GL_UNSIGNED_SHORT: + case GL_2_BYTES: + case GL_UTF16_NV: + return 2; + case GL_3_BYTES: + return 3; + case GL_4_BYTES: + return 4; + default: + throw new IllegalArgumentException("Unsupported charcode type: " + type); + } + } + + static int calculateBytesPerPathName(int pathNameType) { + switch ( pathNameType ) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_UTF8_NV: + return 1; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_2_BYTES: + case GL_UTF16_NV: + return 2; + case GL_3_BYTES: + return 3; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_4_BYTES: + return 4; + default: + throw new IllegalArgumentException("Unsupported path name type: " + pathNameType); + } + } + + static int calculateTransformPathValues(int transformType) { + switch ( transformType ) { + case GL_NONE: + return 0; + case GL_TRANSLATE_X_NV: + case GL_TRANSLATE_Y_NV: + return 1; + case GL_TRANSLATE_2D_NV: + return 2; + case GL_TRANSLATE_3D_NV: + return 3; + case GL_AFFINE_2D_NV: + case GL_TRANSPOSE_AFFINE_2D_NV: + return 6; + case GL_AFFINE_3D_NV: + case GL_TRANSPOSE_AFFINE_3D_NV: + return 12; + default: + throw new IllegalArgumentException("Unsupported transform type: " + transformType); + } + } + + static int calculatePathColorGenCoeffsCount(int genMode, int colorFormat) { + final int coeffsPerComponent = calculatePathGenCoeffsPerComponent(genMode); + + switch ( colorFormat ) { + case GL_RGB: + return 3 * coeffsPerComponent; + case GL_RGBA: + return 4 * coeffsPerComponent; + default: + return coeffsPerComponent; + } + } + + static int calculatePathTextGenCoeffsPerComponent(FloatBuffer coeffs, int genMode) { + if ( genMode == GL_NONE ) + return 0; + + return coeffs.remaining() / calculatePathGenCoeffsPerComponent(genMode); + } + + private static int calculatePathGenCoeffsPerComponent(int genMode) { + switch ( genMode ) { + case GL_NONE: + return 0; + case GL_OBJECT_LINEAR: + case GL_PATH_OBJECT_BOUNDING_BOX_NV: + return 3; + case GL_EYE_LINEAR: + return 4; + default: + throw new IllegalArgumentException("Unsupported gen mode: " + genMode); + } + } + + static int calculateMetricsSize(int metricQueryMask, int stride) { + if ( LWJGLUtil.DEBUG && (stride < 0 || (stride % 4) != 0) ) + throw new IllegalArgumentException("Invalid stride value: " + stride); + + final int metrics = Integer.bitCount(metricQueryMask); + + if ( LWJGLUtil.DEBUG && (stride >> 2) < metrics ) + throw new IllegalArgumentException("The queried metrics do not fit in the specified stride: " + stride); + + return stride == 0 ? metrics : (stride >> 2); + } + +} \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-24 09:38:46 UTC (rev 3601) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -32,7 +32,6 @@ package org.lwjgl.test.mapped; import org.lwjgl.MemoryUtil; -import org.lwjgl.util.mapped.MappedObjectUnsafe; import java.nio.ByteBuffer; import java.util.Arrays; Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-24 09:38:46 UTC (rev 3601) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -33,7 +33,6 @@ import org.lwjgl.MemoryUtil; import org.lwjgl.util.mapped.MappedHelper; -import org.lwjgl.util.mapped.MappedObjectUnsafe; import java.nio.ByteBuffer; Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/AutoSize.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/AutoSize.java 2011-07-24 09:38:46 UTC (rev 3601) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/AutoSize.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -49,6 +49,7 @@ public @interface AutoSize { String value(); // The name of the Buffer parameter String expression() default ""; // This value is added after the argument + boolean useExpression() default false; // When this is true, the expression result will be used directly. boolean canBeNull() default false; // When this is true and the Buffer parameter is null, 0 will be used. boolean isNative() default false; // When this is true, auto-sizing will be performed in native code. } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-24 09:38:46 UTC (rev 3601) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -458,25 +458,27 @@ writer.print(auto_type); } else if (AutoSize.class.equals(param_type)) { final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class); - final String auto_parameter_name = auto_size_annotation.value(); - final ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name); - final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param); - final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param); - int shifting = 0; - if ( shift_remaining ) { - shifting = getBufferElementSizeExponent(auto_target_type_info.getType()); - if ( shifting > 0 ) - writer.print("("); + if ( !auto_size_annotation.useExpression() ) { + final String auto_parameter_name = auto_size_annotation.value(); + final ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name); + final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param); + final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param); + int shifting = 0; + if ( shift_remaining ) { + shifting = getBufferElementSizeExponent(auto_target_type_info.getType()); + if ( shifting > 0 ) + writer.print("("); + } + if ( auto_size_annotation.canBeNull() ) + writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())"); + else + writer.print(auto_parameter_name + ".remaining()"); + // Shift the remaining if the target parameter is multityped and there's no AutoType to track type + if (shift_remaining && shifting > 0) { + writer.print(" << " + shifting); + writer.print(")"); + } } - if ( auto_size_annotation.canBeNull() ) - writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())"); - else - writer.print(auto_parameter_name + ".remaining()"); - // Shift the remaining if the target parameter is multityped and there's no AutoType to track type - if (shift_remaining && shifting > 0) { - writer.print(" << " + shifting); - writer.print(")"); - } writer.print(auto_size_annotation.expression()); } else throw new RuntimeException("Unknown auto annotation " + param_type); Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-24 09:38:46 UTC (rev 3601) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -36,6 +36,8 @@ import java.nio.ByteBuffer; +import static org.lwjgl.util.mapped.MappedObjectUnsafe.*; + /** * [INTERNAL USE ONLY] * <p/> @@ -122,7 +124,7 @@ dst.checkRange(bytes); } - MappedObjectUnsafe.INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes); + INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes); } public static ByteBuffer newBuffer(long address, int capacity) { @@ -134,257 +136,257 @@ // byte public static void bput(byte value, long addr) { - MappedObjectUnsafe.INSTANCE.putByte(addr, value); + INSTANCE.putByte(addr, value); } public static void bput(MappedObject mapped, byte value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putByte(mapped.viewAddress + fieldOffset, value); + INSTANCE.putByte(mapped.viewAddress + fieldOffset, value); } public static byte bget(long addr) { - return MappedObjectUnsafe.INSTANCE.getByte(addr); + return INSTANCE.getByte(addr); } public static byte bget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getByte(mapped.viewAddress + fieldOffset); + return INSTANCE.getByte(mapped.viewAddress + fieldOffset); } public static void bvput(byte value, long addr) { - MappedObjectUnsafe.INSTANCE.putByteVolatile(null, addr, value); + INSTANCE.putByteVolatile(null, addr, value); } public static void bvput(MappedObject mapped, byte value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value); + INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value); } public static byte bvget(long addr) { - return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, addr); + return INSTANCE.getByteVolatile(null, addr); } public static byte bvget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset); + return INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset); } // short public static void sput(short value, long addr) { - MappedObjectUnsafe.INSTANCE.putShort(addr, value); + INSTANCE.putShort(addr, value); } public static void sput(MappedObject mapped, short value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putShort(mapped.viewAddress + fieldOffset, value); + INSTANCE.putShort(mapped.viewAddress + fieldOffset, value); } public static short sget(long addr) { - return MappedObjectUnsafe.INSTANCE.getShort(addr); + return INSTANCE.getShort(addr); } public static short sget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getShort(mapped.viewAddress + fieldOffset); + return INSTANCE.getShort(mapped.viewAddress + fieldOffset); } public static void svput(short value, long addr) { - MappedObjectUnsafe.INSTANCE.putShortVolatile(null, addr, value); + INSTANCE.putShortVolatile(null, addr, value); } public static void svput(MappedObject mapped, short value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value); + INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value); } public static short svget(long addr) { - return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, addr); + return INSTANCE.getShortVolatile(null, addr); } public static short svget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset); + return INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset); } // char public static void cput(char value, long addr) { - MappedObjectUnsafe.INSTANCE.putChar(addr, value); + INSTANCE.putChar(addr, value); } public static void cput(MappedObject mapped, char value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putChar(mapped.viewAddress + fieldOffset, value); + INSTANCE.putChar(mapped.viewAddress + fieldOffset, value); } public static char cget(long addr) { - return MappedObjectUnsafe.INSTANCE.getChar(addr); + return INSTANCE.getChar(addr); } public static char cget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getChar(mapped.viewAddress + fieldOffset); + return INSTANCE.getChar(mapped.viewAddress + fieldOffset); } public static void cvput(char value, long addr) { - MappedObjectUnsafe.INSTANCE.putCharVolatile(null, addr, value); + INSTANCE.putCharVolatile(null, addr, value); } public static void cvput(MappedObject mapped, char value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value); + INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value); } public static char cvget(long addr) { - return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, addr); + return INSTANCE.getCharVolatile(null, addr); } public static char cvget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset); + return INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset); } // int public static void iput(int value, long addr) { - MappedObjectUnsafe.INSTANCE.putInt(addr, value); + INSTANCE.putInt(addr, value); } public static void iput(MappedObject mapped, int value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putInt(mapped.viewAddress + fieldOffset, value); + INSTANCE.putInt(mapped.viewAddress + fieldOffset, value); } public static int iget(long address) { - return MappedObjectUnsafe.INSTANCE.getInt(address); + return INSTANCE.getInt(address); } public static int iget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getInt(mapped.viewAddress + fieldOffset); + return INSTANCE.getInt(mapped.viewAddress + fieldOffset); } public static void ivput(int value, long addr) { - MappedObjectUnsafe.INSTANCE.putIntVolatile(null, addr, value); + INSTANCE.putIntVolatile(null, addr, value); } public static void ivput(MappedObject mapped, int value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value); + INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value); } public static int ivget(long address) { - return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, address); + return INSTANCE.getIntVolatile(null, address); } public static int ivget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset); + return INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset); } // float public static void fput(float value, long addr) { - MappedObjectUnsafe.INSTANCE.putFloat(addr, value); + INSTANCE.putFloat(addr, value); } public static void fput(MappedObject mapped, float value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value); + INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value); } public static float fget(long addr) { - return MappedObjectUnsafe.INSTANCE.getFloat(addr); + return INSTANCE.getFloat(addr); } public static float fget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getFloat(mapped.viewAddress + fieldOffset); + return INSTANCE.getFloat(mapped.viewAddress + fieldOffset); } public static void fvput(float value, long addr) { - MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, addr, value); + INSTANCE.putFloatVolatile(null, addr, value); } public static void fvput(MappedObject mapped, float value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value); + INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value); } public static float fvget(long addr) { - return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, addr); + return INSTANCE.getFloatVolatile(null, addr); } public static float fvget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset); + return INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset); } // long public static void jput(long value, long addr) { - MappedObjectUnsafe.INSTANCE.putLong(addr, value); + INSTANCE.putLong(addr, value); } public static void jput(MappedObject mapped, long value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putLong(mapped.viewAddress + fieldOffset, value); + INSTANCE.putLong(mapped.viewAddress + fieldOffset, value); } public static long jget(long addr) { - return MappedObjectUnsafe.INSTANCE.getLong(addr); + return INSTANCE.getLong(addr); } public static long lget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset); + return INSTANCE.getLong(mapped.viewAddress + fieldOffset); } public static void jvput(long value, long addr) { - MappedObjectUnsafe.INSTANCE.putLongVolatile(null, addr, value); + INSTANCE.putLongVolatile(null, addr, value); } public static void jvput(MappedObject mapped, long value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value); + INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value); } public static long jvget(long addr) { - return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, addr); + return INSTANCE.getLongVolatile(null, addr); } public static long lvget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset); + return INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset); } // address public static void aput(long value, long addr) { - MappedObjectUnsafe.INSTANCE.putAddress(addr, value); + INSTANCE.putAddress(addr, value); } public static void aput(MappedObject mapped, long value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value); + INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value); } public static long aget(long addr) { - return MappedObjectUnsafe.INSTANCE.getAddress(addr); + return INSTANCE.getAddress(addr); } public static long aget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getAddress(mapped.viewAddress + fieldOffset); + return INSTANCE.getAddress(mapped.viewAddress + fieldOffset); } // double public static void dput(double value, long addr) { - MappedObjectUnsafe.INSTANCE.putDouble(addr, value); + INSTANCE.putDouble(addr, value); } public static void dput(MappedObject mapped, double value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value); + INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value); } public static double dget(long addr) { - return MappedObjectUnsafe.INSTANCE.getDouble(addr); + return INSTANCE.getDouble(addr); } public static double dget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getDouble(mapped.viewAddress + fieldOffset); + return INSTANCE.getDouble(mapped.viewAddress + fieldOffset); } public static void dvput(double value, long addr) { - MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, addr, value); + INSTANCE.putDoubleVolatile(null, addr, value); } public static void dvput(MappedObject mapped, double value, int fieldOffset) { - MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value); + INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value); } public static double dvget(long addr) { - return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, addr); + return INSTANCE.getDoubleVolatile(null, addr); } public static double dvget(MappedObject mapped, int fieldOffset) { - return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset); + return INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset); } } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-24 09:38:46 UTC (rev 3601) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -549,10 +549,10 @@ final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>(); /* - We need this map because we insert/remove instructions from the stream and we need a way - to match each original instruction with the corresponding frame. - TODO: Can we keep track of everything more efficiently without a map? - */ + We need this map because we insert/remove instructions from the stream and we need a way + to match each original instruction with the corresponding frame. + TODO: Can we keep track of everything more efficiently without a map? + */ final Map<AbstractInsnNode, Frame<BasicValue>> frameMap = new HashMap<AbstractInsnNode, Frame<BasicValue>>(); for ( int i = 0; i < frames.length; i++ ) frameMap.put(instructions.get(i), frames[i]); Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java 2011-07-24 09:38:46 UTC (rev 3601) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -42,9 +42,9 @@ * * @author Riven */ -public class MappedObjectUnsafe { +final class MappedObjectUnsafe { - public static final Unsafe INSTANCE = getUnsafeInstance(); + static final Unsafe INSTANCE = getUnsafeInstance(); private static final long BUFFER_ADDRESS_OFFSET = getObjectFieldOffset(ByteBuffer.class, "address"); private static final long BUFFER_CAPACITY_OFFSET = getObjectFieldOffset(ByteBuffer.class, "capacity"); Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_path_rendering.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_path_rendering.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_path_rendering.java 2011-07-29 11:30:14 UTC (rev 3602) @@ -0,0 +1,515 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +public interface NV_path_rendering { + + /** + * Accepted in elements of the <commands> array parameter of + * PathCommandsNV and PathSubCommandsNV: + */ + int GL_CLOSE_PATH_NV = 0x00, + GL_MOVE_TO_NV = 0x02, + GL_RELATIVE_MOVE_TO_NV = 0x03, + GL_LINE_TO_NV = 0x04, + GL_RELATIVE_LINE_TO_NV = 0x05, + GL_HORIZONTAL_LINE_TO_NV = 0x06, + GL_RELATIVE_HORIZONTAL_LINE_TO_NV = 0x07, + GL_VERTICAL_LINE_TO_NV = 0x08, + GL_RELATIVE_VERTICAL_LINE_TO_NV = 0x09, + GL_QUADRATIC_CURVE_TO_NV = 0x0A, + GL_RELATIVE_QUADRATIC_CURVE_TO_NV = 0x0B, + GL_CUBIC_CURVE_TO_NV = 0x0C, + GL_RELATIVE_CUBIC_CURVE_TO_NV = 0x0D, + GL_SMOOTH_QUADRATIC_CURVE_TO_NV = 0x0E, + GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV = 0x0F, + GL_SMOOTH_CUBIC_CURVE_TO_NV = 0x10, + GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV = 0x11, + GL_SMALL_CCW_ARC_TO_NV = 0x12, + GL_RELATIVE_SMALL_CCW_ARC_TO_NV = 0x13, + GL_SMALL_CW_ARC_TO_NV = 0x14, + GL_RELATIVE_SMALL_CW_ARC_TO_NV = 0x15, + GL_LARGE_CCW_ARC_TO_NV = 0x16, + GL_RELATIVE_LARGE_CCW_ARC_TO_NV = 0x17, + GL_LARGE_CW_ARC_TO_NV = 0x18, + GL_RELATIVE_LARGE_CW_ARC_TO_NV = 0x19, + GL_CIRCULAR_CCW_ARC_TO_NV = 0xF8, + GL_CIRCULAR_CW_ARC_TO_NV = 0xFA, + GL_CIRCULAR_TANGENT_ARC_TO_NV = 0xFC, + GL_ARC_TO_NV = 0xFE, + GL_RELATIVE_ARC_TO_NV = 0xFF; + + /** Accepted by the <format> parameter of PathStringNV: */ + int GL_PATH_FORMAT_SVG_NV = 0x9070, + GL_PATH_FORMAT_PS_NV = 0x9071; + + /** + * Accepted by the <fontTarget> parameter of PathGlyphsNV and + * PathGlyphRangeNV: + */ + int GL_STANDARD_FONT_NAME_NV = 0x9072, + GL_SYSTEM_FONT_NAME_NV = 0x9073, + GL_FILE_NAME_NV = 0x9074; + + /** + * Accepted by the <handleMissingGlyph> parameter of PathGlyphsNV and + * PathGlyphRangeNV: + */ + int GL_SKIP_MISSING_GLYPH_NV = 0x90A9, + GL_USE_MISSING_GLYPH_NV = 0x90AA; + + /** + * Accepted by the <pname> parameter of PathParameterfNV, + * PathParameterfvNV, GetPathParameterfvNV, PathParameteriNV, + * PathParameterivNV, and GetPathParameterivNV: + */ + int GL_PATH_STROKE_WIDTH_NV = 0x9075, + GL_PATH_INITIAL_END_CAP_NV = 0x9077, + GL_PATH_TERMINAL_END_CAP_NV = 0x9078, + GL_PATH_JOIN_STYLE_NV = 0x9079, + GL_PATH_MITER_LIMIT_NV = 0x907A, + GL_PATH_INITIAL_DASH_CAP_NV = 0x907C, + GL_PATH_TERMINAL_DASH_CAP_NV = 0x907D, + GL_PATH_DASH_OFFSET_NV = 0x907E, + GL_PATH_CLIENT_LENGTH_NV = 0x907F, + GL_PATH_DASH_OFFSET_RESET_NV = 0x90B4, + + GL_PATH_FILL_MODE_NV = 0x9080, + GL_PATH_FILL_MASK_NV = 0x9081, + GL_PATH_FILL_COVER_MODE_NV = 0x9082, + GL_PATH_STROKE_COVER_MODE_NV = 0x9083, + GL_PATH_STROKE_MASK_NV = 0x9084; + + /** + * Accepted by the <pname> parameter of PathParameterfNV and + * PathParameterfvNV: + */ + int GL_PATH_END_CAPS_NV = 0x9076, + GL_PATH_DASH_CAPS_NV = 0x907B; + + /** + * Accepted by the <fillMode> parameter of StencilFillPathNV and + * StencilFillPathInstancedNV: + */ + int GL_COUNT_UP_NV = 0x9088, + GL_COUNT_DOWN_NV = 0x9089; + + /** + * Accepted by the <color> parameter of PathColorGenNV, + * GetPathColorGenivNV, and GetPathColorGenfvNV: + */ + int GL_PRIMARY_COLOR = 0x8577, // from OpenGL 1.3 + GL_PRIMARY_COLOR_NV = 0x852C, // from NV_register_combiners + GL_SECONDARY_COLOR_NV = 0x852D; // from NV_register_combiners + + /** + * Accepted by the <genMode> parameter of PathColorGenNV and + * PathTexGenNV: + */ + int GL_PATH_OBJECT_BOUNDING_BOX_NV = 0x908A; + + /** + * Accepted by the <coverMode> parameter of CoverFillPathNV and + * CoverFillPathInstancedNV: + */ + int GL_CONVEX_HULL_NV = 0x908B, + GL_BOUNDING_BOX_NV = 0x908D; + + /** + * Accepted by the <transformType> parameter of + * StencilFillPathInstancedNV, StencilStrokePathInstancedNV, + * CoverFillPathInstancedNV, and CoverStrokePathInstancedNV: + */ + int GL_TRANSLATE_X_NV = 0x908E, + GL_TRANSLATE_Y_NV = 0x908F, + GL_TRANSLATE_2D_NV = 0x9090, + GL_TRANSLATE_3D_NV = 0x9091, + GL_AFFINE_2D_NV = 0x9092, + GL_AFFINE_3D_NV = 0x9094, + GL_TRANSPOSE_AFFINE_2D_NV = 0x9096, + GL_TRANSPOSE_AFFINE_3D_NV = 0x9098; + + /** + * Accepted by the <type> or <pathNameType> parameter of CallLists, + * StencilFillPathInstancedNV, StencilStrokePathInstancedNV, + * CoverFillPathInstancedNV, CoverStrokePathInstancedNV, + * GetPathMetricsNV, and GetPathSpacingNV: + */ + int GL_UTF8_NV = 0x909A, + GL_UTF16_NV = 0x909B; + + /** Accepted by the <coverMode> parameter of CoverFillPathInstancedNV: */ + int GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV = 0x909C; + + /** + * Accepted by the <pname> parameter of GetPathParameterfvNV and + * GetPathParameterivNV: + */ + int GL_PATH_COMMAND_COUNT_NV = 0x909D, + GL_PATH_COORD_COUNT_NV = 0x909E, + GL_PATH_DASH_ARRAY_COUNT_NV = 0x909F, + GL_PATH_COMPUTED_LENGTH_NV = 0x90A0, + GL_PATH_FILL_BOUNDING_BOX_NV = 0x90A1, + GL_PATH_STROKE_BOUNDING_BOX_NV = 0x90A2; + + /** + * Accepted by the <value> parameter of PathParameterfNV, + * PathParameterfvNV, PathParameteriNV, and PathParameterivNV + * when <pname> is one of PATH_END_CAPS_NV, PATH_INTIAL_END_CAP_NV, + * PATH_TERMINAL_END_CAP_NV, PATH_DASH_CAPS_NV, PATH_INITIAL_DASH_CAP_NV, + * and PATH_TERMINAL_DASH_CAP_NV: + */ + int GL_SQUARE_NV = 0x90A3, + GL_ROUND_NV = 0x90A4, + GL_TRIANGULAR_NV = 0x90A5; + + /** + * Accepted by the <value> parameter of PathParameterfNV, + * PathParameterfvNV, PathParameteriNV, and PathParameterivNV + * when <pname> is PATH_JOIN_STYLE_NV: + */ + int GL_BEVEL_NV = 0x90A6, + GL_MITER_REVERT_NV = 0x90A7, + GL_MITER_TRUNCATE_NV = 0x90A8; + + /** + * Accepted by the <value> parameter of PathParameterfNV, + * PathParameterfvNV, PathParameteriNV, and PathParameterivNV when + * <pname> is PATH_DASH_OFFSET_RESET_NV + */ + int GL_MOVE_TO_RESETS_NV = 0x90B5, + GL_MOVE_TO_CONTINUES_NV = 0x90B6; + + /** Accepted by the <fontStyle> parameter of PathStringNV: */ + int GL_BOLD_BIT_NV = 0x01, + GL_ITALIC_BIT_NV = 0x02; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv, and GetDoublev: + */ + int GL_PATH_ERROR_POSITION_NV = 0x90AB, + + GL_PATH_FOG_GEN_MODE_NV = 0x90AC, + + GL_PATH_STENCIL_FUNC_NV = 0x90B7, + GL_PATH_STENCIL_REF_NV = 0x90B8, + GL_PATH_STENCIL_VALUE_MASK_NV = 0x90B9, + + GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV = 0x90BD, + GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV = 0x90BE, + + GL_PATH_COVER_DEPTH_FUNC_NV = 0x90BF; + + /** + * Accepted as a bit within the <metricQueryMask> parameter of + * GetPathMetricRangeNV or GetPathMetricsNV: + */ + + int GL_GLYPH_WIDTH_BIT_NV = 0x01, // per-glyph metrics + GL_GLYPH_HEIGHT_BIT_NV = 0x02, + GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV = 0x04, + GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV = 0x08, + GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV = 0x10, + GL_GLYPH_VERTICAL_BEARING_X_BIT_NV = 0x20, + GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV = 0x40, + GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV = 0x80, + GL_GLYPH_HAS_KERNING_NV = 0x100, + GL_FONT_X_MIN_BOUNDS_NV = 0x00010000, // per-font face metrics + GL_FONT_Y_MIN_BOUNDS_NV = 0x00020000, + GL_FONT_X_MAX_BOUNDS_NV = 0x00040000, + GL_FONT_Y_MAX_BOUNDS_NV = 0x00080000, + GL_FONT_UNITS_PER_EM_NV = 0x00100000, + GL_FONT_ASCENDER_NV = 0x00200000, + GL_FONT_DESCENDER_NV = 0x00400000, + GL_FONT_HEIGHT_NV = 0x00800000, + GL_FONT_MAX_ADVANCE_WIDTH_NV = 0x01000000, + GL_FONT_MAX_ADVANCE_HEIGHT_NV = 0x02000000, + GL_FONT_UNDERLINE_POSITION_NV = 0x04000000, + GL_FONT_UNDERLINE_THICKNESS_NV = 0x08000000, + GL_FONT_HAS_KERNING_NV = 0x10000000; + + /** Accepted by the <pathListMode> parameter of GetPathSpacingNV: */ + int GL_ACCUM_ADJACENT_PAIRS_NV = 0x90AD, + GL_ADJACENT_PAIRS_NV = 0x90AE, + GL_FIRST_TO_REST_NV = 0x90AF; + + /** + * Accepted by the <pname> parameter of GetPathColorGenivNV, + * GetPathColorGenfvNV, GetPathTexGenivNV and GetPathTexGenfvNV: + */ + int GL_PATH_GEN_MODE_NV = 0x90B0, + GL_PATH_GEN_COEFF_NV = 0x90B1, + GL_PATH_GEN_COLOR_FORMAT_NV = 0x90B2, + GL_PATH_GEN_COMPONENTS_NV = 0x90B3; + + void glPathCommandsNV(@GLuint int path, + @AutoSize("commands") @GLsizei int numCommands, @Const @GLubyte ByteBuffer commands, + @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType, + @Const @GLvoid ByteBuffer coords); + + void glPathCoordsNV(@GLuint int path, + @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType, + @Const @GLvoid ByteBuffer coords); + + void glPathSubCommandsNV(@GLuint int path, + @GLsizei int commandStart, @GLsizei int commandsToDelete, + @AutoSize("commands") @GLsizei int numCommands, @Const @GLubyte ByteBuffer commands, + @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType, + @Const @GLvoid ByteBuffer coords); + + void glPathSubCoordsNV(@GLuint int path, + @GLsizei int coordStart, + @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType, + @Const @GLvoid ByteBuffer coords); + + void glPathStringNV(@GLuint int path, @GLenum int format, + @AutoSize("pathString") @GLsizei int length, @Const @GLvoid ByteBuffer pathString); + + void glPathGlyphsNV(@GLuint int firstPathName, + @GLenum int fontTarget, + @NullTerminated @Const @GLvoid ByteBuffer fontName, + @GLbitfield int fontStyle, + @AutoSize(value = "charcodes", expression = " / GLChecks.calculateBytesPerCharCode(type)") @GLsizei int numGlyphs, @GLenum int type, + @Const @GLvoid ByteBuffer charcodes, + @GLenum int handleMissingGlyphs, + @GLuint int pathParameterTemplate, + float emScale); + + void glPathGlyphRangeNV(@GLuint int firstPathName, + @GLenum int fontTarget, + @NullTerminated @Const @GLvoid ByteBuffer fontName, + @GLbitfield int fontStyle, + @GLuint int firstGlyph, + @GLsizei int numGlyphs, + @GLenum int handleMissingGlyphs, + @GLuint int pathParameterTemplate, + float emScale); + + void glWeightPathsNV(@GLuint int resultPath, + @AutoSize("paths") @GLsizei int numPaths, + @Const @GLuint IntBuffer paths, @Check("paths.remaining()") @Const FloatBuffer weights); + + void glCopyPathNV(@GLuint int resultPath, @GLuint int srcPath); + + void glInterpolatePathsNV(@GLuint int resultPath, + @GLuint int pathA, @GLuint int pathB, + float weight); + + void glTransformPathNV(@GLuint int resultPath, + @GLuint int srcPath, + @GLenum int transformType, + @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues); + + @StripPostfix("value") + void glPathParameterivNV(@GLuint int path, @GLenum int pname, @Check("4") @Const IntBuffer value); + + void glPathParameteriNV(@GLuint int path, @GLenum int pname, int value); + + @StripPostfix("value") + void glPathParameterfvNV(@GLuint int path, @GLenum int pname, @Check("4") @Const IntBuffer value); + + void glPathParameterfNV(@GLuint int path, @GLenum int pname, float value); + + void glPathDashArrayNV(@GLuint int path, + @AutoSize("dashArray") @GLsizei int dashCount, @Const FloatBuffer dashArray); + + // PATH NAME MANAGEMENT + + @GLuint + int glGenPathsNV(@GLsizei int range); + + void glDeletePathsNV(@GLuint int path, @GLsizei int range); + + boolean glIsPathNV(@GLuint int path); + + // PATH STENCILING + + void glPathStencilFuncNV(@GLenum int func, int ref, @GLuint int mask); + + void glPathStencilDepthOffsetNV(float factor, int units); + + void glStencilFillPathNV(@GLuint int path, + @GLenum int fillMode, @GLuint int mask); + + void glStencilStrokePathNV(@GLuint int path, + int reference, @GLuint int mask); + + void glStencilFillPathInstancedNV(@AutoSize(value="paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths, + @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths, + @Constant("0") @GLuint int pathBase, + @GLenum int fillMode, @GLuint int mask, + @GLenum int transformType, + @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues); + + void glStencilStrokePathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths, + @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths, + @Constant("0") @GLuint int pathBase, + int reference, @GLuint int mask, + @GLenum int transformType, + @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues); + + // PATH COVERING + + void glPathCoverDepthFuncNV(@GLenum int zfunc); + + void glPathColorGenNV(@GLenum int color, + @GLenum int genMode, + @GLenum int colorFormat, @Check(value = "GLChecks.calculatePathColorGenCoeffsCount(genMode, colorFormat)", canBeNull = true) @Const FloatBuffer coeffs); + + void glPathTexGenNV(@GLenum int texCoordSet, + @GLenum int genMode, + @AutoSize(value="coeffs", expression="GLChecks.calculatePathTextGenCoeffsPerComponent(coeffs, genMode)", useExpression = true, canBeNull = true) int components, @Check(canBeNull = true) @Const FloatBuffer coeffs); + + void glPathFogGenNV(@GLenum int genMode); + + void glCoverFillPathNV(@GLuint int path, @GLenum int coverMode); + + void glCoverStrokePathNV(@GLuint int name, @GLenum int coverMode); + + void glCoverFillPathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths, + @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths, + @Constant("0") @GLuint int pathBase, + @GLenum int coverMode, + @GLenum int transformType, + @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues); + + void glCoverStrokePathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths, + @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths, + @Constant("0") @GLuint int pathBase, + @GLenum int coverMode, + @GLenum int transformType, + @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues); + + // PATH QUERIES + + @StripPostfix("value") + void glGetPathParameterivNV(@GLuint int name, @GLenum int param, @Check("4") @OutParameter IntBuffer value); + + @Alternate("glGetPathParameterivNV") + @GLreturn("value") + @StripPostfix(value = "value", postfix = "v") + void glGetPathParameterivNV2(@GLuint int name, @GLenum int param, @OutParameter IntBuffer value); + + void glGetPathParameterfvNV(@GLuint int name, @GLenum int param, @Check("4") @OutParameter FloatBuffer value); + + @Alternate("glGetPathParameterfvNV") + @GLreturn("value") + @StripPostfix(value = "value", postfix = "v") + void glGetPathParameterfvNV2(@GLuint int name, @GLenum int param, @OutParameter FloatBuffer value); + + void glGetPathCommandsNV(@GLuint int name, @Check @OutParameter @GLubyte ByteBuffer commands); + + void glGetPathCoordsNV(@GLuint int name, @Check @OutParameter FloatBuffer coords); + + void glGetPathDashArrayNV(@GLuint int name, @Check @OutParameter FloatBuffer dashArray); + + void glGetPathMetricsNV(@GLbitfield int metricQueryMask, + @AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths, + @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths, + @Constant("0") @GLuint int pathBase, + @GLsizei int stride, + @Check("GLChecks.calculateMetricsSize(metricQueryMask, stride)") @OutParameter FloatBuffer metrics); + + void glGetPathMetricRangeNV(@GLbitfield int metricQueryMask, + @GLuint int fistPathName, + @GLsizei int numPaths, + @GLsizei int stride, + @Check("GLChecks.calculateMetricsSize(metricQueryMask, stride)") @OutParameter FloatBuffer metrics); + + @Code("\t\tint numPaths = paths.remaining() / GLChecks.calculateBytesPerPathName(pathNameType);") + void glGetPathSpacingNV(@GLenum int pathListMode, + @AutoSize(value = "paths", expression = "numPaths", useExpression = true) @GLsizei int numPaths, + @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths, + @Constant("0") @GLuint int pathBase, + float advanceScale, + float kerningScale, + @GLenum int transformType, + @Check("numPaths - 1") @OutParameter FloatBuffer returnedSpacing); + + @StripPostfix("value") + void glGetPathColorGenivNV(@GLenum int color, @GLenum int pname, @Check("16") @OutParameter IntBuffer value); + + @Alternate("glGetPathColorGenivNV") + @GLreturn("value") + @StripPostfix(value = "value", postfix = "v") + void glGetPathColorGenivNV2(@GLenum int color, @GLenum int pname, @OutParameter IntBuffer value); + + @StripPostfix("value") + void glGetPathColorGenfvNV(@GLenum int color, @GLenum int pname, @Check("16") @OutParameter FloatBuffer value); + + @Alternate("glGetPathColorGenfvNV") + @GLreturn("value") + @StripPostfix(value = "value", postfix = "v") + void glGetPathColorGenfvNV2(@GLenum int color, @GLenum int pname, @OutParameter FloatBuffer value); + + @StripPostfix("value") + void glGetPathTexGenivNV(@GLenum int texCoordSet, @GLenum int pname, @Check("16") @OutParameter IntBuffer value); + + @Alternate("glGetPathTexGenivNV") + @GLreturn("value") + @StripPostfix(value = "value", postfix = "v") + void glGetPathTexGenivNV2(@GLenum int texCoordSet, @GLenum int pname, @OutParameter IntBuffer value); + + @StripPostfix("value") + void glGetPathTexGenfvNV(@GLenum int texCoordSet, @GLenum int pname, @Check("16") @OutParameter FloatBuffer value); + + @Alternate("glGetPathTexGenfvNV") + @GLreturn("value") + @StripPostfix(value = "value", postfix = "v") + void glGetPathTexGenfvNV2(@GLenum int texCoordSet, @GLenum int pname, @OutParameter FloatBuffer value); + + boolean glIsPointInFillPathNV(@GLuint int path, + @GLuint int mask, float x, float y); + + boolean glIsPointInStrokePathNV(@GLuint int path, + float x, float y); + + float glGetPathLengthNV(@GLuint int path, + @GLsizei int startSegment, @GLsizei int numSegments); + + boolean glPointAlongPathNV(@GLuint int path, + @GLsizei int startSegment, @GLsizei int numSegments, + float distance, + @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer x, + @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer y, + @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer tangentX, + @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer tangentY); + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-24 09:38:53
|
Revision: 3601 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3601&view=rev Author: spasi Date: 2011-07-24 09:38:46 +0000 (Sun, 24 Jul 2011) Log Message: ----------- @MappedType is now optional. copyTo now only copies (SIZEOF - padding) bytes. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -32,10 +32,8 @@ package org.lwjgl.test.mapped; import org.lwjgl.util.mapped.MappedObject; -import org.lwjgl.util.mapped.MappedType; /** @author Riven */ -@MappedType public class MappedFloat extends MappedObject { public MappedFloat() { Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -35,7 +35,6 @@ import org.lwjgl.util.mapped.MappedObject; import org.lwjgl.util.mapped.MappedSet; import org.lwjgl.util.mapped.MappedSet2; -import org.lwjgl.util.mapped.MappedType; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -82,7 +81,6 @@ System.out.println("current.view=" + some.view + ", not " + elementCount + ", as you might expect"); } - @MappedType public static class Xyz extends MappedObject { int x, y, z; Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -35,7 +35,6 @@ import org.lwjgl.PointerBuffer; import org.lwjgl.opengl.Display; import org.lwjgl.util.mapped.MappedObject; -import org.lwjgl.util.mapped.MappedType; import org.lwjgl.util.mapped.Pointer; import java.io.File; @@ -116,7 +115,6 @@ } } - @MappedType public static class MappedPointer extends MappedObject { int foo; Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -33,12 +33,10 @@ import org.lwjgl.util.mapped.MappedField; import org.lwjgl.util.mapped.MappedObject; -import org.lwjgl.util.mapped.MappedType; import java.nio.ByteBuffer; /** @author Riven */ -@MappedType public class MappedSomething extends MappedObject { @MappedField(byteOffset = 0) Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -32,10 +32,8 @@ package org.lwjgl.test.mapped; import org.lwjgl.util.mapped.MappedObject; -import org.lwjgl.util.mapped.MappedType; /** @author Riven */ -@MappedType public class MappedVec2 extends MappedObject { public float x; Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -32,10 +32,8 @@ package org.lwjgl.test.mapped; import org.lwjgl.util.mapped.MappedObject; -import org.lwjgl.util.mapped.MappedType; /** @author Riven */ -@MappedType public class MappedVec3 extends MappedObject { public float x; Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -204,7 +204,6 @@ return texID; } - @MappedType public static class Pixel4b extends MappedObject { public byte r, g, b, a; @@ -413,7 +412,6 @@ Display.destroy(); } - @MappedType public static class Sprite extends MappedObject { public float x, dx; @@ -421,7 +419,6 @@ } - @MappedType public static class SpriteRender extends MappedObject { public float x, y; Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -37,7 +37,7 @@ import java.lang.annotation.Target; /** - * This annotation can be used on fields of {@link MappedType} classes, + * This annotation can be used on fields of {@link MappedObject} subclasses, * to manually specify byte offsets and lengths. This is useful when the * mapped fields require custom alignment. {@link java.nio.ByteBuffer} * fields are required to have this annotation with a hardcoded byte length. Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -39,8 +39,8 @@ /** * Base superclass of all mapped objects. Classes that require - * data mapping should extend this class and also be annotated - * with {@link MappedType}. + * data mapping should extend this class and registered with + * {@link MappedObjectTransformer#register(Class)}. * <p/> * Subclasses may only specify the default constructor. Any code * inside that constructor is optional, but will not run when the @@ -215,7 +215,7 @@ } /** - * Copies and amount of <code>SIZEOF</code> bytes, from the current + * Copies and amount of <code>SIZEOF - padding</code> bytes, from the current * mapped object, to the specified mapped object. */ @SuppressWarnings("unused") @@ -225,8 +225,9 @@ } /** - * Copies and amount of <code>SIZEOF*instances<c/ode> bytes, from the - * current mapped object, to the specified mapped object. + * Copies and amount of <code>SIZEOF * instances</code> bytes, from the + * current mapped object, to the specified mapped object. Note that + * this includes any padding bytes that are part of SIZEOF. */ @SuppressWarnings("unused") public final <T extends MappedObject> void copyRange(T target, int instances) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -113,7 +113,7 @@ // => IADD // => PUTFIELD MyMappedType.view // - className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1)); + className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1, -1)); } final String vmName = System.getProperty("java.vm.name"); @@ -128,15 +128,13 @@ * * @param type the mapped object class. */ - public static void register(Class<?> type) { + public static void register(Class<? extends MappedObject> type) { if ( MappedObjectClassLoader.FORKED ) return; final MappedType mapped = type.getAnnotation(MappedType.class); - if ( mapped == null ) - throw new ClassFormatError("missing " + MappedType.class.getName() + " annotation"); - if ( mapped.padding() < 0 ) + if ( mapped != null && mapped.padding() < 0 ) throw new ClassFormatError("Invalid mapped type padding: " + mapped.padding()); if ( type.getEnclosingClass() != null && !Modifier.isStatic(type.getModifiers()) ) @@ -148,7 +146,7 @@ int advancingOffset = 0; long sizeof = 0; for ( Field field : type.getDeclaredFields() ) { - FieldInfo fieldInfo = registerField(mapped, className, advancingOffset, field); + FieldInfo fieldInfo = registerField(mapped == null || mapped.autoGenerateOffsets(), className, advancingOffset, field); if ( fieldInfo == null ) continue; @@ -158,14 +156,17 @@ sizeof = Math.max(sizeof, fieldInfo.offset + fieldInfo.length); } - sizeof += mapped.padding(); + final int align = mapped == null ? 4 : mapped.align(); + final int padding = mapped == null ? 0 : mapped.padding(); - final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, mapped.align()); + sizeof += padding; + + final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, align, padding); if ( className_to_subtype.put(className, mappedType) != null ) throw new InternalError("duplicate mapped type: " + mappedType.className); } - private static FieldInfo registerField(final MappedType mapped, final String className, int advancingOffset, final Field field) { + private static FieldInfo registerField(final boolean autoGenerateOffsets, final String className, int advancingOffset, final Field field) { if ( Modifier.isStatic(field.getModifiers()) ) // static fields are never mapped return null; @@ -174,7 +175,7 @@ throw new ClassFormatError("field '" + className + "." + field.getName() + "' not supported: " + field.getType()); MappedField meta = field.getAnnotation(MappedField.class); - if ( meta == null && !mapped.autoGenerateOffsets() ) + if ( meta == null && !autoGenerateOffsets ) throw new ClassFormatError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className); Pointer pointer = field.getAnnotation(Pointer.class); @@ -688,7 +689,7 @@ final InsnList list = new InsnList(); // stack: target, this - list.add(getIntNode(mappedType.sizeof)); + list.add(getIntNode(mappedType.sizeof - mappedType.padding)); // stack: sizeof, target, this list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "copy", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";I)V")); // stack: - @@ -1073,10 +1074,11 @@ final int sizeof; final int sizeof_shift; final int align; + final int padding; final Map<String, FieldInfo> fields; - MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align) { + MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align, int padding) { this.className = className; this.sizeof = sizeof; @@ -1085,6 +1087,7 @@ else this.sizeof_shift = 0; this.align = align; + this.padding = padding; this.fields = fields; } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java 2011-07-23 22:28:57 UTC (rev 3600) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java 2011-07-24 09:38:46 UTC (rev 3601) @@ -37,7 +37,7 @@ import java.lang.annotation.Target; /** - * This annotation can be used on long fields of {@link MappedType} classes, + * This annotation can be used on long fields of {@link MappedObject} subclasses, * to specify that the long value should be interpreted as a pointer. This * will determine the actual byte size of the field at runtime (4 or 8 bytes). * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-23 22:29:03
|
Revision: 3600 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3600&view=rev Author: spasi Date: 2011-07-23 22:28:57 +0000 (Sat, 23 Jul 2011) Log Message: ----------- Added support for volatile keyword. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-23 22:02:01 UTC (rev 3599) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-23 22:28:57 UTC (rev 3600) @@ -149,6 +149,22 @@ return MappedObjectUnsafe.INSTANCE.getByte(mapped.viewAddress + fieldOffset); } + public static void bvput(byte value, long addr) { + MappedObjectUnsafe.INSTANCE.putByteVolatile(null, addr, value); + } + + public static void bvput(MappedObject mapped, byte value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value); + } + + public static byte bvget(long addr) { + return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, addr); + } + + public static byte bvget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset); + } + // short public static void sput(short value, long addr) { @@ -167,6 +183,22 @@ return MappedObjectUnsafe.INSTANCE.getShort(mapped.viewAddress + fieldOffset); } + public static void svput(short value, long addr) { + MappedObjectUnsafe.INSTANCE.putShortVolatile(null, addr, value); + } + + public static void svput(MappedObject mapped, short value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value); + } + + public static short svget(long addr) { + return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, addr); + } + + public static short svget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset); + } + // char public static void cput(char value, long addr) { @@ -185,6 +217,22 @@ return MappedObjectUnsafe.INSTANCE.getChar(mapped.viewAddress + fieldOffset); } + public static void cvput(char value, long addr) { + MappedObjectUnsafe.INSTANCE.putCharVolatile(null, addr, value); + } + + public static void cvput(MappedObject mapped, char value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value); + } + + public static char cvget(long addr) { + return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, addr); + } + + public static char cvget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset); + } + // int public static void iput(int value, long addr) { @@ -203,6 +251,22 @@ return MappedObjectUnsafe.INSTANCE.getInt(mapped.viewAddress + fieldOffset); } + public static void ivput(int value, long addr) { + MappedObjectUnsafe.INSTANCE.putIntVolatile(null, addr, value); + } + + public static void ivput(MappedObject mapped, int value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value); + } + + public static int ivget(long address) { + return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, address); + } + + public static int ivget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset); + } + // float public static void fput(float value, long addr) { @@ -221,6 +285,22 @@ return MappedObjectUnsafe.INSTANCE.getFloat(mapped.viewAddress + fieldOffset); } + public static void fvput(float value, long addr) { + MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, addr, value); + } + + public static void fvput(MappedObject mapped, float value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value); + } + + public static float fvget(long addr) { + return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, addr); + } + + public static float fvget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset); + } + // long public static void jput(long value, long addr) { @@ -239,6 +319,22 @@ return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset); } + public static void jvput(long value, long addr) { + MappedObjectUnsafe.INSTANCE.putLongVolatile(null, addr, value); + } + + public static void jvput(MappedObject mapped, long value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value); + } + + public static long jvget(long addr) { + return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, addr); + } + + public static long lvget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset); + } + // address public static void aput(long value, long addr) { @@ -275,4 +371,20 @@ return MappedObjectUnsafe.INSTANCE.getDouble(mapped.viewAddress + fieldOffset); } + public static void dvput(double value, long addr) { + MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, addr, value); + } + + public static void dvput(MappedObject mapped, double value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value); + } + + public static double dvget(long addr) { + return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, addr); + } + + public static double dvget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset); + } + } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-23 22:02:01 UTC (rev 3599) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-23 22:28:57 UTC (rev 3600) @@ -179,7 +179,11 @@ Pointer pointer = field.getAnnotation(Pointer.class); if ( pointer != null && field.getType() != long.class ) - throw new ClassFormatError("The @Pointer annotation can only be used on long fields. Field found: " + className + "." + field.getName() + ": " + field.getType()); + throw new ClassFormatError("The @Pointer annotation can only be used on long fields. @Pointer field found: " + className + "." + field.getName() + ": " + field.getType()); + + if ( Modifier.isVolatile(field.getModifiers()) && (pointer != null || field.getType() == ByteBuffer.class) ) + throw new ClassFormatError("The volatile keyword is not supported for @Pointer or ByteBuffer fields. Volatile field found: " + className + "." + field.getName() + ": " + field.getType()); + // quick hack long byteOffset = meta == null ? advancingOffset : meta.byteOffset(); long byteLength; @@ -209,7 +213,7 @@ if ( PRINT_ACTIVITY ) LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]"); - return new FieldInfo(byteOffset, byteLength, Type.getType(field.getType()), pointer != null); + return new FieldInfo(byteOffset, byteLength, Type.getType(field.getType()), Modifier.isVolatile(field.getModifiers()), pointer != null); } /** Removes final from methods that will be overriden by subclasses. */ @@ -395,7 +399,7 @@ visitIntNode(mv, (int)field.offset); mv.visitInsn(I2L); mv.visitInsn(LADD); - mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.isPointer ? "a" : field.type.getDescriptor().toLowerCase() + "get", "(J)" + field.type.getDescriptor()); + mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "get", "(J)" + field.type.getDescriptor()); mv.visitInsn(field.type.getOpcode(IRETURN)); mv.visitMaxs(3, 2); mv.visitEnd(); @@ -430,7 +434,7 @@ visitIntNode(mv, (int)field.offset); mv.visitInsn(I2L); mv.visitInsn(LADD); - mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.isPointer ? "a" : field.type.getDescriptor().toLowerCase() + "put", "(" + field.type.getDescriptor() + "J)V"); + mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "put", "(" + field.type.getDescriptor() + "J)V"); mv.visitInsn(RETURN); mv.visitMaxs(4, 4); mv.visitEnd(); @@ -933,13 +937,11 @@ private static InsnList generateFieldInstructions(final FieldInsnNode fieldInsn, final FieldInfo field) { final InsnList list = new InsnList(); - final String dataType = field.isPointer ? "a" : fieldInsn.desc.toLowerCase(); - if ( fieldInsn.getOpcode() == PUTFIELD ) { // stack: value, ref list.add(getIntNode((int)field.offset)); // stack: fieldOffset, value, ref - list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, dataType + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V")); + list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V")); // stack - return list; } @@ -948,7 +950,7 @@ // stack: ref list.add(getIntNode((int)field.offset)); // stack: fieldOffset, ref - list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, dataType + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc)); + list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc)); // stack: - return list; } @@ -1047,15 +1049,21 @@ final long offset; final long length; final Type type; + final boolean isVolatile; final boolean isPointer; - FieldInfo(final long offset, final long length, final Type type, final boolean isPointer) { + FieldInfo(final long offset, final long length, final Type type, final boolean isVolatile, final boolean isPointer) { this.offset = offset; this.length = length; this.type = type; + this.isVolatile = isVolatile; this.isPointer = isPointer; } + String getAccessType() { + return isPointer ? "a" : type.getDescriptor().toLowerCase() + (isVolatile ? "v" : ""); + } + } private static class MappedSubtypeInfo { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-23 22:02:08
|
Revision: 3599 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3599&view=rev Author: spasi Date: 2011-07-23 22:02:01 +0000 (Sat, 23 Jul 2011) Log Message: ----------- Removed sizeof from @MappedType, it's calculated automatically now. Added padding to @MappedType, defaults to 0. Added support for @Pointer long fields for easier interaction with pointer data. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java Modified: trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -462,7 +462,7 @@ * * @param msg Message to print */ - public static void log(String msg) { + public static void log(CharSequence msg) { if (DEBUG) { System.err.println("[LWJGL] " + msg); } Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -35,7 +35,7 @@ import org.lwjgl.util.mapped.MappedType; /** @author Riven */ -@MappedType(sizeof = 4) +@MappedType public class MappedFloat extends MappedObject { public MappedFloat() { Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -82,7 +82,7 @@ System.out.println("current.view=" + some.view + ", not " + elementCount + ", as you might expect"); } - @MappedType(sizeof = 12) + @MappedType public static class Xyz extends MappedObject { int x, y, z; Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -32,7 +32,11 @@ package org.lwjgl.test.mapped; import org.lwjgl.MemoryUtil; +import org.lwjgl.PointerBuffer; import org.lwjgl.opengl.Display; +import org.lwjgl.util.mapped.MappedObject; +import org.lwjgl.util.mapped.MappedType; +import org.lwjgl.util.mapped.Pointer; import java.io.File; import java.nio.ByteBuffer; @@ -112,4 +116,35 @@ } } + @MappedType + public static class MappedPointer extends MappedObject { + + int foo; + @Pointer long pointer; + int bar; + + } + + public static void testPointer() { + MappedPointer data = MappedPointer.malloc(100); + + assert (data.backingByteBuffer().capacity() == 100 * (4 + 4 + PointerBuffer.getPointerSize())); + + for ( int i = 0; i < 100; i++ ) { + data.view = i; + + data.foo = i; + data.pointer = i * 1000; + data.bar = i * 2; + } + + for ( int i = 0; i < 100; i++ ) { + data.view = i; + + assert (data.foo == i); + assert (data.pointer == i * 1000); + assert (data.bar == i * 2); + } + } + } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -38,7 +38,7 @@ import java.nio.ByteBuffer; /** @author Riven */ -@MappedType(sizeof = 64) +@MappedType public class MappedSomething extends MappedObject { @MappedField(byteOffset = 0) Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -35,7 +35,7 @@ import org.lwjgl.util.mapped.MappedType; /** @author Riven */ -@MappedType(sizeof = 8) +@MappedType public class MappedVec2 extends MappedObject { public float x; Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -35,7 +35,7 @@ import org.lwjgl.util.mapped.MappedType; /** @author Riven */ -@MappedType(sizeof = 12) +@MappedType public class MappedVec3 extends MappedObject { public float x; Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -51,6 +51,7 @@ MappedObjectTransformer.register(MappedVec3.class); MappedObjectTransformer.register(MappedSomething.class); MappedObjectTransformer.register(MappedObjectTests3.Xyz.class); + MappedObjectTransformer.register(MappedObjectTests4.MappedPointer.class); if ( MappedObjectClassLoader.fork(TestMappedObject.class, args) ) { return; @@ -72,10 +73,9 @@ MappedObjectTests3.testMappedSet(); MappedObjectTests4.testLocalView(); - //MappedObjectTests4.testLWJGL(); + MappedObjectTests4.testPointer(); - System.out.println("done"); } Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -204,14 +204,14 @@ return texID; } - @MappedType(sizeof = 4) + @MappedType public static class Pixel4b extends MappedObject { public byte r, g, b, a; } - @MappedType(sizeof = 3, align = 3) + @MappedType(align = 3) public static class Pixel3b extends MappedObject { public byte r, g, b; @@ -413,15 +413,15 @@ Display.destroy(); } - @MappedType(sizeof = 4 * 4) + @MappedType public static class Sprite extends MappedObject { - public float x, y; - public float dx, dy; + public float x, dx; + public float y, dy; } - @MappedType(sizeof = 2 * 4) + @MappedType public static class SpriteRender extends MappedObject { public float x, y; @@ -536,12 +536,15 @@ x += dx * delta; if ( x < ballRadius ) { x = ballRadius; - sprites[b].dx = -dx; + dx = -dx; } else if ( x > boundW ) { x = boundW; - sprites[b].dx = -dx; + dx = -dx; } + sprites[b].x = x; + sprites[b].dx = dx; + spritesRender[r].x = x; float y = sprites[b].y; float dy = sprites[b].dy; @@ -549,14 +552,14 @@ y += dy * delta; if ( y < ballRadius ) { y = ballRadius; - sprites[b].dy = -dy; + dy = -dy; } else if ( y > boundH ) { y = boundH; - sprites[b].dy = -dy; + dy = -dy; } + sprites[b].y = y; - - spritesRender[r].x = x; + sprites[b].dy = dy; spritesRender[r].y = y; } } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -239,6 +239,24 @@ return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset); } + // address + + public static void aput(long value, long addr) { + MappedObjectUnsafe.INSTANCE.putAddress(addr, value); + } + + public static void aput(MappedObject mapped, long value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value); + } + + public static long aget(long addr) { + return MappedObjectUnsafe.INSTANCE.getAddress(addr); + } + + public static long aget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getAddress(mapped.viewAddress + fieldOffset); + } + // double public static void dput(double value, long addr) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -96,9 +96,6 @@ final String name = MappedObject.class.getName(); String className = name.replace('.', '/'); - if ( MappedObjectTransformer.PRINT_ACTIVITY ) - LWJGLUtil.log(MappedObjectClassLoader.class.getSimpleName() + ": " + className); - byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class"))); long t0 = System.nanoTime(); @@ -106,8 +103,8 @@ long t1 = System.nanoTime(); total_time_transforming += (t1 - t0); - if ( MappedObjectTransformer.PRINT_TIMING ) - LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)"); + if ( MappedObjectTransformer.PRINT_ACTIVITY ) + printActivity(className, t0, t1); Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length); resolveClass(clazz); @@ -128,25 +125,29 @@ if ( name.startsWith("sunw.") ) return super.loadClass(name, resolve); - if ( name.equals(MappedObjectClassLoader.class.getName()) ) + if ( name.startsWith("org.objectweb.asm.") ) return super.loadClass(name, resolve); + if ( name.equals(MappedObjectClassLoader.class.getName()) || name.equals((MappedObjectTransformer.class.getName())) ) + return super.loadClass(name, resolve); + String className = name.replace('.', '/'); - if ( MappedObjectTransformer.PRINT_ACTIVITY ) - LWJGLUtil.log(MappedObjectClassLoader.class.getSimpleName() + ": " + className); - byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class"))); // Classes in this package do not get transformed, but need to go through here because we have transformed MappedObject. if ( !(name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX) && name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1) ) { long t0 = System.nanoTime(); - bytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode); + final byte[] newBytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode); long t1 = System.nanoTime(); total_time_transforming += (t1 - t0); - if ( MappedObjectTransformer.PRINT_TIMING ) - LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)"); + + if ( bytecode != newBytecode ) { + bytecode = newBytecode; + if ( MappedObjectTransformer.PRINT_ACTIVITY ) + printActivity(className, t0, t1); + } } Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length); @@ -155,6 +156,15 @@ return clazz; } + private static void printActivity(final String className, final long t0, final long t1) { + final StringBuilder msg = new StringBuilder(MappedObjectClassLoader.class.getSimpleName() + ": " + className); + + if ( MappedObjectTransformer.PRINT_TIMING ) + msg.append("\n\ttransforming took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)"); + + LWJGLUtil.log(msg); + } + private static byte[] readStream(InputStream in) { byte[] bytecode = new byte[256]; int len = 0; Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -63,8 +63,8 @@ */ public class MappedObjectTransformer { - static final boolean PRINT_TIMING = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintTiming"); static final boolean PRINT_ACTIVITY = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintActivity"); + static final boolean PRINT_TIMING = PRINT_ACTIVITY && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintTiming"); static final boolean PRINT_BYTECODE = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode"); static final Map<String, MappedSubtypeInfo> className_to_subtype; @@ -113,7 +113,7 @@ // => IADD // => PUTFIELD MyMappedType.view // - className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, -1, -1)); + className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1)); } final String vmName = System.getProperty("java.vm.name"); @@ -129,39 +129,66 @@ * @param type the mapped object class. */ public static void register(Class<?> type) { + if ( MappedObjectClassLoader.FORKED ) + return; + final MappedType mapped = type.getAnnotation(MappedType.class); if ( mapped == null ) - throw new InternalError("missing " + MappedType.class.getName() + " annotation"); + throw new ClassFormatError("missing " + MappedType.class.getName() + " annotation"); + if ( mapped.padding() < 0 ) + throw new ClassFormatError("Invalid mapped type padding: " + mapped.padding()); + if ( type.getEnclosingClass() != null && !Modifier.isStatic(type.getModifiers()) ) throw new InternalError("only top-level or static inner classes are allowed"); - final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(jvmClassName(type), mapped.sizeof(), mapped.align()); + final String className = jvmClassName(type); + final Map<String, FieldInfo> fields = new HashMap<String, FieldInfo>(); int advancingOffset = 0; - for ( Field field : type.getDeclaredFields() ) - advancingOffset += registerField(mapped, mappedType.className, mappedType, advancingOffset, field); + long sizeof = 0; + for ( Field field : type.getDeclaredFields() ) { + FieldInfo fieldInfo = registerField(mapped, className, advancingOffset, field); + if ( fieldInfo == null ) + continue; - if ( className_to_subtype.put(mappedType.className, mappedType) != null ) + fields.put(field.getName(), fieldInfo); + + advancingOffset += fieldInfo.length; + sizeof = Math.max(sizeof, fieldInfo.offset + fieldInfo.length); + } + + sizeof += mapped.padding(); + + final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, mapped.align()); + if ( className_to_subtype.put(className, mappedType) != null ) throw new InternalError("duplicate mapped type: " + mappedType.className); } - private static int registerField(final MappedType mapped, final String className, final MappedSubtypeInfo mappedType, int advancingOffset, final Field field) { + private static FieldInfo registerField(final MappedType mapped, final String className, int advancingOffset, final Field field) { if ( Modifier.isStatic(field.getModifiers()) ) // static fields are never mapped - return 0; + return null; // we only support primitives and ByteBuffers if ( !field.getType().isPrimitive() && field.getType() != ByteBuffer.class ) - throw new InternalError("field '" + className + "." + field.getName() + "' not supported: " + field.getType()); + throw new ClassFormatError("field '" + className + "." + field.getName() + "' not supported: " + field.getType()); MappedField meta = field.getAnnotation(MappedField.class); if ( meta == null && !mapped.autoGenerateOffsets() ) - throw new InternalError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className); + throw new ClassFormatError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className); + Pointer pointer = field.getAnnotation(Pointer.class); + if ( pointer != null && field.getType() != long.class ) + throw new ClassFormatError("The @Pointer annotation can only be used on long fields. Field found: " + className + "." + field.getName() + ": " + field.getType()); // quick hack long byteOffset = meta == null ? advancingOffset : meta.byteOffset(); long byteLength; - if ( field.getType() == long.class || field.getType() == double.class ) + if ( field.getType() == long.class || field.getType() == double.class ) { + if ( pointer == null ) + byteLength = 8; + else + byteLength = MappedObjectUnsafe.INSTANCE.addressSize(); + } else if ( field.getType() == double.class ) byteLength = 8; else if ( field.getType() == int.class || field.getType() == float.class ) byteLength = 4; @@ -174,7 +201,7 @@ if ( byteLength < 0 ) throw new IllegalStateException("invalid byte length for mapped ByteBuffer field: " + className + "." + field.getName() + " [length=" + byteLength + "]"); } else - throw new InternalError(field.getType().getName()); + throw new ClassFormatError(field.getType().getName()); if ( field.getType() != ByteBuffer.class && (advancingOffset % byteLength) != 0 ) throw new IllegalStateException("misaligned mapped type: " + className + "." + field.getName()); @@ -182,11 +209,7 @@ if ( PRINT_ACTIVITY ) LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]"); - mappedType.fieldToOffset.put(field.getName(), byteOffset); - mappedType.fieldToLength.put(field.getName(), byteLength); - mappedType.fieldToType.put(field.getName(), Type.getType(field.getType())); - - return (int)byteLength; + return new FieldInfo(byteOffset, byteLength, Type.getType(field.getType()), pointer != null); } /** Removes final from methods that will be overriden by subclasses. */ @@ -231,13 +254,18 @@ }; - ClassVisitor cv = getTransformationAdapter(className, cw); + final TransformationAdapter ta = new TransformationAdapter(cw, className); + + ClassVisitor cv = ta; if ( className_to_subtype.containsKey(className) ) // Do a first pass to generate address getters cv = getMethodGenAdapter(className, cv); new ClassReader(bytecode).accept(cv, ClassReader.SKIP_FRAMES); + + if ( !ta.transformed ) + return bytecode; + bytecode = cw.toByteArray(); - if ( PRINT_BYTECODE ) printBytecode(bytecode); @@ -257,14 +285,14 @@ generateSizeofGetter(); generateNext(); - for ( String fieldName : mappedSubtype.fieldToOffset.keySet() ) { - final Type type = mappedSubtype.fieldToType.get(fieldName); + for ( String fieldName : mappedSubtype.fields.keySet() ) { + final FieldInfo field = mappedSubtype.fields.get(fieldName); - if ( type.getDescriptor().length() > 1 ) { // ByteBuffer, getter only - generateByteBufferGetter(mappedSubtype, fieldName, type); + if ( field.type.getDescriptor().length() > 1 ) { // ByteBuffer, getter only + generateByteBufferGetter(fieldName, field); } else { - generateFieldGetter(mappedSubtype, fieldName, type); - generateFieldSetter(mappedSubtype, fieldName, type); + generateFieldGetter(fieldName, field); + generateFieldSetter(fieldName, field); } } @@ -342,42 +370,42 @@ mv.visitEnd(); } - private void generateByteBufferGetter(final MappedSubtypeInfo mappedSubtype, final String fieldName, final Type type) { - MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + type.getDescriptor(), null, null); + private void generateByteBufferGetter(final String fieldName, final FieldInfo field) { + MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + field.type.getDescriptor(), null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J"); - visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue()); + visitIntNode(mv, (int)field.offset); mv.visitInsn(I2L); mv.visitInsn(LADD); - visitIntNode(mv, mappedSubtype.fieldToLength.get(fieldName).intValue()); + visitIntNode(mv, (int)field.length); mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";"); mv.visitInsn(ARETURN); - mv.visitMaxs(4, 2); + mv.visitMaxs(3, 2); mv.visitEnd(); } - private void generateFieldGetter(final MappedSubtypeInfo mappedSubtype, final String fieldName, final Type type) { - MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + type.getDescriptor(), null, null); + private void generateFieldGetter(final String fieldName, final FieldInfo field) { + MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + field.type.getDescriptor(), null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J"); - visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue()); + visitIntNode(mv, (int)field.offset); mv.visitInsn(I2L); mv.visitInsn(LADD); - mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, type.getDescriptor().toLowerCase() + "get", "(J)" + type.getDescriptor()); - mv.visitInsn(type.getOpcode(IRETURN)); + mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.isPointer ? "a" : field.type.getDescriptor().toLowerCase() + "get", "(J)" + field.type.getDescriptor()); + mv.visitInsn(field.type.getOpcode(IRETURN)); mv.visitMaxs(3, 2); mv.visitEnd(); } - private void generateFieldSetter(final MappedSubtypeInfo mappedSubtype, final String fieldName, final Type type) { - MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, setterName(fieldName), "(L" + className + ";I" + type.getDescriptor() + ")V", null, null); + private void generateFieldSetter(final String fieldName, final FieldInfo field) { + MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, setterName(fieldName), "(L" + className + ";I" + field.type.getDescriptor() + ")V", null, null); mv.visitCode(); int load = 0; - switch ( type.getSort() ) { + switch ( field.type.getSort() ) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: @@ -399,156 +427,164 @@ mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J"); - visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue()); + visitIntNode(mv, (int)field.offset); mv.visitInsn(I2L); mv.visitInsn(LADD); - mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, type.getDescriptor().toLowerCase() + "put", "(" + type.getDescriptor() + "J)V"); + mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.isPointer ? "a" : field.type.getDescriptor().toLowerCase() + "put", "(" + field.type.getDescriptor() + "J)V"); mv.visitInsn(RETURN); - mv.visitMaxs(4, 3); + mv.visitMaxs(4, 4); mv.visitEnd(); } }; } - private static ClassAdapter getTransformationAdapter(final String className, final ClassWriter cw) { - return new ClassAdapter(cw) { + private static class TransformationAdapter extends ClassAdapter { - @Override - public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) { - // remove redirected fields - final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); - if ( mappedSubtype != null && mappedSubtype.fieldToOffset.containsKey(name) ) { - if ( PRINT_ACTIVITY ) - LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": discarding field: " + className + "." + name + ":" + desc); - return null; - } + final String className; - return super.visitField(access, name, desc, signature, value); + boolean transformed; + + TransformationAdapter(final ClassVisitor cv, final String className) { + super(cv); + this.className = className; + } + + @Override + public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) { + // remove redirected fields + final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); + if ( mappedSubtype != null && mappedSubtype.fields.containsKey(name) ) { + if ( PRINT_ACTIVITY ) + LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": discarding field: " + className + "." + name + ":" + desc); + return null; } - @Override - public MethodVisitor visitMethod(final int access, String name, final String desc, final String signature, final String[] exceptions) { - // Move MappedSubtype constructors to another method - if ( "<init>".equals(name) ) { - final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); - if ( mappedSubtype != null ) { - if ( !"()V".equals(desc) ) - throw new ClassFormatError(className + " can only have a default constructor, found: " + desc); + return super.visitField(access, name, desc, signature, value); + } - final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESPECIAL, MAPPED_OBJECT_JVM, "<init>", "()V"); - mv.visitInsn(RETURN); - mv.visitMaxs(0, 0); + @Override + public MethodVisitor visitMethod(final int access, String name, final String desc, final String signature, final String[] exceptions) { + // Move MappedSubtype constructors to another method + if ( "<init>".equals(name) ) { + final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); + if ( mappedSubtype != null ) { + if ( !"()V".equals(desc) ) + throw new ClassFormatError(className + " can only have a default constructor, found: " + desc); - // put the method body in another method - name = VIEW_CONSTRUCTOR_NAME; - } + final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, MAPPED_OBJECT_JVM, "<init>", "()V"); + mv.visitInsn(RETURN); + mv.visitMaxs(0, 0); + + // put the method body in another method + name = VIEW_CONSTRUCTOR_NAME; } + } - final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); - return new MethodNode(access, name, desc, signature, exceptions) { + final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); + return new MethodNode(access, name, desc, signature, exceptions) { - /** When true, the method has touched a mapped object and needs to be transformed. We track this - * so we can skip the expensive frame analysis and tree API usage. */ - boolean needsTransformation; + /** When true, the method has touched a mapped object and needs to be transformed. We track this + * so we can skip the expensive frame analysis and tree API usage. */ + boolean needsTransformation; - @Override - public void visitMaxs(int a, int b) { - try { - is_currently_computing_frames = true; - super.visitMaxs(a, b); - } finally { - is_currently_computing_frames = false; - } + @Override + public void visitMaxs(int a, int b) { + try { + is_currently_computing_frames = true; + super.visitMaxs(a, b); + } finally { + is_currently_computing_frames = false; } + } - @Override - public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) { - if ( className_to_subtype.containsKey(owner) || owner.startsWith(MAPPEDSET_PREFIX) ) - needsTransformation = true; + @Override + public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) { + if ( className_to_subtype.containsKey(owner) || owner.startsWith(MAPPEDSET_PREFIX) ) + needsTransformation = true; - super.visitFieldInsn(opcode, owner, name, desc); - } + super.visitFieldInsn(opcode, owner, name, desc); + } - @Override - public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { - if ( className_to_subtype.containsKey(owner) ) - needsTransformation = true; + @Override + public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { + if ( className_to_subtype.containsKey(owner) ) + needsTransformation = true; - super.visitMethodInsn(opcode, owner, name, desc); - } + super.visitMethodInsn(opcode, owner, name, desc); + } - @Override - public void visitEnd() { - if ( needsTransformation ) { // Early-out for methods that do not touch a mapped object. - //System.err.println("\nTRANSFORMING: " + className + "." + name + desc); - try { - transformMethod(analyse()); - } catch (Exception e) { - throw new RuntimeException(e); - } + @Override + public void visitEnd() { + if ( needsTransformation ) { // Early-out for methods that do not touch a mapped object. + //System.err.println("\nTRANSFORMING: " + className + "." + name + desc); + transformed = true; + try { + transformMethod(analyse()); + } catch (Exception e) { + throw new RuntimeException(e); } - - // Pass the instruction stream to the adapter's MethodVisitor - accept(mv); } - private Frame<BasicValue>[] analyse() throws AnalyzerException { - final Analyzer<BasicValue> a = new Analyzer<BasicValue>(new SimpleVerifier()); - a.analyze(className, this); - return a.getFrames(); - } + // Pass the instruction stream to the adapter's MethodVisitor + accept(mv); + } - private void transformMethod(final Frame<BasicValue>[] frames) { - final InsnList instructions = this.instructions; + private Frame<BasicValue>[] analyse() throws AnalyzerException { + final Analyzer<BasicValue> a = new Analyzer<BasicValue>(new SimpleVerifier()); + a.analyze(className, this); + return a.getFrames(); + } - final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>(); + private void transformMethod(final Frame<BasicValue>[] frames) { + final InsnList instructions = this.instructions; - /* - We need this map because we insert/remove instructions from the stream and we need a way - to match each original instruction with the corresponding frame. - TODO: Can we keep track of everything more efficiently without a map? - */ - final Map<AbstractInsnNode, Frame<BasicValue>> frameMap = new HashMap<AbstractInsnNode, Frame<BasicValue>>(); - for ( int i = 0; i < frames.length; i++ ) - frameMap.put(instructions.get(i), frames[i]); + final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>(); - for ( int i = 0; i < instructions.size(); i++ ) { // f is a separate cursor for frames - final AbstractInsnNode instruction = instructions.get(i); + /* + We need this map because we insert/remove instructions from the stream and we need a way + to match each original instruction with the corresponding frame. + TODO: Can we keep track of everything more efficiently without a map? + */ + final Map<AbstractInsnNode, Frame<BasicValue>> frameMap = new HashMap<AbstractInsnNode, Frame<BasicValue>>(); + for ( int i = 0; i < frames.length; i++ ) + frameMap.put(instructions.get(i), frames[i]); - //System.out.println("MAIN LOOP #" + i + " - " + getOpcodeName(instruction)); + for ( int i = 0; i < instructions.size(); i++ ) { // f is a separate cursor for frames + final AbstractInsnNode instruction = instructions.get(i); - switch ( instruction.getType() ) { - case AbstractInsnNode.VAR_INSN: - if ( instruction.getOpcode() == ALOAD ) { - VarInsnNode varInsn = (VarInsnNode)instruction; - final MappedSubtypeInfo mappedSubtype = arrayVars.get(varInsn.var); - if ( mappedSubtype != null ) - i = transformArrayAccess(instructions, i, frameMap, varInsn, mappedSubtype, varInsn.var); - } - break; - case AbstractInsnNode.FIELD_INSN: - FieldInsnNode fieldInsn = (FieldInsnNode)instruction; + //System.out.println("MAIN LOOP #" + i + " - " + getOpcodeName(instruction)); - final InsnList list = transformFieldAccess(fieldInsn); - if ( list != null ) - i = replace(instructions, i, instruction, list); + switch ( instruction.getType() ) { + case AbstractInsnNode.VAR_INSN: + if ( instruction.getOpcode() == ALOAD ) { + VarInsnNode varInsn = (VarInsnNode)instruction; + final MappedSubtypeInfo mappedSubtype = arrayVars.get(varInsn.var); + if ( mappedSubtype != null ) + i = transformArrayAccess(instructions, i, frameMap, varInsn, mappedSubtype, varInsn.var); + } + break; + case AbstractInsnNode.FIELD_INSN: + FieldInsnNode fieldInsn = (FieldInsnNode)instruction; - break; - case AbstractInsnNode.METHOD_INSN: - MethodInsnNode methodInsn = (MethodInsnNode)instruction; - final MappedSubtypeInfo mappedType = className_to_subtype.get(methodInsn.owner); - if ( mappedType != null ) - i = transformMethodCall(instructions, i, frameMap, methodInsn, mappedType, arrayVars); - break; - } + final InsnList list = transformFieldAccess(fieldInsn); + if ( list != null ) + i = replace(instructions, i, instruction, list); + + break; + case AbstractInsnNode.METHOD_INSN: + MethodInsnNode methodInsn = (MethodInsnNode)instruction; + final MappedSubtypeInfo mappedType = className_to_subtype.get(methodInsn.owner); + if ( mappedType != null ) + i = transformMethodCall(instructions, i, frameMap, methodInsn, mappedType, arrayVars); + break; } } - }; - } - }; + } + }; + } } static int transformMethodCall(final InsnList instructions, int i, final Map<AbstractInsnNode, Frame<BasicValue>> frameMap, final MethodInsnNode methodInsn, final MappedSubtypeInfo mappedType, final Map<Integer, MappedSubtypeInfo> arrayVars) { @@ -760,16 +796,16 @@ return generateAddressInstructions(fieldInsn); } - final Long fieldOffset = mappedSubtype.fieldToOffset.get(fieldInsn.name); - if ( fieldOffset == null ) // early out + final FieldInfo field = mappedSubtype.fields.get(fieldInsn.name); + if ( field == null ) // early out return null; // now we're going to transform ByteBuffer-typed field access if ( fieldInsn.desc.equals("L" + jvmClassName(ByteBuffer.class) + ";") ) - return generateByteBufferInstructions(fieldInsn, mappedSubtype, fieldOffset); + return generateByteBufferInstructions(fieldInsn, mappedSubtype, field.offset); // we're now going to transform the field access - return generateFieldInstructions(fieldInsn, fieldOffset); + return generateFieldInstructions(fieldInsn, field); } private static InsnList generateSetViewInstructions(final FieldInsnNode fieldInsn) { @@ -867,13 +903,11 @@ throw new InternalError(); } - private static InsnList generateByteBufferInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype, final Long fieldOffset) { + private static InsnList generateByteBufferInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype, final long fieldOffset) { if ( fieldInsn.getOpcode() == PUTFIELD ) throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name); if ( fieldInsn.getOpcode() == GETFIELD ) { - final Long fieldLength = mappedSubtype.fieldToLength.get(fieldInsn.name); - final InsnList list = new InsnList(); // stack: ref @@ -883,7 +917,7 @@ // stack: long, long list.add(new InsnNode(LADD)); // stack: long - list.add(new LdcInsnNode(fieldLength)); + list.add(new LdcInsnNode(mappedSubtype.fields.get(fieldInsn.name).length)); // stack: long, long list.add(new InsnNode(L2I)); // stack: int, long @@ -896,23 +930,25 @@ throw new InternalError(); } - private static InsnList generateFieldInstructions(final FieldInsnNode fieldInsn, final Long fieldOffset) { + private static InsnList generateFieldInstructions(final FieldInsnNode fieldInsn, final FieldInfo field) { final InsnList list = new InsnList(); + final String dataType = field.isPointer ? "a" : fieldInsn.desc.toLowerCase(); + if ( fieldInsn.getOpcode() == PUTFIELD ) { // stack: value, ref - list.add(getIntNode(fieldOffset.intValue())); + list.add(getIntNode((int)field.offset)); // stack: fieldOffset, value, ref - list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, fieldInsn.desc.toLowerCase() + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V")); + list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, dataType + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V")); // stack - return list; } if ( fieldInsn.getOpcode() == GETFIELD ) { // stack: ref - list.add(getIntNode(fieldOffset.intValue())); + list.add(getIntNode((int)field.offset)); // stack: fieldOffset, ref - list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, fieldInsn.desc.toLowerCase() + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc)); + list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, dataType + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc)); // stack: - return list; } @@ -1006,29 +1042,43 @@ } } + private static class FieldInfo { + + final long offset; + final long length; + final Type type; + final boolean isPointer; + + FieldInfo(final long offset, final long length, final Type type, final boolean isPointer) { + this.offset = offset; + this.length = length; + this.type = type; + this.isPointer = isPointer; + } + + } + private static class MappedSubtypeInfo { - public final String className; + final String className; - public int sizeof; - public int sizeof_shift; - public int align; + final int sizeof; + final int sizeof_shift; + final int align; - public Map<String, Long> fieldToOffset; - public Map<String, Long> fieldToLength; - public Map<String, Type> fieldToType; + final Map<String, FieldInfo> fields; - MappedSubtypeInfo(String className, int sizeof, int align) { + MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align) { this.className = className; this.sizeof = sizeof; if ( ((sizeof - 1) & sizeof) == 0 ) this.sizeof_shift = getPoT(sizeof); + else + this.sizeof_shift = 0; this.align = align; - this.fieldToOffset = new HashMap<String, Long>(); - this.fieldToLength = new HashMap<String, Long>(); - this.fieldToType = new HashMap<String, Type>(); + this.fields = fields; } private static int getPoT(int value) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java 2011-07-22 20:09:01 UTC (rev 3598) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -60,11 +60,12 @@ public @interface MappedType { /** - * The total size of the mapped object, in bytes. + * The number of bytes to add to the total byte size. + * SIZEOF will be calculated as <code>SIZEOF = max(field_offset + field_length) + padding</code> * - * @return the byte size + * @return the padding amount */ - int sizeof(); + int padding() default 0; /** * The mapped data memory alignment, in bytes. Added: trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java 2011-07-23 22:02:01 UTC (rev 3599) @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.mapped; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation can be used on long fields of {@link MappedType} classes, + * to specify that the long value should be interpreted as a pointer. This + * will determine the actual byte size of the field at runtime (4 or 8 bytes). + * + * @author Spasi + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Pointer { + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-22 20:09:08
|
Revision: 3598 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3598&view=rev Author: spasi Date: 2011-07-22 20:09:01 +0000 (Fri, 22 Jul 2011) Log Message: ----------- Converted sizeof and align to methods. Override more methods in MappedObject subclasses, foreach is now 4 times faster. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -60,8 +60,8 @@ { MappedFloat vecs1 = MappedFloat.malloc(1234); - assert (vecs1.sizeof == MappedFloat.SIZEOF); - assert (vecs1.sizeof * 1234 == vecs1.backingByteBuffer().capacity()); + assert (vecs1.getSizeof() == MappedFloat.SIZEOF); + assert (vecs1.getSizeof() * 1234 == vecs1.backingByteBuffer().capacity()); assert (MappedFloat.SIZEOF * 1234 == vecs1.backingByteBuffer().capacity()); } Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -44,7 +44,7 @@ System.out.println(vecs.viewAddress); // test read-access - System.out.println(vecs.align); // test read-access + System.out.println(vecs.getAlign()); // test read-access System.out.println(MappedVec3.SIZEOF); // test read-access } @@ -91,7 +91,7 @@ vecs.view = 1; long a2 = vecs.viewAddress; assert (a2 - a1 == MappedVec3.SIZEOF); - assert (a2 - a1 == vecs.sizeof); + assert (a2 - a1 == vecs.getSizeof()); vecs.view = 0; } } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -58,7 +58,7 @@ } public T next() { - MappedHelper.put_view(mapped, this.index++, mapped.sizeof); + mapped.setViewAddress(mapped.getViewAddress(this.index++)); return mapped; } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -55,11 +55,9 @@ if ( LWJGLUtil.CHECKS && align <= 0 ) throw new IllegalArgumentException("invalid alignment"); - mo.align = align; if ( LWJGLUtil.CHECKS && (sizeof <= 0 || sizeof % align != 0) ) throw new IllegalStateException("sizeof not a multiple of alignment"); - mo.sizeof = sizeof; long addr = MemoryUtil.getAddress(buffer); if ( LWJGLUtil.CHECKS && addr % align != 0 ) @@ -107,8 +105,6 @@ public static MappedObject dup(MappedObject src, MappedObject dst) { dst.baseAddress = src.baseAddress; dst.viewAddress = src.viewAddress; - dst.align = src.align; - dst.sizeof = src.sizeof; dst.preventGC = src.preventGC; return dst; } @@ -116,8 +112,6 @@ public static MappedObject slice(MappedObject src, MappedObject dst) { dst.baseAddress = src.viewAddress; // ! dst.viewAddress = src.viewAddress; - dst.align = src.align; - dst.sizeof = src.sizeof; dst.preventGC = src.preventGC; return dst; } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -50,11 +50,11 @@ * * @author Riven */ -public class MappedObject { +public abstract class MappedObject { static final boolean CHECKS = LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.Checks"); - public MappedObject() { + protected MappedObject() { // } @@ -64,12 +64,9 @@ /** The mapped object view memory address, in bytes. Read-only. */ public long viewAddress; - /** The mapped object memory alignment, in bytes. Read-only. */ - public int align; + /** The mapped buffer. */ + ByteBuffer preventGC; - /** The mapped object memory sizeof, in bytes. Read-only. */ - public int sizeof; - /** * Holds the value of sizeof of the sub-type of this MappedObject<br> * <br> @@ -87,6 +84,12 @@ */ public int view; + protected final long getViewAddress(final int view) { + // No call-site modification for this, we override in every subclass instead, + // so that we can use it in MappedForeach. + throw new InternalError("type not registered"); + } + public final void setViewAddress(final long address) { if ( CHECKS ) checkAddress(address); @@ -96,8 +99,8 @@ final void checkAddress(final long address) { final long base = MemoryUtil.getAddress0(preventGC); final int offset = (int)(address - base); - if ( address < base || preventGC.capacity() < (offset + this.sizeof) ) - throw new IndexOutOfBoundsException(Integer.toString(offset / sizeof)); + if ( address < base || preventGC.capacity() < (offset + getSizeof()) ) + throw new IndexOutOfBoundsException(Integer.toString(offset / getSizeof())); } final void checkRange(final int bytes) { @@ -108,7 +111,28 @@ throw new BufferOverflowException(); } + /** The mapped object memory alignment, in bytes. Read-only. */ /** + * Returns the mapped object memory alignment, in bytes. + * + * @return the memory alignment + */ + public final int getAlign() { + // No call-site modification for this, we override in every subclass instead. + throw new InternalError("type not registered"); + } + + /** + * Returns the mapped object memory sizeof, in bytes. + * + * @return the sizeof value + */ + public final int getSizeof() { + // No call-site modification for this, we override in every subclass instead. + throw new InternalError("type not registered"); + } + + /** * Creates a MappedObject instance, mapping the memory region of the specified direct ByteBuffer. * <p/> * The behavior of this (transformed) method does not follow the normal Java behavior.<br> @@ -178,22 +202,18 @@ * Any code in the default constructor will not run automatically. This method * can be used to run execute that code on the current view. */ - public final <T extends MappedObject> void runViewConstructor() { + public final void runViewConstructor() { // any method that calls this method will have its call-site modified throw new InternalError("type not registered"); } /** Moves the current view to the next element. */ public final void next() { - // any method that calls this method will have its call-site modified + // No call-site modification for this, we override in every subclass instead, + // so that we can use it in MappedSetX. throw new InternalError("type not registered"); } - /** Moves the current view to the next element. Non-transformed implementation for MappedSets. */ - final void nextSet() { - setViewAddress(viewAddress + sizeof); - } - /** * Copies and amount of <code>SIZEOF</code> bytes, from the current * mapped object, to the specified mapped object. @@ -232,14 +252,12 @@ throw new InternalError("type not registered"); } - ByteBuffer preventGC; - /** * Returns the {@link java.nio.ByteBuffer} that backs this mapped object. * * @return the backing buffer */ - public ByteBuffer backingByteBuffer() { + public final ByteBuffer backingByteBuffer() { return this.preventGC; } Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -73,7 +73,9 @@ FORKED = true; try { - URLClassLoader loader = new MappedObjectClassLoader(mainClass); + MappedObjectClassLoader loader = new MappedObjectClassLoader(mainClass); + loader.loadMappedObject(); + Class<?> replacedMainClass = loader.loadClass(mainClass.getName()); Method mainMethod = replacedMainClass.getMethod("main", String[].class); mainMethod.invoke(null, new Object[] { args }); @@ -90,6 +92,28 @@ super(((URLClassLoader)mainClass.getClassLoader()).getURLs()); } + protected synchronized Class<?> loadMappedObject() throws ClassNotFoundException { + final String name = MappedObject.class.getName(); + String className = name.replace('.', '/'); + + if ( MappedObjectTransformer.PRINT_ACTIVITY ) + LWJGLUtil.log(MappedObjectClassLoader.class.getSimpleName() + ": " + className); + + byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class"))); + + long t0 = System.nanoTime(); + bytecode = MappedObjectTransformer.transformMappedObject(bytecode); + long t1 = System.nanoTime(); + total_time_transforming += (t1 - t0); + + if ( MappedObjectTransformer.PRINT_TIMING ) + LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)"); + + Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length); + resolveClass(clazz); + return clazz; + } + private static long total_time_transforming; @Override @@ -104,10 +128,8 @@ if ( name.startsWith("sunw.") ) return super.loadClass(name, resolve); - // never transform classes in this very package, sub-packages should be transformed - if ( name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX) ) - if ( name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1 ) - return super.loadClass(name, resolve); + if ( name.equals(MappedObjectClassLoader.class.getName()) ) + return super.loadClass(name, resolve); String className = name.replace('.', '/'); @@ -116,13 +138,16 @@ byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class"))); - long t0 = System.nanoTime(); - bytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode); - long t1 = System.nanoTime(); - total_time_transforming += (t1 - t0); + // Classes in this package do not get transformed, but need to go through here because we have transformed MappedObject. + if ( !(name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX) && name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1) ) { + long t0 = System.nanoTime(); + bytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode); + long t1 = System.nanoTime(); - if ( MappedObjectTransformer.PRINT_TIMING ) - LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)"); + total_time_transforming += (t1 - t0); + if ( MappedObjectTransformer.PRINT_TIMING ) + LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)"); + } Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length); if ( resolve ) Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -35,6 +35,7 @@ import org.objectweb.asm.*; import org.objectweb.asm.tree.*; import org.objectweb.asm.tree.analysis.*; +import org.objectweb.asm.tree.analysis.Frame; import org.objectweb.asm.util.TraceClassVisitor; import java.io.PrintWriter; @@ -76,10 +77,16 @@ static final String MAPPED_SET3_JVM = jvmClassName(MappedSet3.class); static final String MAPPED_SET4_JVM = jvmClassName(MappedSet4.class); - static final String LENGTH_METHOD_NAME = "length$LWJGL"; - static final String VIEWADDRESS_METHOD_NAME = "getViewAddress$LWJGL"; - static final String VIEW_CONSTRUCTOR_NAME = "constructView$LWJGL"; + // Public methods + static final String VIEWADDRESS_METHOD_NAME = "getViewAddress"; + static final String NEXT_METHOD_NAME = "next"; + static final String ALIGN_METHOD_NAME = "getAlign"; + static final String SIZEOF_METHOD_NAME = "getSizeof"; + // Internal methods + static final String LENGTH_METHOD_NAME = "length$LWJGL"; // Used for .asArray().length + static final String VIEW_CONSTRUCTOR_NAME = "constructView$LWJGL"; // Used by runViewConstructor + static final Map<Integer, String> OPCODE_TO_NAME = new HashMap<Integer, String>(); static final Map<Integer, String> INSNTYPE_TO_NAME = new HashMap<Integer, String>(); @@ -122,9 +129,6 @@ * @param type the mapped object class. */ public static void register(Class<?> type) { - if ( MappedObjectClassLoader.FORKED ) - return; - final MappedType mapped = type.getAnnotation(MappedType.class); if ( mapped == null ) throw new InternalError("missing " + MappedType.class.getName() + " annotation"); @@ -185,6 +189,34 @@ return (int)byteLength; } + /** Removes final from methods that will be overriden by subclasses. */ + static byte[] transformMappedObject(byte[] bytecode) { + final ClassWriter cw = new ClassWriter(0); + + ClassVisitor cv = new ClassAdapter(cw) { + + private final String[] DEFINALIZE_LIST = { + VIEWADDRESS_METHOD_NAME, + NEXT_METHOD_NAME, + ALIGN_METHOD_NAME, + SIZEOF_METHOD_NAME, + }; + + public MethodVisitor visitMethod(int access, final String name, final String desc, final String signature, final String[] exceptions) { + for ( String method : DEFINALIZE_LIST ) { + if ( name.equals(method) ) { + access &= ~ACC_FINAL; + break; + } + } + return super.visitMethod(access, name, desc, signature, exceptions); + } + }; + + new ClassReader(bytecode).accept(cv, 0); + return cw.toByteArray(); + } + static byte[] transformMappedAPI(final String className, byte[] bytecode) { final ClassWriter cw = new ClassWriter(COMPUTE_FRAMES) { @@ -203,8 +235,7 @@ if ( className_to_subtype.containsKey(className) ) // Do a first pass to generate address getters cv = getMethodGenAdapter(className, cv); - //cr.accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); - new ClassReader(bytecode).accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); + new ClassReader(bytecode).accept(cv, ClassReader.SKIP_FRAMES); bytecode = cw.toByteArray(); if ( PRINT_BYTECODE ) @@ -218,11 +249,14 @@ @Override public void visitEnd() { + final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); + generateViewAddressGetter(); generateLengthGetter(); + generateAlignGetter(mappedSubtype); + generateSizeofGetter(); + generateNext(); - final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); - for ( String fieldName : mappedSubtype.fieldToOffset.keySet() ) { final Type type = mappedSubtype.fieldToType.get(fieldName); @@ -238,7 +272,7 @@ } private void generateViewAddressGetter() { - MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, VIEWADDRESS_METHOD_NAME, "(L" + className + ";I)J", null, null); + MethodVisitor mv = super.visitMethod(ACC_PUBLIC, VIEWADDRESS_METHOD_NAME, "(I)J", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, MAPPED_OBJECT_JVM, "baseAddress", "J"); @@ -266,7 +300,7 @@ MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, LENGTH_METHOD_NAME, "(L" + className + ";)I", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKEVIRTUAL, className, "backingByteBuffer", "()L" + jvmClassName(ByteBuffer.class) + ";"); + mv.visitMethodInsn(INVOKEVIRTUAL, MAPPED_OBJECT_JVM, "backingByteBuffer", "()L" + jvmClassName(ByteBuffer.class) + ";"); mv.visitMethodInsn(INVOKEVIRTUAL, jvmClassName(ByteBuffer.class), "capacity", "()I"); mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I"); mv.visitInsn(IDIV); @@ -275,12 +309,45 @@ mv.visitEnd(); } + private void generateAlignGetter(final MappedSubtypeInfo mappedSubtype) { + MethodVisitor mv = super.visitMethod(ACC_PUBLIC, ALIGN_METHOD_NAME, "()I", null, null); + mv.visitCode(); + visitIntNode(mv, mappedSubtype.sizeof); + mv.visitInsn(IRETURN); + mv.visitMaxs(1, 1); + mv.visitEnd(); + } + + private void generateSizeofGetter() { + MethodVisitor mv = super.visitMethod(ACC_PUBLIC, SIZEOF_METHOD_NAME, "()I", null, null); + mv.visitCode(); + mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I"); + mv.visitInsn(IRETURN); + mv.visitMaxs(1, 1); + mv.visitEnd(); + } + + private void generateNext() { + MethodVisitor mv = super.visitMethod(ACC_PUBLIC, NEXT_METHOD_NAME, "()V", null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETFIELD, MAPPED_OBJECT_JVM, "viewAddress", "J"); + mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I"); + mv.visitInsn(I2L); + mv.visitInsn(LADD); + mv.visitMethodInsn(INVOKEVIRTUAL, className, "setViewAddress", "(J)V"); + mv.visitInsn(RETURN); + mv.visitMaxs(3, 1); + mv.visitEnd(); + } + private void generateByteBufferGetter(final MappedSubtypeInfo mappedSubtype, final String fieldName, final Type type) { MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + type.getDescriptor(), null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKESTATIC, className, VIEWADDRESS_METHOD_NAME, "(L" + className + ";I)J"); + mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J"); visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue()); mv.visitInsn(I2L); mv.visitInsn(LADD); @@ -296,13 +363,13 @@ mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKESTATIC, className, VIEWADDRESS_METHOD_NAME, "(L" + className + ";I)J"); + mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J"); visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue()); mv.visitInsn(I2L); mv.visitInsn(LADD); mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, type.getDescriptor().toLowerCase() + "get", "(J)" + type.getDescriptor()); mv.visitInsn(type.getOpcode(IRETURN)); - mv.visitMaxs(2, 2); + mv.visitMaxs(3, 2); mv.visitEnd(); } @@ -331,13 +398,13 @@ mv.visitVarInsn(load, 2); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKESTATIC, className, VIEWADDRESS_METHOD_NAME, "(L" + className + ";I)J"); + mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J"); visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue()); mv.visitInsn(I2L); mv.visitInsn(LADD); mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, type.getDescriptor().toLowerCase() + "put", "(" + type.getDescriptor() + "J)V"); mv.visitInsn(RETURN); - mv.visitMaxs(3, 3); + mv.visitMaxs(4, 3); mv.visitEnd(); } @@ -415,12 +482,14 @@ @Override public void visitEnd() { - if ( needsTransformation ) // Early-out for methods that do not touch a mapped object. + if ( needsTransformation ) { // Early-out for methods that do not touch a mapped object. + //System.err.println("\nTRANSFORMING: " + className + "." + name + desc); try { transformMethod(analyse()); } catch (Exception e) { throw new RuntimeException(e); } + } // Pass the instruction stream to the adapter's MethodVisitor accept(mv); @@ -433,8 +502,6 @@ } private void transformMethod(final Frame<BasicValue>[] frames) { - //System.err.println("\nTRANSFORMING: " + className + " - " + name + desc); - final InsnList instructions = this.instructions; final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>(); @@ -540,10 +607,6 @@ break; } - if ( "next".equals(methodInsn.name) && "()V".equals(methodInsn.desc) ) { - i = replace(instructions, i, methodInsn, generateNextInstructions(mappedType)); - break; - } break; case INVOKESPECIAL: // super() in VIEW_CONSTRUCTOR_NAME, remove @@ -567,18 +630,6 @@ return i; } - private static InsnList generateNextInstructions(final MappedSubtypeInfo mappedType) { - final InsnList list = new InsnList(); - - // stack: this - list.add(getIntNode(mappedType.sizeof)); - // stack: sizeof, this - list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_view_next", "(L" + MAPPED_OBJECT_JVM + ";I)V")); - // stack: - - - return list; - } - private static InsnList generateCopyRangeInstructions(final MappedSubtypeInfo mappedType) { final InsnList list = new InsnList(); @@ -705,9 +756,6 @@ if ( "view".equals(fieldInsn.name) ) return generateViewInstructions(fieldInsn, mappedSubtype); - if ( "align".equals(fieldInsn.name) || "sizeof".equals(fieldInsn.name) ) - return generateAlignSizeofInstructions(fieldInsn, mappedSubtype); - if ( "baseAddress".equals(fieldInsn.name) || "viewAddress".equals(fieldInsn.name) ) { return generateAddressInstructions(fieldInsn); } @@ -806,29 +854,6 @@ throw new InternalError(); } - private static InsnList generateAlignSizeofInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype) { - if ( !"I".equals(fieldInsn.desc) ) - throw new InternalError(); - - if ( fieldInsn.getOpcode() == GETFIELD ) { - final InsnList list = new InsnList(); - - // stack: instance - list.add(new InsnNode(POP)); - // stack: - - if ( "sizeof".equals(fieldInsn.name) ) - list.add(getIntNode(mappedSubtype.sizeof)); - else if ( "align".equals(fieldInsn.name) ) - list.add(getIntNode(mappedSubtype.align)); - // stack: int - return list; - } - - if ( fieldInsn.getOpcode() == PUTFIELD ) - throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name); - throw new InternalError(); - } - private static InsnList generateAddressInstructions(final FieldInsnNode fieldInsn) { if ( !"J".equals(fieldInsn.desc) ) throw new IllegalStateException(); @@ -961,7 +986,7 @@ nextInsn = getter; continue; } else if ( stackSize < loadStackSize ) - throw new ClassFormatError("Invalid .asArray() usage detected: " + getOpcodeName(nextInsn)); + throw new ClassFormatError("Invalid " + mappedSubtype.className + " view array usage detected: " + getOpcodeName(nextInsn)); } instructions.remove(aaLoadInsn); Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -44,13 +44,13 @@ public int view; void view(int view) { - MappedHelper.put_view(this.a, view, this.a.sizeof); - MappedHelper.put_view(this.b, view, this.b.sizeof); + a.setViewAddress(a.getViewAddress(view)); + b.setViewAddress(b.getViewAddress(view)); } public void next() { - this.a.nextSet(); - this.b.nextSet(); + this.a.next(); + this.b.next(); } } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -45,15 +45,15 @@ public int view; void view(int view) { - MappedHelper.put_view(this.a, view, this.a.sizeof); - MappedHelper.put_view(this.b, view, this.b.sizeof); - MappedHelper.put_view(this.c, view, this.c.sizeof); + a.setViewAddress(a.getViewAddress(view)); + b.setViewAddress(b.getViewAddress(view)); + c.setViewAddress(c.getViewAddress(view)); } public void next() { - this.a.nextSet(); - this.b.nextSet(); - this.c.nextSet(); + this.a.next(); + this.b.next(); + this.c.next(); } } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java 2011-07-22 02:01:56 UTC (rev 3597) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java 2011-07-22 20:09:01 UTC (rev 3598) @@ -46,16 +46,16 @@ public int view; void view(int view) { - MappedHelper.put_view(this.a, view, this.a.sizeof); - MappedHelper.put_view(this.b, view, this.b.sizeof); - MappedHelper.put_view(this.c, view, this.c.sizeof); - MappedHelper.put_view(this.d, view, this.d.sizeof); + a.setViewAddress(a.getViewAddress(view)); + b.setViewAddress(b.getViewAddress(view)); + c.setViewAddress(c.getViewAddress(view)); + d.setViewAddress(d.getViewAddress(view)); } public void next() { - this.a.nextSet(); - this.b.nextSet(); - this.c.nextSet(); - this.d.nextSet(); + this.a.next(); + this.b.next(); + this.c.next(); + this.d.next(); } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-22 02:02:05
|
Revision: 3597 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3597&view=rev Author: spasi Date: 2011-07-22 02:01:56 +0000 (Fri, 22 Jul 2011) Log Message: ----------- Added support for array access to mapped objects. Added SpriteShootout test that uses mapped objects. Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java Added Paths: ----------- trunk/LWJGL/libs/asm-debug-all.jar trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java Removed Paths: ------------- trunk/LWJGL/libs/asm-util.jar trunk/LWJGL/libs/asm.jar Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/build.xml 2011-07-22 02:01:56 UTC (rev 3597) @@ -410,7 +410,7 @@ <!-- Compiles the Java source code --> <target name="compile" description="Compiles the java source code" depends="-initialize"> - <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar;${lwjgl.lib}/asm.jar;${lwjgl.lib}/asm-util.jar" taskname="core"> + <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar" taskname="core"> <!--<compilerarg value="-Xlint:unchecked"/>--> <src path="${lwjgl.src}/java/"/> <src path="${lwjgl.src}/generated/"/> Added: trunk/LWJGL/libs/asm-debug-all.jar =================================================================== (Binary files differ) Property changes on: trunk/LWJGL/libs/asm-debug-all.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: trunk/LWJGL/libs/asm-util.jar =================================================================== (Binary files differ) Deleted: trunk/LWJGL/libs/asm.jar =================================================================== (Binary files differ) Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -31,6 +31,7 @@ */ package org.lwjgl.test.mapped; +import org.lwjgl.MemoryUtil; import org.lwjgl.util.mapped.MappedObjectUnsafe; import java.nio.ByteBuffer; @@ -212,7 +213,7 @@ final int iterations = 64 * 1024; ByteBuffer bb = ByteBuffer.allocateDirect(200); - long addr = MappedObjectUnsafe.getBufferBaseAddress(bb); + long addr = MemoryUtil.getAddress(bb); long[] took = new long[runs]; for ( int run = 0; run < runs; run++ ) { Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -31,6 +31,7 @@ */ package org.lwjgl.test.mapped; +import org.lwjgl.MemoryUtil; import org.lwjgl.util.mapped.MappedHelper; import org.lwjgl.util.mapped.MappedObjectUnsafe; @@ -143,9 +144,9 @@ // test newBuffer { - long addr1 = MappedObjectUnsafe.getBufferBaseAddress(bb); + long addr1 = MemoryUtil.getAddress(bb); ByteBuffer bb2 = MappedHelper.newBuffer(addr1, bb.capacity()); - long addr2 = MappedObjectUnsafe.getBufferBaseAddress(bb); + long addr2 = MemoryUtil.getAddress(bb); System.out.println(bb); System.out.println(bb2); Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -31,7 +31,11 @@ */ package org.lwjgl.test.mapped; -import org.lwjgl.util.mapped.*; +import org.lwjgl.MemoryUtil; +import org.lwjgl.util.mapped.MappedObject; +import org.lwjgl.util.mapped.MappedSet; +import org.lwjgl.util.mapped.MappedSet2; +import org.lwjgl.util.mapped.MappedType; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -49,10 +53,10 @@ assert (some.data != some.data); - long addr1 = MappedObjectUnsafe.getBufferBaseAddress(some.backingByteBuffer()); + long addr1 = MemoryUtil.getAddress(some.backingByteBuffer()); ByteBuffer mapped = some.data; // creates new ByteBuffer instance - long addr2 = MappedObjectUnsafe.getBufferBaseAddress(mapped); + long addr2 = MemoryUtil.getAddress(mapped); assert (addr2 - addr1 == 4); assert (mapped.capacity() == MappedSomething.SIZEOF - 4); @@ -60,7 +64,7 @@ some.view++; mapped = some.data; // creates new ByteBuffer instance - long addr3 = MappedObjectUnsafe.getBufferBaseAddress(mapped); + long addr3 = MemoryUtil.getAddress(mapped); assert (addr3 - addr1 == 4 + MappedSomething.SIZEOF); assert (addr3 - addr2 == 0 + MappedSomething.SIZEOF); assert (mapped.capacity() == MappedSomething.SIZEOF - 4); @@ -87,7 +91,7 @@ static void testConstructor() { int capacity = 1024; ByteBuffer bb = ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder()); - long address = MappedObjectUnsafe.getBufferBaseAddress(bb); + long address = MemoryUtil.getAddress(bb); MappedFloat mf = MappedFloat.map(address, capacity); Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.test.mapped; + +import org.lwjgl.MemoryUtil; +import org.lwjgl.opengl.Display; + +import java.io.File; +import java.nio.ByteBuffer; + +/** @author Riven */ +@SuppressWarnings("static-access") +public class MappedObjectTests4 { + + public static void testLWJGL() throws Exception { + System.out.println(new File(System.getProperty("java.library.path")).getCanonicalPath()); + Display.create(); + } + + public static void testLocalView() { + MappedFloat mapped1 = MappedFloat.malloc(5); + MappedFloat mapped2 = MappedFloat.malloc(5); + + testLocalView(mapped1); + testLocalView(mapped1, mapped2); + + MappedSomething some = MappedSomething.malloc(5); + testLocalView(some); + } + + private static void testLocalView(MappedFloat mapped1) { + final MappedFloat[] array = mapped1.asArray(); + + assert (array.length == 5); + + int l = 10 * array.length; + for ( int localView1 = 0; localView1 < 5; localView1++ ) { + array[localView1].value = localView1 * 5; + array[localView1].value *= 2.0f; + } + System.out.println(); + float x = 0.0f; + for ( int localView1 = 0; localView1 < 5; localView1++ ) { + System.out.println("[" + localView1 + "] =>" + array[localView1].value); + x += array[localView1].value; + } + System.out.println("x = " + x); + } + + private static void testLocalView(MappedFloat mo1, MappedFloat mo2) { + final MappedFloat[] array1 = mo1.<MappedFloat>asArray(); + for ( int v1 = 0; v1 < 5; v1++ ) { + array1[v1].value = (float)Math.random(); + array1[v1].value *= 2.0f; + } + final MappedFloat[] array2 = mo2.<MappedFloat>asArray(); + for ( int v2 = 0; v2 < 5; v2++ ) { + array2[v2].value = (float)Math.random(); + array2[v2].value *= 2.0f; + } + + System.out.println(); + + for ( int v1 = 0; v1 < 5; v1++ ) { + System.out.println("[" + v1 + "] =>" + array1[v1].value); + } + for ( int v2 = 0; v2 < 5; v2++ ) { + System.out.println("[" + v2 + "] =>" + array2[v2].value); + } + } + + private static void testLocalView(MappedSomething some) { + final MappedSomething[] array = some.asArray(); + + assert (array.length == 5); + + final long baseAddress = MemoryUtil.getAddress(some.backingByteBuffer()); + for ( int i = 0; i < array.length; i++ ) { + ByteBuffer data = array[i].data; + + assert (data.capacity() == (64 - 4)); + assert (MemoryUtil.getAddress(data) == baseAddress + i * MappedSomething.SIZEOF + 4); + } + } + +} \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -71,6 +71,11 @@ MappedObjectTests3.testConstructor(); MappedObjectTests3.testMappedSet(); + MappedObjectTests4.testLocalView(); + + //MappedObjectTests4.testLWJGL(); + + System.out.println("done"); } Added: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -0,0 +1,831 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.test.opengl.sprites; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.*; +import org.lwjgl.util.mapped.MappedObject; +import org.lwjgl.util.mapped.MappedObjectClassLoader; +import org.lwjgl.util.mapped.MappedObjectTransformer; +import org.lwjgl.util.mapped.MappedType; + +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Random; +import javax.imageio.ImageIO; + +import static org.lwjgl.opengl.EXTTransformFeedback.*; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL12.*; +import static org.lwjgl.opengl.GL15.*; +import static org.lwjgl.opengl.GL20.*; +import static org.lwjgl.opengl.GL30.*; + +/** + * Sprite rendering demo. Three implementations are supported: + * a) CPU animation + BufferData VBO update. + * b) CPU animation + MapBufferRange VBO update. + * c) GPU animation using transform feedback with a vertex shader. + * + * @author Spasi + * @since 18/3/2011 + */ +public final class SpriteShootoutMapped { + + static final int SCREEN_WIDTH = 800; + static final int SCREEN_HEIGHT = 600; + + private static final int ANIMATION_TICKS = 60; + + private boolean run = true; + private boolean render = true; + private boolean colorMask = true; + private boolean animate = true; + private boolean smooth; + private boolean vsync; + + int ballSize = 42; + int ballCount = 100 * 1000; + + private SpriteRenderer renderer; + + // OpenGL stuff + private int texID; + private int texBigID; + private int texSmallID; + + private SpriteShootoutMapped() { + } + + public static void main(String[] args) { + MappedObjectTransformer.register(Pixel4b.class); + MappedObjectTransformer.register(Pixel3b.class); + MappedObjectTransformer.register(Sprite.class); + MappedObjectTransformer.register(SpriteRender.class); + + if ( MappedObjectClassLoader.fork(SpriteShootoutMapped.class, args) ) + return; + + try { + new SpriteShootoutMapped().start(); + } catch (LWJGLException e) { + e.printStackTrace(); + } + } + + private void start() throws LWJGLException { + try { + initGL(); + + final ContextCapabilities caps = GLContext.getCapabilities(); + if ( !true && (caps.OpenGL30 || caps.GL_EXT_transform_feedback) ) + renderer = new SpriteRendererTF(); + else if ( true && caps.GL_ARB_map_buffer_range ) + renderer = new SpriteRendererMapped(); + else + renderer = new SpriteRendererPlain(); + + updateBalls(ballCount); + run(); + } catch (Throwable t) { + t.printStackTrace(); + } finally { + destroy(); + } + } + + private void initGL() throws LWJGLException { + Display.setLocation((Display.getDisplayMode().getWidth() - SCREEN_WIDTH) / 2, + (Display.getDisplayMode().getHeight() - SCREEN_HEIGHT) / 2); + Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT)); + Display.setTitle("Sprite Shootout"); + Display.create(); + //Display.create(new PixelFormat(), new ContextAttribs(4, 1).withProfileCompatibility(true).withDebug(true)); + //AMDDebugOutput.glDebugMessageCallbackAMD(new AMDDebugOutputCallback()); + + if ( !GLContext.getCapabilities().OpenGL20 ) + throw new RuntimeException("OpenGL 2.0 is required for this demo."); + + // Setup viewport + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1.0, 1.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + + glClearColor(1.0f, 1.0f, 1.0f, 0.0f); + + // Create textures + + try { + texSmallID = createTexture("res/ball_sm.png"); + texBigID = createTexture("res/ball.png"); + } catch (IOException e) { + e.printStackTrace(); + System.exit(-1); + } + texID = texBigID; + + // Setup rendering state + + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.0f); + + glColorMask(colorMask, colorMask, colorMask, false); + glDepthMask(false); + glDisable(GL_DEPTH_TEST); + + // Setup geometry + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + Util.checkGLError(); + } + + private static int createTexture(final String path) throws IOException { + final BufferedImage img = ImageIO.read(SpriteShootoutMapped.class.getClassLoader().getResource(path)); + + final int w = img.getWidth(); + final int h = img.getHeight(); + + final ByteBuffer buffer = readImage(img); + + final int texID = glGenTextures(); + + glBindTexture(GL_TEXTURE_2D, texID); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer); + + return texID; + } + + @MappedType(sizeof = 4) + public static class Pixel4b extends MappedObject { + + public byte r, g, b, a; + + } + + @MappedType(sizeof = 3, align = 3) + public static class Pixel3b extends MappedObject { + + public byte r, g, b; + + } + + private static ByteBuffer readImage(final BufferedImage img) throws IOException { + final Raster raster = img.getRaster(); + + final int bands = raster.getNumBands(); + + final int w = img.getWidth(); + final int h = img.getHeight(); + + final int count = w * h; + + final byte[] pixels = new byte[count * bands]; + raster.getDataElements(0, 0, w, h, pixels); + + if ( bands == 4 ) { + Pixel4b p = Pixel4b.malloc(count); + + int b = 0; + for ( int i = 0; i < count; i++, b += 4 ) { + // Pre-multiply alpha + final float a = unpackUByte01(pixels[b + 3]); + + p.view = i; + p.r = packUByte01(unpackUByte01(pixels[b + 2]) * a); + p.g = packUByte01(unpackUByte01(pixels[b + 1]) * a); + p.b = packUByte01(unpackUByte01(pixels[b + 0]) * a); + p.a = pixels[b + 3]; + } + + return p.backingByteBuffer(); + } else if ( bands == 3 ) { + Pixel3b p = Pixel3b.malloc(count); + + int b = 0; + for ( int i = 0; i < count; i++, b += 3 ) { + p.view = i; + p.r = pixels[b + 2]; + p.g = pixels[b + 1]; + p.b = pixels[b + 0]; + } + + return p.backingByteBuffer(); + } else { + ByteBuffer p = BufferUtils.createByteBuffer(count * bands); + p.put(pixels, 0, p.capacity()); + p.flip(); + return p; + } + + } + + private static float unpackUByte01(final byte x) { + return (x & 0xFF) / 255.0f; + } + + private static byte packUByte01(final float x) { + return (byte)(x * 255.0f); + } + + private void updateBalls(final int count) { + System.out.println("NUMBER OF BALLS: " + count); + renderer.updateBalls(ballCount); + } + + private void run() { + long startTime = System.currentTimeMillis() + 5000; + long fps = 0; + + long time = Sys.getTime(); + final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS); + + renderer.render(false, true, 0); + + while ( run ) { + Display.processMessages(); + handleInput(); + + glClear(GL_COLOR_BUFFER_BIT); + + final long currTime = Sys.getTime(); + final int delta = (int)(currTime - time); + if ( smooth || delta >= ticksPerUpdate ) { + renderer.render(render, animate, delta); + time = currTime; + } else + renderer.render(render, false, 0); + + Display.update(false); + //Display.sync(60); + + if ( startTime > System.currentTimeMillis() ) { + fps++; + } else { + long timeUsed = 5000 + (startTime - System.currentTimeMillis()); + startTime = System.currentTimeMillis() + 5000; + System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount); + fps = 0; + } + } + } + + private void handleInput() { + if ( Display.isCloseRequested() ) + run = false; + + while ( Keyboard.next() ) { + if ( Keyboard.getEventKeyState() ) + continue; + + switch ( Keyboard.getEventKey() ) { + case Keyboard.KEY_1: + case Keyboard.KEY_2: + case Keyboard.KEY_3: + case Keyboard.KEY_4: + case Keyboard.KEY_5: + case Keyboard.KEY_6: + case Keyboard.KEY_7: + case Keyboard.KEY_8: + case Keyboard.KEY_9: + case Keyboard.KEY_0: + ballCount = 1 << (Keyboard.getEventKey() - Keyboard.KEY_1); + updateBalls(ballCount); + break; + case Keyboard.KEY_ADD: + case Keyboard.KEY_SUBTRACT: + int mult; + if ( Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) ) + mult = 1000; + else if ( Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU) ) + mult = 100; + else if ( Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ) + mult = 10; + else + mult = 1; + if ( Keyboard.getEventKey() == Keyboard.KEY_SUBTRACT ) + mult = -mult; + ballCount += mult * 100; + if ( ballCount <= 0 ) + ballCount = 1; + updateBalls(ballCount); + break; + case Keyboard.KEY_ESCAPE: + run = false; + break; + case Keyboard.KEY_A: + animate = !animate; + System.out.println("Animation is now " + (animate ? "on" : "off") + "."); + break; + case Keyboard.KEY_C: + colorMask = !colorMask; + glColorMask(colorMask, colorMask, colorMask, false); + System.out.println("Color mask is now " + (colorMask ? "on" : "off") + "."); + // Disable alpha test when color mask is off, else we get no benefit. + if ( colorMask ) { + glEnable(GL_BLEND); + glEnable(GL_ALPHA_TEST); + } else { + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + } + break; + case Keyboard.KEY_R: + render = !render; + System.out.println("Rendering is now " + (render ? "on" : "off") + "."); + break; + case Keyboard.KEY_S: + smooth = !smooth; + System.out.println("Smooth animation is now " + (smooth ? "on" : "off") + "."); + break; + case Keyboard.KEY_T: + if ( texID == texBigID ) { + texID = texSmallID; + ballSize = 16; + } else { + texID = texBigID; + ballSize = 42; + } + renderer.updateBallSize(); + glBindTexture(GL_TEXTURE_2D, texID); + System.out.println("Now using the " + (texID == texBigID ? "big" : "small") + " texture."); + break; + case Keyboard.KEY_V: + vsync = !vsync; + Display.setVSyncEnabled(vsync); + System.out.println("VSYNC is now " + (vsync ? "enabled" : "disabled") + "."); + break; + } + } + + while ( Mouse.next() ) ; + } + + private void destroy() { + Display.destroy(); + } + + @MappedType(sizeof = 4 * 4) + public static class Sprite extends MappedObject { + + public float x, y; + public float dx, dy; + + } + + @MappedType(sizeof = 2 * 4) + public static class SpriteRender extends MappedObject { + + public float x, y; + + } + + private abstract class SpriteRenderer { + + protected Sprite sprites; + + protected int spriteCount; + + protected int vshID; + protected int progID; + + protected void createProgram() { + final int fshID = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fshID, "uniform sampler2D COLOR_MAP;\n" + + "void main(void) {\n" + + " gl_FragColor = texture2D(COLOR_MAP, gl_PointCoord);\n" + + "}"); + glCompileShader(fshID); + if ( glGetShader(fshID, GL_COMPILE_STATUS) == GL_FALSE ) { + System.out.println(glGetShaderInfoLog(fshID, glGetShader(fshID, GL_INFO_LOG_LENGTH))); + throw new RuntimeException("Failed to compile fragment shader."); + } + + progID = glCreateProgram(); + glAttachShader(progID, vshID); + glAttachShader(progID, fshID); + glLinkProgram(progID); + if ( glGetProgram(progID, GL_LINK_STATUS) == GL_FALSE ) { + System.out.println(glGetProgramInfoLog(progID, glGetProgram(progID, GL_INFO_LOG_LENGTH))); + throw new RuntimeException("Failed to link shader program."); + } + + glUseProgram(progID); + glUniform1i(glGetUniformLocation(progID, "COLOR_MAP"), 0); + + updateBallSize(); + + glEnableClientState(GL_VERTEX_ARRAY); + } + + public void updateBallSize() { + glPointSize(ballSize); + } + + public abstract void updateBalls(int count); + + protected abstract void render(boolean render, boolean animate, int delta); + + } + + private abstract class SpriteRendererBatched extends SpriteRenderer { + + protected static final int BALLS_PER_BATCH = 10 * 1000; + + SpriteRendererBatched() { + vshID = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vshID, "void main(void) {\n" + + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + + "}"); + glCompileShader(vshID); + if ( glGetShader(vshID, GL_COMPILE_STATUS) == GL_FALSE ) { + System.out.println(glGetShaderInfoLog(vshID, glGetShader(vshID, GL_INFO_LOG_LENGTH))); + throw new RuntimeException("Failed to compile vertex shader."); + } + + createProgram(); + } + + public void updateBalls(final int count) { + final Random random = new Random(); + + final Sprite newSprites = Sprite.malloc(count); + if ( sprites != null ) { + sprites.view = 0; + sprites.copyRange(newSprites, Math.min(count, spriteCount)); + } + + if ( count > spriteCount ) { + for ( int i = spriteCount; i < count; i++ ) { + newSprites.view = i; + + newSprites.x = (int)(random.nextFloat() * (SCREEN_WIDTH - ballSize) + ballSize * 0.5f); + newSprites.y = (int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize) + ballSize * 0.5f); + newSprites.dx = random.nextFloat() * 0.4f - 0.2f; + newSprites.dy = random.nextFloat() * 0.4f - 0.2f; + } + } + + sprites = newSprites; + spriteCount = count; + } + + protected void animate( + final Sprite sprite, + final SpriteRender spriteRender, + final int ballSize, final int ballIndex, final int batchSize, final int delta + ) { + final float ballRadius = ballSize * 0.5f; + final float boundW = SCREEN_WIDTH - ballRadius; + final float boundH = SCREEN_HEIGHT - ballRadius; + + final Sprite[] sprites = sprite.asArray(); + final SpriteRender[] spritesRender = spriteRender.asArray(); + for ( int b = ballIndex, r = 0, len = (ballIndex + batchSize); b < len; b++, r++ ) { + float x = sprites[b].x; + float dx = sprites[b].dx; + + x += dx * delta; + if ( x < ballRadius ) { + x = ballRadius; + sprites[b].dx = -dx; + } else if ( x > boundW ) { + x = boundW; + sprites[b].dx = -dx; + } + sprites[b].x = x; + + float y = sprites[b].y; + float dy = sprites[b].dy; + + y += dy * delta; + if ( y < ballRadius ) { + y = ballRadius; + sprites[b].dy = -dy; + } else if ( y > boundH ) { + y = boundH; + sprites[b].dy = -dy; + } + sprites[b].y = y; + + spritesRender[r].x = x; + spritesRender[r].y = y; + } + } + + } + + private class SpriteRendererPlain extends SpriteRendererBatched { + + private final int DATA_PER_BATCH = BALLS_PER_BATCH * 2 * 4; // balls * 2 floats * 4 bytes + + protected int[] animVBO; + + private SpriteRender spritesRender; + + SpriteRendererPlain() { + System.out.println("Shootout Implementation: CPU animation & BufferData"); + spritesRender = SpriteRender.malloc(BALLS_PER_BATCH); + } + + public void updateBalls(final int count) { + super.updateBalls(count); + + final int batchCount = count / BALLS_PER_BATCH + (count % BALLS_PER_BATCH == 0 ? 0 : 1); + if ( animVBO != null && batchCount == animVBO.length ) + return; + + final int[] newAnimVBO = new int[batchCount]; + if ( animVBO != null ) { + System.arraycopy(animVBO, 0, newAnimVBO, 0, Math.min(animVBO.length, newAnimVBO.length)); + for ( int i = newAnimVBO.length; i < animVBO.length; i++ ) + glDeleteBuffers(animVBO[i]); + } + for ( int i = animVBO == null ? 0 : animVBO.length; i < newAnimVBO.length; i++ ) { + newAnimVBO[i] = glGenBuffers(); + glBindBuffer(GL_ARRAY_BUFFER, newAnimVBO[i]); + } + + animVBO = newAnimVBO; + } + + public void render(final boolean render, final boolean animate, final int delta) { + int batchSize = Math.min(ballCount, BALLS_PER_BATCH); + int ballIndex = 0; + int batchIndex = 0; + while ( ballIndex < ballCount ) { + glBindBuffer(GL_ARRAY_BUFFER, animVBO[batchIndex]); + + if ( animate ) + animate(ballIndex, batchSize, delta); + + if ( render ) { + glVertexPointer(2, GL_FLOAT, 0, 0); + glDrawArrays(GL_POINTS, 0, batchSize); + } + + ballIndex += batchSize; + batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH); + batchIndex++; + } + } + + private void animate(final int ballIndex, final int batchSize, final int delta) { + animate( + sprites, spritesRender, + ballSize, ballIndex, batchSize, delta + ); + + glBufferData(GL_ARRAY_BUFFER, DATA_PER_BATCH, GL_STREAM_DRAW); + glBufferSubData(GL_ARRAY_BUFFER, 0, spritesRender.backingByteBuffer()); + } + + } + + private class SpriteRendererMapped extends SpriteRendererBatched { + + private StreamVBO animVBO; + + SpriteRendererMapped() { + System.out.println("Shootout Implementation: CPU animation & MapBufferRange"); + } + + public void updateBalls(final int count) { + super.updateBalls(count); + + if ( animVBO != null ) + animVBO.destroy(); + + animVBO = new StreamVBO(GL_ARRAY_BUFFER, ballCount * (2 * 4)); + } + + public void render(final boolean render, final boolean animate, final int delta) { + int batchSize = Math.min(ballCount, BALLS_PER_BATCH); + int ballIndex = 0; + while ( ballIndex < ballCount ) { + if ( animate ) { + final ByteBuffer buffer = animVBO.map(batchSize * (2 * 4)); + + animate(sprites, SpriteRender.<SpriteRender>map(buffer), ballSize, ballIndex, batchSize, delta); + + animVBO.unmap(); + } + + if ( render ) { + glVertexPointer(2, GL_FLOAT, 0, ballIndex * (2 * 4)); + glDrawArrays(GL_POINTS, 0, batchSize); + } + + ballIndex += batchSize; + batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH); + } + } + + } + + private class SpriteRendererTF extends SpriteRenderer { + + private int progIDTF; + private int ballSizeLoc; + private int deltaLoc; + + private int[] tfVBO = new int[2]; + private int currVBO; + + SpriteRendererTF() { + System.out.println("Shootout Implementation: TF GPU animation"); + + // Transform-feedback program + + final int vshID = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vshID, "#version 130\n" + + "const float WIDTH = " + SCREEN_WIDTH + ";\n" + + "const float HEIGHT = " + SCREEN_HEIGHT + ";\n" + + "uniform float ballSize;\n" + // ballSize / 2 + "uniform float delta;\n" + + "void main(void) {\n" + + " vec4 anim = gl_Vertex;\n" + + " anim.xy = anim.xy + anim.zw * delta;\n" + + " vec2 animC = clamp(anim.xy, vec2(ballSize), vec2(WIDTH - ballSize, HEIGHT - ballSize));\n" + + " if ( anim.x != animC.x ) anim.z = -anim.z;\n" + + " if ( anim.y != animC.y ) anim.w = -anim.w;\n" + + " gl_Position = vec4(animC, anim.zw);\n" + + "}"); + glCompileShader(vshID); + if ( glGetShader(vshID, GL_COMPILE_STATUS) == GL_FALSE ) { + System.out.println(glGetShaderInfoLog(vshID, glGetShader(vshID, GL_INFO_LOG_LENGTH))); + throw new RuntimeException("Failed to compile vertex shader."); + } + + progIDTF = glCreateProgram(); + glAttachShader(progIDTF, vshID); + glTransformFeedbackVaryings(progIDTF, new CharSequence[] { "gl_Position" }, GL_SEPARATE_ATTRIBS); + glLinkProgram(progIDTF); + if ( glGetProgram(progIDTF, GL_LINK_STATUS) == GL_FALSE ) { + System.out.println(glGetProgramInfoLog(progIDTF, glGetProgram(progIDTF, GL_INFO_LOG_LENGTH))); + throw new RuntimeException("Failed to link shader program."); + } + + glUseProgram(progIDTF); + + ballSizeLoc = glGetUniformLocation(progIDTF, "ballSize"); + deltaLoc = glGetUniformLocation(progIDTF, "delta"); + + glUniform1f(ballSizeLoc, ballSize * 0.5f); + + // ----------------- + + this.vshID = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(this.vshID, "void main(void) {\n" + + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + + "}"); + glCompileShader(this.vshID); + if ( glGetShader(this.vshID, GL_COMPILE_STATUS) == GL_FALSE ) { + System.out.println(glGetShaderInfoLog(this.vshID, glGetShader(this.vshID, GL_INFO_LOG_LENGTH))); + throw new RuntimeException("Failed to compile vertex shader."); + } + + createProgram(); + } + + public void updateBallSize() { + glUseProgram(progIDTF); + glUniform1f(ballSizeLoc, ballSize * 0.5f); + + glUseProgram(progID); + super.updateBallSize(); + } + + private void doUpdateBalls(final int count) { + final Random random = new Random(); + + final Sprite newSprites = Sprite.malloc(count); + if ( sprites != null ) { + sprites.view = 0; + sprites.copyRange(newSprites, Math.min(count, spriteCount)); + } + + if ( count > spriteCount ) { + for ( int i = spriteCount; i < count; i++ ) { + newSprites.view = i; + + newSprites.x = (int)(random.nextFloat() * (SCREEN_WIDTH - ballSize) + ballSize * 0.5f); + newSprites.y = (int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize) + ballSize * 0.5f); + newSprites.dx = random.nextFloat() * 0.4f - 0.2f; + newSprites.dy = random.nextFloat() * 0.4f - 0.2f; + } + } + + sprites = newSprites; + spriteCount = count; + } + + public void updateBalls(final int count) { + if ( tfVBO[0] != 0 ) { + // Fetch current animation state + glGetBufferSubData(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sprites.backingByteBuffer()); + } + + doUpdateBalls(count); + + if ( tfVBO[0] != 0 ) { + for ( int i = 0; i < tfVBO.length; i++ ) + glDeleteBuffers(tfVBO[i]); + } + + for ( int i = 0; i < tfVBO.length; i++ ) { + tfVBO[i] = glGenBuffers(); + glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, tfVBO[i]); + glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, sprites.backingByteBuffer(), GL_STATIC_DRAW); + } + + glBindBuffer(GL_ARRAY_BUFFER, tfVBO[0]); + glVertexPointer(2, GL_FLOAT, (4 * 4), 0); + } + + public void render(final boolean render, final boolean animate, final int delta) { + if ( animate ) { + glUseProgram(progIDTF); + glUniform1f(deltaLoc, delta); + + final int vbo = currVBO; + currVBO = 1 - currVBO; + + glBindBuffer(GL_ARRAY_BUFFER, tfVBO[vbo]); + glVertexPointer(4, GL_FLOAT, 0, 0); + + glEnable(GL_RASTERIZER_DISCARD); + if ( GLContext.getCapabilities().OpenGL30 ) { + glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfVBO[1 - vbo]); + + glBeginTransformFeedback(GL_POINTS); + glDrawArrays(GL_POINTS, 0, ballCount); + glEndTransformFeedback(); + } else { + glBindBufferBaseEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, tfVBO[1 - vbo]); + + glBeginTransformFeedbackEXT(GL_POINTS); + glDrawArrays(GL_POINTS, 0, ballCount); + glEndTransformFeedbackEXT(); + } + glDisable(GL_RASTERIZER_DISCARD); + + glUseProgram(progID); + glVertexPointer(2, GL_FLOAT, (4 * 4), 0); + } + + if ( render ) + glDrawArrays(GL_POINTS, 0, ballCount); + } + + } + +} \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -31,6 +31,9 @@ */ package org.lwjgl.util.mapped; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.MemoryUtil; + import java.nio.ByteBuffer; /** @@ -43,30 +46,32 @@ public class MappedHelper { public static void setup(MappedObject mo, ByteBuffer buffer, int align, int sizeof) { - if ( mo.baseAddress != 0L ) + if ( LWJGLUtil.CHECKS && mo.baseAddress != 0L ) throw new IllegalStateException("this method should not be called by user-code"); - if ( buffer == null ) - throw new NullPointerException("buffer"); - if ( !buffer.isDirect() ) + if ( LWJGLUtil.CHECKS && !buffer.isDirect() ) throw new IllegalArgumentException("bytebuffer must be direct"); mo.preventGC = buffer; - if ( align <= 0 ) + if ( LWJGLUtil.CHECKS && align <= 0 ) throw new IllegalArgumentException("invalid alignment"); mo.align = align; - if ( sizeof % align != 0 ) + if ( LWJGLUtil.CHECKS && (sizeof <= 0 || sizeof % align != 0) ) throw new IllegalStateException("sizeof not a multiple of alignment"); mo.sizeof = sizeof; - long addr = MappedObjectUnsafe.getBufferBaseAddress(buffer) + buffer.position(); - if ( addr % align != 0 ) + long addr = MemoryUtil.getAddress(buffer); + if ( LWJGLUtil.CHECKS && addr % align != 0 ) throw new IllegalStateException("buffer address not aligned on " + align + " bytes"); mo.baseAddress = mo.viewAddress = addr; } + public static void checkAddress(MappedObject mapped, long viewAddress) { + mapped.checkAddress(viewAddress); + } + public static void put_views(MappedSet2 set, int view) { set.view(view); } @@ -87,6 +92,14 @@ return (int)(mapped.viewAddress - mapped.baseAddress) / sizeof; } + public static void put_view_shift(MappedObject mapped, int view, int sizeof_shift) { + mapped.setViewAddress(mapped.baseAddress + (view << sizeof_shift)); + } + + public static int get_view_shift(MappedObject mapped, int sizeof_shift) { + return ((int)(mapped.viewAddress - mapped.baseAddress)) >> sizeof_shift; + } + public static void put_view_next(MappedObject mapped, int sizeof) { mapped.setViewAddress(mapped.viewAddress + sizeof); } @@ -130,68 +143,124 @@ MappedObjectUnsafe.INSTANCE.putByte(addr, value); } + public static void bput(MappedObject mapped, byte value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putByte(mapped.viewAddress + fieldOffset, value); + } + public static byte bget(long addr) { return MappedObjectUnsafe.INSTANCE.getByte(addr); } + public static byte bget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getByte(mapped.viewAddress + fieldOffset); + } + // short public static void sput(short value, long addr) { MappedObjectUnsafe.INSTANCE.putShort(addr, value); } + public static void sput(MappedObject mapped, short value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putShort(mapped.viewAddress + fieldOffset, value); + } + public static short sget(long addr) { return MappedObjectUnsafe.INSTANCE.getShort(addr); } + public static short sget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getShort(mapped.viewAddress + fieldOffset); + } + // char public static void cput(char value, long addr) { MappedObjectUnsafe.INSTANCE.putChar(addr, value); } + public static void cput(MappedObject mapped, char value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putChar(mapped.viewAddress + fieldOffset, value); + } + public static char cget(long addr) { return MappedObjectUnsafe.INSTANCE.getChar(addr); } + public static char cget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getChar(mapped.viewAddress + fieldOffset); + } + // int public static void iput(int value, long addr) { MappedObjectUnsafe.INSTANCE.putInt(addr, value); } - public static int iget(long addr) { - return MappedObjectUnsafe.INSTANCE.getInt(addr); + public static void iput(MappedObject mapped, int value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putInt(mapped.viewAddress + fieldOffset, value); } + public static int iget(long address) { + return MappedObjectUnsafe.INSTANCE.getInt(address); + } + + public static int iget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getInt(mapped.viewAddress + fieldOffset); + } + // float public static void fput(float value, long addr) { MappedObjectUnsafe.INSTANCE.putFloat(addr, value); } + public static void fput(MappedObject mapped, float value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value); + } + public static float fget(long addr) { return MappedObjectUnsafe.INSTANCE.getFloat(addr); } + public static float fget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getFloat(mapped.viewAddress + fieldOffset); + } + // long public static void jput(long value, long addr) { MappedObjectUnsafe.INSTANCE.putLong(addr, value); } + public static void jput(MappedObject mapped, long value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putLong(mapped.viewAddress + fieldOffset, value); + } + public static long jget(long addr) { return MappedObjectUnsafe.INSTANCE.getLong(addr); } + public static long lget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset); + } + // double public static void dput(double value, long addr) { MappedObjectUnsafe.INSTANCE.putDouble(addr, value); } + public static void dput(MappedObject mapped, double value, int fieldOffset) { + MappedObjectUnsafe.INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value); + } + public static double dget(long addr) { return MappedObjectUnsafe.INSTANCE.getDouble(addr); } + public static double dget(MappedObject mapped, int fieldOffset) { + return MappedObjectUnsafe.INSTANCE.getDouble(mapped.viewAddress + fieldOffset); + } + } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -32,6 +32,7 @@ package org.lwjgl.util.mapped; import org.lwjgl.LWJGLUtil; +import org.lwjgl.MemoryUtil; import java.nio.BufferOverflowException; import java.nio.ByteBuffer; @@ -93,7 +94,7 @@ } final void checkAddress(final long address) { - final long base = MappedObjectUnsafe.getBufferBaseAddress(preventGC); + final long base = MemoryUtil.getAddress0(preventGC); final int offset = (int)(address - base); if ( address < base || preventGC.capacity() < (offset + this.sizeof) ) throw new IndexOutOfBoundsException(Integer.toString(offset / sizeof)); @@ -103,7 +104,7 @@ if ( bytes < 0 ) throw new IllegalArgumentException(); - if ( preventGC.capacity() < (viewAddress - MappedObjectUnsafe.getBufferBaseAddress(preventGC) + bytes) ) + if ( preventGC.capacity() < (viewAddress - MemoryUtil.getAddress0(preventGC) + bytes) ) throw new BufferOverflowException(); } @@ -155,7 +156,7 @@ /** * Creates an identical new MappedObject instance, comparable to the - * contract of {@link ByteBuffer#duplicate}. This is useful when more than one + * contract of {@link java.nio.ByteBuffer#duplicate}. This is useful when more than one * views of the mapped object are required at the same time, e.g. in * multithreaded access. */ @@ -166,7 +167,7 @@ /** * Creates a new MappedObject instance, with a base offset equal to - * the offset of the current view, comparable to the contract of {@link ByteBuffer#slice}. + * the offset of the current view, comparable to the contract of {@link java.nio.ByteBuffer#slice}. */ public final <T extends MappedObject> T slice() { // any method that calls this method will have its call-site modified @@ -188,6 +189,11 @@ throw new InternalError("type not registered"); } + /** Moves the current view to the next element. Non-transformed implementation for MappedSets. */ + final void nextSet() { + setViewAddress(viewAddress + sizeof); + } + /** * Copies and amount of <code>SIZEOF</code> bytes, from the current * mapped object, to the specified mapped object. @@ -220,10 +226,16 @@ return new MappedForeach<T>(mapped, elementCount); } + @SuppressWarnings("unused") + public final <T extends MappedObject> T[] asArray() { + // any method that calls this method will have its call-site modified + throw new InternalError("type not registered"); + } + ByteBuffer preventGC; /** - * Returns the {@link ByteBuffer} that backs this mapped object. + * Returns the {@link java.nio.ByteBuffer} that backs this mapped object. * * @return the backing buffer */ Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -117,7 +117,7 @@ byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class"))); long t0 = System.nanoTime(); - bytecode = MappedObjectTransformer.transformFieldAccess(className, bytecode); + bytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode); long t1 = System.nanoTime(); total_time_transforming += (t1 - t0); Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-21 22:52:16 UTC (rev 3596) +++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-22 02:01:56 UTC (rev 3597) @@ -1,21 +1,51 @@ /* - * Created on Jun 23, 2011 + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - package org.lwjgl.util.mapped; import org.lwjgl.LWJGLUtil; import org.objectweb.asm.*; +import org.objectweb.asm.tree.*; +import org.objectweb.asm.tree.analysis.*; import org.objectweb.asm.util.TraceClassVisitor; -import java.io.*; +import java.io.PrintWriter; +import java.io.StringWriter; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Map; -import java.util.StringTokenizer; +import static org.objectweb.asm.ClassWriter.*; import static org.objectweb.asm.Opcodes.*; /** @@ -25,7 +55,7 @@ * The transformer supports some debugging tools, enabled through JVM system properties:<br/> * org.lwjgl.util.mapped.PrintTiming=true, prints timing information for the transformation step.<br/> * org.lwjgl.util.mapped.PrintActivity=true, prints activity information.<br/> - * org.lwjgl.util.mapped.PrintBytecode=true, prints the transformed bytecode. [not working atm]<br/> + * org.lwjgl.util.mapped.PrintBytecode=true, prints the transformed bytecode.<br/> * org.lwjgl.util.Debug must also be set to true for the above to work. * * @author Riven @@ -41,7 +71,24 @@ static final String MAPPED_OBJECT_JVM = jvmClassName(MappedObject.class); static final String MAPPED_HELPER_JVM = jvmClassName(MappedHelper.class); + static final String MAPPEDSET_PREFIX = jvmClassName(MappedSet.class); + static final String MAPPED_SET2_JVM = jvmClassName(MappedSet2.class); + static final String MAPPED_SET3_JVM = jvmClassName(MappedSet3.class); + static final String MAPPED_SET4_JVM = jvmClassName(MappedSet4.class); + + static final String LENGTH_METHOD_NAME = "length$LWJGL"; + static final String VIEWADDRESS_METHOD_NAME = "getViewAddress$LWJGL"; + static final String VIEW_CONSTRUCTOR_NAME = "constructView$LWJGL"; + + static final Map<Integer, String> OPCODE_TO_NAME = new HashMap<Integer, String>(); + static final Map<Integer, String> INSNTYPE_TO_NAME = new HashMap<Integer, String>(); + + static boolean is_currently_computing_frames; + static { + getClassEnums(Opcodes.class, OPCODE_TO_NAME, "V1_", "ACC_", "T_", "F_", "MH_"); + getClassEnums(AbstractInsnNode.class, INSNTYPE_TO_NAME); + className_to_subtype = new HashMap<String, MappedSubtypeInfo>(); { @@ -59,11 +106,10 @@ // => IADD // => PUTFIELD MyMappedType.view // - MappedSubtypeInfo info = new MappedSubtypeInfo(MAPPED_OBJECT_JVM, -1, -1); - className_to_subtype.put(info.className, info); + className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, -1, -1)); } - String vmName = System.getProperty("java.vm.name"); + final String vmName = System.getProperty("java.vm.name"); if ( vmName != null && !vmName.contains("Server") ) { System.err.println("Warning: " + MappedObject.class.getSimpleName() + "s have inferiour performance on Client VMs, please consider switching to a Server VM."); } @@ -71,7 +117,7 @@ /** * Registers a class as a mapped object. - * The class must extend {@link MappedObject} and be annotated with {@link MappedField}. + * The class must extend {@link org.lwjgl.util.mapped.MappedObject} and be annotated with {@link org.lwjgl.util.mapped.MappedField}. * * @param type the mapped object class. */ @@ -79,585 +125,992 @@ if ( MappedObjectClassLoader.FORKED ) return; - MappedType mapped = type.getAnnotation(MappedType.class); + final MappedType mapped = type.getAnnotation(MappedType.class); if ( mapped == null ) throw new InternalError("missing " + MappedType.class.getName() + " annotation"); if ( type.getEnclosingClass() != null && !Modifier.isStatic(type.getModifiers()) ) throw new InternalError("only top-level or static inner classes are allowed"); - String className = jvmClassName(type); + final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(jvmClassName(type), mapped.sizeof(), mapped.align()); - MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, mapped.sizeof(), mapped.align()); - int advancingOffset = 0; + for ( Field field : type.getDeclaredFields() ) + advancingOffset += registerField(mapped, mappedType.className, mappedType, advancingOffset, field); - for ( Field field : type.getDeclaredFields() ) { - // static fields are never mapped - if ( Modifier.isStatic(field.getModifiers()) ) - continue; + if ( className_to_subtype.put(mappedType.className, mappedType) != null ) + throw new InternalError("duplicate mapped type: " + mappedType.className); + } - // we only support primitives and ByteBuffers - if ( !field.getType().isPrimitive() && field.getType() != ByteBuffer.class ) - throw new InternalError("field '" + className + "." + field.getName() + "' not supported: " + field.getType()); + private static int registerField(final MappedType mapped, final String className, final MappedSubtypeInfo mappedType, int advancingOffset, final Field field) { + if ( Modifier.isStatic(field.getModifiers()) ) // static fields are never mapped + return 0; - MappedField meta = field.getAnnotation(MappedField.class); - if ( meta == null && !mapped.autoGenerateOffsets() ) - throw new InternalError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className); + // we only support primitives and ByteBuffers + if ( !field.getType().isPrimitive() && field.getType() != ByteBuffer.class ) + throw new InternalError("field '" + className + "." + field.getName() + "' not supported: " + field.getType()); - // quick hack - long byteOffset = meta == null ? advancingOffset : meta.byteOffset(); - long byteLength; - if ( field.getType() == long.class || field.getType() == double.class ) - byteLength = 8; - else if ( field.getType() == int.class || field.getType() == float.class ) - byteLength = 4; - else if ( field.getType() == char.class || field.getType() == short.class ) - byteLength = 2; - else if ( field.getType() == byte.class ) - byteLength = 1; - else if ( field.getType() == ByteBuffer.class ) { - byteLength = meta.byteLength(); - if ( byteLength < 0 ) - throw new IllegalStateException("invalid byte length for mapped ByteBuffer field: " + className + "." + field.getName() + " [length=" + byteLength + "]"); - } else - throw new IllegalStateException(field.getType().getName()); + MappedField meta = field.getAnnotation(MappedField.class); + if ( meta == null && !mapped.autoGenerateOffsets() ) + throw new InternalError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className); - if ( field.getType() != ByteBuffer.class ) - if ( (advancingOffset % byteLength) != 0 ) - throw new IllegalStateException("misaligned mapped type: " + className + "." + field.getName()); + // quick hack + long byteOffset = meta == null ? advancingOffset : meta.byteOffset(); + long byteLength; + if ( field.getType() == long.class || field.getType() == double.class ) + byteLength = 8; + else if ( field.getType() == int.class || field.getType() == float.class ) + byteLength = 4; + else if ( field.getType() == char.class || field.getType() == short.class ) + byteLength = 2; + else if ( field.getType() == byte.class ) + byteLength = 1; + else if ( field.getType() == ByteBuffer.class ) { + byteLength = meta.byteLength(); + if ( byteLength < 0 ) + throw new IllegalStateException("invalid byte length for mapped ByteBuffer field: " + className + "." + field.getName() + " [length=" + byteLength + "]"); + } else + throw new InternalError(field.getType().getName()); - if ( PRINT_ACTIVITY ) - LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]"); + if ( field.getType() != ByteBuffer.class && (advancingOffset % byteLength) != 0 ) + throw new IllegalStateException("misaligned mapped type: " + className + "." + field.getName()); - mappedType.fieldToOffset.put(field.getName(), byteOffset); - mappedType.fieldToLength.put(field.getName(), byteLength); + if ( PRINT_ACTIVITY ) + LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]"); - advancingOffset += byteLength; - } + mappedType.fieldToOffset.put(field.getName(), byteOffset); + mappedType.fieldToLength.put(field.getName(), byteLength); + mappedType.fieldToType.put(field.getName(), Type.getType(field.getType())); - if ( className_to_subtype.put(className, mappedType) != null ) { - throw new InternalError("duplicate mapped type: " + className); - } + return (int)byteLength; } - static boolean is_currently_computing_frames = false; - static final String view_constructor_method = "_construct_view_"; + static byte[] transformMappedAPI(final String className, byte[] bytecode) { + final ClassWriter cw = new ClassWriter(COMPUTE_FRAMES) { - static byte[] transformFieldAccess(final String className, byte[] bytecode) { - int flags = ClassWriter.COMPUTE_FRAMES; - - ClassWriter writer = new ClassWriter(flags) { - // HACK: prevent user-code static-initialization-blocks to be executed - @Override protected String getCommonSuperClass(String a, String b) { - if ( is_currently_computing_frames ) - if ( !a.startsWith("java/") || !b.startsWith("java/") ) - return "java/lang/Object"; + // HACK: prevent user-code static-initialization-blocks to be executed + if ( is_currently_computing_frames && !a.startsWith("java/") || !b.startsWith("java/") ) + return "java/lang/Object"; + return super.getCommonSuperClass(a, b); } + }; - ClassAdapter adapter = new ClassAdapter(writer) { + ClassVisitor cv = getTransformationAdapter(className, cw); + if ( className_to_subtype.containsKey(className) ) // Do a first pass to generate address getters + cv = getMethodGenAdapter(className, cv); + + //cr.accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); + new ClassReader(bytecode).accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); + bytecode = cw.toByteArray(); + + if ( PRINT_BYTECODE ) + printBytecode(bytecode); + + return bytecode; + } + + private static ClassAdapter getMethodGenAdapter(final String className, final ClassVisitor cv) { + return new ClassAdapter(cv) { + @Override - public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - { - MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); + public void visitEnd() { + generateViewAddressGetter(); + generateLengthGetter(); - if ( mappedSubtype != null && !mappedSubtype.className.equals(MAPPED_OBJECT_JVM) ) { - if ( "<init>".equals(name) ) { - if ( !"()V".equals(desc) ) - throw new IllegalStateException(className + " can only have a default constructor, found: " + desc); + final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className); - MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); - mv.visitCode(... [truncated message content] |
From: <ma...@us...> - 2011-07-21 22:52:23
|
Revision: 3596 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3596&view=rev Author: matzon Date: 2011-07-21 22:52:16 +0000 (Thu, 21 Jul 2011) Log Message: ----------- Initial stab at win32 resize api Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-17 09:37:35 UTC (rev 3595) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-21 22:52:16 UTC (rev 3596) @@ -41,6 +41,7 @@ import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.nio.LongBuffer; import java.awt.Canvas; import org.lwjgl.LWJGLException; @@ -66,7 +67,10 @@ private static final int WM_MBUTTONDBLCLK = 0x0209; private static final int WM_MOUSEWHEEL = 0x020A; private static final int WM_CAPTURECHANGED = 0x0215; - private static final int WM_MOUSELEAVE = 0x02A3; + private static final int WM_MOUSELEAVE = 0x02A3; + private static final int WM_ENTERSIZEMOVE = 0x0231; + private static final int WM_EXITSIZEMOVE = 0x0232; + private static final int WM_SIZING = 0x0214; private static final int WM_KEYDOWN = 256; private static final int WM_KEYUP = 257; private static final int WM_SYSKEYUP = 261; @@ -115,6 +119,7 @@ private static final int WA_INACTIVE = 0; private static final int WA_ACTIVE = 1; private static final int WA_CLICKACTIVE = 2; + private static final int SW_NORMAL = 1; private static final int SW_SHOWMINNOACTIVE = 7; private static final int SW_SHOWDEFAULT = 10; private static final int SW_RESTORE = 9; @@ -124,6 +129,23 @@ private static final IntBuffer rect_buffer = BufferUtils.createIntBuffer(4); private static final Rect rect = new Rect(); + + private static final long HWND_TOP = 0; + private static final long HWND_BOTTOM = 1; + private static final long HWND_TOPMOST = -1; + private static final long HWND_NOTOPMOST = -2; + + private static final int SWP_NOSIZE = 0x0001; + private static final int SWP_NOMOVE = 0x0002; + private static final int SWP_NOZORDER = 0x0004; + private static final int SWP_FRAMECHANGED = 0x0020; + + private static final int GWL_STYLE = -16; + private static final int GWL_EXSTYLE = -20; + + private static final int WS_THICKFRAME = 0x00040000; + + private static WindowsDisplay current_display; private static boolean cursor_clipped; @@ -147,6 +169,10 @@ private boolean isFocused; private boolean did_maximize; private boolean inAppActivate; + private boolean resized; + private boolean resizable; + private int width; + private int height; private long hwnd; private long hdc; @@ -191,7 +217,13 @@ } peer_info.initDC(getHwnd(), getHdc()); showWindow(getHwnd(), SW_SHOWDEFAULT); + + updateWidthAndHeight(); + if ( parent == null ) { + if(Display.isResizable()) { + setResizable(true); + } setForegroundWindow(getHwnd()); setFocus(getHwnd()); } @@ -201,6 +233,14 @@ throw e; } } + + private void updateWidthAndHeight() { + getClientRect(hwnd, rect_buffer); + rect.copyFromBuffer(rect_buffer); + width = rect.right - rect.left; + height = rect.bottom - rect.top; + } + private static native long nCreateWindow(int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; private static boolean isUndecorated() { @@ -695,6 +735,9 @@ private static native long createIcon(int width, int height, IntBuffer icon); private static native void destroyIcon(long handle); private static native long sendMessage(long hwnd, long msg, long wparam, long lparam); + private static native long setWindowLongPtr(long hwnd, int nindex, long longPtr); + private static native long getWindowLongPtr(long hwnd, int nindex); + private static native boolean setWindowPos(long hwnd, long hwnd_after, int x, int y, int cx, int cy, long uflags); private void handleMouseButton(int button, int state, long millis) { if (mouse != null) { @@ -820,6 +863,14 @@ break; } return defWindowProc(hwnd, msg, wParam, lParam); + case WM_ENTERSIZEMOVE: + return defWindowProc(hwnd, msg, wParam, lParam); + case WM_EXITSIZEMOVE: + return defWindowProc(hwnd, msg, wParam, lParam); + case WM_SIZING: + resized = true; + updateWidthAndHeight(); + return defWindowProc(hwnd, msg, wParam, lParam); case WM_KILLFOCUS: appActivate(false); return 0; @@ -900,10 +951,10 @@ case WM_PAINT: is_dirty = true; return defWindowProc(hwnd, msg, wParam, lParam); - case WM_MOUSELEAVE: - mouseInside = false; - trackingMouse = false; - return defWindowProc(hwnd, msg, wParam, lParam); + case WM_MOUSELEAVE: + mouseInside = false; + trackingMouse = false; + return defWindowProc(hwnd, msg, wParam, lParam); case WM_CANCELMODE: nReleaseCapture(); /* fall through */ @@ -919,11 +970,11 @@ } public int getWidth() { - return Display.getDisplayMode().getWidth(); + return width; } public int getHeight() { - return Display.getDisplayMode().getHeight(); + return height; } private int firstMouseButtonDown() { @@ -942,10 +993,40 @@ } public void setResizable(boolean resizable) { - + if(this.resizable != resizable) { + long style = getWindowLongPtr(hwnd, GWL_STYLE); + long styleex = getWindowLongPtr(hwnd, GWL_EXSTYLE); + + // update frame style + if(resizable) { + setWindowLongPtr(hwnd, GWL_STYLE, style |= WS_THICKFRAME); + } else { + setWindowLongPtr(hwnd, GWL_STYLE, style &= ~WS_THICKFRAME); + } + + // from the existing client rect, determine the new window rect + // based on the style changes - using AdjustWindowRectEx. + getClientRect(hwnd, rect_buffer); + rect.copyFromBuffer(rect_buffer); + adjustWindowRectEx(rect_buffer, style, false, styleex); + rect.copyFromBuffer(rect_buffer); + + // force a frame update and resize accordingly + setWindowPos(hwnd, HWND_TOP, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); + + updateWidthAndHeight(); + resized = false; + } + this.resizable = resizable; } + private native boolean adjustWindowRectEx(IntBuffer rectBuffer, long style, boolean menu, long styleex); + public boolean wasResized() { + if(resized) { + resized = false; + return true; + } return false; } @@ -981,7 +1062,7 @@ } public String toString() { - return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right; + return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right + ", width: " + (right - left) + ", height: " + (bottom - top); } } } Modified: trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java 2011-07-17 09:37:35 UTC (rev 3595) +++ trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java 2011-07-21 22:52:16 UTC (rev 3596) @@ -354,6 +354,10 @@ if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { Mouse.setGrabbed(!Mouse.isGrabbed()); } + + if(Keyboard.getEventKey() == Keyboard.KEY_R && Keyboard.getEventKeyState()) { + Display.setResizable(!Display.isResizable()); + } } } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2011-07-17 09:37:35 UTC (rev 3595) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2011-07-21 22:52:16 UTC (rev 3596) @@ -427,6 +427,32 @@ return SendMessage(hwnd, (UINT)msg, (WPARAM)wparam, (LPARAM)lparam); } +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowLongPtr + (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex, jlong longPtr) { + + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + return SetWindowLongPtr(hwnd, nindex, (LONG_PTR) longPtr); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowLongPtr + (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex) { + + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + jlong result = GetWindowLongPtr(hwnd, nindex); + return result; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowPos + (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hwnd_after_ptr, jint x, jint y, jint width, jint height, jlong uflags) { + + jboolean result; + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + HWND hwnd_after = (HWND)(INT_PTR)hwnd_after_ptr; + + result = SetWindowPos(hwnd, hwnd_after, x, y, width, height, (UINT) uflags); + return result; +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition (JNIEnv * env, jclass unused, jint x, jint y) { if (!SetCursorPos(x, y)) @@ -441,6 +467,16 @@ copyRectToBuffer(env, &clientRect, rect_buffer); } +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_adjustWindowRectEx + (JNIEnv *env, jclass unused, jobject rect_buffer, jlong style, jboolean menu, jlong styleex) { + jboolean result; + RECT clientRect; + copyBufferToRect(env, rect_buffer, &clientRect); + result = AdjustWindowRectEx(&clientRect, style, menu, styleex); + copyRectToBuffer(env, &clientRect, rect_buffer); + return result; +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetNativeCursor (JNIEnv *env, jclass unused, jlong hwnd_int, jobject handle_buffer) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-17 09:37:41
|
Revision: 3595 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3595&view=rev Author: spasi Date: 2011-07-17 09:37:35 +0000 (Sun, 17 Jul 2011) Log Message: ----------- Code cleanup. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-16 22:40:06 UTC (rev 3594) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-17 09:37:35 UTC (rev 3595) @@ -50,20 +50,29 @@ private static final int BUFFERS_SIZE = 32; - private char[] arrayTL; - private ByteBuffer bufferTL; - private IntBuffer lengthsTL; - private final Buffers buffersTL; + private char[] array; + private ByteBuffer buffer; + private IntBuffer lengths; + private final IntBuffer ints; + private final LongBuffer longs; + private final FloatBuffer floats; + private final DoubleBuffer doubles; + APIUtil() { - arrayTL = new char[INITIAL_BUFFER_SIZE]; - bufferTL = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); - lengthsTL = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); - buffersTL = new Buffers(); + array = new char[INITIAL_BUFFER_SIZE]; + buffer = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); + lengths = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); + + ints = BufferUtils.createIntBuffer(BUFFERS_SIZE); + longs = BufferUtils.createLongBuffer(BUFFERS_SIZE); + + floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE); + doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE); } private static char[] getArray(final ContextCapabilities caps, final int size) { - char[] array = caps.util.arrayTL; + char[] array = caps.util.array; if ( array.length < size ) { int sizeNew = array.length << 1; @@ -71,14 +80,14 @@ sizeNew <<= 1; array = new char[size]; - caps.util.arrayTL = array; + caps.util.array = array; } return array; } static ByteBuffer getBufferByte(final ContextCapabilities caps, final int size) { - ByteBuffer buffer = caps.util.bufferTL; + ByteBuffer buffer = caps.util.buffer; if ( buffer.capacity() < size ) { int sizeNew = buffer.capacity() << 1; @@ -86,7 +95,7 @@ sizeNew <<= 1; buffer = BufferUtils.createByteBuffer(size); - caps.util.bufferTL = buffer; + caps.util.buffer = buffer; } else buffer.clear(); @@ -94,7 +103,7 @@ } private static ByteBuffer getBufferByteOffset(final ContextCapabilities caps, final int size) { - ByteBuffer buffer = caps.util.bufferTL; + ByteBuffer buffer = caps.util.buffer; if ( buffer.capacity() < size ) { int sizeNew = buffer.capacity() << 1; @@ -103,7 +112,7 @@ final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size); bufferNew.put(buffer); - caps.util.bufferTL = (buffer = bufferNew); + caps.util.buffer = (buffer = bufferNew); } else { buffer.position(buffer.limit()); buffer.limit(buffer.capacity()); @@ -112,22 +121,20 @@ return buffer; } - static ShortBuffer getBufferShort(final ContextCapabilities caps) { return caps.util.buffersTL.shorts; } + static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.ints; } - static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.buffersTL.ints; } + static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.longs; } - static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.buffersTL.longs; } + static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.floats; } - static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.buffersTL.floats; } + static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.doubles; } - static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.buffersTL.doubles; } - static IntBuffer getLengths(final ContextCapabilities caps) { return getLengths(caps, 1); } static IntBuffer getLengths(final ContextCapabilities caps, final int size) { - IntBuffer lengths = caps.util.lengthsTL; + IntBuffer lengths = caps.util.lengths; if ( lengths.capacity() < size ) { int sizeNew = lengths.capacity(); @@ -135,7 +142,7 @@ sizeNew <<= 1; lengths = BufferUtils.createIntBuffer(size); - caps.util.lengthsTL = lengths; + caps.util.lengths = lengths; } else lengths.clear(); @@ -286,24 +293,4 @@ return MemoryUtil.getAddress0(getBufferByte(caps, 0)); } - private static class Buffers { - - final ShortBuffer shorts; - final IntBuffer ints; - final LongBuffer longs; - - final FloatBuffer floats; - final DoubleBuffer doubles; - - Buffers() { - shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE); - ints = BufferUtils.createIntBuffer(BUFFERS_SIZE); - longs = BufferUtils.createLongBuffer(BUFFERS_SIZE); - - floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE); - doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE); - } - - } - } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java 2011-07-16 22:40:06 UTC (rev 3594) +++ trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java 2011-07-17 09:37:35 UTC (rev 3595) @@ -39,9 +39,12 @@ import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; -import java.nio.ShortBuffer; -/** @author spasi */ +/** + * Utility class for OpenGL ES API calls. + * + * @author spasi + */ final class APIUtil { private static final int INITIAL_BUFFER_SIZE = 256; @@ -138,14 +141,10 @@ return buffer; } - static ShortBuffer getBufferShort() { return buffersTL.get().shorts; } - static IntBuffer getBufferInt() { return buffersTL.get().ints; } static FloatBuffer getBufferFloat() { return buffersTL.get().floats; } - static PointerBuffer getBufferPointer() { return buffersTL.get().pointers; } - static IntBuffer getLengths() { return getLengths(1); } @@ -312,18 +311,12 @@ private static class Buffers { - final ShortBuffer shorts; final IntBuffer ints; final FloatBuffer floats; - final PointerBuffer pointers; - Buffers() { - shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE); ints = BufferUtils.createIntBuffer(BUFFERS_SIZE); floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE); - - pointers = BufferUtils.createPointerBuffer(BUFFERS_SIZE); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-16 22:40:12
|
Revision: 3594 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3594&view=rev Author: spasi Date: 2011-07-16 22:40:06 +0000 (Sat, 16 Jul 2011) Log Message: ----------- Removed GLES dependency on GL APIUtil. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java 2011-07-16 22:26:46 UTC (rev 3593) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java 2011-07-16 22:40:06 UTC (rev 3594) @@ -31,6 +31,7 @@ */ package org.lwjgl.opengl; +import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.PointerBuffer; @@ -95,7 +96,7 @@ EGL_NATIVE_RENDERABLE, EGL_FALSE, }; - final EGLConfig[] configs = eglDisplay.chooseConfig(pf.getAttribBuffer(eglDisplay, eglSurfaceType, attribs), null, APIUtil.getBufferInt()); + final EGLConfig[] configs = eglDisplay.chooseConfig(pf.getAttribBuffer(eglDisplay, eglSurfaceType, attribs), null, BufferUtils.createIntBuffer(1)); if ( configs.length == 0 ) throw new LWJGLException("No EGLConfigs found for the specified PixelFormat."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2011-07-16 22:26:54
|
Revision: 3593 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3593&view=rev Author: spasi Date: 2011-07-16 22:26:46 +0000 (Sat, 16 Jul 2011) Log Message: ----------- Converted GL APIUtil to a per ContextCapabilities instance. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/TypeMap.java trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java trunk/LWJGL/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLESTypeMap.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL30.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL33.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL40.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL41.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_fence.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_occlusion_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2008 LWJGL Project + * Copyright (c) 2002-2011 LWJGL Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,35 +37,33 @@ import java.nio.*; -/** @author spasi */ +/** + * Utility class for OpenGL API calls. Instances of APIUtil are created in ContextCapabilities, + * so we have an instance per OpenGL context. + * + * @author spasi + */ final class APIUtil { - private static final int INITIAL_BUFFER_SIZE = 256; + private static final int INITIAL_BUFFER_SIZE = 256; private static final int INITIAL_LENGTHS_SIZE = 4; private static final int BUFFERS_SIZE = 32; - private static final ThreadLocal<char[]> arrayTL = new ThreadLocal<char[]>() { - protected char[] initialValue() { return new char[INITIAL_BUFFER_SIZE]; } - }; + private char[] arrayTL; + private ByteBuffer bufferTL; + private IntBuffer lengthsTL; + private final Buffers buffersTL; - private static final ThreadLocal<ByteBuffer> bufferTL = new ThreadLocal<ByteBuffer>() { - protected ByteBuffer initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); } - }; - - private static final ThreadLocal<IntBuffer> lengthsTL = new ThreadLocal<IntBuffer>() { - protected IntBuffer initialValue() { return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); } - }; - - private static final ThreadLocal<Buffers> buffersTL = new ThreadLocal<Buffers>() { - protected Buffers initialValue() { return new Buffers(); } - }; - - private APIUtil() { + APIUtil() { + arrayTL = new char[INITIAL_BUFFER_SIZE]; + bufferTL = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); + lengthsTL = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); + buffersTL = new Buffers(); } - private static char[] getArray(final int size) { - char[] array = arrayTL.get(); + private static char[] getArray(final ContextCapabilities caps, final int size) { + char[] array = caps.util.arrayTL; if ( array.length < size ) { int sizeNew = array.length << 1; @@ -73,14 +71,14 @@ sizeNew <<= 1; array = new char[size]; - arrayTL.set(array); + caps.util.arrayTL = array; } return array; } - static ByteBuffer getBufferByte(final int size) { - ByteBuffer buffer = bufferTL.get(); + static ByteBuffer getBufferByte(final ContextCapabilities caps, final int size) { + ByteBuffer buffer = caps.util.bufferTL; if ( buffer.capacity() < size ) { int sizeNew = buffer.capacity() << 1; @@ -88,15 +86,15 @@ sizeNew <<= 1; buffer = BufferUtils.createByteBuffer(size); - bufferTL.set(buffer); + caps.util.bufferTL = buffer; } else buffer.clear(); return buffer; } - private static ByteBuffer getBufferByteOffset(final int size) { - ByteBuffer buffer = bufferTL.get(); + private static ByteBuffer getBufferByteOffset(final ContextCapabilities caps, final int size) { + ByteBuffer buffer = caps.util.bufferTL; if ( buffer.capacity() < size ) { int sizeNew = buffer.capacity() << 1; @@ -105,7 +103,7 @@ final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size); bufferNew.put(buffer); - bufferTL.set(buffer = bufferNew); + caps.util.bufferTL = (buffer = bufferNew); } else { buffer.position(buffer.limit()); buffer.limit(buffer.capacity()); @@ -114,22 +112,22 @@ return buffer; } - static ShortBuffer getBufferShort() { return buffersTL.get().shorts; } + static ShortBuffer getBufferShort(final ContextCapabilities caps) { return caps.util.buffersTL.shorts; } - static IntBuffer getBufferInt() { return buffersTL.get().ints; } + static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.buffersTL.ints; } - static LongBuffer getBufferLong() { return buffersTL.get().longs; } + static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.buffersTL.longs; } - static FloatBuffer getBufferFloat() { return buffersTL.get().floats; } + static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.buffersTL.floats; } - static DoubleBuffer getBufferDouble() { return buffersTL.get().doubles; } + static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.buffersTL.doubles; } - static IntBuffer getLengths() { - return getLengths(1); + static IntBuffer getLengths(final ContextCapabilities caps) { + return getLengths(caps, 1); } - static IntBuffer getLengths(final int size) { - IntBuffer lengths = lengthsTL.get(); + static IntBuffer getLengths(final ContextCapabilities caps, final int size) { + IntBuffer lengths = caps.util.lengthsTL; if ( lengths.capacity() < size ) { int sizeNew = lengths.capacity(); @@ -137,7 +135,7 @@ sizeNew <<= 1; lengths = BufferUtils.createIntBuffer(size); - lengthsTL.set(lengths); + caps.util.lengthsTL = lengths; } else lengths.clear(); @@ -169,9 +167,9 @@ * * @return the buffer as a String. */ - static String getString(final ByteBuffer buffer) { + static String getString(final ContextCapabilities caps, final ByteBuffer buffer) { final int length = buffer.remaining(); - final char[] charArray = getArray(length); + final char[] charArray = getArray(caps, length); for ( int i = buffer.position(); i < buffer.limit(); i++ ) charArray[i - buffer.position()] = (char)buffer.get(i); @@ -186,8 +184,8 @@ * * @return the String as a ByteBuffer */ - static long getBuffer(final CharSequence string) { - final ByteBuffer buffer = encode(getBufferByte(string.length()), string); + static long getBuffer(final ContextCapabilities caps, final CharSequence string) { + final ByteBuffer buffer = encode(getBufferByte(caps, string.length()), string); buffer.flip(); return MemoryUtil.getAddress0(buffer); } @@ -199,8 +197,8 @@ * * @return the String as a ByteBuffer */ - static long getBuffer(final CharSequence string, final int offset) { - final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string); + static long getBuffer(final ContextCapabilities caps, final CharSequence string, final int offset) { + final ByteBuffer buffer = encode(getBufferByteOffset(caps, offset + string.length()), string); buffer.flip(); return MemoryUtil.getAddress(buffer); } @@ -212,8 +210,8 @@ * * @return the String as a ByteBuffer */ - static long getBufferNT(final CharSequence string) { - final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string); + static long getBufferNT(final ContextCapabilities caps, final CharSequence string) { + final ByteBuffer buffer = encode(getBufferByte(caps, string.length() + 1), string); buffer.put((byte)0); buffer.flip(); return MemoryUtil.getAddress0(buffer); @@ -234,8 +232,8 @@ * * @return the Strings as a ByteBuffer */ - static long getBuffer(final CharSequence[] strings) { - final ByteBuffer buffer = getBufferByte(getTotalLength(strings)); + static long getBuffer(final ContextCapabilities caps, final CharSequence[] strings) { + final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings)); for ( CharSequence string : strings ) encode(buffer, string); @@ -251,8 +249,8 @@ * * @return the Strings as a ByteBuffer */ - static long getBufferNT(final CharSequence[] strings) { - final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length); + static long getBufferNT(final ContextCapabilities caps, final CharSequence[] strings) { + final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings) + strings.length); for ( CharSequence string : strings ) { encode(buffer, string); @@ -270,8 +268,8 @@ * * @return the String lengths in an IntBuffer */ - static long getLengths(final CharSequence[] strings) { - IntBuffer buffer = getLengths(strings.length); + static long getLengths(final ContextCapabilities caps, final CharSequence[] strings) { + IntBuffer buffer = getLengths(caps, strings.length); for ( CharSequence string : strings ) buffer.put(string.length()); @@ -280,21 +278,21 @@ return MemoryUtil.getAddress0(buffer); } - static long getInt(final int value) { - return MemoryUtil.getAddress0(getBufferInt().put(0, value)); + static long getInt(final ContextCapabilities caps, final int value) { + return MemoryUtil.getAddress0(getBufferInt(caps).put(0, value)); } - static long getBufferByte0() { - return MemoryUtil.getAddress0(getBufferByte(0)); + static long getBufferByte0(final ContextCapabilities caps) { + return MemoryUtil.getAddress0(getBufferByte(caps, 0)); } private static class Buffers { final ShortBuffer shorts; - final IntBuffer ints; - final LongBuffer longs; + final IntBuffer ints; + final LongBuffer longs; - final FloatBuffer floats; + final FloatBuffer floats; final DoubleBuffer doubles; Buffers() { Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -301,13 +301,13 @@ } } else if ( method.getAnnotation(GLreturn.class) != null ) { has_result = true; - Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class)); + Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class), type_map); } writer.print(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific)); if (mode == Mode.BUFFEROBJECT) writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); writer.print("("); - boolean first_parameter = printMethodCallArguments(writer, method, typeinfos_instance, mode); + boolean first_parameter = printMethodCallArguments(writer, method, typeinfos_instance, mode, type_map); if (context_specific) { if (!first_parameter) writer.print(", "); @@ -335,7 +335,7 @@ else writer.println(tabs + "return " + Utils.RESULT_VAR_NAME + ";"); } else - Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class)); + Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class), type_map); } if ( code_annotation != null && code_annotation.tryBlock() ) { @@ -439,7 +439,7 @@ throw new RuntimeException(c + " is not allowed"); } - private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean first_parameter) { + private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean first_parameter, TypeMap type_map) { if (!first_parameter) writer.print(", "); @@ -496,7 +496,9 @@ writer.print("APIUtil.getBuffer"); if ( param.getAnnotation(NullTerminated.class) != null ) writer.print("NT"); - writer.print("(" + param.getSimpleName()); + writer.print('('); + writer.print(type_map.getAPIUtilParam(true)); + writer.print(param.getSimpleName()); if ( offset != null ) writer.print(", " + offset); writer.print(")"); @@ -531,7 +533,7 @@ return false; } - private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode) { + private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, TypeMap type_map) { boolean first_parameter = true; for ( ParameterDeclaration param : method.getParameters() ) { if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) ) @@ -539,7 +541,7 @@ final Constant constant_annotation = param.getAnnotation(Constant.class); if ( constant_annotation== null || !constant_annotation.isNative() ) - first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter); + first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter, type_map); } if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null) { if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/TypeMap.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/TypeMap.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/TypeMap.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -50,6 +50,7 @@ public interface TypeMap { void printCapabilitiesInit(PrintWriter writer); String getCapabilities(); + String getAPIUtilParam(boolean comma); void printErrorCheckMethod(PrintWriter writer, MethodDeclaration method, String tabs); String getRegisterNativesFunctionName(); PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class<? extends Annotation> native_type); Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -57,19 +57,19 @@ public class Utils { - public static final String TYPEDEF_POSTFIX = "PROC"; - public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer"; - public static final String FUNCTION_POINTER_POSTFIX = "_pointer"; - public static final String CHECKS_CLASS_NAME = "GLChecks"; - public static final String CONTEXT_CAPS_CLASS_NAME = "ContextCapabilities"; - public static final String STUB_INITIALIZER_NAME = "initNativeStubs"; - public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO"; - public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset"; - public static final String RESULT_SIZE_NAME = "result_size"; - public static final String RESULT_VAR_NAME = "__result"; - public static final String CACHED_BUFFER_LENGTH_NAME = "length"; - public static final String CACHED_BUFFER_NAME = "old_buffer"; - private static final String OVERLOADED_METHOD_PREFIX = "n"; + public static final String TYPEDEF_POSTFIX = "PROC"; + public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer"; + public static final String FUNCTION_POINTER_POSTFIX = "_pointer"; + public static final String CHECKS_CLASS_NAME = "GLChecks"; + public static final String CONTEXT_CAPS_CLASS_NAME = "ContextCapabilities"; + public static final String STUB_INITIALIZER_NAME = "initNativeStubs"; + public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO"; + public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset"; + public static final String RESULT_SIZE_NAME = "result_size"; + public static final String RESULT_VAR_NAME = "__result"; + public static final String CACHED_BUFFER_LENGTH_NAME = "length"; + public static final String CACHED_BUFFER_NAME = "old_buffer"; + private static final String OVERLOADED_METHOD_PREFIX = "n"; public static String getTypedefName(MethodDeclaration method) { Alternate alt_annotation = method.getAnnotation(Alternate.class); @@ -102,6 +102,7 @@ } private static class AnnotationMirrorComparator implements Comparator<AnnotationMirror> { + public int compare(AnnotationMirror a1, AnnotationMirror a2) { String n1 = a1.getAnnotationType().getDeclaration().getQualifiedName(); String n2 = a2.getAnnotationType().getDeclaration().getQualifiedName(); @@ -148,22 +149,22 @@ private static boolean hasParameterMultipleTypes(ParameterDeclaration param) { int num_native_annotations = 0; - for (AnnotationMirror annotation : param.getAnnotationMirrors()) - if (NativeTypeTranslator.getAnnotation(annotation, NativeType.class) != null) + for ( AnnotationMirror annotation : param.getAnnotationMirrors() ) + if ( NativeTypeTranslator.getAnnotation(annotation, NativeType.class) != null ) num_native_annotations++; return num_native_annotations > 1; } public static boolean isParameterMultiTyped(ParameterDeclaration param) { boolean result = Buffer.class.equals(Utils.getJavaType(param.getType())); - if (!result && hasParameterMultipleTypes(param)) + if ( !result && hasParameterMultipleTypes(param) ) throw new RuntimeException(param + " not defined as java.nio.Buffer but has multiple types"); return result; } public static ParameterDeclaration findParameter(MethodDeclaration method, String name) { - for (ParameterDeclaration param : method.getParameters()) - if (param.getSimpleName().equals(name)) + for ( ParameterDeclaration param : method.getParameters() ) + if ( param.getSimpleName().equals(name) ) return param; throw new RuntimeException("Parameter " + name + " not found"); } @@ -176,7 +177,7 @@ overloadsComment = null; String doc_comment = decl.getDocComment(); - if (doc_comment != null) { + if ( doc_comment != null ) { final String tab = decl instanceof InterfaceDeclaration ? "" : "\t"; writer.println(tab + "/**"); @@ -187,7 +188,7 @@ final StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n", true); boolean lastWasNL = false; - while (doc_lines.hasMoreTokens()) { + while ( doc_lines.hasMoreTokens() ) { final String t = doc_lines.nextToken(); if ( "\n".equals(t) ) { if ( lastWasNL ) @@ -205,8 +206,8 @@ } public static AnnotationMirror getParameterAutoAnnotation(ParameterDeclaration param) { - for (AnnotationMirror annotation : param.getAnnotationMirrors()) - if (NativeTypeTranslator.getAnnotation(annotation, Auto.class) != null) + for ( AnnotationMirror annotation : param.getAnnotationMirrors() ) + if ( NativeTypeTranslator.getAnnotation(annotation, Auto.class) != null ) return annotation; return null; } @@ -242,9 +243,9 @@ public static ParameterDeclaration getResultParameter(MethodDeclaration method) { ParameterDeclaration result_param = null; - for (ParameterDeclaration param : method.getParameters()) { - if (param.getAnnotation(Result.class) != null) { - if (result_param != null) + for ( ParameterDeclaration param : method.getParameters() ) { + if ( param.getAnnotation(Result.class) != null ) { + if ( result_param != null ) throw new RuntimeException("Multiple parameters annotated with Result in method " + method); result_param = param; } @@ -255,7 +256,7 @@ public static TypeMirror getMethodReturnType(MethodDeclaration method) { TypeMirror result_type; ParameterDeclaration result_param = getResultParameter(method); - if (result_param != null) { + if ( result_param != null ) { result_type = result_param.getType(); } else result_type = method.getReturnType(); @@ -291,20 +292,20 @@ public static void printExtraCallArguments(PrintWriter writer, MethodDeclaration method, String size_parameter_name) { writer.print(size_parameter_name); - if (method.getAnnotation(CachedResult.class) != null) { + if ( method.getAnnotation(CachedResult.class) != null ) { writer.print(", " + CACHED_BUFFER_NAME); } } private static String getClassName(InterfaceDeclaration interface_decl, String opengl_name) { Extension extension_annotation = interface_decl.getAnnotation(Extension.class); - if (extension_annotation != null && !"".equals(extension_annotation.className())) { + if ( extension_annotation != null && !"".equals(extension_annotation.className()) ) { return extension_annotation.className(); } StringBuilder result = new StringBuilder(); - for (int i = 0; i < opengl_name.length(); i++) { + for ( int i = 0; i < opengl_name.length(); i++ ) { int ch = opengl_name.codePointAt(i); - if (ch == '_') { + if ( ch == '_' ) { i++; result.appendCodePoint(Character.toUpperCase(opengl_name.codePointAt(i))); } else @@ -314,8 +315,8 @@ } public static boolean hasMethodBufferObjectParameter(MethodDeclaration method) { - for (ParameterDeclaration param : method.getParameters()) { - if (param.getAnnotation(BufferObject.class) != null) { + for ( ParameterDeclaration param : method.getParameters() ) { + if ( param.getAnnotation(BufferObject.class) != null ) { return true; } } @@ -332,7 +333,7 @@ public static Class<?> getNIOBufferType(TypeMirror t) { Class<?> param_type = getJavaType(t); - if (Buffer.class.isAssignableFrom(param_type)) + if ( Buffer.class.isAssignableFrom(param_type) ) return param_type; else if ( param_type == CharSequence.class || param_type == CharSequence[].class || param_type == PointerBuffer.class ) return ByteBuffer.class; @@ -344,7 +345,7 @@ String method_name; Alternate alt_annotation = method.getAnnotation(Alternate.class); method_name = alt_annotation == null || alt_annotation.nativeAlt() ? method.getSimpleName() : alt_annotation.value(); - if (isMethodIndirect(generate_error_checks, context_specific, method)) + if ( isMethodIndirect(generate_error_checks, context_specific, method) ) method_name = OVERLOADED_METHOD_PREFIX + method_name; return method_name; } @@ -392,15 +393,15 @@ return offset; } - static void printGLReturnPre(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) { + static void printGLReturnPre(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation, TypeMap type_map) { final String return_type = getMethodReturnType(method, return_annotation, true); if ( "String".equals(return_type) ) { if ( !return_annotation.forceMaxLength() ) { - writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtil.getLengths();"); + writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtil.getLengths(" + type_map.getAPIUtilParam(false) + ");"); writer.print("\t\t"); } - writer.print("ByteBuffer " + return_annotation.value() + " = APIUtil.getBufferByte(" + return_annotation.maxLength()); + writer.print("ByteBuffer " + return_annotation.value() + " = APIUtil.getBufferByte(" + type_map.getAPIUtilParam(true) + return_annotation.maxLength()); /* Params that use the return buffer will advance its position while filling it. When we return, the position will be at the right spot for grabbing the returned string bytes. We only have to make sure that the original buffer was @@ -412,9 +413,9 @@ writer.println(");"); } else { final String buffer_type = "Boolean".equals(return_type) ? "Byte" : return_type; - writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtil.getBuffer" + buffer_type + "("); + writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtil.getBuffer" + buffer_type + "(" + type_map.getAPIUtilParam(false)); if ( "Byte".equals(buffer_type) ) - writer.print('1'); + writer.print((type_map.getAPIUtilParam(false).length() > 0 ? ", " : "") + "1"); writer.println(");"); } @@ -426,20 +427,20 @@ writer.print("\t\t"); } - static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) { + static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation, TypeMap type_map) { final String return_type = getMethodReturnType(method, return_annotation, true); if ( "String".equals(return_type) ) { writer.print("\t\t" + return_annotation.value() + ".limit("); final String offset = getStringOffset(method, null); - if ( offset != null) + if ( offset != null ) writer.print(offset + " + "); if ( return_annotation.forceMaxLength() ) writer.print(return_annotation.maxLength()); else writer.print(return_annotation.value() + "_length.get(0)"); writer.println(");"); - writer.println("\t\treturn APIUtil.getString(" + return_annotation.value() + ");"); + writer.println("\t\treturn APIUtil.getString(" + type_map.getAPIUtilParam(true) + return_annotation.value() + ");"); } else { writer.print("\t\treturn " + return_annotation.value() + ".get(0)"); if ( "Boolean".equals(return_type) ) Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -178,6 +178,10 @@ throw new UnsupportedOperationException(); } + public String getAPIUtilParam(boolean comma) { + return ""; + } + public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) { writer.println(tabs + "Util.checkALError();"); } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -89,6 +89,10 @@ return "CLCapabilities"; } + public String getAPIUtilParam(boolean comma) { + return ""; + } + public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) { final Check check = method.getAnnotation(Check.class); if ( check != null ) // Get the error code from an IntBuffer output parameter Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -64,6 +64,7 @@ public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) { writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {"); writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";"); + writer.println("\tfinal APIUtil util = new APIUtil();"); writer.println("\tfinal StateTracker tracker = new StateTracker();"); writer.println(); if ( !context_specific ) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLESTypeMap.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLESTypeMap.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLESTypeMap.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -97,6 +97,10 @@ return "caps"; } + public String getAPIUtilParam(boolean comma) { + return ""; + } + public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) { writer.println(tabs + "Util.checkGLError();"); } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -106,6 +106,10 @@ return "caps"; } + public String getAPIUtilParam(boolean comma) { + return comma ? "caps, " : "caps"; + } + public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) { writer.println(tabs + "Util.checkGLError();"); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -58,7 +58,7 @@ void glDeleteNamesAMD(@GLenum int identifier, @AutoSize("names") @GLsizei int num, @Const @GLuint IntBuffer names); @Alternate("glDeleteNamesAMD") - void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtil.getInt(name)", keepParam = true) int name); + void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtil.getInt(caps, name)", keepParam = true) int name); boolean glIsNameAMD(@GLenum int identifier, @GLuint int name); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -100,12 +100,12 @@ void glDeletePerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @GLuint IntBuffer monitors); @Alternate("glDeletePerfMonitorsAMD") - void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(monitor)", keepParam = true) int monitor); + void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, monitor)", keepParam = true) int monitor); void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @AutoSize("counterList") int numCounters, @GLuint IntBuffer counterList); @Alternate("glSelectPerfMonitorCountersAMD") - void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getInt(counter)", keepParam = true) int counter); + void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getInt(caps, counter)", keepParam = true) int counter); void glBeginPerfMonitorAMD(@GLuint int monitor); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -55,7 +55,7 @@ void glDeleteFencesAPPLE(@AutoSize("fences") @GLsizei int n, @Const @GLuint IntBuffer fences); @Alternate("glDeleteFencesAPPLE") - void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(fence)", keepParam = true) int fence); + void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(caps, fence)", keepParam = true) int fence); void glSetFenceAPPLE(@GLuint int fence); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -52,7 +52,7 @@ void glDeleteVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays); @Alternate("glDeleteVertexArraysAPPLE") - void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(array)", keepParam = true) int array); + void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(caps, array)", keepParam = true) int array); void glGenVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -71,7 +71,7 @@ void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); @Alternate("glDeleteBuffersARB") - void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer); + void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer); void glGenBuffersARB(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -65,5 +65,5 @@ void glDrawBuffersARB(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers); @Alternate("glDrawBuffersARB") - void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer); + void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -197,7 +197,7 @@ @Reuse("GL30") @Alternate("glDeleteRenderbuffers") - void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(renderbuffer)", keepParam = true) int renderbuffer); + void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, renderbuffer)", keepParam = true) int renderbuffer); @Reuse("GL30") void glGenRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers); @@ -237,7 +237,7 @@ @Reuse("GL30") @Alternate("glDeleteFramebuffers") - void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(framebuffer)", keepParam = true) int framebuffer); + void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, framebuffer)", keepParam = true) int framebuffer); @Reuse("GL30") void glGenFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -68,7 +68,7 @@ void glDeleteQueriesARB(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids); @Alternate("glDeleteQueriesARB") - void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id); + void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id); boolean glIsQueryARB(@GLuint int id); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -128,7 +128,7 @@ void glDeleteProgramsARB(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs); @Alternate("glDeleteProgramsARB") - void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(program)", keepParam = true) int program); + void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, program)", keepParam = true) int program); void glGenProgramsARB(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -63,7 +63,7 @@ @Reuse("GL33") @Alternate("glDeleteSamplers") - void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getInt(sampler)", keepParam = true) int sampler); + void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getInt(caps, sampler)", keepParam = true) int sampler); @Reuse("GL33") boolean glIsSampler(@GLuint int sampler); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -98,7 +98,7 @@ @Reuse("GL41") @Alternate("glDeleteProgramPipelines") - void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(pipeline)", keepParam = true) int pipeline); + void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, pipeline)", keepParam = true) int pipeline); @Reuse("GL41") void glGenProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -110,7 +110,7 @@ @Alternate(value = "glShaderSourceARB", nativeAlt = true) void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count, @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings, - @Constant("APIUtil.getLengths(strings)") @Const IntBuffer length); + @Constant("APIUtil.getLengths(caps, strings)") @Const IntBuffer length); void glCompileShaderARB(@GLhandleARB int shaderObj); @@ -234,7 +234,7 @@ @Alternate(value = "glGetActiveUniformARB", javaAlt = true) @GLreturn(value = "name", maxLength = "maxLength") void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, - @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt()), MemoryUtil.getAddress(APIUtil.getBufferInt(), 1)") IntBuffer length, + @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length, @OutParameter @GLcharARB ByteBuffer name); /** Overloads glGetActiveUniformARB. This version returns only the uniform size. */ @@ -244,7 +244,7 @@ @OutParameter @GLsizei @Constant("0L") IntBuffer length, @OutParameter IntBuffer size, @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore - @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0()") ByteBuffer name); + @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name); /** Overloads glGetActiveUniformARB. This version returns only the uniform type. */ @Alternate(value = "glGetActiveUniformARB", javaAlt = true) @@ -253,7 +253,7 @@ @OutParameter @GLsizei @Constant("0L") IntBuffer length, @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore @OutParameter @GLenum IntBuffer type, - @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0()") ByteBuffer name); + @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name); @StripPostfix("params") void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -68,7 +68,7 @@ @Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true) void glCompileShaderIncludeARB2(@GLuint int shader, @Constant("path.length") @GLsizei int count, @Const @PointerArray(value = "count", lengths = "length") CharSequence[] path, - @Constant("APIUtil.getLengths(path)") @Const IntBuffer length); + @Constant("APIUtil.getLengths(caps, path)") @Const IntBuffer length); boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -61,7 +61,7 @@ @Reuse("GL40") @Alternate("glDeleteTransformFeedbacks") - void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id); + void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id); @Reuse("GL40") void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -55,7 +55,7 @@ @Reuse("GL30") @Alternate("glDeleteVertexArrays") - void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(array)", keepParam = true) int array); + void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, array)", keepParam = true) int array); @Reuse("GL30") void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -170,7 +170,7 @@ @Alternate(value = "glGetActiveAttribARB", javaAlt = true) @GLreturn(value = "name", maxLength = "maxLength") void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, - @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt()), MemoryUtil.getAddress(APIUtil.getBufferInt(), 1)") IntBuffer length, + @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length, @OutParameter @GLcharARB ByteBuffer name); /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */ @@ -180,7 +180,7 @@ @OutParameter @GLsizei @Constant("0L") IntBuffer length, @OutParameter IntBuffer size, @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore - @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0()") ByteBuffer name); + @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name); /** Overloads glGetActiveAttribARB. This version returns only the attrib type. */ @Alternate(value = "glGetActiveAttribARB", javaAlt = true) @@ -189,7 +189,7 @@ @OutParameter @GLsizei @Constant("0L") IntBuffer length, @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore @OutParameter @GLenum IntBuffer type, - @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0()") ByteBuffer name); + @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name); int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -65,5 +65,5 @@ void glDrawBuffersATI(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers); @Alternate("glDrawBuffersATI") - void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer); + void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -1075,7 +1075,7 @@ @Alternate("glTextureParameterIivEXT") @Dependent("GL_EXT_texture_integer") @StripPostfix("param") - void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param); + void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param); @Dependent("GL_EXT_texture_integer") @StripPostfix("params") @@ -1084,7 +1084,7 @@ @Alternate("glTextureParameterIuivEXT") @Dependent("GL_EXT_texture_integer") @StripPostfix("param") - void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) @GLuint int param); + void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) @GLuint int param); @Dependent("GL_EXT_texture_integer") @StripPostfix("params") @@ -1119,7 +1119,7 @@ @Alternate("glMultiTexParameterIivEXT") @Dependent("GL_EXT_texture_integer") @StripPostfix("param") - void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param); + void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param); @Dependent("GL_EXT_texture_integer") @StripPostfix("params") @@ -1128,7 +1128,7 @@ @Alternate("glMultiTexParameterIuivEXT") @Dependent("GL_EXT_texture_integer") @StripPostfix("param") - void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param); + void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param); @Dependent("GL_EXT_texture_integer") @StripPostfix("params") Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -136,7 +136,7 @@ void glDeleteRenderbuffersEXT(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers); @Alternate("glDeleteRenderbuffersEXT") - void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(renderbuffer)", keepParam = true) int renderbuffer); + void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(caps, renderbuffer)", keepParam = true) int renderbuffer); void glGenRenderbuffersEXT(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers); @@ -161,7 +161,7 @@ void glDeleteFramebuffersEXT(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers); @Alternate("glDeleteFramebuffersEXT") - void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(framebuffer)", keepParam = true) int framebuffer); + void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(caps, framebuffer)", keepParam = true) int framebuffer); void glGenFramebuffersEXT(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -118,14 +118,14 @@ @Alternate("glTexParameterIivEXT") @StripPostfix(value = "param", postfix = "v") - void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param); + void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param); @StripPostfix("params") void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); @Alternate("glTexParameterIuivEXT") @StripPostfix(value = "param", postfix = "v") - void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param); + void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param); @StripPostfix("params") void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -784,7 +784,7 @@ void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures); @Alternate("glDeleteTextures") - void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(texture)", keepParam = true) int texture); + void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, texture)", keepParam = true) int texture); void glCullFace(@GLenum int mode); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -97,7 +97,7 @@ void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); @Alternate("glDeleteBuffers") - void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer); + void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer); void glGenBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); @@ -205,7 +205,7 @@ void glDeleteQueries(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids); @Alternate("glDeleteQueries") - void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id); + void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id); boolean glIsQuery(@GLuint int id); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java 2011-07-16 19:40:16 UTC (rev 3592) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java 2011-07-16 22:26:46 UTC (rev 3593) @@ -108,7 +108,7 @@ @Alternate(value = "glShaderSource", nativeAlt = true) void glShaderSource3(@GLuint int shader, @Constant("strings.length") @GLsizei int count, @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings, - @Constant("APIUtil.getLengths(strings)") @Const IntBuffer length); + @Constant("APIUtil.getLengths(caps, strings)") @Const IntBuffer length); int glCreateShader(@GLuint int type); @@ -257,7 +257,7 @@ @Alternate(value = "glGetActiveUniform", javaAlt = true) @GLreturn(value = "name", maxLength = "maxLength") void glGetActiveUniform(@GLuint int program, @GLuint int index, @GLsizei int maxLength, - @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt()), MemoryUtil.getAddress(APIUtil.getBufferInt(), 1)") IntBuffer length, + @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length, @OutParameter @GLchar ByteBuffer name); /** Overloads glGetActiveUniform. This version returns only the uniform size. */ @@ -267,7 +267,7 @@ @OutParameter @GLsizei @Constant("0L") IntBuffer length, ... [truncated message content] |
From: <sp...@us...> - 2011-07-16 19:40:23
|
Revision: 3592 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3592&view=rev Author: spasi Date: 2011-07-16 19:40:16 +0000 (Sat, 16 Jul 2011) Log Message: ----------- Removed test code. /fail Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java Modified: trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-07-16 16:59:46 UTC (rev 3591) +++ trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-07-16 19:40:16 UTC (rev 3592) @@ -49,8 +49,7 @@ Accessor util; try { // Depends on java.nio.Buffer#address and sun.misc.Unsafe - //util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe"); - util = new AccessorJNI(); + util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe"); } catch (Exception e0) { try { // Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |